Skip to content

Game.Citizens.Child

Assembly: Assembly-CSharp (game assembly)

Namespace: Game.Citizens

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary: Child is an empty/tag ECS component used to mark an entity as a "child" citizen. The struct is intentionally empty and carries no runtime data; its presence on an entity is all that matters. The [StructLayout(LayoutKind.Sequential, Size = 1)] attribute gives the type a non-zero size which can be required by certain serializers or runtime systems. Implements IComponentData to participate in Unity.Entities, IQueryTypeParameter to be usable in query/ForEach type parameters, and IEmptySerializable to integrate with the game's Colossal.Serialization.Entities infrastructure for saving/loading empty components.


Fields

  • This struct defines no fields; it is an empty/tag component.
    {{ Used purely as a marker. No per-instance data is stored; presence/absence on an entity indicates that the entity is a "child" citizen. }}

Properties

  • This struct defines no properties.
    {{ Use Component presence checks (e.g., HasComponent) to query state. }}

Constructors

  • The struct has the implicit default value-type constructor.
    {{ No initialization is required; adding the component is sufficient to tag an entity. }}

Methods

  • This struct defines no methods.
    {{ Behavior is driven by systems that check for the Child tag; there is no behavior inside the struct itself. }}

Usage Example

// Add the Child tag to an entity
entityManager.AddComponent<Child>(someEntity);

// Remove the tag
entityManager.RemoveComponent<Child>(someEntity);

// Check for the tag
if (entityManager.HasComponent<Child>(someEntity)) {
    // entity is a child
}

// Create a query for all child entities inside a SystemBase
var childQuery = GetEntityQuery(ComponentType.ReadOnly<Child>());

// Example Entities.ForEach usage (SystemBase):
Entities
    .WithAll<Child>()
    .ForEach((Entity e) =>
    {
        // operate on child entities
    })
    .Schedule();

{{ NOTES: - Because the component is empty, it is inexpensive in memory and efficient for archetype queries. - The Size = 1 layout attribute is commonly used to ensure a non-zero size for empty types when interacting with serializers or native code. - Implementing IEmptySerializable ties this tag into the game's custom serialization pipeline so empty components can be persisted/restored as needed. }}