Mode State and Enums (6.0)
This guide documents how GridBuilding 6.0 represents build modes and how it maps from the legacy GDScript enums used in GBEnums and BuildingMode to the new canonical C# enum GridMode.
It is intended for:
- Existing GDScript projects migrating from
GBEnums.Mode/BuildingMode. - New 6.0 projects that should only depend on
GridModeandIModeService.
Canonical mode enum in 6.0
In 6.0, there is one canonical gameplay/tool mode enum for the GridBuilding system:
| |
Key points:
GridModeis the only mode enum that represents the current tool / gameplay mode.- The mode service (
GridBuilding.Core.Services.Mode.IModeService) exposes the currentGridModeand emits mode-change events. - Godot UI (for example,
UIManagerandGBCursorChanger) synchronizes withGridModeand uses it as the source of truth.
Any older enums that tried to describe “modes” (such as
BuildingMode,ManipulationMode,ApplicationMode,EditMode, etc.) are now marked [Obsolete] and should be treated as legacy only.
Legacy GDScript mode enums (pre‑6.0)
Historically, the Godot side used a centralized GDScript class GBEnums:
| |
On the C# side, an early port introduced a BuildingMode enum that intentionally mirrored GBEnums.Mode:
| |
6.0 note:
BuildingModeexists only as a historical artifact and is not used by the 6.0 core at runtime. New C# code must depend directly onGridModeand must not introduce new usages ofBuildingMode.
In 6.0, both GBEnums.Mode and BuildingMode are considered legacy representation of mode for migration purposes only. The new, stable enum is GridMode.
Mode mapping: GDScript → 6.0 C#
The following table documents how old GDScript modes map onto GridMode in 6.0.
This is useful when migrating GDScript code or older C# wrappers that still think in terms of
GBEnums.ModeorBuildingMode.
Primary build modes
| Legacy enum (GDScript / C#) | 6.0 enum (C#) | Notes |
|---|---|---|
GBEnums.Mode.OFF | GridMode.Off | Systems disabled / no interaction. |
GBEnums.Mode.INFO | GridMode.Info | Info / inspect mode (hover for details, no edits). |
GBEnums.Mode.BUILD | GridMode.Place | Building / placement of new objects. |
GBEnums.Mode.MOVE | GridMode.Move | Moving existing objects. |
GBEnums.Mode.DEMOLISH | GridMode.Remove | Generic removal: demolish / sell / delete any object. |
BuildingMode.Off | GridMode.Off | Legacy C# mirror of GBEnums.Mode.OFF. |
BuildingMode.Info | GridMode.Info | Legacy C# mirror of GBEnums.Mode.INFO. |
BuildingMode.Build | GridMode.Place | Legacy C# mirror of GBEnums.Mode.BUILD. |
BuildingMode.Move | GridMode.Move | Legacy C# mirror of GBEnums.Mode.MOVE. |
BuildingMode.Demolish | GridMode.Remove | Legacy C# mirror of GBEnums.Mode.DEMOLISH. |
Actions vs. modes
GBEnums.Action represented discrete actions (build, move, rotate, flip, demolish). In 6.0 these map to operation types, not global modes:
| Legacy enum (GDScript) | 6.0 concept | Notes |
|---|---|---|
GBEnums.Action.BUILD | GridMode.Place + placement services | Performed while in a placement-oriented mode. |
GBEnums.Action.MOVE | GridMode.Move + move services | Performed while in move mode. |
GBEnums.Action.ROTATE | Operation within placement / move | Rotation is typically a sub-action while placing or moving. |
GBEnums.Action.FLIP_H | Operation within placement / move | Horizontal flip sub-action. |
GBEnums.Action.FLIP_V | Operation within placement / move | Vertical flip sub-action. |
GBEnums.Action.DEMOLISH | GridMode.Remove + remove services | Removal of objects (demolish / sell / delete). |
Guideline: In 6.0 you should treat
GridModeas the high-level tool state, and treat rotations / flips / specific building commands as domain operations invoked while in that mode, rather than as separate global modes.
How mode state flows in 6.0
At a high level, mode state works like this in a 6.0 project:
- Core service layer keeps the authoritative
GridModeviaIModeService. - Godot UI (
UIManager) maps UI interactions (e.g. placement toolbar, hotkeys) intoGridModevalues. - Systems & tools read the current
GridModeand decide whether they are active. - Cursor / highlight visuals (e.g.
GBCursorChanger, highlight settings) respond toGridModechanges to update visual feedback.
Example: reading GridMode from a Godot node
| |
This pattern keeps GridMode as the single source of truth while allowing Godot UI nodes to react to mode changes.
This is conceptually similar to the old GBEnums.Mode, but:
- The enum is owned by C# Core instead of GDScript.
- There is exactly one canonical mode enum (
GridMode). - Legacy multi-enum state (
ApplicationMode,UIMode,EditMode,ViewMode,GameMode,BuildingMode,ManipulationMode) is kept only for compatibility and is marked[Obsolete].
Migration tips
When migrating an existing GDScript project that used GBEnums.Mode:
Identify mode usage
- Search for
GBEnums.Mode.*andGBEnums.Action.*in your GDScript.
- Search for
Switch to service-based mode access
- Use Godot integration (e.g.
UIManager, mode service access) to query the currentGridModeinstead of trackingGBEnums.Modeyourself.
- Use Godot integration (e.g.
Apply the mapping table
- Replace old cases according to the table above, e.g.:
GBEnums.Mode.BUILD→GridMode.PlaceGBEnums.Mode.DEMOLISH→GridMode.Remove
- Replace old cases according to the table above, e.g.:
Keep UI text free to change
- Even though the enum member is
Remove, your UI can still label the tool as Demolish, Sell, or Remove depending on context.
- Even though the enum member is
Avoid new usage of legacy enums
- Treat
BuildingMode,ManipulationMode,ApplicationMode, etc. as read-only legacy. Do not introduce new code that depends on them.
- Treat
For more background on the overall architecture and migration: