Grid Placement

GBCompositionContainer

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: resources/gb_composition_container.gd

Version: 5.0

class_name: GBCompositionContainer extends: GBResource

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: The injector (GBInjectorSystem) handles both dependency injection and automatic validation. No manual validation calls are required in most cases.

Signals

(none)

Exports

  • config
    • Main configuration resource for the grid building system.

Methods

  • get_contexts()
    • Gets or creates the contexts container for dependency injection.[br][br] [code]return[/code]: [i]GBContexts[/i] - Contexts container with all system contexts
  • get_states()
    • Gets or creates the states container for all system states.[br][br] [code]return[/code]: [i]GBStates[/i] - States container with targeting, building, manipulation states
  • get_logger()
    • Gets or creates the centralized logger instance.[br][br] [code]return[/code]: [i]GBLogger[/i] - Logger instance for error/warning reporting
  • get_mode_state()
    • Gets the mode state from the states container.
  • get_targeting_state()
    • Gets the grid targeting state from the states container.
  • get_building_state()
    • Gets the building state from the states container.
  • get_manipulation_state()
    • Gets the manipulation state from the states container.
  • get_settings()
    • Gets the main settings configuration resource.
  • get_placement_rules()
    • Gets the placement rules array from settings.
  • _log_placement_rules_summary()
  • get_visual_settings()
    • Gets the visual settings from the main settings.
  • get_systems_context()
    • Gets the systems context from the contexts container.
  • get_manipulation_settings()
    • Gets the manipulation settings from the main settings.
  • get_runtime_checks()
    • Gets the runtime checks configuration resource.
  • get_templates()
    • Gets the templates resource from configuration.
  • get_indicator_context()
    • Gets the placement context from the contexts container.
  • get_actions()
    • Gets the input actions configuration resource.
  • get_debug_settings()
    • Gets the debug settings from the main settings configuration.
  • get_editor_issues()
    • Gets all issues that would prevent proper operation in the editor.
  • get_runtime_issues()
    • 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
  • log_runtime_issues()
    • 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.
  • validate_editor()
    • Runs validation checks on editor setup to ensure required resources are set
  • validate_runtime()
    • Validates runtime configuration and dependencies.

[b]Note:[/b] Validation is automatically handled by GBInjectorSystem after dependency injection. This method is primarily for manual validation in special cases or debugging.

[b]Usage Examples:[/b] [codeblock]

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) [/codeblock]

[b]Returns:[/b] true if all runtime checks pass, false otherwise

  • _get_debug_settings_for_logger()
    • Internal helper to get debug settings without logging (for logger initialization)