Skip to content

Game.Buildings.Extension

Assembly: Assembly-CSharp (game code / mod runtime)
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a small, serializable ECS component used by the game's building system to store extension-related flags for an entity. The component stores its flags in a single byte when serialized. It is intended to be used with Unity's ECS (Entity Component System) as a component data type and can be used as a query parameter because it implements IQueryTypeParameter.


Fields

  • public ExtensionFlags m_Flags
    Holds the extension flags for this component. ExtensionFlags is an enum (flags) used by the building subsystem to represent various extension states/behaviours. When serialized, the enum value is cast to a byte and written/read as a single byte.

Properties

  • (none)
    This struct exposes no properties. It is a plain data component (struct) with a single public field. Being a value type it has the implicit default constructor that initializes m_Flags to the enum's default (usually 0).

Constructors

  • public Extension()
    Implicit default struct constructor. Initializes m_Flags to the default value (0 / no flags set). There is no custom parameterized constructor defined in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the component by writing the flags as a single byte: writer.Write((byte)m_Flags). This compact representation minimizes storage for this small component.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the component by reading a byte and casting it back to the ExtensionFlags enum: reader.Read(out byte value); m_Flags = (ExtensionFlags)value;

These methods implement the ISerializable contract used by Colossal's serialization system.

Usage Example

// Create an entity and set the Extension component
var entity = entityManager.CreateEntity(typeof(Game.Buildings.Extension));
var ext = new Game.Buildings.Extension { m_Flags = ExtensionFlags.SomeFlag | ExtensionFlags.OtherFlag };
entityManager.SetComponentData(entity, ext);

// Reading back
var readExt = entityManager.GetComponentData<Game.Buildings.Extension>(entity);
if ((readExt.m_Flags & ExtensionFlags.SomeFlag) != 0)
{
    // do something for this flag
}

// Example: manual serialization (illustrative)
void SerializeExtension<TWriter>(TWriter writer, Game.Buildings.Extension e) where TWriter : IWriter
{
    // writes a single byte representing the flags
    writer.Write((byte)e.m_Flags);
}

void DeserializeExtension<TReader>(TReader reader, out Game.Buildings.Extension e) where TReader : IReader
{
    reader.Read(out byte val);
    e = new Game.Buildings.Extension { m_Flags = (ExtensionFlags)val };
}

Notes and tips: - ExtensionFlags is stored in one byte during serialization — be aware of the enum underlying type and any flags exceeding byte range. - Because this is a plain ECS IComponentData struct, it is safe and efficient to use in large arrays and queries. - Implementing IQueryTypeParameter means this type can be used directly in ECS queries/for-each patterns where supported.