Dependency injection system for the Grid Building Plugin. This system automatically handles: 1. Dependency Injection: Wires the PlacementContainer into all nodes that implement resolve_placement_dependencies(p_config: PlacementContainer) 2. Automatic Validation: Validates the complete setup after injection and reports any configuration issues via the container's logger No manual validation calls are required
- the injector handles everything automatically after dependency injection is complete. [b]Modes[/b] [b]Global mode[/b] (default, no [code]scope_root[/code]): injects the entire scene tree. Connects to [code]tree.node_added[/code] to catch dynamically added nodes. Falls back to [code][tree.root][/code] when [code]injection_roots[/code] is empty. Session auto-registration with the host is enabled by default. [b]Scoped mode[/b] ([code]scope_root[/code] set via [code]set_session_scope()[/code]): injects only the subtree under [code]scope_root[/code]. Does NOT connect to the global [code]node_added[/code] signal. The controller/bootstrap is responsible for explicitly registering the session with the host (see [code]host_created[/code] signal). This is the preferred path for split-screen, per-controller, and explicit code-built setups. [b]Responsibility Boundaries[/b] - [code]PlacementSession[/code]: owns mutable state, config, contexts, logger (SSOT) - [code]GridPlacementHost[/code]: owns stateless runtime services and dispatch - [code]PlacementInjectorSystem[/code]: wires scene-authored nodes around a session subtree; does NOT own the container, the session, or runtime logic [b]Setup Requirements:[/b]
- Assign a
PlacementContainerresource to this injector - Ensure
PlacementLevelContextandPlacementOwnerare properly configured before the injector runs (usually in_ready()methods) - The injector will automatically validate after injection and log any issues Usage Example: ```gdscript # In your scene node: func resolve_placement_dependencies(p_config: PlacementContainer) -> void: _composition_container = p_config _logger = p_config.get_logger() # No validation call needed
- injector handles it automatically ``` [i]Nodes that implement
resolve_placement_dependencies(p_config: PlacementContainer)will be injected automatically by this system.[/i]
Source: addons/grid_placement/systems/injection/placement_injector_system.gd
Syntax
class PlacementInjectorSystem extends PlacementSystemBaseMembers
| Name | Kind | Summary |
|---|---|---|
initial_injection_completed | Event | Emits when the initial scene injection is completed |
node_injected | Event | Emit whenever a node is injected |
host_configured | Event | Emitted when the injector creates a [GridPlacementHost] host from its session. Controllers in scoped mode should connect to this signal to explicitly register their session with the host. |
session | Property | Optional [PlacementSession] — when set, the injector creates a minimal [PlacementContainer] that delegates through the session. This is the preferred path for code-built/explicit setups. 6.0.0-S: when the injector creates a [GridPlacementHost] host, this session is auto-registered with the host's per-controller session registry (single-player convenience; controllers can register additional sessions for split-screen). |
composition_container | Property | @deprecated Backward-compat wrapper built automatically from [member session] in [method _ready]. During the 6.0 deprecation window, consumer nodes that implement [code]resolve_placement_dependencies(p_config: PlacementContainer)[/code] still receive this wrapper. New code should use [member session] directly. |
injection_roots | Property | Debug settings for logging and warnings. Note: runtime validation is intentionally NOT auto-run on `_ready()` because other game-level dependencies (Placement level context, PlacementOwner, etc.) may not be fully settled. Call `run_validation()` from your world/initializer script after those dependencies are created and injected. Root nodes for injection. These nodes and any children node added will be injected by the PlacementInjectorSystem. Use this for scoping injection. If left empty, all nodes in the scene tree will be injected. |
scope_root | Property | Optional explicit scope root for session-scoped injection. |
auto_register_host_session | Property | When [code]true[/code] (default), the injector automatically registers its session with the host's per-controller registry as a single-player convenience. Set to [code]false[/code] in scoped mode and connect to the [code]host_configured[/code] signal for explicit controller-owned registration. |
INJECTION_META_KEY | Field | |
CHILD_ENTERED_LISTENER_META_KEY | Field | |
RESOLVE_METHOD | Field | |
ORPHAN_MESSAGE | Field | Legacy 5.0 name (`resolve_gb_dependencies`) was removed in . Nodes that only implement the 5.0 entry point must rename to `resolve_placement_dependencies`. See the migration guide. |
get_injection_roots | Method | |
roots | Property | |
validate_runtime | Method | |
issues | Property | |
session_issues | Property | |
run_validation | Method | |
ok | Property | |
get_editor_issues | Method | |
issues | Property | |
get_runtime_issues | Method | |
issues | Property | |
was_injected | Property | |
message | Property | |
is_scoped | Method | |
create_with_injection | Method | |
system | Property | |
from_session | Method | |
injector | Property | |
from_session_scoped | Method | |
injector | Property | |
set_session_scope | Method | |
catalog_path | Property | |
n_issues | Property | |
resolve_placement_dependencies | Method | |
rule_count | Property | |
inject_node | Method | |
existing | Property | |
inject_recursive | Method | |
set_injection_meta | Method | |
meta | Property | |
remove_injection_meta | Method | |
node_path | Property | |
msg | Property | |
bound_cb | Property | |
existing_cb | Property | |
bound_cb | Property | |
bound_exit_cb | Property | |
meta | Property | |
meta | Property | |
bound_exit_cb | Property | |
tree | Property | |
issues | Property | |
host_session | Property | |
host | Property | |
roots | Property | |
placement_system | Property | |
find_placement_system | Method | |
ps | Property |
Source
addons/grid_placement/systems/injection/placement_injector_system.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs