Skip to content

Game.LeisureProvider

Assembly: Assembly-CSharp.dll
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
LeisureProvider is an empty (marker/tag) ECS component used to mark building entities that provide leisure-related services. It contains no data and exists only to identify or filter entities in queries. The StructLayout attribute with Size = 1 ensures the type has a non-zero size for serialization and runtime stability when used with the game's serialization/runtime systems (Colossal's ECS/serialization).


Fields

  • This struct defines no instance fields. It is intentionally empty and used purely as a tag component.

Properties

  • This struct exposes no properties.

Constructors

  • public LeisureProvider()
    The default parameterless struct constructor is implicit. No initialization is required because the component carries no data.

Methods

  • This type declares no methods. Behavior is provided by systems that query for this component.

Usage Example

// Adding the tag to an existing entity:
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponent<LeisureProvider>(someBuildingEntity);

// Creating an archetype that includes the tag:
var archetype = entityManager.CreateArchetype(
    typeof(Translation),
    typeof(Building), 
    typeof(LeisureProvider) // mark this entity as a leisure provider
);
var entity = entityManager.CreateEntity(archetype);

// Querying for buildings that are leisure providers:
var query = entityManager.CreateEntityQuery(typeof(LeisureProvider), typeof(Building));
var entities = query.ToEntityArray(Unity.Collections.Allocator.TempJob);
try
{
    foreach (var e in entities)
    {
        // handle leisure building entity
    }
}
finally
{
    entities.Dispose();
}

// Using in a SystemBase:
public partial class LeisureSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .WithAll<LeisureProvider>()
            .ForEach((Entity entity, in Building building) =>
            {
                // logic for leisure buildings
            }).Schedule();
    }
}

Notes: - Because LeisureProvider implements IEmptySerializable (from Colossal.Serialization.Entities), it is intended to participate in the game's serialization pipeline even though it contains no fields. The explicit StructLayout(Size = 1) prevents the component from being a true zero-sized type, which can help avoid issues with certain serializers or native interop. - Use this component as a lightweight tag for filtering and conditional logic in systems rather than storing per-entity data.