Game.Net.Lane
Assembly: Assembly-CSharp.dll
Namespace: Game.Net
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEquatable
Summary: Represents a lane as a compact value-type component used by the game's ECS and networking/serialization systems. A Lane contains three PathNode points (start, middle, end). It implements game serialization interfaces so it can be written to/read from network or save streams and used as an ECS component (IComponentData / IQueryTypeParameter). Equality compares the three nodes; hashing uses the middle node only, and stride/serialization are delegated to the contained PathNode instances.
Fields
-
public PathNode m_StartNode
Represents the lane's start node. Used during serialization/deserialization and in stride calculations via PathNode's own methods. -
public PathNode m_MiddleNode
The lane's middle node. This node is used by GetHashCode(), so it determines the struct's hash. -
public PathNode m_EndNode
Represents the lane's end node.
Properties
- None (this struct exposes only public fields; no C# properties are declared)
Constructors
public Lane()
Default implicit struct constructor. Fields (m_StartNode, m_MiddleNode, m_EndNode) are value-initialized (default PathNode values) unless explicitly set.
Methods
-
public bool Equals(Lane other)
Compares this Lane to another by performing Equals on m_StartNode, m_MiddleNode and m_EndNode in sequence. Returns true only if all three nodes are equal. -
public override int GetHashCode()
Returns the GetHashCode() of m_MiddleNode. Note: hashing uses only the middle node, so distinct lanes that share the same middle node will collide. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes m_StartNode, m_MiddleNode and m_EndNode to the provided writer in that order. Used by the game's serialization framework (Colossal.Serialization.Entities). -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads into m_StartNode, m_MiddleNode and m_EndNode from the provided reader in that order. Used when reconstructing the struct from a stream. -
public int GetStride(Context context)
Returns the combined stride required to serialize this Lane by delegating to m_StartNode.GetStride(context) and multiplying by 3 (one stride per node). Used by the stride-based serializer to compute buffer sizes.
Usage Example
// Create a Lane and assign nodes (PathNode constructor/fields depend on Game.Pathfind.PathNode)
var lane = new Game.Net.Lane
{
m_StartNode = new PathNode(/* ... */),
m_MiddleNode = new PathNode(/* ... */),
m_EndNode = new PathNode(/* ... */)
};
// Add to an ECS entity (EntityManager example)
entityManager.AddComponentData(entity, lane);
// Serialize to a writer (pseudo-code — depends on the IWriter implementation)
writer.Write(lane.m_StartNode);
writer.Write(lane.m_MiddleNode);
writer.Write(lane.m_EndNode);
// Deserialize from a reader (pseudo-code)
Game.Net.Lane readLane = default;
reader.Read(out readLane.m_StartNode);
reader.Read(out readLane.m_MiddleNode);
reader.Read(out readLane.m_EndNode);
// Equality check
if (lane.Equals(readLane))
{
// lanes match
}
Notes for modders: - Lane is a plain value-type component intended for fast copy/serialize scenarios. Because GetHashCode() only uses the middle node, be careful when using it as a key in hashed collections. - When implementing custom serialization or network code, honor the node order (start, middle, end) and use PathNode's stride for buffer sizing. - As an IComponentData, Lane is suitable for storing on entities and querying via Unity.Entities systems or Job-based queries.