Skip to content

Game.Buildings.WaterPumpingStation

Assembly:
Game

Namespace:
Game.Buildings

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents the component data for a water pumping station used by the game's ECS. Holds runtime values such as pollution, capacity and last production for a pumping station entity and implements custom binary serialization/deserialization with version-aware compatibility logic for older save formats.


Fields

  • public float m_Pollution
    Holds the pollution value contributed by the pumping station. When serialized/deserialized its presence in the stream is guarded by historical version checks (see Deserialize).

  • public int m_Capacity
    The pumping station's capacity value. Always read/written by the current serialization implementation.

  • public int m_LastProduction
    Stores the last production amount of the station. Its read/write is subject to version checks in Deserialize to preserve compatibility with older formats.

Properties

  • This type exposes no C# properties. All data is stored in public fields.

Constructors

  • public WaterPumpingStation()
    No explicit constructor is declared in the source — this is a plain struct and therefore has the default parameterless value-type constructor generated by the runtime. Fields default to 0 / 0f if not initialized.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component state to the provided writer in the following order: m_Pollution, m_Capacity, m_LastProduction. The method assumes the current serialized layout and does not perform version-specific branching when writing; consumers must rely on the matching Deserialize logic when reading.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from the provided reader while handling historical save-file layout differences using reader.context.version checks:

  • If reader.context.version < Version.waterPipeFlowSim the method reads and discards an int (legacy placeholder).
  • If reader.context.version >= Version.waterPipePollution the pollution field (m_Pollution) is read into the struct; otherwise an int is read and discarded (legacy layout).
  • The capacity (m_Capacity) is always read.
  • If reader.context.version >= Version.waterSelectedInfoFix then:
    • If reader.context.version < Version.waterPipeFlowSim, an extra int is read and discarded (legacy placeholder).
    • The last production (m_LastProduction) is then read. This logic preserves compatibility with older save versions while populating the current fields when present.

Usage Example

// Example: creating and attaching the component to an entity
var station = new WaterPumpingStation {
    m_Pollution = 0f,
    m_Capacity = 1000,
    m_LastProduction = 0
};
entityManager.AddComponentData(entity, station);

// Example: custom initialization when creating an ECS system entity
[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // Create entity and add WaterPumpingStation with defaults or configured values
    var stationEntity = EntityManager.CreateEntity(typeof(WaterPumpingStation));
    EntityManager.SetComponentData(stationEntity, new WaterPumpingStation { m_Capacity = 2000 });
}