Skip to content

Game.Pathfind.PathFlags

Assembly: Assembly-CSharp (inferred)
Namespace: Game.Pathfind

Type: enum PathFlags

Base: System.Enum (underlying type: System.UInt16)

Summary:
PathFlags is a bitmask enum used by the pathfinding system to represent the state and special conditions of a path. The enum uses the [Flags] attribute and an underlying type of ushort, allowing multiple flags to be combined and tested with bitwise operations. These flags indicate processing state (e.g., Pending, Scheduled), outcomes (Failed, Obsolete), special requests (WantsEvent, AddDestination), debug/maintenance markers (Debug, CachedObsolete) and diversion-related states (Divert, DivertObsolete).


Fields

  • Pending = 1
    Represents a path that is queued and waiting to be processed by the pathfinding system.

  • Failed = 2
    Marks a path that failed to be resolved (no valid route or an error during pathfinding).

  • Obsolete = 4
    Indicates the path is outdated (for example, route data changed) and should be re-evaluated or discarded.

  • Scheduled = 8
    The path has been scheduled for computation/processing by the pathfinding worker.

  • Append = 0x10
    Specifies that results should be appended to existing path data rather than replacing it. Used when extending an existing route.

  • Updated = 0x20
    Marks that the path has been updated since last inspection — useful for synchronization between systems that cache paths.

  • Stuck = 0x40
    Indicates the path (or its agent) became stuck during simulation or execution and may require special handling or retry.

  • WantsEvent = 0x80
    Requests an event or callback when a particular path operation completes. Used to notify other systems that depend on path completion.

  • AddDestination = 0x100
    Denotes that a destination should be appended/added to this path. Used when modifying routes dynamically.

  • Debug = 0x200
    Reserved for debugging purposes — may enable extra logging or retain extra state for diagnostics.

  • Divert = 0x400
    Marks that the path has been diverted (rerouted) from its original course, e.g., due to dynamic changes like road closures.

  • DivertObsolete = 0x800
    Indicates that a diverted path is now obsolete and should be reprocessed or removed.

  • CachedObsolete = 0x1000
    Used to mark cached path data as stale/invalid so it will be recomputed or invalidated.

Properties

None. (This is an enum type; state is represented by enum values/bitmask.)

Constructors

None. (Enums have no user-defined constructors in C#.)

Methods

None. (Enums rely on bitwise operations and System.Enum helpers.)

Usage Example

// Combine flags
PathFlags flags = PathFlags.Pending | PathFlags.WantsEvent;

// Test flags (fast bitwise test)
bool isPending = (flags & PathFlags.Pending) != 0;

// Using HasFlag (slower, boxed internally)
bool wantsEvent = flags.HasFlag(PathFlags.WantsEvent);

// Set a flag
flags |= PathFlags.Scheduled;

// Clear a flag
flags &= ~PathFlags.Pending;

// Check for multiple flags
bool needsProcessing = (flags & (PathFlags.Scheduled | PathFlags.Pending)) != 0;

// Casting to/from underlying ushort (e.g., for serialization/storage)
ushort raw = (ushort)flags;
PathFlags fromRaw = (PathFlags)raw;

Notes and tips: - Prefer bitwise operators (&, |, ~) for performance-critical code instead of Enum.HasFlag. - Be mindful of the underlying type (ushort) when storing or serializing flags to ensure correct casting. - Combine and clear flags atomically if accessed from multiple threads or systems — synchronize access where necessary.