Game.Prefabs.DemandParameterData
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
A plain ECS component that groups a large set of parameters controlling demand logic and population/visitor spawning behavior in Cities: Skylines 2. This data is intended to be read by demand- and spawn-related systems (residential/commercial/industrial demand, commuter/tourist/citizen spawn rates, and related adjustments). Fields use Unity.Mathematics types (float3/float4/int3) for compact storage of grouped numeric parameters.
Fields
-
public Entity m_ForestryPrefab
Reference to the forestry-prefab entity used by systems that spawn or reference forestry industry buildings. Use this to point to the Entity prefab asset representing forestry production. -
public Entity m_OfficePrefab
Reference to the office-prefab entity used by systems that spawn or reference office buildings. Useful when determining workplace types or spawning specific workplace prefabs. -
public int m_MinimumHappiness
Minimum happiness threshold used as a clamp or baseline when computing demand modifiers. Prevents negative or excessively low happiness values from breaking demand logic. -
public float m_HappinessEffect
Scalar multiplier expressing how changes in population happiness affect demand. Typically applied to increase/decrease demand in response to city happiness. -
public float3 m_TaxEffect
Per‑sector tax effect values (packed in a float3). Each component is used to modify demand for different sectors depending on tax level (for example: residential, commercial, industrial). Values are multipliers or offsets applied during demand calculation. -
public float m_StudentEffect
Modifier describing how the number or proportion of students in the city affects demand (e.g., residential or education-driven demand adjustments). -
public float m_AvailableWorkplaceEffect
Effect applied to demand based on the amount of available workplaces. More available jobs usually reduces residential demand pressure; this value controls that influence. -
public float m_HomelessEffect
Modifier that adjusts demand based on homelessness levels. High homelessness may reduce demand or change spawning behavior. -
public int m_NeutralHappiness
Happiness value considered "neutral" (no positive/negative demand adjustments). Used as a reference point for the m_HappinessEffect calculations. -
public float m_NeutralUnemployment
Baseline unemployment ratio considered neutral for demand calculations. Deviations from this value adjust demand per configured effects. -
public float m_NeutralAvailableWorkplacePercentage
Baseline percentage of available workplaces considered neutral. Used as a reference when applying m_AvailableWorkplaceEffect. -
public int m_NeutralHomelessness
Baseline homelessness count considered neutral. Used as reference for homelessness-related adjustments. -
public int3 m_FreeResidentialRequirement
Three integer values (int3) representing tiered requirements for "free residential" conditions. Could represent thresholds for different residential sizes/levels or stages when free/reserved residential plots are considered. -
public float m_FreeCommercialProportion
Proportion (0..1) of commercial capacity considered “free” or available; used in demand/placement logic for commercial buildings. -
public float m_FreeIndustrialProportion
Proportion (0..1) of industrial capacity considered “free” or available; used similarly for industrial demand. -
public float m_CommercialStorageMinimum
Minimum storage threshold for commercial goods before storage starts to influence commercial demand. -
public float m_CommercialStorageEffect
Multiplier describing how commercial storage levels change commercial demand (e.g., low storage => higher demand). -
public float m_CommercialBaseDemand
Base demand value for commercial sector. Systems will use this as a starting point before applying modifiers. -
public float m_IndustrialStorageMinimum
Minimum storage threshold for industrial products before affecting industrial demand. -
public float m_IndustrialStorageEffect
Multiplier describing the influence of industrial storage levels on industrial demand. -
public float m_IndustrialBaseDemand
Base demand value for industrial sector. -
public float m_ExtractorBaseDemand
Base demand value specifically for extractors (resource extraction industry). Controls spawn/placement pressure for extractors. -
public float m_StorageDemandMultiplier
Global multiplier applied to demand adjustments that are driven by storage levels (for both commercial and industrial contexts). -
public int m_CommuterWorkerRatioLimit
Integer limit used when calculating commuter ratios (caps the commuter/worker ratio used in spawn or simulation logic). -
public int m_CommuterSlowSpawnFactor
Integer factor that slows commuter spawn rates (higher values reduce spawn frequency or speed). -
public float4 m_CommuterOCSpawnParameters
Four packed floats controlling commuter spawn behavior. The four components are used by the spawning system (e.g., base rate, variance, min/max thresholds). Exact interpretation depends on the consumer system, but they collectively configure commuter spawn timing and intensity. -
public float4 m_TouristOCSpawnParameters
Four packed floats controlling tourist spawn behavior (similar pattern to commuter parameters). -
public float4 m_CitizenOCSpawnParameters
Four packed floats controlling regular citizen spawn behavior. -
public float m_TeenSpawnPercentage
Percentage (0..1) of new spawns that should be teenagers. Used by population spawn logic to set age-distribution of new citizens/households. -
public int3 m_FrameIntervalForSpawning
Three integer frame intervals (int3) controlling how often different spawning checks run (for example: citizens, commuters, tourists). Using separate intervals lets the system stagger and reduce per-frame load. -
public float m_HouseholdSpawnSpeedFactor
Multiplier that adjusts household spawn speed globally. Larger values cause faster household creation. -
public float m_HotelRoomPercentRequirement
Percentage threshold of hotel room occupancy/availability that influences related demand or spawning behavior (e.g., when hotels are “full enough” to change tourist demand). -
public float4 m_NewCitizenEducationParameters
Four floats that parameterize the education distribution (or spawn probabilities by education level) for newly spawned citizens. Used to shape the skill/education mix of incoming population.
Properties
- None.
This struct contains only public fields and implements IComponentData / IQueryTypeParameter for ECS usage.
Constructors
public DemandParameterData()
Default (compiler-provided) value-type constructor. Populate fields manually or via object initializer when adding the component to an entity.
Methods
- None.
This is a data-only component; logic is implemented by systems reading these fields.
Usage Example
// Example: create and attach DemandParameterData to an entity (in a system or bootstrap)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(DemandParameterData));
// Create an entity and initialize demand parameters
var ent = entityManager.CreateEntity(archetype);
var data = new DemandParameterData
{
m_ForestryPrefab = Entity.Null,
m_OfficePrefab = Entity.Null,
m_MinimumHappiness = 30,
m_HappinessEffect = 0.8f,
m_TaxEffect = new Unity.Mathematics.float3(0.9f, 1.0f, 1.1f),
m_StudentEffect = 0.5f,
m_AvailableWorkplaceEffect = 1.2f,
m_HomelessEffect = 0.7f,
m_NeutralHappiness = 50,
m_NeutralUnemployment = 0.06f,
m_NeutralAvailableWorkplacePercentage = 0.1f,
m_NeutralHomelessness = 0,
m_FreeResidentialRequirement = new Unity.Mathematics.int3(0, 0, 0),
m_FreeCommercialProportion = 0.05f,
m_FreeIndustrialProportion = 0.05f,
m_CommercialStorageMinimum = 10f,
m_CommercialStorageEffect = 1.0f,
m_CommercialBaseDemand = 1.0f,
m_IndustrialStorageMinimum = 10f,
m_IndustrialStorageEffect = 1.0f,
m_IndustrialBaseDemand = 1.0f,
m_ExtractorBaseDemand = 0.2f,
m_StorageDemandMultiplier = 1.0f,
m_CommuterWorkerRatioLimit = 200,
m_CommuterSlowSpawnFactor = 2,
m_CommuterOCSpawnParameters = new Unity.Mathematics.float4(1f, 0.2f, 0.0f, 10f),
m_TouristOCSpawnParameters = new Unity.Mathematics.float4(0.5f, 0.1f, 0.0f, 5f),
m_CitizenOCSpawnParameters = new Unity.Mathematics.float4(1f, 0.3f, 0.0f, 8f),
m_TeenSpawnPercentage = 0.12f,
m_FrameIntervalForSpawning = new Unity.Mathematics.int3(60, 120, 180),
m_HouseholdSpawnSpeedFactor = 1.0f,
m_HotelRoomPercentRequirement = 0.8f,
m_NewCitizenEducationParameters = new Unity.Mathematics.float4(0.25f, 0.35f, 0.25f, 0.15f)
};
entityManager.SetComponentData(ent, data);
Notes for modders: - This component is read by demand/spawn systems — changing values at runtime will affect how the game calculates demand and spawning. Test changes incrementally. - Many parameters are proportions or multipliers; typical normalized ranges are 0..1 but some fields (base demands, caps) may use larger numbers depending on system expectations. - Use Entity references (m_ForestryPrefab / m_OfficePrefab) to plug in prefab entities from your asset loading/bootstrap code so spawners can instantiate the correct building types.