Composition + injection (5.0.3)
5.0.3 projects wire GridBuilding through a composition container and an injector pattern.
If you are coming from the setup flow, complete Getting Started (5.0.3) first. This guide explains the wiring layer that sits behind that setup, not the initial addon install and first placement sequence.
What the container actually owns
GBCompositionContainer is the canonical composition root for one runtime grid-building context. Through helper methods it provides:
GBConfigGBSettingsGBTemplatesGBActionsGBLoggerGBContextsGBStates
Use one container per active runtime context.
What the injector actually does
GBInjectorSystem:
- requires
composition_container - injects any node that implements
resolve_gb_dependencies(...) - performs initial recursive injection
- injects newly added nodes inside the injection scope
- runs editor validation automatically
Important runtime detail:
- the injector helps with wiring
- runtime validation is only meaningful once
GBLevelContextandGBOwnerhave populated the contexts/states your systems depend on
Canonical scene wiring
Required scene contracts
GBInjectorSystem.composition_containermust be assignedGBLevelContext.target_mapmust be assignedGBLevelContext.objects_parentmust be assignedGBOwner.owner_rootmust be assigned- any node that needs plugin dependencies must implement
resolve_gb_dependencies(container: GBCompositionContainer)
What resolve_gb_dependencies(...) means
There is no formal interface keyword here. The injector simply checks whether a node has the method and, if so, calls it.
Typical runtime patterns:
GBOwner.resolve_gb_dependencies(...)registers the active owner into owner contextGBLevelContext.resolve_gb_dependencies(...)applies level maps and placement parent into the states- systems such as
BuildingSystem,GridTargetingSystem, andManipulationSystemregister themselves intoGBSystemsContext - UI and helper nodes read state/context references from the container
Recommended setup
What should be in the container resource
config.settings.buildingconfig.settings.manipulationconfig.settings.targetingconfig.settings.placement_rulesconfig.templatesconfig.actions
Example injection target
What is not automatic
- the injector does not invent a
GBLevelContextfor you - the injector does not invent a
GBOwnerfor you - the injector does not make placement work if
target_map,objects_parent, or owner wiring are missing - the injector does not replace calling real system entry points like
enter_build_mode(placeable)
Plugin-user checklist
- create a
GBCompositionContainerresource - assign a valid
GBConfig - add
GBInjectorSystemto your scene - assign
composition_container - add
GBLevelContext - assign
target_mapandobjects_parent - add
GBOwner - assign
owner_root - add the systems/nodes you want to use
- trigger placement through the system API or injected UI