Game.Simulation.Flow.CutElement
Assembly: Assembly-CSharp
Namespace: Game.Simulation.Flow
Type: struct
Base: System.ValueType
Summary:
Represents a single element/node in the simulation "cut" / flow graph. CutElement packs several integer identifiers (start/end node, edge, group, version, links, next index) and a small set of boolean state flags into a CutElementFlags field. The boolean properties (isCreated, isAdmissible, isChanged, isDeleted) are stored as bits in m_Flags and accessed via small helper methods. This struct is intended to be a compact value type used in high-performance simulation code (bitflags reduce memory overhead compared to separate bool fields).
Fields
-
public CutElementFlags m_Flags
Stores bitwise flags for the element. The flags are used for the boolean properties (Created, Admissible, Changed, Deleted) and potentially other flag values defined in the CutElementFlags enum. Use bitwise operations or the provided GetFlag/SetFlag helpers to read/write individual flags. -
public int m_StartNode
Identifier/index of the start node for this cut element. Meaning depends on the surrounding flow/cut graph data structures. -
public int m_EndNode
Identifier/index of the end node for this cut element. -
public int m_Edge
Identifier/index of the edge associated with this cut element. -
public int m_Group
Group id for grouping related cut elements (used by algorithms that partition or categorize elements). -
public int m_Version
Version or timestamp integer used to track updates to this element. Commonly used to detect stale references. -
public int m_LinkedElements
Index or count pointing to linked elements (depends on how the flow graph stores adjacency/links). -
public int m_NextIndex
Index of the next element in a chain/list. Useful for building linked-lists or free lists inside an array of CutElement.
Properties
-
public bool isCreated { get; set; }
True when the element has been created/initialized. Backed by the Created bit in m_Flags. Setting this property toggles that bit. -
public bool isAdmissible { get; set; }
Indicates whether this element is admissible for the current flow/cut algorithm. Stored as a bit in m_Flags. -
public bool isChanged { get; set; }
Marks the element as changed (dirty). Useful for incremental updates; stored as a bit in m_Flags. -
public bool isDeleted { get; set; }
Marks the element as deleted/removed. Stored as a bit in m_Flags.
Constructors
public CutElement()
Implicit default constructor for the struct. All integer fields default to 0 and m_Flags defaults to 0 (all flags false). You can assign individual fields or use an initializer to set values as needed. Because this is a value type, instances are copied by value.
Methods
-
private bool GetFlag(CutElementFlags flag)
Returns true when the specified flag bit is set in m_Flags. Implementation: (m_Flags & flag) != 0. Use this for read-only checks when you need to test specific bits. -
private void SetFlag(CutElementFlags flag, bool value)
Sets or clears the specified flag bit in m_Flags. If value is true the bit is ORed in; otherwise the bit is cleared using a bitwise AND with the bitwise complement. Use this to update individual boolean flags without affecting other bits.
Usage Example
// Example showing basic usage of CutElement flags and fields
CutElement elem = new CutElement();
elem.m_StartNode = 10;
elem.m_EndNode = 20;
elem.m_Edge = 5;
elem.m_Group = 1;
elem.m_Version = 1;
elem.m_LinkedElements = -1;
elem.m_NextIndex = -1;
// Set boolean flags via properties (these manipulate the m_Flags bitfield)
elem.isCreated = true;
elem.isAdmissible = false;
elem.isChanged = true;
elem.isDeleted = false;
// Read flags
if (elem.isCreated && !elem.isDeleted)
{
// element is active
// perform logic...
}
// Because CutElement is a struct, assignments copy the entire value:
// Copying:
CutElement copy = elem;
copy.m_Version = 2; // does not change elem.m_Version
// If you interact with low-level arrays of CutElement (for performance),
// prefer updating m_Flags via the provided properties or helpers to avoid
// inadvertently clobbering other flag bits.
{{ Notes: CutElementFlags is not included in this file — it is expected to be an enum elsewhere in the codebase defining the bits (e.g., Created, Admissible, Changed, Deleted). As a compact value type, CutElement is suitable for use in arrays and native-like data structures; keep in mind copying semantics of structs and use references or indices when large collections are modified frequently. }}