Skip to content

Game.Events.SpectatorEvent

Assembly: Assembly-CSharp (game/mod assembly)
Namespace: Game.Events

Type: struct

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

Summary: SpectatorEvent is an empty marker component (value type) used by the ECS to mark an entity as associated with a "spectator event" concept. The struct contains no runtime fields; it is a tag component intended for queries, conditional logic, and (de)serialization integration with the game's Colossal Serialization system. The StructLayout attribute with Size = 1 ensures the type has a non-zero size for serialization/interop purposes. Implementing IEmptySerializable indicates custom handling by the game's serialization utilities for empty components, and IQueryTypeParameter makes the type usable as a query parameter in entity queries.


Fields

  • None. This struct contains no instance fields and is intentionally empty. {{ This tag component is implemented with StructLayout(Size = 1) so it occupies at least one byte, which helps with serialization and interop. }}

Properties

  • None. {{ As an empty marker component, SpectatorEvent exposes no properties. It only implements marker/query/serialization interfaces. }}

Constructors

  • The type uses the implicit default constructor (public parameterless) provided by the runtime. {{ You can create an instance with new SpectatorEvent() if needed, but most ECS APIs accept the type directly when adding or querying components. }}

Methods

  • None. {{ No methods are defined on this type. Behavior and processing are provided by systems that query for this tag component. }}

Usage Example

// Add the tag component to an entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity();
entityManager.AddComponent<SpectatorEvent>(e);
// or
entityManager.AddComponentData(e, new SpectatorEvent());

// Query entities that have the SpectatorEvent tag
Entities
    .WithAll<SpectatorEvent>()
    .ForEach((Entity entity) =>
    {
        // handle spectator-event entities here
    }).Schedule();

// Remove the tag when it's no longer applicable
entityManager.RemoveComponent<SpectatorEvent>(e);

{{ NOTES: - Use this component as a lightweight marker (tag) to drive systems that process "spectator events". - The IEmptySerializable interface indicates integration with Colossal's serialization; the empty-layout pattern is deliberate to optimize memory and save/load behavior. - Because it's an IComponentData, it can be used in jobs and queries like any other ECS component. }}