Skip to content

Game.Zones.BuildOrder

Assembly: Assembly-CSharp
Namespace: Game.Zones

Type: struct

Base: System.ValueType (implements IComponentData, IQueryTypeParameter, ISerializable)

Summary:
BuildOrder is a small value-type component used by the zone/building systems to store an unsigned integer representing the order or priority for a build operation. It is an ECS component (IComponentData) and supports custom binary serialization via the ISerializable pattern used in the game's save/load systems. Typical use is to attach this component to entities to track their build queue position or ordering index.


Fields

  • public System.UInt32 m_Order
    Holds the build order index (unsigned 32-bit). Semantics are: lower/higher values may indicate earlier/later processing depending on the surrounding system. This field is what gets written/read by the component's Serialize/Deserialize implementations.

Properties

  • This type exposes no properties. It is a plain struct with a single public field.

Constructors

  • public BuildOrder()
    Implicit default constructor generated for the struct. You can initialize the field with an object initializer, e.g. new BuildOrder { m_Order = 5 }.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_Order field to the provided writer. The method calls writer.Write(m_Order), ensuring the value is persisted in the component serialization stream used by the game's save system.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the m_Order field from the provided reader. The method calls reader.Read(out m_Order) to restore the saved value into the component.

Usage Example

// Add BuildOrder to an entity using Unity.Entities EntityManager
using Unity.Entities;
using Game.Zones;

// get an EntityManager (example in a system or initialization code)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

// create an entity with the BuildOrder component
var entity = entityManager.CreateEntity(typeof(BuildOrder));

// set the build order index to 3
entityManager.SetComponentData(entity, new BuildOrder { m_Order = 3 });

// Alternatively, when constructing entities via an EntityCommandBuffer:
var ecb = new Unity.Entities.EntityCommandBuffer(Unity.Collections.Allocator.Temp);
ecb.AddComponent(entity, new BuildOrder { m_Order = 10 });
ecb.Playback(entityManager);
ecb.Dispose();

Notes: - Because BuildOrder implements ISerializable, it's used by the game's custom serialization pipeline; the Serialize/Deserialize methods must remain compatible with save formats. - The struct also implements IQueryTypeParameter to allow use in query definitions or other ECS-related APIs that expect that marker.