Skip to content

Game.Prefabs.AdminBuildingData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
AdminBuildingData is an empty/marker ECS component used to tag entities as "administrative buildings" within the game's ECS. The struct is intentionally empty (no payload) and decorated with [StructLayout(LayoutKind.Sequential, Size = 1)] to ensure a non-zero size for serialization and runtime compatibility. It implements Colossal's IEmptySerializable to participate in the game's custom serialization system and IQueryTypeParameter for use with the game's query/type parameter patterns.


Fields

  • This struct declares no instance fields. It is a marker (tag) component; the StructLayout(Size = 1) attribute ensures the type occupies one byte to avoid zero-size issues during serialization and interop.

Properties

  • None.

Constructors

  • public AdminBuildingData() (implicit default constructor)
    As a value type, it has an implicit parameterless constructor that produces the default instance. No custom constructors are defined.

Methods

  • None. This type is a plain marker component and does not expose methods. Its behavior is solely determined by the presence/absence of the component on entities and by systems that query for it.

Usage Example

// Add the marker to an existing entity using EntityManager
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(someEntity, new AdminBuildingData());

// Create an archetype that includes the admin building tag
var archetype = entityManager.CreateArchetype(
    typeof(TransformAuthoring), // example other components
    typeof(AdminBuildingData)
);
var adminEntity = entityManager.CreateEntity(archetype);

// Using an EntityCommandBuffer (e.g., from a system/job)
var ecb = new Unity.Entities.EntityCommandBuffer(Unity.Collections.Allocator.Temp);
ecb.AddComponent<AdminBuildingData>(someEntity);
ecb.Playback(entityManager);
ecb.Dispose();

// Querying for admin buildings in a system (example)
Entities
    .WithAll<AdminBuildingData>()
    .ForEach((Entity e, in SomeOtherComponent comp) =>
    {
        // process admin building entity
    })
    .Schedule();

Notes: - The one-byte size is intentional to avoid problems with zero-sized components and to work with the game's serializer. - Because this component carries no data, it is efficient as a tag; logic should be placed in systems that check for its presence.