Skip to content

Game.Prefabs.PillarData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
PillarData is a lightweight ECS component/serializable struct that describes a pillar prefab's type and a single-axis offset range used for placement variation. It implements IComponentData so it can be stored on entities, IQueryTypeParameter to be used in ECS queries, and ISerializable to participate in the game's read/write serialization system. The binary serialization format is compact: an int for the PillarType followed by two floats for the offset range (min, max).


Fields

  • public PillarType m_Type
    Represents the pillar variant/type. Serialized as an int. When deserializing the integer value is cast back to PillarType.

  • public Colossal.Mathematics.Bounds1 m_OffsetRange
    A 1-dimensional bounds containing min and max floats that define the allowed offset range for the pillar (for example, vertical offset or placement jitter). Serialized as two consecutive floats: min then max.

Properties

  • None
    This struct exposes no CLR properties; only public fields and the serialization methods.

Constructors

  • public PillarData()
    No explicit constructors are defined in source — this is a plain value type (struct) and uses the default parameterless constructor generated by the runtime.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component to the writer in the order:
  • (int) m_Type
  • m_OffsetRange.min (float)
  • m_OffsetRange.max (float)
    Important: reader/writer order must match to avoid corrupted data.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads data in the same order the serializer writes:

  • reads an int into a temporary and later casts to PillarType
  • reads float into m_OffsetRange.min by ref
  • reads float into m_OffsetRange.max by ref
    After reads, m_Type is assigned from the integer value.

Usage Example

// Example: create and serialize a PillarData instance
PillarData data = new PillarData {
    m_Type = PillarType.Stone, // example enum value
    m_OffsetRange = new Colossal.Mathematics.Bounds1 { min = -0.1f, max = 0.2f }
};

// Write to a writer (IWriter implementation provided by the game's serialization system)
data.Serialize(writer);

// Later, to read back:
PillarData read = new PillarData();
read.Deserialize(reader);

// As an ECS component: add to an entity (pseudo-code)
// entityManager.AddComponentData(entity, data);

Additional notes: - Binary size is compact: 12 bytes (4 bytes for int + 4 + 4 for the two floats) when using 32-bit int and floats. - Keep writer/reader call order consistent between Serialize and Deserialize. - Because this is an ECS component, it is intended to be attached to prefab/entity archetypes to control pillar placement behavior in-game.