Game.Prefabs.GroundWaterPoweredData
Assembly:
Game (assembly containing Game.Prefabs; commonly part of the game's mod assembly / Assembly-CSharp)
Namespace: Game.Prefabs
Type:
struct
Base:
Implements:
- Unity.Entities.IComponentData
- Unity.Entities.IQueryTypeParameter
- ICombineData
- Colossal.Serialization.Entities.ISerializable
Summary:
Component data used by the game's ECS to represent groundwater-powered production for a prefab. Stores current production and the maximum available groundwater. Supports combining with another instance (useful when aggregating data from multiple sources) and binary-style serialization/deserialization via the ISerializable pattern used in the engine.
Fields
-
public System.Int32 m_Production
Holds the current groundwater production value for this component instance. Used by systems that consume or display production rates. -
public System.Int32 m_MaximumGroundWater
Holds the maximum groundwater available / capacity for this component instance. Used to cap or report available groundwater.
Properties
- None (no explicit C# properties are declared on this struct)
Constructors
public GroundWaterPoweredData()
Default value-type constructor provided by C#. Both integer fields are initialized to 0 unless explicitly set. You can initialize with an object initializer to set values.
Methods
public void Combine(GroundWaterPoweredData otherData)
Combines another GroundWaterPoweredData into this instance by summing production and maximum groundwater:- m_Production += otherData.m_Production
-
m_MaximumGroundWater += otherData.m_MaximumGroundWater Use this when aggregating data from multiple components (for example, when merging results from multiple matched entities).
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component's data to a writer in a simple sequential format: - Writes m_Production (int)
-
Writes m_MaximumGroundWater (int) This follows the ISerializable contract used by the game's save/load and network layers.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component's data from a reader in the same order used by Serialize: - Reads an int into m_Production
- Reads an int into m_MaximumGroundWater Ensure the reader corresponds to the same writer layout used during serialization.
Usage Example
// Simple initialization and combine example
var a = new GroundWaterPoweredData { m_Production = 10, m_MaximumGroundWater = 100 };
var b = new GroundWaterPoweredData { m_Production = 5, m_MaximumGroundWater = 50 };
// Aggregate b into a
a.Combine(b);
// a.m_Production == 15
// a.m_MaximumGroundWater == 150
// Serialization example (pseudocode — depends on game's IWriter/IReader implementations)
using (var writer = GetGameWriter())
{
a.Serialize(writer);
}
using (var reader = GetGameReader())
{
var deserialized = new GroundWaterPoweredData();
deserialized.Deserialize(reader);
}
Notes: - Because this is an IComponentData, instances are intended to be stored on ECS entities and manipulated by systems rather than used like regular objects. - Combine is additive; if you need different aggregation semantics (max, average, etc.), adjust accordingly before or after combining.