Skip to content

Game.Creatures.AnimalFlags

Assembly: Game (Assembly-CSharp)
Namespace: Game.Creatures

Type: Enumeration (flags)

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

Summary: AnimalFlags is a [Flags] enum used to mark animal entities with one or more behavior/targeting characteristics. Its underlying type is uint. Because it is annotated with [Flags], values can be combined with bitwise operators to represent multiple behaviors at once. Note that there is no explicit "None = 0" member defined in this enum; a value of 0 would represent "no flags set."


Fields

  • Roaming = 1u Represents animals that roam (ground movement / general roaming behavior).

  • SwimmingTarget = 2u Marks animals that can be targeted for swimming-related behaviors or considered swimming targets.

  • FlyingTarget = 4u Marks animals that can be targeted for flying-related behaviors or considered flying targets.

Properties

  • This enum type defines no properties. Use bitwise operations or Enum helper methods to inspect values.

Constructors

  • Enums do not expose public constructors. You can create values by direct assignment, by casting from the underlying type, or by parsing:
  • AnimalFlags f = AnimalFlags.Roaming;
  • AnimalFlags f = (AnimalFlags)3u; // combined flags (Roaming | SwimmingTarget)

Methods

  • The enum itself does not declare instance methods, but you can use these common System.Enum / value operations:
  • To combine flags: bitwise OR (|) — e.g., AnimalFlags.Roaming | AnimalFlags.FlyingTarget
  • To remove flags: bitwise AND with complement (& ~) — e.g., flags & ~AnimalFlags.Roaming
  • To test flags:
    • flags.HasFlag(AnimalFlags.Roaming) — uses Enum.HasFlag (slower box/enum method)
    • (flags & AnimalFlags.Roaming) != 0 — preferred for performance in hot code
  • Parsing and formatting: Enum.Parse, Enum.TryParse, and ToString() are available for conversion and debugging.

Usage Example

// Combining flags
AnimalFlags flags = AnimalFlags.Roaming | AnimalFlags.SwimmingTarget;

// Checking flags (preferred bitwise check for performance)
bool isRoaming = (flags & AnimalFlags.Roaming) != 0;

// Using Enum.HasFlag (works, but can be slower due to boxing)
bool isSwimming = flags.HasFlag(AnimalFlags.SwimmingTarget);

// Setting a flag
flags |= AnimalFlags.FlyingTarget; // now Roaming | SwimmingTarget | FlyingTarget

// Clearing a flag
flags &= ~AnimalFlags.SwimmingTarget; // removes SwimmingTarget

// Casting to/from underlying uint (interop or storage)
uint raw = (uint)flags;
AnimalFlags fromRaw = (AnimalFlags)raw;

// Parsing from string
if (Enum.TryParse<AnimalFlags>("Roaming,FlyingTarget", out var parsed))
{
    // parsed == AnimalFlags.Roaming | AnimalFlags.FlyingTarget
}

Notes: - Because this enum lacks a defined "None = 0" member, a value of 0 implicitly means "no flags set." Consider this when storing or checking default values. - For performance-critical code paths (e.g., per-frame simulation loops), prefer bitwise checks ((flags & X) != 0) over Enum.HasFlag.