GBCompositionContainer
Summary
Section titled “Summary”Dependency injection root for context-specific Grid Building setup.
The GBCompositionContainer
is the canonical composition root for a runtime Grid Building context. Typical usage: - Create one container per player or active simulation instance (for multiplayer or local split-screen projects each player can have their own isolated composition container). - Assign a GBConfig
resource to the container. The config contains the user-visible settings, templates, rules, and runtime checks used by the systems. - Create and assign a GBLevelContext
and a GBOwner
in your scene, then ensure they are wired into the container’s contexts (usually via the injector). The GBLevelContext
provides tilemap / tilelayer lookup and spatial context required for placement and targeting. The GBOwner
identifies who is responsible for performing operations (a player or simulated actor) and is required by many systems.
Validation workflow: 1. Ensure the level is loaded and the GBLevelContext
and a GBOwner
instance are created and assigned to the container’s contexts. 2. The GBInjectorSystem
automatically validates the complete setup after dependency injection is complete. Any issues are logged via the container’s logger system. 3. For manual validation, call composition_container.get_runtime_issues()
to collect diagnostics, or composition_container.validate_runtime()
to get a boolean result.
:::note[Note] The injector (GBInjectorSystem
) handles both dependency injection and automatic validation. No manual validation calls are required in most cases. :::
Properties
Section titled “Properties”config: GBConfig
Main configuration resource for the grid building system.
Methods
Section titled “Methods”func get_contexts( ) -> GBContexts
Cached contexts instance for dependency resolution.
Cached states instance for system coordination.
Cached logger instance for debugging and warnings.
Gets or creates the contexts container for dependency injection.
return
: GBContexts - Contexts container with all system contextsfunc get_states( ) -> GBStates
Gets or creates the states container for all system states.
return
: GBStates - States container with targeting, building, manipulation statesfunc get_logger( ) -> GBLogger
Gets or creates the centralized logger instance.
return
: GBLogger - Logger instance for error/warning reportingfunc get_mode_state( ) -> ModeState
Gets the mode state from the states container.
func get_targeting_state( ) -> GridTargetingState
Gets the grid targeting state from the states container.
func get_building_state( ) -> BuildingState
Gets the building state from the states container.
func get_manipulation_state( ) -> ManipulationState
Gets the manipulation state from the states container.
func get_settings( ) -> GBSettings
Gets the main settings configuration resource.
func get_placement_rules( ) -> Array[PlacementRule]
Gets the placement rules array from settings.
func _log_placement_rules_summary( rules: Array ) -> void
func get_visual_settings( ) -> GBVisualSettings
Gets the visual settings from the main settings.
func get_systems_context( ) -> GBSystemsContext
Gets the systems context from the contexts container.
func get_manipulation_settings( ) -> ManipulationSettings
Gets the manipulation settings from the main settings.
func get_runtime_checks( ) -> GBRuntimeChecks
Gets the runtime checks configuration resource.
func get_templates( ) -> GBTemplates
Gets the templates resource from configuration.
func get_indicator_context( ) -> IndicatorContext
Gets the placement context from the contexts container.
func get_actions( ) -> GBActions
Gets the input actions configuration resource.
func get_debug_settings( ) -> GBDebugSettings
Gets the debug settings from the main settings configuration.
func get_editor_issues( ) -> Array[String]
Gets all issues that would prevent proper operation in the editor.
func get_runtime_issues( ) -> Array[String]
Gets all issues that would prevent the grid building systems from operating. This should be called after your level is loaded with GBLevelContext and a GBOwner is set to the GBOwnerContext
func log_runtime_issues( ) -> Array[String]
Convenience: Log runtime issues using the container’s logger. Useful for quick smoke-tests from host scripts or for initial boot-time diagnostics. Returns the issue array for programmatic inspection as well.
func validate_editor( ) -> bool
Runs validation checks on editor setup to ensure required resources are set
func validate_runtime( ) -> bool
Validates runtime configuration and dependencies.
Note: Validation is automatically handled by GBInjectorSystem after dependency injection. This method is primarily for manual validation in special cases or debugging.
Usage Examples:
# Manual validation (rarely needed):if not composition_container.validate_runtime():push_error("Grid Building validation failed!")# Get detailed issues for debugging:var issues = composition_container.get_runtime_issues()for issue in issues:print("Issue: ", issue)Returns: true if all runtime checks pass, false otherwise
func _get_debug_settings_for_logger( ) -> GBDebugSettings
Internal helper to get debug settings without logging (for logger initialization)
Source
Section titled “Source”addons/grid_building/resources/gb_composition_container.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.