Game.Simulation.PopulationCell
Assembly: Assembly-CSharp (game assembly; actual assembly name may vary)
Namespace: Game.Simulation
Type: struct
Base: System.ValueType, IPopulationCell, IStrideSerializable, ISerializable
Summary:
Represents a simple population value container for a simulation cell. Provides basic operations to get and add population, and implements serialization interfaces used by the game's binary/entity serializer. The struct stores a single float (m_Population) and reports a 4-byte stride for serialization.
Fields
public float m_Population
Holds the population value for this cell as a single-precision floating-point number. Defaults to 0 for the parameterless struct initialization.
Properties
None
This struct exposes no C# properties; access is via the public field and methods.
Constructors
public PopulationCell()
Implicit default parameterless constructor provided by the struct. Initializes m_Population to 0. There is no custom constructor defined in the source.
Methods
-
public float Get()
Returns the current population value (m_Population). -
public void Add(float amount)
Adds the provided amount to m_Population. Simple in-place increment. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Population value to the provided writer. Intended for the game's serialization pipeline. The writer is expected to handle writing a float. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a float from the provided reader into m_Population. Matches the order used by Serialize. -
public int GetStride(Context context)
Returns 4. The stride represents the number of bytes used by this struct when serialized (float = 4 bytes). The provided Context parameter is unused in the implementation.
Usage Example
// Create and modify
var cell = new Game.Simulation.PopulationCell();
cell.Add(12.5f);
float current = cell.Get(); // 12.5f
// Serialization (pseudocode — replace SomeWriter/SomeReader with actual implementations)
SomeWriter writer = /* obtain writer from serializer/context */;
cell.Serialize(writer);
// Deserialization
SomeReader reader = /* obtain reader from serializer/context */;
var cell2 = new Game.Simulation.PopulationCell();
cell2.Deserialize(reader);
float loaded = cell2.Get();