Skip to content

Game.Prefabs.ExtractorParameterData

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
struct

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
Data-only ECS component that holds numeric parameters for resource extractors (e.g., farms, fisheries, mines, oil extractors, forestry). Contains consumption rates and "full" capacity values used by systems that simulate or evaluate extractor production and resource depletion.


Fields

  • public float m_FertilityConsumption
    Consumption rate of soil fertility for fertility-based extractors (e.g., farms). Units and time base depend on the systems using this data (typically game ticks or seconds). Used to reduce local fertility when producing resources.

  • public float m_FishConsumption
    Consumption rate of fish stock for fishing extractors. Represents how quickly fish resources are consumed while producing output.

  • public float m_OreConsumption
    Consumption rate of ore for mining extractors. Used to deplete ore deposits as the extractor produces.

  • public float m_ForestConsumption
    Consumption rate of forest resources for forestry extractors (e.g., lumber/hardwood). Used to reduce local forest resource state.

  • public float m_OilConsumption
    Consumption rate of oil for oil extractors. Used to deplete oil resources when producing.

  • public float m_FullFertility
    Reference "full" fertility value for the extractor. Can be used as a normalization or threshold value to compute production multipliers.

  • public float m_FullFish
    Reference "full" fish stock value. Used similarly for normalization or to determine depleted vs. abundant states.

  • public float m_FullOre
    Reference "full" ore deposit value.

  • public float m_FullOil
    Reference "full" oil deposit value.

Properties

  • None declared on this struct. (The type implements IComponentData and IQueryTypeParameter and is intended as a plain data container.)

Constructors

  • public ExtractorParameterData() (implicit default)
    As a C# struct, it has an implicit parameterless constructor that initializes all floats to 0. If you need non-zero defaults, construct it explicitly (example shown below).

Methods

  • None declared. This is a plain data component; behavior is implemented in ECS systems that read or write this component.

Usage Example

using Unity.Entities;
using Game.Prefabs;

// Example: create and add the component to an entity with the EntityManager
public void AddExtractorParameters(EntityManager entityManager, Entity extractorEntity)
{
    var parameters = new ExtractorParameterData
    {
        m_FertilityConsumption = 0.5f,
        m_FishConsumption = 0.2f,
        m_OreConsumption = 1.0f,
        m_ForestConsumption = 0.6f,
        m_OilConsumption = 0.8f,
        m_FullFertility = 100f,
        m_FullFish = 50f,
        m_FullOre = 200f,
        m_FullOil = 150f
    };

    // If the entity already exists:
    if (entityManager.HasComponent<ExtractorParameterData>(extractorEntity))
    {
        entityManager.SetComponentData(extractorEntity, parameters);
    }
    else
    {
        entityManager.AddComponentData(extractorEntity, parameters);
    }
}

// Example: adding via EntityCommandBuffer in a system
public partial class ExtractorSetupSystem : SystemBase
{
    EndSimulationEntityCommandBufferSystem _ecbSystem;

    protected override void OnCreate()
    {
        _ecbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
    }

    protected override void OnUpdate()
    {
        var ecb = _ecbSystem.CreateCommandBuffer();
        Entities
            .WithNone<ExtractorParameterData>()
            .ForEach((Entity entity, in SomeExtractorTag tag) =>
            {
                var paramsData = new ExtractorParameterData
                {
                    m_OreConsumption = 1.2f,
                    m_FullOre = 250f
                    // other fields default to 0 unless set
                };
                ecb.AddComponent(entity, paramsData);
            }).Schedule();
        _ecbSystem.AddJobHandleForProducer(Dependency);
    }
}

Notes and tips: - This struct is blittable and suitable for high-performance ECS usage. - Be explicit about the time base (per second, per tick) when you set consumption values so that systems consuming these values interpret them correctly. - Systems that read this component should handle zero or missing "full" values gracefully (avoid division by zero when normalizing).