Skip to content

Game.Prefabs.BuildingOptionData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
BuildingOptionData is a small ECS component that stores a 32-bit option bitmask for a building prefab. It is implemented as a value type (struct) and is intended to be attached to entities to represent per-building boolean/options flags in a compact form. Because it implements IComponentData it can be used with Unity's DOTS ECS; implementing IQueryTypeParameter makes it usable in query contexts that accept query-type parameters.


Fields

  • public System.UInt32 m_OptionMask
    A 32-bit unsigned integer used as a bitmask to represent various building options/flags. Each bit represents an independent on/off option; 0 means the option is off. Use a [Flags] enum cast to uint (or constants) to give semantic meaning to individual bits and make code clearer.

Properties

  • This type declares no properties. It exposes a single public field (m_OptionMask).

Constructors

  • This struct uses the default parameterless constructor provided by C#. All fields default to zero (m_OptionMask == 0). You may construct it explicitly when adding the component:
  • Example implicit/default: new BuildingOptionData() -> m_OptionMask = 0
  • Example explicit: new BuildingOptionData { m_OptionMask = 0x1 }

Methods

  • This type declares no methods.

Usage Example

// Define a Flags enum to label bits (optional, for clarity)
[System.Flags]
public enum BuildingOptions : uint
{
    None        = 0,
    OptionA     = 1u << 0, // bit 0
    OptionB     = 1u << 1, // bit 1
    OptionC     = 1u << 2, // bit 2
    // ... up to 32 flags
}

// Adding the component to an entity with specific options:
var options = BuildingOptions.OptionA | BuildingOptions.OptionC;
entityManager.AddComponentData(entity, new Game.Prefabs.BuildingOptionData
{
    m_OptionMask = (uint)options
});

// Reading and testing flags:
var data = entityManager.GetComponentData<Game.Prefabs.BuildingOptionData>(entity);
bool hasOptionA = (data.m_OptionMask & (uint)BuildingOptions.OptionA) != 0;
bool hasOptionB = (data.m_OptionMask & (uint)BuildingOptions.OptionB) != 0;