Game.Pathfind.PathInformations
Assembly:
Assembly-CSharp
Namespace:
Game.Pathfind
Type:
struct
Base:
System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable
Summary:
A reusable buffer element that holds the results/metadata for a computed path between two Entities. Instances are intended to be stored in an Entity's dynamic buffer (InternalBufferCapacity(0) indicates the buffer has no inline capacity) and serialized for save/load. The struct stores origin/destination entities, simple cost metrics (distance, duration, total cost) and bitflag enums describing the pathfinding method and the path state.
Fields
-
public Entity m_Origin
{{ This is the Entity that represents the start of the path. Typically set to the entity that requested or produced the path. }} -
public Entity m_Destination
{{ The target Entity for this path entry. }} -
public float m_Distance
{{ The computed distance of the path (game units). Used for metrics and comparisons. }} -
public float m_Duration
{{ Estimated travel time for the path, in seconds (or game time units) as produced by the pathfinder. }} -
public float m_TotalCost
{{ Numerical cost value combining factors used by the pathfinding algorithm (could include penalties, weights, etc.). }} -
public PathMethod m_Methods
{{ Enum flag(s) describing which pathfinding method(s) were used to produce this entry (PathMethod is defined elsewhere in the codebase). Stored as a 16-bit value during serialization. }} -
public PathFlags m_State
{{ Enum flag(s) describing the state of the path (for example Pending, Obsolete, Valid, Failed, etc.). Stored as a 16-bit value during serialization. Note: on deserialization, if the Pending flag is found it is converted to Obsolete to avoid resurrecting transient pending state across loads. }}
Properties
- None (this is a plain data struct used as a buffer element)
{{ PathInformations exposes only public fields (no explicit properties). It is intended to be used as an IBufferElementData type stored in DynamicBuffer
Constructors
public PathInformations()
{{ The default parameterless constructor is provided implicitly by the C# compiler (struct). Initialize fields directly or via a helper factory method before adding to buffers. Example: new PathInformations { m_Origin = originEntity, m_Destination = destEntity, m_Distance = d, ... } }}
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
{{ Serializes all fields in a fixed order:- m_Origin (Entity)
- m_Destination (Entity)
- m_Distance (float)
- m_Duration (float)
- m_TotalCost (float)
- m_Methods (cast to ushort)
-
m_State (cast to ushort) This method is used by the game's save/load serialization system (Colossal.Serialization.Entities). }}
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
{{ Deserializes the same field order back into the struct. After reading the PathFlags value, the implementation maps any Pending flag to Obsolete (it clears Pending and sets Obsolete). This prevents leftover transient "Pending" state from being restored when loading saved games. }}
Usage Example
// Example: creating a PathInformations entry and adding it to an entity's buffer
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity pathOwner = /* some entity */;
DynamicBuffer<Game.Pathfind.PathInformations> buffer = em.GetBuffer<Game.Pathfind.PathInformations>(pathOwner);
Game.Pathfind.PathInformations info = new Game.Pathfind.PathInformations
{
m_Origin = originEntity,
m_Destination = destinationEntity,
m_Distance = 120f,
m_Duration = 30f,
m_TotalCost = 75.5f,
m_Methods = PathMethod.AStar, // example enum value
m_State = PathFlags.Valid
};
buffer.Add(info);
{{ Notes: - InternalBufferCapacity(0) means the buffer items are stored in a separate heap allocation rather than inline with the entity. - PathMethod and PathFlags enums are defined elsewhere; consult their definitions to interpret flags and combine methods. - Because this type implements ISerializable, it participates in the game's save/load pipeline — be careful if modifying field order or types as it will affect compatibility with saved games. }}