Game.Routes.SubRoute
Assembly: Game
Namespace: Game.Routes
Type: struct
Base: IBufferElementData, IEquatable
Summary:
Represents a single entry in a dynamic ECS buffer that references a route entity. This struct is intended for use with Unity's DOTS/Entities systems in Cities: Skylines 2 modding. It is marked with [InternalBufferCapacity(0)], making the buffer start with zero inline capacity (purely dynamic). Equality and hashing are implemented based on the contained Entity reference so instances can be compared reliably.
Fields
public Unity.Entities.Entity m_Route
Holds the Entity reference to the route (the "sub-route"). This is the only stored data in the buffer element; it is the value used for Equals and GetHashCode.
Properties
- This type exposes no properties.
Constructors
public SubRoute(Unity.Entities.Entity route)
Initializes a new SubRoute with the provided route Entity. Simply assigns route to m_Route.
Methods
-
public bool Equals(SubRoute other)
Returns true if the contained Entity equals the other instance's Entity. Uses Entity.Equals for comparison. -
public override int GetHashCode()
Returns the hash code of the contained Entity (delegates to m_Route.GetHashCode()). -
Implements marker interface
IEmptySerializable
(no runtime methods) to participate in the game's/custom serialization pipeline where required.
Usage Example
// Example of using SubRoute in a system to append a route entity to an entity's buffer
public partial class RouteSystem : SystemBase
{
protected override void OnUpdate()
{
// Assume 'entityWithBuffer' has a DynamicBuffer<SubRoute>
Entities
.WithName("AddSubRoute")
.ForEach((Entity entity, ref DynamicBuffer<Game.Routes.SubRoute> buffer) =>
{
var routeEntity = /* obtain route entity */;
buffer.Add(new Game.Routes.SubRoute(routeEntity));
}).ScheduleParallel();
}
}
Notes: - The [InternalBufferCapacity(0)] attribute makes buffers of this element type allocate storage dynamically rather than reserving inline space on the entity. - Because equality and hashing rely solely on the Entity value, two SubRoute instances with the same Entity are considered equal.