Skip to content

Game.Creatures.CreatureSpawner

Assembly: Assembly-CSharp (inferred)
Namespace: Game.Creatures

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
CreatureSpawner is an empty marker/component struct used to tag entities that act as creature spawners in the game. It has a very small memory footprint (StructLayout with Size = 1) and is intended to be used purely as a queryable marker (no fields or logic inside). The IEmptySerializable interface indicates it participates in the game's custom serialization pipeline, and IQueryTypeParameter allows it to be used directly in ECS query APIs.


Fields

  • None.
    This struct intentionally contains no fields; it serves as a zero-sized/marker component. The StructLayout(Size = 1) attribute ensures a minimal, consistent layout for serialization/interop.

Properties

  • None.
    No runtime properties are defined; use this type only for tagging/querying entities.

Constructors

  • public CreatureSpawner()
    Default value-type constructor. No initialization is required because the struct contains no fields.

Methods

  • None.
    There are no instance methods. Behavior associated with creature spawners is implemented by systems that query for entities having this component.

Usage Example

// Add as a component when creating an entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(
    typeof(Game.Creatures.CreatureSpawner),
    typeof(Unity.Transforms.LocalToWorld) // example: other components a spawner might have
);
var spawnerEntity = entityManager.CreateEntity(archetype);

// Or add to an existing entity
entityManager.AddComponentData(someEntity, new Game.Creatures.CreatureSpawner());

// Querying in a system (Entities 1.0-style pseudo-code)
public partial struct CreatureSpawnSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        // Iterate over all entities tagged as CreatureSpawner
        foreach (var (spawnerEntity) in SystemAPI.Query<Entity>().WithAll<Game.Creatures.CreatureSpawner>())
        {
            // spawn logic here
        }
    }
}

{{ - Notes: - The attribute [StructLayout(LayoutKind.Sequential, Size = 1)] is used to ensure a consistent minimal layout and to satisfy the serializer/interop expectations. - IEmptySerializable is part of the game's Colossal.Serialization.Entities facilities; it marks the type as serializable by the game serializer despite being empty. - Use this component only as a marker/tag. All runtime behavior should be implemented in systems that query for this component. }}