Table of Contents

Class GBInjectorSystem

Namespace
GridPlacement.GDScript
Assembly
MoonBark.GridPlacement.GDScript.dll

Dependency injection system for the Grid Building Plugin.\n\nThis system automatically handles: 1. Dependency Injection: Wires the PlacementContainer into all nodes that implement resolve_gb_dependencies(p_config: PlacementContainer) 2. Automatic Validation: Validates the complete setup after injection and reports any configuration issues via the container's logger\n\nNo manual validation calls are required - the injector handles everything automatically after dependency injection is complete.\n\nThe injector operates on a scoped portion of the scene tree (or the whole tree when no injection_roots are provided). It does not own the composition container — it holds a reference to one and performs injection and validation.\n\nSetup Requirements: - Assign a PlacementContainer resource to this injector - Ensure GBLevelContext and GBOwner are properly configured before the injector runs (usually in _ready() methods) - The injector will automatically validate after injection and log any issues\n\nUsage Example: gdscript # In your scene node: func resolve_gb_dependencies(p_config: PlacementContainer) -> void: _composition_container = p_config _logger = p_config.get_logger() # No validation call needed - injector handles it automatically \n\n[i]Nodes that implement resolve_gb_dependencies(p_config: PlacementContainer) will be injected automatically by this system.[/i]

class GBInjectorSystem extends GBSystem
GBInjectorSystem

Fields

INJECTION_META_KEY

const INJECTION_META_KEY: String = "gb_injection_meta"

RESOLVE_METHOD

const RESOLVE_METHOD: StringName = "resolve_gb_dependencies"

ORPHAN_MESSAGE

const ORPHAN_MESSAGE: String = "[ORPHANED NODE]"

Properties

composition_container

Container services as the single source of truth for settings within it's scope for systems and other nodes concerned with grid building operations. [br][br]\n\n[b]Dependencies are injected out of this container by the GBInjectorSystem[/b]

@export var composition_container: PlacementContainer

injection_roots

Debug settings for logging and warnings. Note: runtime validation is intentionally NOT auto-run on _ready() because other game-level dependencies (GB level context, GBOwner, 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 GBInjectorSystem. Use this for scoping injection. If left empty, all nodes in the scene tree will be injected.

@export var injection_roots: Array[Node] = []

roots

var roots: Array[Node] = []

issues

var issues = composition_container.get_runtime_issues()

container_issues

var container_issues = composition_container.get_runtime_issues()

ok

var ok = validate_runtime()

issues

var issues = composition_container.get_runtime_issues()

issues

var issues = composition_container.get_runtime_issues()

was_injected

var was_injected: bool = inject_node(p_node)

message

var message: String = "[scope-child_entered_tree] added=%s injected=%s" % [p_node, was_injected]

system

var system = GBInjectorSystem.new(container)

rule_count

var rule_count = 0

existing

var existing = p_node.get_meta(INJECTION_META_KEY)

meta

var meta = p_node.get_meta(INJECTION_META_KEY)

node_path

var node_path = p_node.get_path() if p_node.is_inside_tree() else ORPHAN_MESSAGE

msg

var msg = "[GBInjectorSystem] Node exiting: %-25s at %s" % [p_node.name, node_path]

bound_cb

var bound_cb = meta["_child_entered_cb"]

meta

var meta = p_node.get_meta(INJECTION_META_KEY)

meta

var meta = p_node.get_meta(INJECTION_META_KEY)

bound_cb

var bound_cb = meta["_child_entered_cb"]

bound_exit_cb

var bound_exit_cb = meta["_tree_exiting_cb"]

meta

var meta = p_node.get_meta(INJECTION_META_KEY)

meta

var meta = p_node.get_meta(INJECTION_META_KEY)

bound_exit_cb

var bound_exit_cb = meta["_tree_exiting_cb"]

tree

var tree = get_tree()

issues

var issues = composition_container.get_runtime_issues()

Methods

get_injection_roots

func get_injection_roots() -> Array[Node]:

Returns

validate_runtime

func validate_runtime() -> bool:

Returns

run_validation

func run_validation() -> bool:

Returns

get_editor_issues

func get_editor_issues() -> Array[String]:

Returns

get_runtime_issues

func get_runtime_issues() -> Array[String]:

Returns

create_with_injection

static func create_with_injection(p_parent : Node, container: PlacementContainer) -> GBInjectorSystem:

Parameters

p_parent
container

Returns

resolve_gb_dependencies

func resolve_gb_dependencies(p_config : PlacementContainer) -> void:

Parameters

p_config

Returns

inject_node

func inject_node(p_node: Node) -> bool:

Parameters

p_node

Returns

inject_recursive

func inject_recursive(p_node: Node) -> void:

Parameters

p_node

Returns

set_injection_meta

func set_injection_meta(p_node : Node) -> void:

Parameters

p_node

Returns

remove_injection_meta

func remove_injection_meta(p_node: Node) -> void:

Parameters

p_node

Returns

Events

initial_injection_completed

Emits when the initial scene injection is completed

signal initial_injection_completed()

node_injected

Emit whenever a node is injected

signal node_injected(node : Node)