Skip to content

Game.Objects.TreeState

Assembly: Assembly-CSharp (common Unity game assembly — may vary)

Namespace: Game.Objects

Type: enum (flags)

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

Summary:
TreeState is a [Flags] enum that represents the lifecycle stage and status flags for a tree in the game. Each member is a single-bit value (byte) so states can be combined using bitwise operations (for example, a tree can be marked as Collected in addition to a growth stage). Some flags are conceptually mutually exclusive (growth stages like Teen/Adult/Elderly), while others represent orthogonal statuses (Collected). Use bitwise checks to test for flags, and bitwise operations to set/clear them.


Fields

  • Teen = 1
    Represents a young tree (juvenile). Typically a growth-stage flag.

  • Adult = 2
    Represents a mature tree. Typically a growth-stage flag.

  • Elderly = 4
    Represents an old tree. Typically a growth-stage flag.

  • Dead = 8
    Represents a dead tree. Indicates the tree is dead; may be used in logic that handles removal, visuals, or decay.

  • Stump = 0x10
    Represents a tree reduced to a stump (after cutting or decay). Distinct from Dead in usage (visual/interaction differences).

  • Collected = 0x20
    Represents that the tree (or its remains) has been collected/removed by game systems. This is an orthogonal status that can be combined with other flags.

Properties

  • This enum type has no custom properties. Use standard enum operations and any helper/extension methods in your mod code to interpret or manipulate flags.

Constructors

  • Enums do not define constructors. The default value is 0 (no flags set), which may represent an uninitialized or "no state" condition — handle accordingly in game logic.

Methods

  • There are no custom methods on this enum. Use System.Enum helpers or utility extension methods to work with flag combinations:
  • Use bitwise AND/OR to test/set flags: (state & TreeState.Dead) != 0
  • Use bitwise XOR to toggle, bitwise AND with complement to clear.

Usage Example

// Set an initial state
TreeState state = TreeState.Teen;

// Promote to Adult (replace growth stage)
state &= ~(TreeState.Teen | TreeState.Elderly);
state |= TreeState.Adult;

// Mark as collected as an additional flag
state |= TreeState.Collected;

// Check for flags
bool isCollected = (state & TreeState.Collected) != 0;
bool isDead = (state & TreeState.Dead) != 0;

// Clear a flag (remove Collected)
state &= ~TreeState.Collected;

// Example of mutually exclusive logic for growth stages
if ((state & (TreeState.Teen | TreeState.Adult | TreeState.Elderly)) == 0)
{
    // No growth stage set — set default
    state |= TreeState.Teen;
}

Notes and recommendations: - Because this enum uses the [Flags] attribute, prefer bitwise operations rather than equality checks when testing for individual flags. - Be careful when combining growth-stage flags — treat them as mutually exclusive in code unless the game design allows multiple stages simultaneously. - When serializing/saving state, store the underlying byte value to preserve combined flags.