Game.Tools.ToolMode
Assembly: Assembly-CSharp.dll
Namespace: Game.Tools
Type: readonly struct
Base: System.ValueType
Summary:
ToolMode is a small immutable value type that represents a single tool mode in the game's tool system. It stores a human-readable name and a numeric index identifying the mode. Being a readonly struct ensures the instance is immutable after construction and is efficient to pass by value.
Fields
- None
This struct does not declare any explicit fields in source; it exposes two read-only auto-properties. The compiler emits backing fields for those properties, but they are implementation details and not part of the public API.
Properties
-
public string name { get; }
A read-only property containing the display name or identifier for the tool mode. It is set during construction and cannot be changed afterwards. -
public int index { get; }
A read-only integer that represents the mode's index (often used for selection, ordering, or as an ID). It is set in the constructor and remains constant for the lifetime of the instance.
Constructors
public ToolMode(string name, int index)
Constructs a new ToolMode instance by assigning the provided name and index to the corresponding read-only properties. Because the struct is marked readonly, these values establish the instance's immutable state.
Methods
- None
This struct does not define any methods beyond the implicit methods inherited from System.ValueType (Equals, GetHashCode, ToString) unless the compiler generates additional members. Behavior for equality/printing is the default for structs unless overridden elsewhere.
Usage Example
// Create a tool mode instance
var bulldozeMode = new ToolMode("Bulldoze", 2);
// Read values
string modeName = bulldozeMode.name; // "Bulldoze"
int modeIndex = bulldozeMode.index; // 2
// Value-type semantics: copying creates an independent value
var copy = bulldozeMode;
Additional notes: - Use ToolMode when you need a lightweight immutable representation of a tool option (display + numeric id). - Being a value type, ToolMode instances are copied on assignment and method calls; prefer it for small, frequently-passed data.