Game.Prefabs.Modes.PollutionPrefabMode
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: public class PollutionPrefabMode
Base: EntityQueryModePrefab
Summary:
PollutionPrefabMode is a Unity component/prefab mode that encapsulates a collection of configurable pollution parameters (multipliers, radii, fades, notification limits, etc.). It is used by the game's prefab system to apply these parameters to the PollutionParameterData component (usually a singleton) and to restore defaults from PollutionPrefab data. This class provides overrides to describe which entities it targets, to record changes, to apply the in-inspector values to the ECS world, and to restore default values from the prefab data.
Fields
-
public float m_GroundMultiplier
Controls the ground pollution strength multiplier. -
public float m_AirMultiplier
Controls the air pollution strength multiplier. -
public float m_NoiseMultiplier
Controls the noise pollution multiplier. -
public float m_NetAirMultiplier
Multiplier for net air pollution (aggregation/network effects). -
public float m_NetNoiseMultiplier
Multiplier for net noise pollution. -
public float m_GroundRadius
Effective radius for ground pollution spread. -
public float m_AirRadius
Effective radius for air pollution spread. -
public float m_NoiseRadius
Effective radius for noise pollution spread. -
public float m_NetNoiseRadius
Effective radius used when calculating net noise propagation. -
public float m_WindAdvectionSpeed
Speed at which air pollution is advected by wind. -
public short m_AirFade
Fade parameter for air pollution (short/integer scale used by systems). -
public short m_GroundFade
Fade parameter for ground pollution. -
public float m_PlantAirMultiplier
Multiplier applied to air pollution in presence of plants (reduces/increases). -
public float m_PlantGroundMultiplier
Multiplier applied to ground pollution in presence of plants. -
public float m_PlantFade
Fade parameter for plant effect on pollution. -
public float m_FertilityGroundMultiplier
Multiplier affecting ground fertility in response to pollution. -
public float m_DistanceExponent
Exponent controlling how pollution decays with distance. -
public int m_AirPollutionNotificationLimit
Limit used to trigger air pollution notifications to the player. -
public int m_NoisePollutionNotificationLimit
Limit used to trigger noise pollution notifications to the player. -
public int m_GroundPollutionNotificationLimit
Limit used to trigger ground pollution notifications to the player. -
public float m_AbandonedNoisePollutionMultiplier
Multiplier used for noise pollution contributed by abandoned buildings. -
public int m_HomelessNoisePollution
Noise pollution amount contributed by homeless citizens (integer). -
public int m_GroundPollutionLandValueDivisor
Divisor used to compute how ground pollution affects land value.
Properties
- None declared in this class.
Constructors
public PollutionPrefabMode()
Default, parameterless constructor. This is the MonoBehaviour / prefab-mode component constructor used by Unity. Instances are typically created/edited in the editor (inspector) and applied to the ECS world via the prefab/mode system.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that targets entities containing the PollutionParameterData component. Implementation builds and returns an EntityQueryDesc with All = [ComponentType.ReadOnly()]. Use: the prefab/mode system uses this query to find the singleton pollution parameter entity to modify. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Records changes for the prefab system. The implementation calls entityManager.GetComponentData(entity) — this accesses the existing component to mark/read it (used by the prefab change-tracking system). -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the values stored on this PollutionPrefabMode instance to the PollutionParameterData component on the singleton entity matched by requestedQuery. Steps: - Get singleton entity via requestedQuery.GetSingletonEntity().
- Get PollutionParameterData from EntityManager.
- Overwrite its fields with the corresponding m_* fields from this prefab mode.
- Set the updated component back to the EntityManager with SetComponentData.
-
Return the incoming JobHandle (no additional jobs scheduled here). Note: This is performed on the thread/context calling ApplyModeData; the method does not schedule jobs (it uses direct component access).
-
public override void RestoreDefaultData(EntityManager entityManager, ref Unity.Collections.NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores default PollutionParameterData from the PollutionPrefab associated with the provided entity. Steps: - Use the first entity in the entities array.
- Retrieve the PollutionPrefab via prefabSystem.GetPrefab
(entity). - Read default values from that PollutionPrefab and copy them into the entity's PollutionParameterData component.
- Write the component back via entityManager.SetComponentData(entity, componentData). This is used by the prefab system to revert changes and restore base/preset values.
Usage Example
// Example: Applying the mode values to the pollution singleton via the prefab/mode system
// (Assumes you have an instance of PollutionPrefabMode active in the scene/prefab system)
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityQuery query = entityManager.CreateEntityQuery(typeof(PollutionParameterData));
PollutionPrefabMode mode = /* obtain reference from prefab or inspector */;
JobHandle deps = default;
// Apply mode values (this will copy the m_* fields into the PollutionParameterData singleton)
mode.ApplyModeData(entityManager, query, deps);
Notes: - This class is typically serialized/edited in the Unity editor (inspector) as part of the game's prefab/mode authoring workflow. - The class expects that the requested EntityQuery singles out the PollutionParameterData singleton entity; ensure the query provided to ApplyModeData matches the one returned by GetEntityQueryDesc(). - RestoreDefaultData requires access to the PrefabSystem and the appropriate PollutionPrefab to reset values to the original defaults.