Skip to content

Game.Prefabs.BuildingExtensionData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Component data used to store lightweight metadata for a building extension/prefab placement. Contains world position, lot size, and flags describing whether the extension is external and whether it has underground elements. Important: the Serialize/Deserialize implementations only read/write m_Position, m_LotSize and m_External — m_HasUndergroundElements is declared but not serialized by the implementation in this file (it will remain at its default value after deserialization unless set explicitly).


Fields

  • public Unity.Mathematics.float3 m_Position
    Holds the world position of the building extension. This field is written/read by Serialize/Deserialize.

  • public Unity.Mathematics.int2 m_LotSize
    Stores the lot size (x/y or width/height) for the extension. This field is written/read by Serialize/Deserialize.

  • public bool m_External
    Flag indicating if the extension is external. This field is written/read by Serialize/Deserialize.

  • public bool m_HasUndergroundElements
    Flag indicating whether the extension includes underground elements. NOTE: This field is not serialized/deserialized by the current implementation; it must be set manually in code if needed.

Properties

  • None — this struct exposes no C# properties.

Constructors

  • public BuildingExtensionData() (implicit)
    No explicit constructors are defined. Use the default struct initializer or object initializer to populate fields.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the struct to a writer. The implementation writes, in this order: m_Position (float3), m_LotSize (int2), and m_External (bool). The writer type must implement IWriter. The serialization order must be preserved by any corresponding reader.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the struct from a reader. The implementation reads values in the same order they were written and stores them into m_Position, m_LotSize, and m_External. As noted above, m_HasUndergroundElements is not read and will retain its default value unless set elsewhere.

Usage Example

// Create and populate the component data
var extData = new BuildingExtensionData {
    m_Position = new float3(10f, 0f, 20f),
    m_LotSize = new int2(3, 2),
    m_External = true,
    m_HasUndergroundElements = false // not serialized by default
};

// Add to an ECS entity (EntityManager assumed available)
entityManager.AddComponentData(entity, extData);

// Serializing with a compatible writer (pseudo-code; actual writer depends on game's serializer)
writer.Write(extData.m_Position);
writer.Write(extData.m_LotSize);
writer.Write(extData.m_External);

// Deserialization must follow the same order:
reader.Read(out extData.m_Position);
reader.Read(out extData.m_LotSize);
reader.Read(out extData.m_External);
// Note: m_HasUndergroundElements must be set explicitly after deserialization if required.