Skip to content

Game.Prefabs.DemandPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
DemandPrefab is a Prefab asset class that exposes tuning parameters used by the game's demand and spawning systems (households, workers, commuters, tourists, commercial/industrial demand, etc.). At runtime it copies these prefab values into a DemandParameterData component on a created entity (via LateInitialize) so the ECS systems can read the parameters. This prefab also declares that the DemandParameterData component is required for entities using this prefab.


Fields

  • public PrefabBase m_ForestryPrefab
    Reference to a forestry Prefab to be stored into DemandParameterData (resolved to an Entity in LateInitialize).

  • public PrefabBase m_OfficePrefab
    Reference to an office Prefab to be stored into DemandParameterData (resolved to an Entity in LateInitialize).

  • public int m_MinimumHappiness = 30
    Tooltip: "The minimum happiness value that affect the demanding, average happiness below this won't have any different"
    Minimum happiness used in demand calculations — values below this are treated as not providing additional effect.

  • public float m_HappinessEffect = 2f
    Tooltip: "The weight that multiply to the happiness value differ to the neutral"
    Multiplier applied to the difference between current and neutral happiness when calculating demand.

  • public float3 m_TaxEffect = 1f
    Tooltip: "The weight that multiply to the tax effect value differ to the neutral 10% tax rate (residential, commercial, industrial/office)"
    Per-sector tax effect multipliers (x: residential, y: commercial, z: industrial/office) applied relative to neutral tax.

  • public float m_StudentEffect = 1f
    Tooltip: "The weight that multiply to the student effect value"
    Multiplier for student-related demand effects.

  • public float m_AvailableWorkplaceEffect = 8f
    Tooltip: "The weight that multiply to the workplace value differ to the neutral"
    Multiplier for the effect of available workplaces on demand.

  • public float m_HomelessEffect = 20f
    Tooltip: "The weight that multiply to the homeless value differ to the neutral"
    Multiplier for homeless population effect on demand.

  • public int m_NeutralHappiness = 45
    Tooltip: "Neutral average happiness value, the happiness value showed at bottom bar"
    Neutral happiness baseline used when computing effects.

  • public float m_NeutralUnemployment = 20f
    Tooltip: "Neutral unemployment percentage, 10 = 10% unemployment is neutral"
    Neutral unemployment percentage used as baseline for demand/unemployment calculations.

  • public float m_NeutralAvailableWorkplacePercentage = 10f
    Tooltip: "Neutral available workplace percentage, 10 = 10% available workplace is neutral"
    Neutral available-workplace percentage baseline.

  • public int m_NeutralHomelessness = 50
    Tooltip: "Neutral homeless household amount"
    Neutral homeless household count used as baseline.

  • public int3 m_FreeResidentialRequirement = new int3(5, 10, 10)
    Tooltip: "Need free unoccupied residential buildings amount, x-low density, y-medium density, z-high density"
    Minimum number of free residential buildings required per density type.

  • public float m_FreeCommercialProportion = 10f
    Proportion parameter used for commercial vacancy/availability behavior.

  • public float m_FreeIndustrialProportion = 10f
    Proportion parameter used for industrial vacancy/availability behavior.

  • public float m_CommercialStorageMinimum = 0.2f
    Commercial storage minimum threshold used by demand calculations.

  • public float m_CommercialStorageEffect = 1.6f
    Commercial storage effect multiplier.

  • public float m_CommercialBaseDemand = 4f
    Tooltip: "The commercial resource demand multiplier to household's needs"
    Base demand multiplier for commercial goods relative to household needs.

  • public float m_IndustrialStorageMinimum = 0.2f
    Industrial storage minimum threshold.

  • public float m_IndustrialStorageEffect = 1.6f
    Industrial storage effect multiplier.

  • public float m_IndustrialBaseDemand = 7f
    Base demand multiplier for industrial goods.

  • public float m_ExtractorBaseDemand = 1.5f
    Base demand for extractor-type industries.

  • public float m_StorageDemandMultiplier = 5E-05f
    Multiplier applied to storage when computing demand effects.

  • public int m_CommuterWorkerRatioLimit = 8
    Upper limit for commuter-to-worker ratio parameters.

  • public int m_CommuterSlowSpawnFactor = 8
    Factor that slows commuter spawning.

  • public float4 m_CommuterOCSpawnParameters = new float4(0.8f, 0.2f, 0f, 0f)
    Tooltip: "Percentage that commuter will spawn at OCs x:Road y:Train z:Air w:Ship"
    Probabilities for commuter spawn origins by OC (Origin/Connection) type: Road, Train, Air, Ship.

  • public float4 m_TouristOCSpawnParameters = new float4(0.1f, 0.1f, 0.5f, 0.3f)
    Tooltip: "Percentage that tourist will spawn at OCs x:Road y:Train z:Air w:Ship"
    Probabilities for tourist spawn origins by OC type.

  • public float4 m_CitizenOCSpawnParameters = new float4(0.6f, 0.2f, 0.15f, 0.05f)
    Tooltip: "Percentage that citizen will spawn at OCs x:Road y:Train z:Air w:Ship"
    Probabilities for citizen spawn origins by OC type.

  • public float m_TeenSpawnPercentage = 0.5f
    Tooltip: "Percentage that teen citizen will spawn among all new household that with child"
    Probability that a teen is spawned among new-household children.

  • public int3 m_FrameIntervalForSpawning = new int3(0, 2000, 2000)
    Tooltip: "Frames cooldown interval for x-residential,y-commercial,z-industrial citizen/company spawning"
    Frame interval cooldowns for spawning by sector.

  • public float m_HouseholdSpawnSpeedFactor = 0.5f
    Tooltip: "The speed factor of new household spawning"
    Multiplier controlling how quickly new households spawn.

  • public float m_HotelRoomPercentRequirement = 0.5f
    Tooltip: "The spawning percent requirement of hotel rooms that need to meet the demand of tourist"
    Proportion of hotel room availability required to meet tourist spawning demand.

  • public float4 m_NewCitizenEducationParameters = new float4(0.005f, 0.5f, 0.35f, 0.13f)
    Tooltip: "Percentage of citizens' education level x:uneducated y:poorly educated z:educated w:WellEducated, then rest is the highly educated"
    Distribution weights for new citizen education levels (remaining probability after these four is considered 'highly educated').

Properties

  • None declared on this prefab class. All data is exposed as public fields and copied into the DemandParameterData component at initialization.

Constructors

  • public DemandPrefab()
    No explicit constructor is defined in code; the default parameterless constructor is used by Unity/Serialization. All fields have their default values as shown in their declarations.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds required component types for this prefab. Implementation calls base.GetPrefabComponents and then adds ComponentType.ReadWrite() which indicates entities using this prefab will have DemandParameterData.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Overrides PrefabBase.GetArchetypeComponents. Current implementation only calls base (no additional archetype components added here).

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Copies the prefab's field values into the DemandParameterData component on the given entity. It resolves referenced PrefabBase assets (m_ForestryPrefab and m_OfficePrefab) to Entities via PrefabSystem.GetEntity and sets a DemandParameterData struct with the prefab values on the entity using entityManager.SetComponentData.

Notes: - LateInitialize depends on PrefabSystem (resolved with entityManager.World.GetOrCreateSystemManaged()) to translate PrefabBase references to ECS Entities. - The produced DemandParameterData mirrors the public fields of this prefab so ECS systems can read demand tuning data at runtime.

Usage Example

// When this Prefab is instantiated and LateInitialize is called, it will write a DemandParameterData
// component to the created entity with the same values as the prefab fields.

public override void LateInitialize(EntityManager entityManager, Entity entity)
{
    base.LateInitialize(entityManager, entity);
    PrefabSystem prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
    // The prefab resolves references and writes DemandParameterData onto the entity:
    entityManager.SetComponentData(entity, new DemandParameterData {
        m_ForestryPrefab = prefabSystem.GetEntity(m_ForestryPrefab),
        m_OfficePrefab = prefabSystem.GetEntity(m_OfficePrefab),
        m_MinimumHappiness = m_MinimumHappiness,
        m_HappinessEffect = m_HappinessEffect,
        // ...other fields copied similarly...
        m_HotelRoomPercentRequirement = m_HotelRoomPercentRequirement
    });
}

If you want, I can also generate the matching DemandParameterData struct documentation (fields/types) by inspecting that type so you can see how prefab values are mapped to the runtime component.