Skip to content

Game.Objects.Marker

Assembly:
Game (Assembly-CSharp / Game)

Namespace: Game.Objects

Type: struct

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

Summary: Marker is an empty/tag-style ECS component used by the game's Entity Component System (Unity.Entities). The struct is annotated with a fixed layout and size ([StructLayout(LayoutKind.Sequential, Size = 1)]) so that it occupies a single byte for serialization and interop purposes. It is intended to be used as a marker/tag to mark entities for queries, systems, or game logic without carrying additional data. It also implements IEmptySerializable to participate in the game's Colossal serialization pipeline.


Fields

  • (none — empty struct) This type declares no managed fields. The StructLayout attribute sets Size = 1 so the type has a non-zero size for serialization/interoperability.

Properties

  • (none) No properties are defined on this type.

Constructors

  • (default) public Marker() As a value type, Marker uses the default parameterless constructor. There is no custom constructor defined.

Methods

  • (none) No methods are defined on this type.

Usage Example

// Example: Add a Marker component to an entity using the Unity.Entities API
// (assumes you have an EntityManager or use an ECS system context)

var manager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityArchetype archetype = manager.CreateArchetype(typeof(Marker), /* other components */);
Entity entity = manager.CreateEntity(archetype);

// Or add the marker to an existing entity
manager.AddComponentData(entity, new Marker());

// Example usage in a system query: select entities that have Marker
Entities
    .WithAll<Marker>()
    .ForEach((Entity e) =>
    {
        // Process marked entities
    }).Schedule();

{{ Additional notes: - Because Marker implements IQueryTypeParameter you can use it directly in queries (WithAll(), WithNone(), etc.). - IEmptySerializable + the StructLayout(Size = 1) attribute ensures compatibility with the Colossal serialization used by Cities: Skylines 2 mods and avoids zero-sized type issues when serializing or reflecting components. - Use marker components when you need to tag entities for conditional processing without allocating extra memory per-entity for component data. }}