Skip to content

Game.Creatures.Stumbling

Assembly:
Assembly-CSharp (game code)

Namespace:
Game.Creatures

Type:
struct

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

Summary:
Stumbling is a tag (marker) ECS component used to mark creature entities that are currently in a "stumbling" state. The struct is intentionally empty and uses a fixed layout of size 1 (StructLayout(LayoutKind.Sequential, Size = 1)) so it occupies a minimal, non-zero size for interop/serialization and engine compatibility. The component implements IComponentData for placement in the Unity Entities world, IQueryTypeParameter to be usable directly in queries, and IEmptySerializable (Colossal.Serialization.Entities) so the game's serialization system can include it in save/load data.


Fields

  • None. This is an empty/tag component; no instance data is stored on the component type.

Notes: - The source applies [StructLayout(LayoutKind.Sequential, Size = 1)] to ensure the component has a non-zero size for interop/serialization even though it contains no fields.

Properties

  • None.

Constructors

  • public Stumbling() (implicit)

Notes: - As a value type (struct) there is an implicit parameterless constructor. No explicit constructors are defined in source.

Methods

  • None.

Notes: - The type contains no methods. Behavior tied to the "stumbling" state should be implemented in systems that add/remove or query this tag component.

Usage Example

// Mark an entity as stumbling (immediately):
entityManager.AddComponent<Stumbling>(creatureEntity);

// Or, from a system using an EntityCommandBuffer (deferred in jobs):
ecb.AddComponent<Stumbling>(creatureEntity);

// Remove the tag:
entityManager.RemoveComponent<Stumbling>(creatureEntity);

// Query all stumbling creatures in a SystemBase:
protected override void OnUpdate()
{
    Entities
        .WithAll<Stumbling>()
        .ForEach((Entity entity) =>
        {
            // Handle stumbling behavior (e.g., apply slow, play animation, start recovery timer)
        })
        .ScheduleParallel();
}

// Example: Add the tag on a condition
Entities
    .ForEach((Entity entity, in SomeCreatureState state) =>
    {
        if (state.shouldStumble)
        {
            ecb.AddComponent<Stumbling>(entity);
        }
    })
    .ScheduleParallel();

Additional notes: - Use EntityCommandBuffer to add/remove this component safely from jobs. - Because this is a tag component, systems typically use WithAll() / WithNone() or HasComponent checks to branch logic. - IEmptySerializable ensures the component participates in the game's serialization pipeline (saves/loads) even though it contains no data.