Game.Routes.Waypoint
Assembly: Assembly-CSharp
Namespace: Game.Routes
Type: struct (IComponentData, IQueryTypeParameter, ISerializable)
Base: System.ValueType
Summary:
Represents a simple ECS component that stores the integer index of a route waypoint. This struct is used with Unity's ECS (IComponentData) to attach waypoint identity to entities involved in the routing system. It also implements Colossal's ISerializable interfaces to support save/load (serialization) of the waypoint index.
Fields
public int m_Index
Holds the index (identifier) of the waypoint in a route or waypoint list. Being a plain int makes the struct blittable and efficient for use in ECS components and serialization.
Properties
- This type exposes no properties. The waypoint index is accessed directly via the public field
m_Index
.
Constructors
public Waypoint(int index)
Initializes a new Waypoint with the given integer index. Example usage:new Waypoint(3)
creates a waypoint whose m_Index equals 3.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the waypoint index to the provided writer. Used by the game's serialization pipeline to save the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the waypoint index from the provided reader. Used by the game's serialization pipeline to restore the component state during load.
Usage Example
// Add waypoint component to an entity (Unity.Entities)
var waypoint = new Game.Routes.Waypoint(5);
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity();
entityManager.AddComponentData(e, waypoint);
// Serialization example (pseudo-usage — depends on actual IWriter/IReader implementation)
void SaveWaypoint(IWriter writer, Game.Routes.Waypoint w)
{
w.Serialize(writer);
}
Game.Routes.Waypoint LoadWaypoint(IReader reader)
{
var w = new Game.Routes.Waypoint(); // default struct ctor -> m_Index == 0
w.Deserialize(reader);
return w;
}