Game.Simulation.LandValueCell
Assembly: Assembly-CSharp
Namespace: Game.Simulation
Type: struct
Base: System.ValueType, ILandValueCell, IStrideSerializable, ISerializable
Summary:
Lightweight value-type that stores a single land value (float) for a simulation cell. Implements simple add semantics and provides serialization/deserialization and stride-size reporting for binary/stride-based serializers used by the simulation/engine.
Fields
public float m_LandValue
Stores the numeric land value for this cell. This field is public and represents the primary data held by the struct (4 bytes, IEEE single-precision float). Typical usage is accumulating or reading land-value contributions for a grid cell in the simulation.
Properties
- (none)
This struct exposes its data directly via the public field; there are no CLR properties defined.
Constructors
public LandValueCell()
Default value-type constructor (implicitly provided). Initializes m_LandValue to 0.0f. No explicit constructor is defined in the source.
Methods
-
public void Add(float amount)
Adds the provided amount to m_LandValue. Useful for accumulating multiple contributions into the same cell. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_LandValue to the provided writer. This method satisfies ISerializable/serialization patterns used by the engine. Implementation simply calls writer.Write(m_LandValue). -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a float value from the provided reader into m_LandValue. Implementation calls reader.Read(out m_LandValue). -
public int GetStride(Context context)
Returns the stride (in bytes) required to store this struct when using stride-based serialization; returns 4 (size of a single float). The Context parameter is provided by the IStrideSerializable interface but is not used by this implementation.
Usage Example
// Create and use a LandValueCell
var cell = new Game.Simulation.LandValueCell();
cell.Add(12.5f);
cell.Add(-2.0f);
float current = cell.m_LandValue; // 10.5f
// Example serialization (pseudo-API)
using (var writer = new SomeBinaryWriter(...))
{
cell.Serialize(writer);
}
// Example deserialization (pseudo-API)
var readCell = new Game.Simulation.LandValueCell();
using (var reader = new SomeBinaryReader(...))
{
readCell.Deserialize(reader);
}
Notes: - The struct is copy-by-value; passing it around will copy m_LandValue. - GetStride returns 4, matching the 4 bytes used to store the single float value.