Skip to content

Game.Prefabs.Modes.GameModeComponent

Assembly:
(Assembly-CSharp or game-specific assembly where mod types are compiled; not specified in source)

Namespace:
Game.Prefabs.Modes

Type:
struct

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
Lightweight tag component (an empty struct) used with the Unity Entities (DOTS) system. The presence of this component on an entity is intended to mark that entity as a "game mode" prefab or to participate in queries that target game mode entities. The struct is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to force a minimum size (1 byte), avoiding zero-size-layout pitfalls for empty structs when used in native containers or serialization contexts.


Fields

This type defines no instance fields. It is intentionally empty and used only as a tag.

Properties

This type defines no properties.

Constructors

  • public GameModeComponent()
    Implicit parameterless value-type constructor (default). No initialization logic is required or present because the struct is empty.

Methods

This type defines no methods.

Usage Example

// Add the tag component to an entity (EntityManager API)
var manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = manager.CreateEntity(typeof(GameModeComponent));

// Check for the tag
bool hasTag = manager.HasComponent<GameModeComponent>(entity);

// Remove the tag
manager.RemoveComponent<GameModeComponent>(entity);

// Use in a query with Entities.ForEach or ComponentSystemBase
Entities
    .WithAll<GameModeComponent>()
    .ForEach((Entity e) =>
    {
        // handle game-mode entities
    }).Schedule();

Notes for modders: - Use this component as a marker/tag. It carries no data, so use separate components for any data you need to store. - The StructLayout(Size = 1) attribute ensures the struct occupies space when compiled, which can prevent certain runtime/native issues associated with zero-sized types. - Because it implements IQueryTypeParameter, it is suitable for use in query declarations (WithAll, WithAny, etc.) to filter entities.