Skip to content

Game.Prefabs.ExtractorArea

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
ExtractorArea is a prefab component used for "extractor" style lots (forestry, mines, oil wells, etc.). It exposes configuration used at prefab-to-entity conversion: what natural map feature the extractor targets, how many decorative/harvested objects should spawn relative to extracted resource, the maximum surface area those objects can occupy, whether the extractor requires the underlying natural resource, and a work-vehicle multiplier. During prefab initialization this component writes an ExtractorAreaData component to the entity; it also contributes runtime archetype components (Extractor, OwnedVehicle and, for Forest map feature, WoodResource). This class is authored to be placed on a LotPrefab in the editor and read by the entity conversion pipeline.


Fields

  • public MapFeature m_MapFeature
    MapFeature enum that indicates which natural resource (FertileLand, Forest, Ore, Oil, etc.) this extractor uses. Controls conditional addition of WoodResource in GetArchetypeComponents when set to Forest.

  • public float m_ObjectSpawnFactor = 2f
    (Inspector tooltip: "Spawned object surface area per extracted resource amount") Multiplier that determines how much surface area of spawned objects (trees, rocks, ores, etc.) should be created per unit of extracted resource.

  • public float m_MaxObjectArea = 0.25f
    (Inspector tooltip: "Maximum object surface area proportion of total extractor area") The upper limit (as a fraction of the extractor's total area) for the cumulative surface area of spawned objects.

  • public bool m_RequireNaturalResource = true
    (Inspector tooltip: "Determines whether or not producing this resource requires a set Natural Resource; Fertile Land, Forest, Ore, Oil") If true, the extractor will only function when the underlying natural resource is present on the map.

  • public float m_WorkAmountFactor = 1f
    (Inspector tooltip: "The work vehicle spawn factor that multiply to extractor company's work amount") Multiplier applied to the extractor company's work amount for calculating required/used work vehicles or production scaling.

Properties

  • None (this component exposes public fields and writes a separate ExtractorAreaData component; it does not define C# properties).

Constructors

  • public ExtractorArea()
    Default ctor. Unity/serialization will initialize the component; the field defaults defined in the class (2f, 0.25f, true, 1f) are applied by the runtime/inspector.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the component types required on the prefab representation. Implementation adds ComponentType.ReadWrite() so that the ExtractorAreaData data is present on the created entity.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types to the entity archetype that extractor areas should have at runtime. Always adds ReadWrite() and ReadWrite(). If m_MapFeature == MapFeature.Forest, it also adds ReadWrite() to enable forest-specific resource systems.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called during prefab-to-entity conversion. Writes an ExtractorAreaData struct to the given entity with values copied from the inspector fields:

  • m_MapFeature
  • m_ObjectSpawnFactor
  • m_MaxObjectArea
  • m_RequireNaturalResource
  • m_WorkAmountFactor

This is the primary bridge that transfers designer-set values into ECS components used at runtime.

Usage Example

// Example: reading the data from a system after the prefab has been converted to an entity
protected override void OnUpdate()
{
    Entities.ForEach((Entity entity, in ExtractorAreaData data) =>
    {
        Debug.Log($"Extractor MapFeature: {data.m_MapFeature}, ObjectSpawnFactor: {data.m_ObjectSpawnFactor}");
        // Use data.m_RequireNaturalResource, data.m_MaxObjectArea, data.m_WorkAmountFactor as needed
    }).WithoutBurst().Run();
}