Game.Objects.Stack
Assembly: Assembly-CSharp
Namespace: Game.Objects
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Stack is an ECS component type that stores a one-dimensional range using Colossal.Mathematics.Bounds1. It implements the Colossal.Serialization ISerializable pattern so the range (min and max floats) can be written to and read from a serialization stream. This type is suitable for use as component data in Unity.Entities (Cities: Skylines 2 modding) and participates in querying via IQueryTypeParameter.
Fields
public Bounds1 m_Range
Holds the range as a Bounds1 (typically two floats: min and max). Used by the Serialize/Deserialize implementations to persist the range.
Properties
- This type exposes no properties.
Constructors
public Stack()
Implicit parameterless struct constructor. m_Range will be default-initialized (Bounds1 default).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the range to the provided writer in the order: min, then max. The method reads m_Range.min and m_Range.max into local floats and writes them. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads two floats from the provided reader and assigns them to m_Range.min and m_Range.max. The implementation uses ref locals to directly assign into the Bounds1 fields.
Usage Example
// Create and set component data
var stack = new Game.Objects.Stack
{
m_Range = new Colossal.Mathematics.Bounds1 { min = 0f, max = 10f }
};
// Add to an entity (EntityManager example)
var entityManager = Unity.Entities.World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, stack);
// Serialization example (pseudo-code; obtain writer/reader from serialization system)
TWriter writer = /* get writer from serialization system */;
stack.Serialize(writer);
// Deserialization example
TReader reader = /* get reader from serialization system */;
var loaded = new Game.Objects.Stack();
loaded.Deserialize(reader);
Notes: - Bounds1 is expected to contain float fields named min and max; Serialize writes min then max in that order. - Deserialize uses ref locals to assign directly into m_Range fields. - As a struct and an IComponentData, Stack is intended to be stored directly on entities (value-type semantics).