Game.Prefabs.Modes.ZonePreferenceMode
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: class
Base: EntityQueryModePrefab
Summary:
ZonePreferenceMode is a mode-prefab used to populate and restore ZonePreferenceData on a singleton entity. It exposes a set of float parameters (significances and neutral land values) for different zone types (Residential, Commercial, Industrial, Office). When applied it copies the values from the prefab instance into the ZonePreferenceData component found by an EntityQuery (singleton). It also supports restoring defaults from the corresponding ZonePreferencePrefab via the PrefabSystem.
Fields
-
public float m_ResidentialSignificanceServices
Weight for how much services affect residential zone preference. -
public float m_ResidentialSignificanceWorkplaces
Weight for how much workplaces affect residential zone preference. -
public float m_ResidentialSignificanceLandValue
Weight for land value for residential zone preference. -
public float m_ResidentialSignificancePollution
Weight for pollution for residential zone preference. -
public float m_ResidentialNeutralLandValue
Neutral land value baseline for residential zones. -
public float m_CommercialSignificanceConsumers
Weight for consumer presence for commercial zone preference. -
public float m_CommercialSignificanceCompetitors
Weight for competitor presence for commercial zone preference. -
public float m_CommercialSignificanceWorkplaces
Weight for workplaces for commercial zone preference. -
public float m_CommercialSignificanceLandValue
Weight for land value for commercial zone preference. -
public float m_CommercialNeutralLandValue
Neutral land value baseline for commercial zones. -
public float m_IndustrialSignificanceInput
Weight for input availability for industrial zone preference. -
public float m_IndustrialSignificanceOutside
Weight for outside access/markets for industrial zone preference. -
public float m_IndustrialSignificanceLandValue
Weight for land value for industrial zone preference. -
public float m_IndustrialNeutralLandValue
Neutral land value baseline for industrial zones. -
public float m_OfficeSignificanceEmployees
Weight for employee availability for office zone preference. -
public float m_OfficeSignificanceServices
Weight for services for office zone preference.
Properties
- This class does not declare any public properties.
Constructors
public ZonePreferenceMode()
Default parameterless constructor (implicit). Instances of this prefab are normally created/managed by the game's prefab system and configured in the editor (inspector).
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
: EntityQueryDesc
Returns an EntityQueryDesc that matches entities having a read-only ZonePreferenceData component. Used to locate the singleton ZonePreferenceData entity to operate on. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
: void
Reads the ZonePreferenceData component for the given entity. The method is used by the prefab system to record that the component was read/changed (used for undo/recording systems). -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
: JobHandle
Finds the singleton entity from requestedQuery, gets its ZonePreferenceData component, copies all the fields from this prefab instance into that component, and writes it back to the EntityManager. Returns the input deps unchanged (no jobs spawned). -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
: void
Restores the ZonePreferenceData fields on the provided entity using the default values from the corresponding ZonePreferencePrefab obtained via prefabSystem.GetPrefab(entity). Writes the restored values back to the EntityManager.
Usage Example
// Typical usage in the game's prefab workflow: the prefab fields are set in the editor (inspector).
// At runtime the prefab system calls ApplyModeData to copy these values into the runtime ZonePreferenceData singleton.
ZonePreferenceMode mode = /* get prefab instance from prefab system */;
mode.m_ResidentialSignificanceServices = 0.6f; // example adjustment
EntityQuery query = entityManager.CreateEntityQuery(ComponentType.ReadOnly<ZonePreferenceData>());
JobHandle deps = default;
deps = mode.ApplyModeData(entityManager, query, deps);