Skip to content

Game.Objects.Crane

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

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
Crane is an empty/tag ECS component used to mark entities as cranes (for example, construction cranes or similar in-game objects). The struct is explicitly given a sequential layout with Size = 1 to ensure a non-zero size for serialization and native interop. Because it contains no data, it functions purely as a presence/marker component that systems and queries can use to identify crane entities.


Fields

  • This struct declares no instance fields.
    Because the type is an empty tag component, there are no stored fields; the [StructLayout(LayoutKind.Sequential, Size = 1)] attribute forces a non-zero size for serialization/native interop.

Properties

  • This type exposes no properties.
    It only implements marker interfaces (IComponentData, IQueryTypeParameter, IEmptySerializable) used by the ECS and the game's serialization systems.

Constructors

  • public Crane() (implicit default)
    The default parameterless constructor is available (implicitly). Instantiation is typically done with new Crane() when adding the component to an entity or when creating an entity archetype.

Methods

  • This struct declares no methods.
    All behavior is provided by ECS systems operating on the presence of this component. Implemented interfaces are marker interfaces and do not require instance methods.

Usage Example

using Unity.Entities;

// Add Crane as a marker to an existing entity
entityManager.AddComponentData(existingEntity, new Crane());

// Create an entity with the Crane tag in its archetype
var archetype = entityManager.CreateArchetype(typeof(Crane), typeof(Translation), typeof(RenderMesh));
Entity craneEntity = entityManager.CreateEntity(archetype);

// Using an EntityCommandBuffer (e.g., inside a system)
ecb.AddComponent<Crane>(someEntity);

// Querying for Crane-tagged entities
Entities
    .WithAll<Crane>()
    .ForEach((Entity entity) =>
    {
        // Handle crane entity...
    }).Schedule();

Notes: - Use Crane as a lightweight tag to select, filter, or identify entities in systems and jobs. - The explicit struct layout and Size = 1 helps with binary serialization and prevents zero-sized type edge cases in some runtimes or tooling.