Skip to content

Game.Prefabs.Modes.DemandParameterMode

Assembly:
{{ Likely compiled into the game's main assembly (Assembly-CSharp) or a game-specific assembly. This MonoBehaviour-style prefab class is part of the game's prefabs for mode parameters used by the Cities: Skylines 2 modding/runtime systems. }}

Namespace: Game.Prefabs.Modes

Type:
public class DemandParameterMode : EntityQueryModePrefab

Base:
EntityQueryModePrefab

Summary:
{{ DemandParameterMode is a mode prefab that exposes a set of demand-related parameters (happiness, tax effects, spawn parameters, base demand values, etc.) as public fields. When applied, it writes these values into the game's DemandParameterData singleton component. It also supports restoring defaults from the associated DemandPrefab via RestoreDefaultData. The class defines the EntityQuery used to locate the DemandParameterData component and implements the logic to copy its own field values into that component when ApplyModeData is invoked. }}


Fields

  • public int m_MinimumHappiness
    {{ Minimum allowed happiness value used by demand calculations. Written into DemandParameterData.m_MinimumHappiness by ApplyModeData. }}

  • public float m_HappinessEffect
    {{ A multiplier/offset used to influence demand based on happiness. Copied to DemandParameterData.m_HappinessEffect. }}

  • public float3 m_TaxEffect
    {{ Tax effect on demand; stored in DemandParameterData.m_TaxEffect. Uses Unity.Mathematics.float3. }}

  • public float m_StudentEffect
    {{ Effect of students on demand; copied to DemandParameterData.m_StudentEffect. }}

  • public float m_AvailableWorkplaceEffect
    {{ Effect of available workplaces on demand. }}

  • public float m_HomelessEffect
    {{ Effect of homelessness on demand calculations. }}

  • public int m_NeutralHappiness
    {{ Neutral happiness baseline for demand. }}

  • public float m_NeutralUnemployment
    {{ Neutral unemployment baseline (percentage/ratio) for demand. }}

  • public float m_NeutralAvailableWorkplacePercentage
    {{ Neutral baseline for available workplace percentage. }}

  • public int m_NeutralHomelessness
    {{ Neutral baseline homelessness value. }}

  • public int3 m_FreeResidentialRequirement
    {{ Requirement values for free residential spots (Unity.Mathematics.int3). }}

  • public float m_CommercialBaseDemand
    {{ Base demand value for commercial zones. }}

  • public float m_IndustrialBaseDemand
    {{ Base demand value for industrial zones. }}

  • public float m_ExtractorBaseDemand
    {{ Base demand value for extractors (natural resource industries). }}

  • public int m_CommuterWorkerRatioLimit
    {{ Limit parameter for commuter vs local worker ratios. }}

  • public int m_CommuterSlowSpawnFactor
    {{ Spawn factor affecting commuter spawn speed. }}

  • public float4 m_CommuterOCSpawnParameters
    {{ One-column spawn parameters for commuters (Unity.Mathematics.float4). }}

  • public float4 m_TouristOCSpawnParameters
    {{ One-column spawn parameters for tourists. }}

  • public float4 m_CitizenOCSpawnParameters
    {{ One-column spawn parameters for citizens. }}

  • public float m_TeenSpawnPercentage
    {{ Percentage of teen spawns when creating new citizens. }}

  • public int3 m_FrameIntervalForSpawning
    {{ Frame interval settings (int3) used to control spawning cadence. }}

  • public float m_HouseholdSpawnSpeedFactor
    {{ Spawn speed factor for households. }}

  • public float m_HotelRoomPercentRequirement
    {{ Requirement percentage for hotel rooms relative to tourism/capacity. }}

  • public float4 m_NewCitizenEducationParameters
    {{ Education-related parameters for new citizens (float4). }}

Properties

{{ This class does not declare any C# properties. It exposes data via public fields and implements mode methods inherited from EntityQueryModePrefab. }}

Constructors

  • public DemandParameterMode()
    {{ No custom constructor is defined in source; the default constructor is used. Instances are intended to be created/managed as prefabs/components by the game's prefab/system and populated via the inspector or prefab data. }}

Methods

  • public override EntityQueryDesc GetEntityQueryDesc()
    {{ Returns an EntityQueryDesc that selects entities with a DemandParameterData component (read-only). This is used by the mode system to find the singleton DemandParameterData entity the mode should modify. Implementation: creates a new EntityQueryDesc and sets All = [ ComponentType.ReadOnly() ]. }}

  • protected override void RecordChanges(EntityManager entityManager, Entity entity)
    {{ Implementation simply calls entityManager.GetComponentData(entity) — presumably to read (and thus record) the current DemandParameterData for undo/history or change tracking handled by the mode system. }}

  • public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
    {{ Restores the DemandParameterData component on the provided entity to values sourced from the DemandPrefab associated with the entity. The method:

  • Uses the first entity in the provided entities array.
  • Retrieves a DemandPrefab from PrefabSystem for that entity.
  • Copies all corresponding fields from DemandPrefab into the DemandParameterData component.
  • Writes the component back via entityManager.SetComponentData. This is used to reset mode-modified values back to prefab defaults. }}

  • public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
    {{ Applies the values currently stored on this DemandParameterMode instance to the singleton DemandParameterData entity found via the provided query. The method:

  • Gets the singleton entity via requestedQuery.GetSingletonEntity().
  • Reads DemandParameterData for that entity, overwrites its fields with this mode's fields (m_...).
  • Sets the component back with entityManager.SetComponentData.
  • Returns the incoming deps JobHandle unchanged. This is the main method that propagates mode settings into the ECS world. }}

Usage Example

// Typical usage: this prefab component is authored in-game (inspector or prefab).
// At runtime the mode system will call GetEntityQueryDesc, then ApplyModeData to copy the values
// into the game's DemandParameterData singleton component.

// Example (editor/runtime code) to create a component and set parameters programmatically:
var go = new GameObject("DemandMode");
var mode = go.AddComponent<Game.Prefabs.Modes.DemandParameterMode>();
mode.m_MinimumHappiness = 10;
mode.m_HappinessEffect = 0.5f;
mode.m_CommercialBaseDemand = 1.2f;
// The mode system will later call ApplyModeData(...) to write these into DemandParameterData.

{{ Notes: - Uses Unity.Mathematics types (float3, float4, int3). - The class depends on DemandParameterData and DemandPrefab types; these must exist in the ECS world/prefab system. - ApplyModeData is synchronous in this implementation (it updates component data directly and returns the passed JobHandle). }}