Composition & Injection
5.0.8 projects wire Grid Building through a composition container and an injector pattern.
Version note: This guide is validated for Grid Building 5.0.8 (maintenance stable). The wiring layer is unchanged from 5.0.4.
If you are coming from the setup flow, complete Getting Started 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. It exposes:
config— exportedGBConfigproperty (direct property, not a helper method)get_settings()— returnsGBSettingsget_templates()— returnsGBTemplatesget_actions()— returnsGBActionsget_logger()— returnsGBLoggerget_contexts()— returnsGBContextsget_states()— returnsGBStates
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 assigned.GBLevelContext.target_mapmust be assigned.GBLevelContext.objects_parentmust be assigned.GBOwner.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 context.GBLevelContext.resolve_gb_dependencies(...)applies level maps and placement parent into the states.- UI and helper nodes read state/context references from the container.
- Systems register themselves via
GBSystemsContext.set_system()— this is separate from the injection pattern.
Recommended Setup
| |
What Should Be in the Container Resource
config.settings.buildingconfig.settings.manipulationconfig.settings.targetingconfig.settings.placement_rulesconfig.templatesconfig.actions
5.0.4 update: Base
placement_rulesshould reference external.tresfiles, not embedded subresources. See Web Export Guide for why this matters in exported builds.
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.