Skip to content

Game.Vehicles.OwnedVehicle

Assembly:
Assembly-CSharp (game code / modding assembly; actual assembly may vary)

Namespace:
Game.Vehicles

Type:
struct OwnedVehicle

Base:
Implements: Unity.Entities.IBufferElementData, System.IEquatable, IEmptySerializable
Attribute: [InternalBufferCapacity(0)]

Summary:
Represents a buffer element that holds a reference to a vehicle entity. Intended to be stored in a DynamicBuffer on an owner entity (for example a citizen, building, or manager) to track vehicles owned/associated with that owner. Equality is based on the contained Entity reference. The InternalBufferCapacity(0) attribute indicates no inline buffer capacity is reserved on the owner entity.


Fields

  • public Unity.Entities.Entity m_Vehicle
    Holds the Entity that represents the vehicle. This is the value used for equality and hashing.

Properties

  • None.
    This struct exposes a single public field and implements interfaces directly; it defines no properties.

Constructors

  • public OwnedVehicle(Unity.Entities.Entity vehicle)
    Initializes a new OwnedVehicle instance that references the provided vehicle entity.

Methods

  • public bool Equals(OwnedVehicle other)
    Compares this OwnedVehicle to another by comparing their m_Vehicle Entity values. Returns true if both refer to the same Entity.

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

Usage Example

// Add/obtain a buffer on an owner entity and add a vehicle reference
Entity owner = /* some owner entity */;
Entity vehicle = /* vehicle entity to register */;

var buffer = entityManager.AddBuffer<Game.Vehicles.OwnedVehicle>(owner);
buffer.Add(new Game.Vehicles.OwnedVehicle(vehicle));

// Iterate owned vehicles
foreach (var owned in buffer)
{
    Entity v = owned.m_Vehicle;
    // operate on v
}

Notes: - Because the struct implements IBufferElementData it is intended for use with Unity's ECS DynamicBuffer APIs. - The IEmptySerializable interface is a marker used by the game's serialization utilities; the struct contains no special serialization logic beyond the Entity reference. - InternalBufferCapacity(0) means the buffer does not reserve inline space on the entity itself and will allocate storage separately when elements are added.