Skip to content

Game.Vehicles.Vehicle

Assembly:
Assembly-CSharp

Namespace:
Game.Vehicles

Type:
struct (value type)

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable

Summary:
Vehicle is an empty/tag component used by the game's ECS to mark entities as vehicle entities. It is defined as a zero-field struct but given an explicit layout and size of 1 byte so it is not treated as a true zero-sized type at runtime and can be serialized/handled consistently by Colossal's serialization tooling and Unity's DOTS systems. The implemented interfaces indicate it is a component data type (IComponentData), usable as a query parameter (IQueryTypeParameter), and supports the game's empty-component serialization mechanism (IEmptySerializable).


Fields

  • This struct contains no instance fields.
    The type is decorated with [StructLayout(LayoutKind.Sequential, Size = 1)] to force a size of 1 byte even though it has no fields — preventing issues with zero-sized types in some serialization/interop or ECS scenarios.

Properties

  • None.
    Interfaces implemented are marker/behavioral only; there are no properties declared on this struct.

Constructors

  • public Vehicle() (implicit default)
    As a value type, Vehicle has the implicit parameterless constructor that initializes the struct to its default value. No explicit constructors are defined.

Methods

  • None declared.
    Any behavior is provided by systems that query for this component; the struct itself carries no logic.

Additional notes on interfaces: - IComponentData: marks the struct as a component for Unity's ECS (DOTS). - IQueryTypeParameter: allows usage in query APIs (e.g., WithAll() or Entities.WithAll() patterns). - IEmptySerializable: used by Colossal's serialization framework to handle empty/marker components during save/load.

Usage Example

// Add the tag to an entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new Game.Vehicles.Vehicle());

// Query entities that are vehicles in a SystemBase
Entities
    .WithAll<Game.Vehicles.Vehicle>()
    .ForEach((Entity e) =>
    {
        // e is a vehicle entity — handle vehicle-specific logic here
    })
    .Schedule();

{{ This struct is intentionally minimal — it's a tag component. Use it when you need to mark or query entities as vehicles without carrying per-entity data. The [StructLayout] attribute ensures the struct is non-zero sized for interop and serialization compatibility with the game's tooling. If you need to store per-vehicle data, create a separate IComponentData struct with the required fields and add both the data component and this tag component (or replace the tag with the data component if appropriate). }}