Skip to content

Game.Simulation.SoilWater

Assembly:
Assembly-CSharp (game code)

Namespace:
Game.Simulation

Type:
struct

Base:
System.ValueType, Colossal.Serialization.Entities.IStrideSerializable, Colossal.Serialization.Entities.ISerializable

Summary:
Represents a compact, serializable container for soil water information used by the simulation. Holds a surface value (float) and two 16-bit integer quantities (current amount and maximum). Implements the game's IWriter/IReader-based serialization interfaces and reports a fixed stride of 8 bytes (4 bytes for the float + 2 + 2 for the shorts). Serialization/deserialization is performed in a fixed order: m_Surface, m_Amount, m_Max.


Fields

  • public System.Single m_Surface
    Surface-level water value (float). Serialized first. Represents e.g. water depth at the soil surface or a normalized surface wetness value depending on the simulation use.

  • public System.Int16 m_Amount
    Current amount of water (short). Serialized second.

  • public System.Int16 m_Max
    Maximum amount of water (short). Serialized third.

Properties

  • None.
    This struct exposes only public fields; there are no C# properties.

Constructors

  • public SoilWater()
    Implicit parameterless struct constructor. When default-initialized, m_Surface == 0f, m_Amount == 0, m_Max == 0. No explicit custom constructor is defined in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
    Writes the fields to the provided writer in the order: m_Surface (float), m_Amount (short), m_Max (short). The writer is expected to implement the IWriter interface used by the game's serialization system.

  • public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
    Reads values from the provided reader into the struct fields by reference in the same order they were written: m_Surface, m_Amount, m_Max. The reader must implement the game's IReader interface.

  • public int GetStride(Colossal.Serialization.Entities.Context context)
    Returns the fixed byte stride required for this struct when packed into a contiguous buffer. Returns 8 (4 bytes for float + 2 bytes + 2 bytes). The provided Context parameter is unused by this implementation.

Usage Example

// Create and populate
var soil = new SoilWater {
    m_Surface = 0.12f,
    m_Amount = 50,
    m_Max = 100
};

// Serialize with any IWriter implementation used by the game
IWriter writer = /* obtain or create an IWriter-compatible writer */;
soil.Serialize(writer);

// Later, deserialize with a corresponding IReader
IReader reader = /* obtain or create an IReader-compatible reader */;
SoilWater loaded = default;
loaded.Deserialize(reader);

// loaded now has the same field values as 'soil'
// GetStride can be used when allocating buffers for packed data:
int stride = loaded.GetStride(new Context());

Notes: - Field names use the game's internal naming convention (m_ prefix); fields are public and mutable. - The serialization order must be preserved between Serialize and Deserialize to ensure correct round-trip behavior. - Stride value is constant (8), so this struct is well-suited for tight, fixed-size binary storage.