Skip to content

Game.Citizens.Teen

Assembly: Game
Namespace: Game.Citizens

Type: struct

Base: System.ValueType (implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable)

Summary: A small marker/flag component used by the game's ECS to mark a citizen as a "Teen". The struct is intentionally empty and marked with StructLayout(LayoutKind.Sequential, Size = 1) so it has a defined non-zero size for serialization and interop; it functions as a lightweight tag component for queries and systems.


Fields

  • (none) This struct contains no instance fields. The StructLayout attribute sets the managed layout and forces a size of 1 byte so it can be serialized and used as an empty/tag component reliably.

Properties

  • (none) No properties are defined — this type is a pure marker/tag component.

Constructors

  • Implicit parameterless constructor As a value type (struct) there is an implicit default constructor that produces a zero-initialized instance. No custom constructors are defined.

Methods

  • (none) There are no methods implemented on this struct. It implements marker interfaces only (IComponentData, IQueryTypeParameter, IEmptySerializable) and therefore requires no method implementations.

Usage Example

// Create an entity and mark it as a Teen
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddComponent<Teen>(entity);

// Querying for teen citizens in a system
public partial class TeenProcessingSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .WithAll<Teen>()
            .ForEach((Entity e /*, other components... */) =>
            {
                // Process teen citizens
            })
            .Schedule();
    }
}

// Using EntityCommandBuffer inside a job to add the tag
public partial class MarkTeenSystem : SystemBase
{
    protected override void OnUpdate()
    {
        var ecb = new EntityCommandBuffer(Unity.Collections.Allocator.Temp);
        Entities
            .WithNone<Teen>()
            .ForEach((Entity e /*, some components to decide */) =>
            {
                // Conditionally mark as teen
                ecb.AddComponent<Teen>(e);
            })
            .Run();

        ecb.Playback(EntityManager);
        ecb.Dispose();
    }
}

Additional notes: - Because Teen is an empty/tag component, prefer using AddComponent(entity) rather than AddComponentData to reflect its empty nature. - The IEmptySerializable interface indicates the type is intended to participate in the game's serialization pipeline as an empty/marker type.