Skip to content

Game.Pathfind.EdgeID

Assembly: Assembly-CSharp
Namespace: Game.Pathfind

Type: struct

Base: System.ValueType, implements System.IEquatable

Summary:
Lightweight value type that represents an identifier for an edge in the pathfinding graph. Internally it wraps a single integer index (m_Index). Equality is based solely on that index, and the hash code is the index value. Because the backing field is a public integer, modifying it after using an EdgeID as a dictionary key or in hashed collections can break collection invariants — treat instances as immutable keys where appropriate.


Fields

  • public int m_Index
    Stores the integer index that identifies the edge. Used for equality and hashing.

Properties

  • This struct does not expose any C# properties. The identifier is stored in the public field m_Index.

Constructors

  • No explicit constructors are defined. The default parameterless constructor (which sets m_Index to 0) is provided by the runtime. You may assign the field directly when creating an instance, e.g. new EdgeID { m_Index = 42 }.

Methods

  • public bool Equals(EdgeID other)
    Compares this instance to another EdgeID by comparing their m_Index values. Returns true if the indexes are equal.

  • public override int GetHashCode()
    Returns the m_Index value as the hash code. This makes the struct suitable for use in hash-based collections as long as the index is not mutated while the instance is used as a key.

Usage Example

// Creating EdgeID instances
var e1 = new Game.Pathfind.EdgeID { m_Index = 10 };
var e2 = new Game.Pathfind.EdgeID { m_Index = 10 };
var e3 = new Game.Pathfind.EdgeID { m_Index = 11 };

// Equality
bool equal = e1.Equals(e2); // true
bool notEqual = e1.Equals(e3); // false

// Using as a dictionary key
var dict = new System.Collections.Generic.Dictionary<Game.Pathfind.EdgeID, string>();
dict[e1] = "edge-10";

// Important: do not mutate m_Index while e1 is used as a key, or dictionary lookups may fail
// e1.m_Index = 12; // avoid this

// Retrieving
if (dict.TryGetValue(e2, out var name)) {
    // name == "edge-10"
}