Skip to content

Game.Simulation.Flow.PushHeapData

Assembly:
Namespace: Game.Simulation.Flow

Type: struct

Base: System.ValueType, Colossal.Collections.ILessThan

Summary:
PushHeapData is a small value type used to store a node index and an associated "height" value for use in heap/priority data structures (from Colossal.Collections). The implemented ILessThan compares by height, but note the comparison is inverted (higher height is treated as "less than" lower height), which makes this struct suitable for use as a max-heap priority (higher heights come out first) when used with collections that rely on LessThan semantics.


Fields

  • public int m_NodeIndex
    Holds the index/id of the node related to this heap entry. Typically used to identify which simulation entity the heap item refers to.

  • public int m_Height
    Holds the height (priority) value used for ordering. Higher values are considered higher priority due to the inverted comparison in LessThan.

Properties

  • None (this struct only exposes public fields)

Constructors

  • public PushHeapData(int nodeIndex, int height)
    Initializes a new PushHeapData with the provided node index and height (priority).

Methods

  • public bool LessThan(PushHeapData other)
    Implements Colossal.Collections.ILessThan. Returns true when this.m_Height > other.m_Height. This inverted comparison makes entries with larger m_Height sort before entries with smaller m_Height in heaps that use LessThan to determine priority (effectively a max-heap behavior).

  • public override string ToString()
    Returns a formatted string describing the fields, e.g. "m_NodeIndex: 42, m_Height: 10".

Usage Example

// Create two heap entries
var a = new PushHeapData(nodeIndex: 5, height: 10);
var b = new PushHeapData(nodeIndex: 7, height: 8);

// Since LessThan returns m_Height > other.m_Height,
// a.LessThan(b) is true (10 > 8) => a has higher priority than b in heaps using this comparison.
bool aHasPriority = a.LessThan(b); // true

// Debug output
Console.WriteLine(a.ToString()); // "m_NodeIndex: 5, m_Height: 10"
Console.WriteLine(b.ToString()); // "m_NodeIndex: 7, m_Height: 8"

{{ Notes for modders: - This struct is intended for use with Colossal.Collections heap/priority structures (or any code expecting ILessThan). - The comparison is intentionally inverted: larger m_Height means higher priority. Be careful when integrating with other priority logic to avoid accidental double-inversion. - Being a struct, PushHeapData is a value type—useful for low-allocation, high-performance code in simulation loops. }}