Game.Prefabs.Modes.WaterPipeParametersMode
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs.Modes
Type:
class
Base:
EntityQueryModePrefab
Summary:
A prefab-mode class used to configure water-pipe related simulation parameters in the ECS world. This component exposes a set of editable fields (visible in the Unity Inspector via ComponentMenu) that are written into the WaterPipeParameterData component (a singleton entity) when ApplyModeData is executed. It also supports restoring those parameters to their prefab defaults via RestoreDefaultData.
Fields
-
public float m_GroundwaterReplenish
Controls the rate at which groundwater is replenished. Written to WaterPipeParameterData.m_GroundwaterReplenish. -
public int m_GroundwaterPurification
An integer value representing purification capacity or amount for groundwater. Written to WaterPipeParameterData.m_GroundwaterPurification. -
public float m_GroundwaterUsageMultiplier
Multiplier applied to groundwater usage by consumers / systems. Written to WaterPipeParameterData.m_GroundwaterUsageMultiplier. -
public float m_GroundwaterPumpEffectiveAmount
Effective amount a groundwater pump contributes. Written to WaterPipeParameterData.m_GroundwaterPumpEffectiveAmount. -
public float m_SurfaceWaterUsageMultiplier
Multiplier applied to surface water usage. Written to WaterPipeParameterData.m_SurfaceWaterUsageMultiplier. -
public float m_SurfaceWaterPumpEffectiveDepth
Effective depth for surface water pump operation. Written to WaterPipeParameterData.m_SurfaceWaterPumpEffectiveDepth. -
public float m_MaxToleratedPollution
Range(0f, 1f). The maximum pollution level tolerated by the system before additional effects occur. Written to WaterPipeParameterData.m_MaxToleratedPollution. -
public int m_WaterPipePollutionSpreadInterval
Range(1f, 32f). Interval (in simulation ticks/frames/steps as used by the game) for water-pipe pollution spreading. Written to WaterPipeParameterData.m_WaterPipePollutionSpreadInterval. -
public float m_StaleWaterPipePurification
Range(0f, 1f). Fraction/amount used to purify or reduce stale water pipe pollution. Written to WaterPipeParameterData.m_StaleWaterPipePurification.
Properties
- None in this class.
Constructors
public WaterPipeParametersMode()
Default parameterless constructor (implicit). The class is typically used as a prefab component in the Unity editor (ComponentMenu attribute present).
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that matches entities with a ReadOnly WaterPipeParameterData component. This is used to locate the singleton entity that holds the water-pipe parameters. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Records changes for the prefab system by reading the WaterPipeParameterData for the given entity. (Implementation calls GetComponentData to register that component for change tracking.) -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Fetches the singleton entity from requestedQuery, reads its WaterPipeParameterData, updates all fields with the values from this prefab (the m_... fields), writes the component back to the entity, and returns the incoming JobHandle unchanged. This is the primary method that applies the mode's parameter values into the running simulation. -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores parameter values to the defaults defined in the WaterPipeParametersPrefab. It reads the prefab object (WaterPipeParametersPrefab) from the PrefabSystem for the provided entity and copies its values back into the entity's WaterPipeParameterData component.
Notes: - The class expects the WaterPipeParameterData singleton entity to exist when ApplyModeData is called. - The ComponentMenu attribute makes this script available in Unity's Add Component menu under "Modes/Mode Parameters/".
Usage Example
// Typical usage: attach this prefab to a mode prefab in the editor and edit the fields there.
// At runtime the system will call ApplyModeData to write these values into the WaterPipeParameterData singleton.
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
{
// This method is already implemented in WaterPipeParametersMode.
// Example call (from a manager that holds a reference to this mode instance):
return myWaterPipeParametersMode.ApplyModeData(entityManager, requestedQuery, deps);
}
{{ Additional information: - This mode bridges Unity's prefab/configuration workflow and the DOTS/ECS runtime by copying inspector-configured values into an ECS component (WaterPipeParameterData). - If you create custom modes or modify values at runtime, ensure the singleton entity with WaterPipeParameterData exists and is queried correctly. - Use RestoreDefaultData when you want to revert runtime changes to the prefab-authoritative values (e.g., when resetting a mode). }}