Skip to content

Game.Prefabs.WaterPumpingStationData

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents the data for a water pumping station prefab in the ECS-prefab system. Holds the allowed water types the station can pump, its capacity (units of water supply), and a purification factor. Implements ICombineData to merge multiple instances (e.g., when prefabs are combined) and ISerializable to read/write the data for prefab serialization.


Fields

  • public AllowedWaterTypes m_Types
    Bitmask/enum indicating which water types this pumping station can handle (e.g., fresh, dirty, polluted). Used to determine compatibility with water networks and other systems. When combined, the types are merged with a bitwise OR.

  • public int m_Capacity
    Integer capacity of the pumping station (units of water provided). When combining two data instances their capacities are summed.

  • public float m_Purification
    Purification effectiveness expressed as a float in [0,1]. When combining, the purification values are combined multiplicatively to represent sequential purification stages using the formula: m_Purification = 1 - (1 - a) * (1 - b).

Properties

  • This type defines no C# properties. It uses public fields and implements behavior through methods required by its interfaces.

Constructors

  • public WaterPumpingStationData()
    No explicit constructor is defined in source — the default struct constructor applies. Fields should be initialized by the code creating the struct or by deserialization.

Methods

  • public void Combine(WaterPumpingStationData otherData)
    Merges another WaterPumpingStationData into this instance:
  • m_Types |= otherData.m_Types (union of allowed types)
  • m_Capacity += otherData.m_Capacity (sum capacities)
  • m_Purification = 1f - (1f - m_Purification) * (1f - otherData.m_Purification) (combined purification)

This is used by the ICombineData interface to merge multiple data instances for the same entity/prefab.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the struct's data to the provided writer in the following order:
  • m_Capacity (int)
  • m_Purification (float)
  • m_Types cast to ushort

Note: m_Types is stored as a ushort during serialization.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the struct's data from the provided reader in the same order as Serialize:
  • Reads into m_Capacity (int)
  • Reads into m_Purification (float)
  • Reads a ushort and casts to AllowedWaterTypes for m_Types

The deserialize method assigns directly to the struct fields (using ref locals in the source).

Usage Example

// Example: create and combine two pumping station data instances
var a = new WaterPumpingStationData {
    m_Types = AllowedWaterTypes.Fresh | AllowedWaterTypes.Recycled,
    m_Capacity = 100,
    m_Purification = 0.5f
};

var b = new WaterPumpingStationData {
    m_Types = AllowedWaterTypes.Polluted,
    m_Capacity = 50,
    m_Purification = 0.3f
};

a.Combine(b);
// After combine:
// a.m_Types == (Fresh | Recycled | Polluted)
// a.m_Capacity == 150
// a.m_Purification == 1 - (1 - 0.5)*(1 - 0.3) = 0.65

// Serialization example (pseudo-usage; depends on actual writer implementation)
var writer = /* obtain IWriter from serialization system */;
a.Serialize(writer);

// Deserialization example
var reader = /* obtain IReader from serialization system */;
var data = new WaterPumpingStationData();
data.Deserialize(reader);

Notes: - This struct is intended for use within the Entities/ECS and prefab serialization system of Cities: Skylines 2 mods. Ensure that serialization/deserialization uses the same field order. - The Combine method is deterministic and designed to merge prefab/prototype data sensibly (bitwise union, additive capacity, multiplicative purification).