Game.Net.SubLane
Assembly: Game
Namespace: Game.Net
Type: struct
Base: System.ValueType, IBufferElementData, IEquatable
Summary: Represents a reference to a sub-lane entity together with pathfinding method flags. This struct is intended to be stored in an ECS dynamic buffer (InternalBufferCapacity(0) attribute) and used by the net/pathfinding systems to identify and process sub-lanes. Equality and hash code are based only on the referenced Entity (m_SubLane), not on the PathMethod flags.
Fields
-
public Entity m_SubLane
Holds the Entity that represents the sub-lane. This is the identity used for equality and hashing; two SubLane instances are considered equal if they reference the same Entity. -
public PathMethod m_PathMethods
Flags describing which pathfinding methods apply to this sub-lane (Game.Pathfind.PathMethod). These flags are carried alongside the sub-lane reference but are not considered by Equals/GetHashCode.
Properties
- None. This struct exposes public fields and does not define C# properties.
Constructors
public SubLane(Entity lane, PathMethod pathMethods)
Initializes a new SubLane with the given sub-lane Entity and PathMethod flags.
Notes: - A default parameterless constructor exists implicitly for the struct and will leave fields at their default values (Entity = default, PathMethod = default).
Methods
-
public bool Equals(SubLane other)
Compares this instance to another SubLane. Returns true if the two instances reference the same m_SubLane Entity. PathMethod is ignored in equality comparison. -
public override int GetHashCode()
Returns the hash code of the m_SubLane Entity. This matches the Equals implementation by using only the Entity for hashing.
Additional implementation details:
- Implements IBufferElementData so instances can be stored in a DynamicBuffer
Usage Example
// Example inside a System or other ECS code:
Entity laneEntity = /* obtain a sub-lane entity */;
PathMethod methods = PathMethod.RoadVehicle | PathMethod.EmergencyVehicle;
// Create a SubLane value
SubLane subLane = new SubLane(laneEntity, methods);
// Add to a DynamicBuffer<SubLane> on some parent entity:
var buffer = EntityManager.GetBuffer<SubLane>(parentEntity);
buffer.Add(subLane);
// Comparing two SubLane instances:
SubLane a = new SubLane(laneEntity, PathMethod.RoadVehicle);
SubLane b = new SubLane(laneEntity, PathMethod.ParkingVehicle);
bool equal = a.Equals(b); // true because equality compares only m_SubLane
Notes and tips:
- Because Equals/GetHashCode only examine m_SubLane, PathMethod differences do not affect identity-based operations (e.g., lookups, sets keyed by SubLane).
- The IEmptySerializable marker and Colossal.Serialization.Entities usage indicate the type participates in the game's custom serialization pipeline; treat serialization semantics as engine-specific.
- Use DynamicBuffer