Skip to content

Game.Buildings.SewageOutlet

Assembly:
Assembly-CSharp

Namespace:
Game.Buildings

Type:
struct

Base:
Implements: IComponentData, IQueryTypeParameter, ISerializable

Summary:
SewageOutlet is an ECS component used by the building simulation to track sewage outlet state for an entity (a sewage outlet building). It holds capacity and bookkeeping counters used by the sewage/water simulation and supports binary serialization with backward-compatibility logic for older save versions.


Fields

  • public int m_Capacity
    Represents the outlet's capacity (maximum units handled per simulation step). Used by the water/sewage flow simulation to limit throughput.

  • public int m_LastProcessed
    Integer index/timestamp of the last simulation step when this outlet was processed. Used to avoid reprocessing in the same simulation tick/frame.

  • public int m_LastPurified
    Index/timestamp or counter indicating the last time purification-related logic ran for this outlet (inferred from name). Helps track purification state across updates.

  • public int m_UsedPurified
    Counter of purified units that have been used/drained/consumed since last relevant update (inferred from name). Used for bookkeeping of purified sewage throughput.

Properties

  • None. This struct exposes only public fields and implements the required interfaces.

Constructors

  • public SewageOutlet()
    No explicit constructor is defined in the source; the default parameterless struct constructor is used. Initialize fields directly when creating instances or via object initializer syntax.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes component data in a fixed order: m_Capacity, m_LastProcessed, m_LastPurified, m_UsedPurified. This order must match the Deserialize logic. Used by the game's save system to persist component state.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data and contains branching logic to preserve backward compatibility with older save formats:

  • If reader.context.version < Version.waterPipeFlowSim: the code reads and discards some ints (older layout), and conditionally discards additional ints depending on Version.stormWater and Version.sewageSelectedInfoFix.
  • Otherwise (newer saves): reads the four fields in the same order written by Serialize and assigns them to m_Capacity, m_LastProcessed, m_LastPurified, and m_UsedPurified. This method protects against mismatched field layouts across game versions.

Usage Example

// Create and attach to an entity via Entities API
var outlet = new SewageOutlet {
    m_Capacity = 200,
    m_LastProcessed = -1,
    m_LastPurified = -1,
    m_UsedPurified = 0
};
entityManager.AddComponentData(entity, outlet);

// Serialization example (pseudo, depends on game's writer types)
public void SaveOutlet<TWriter>(TWriter writer, SewageOutlet outlet) where TWriter : IWriter {
    outlet.Serialize(writer);
}

// Deserialization example (pseudo, depends on game's reader and version context)
public SewageOutlet LoadOutlet<TReader>(TReader reader) where TReader : IReader {
    var outlet = new SewageOutlet();
    outlet.Deserialize(reader);
    return outlet;
}

Notes: - This struct is designed for Unity Entities/ECS usage (IComponentData). Handle instances using the EntityManager / systems APIs. - The Deserialize method relies on Version.* constants from the game's serialization versioning. When writing tools or mods that interact with save data, ensure you respect the same versioning semantics to maintain compatibility with different game save formats.