Skip to content

Game.Prefabs.WaterPipeParametersPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Prefab type that holds configuration parameters and notification prefab references used by the water/wastewater systems (pipes, pumps, consumers). During initialization it writes a WaterPipeParameterData component to the prefab entity, resolving referenced PrefabBase/NotificationIconPrefab assets to Entity handles via the PrefabSystem. This prefab centralizes water-related tuning values (groundwater/surface water usage, pump effectiveness, pollution thresholds, pipe pollution spread/purification, etc.).


Fields

  • public PrefabBase m_WaterService
    Reference to the water service prefab (entity) used by systems that need the service entity.

  • public NotificationIconPrefab m_WaterNotification
    Notification prefab shown for general water notifications (fresh water).

  • public NotificationIconPrefab m_DirtyWaterNotification
    Notification prefab used when supplied water is dirty/polluted.

  • public NotificationIconPrefab m_SewageNotification
    Notification prefab for sewage-related alerts.

  • public NotificationIconPrefab m_WaterPipeNotConnectedNotification
    Notification prefab shown when a consumer or pump has no connected water pipe.

  • public NotificationIconPrefab m_SewagePipeNotConnectedNotification
    Notification prefab shown when sewage pipe is missing or disconnected.

  • public NotificationIconPrefab m_NotEnoughWaterCapacityNotification
    Notification prefab shown when there is not enough water capacity.

  • public NotificationIconPrefab m_NotEnoughSewageCapacityNotification
    Notification prefab shown when there is not enough sewage capacity.

  • public NotificationIconPrefab m_NotEnoughGroundwaterNotification
    Notification prefab shown when groundwater sources are insufficient.

  • public NotificationIconPrefab m_NotEnoughSurfaceWaterNotification
    Notification prefab shown when surface water sources are insufficient.

  • public NotificationIconPrefab m_DirtyWaterPumpNotification
    Notification prefab shown on pumps when the source water is too polluted.

  • public float m_GroundwaterReplenish = 0.004f
    Rate at which groundwater cells replenish (per tick / per system-defined timestep).

  • public int m_GroundwaterPurification = 1
    How much a groundwater cell purifies itself per tick (tooltip: 2048 ticks per day). Integer ticks of purification applied.

  • public float m_GroundwaterUsageMultiplier = 0.1f
    Multiplier applied to consumption when using groundwater (affects how quickly groundwater is consumed).

  • public float m_GroundwaterPumpEffectiveAmount = 4000f
    Effective amount (units) a groundwater pump can extract (used when calculating supply from groundwater).

  • public float m_SurfaceWaterUsageMultiplier = 5E-05f
    Multiplier applied to consumption when using surface water.

  • public float m_SurfaceWaterPumpEffectiveDepth = 4f
    Effective depth parameter used when calculating surface water pump yield.

  • public float m_MaxToleratedPollution = 0.1f
    If fresh water pollution exceeds this percentage (0–1), notifications will be shown on pumps/consumers. Decorated with Tooltip and Range(0,1).

  • public int m_WaterPipePollutionSpreadInterval = 5
    Interval at which pollution spreads in pipes. Larger values = slower spread and faster cleanup. Range 1–32.

  • public float m_StaleWaterPipePurification = 0.001f
    How much pollution is removed from water pipes without any flow, per tick (Range 0–1).

Properties

  • (No public properties declared in this class itself. The prefab writes a WaterPipeParameterData component to the entity with equivalent fields when LateInitialize runs.)

Constructors

  • public WaterPipeParametersPrefab()
    Default MonoBehaviour-style prefab constructor (implicit). Prefab instances are normally created/managed by the game's prefab system; no custom constructor logic is provided here.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds all referenced PrefabBase/NotificationIconPrefab instances to the provided dependency list so the prefab system can ensure they are loaded/created first. Calls base.GetDependencies(prefabs) and then adds each field reference (m_WaterService, all notification prefabs, etc.).

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime component type this prefab will provide to the entity: ComponentType.ReadWrite(). Also calls base.GetPrefabComponents.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Called during prefab entity creation/initialization. Resolves each PrefabBase/NotificationIconPrefab reference to an Entity via PrefabSystem.GetEntity(...) and sets a WaterPipeParameterData component on the entity with all configuration values (notification entity handles and numeric parameters). Uses entityManager.SetComponentData(entity, new WaterPipeParameterData { ... }).

Notes: - The method uses entityManager.World.GetOrCreateSystemManaged() to obtain the PrefabSystem for resolution. - After LateInitialize completes, systems can read WaterPipeParameterData from the prefab entity to access the resolved entities and tuning values.

Usage Example

// Example: read values from the prefab entity in a system after prefabs are initialized
public class MyWaterDebugSystem : SystemBase
{
    protected override void OnStartRunning()
    {
        // Assume the water parameters prefab entity exists; query for the component
        Entities
            .WithName("LogWaterParams")
            .WithAll<WaterPipeParameterData>()
            .ForEach((in WaterPipeParameterData wp) =>
            {
                UnityEngine.Debug.Log($"Groundwater replenish rate: {wp.m_GroundwaterReplenish}");
                UnityEngine.Debug.Log($"Max tolerated pollution: {wp.m_MaxToleratedPollution}");
            }).Run();
    }

    protected override void OnUpdate() { }
}

If you want to extend or override behavior in the prefab script, you can derive from WaterPipeParametersPrefab and override GetDependencies or LateInitialize, but be sure to call base implementations to keep the component population and dependency resolution intact.