Skip to content

Game.Simulation.Flow.Identifier

Assembly:
Unknown (not specified in source) — likely the game's core simulation assembly

Namespace: Game.Simulation.Flow

Type:
struct (public) — Identifier

Base:
System.ValueType, System.IEquatable

Summary:
A lightweight value-type identifier used by the simulation flow system. It contains an index and a version so instances act like handles: the index identifies a slot and the version distinguishes different generations of the same slot. Equality compares both index and version. The struct provides a Null static property that returns the default (index = 0, version = 0).


Fields

  • public int m_Index
    Index portion of the identifier. Typically refers to a slot or array index used by the simulation system.

  • public int m_Version
    Version (generation) portion of the identifier. Used to detect stale/invalid handles when a slot has been reused.

Properties

  • public static Identifier Null { get; }
    Returns the default Identifier (same as default(Identifier)), effectively an invalid/empty handle (index = 0, version = 0).

Constructors

  • public Identifier(int index, int version)
    Creates a new Identifier with the given index and version. Use to construct or recreate a handle explicitly.

Methods

  • public static bool operator ==(Identifier left, Identifier right)
    Equality operator — true when both index and version match.

  • public static bool operator !=(Identifier left, Identifier right)
    Inequality operator — logical negation of ==.

  • public bool Equals(Identifier other)
    IEquatable implementation. Compares index and version for equality.

  • public override bool Equals(object obj)
    Overrides System.Object.Equals. Returns true when obj is an Identifier with matching index and version.

  • public override int GetHashCode()
    Returns the hash code for this Identifier. Implementation returns m_Index (only the index portion). Note: because only the index is used, two Identifiers with the same index but different versions will produce the same hash code; this is valid but can lead to more hash collisions in hashed collections.

Usage Example

// Create identifiers
var idA = new Game.Simulation.Flow.Identifier(5, 1);
var idB = new Game.Simulation.Flow.Identifier(5, 2);
var idNull = Game.Simulation.Flow.Identifier.Null;

// Comparison
bool same = idA == idB;         // false, versions differ
bool equals = idA.Equals(idB);  // false

// Check for null/default
if (idNull.Equals(default(Game.Simulation.Flow.Identifier)))
{
    // handle empty identifier
}

// Use as keys in dictionaries (be aware GetHashCode uses only m_Index)
var dict = new Dictionary<Game.Simulation.Flow.Identifier, string>();
dict[idA] = "EntityA";
// idB shares the same hash code as idA if index is the same, but Equals will distinguish them.