Architecture overview (5.0.3)
GridBuilding 5.0.3 is best understood as a node-first plugin with a composition-container / injector integration style.
Core Systems
5.0.3 consists of these main systems that work together:
| System | Purpose | Location |
|---|---|---|
| GBInjectorSystem | Initializes and wires dependencies across the scene | addons/grid_building/systems/injection/ |
| GBCompositionContainer | Canonical runtime composition root for config, contexts, states, logger, actions, and templates | addons/grid_building/resources/ |
| BuildingSystem | Enters build mode, creates preview instances, runs placement setup, and commits placement | addons/grid_building/systems/building/ |
| GridTargetingSystem | Central targeting-side coordinator for targeting state/settings/path manager validation | addons/grid_building/systems/grid_targeting/ |
| GridPositioner2D | Handles mouse/keyboard cursor-to-grid positioning and visibility | addons/grid_building/systems/grid_targeting/grid_positioner/ |
| TargetingShapeCast2D | Updates GridTargetingState.target from collision queries | addons/grid_building/systems/grid_targeting/grid_positioner/ |
| ManipulationSystem | Owns move/build-manipulation workflow and manipulation state transitions | addons/grid_building/systems/manipulation/ |
| ManipulationParent | Visual transform parent for rotation/flip/preview hierarchy during manipulation | addons/grid_building/systems/manipulation/ |
Key Classes
State Management
| Class | Purpose |
|---|---|
| GBStates | Container for all state (mode, targeting, building, manipulation) |
| ModeState | Current building mode (OFF, BUILD, MANIPULATE) |
| GridTargetingState | Targeting information such as target, target map, maps, positioner, manual targeting flags, and collision exclusions |
| BuildingState | Placement parent, builder ownership, and build-related runtime state |
| ManipulationState | Active manipulation parent and manipulation-specific runtime state |
Scene Context Nodes
| Class | Purpose |
|---|---|
| GBLevelContext | Pushes target_map, maps, and objects_parent into the runtime states |
| GBOwner | Registers the active owner/actor in owner context |
| GBContexts | Holds indicator, owner, and systems contexts |
Placement Rules
| Class | Purpose |
|---|---|
| PlacementRule | Base class for all placement rules |
| TileCheckRule | Base class for rules evaluating tile/indicator state |
| CollisionsCheckRule | Checks for overlapping physics bodies |
| WithinTilemapBoundsRule | Validates placement within tilemap bounds |
| ValidPlacementTileRule | Basic placement validity check |
Runtime boundary
- Godot nodes + scripts
- own most runtime behavior
- expose the practical runtime API through exports, methods, and shared state objects
- Composition container + injector
- wire contexts, states, logger, actions, templates, and settings into nodes
- State-first coordination
- many listeners consume shared state directly instead of receiving small isolated payload objects
High-level shape
Data Flow
- Initialization
GBInjectorSystemreadscomposition_container- it injects any node with
resolve_gb_dependencies(...)
- Scene context application
GBLevelContextappliestarget_map,maps, andobjects_parentGBOwnerapplies the active owner
- Input and targeting
GridPositioner2Dprocesses mouse/keyboard input and moves to tile centersTargetingShapeCast2DupdatesGridTargetingState.target
- Placement start
- UI or game code calls
BuildingSystem.enter_build_mode(placeable) - preview/rules/setup are created from the selected
Placeable
- UI or game code calls
- Validation and commit
- base rules from
GBSettings.placement_rulesand placeable-specific rules are evaluated BuildingSystem.try_build()commits placement if validation succeeds
- base rules from
- Manipulation
ManipulationSystemmanages move/manipulation workflowManipulationParentowns the visual rotation/flip parent hierarchy
What plugin users should rely on
- inspector-driven setup for level wiring and settings
- method-based DI via
resolve_gb_dependencies(...) - state-based coordination through
GBStatesandGBContexts - system entry points such as
enter_build_mode(...),try_build(), and manipulation APIs
Essential integration invariant
The plugin is only fully ready after all of these are true:
GBInjectorSystem.composition_containeris assignedGBLevelContext.target_mapandobjects_parentare assignedGBOwner.owner_rootis assigned- the systems you depend on are present in the scene and injected
- runtime validation passes once your level and owner context are actually available