Game.Prefabs.SewageOutletData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ICombineData
Summary:
SewageOutletData is a lightweight ECS component data struct representing parameters of a sewage outlet prefab. It stores the outlet's capacity and a purification factor, supports combination of multiple data instances (useful when aggregating prefab data), and implements simple binary serialization/deserialization used by the game's serialization system.
Fields
-
public int m_Capacity
Holds the integer capacity value for the sewage outlet. Typically represents the throughput or service capacity of the outlet. Used when combining multiple outlets (values are summed). -
public float m_Purification
Holds the purification fraction (floating-point) for the outlet, expected in the range [0, 1]. When combining two SewageOutletData instances the purification values are summed and clamped to a maximum of 1 (100% purification).
Properties
- None declared on this struct. The struct uses public fields and implements required interfaces directly.
Constructors
public SewageOutletData()
(implicit default)
The struct uses the implicit default parameterless constructor provided by C#. Fields default to 0 (m_Capacity = 0, m_Purification = 0f) unless explicitly set.
Methods
public void Combine(SewageOutletData otherData)
Merges another SewageOutletData into this instance. Implementation:- Adds otherData.m_Capacity to this.m_Capacity.
- Adds otherData.m_Purification to this.m_Purification.
-
Clamps m_Purification to a maximum of 1f using math.min(1f, m_Purification). Use case: aggregating contributions when multiple prefabs or subcomponents are combined into a single effective value.
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the data to a writer in binary order: - Writes m_Capacity (int).
-
Writes m_Purification (float). This method conforms to the Colossal.Serialization pattern for saving component data.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the data from a reader in the same order used by Serialize: - Reads into m_Capacity (int).
- Reads into m_Purification (float). The method uses ref locals to read directly into the struct fields.
Usage Example
// Create two SewageOutletData instances (e.g., from two prefabs or chunks)
SewageOutletData outletA = new SewageOutletData { m_Capacity = 100, m_Purification = 0.6f };
SewageOutletData outletB = new SewageOutletData { m_Capacity = 50, m_Purification = 0.5f };
// Combine B into A: capacities add, purification sums then clamps to 1.0
outletA.Combine(outletB);
// Result: outletA.m_Capacity == 150, outletA.m_Purification == 1.0f
// Serialization example (conceptual; TWriter must implement IWriter from Colossal.Serialization.Entities)
void Save<TWriter>(ref TWriter writer, SewageOutletData data) where TWriter : IWriter
{
data.Serialize(writer);
}
// Deserialization example (conceptual; TReader must implement IReader)
SewageOutletData Load<TReader>(ref TReader reader) where TReader : IReader
{
SewageOutletData data = default;
data.Deserialize(reader);
return data;
}