Game.Routes.RouteSearchItem
Assembly:
Likely Assembly-CSharp (game managed assembly) — the specific assembly name may vary by build/mod.
Namespace: Game.Routes
Type: struct (value type)
Base: System.ValueType
Implements: System.IEquatable
Summary:
A lightweight value-type container used by the route-search/pathfinding code to represent a single search item. It pairs a Unity.Entities.Entity with an integer element index (for example, a node/segment/waypoint index inside that entity). It implements IEquatable
Fields
-
public Unity.Entities.Entity m_Entity
Represents the ECS Entity associated with this search item (e.g., the entity containing route data). -
public int m_Element
An integer element index inside the entity (for example, a specific waypoint, lane, or node index relevant to the route search).
Properties
- This struct defines no C# properties. It exposes two public fields (m_Entity and m_Element).
Constructors
public RouteSearchItem(Unity.Entities.Entity entity, int element)
Creates a new RouteSearchItem with the provided ECS entity and element index.
Remarks: - Because this is a struct, a parameterless default instance also exists and will have default(Entity) and element = 0. - Fields are not readonly; the instance can be modified after construction.
Methods
-
public bool Equals(RouteSearchItem other)
Implements IEquatable.Returns true when both the m_Entity and m_Element fields are equal. Note: the implementation uses the non-short-circuiting boolean operator & to combine the two equality checks; this has the same logical result as && but both sides are always evaluated. -
public override int GetHashCode()
Combines the hash codes of m_Entity and m_Element using a small integer mix: return (17 * 31 + m_Entity.GetHashCode()) * 31 + m_Element.GetHashCode(); This produces a stable hash suitable for use in hash-based collections when the fields do not change.
Additional notes:
- There is no override of Equals(object). The IEquatable
Usage Example
// Example: creating and using RouteSearchItem in collections
using System.Collections.Generic;
using Unity.Entities;
using Game.Routes;
Entity myEntity = /* obtain or create entity */;
int elementIndex = 3;
// Construct a search item
var item = new RouteSearchItem(myEntity, elementIndex);
// Compare two items
var other = new RouteSearchItem(myEntity, 3);
bool equal = item.Equals(other); // true if same entity and same element
// Use as a dictionary key
var dict = new Dictionary<RouteSearchItem, float>();
dict[item] = 0.0f;
// Important: don't mutate item.m_Entity or item.m_Element while item is used as a key
// in hash-based collections, as that will change its hash code/equality and corrupt the collection.
Further tips for modders: - This struct is intended to be a compact key/tuple for route/pathfinding logic. If you need additional metadata (cost, parent index, visited flag), store that separately (for example, in parallel arrays or a custom class) to keep this struct small and copyable. - If you plan to use RouteSearchItem across serialization boundaries or persist it, you may need to convert entities to stable IDs depending on the modding context.