Skip to content

Game.Prefabs.StackData

Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
StackData is an ECS component used to describe the bounding information and stacking behaviour for prefab pieces that are used in sequences (first / middle / last). It stores three Bounds1 values for the different segment types, a StackDirection enum value that indicates orientation/ordering, and a bool3 mask indicating per-axis scaling restrictions. Its serialization only persists the direction byte; other fields are not written and are initialized (or left default) during deserialization.


Fields

  • public Bounds1 m_FirstBounds
    Bounding extents for the "first" segment in a stack sequence. Typically used to determine placement/collision for the leading piece.

  • public Bounds1 m_MiddleBounds
    Bounding extents for the "middle" / repeating segment. Note: during deserialization this field is explicitly set to new Bounds1(-1f, 1f).

  • public Bounds1 m_LastBounds
    Bounding extents for the "last" segment in a stack sequence. Used for trailing piece placement/collision.

  • public StackDirection m_Direction
    Enum value describing stack orientation/ordering. This field is the only one that is serialized (written as a single byte).

  • public bool3 m_DontScale
    Per-axis flags (X, Y, Z) indicating axes that should not be scaled for this stack entry. Stored as a Unity.Mathematics.bool3.

Properties

  • This type has no properties.

Constructors

  • public StackData()
    Implicit default struct constructor. All fields are default-initialized (Bounds1/float values as default, m_Direction default enum value, m_DontScale default false3). Note that deserialization code will overwrite m_MiddleBounds and m_Direction when reading from a saved stream.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the current m_Direction value as a single byte to the provided writer. Other fields are not written by this implementation.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads a single byte from the provided reader into a local byte, casts that to StackDirection and assigns to m_Direction. Also sets m_MiddleBounds = new Bounds1(-1f, 1f). Other fields (m_FirstBounds, m_LastBounds, m_DontScale) are left as their default values unless handled elsewhere.

Remarks: - Because only m_Direction is serialized, other fields will not be restored from serialized data; code that relies on those fields should initialize them at runtime or else provide additional serialization logic if persistence is required. - Bounds1 and StackDirection types are defined in the game codebase (Colossal.Mathematics and mod/game types). The exact contents/semantics of StackDirection depend on that enum's definition.

Usage Example

// Example: create and add StackData to an entity in an ECS context
using Unity.Entities;
using Unity.Mathematics;
using Colossal.Mathematics;
using Game.Prefabs;

// ... obtain an EntityManager and an Entity (entityManager, entity) ...

var stack = new StackData
{
    m_FirstBounds = new Bounds1(-0.5f, 0.5f),
    m_MiddleBounds = new Bounds1(-1f, 1f),
    m_LastBounds = new Bounds1(-0.5f, 0.5f),
    // set direction to appropriate enum value; replace 0 with the desired StackDirection member
    m_Direction = (StackDirection)0,
    m_DontScale = new bool3(false, true, false) // example: don't scale Y
};

entityManager.AddComponentData(entity, stack);