Game.Simulation.ZoneAmbienceCell
Assembly:
Assembly-CSharp.dll
Namespace:
Game.Simulation
Type:
struct (value type)
Base:
System.ValueType
Implements: Colossal.Serialization.Entities.IStrideSerializable, Colossal.Serialization.Entities.ISerializable
Summary:
Represents a small serializable container that holds two ZoneAmbiences instances: an accumulator and a current value. It implements the game's serialization abstractions (IWriter/IReader) and computes its serialized stride by delegating to the contained ZoneAmbiences instances. This struct is used by the simulation code to store and persist ambient data for zones in a compact, stride-aware form.
Fields
-
public ZoneAmbiences m_Accumulator
Holds accumulated ambience data. Serialized first by Serialize and deserialized first by Deserialize. Used to accumulate or aggregate ambience contributions across updates. -
public ZoneAmbiences m_Value
Holds the current ambience value for the cell. Serialized second and deserialized second. Represents the effective ambience sample for the zone cell.
Properties
- This type defines no properties.
Constructors
public ZoneAmbienceCell()
There is no explicit constructor defined in the source; the default parameterless struct constructor is used. Fields are initialized to their default values (default(ZoneAmbiences)).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes both contained ZoneAmbiences instances to the provided writer in the following order: m_Accumulator then m_Value. Each write delegates to ZoneAmbiences' serialization logic (writer.Write(...)). Use this when persisting the cell to a stream or buffer via the game's IWriter abstraction. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads both contained ZoneAmbiences instances from the provided reader in the same order they were written: m_Accumulator then m_Value. The method reads into the fields by reference (ref) and calls reader.Read(out ...) for each instance. Use this when reconstructing the cell from serialized data. -
public int GetStride(Context context)
Returns the combined stride (serialized size in the stride system) of the two contained ZoneAmbiences instances by calling GetStride(context) on each and summing the results. This is used by stride-based serializers to compute layout and offsets.
Usage Example
// Example: serialize and compute stride for a ZoneAmbienceCell
using Colossal.Serialization.Entities;
using Game.Simulation;
// Create and populate the cell
ZoneAmbienceCell cell = new ZoneAmbienceCell();
cell.m_Accumulator = new ZoneAmbiences(); // populate as needed
cell.m_Value = new ZoneAmbiences(); // populate as needed
// Compute stride (requires a Context instance provided by the serialization environment)
Context ctx = /* obtain context from environment */;
int stride = cell.GetStride(ctx);
// Serialize using an IWriter implementation (pseudocode)
IWriter writer = /* obtain or create writer */;
cell.Serialize(writer);
// Deserialize using an IReader implementation (pseudocode)
IReader reader = /* obtain or create reader with matching data */;
ZoneAmbienceCell loaded = new ZoneAmbienceCell();
loaded.Deserialize(reader);
Notes: - The struct relies on ZoneAmbiences to implement correct serialization and stride reporting. - Serialization order is important: m_Accumulator is written/read first, then m_Value. Ensure writer/reader pairs follow the same order.