Skip to content

Game.Routes.RouteVehicle

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

Type: struct

Base: IBufferElementData, IEquatable, IEmptySerializable

Summary:
Represents a single vehicle reference stored in a dynamic ECS buffer for route-related data. This buffer element holds a Unity.Entities.Entity that identifies the vehicle. The type is marked with [InternalBufferCapacity(0)], so the dynamic buffer has no inline capacity and will allocate storage externally. IEmptySerializable indicates it participates in the game's serialization pipeline.


Fields

  • public Unity.Entities.Entity m_Vehicle
    Holds the Entity that represents the vehicle. Used to reference the vehicle from route-related buffers/systems.

Properties

  • (none)
    This struct exposes its data via the public field m_Vehicle; it does not define additional properties.

Constructors

  • public RouteVehicle(Unity.Entities.Entity vehicle)
    Initializes a RouteVehicle with the given vehicle Entity (assigns m_Vehicle = vehicle).

Methods

  • public bool Equals(RouteVehicle other)
    Compares this RouteVehicle to another by comparing their m_Vehicle fields (delegates to Entity.Equals).

  • public override int GetHashCode()
    Returns the hash code of the contained Entity (delegates to m_Vehicle.GetHashCode()).

Usage Example

// Add a dynamic buffer of RouteVehicle to an entity and add a vehicle reference.
var buffer = EntityManager.AddBuffer<Game.Routes.RouteVehicle>(routeEntity);
buffer.Add(new Game.Routes.RouteVehicle(vehicleEntity));

// Read or iterate:
var routeBuffer = EntityManager.GetBuffer<Game.Routes.RouteVehicle>(routeEntity);
foreach (var rv in routeBuffer)
{
    Entity veh = rv.m_Vehicle;
    // use veh in systems/jobs
}

Additional notes: - Because this is an IBufferElementData, use DynamicBuffer in systems and jobs. - The [InternalBufferCapacity(0)] attribute sets zero inline capacity; many elements will allocate on the heap. - Ensure correct entity lifetime handling: the stored Entity may point to destroyed or recycled vehicles — validate before use.