Skip to content

Game.Routes.ConnectedRoute

Assembly: Assembly-CSharp
Namespace: Game.Routes

Type: public struct ConnectedRoute

Base: Unity.Entities.IBufferElementData, System.IEquatable, Colossal.Serialization.Entities.IEmptySerializable

Summary:
Represents a single connection (a waypoint reference) in a route buffer used by the game's ECS (Entities) code. This struct is intended to be used as an element type in a DynamicBuffer on an Entity to store links to waypoint Entities. It is marked with InternalBufferCapacity(0), meaning no inline capacity is reserved in the chunk for these buffer elements (all elements are stored out-of-line).


Fields

  • public Unity.Entities.Entity m_Waypoint
    Holds the Entity reference to the waypoint connected by this route element. This field is used for equality and hash code operations, and is the primary payload of the buffer element.

Properties

  • (none)
    This type exposes no C# properties; it only contains a public field.

Constructors

  • public ConnectedRoute(Unity.Entities.Entity waypoint)
    Constructs a ConnectedRoute with the provided waypoint Entity. This initializes the m_Waypoint field.

Methods

  • public bool Equals(ConnectedRoute other)
    Compares this instance to another ConnectedRoute by comparing the underlying Entity (m_Waypoint). Returns true when both refer to the same Entity.

  • public override int GetHashCode()
    Returns the hash code of the underlying Entity (m_Waypoint). Useful when ConnectedRoute values are used in hashed collections or for quick comparisons.

Additional notes: - Implements IEmptySerializable (a Colossal/serialization marker interface) so the type can participate in the game's serialization pipeline. - As an IBufferElementData, this struct is intended to be stored in a DynamicBuffer on an Entity.

Usage Example

// Example: add a waypoint Entity to an entity's ConnectedRoute buffer.
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

// Assume entity and waypoint are valid Entities
Entity routeEntity = ...;
Entity waypoint = ...;

// Ensure the entity has a DynamicBuffer<ConnectedRoute>
if (!entityManager.HasComponent<DynamicBuffer<ConnectedRoute>>(routeEntity))
{
    entityManager.AddBuffer<ConnectedRoute>(routeEntity);
}

DynamicBuffer<ConnectedRoute> buffer = entityManager.GetBuffer<ConnectedRoute>(routeEntity);
// Add a new ConnectedRoute element
buffer.Add(new ConnectedRoute(waypoint));