GBInjectorSystem
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: systems/injection/gb_injector_system.gd
Version: 5.0
class_name: GBInjectorSystem
extends: GBSystem
Summary
Dependency injection system for the Grid Building Plugin.
This system automatically handles:
- Dependency Injection: Wires the
GBCompositionContainerinto all nodes that implementresolve_gb_dependencies(p_config: GBCompositionContainer) - 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.
The 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.
Setup Requirements:
- Assign a
GBCompositionContainerresource to this injector - Ensure
GBLevelContextandGBOwnerare properly configured before the injector runs (usually in_ready()methods) - The injector will automatically validate after injection and log any issues
Usage Example:
| |
[i]Nodes that implement resolve_gb_dependencies(p_config: GBCompositionContainer)
will be injected automatically by this system.[/i]
Signals
initial_injection_completed- Emits when the initial scene injection is completed
node_injected- Emit whenever a node is injected
Exports
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]
[b]Dependencies are injected out of this container by the GBInjectorSystem[/b]
injection_roots- 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.
Methods
_init()_ready()_initialize()get_injection_roots()- Gets the scoped root nodes for injection
validate_runtime()- Validates the runtime level setup for the grid building system.
Notes:
- The authoritative validation is performed by
composition_container.get_runtime_issues(); this method aggregates container-level issues and any injector-specific checks. - This function does NOT auto-run during
_ready(); callrun_validation()or call into the container from host code after the composition container has been injected andGBLevelContext/GBOwnerare available. run_validation()- Public helper: run validation and return boolean result. Logs issues using the container logger.
Public helper: run validation and return boolean result. Logs issues using
the container logger. Prefer calling
composition_container.get_runtime_issues()directly from host scripts when you want to inspect the issue list without logging side-effects.
- Public helper: run validation and return boolean result. Logs issues using the container logger.
Public helper: run validation and return boolean result. Logs issues using
the container logger. Prefer calling
get_editor_issues()get_runtime_issues()_inject_existing()_on_node_added_to_scope()- Handler for new nodes added to the injection scope. [code]p_scope[/code]: The scope node to which the new child belongs. [code]p_node[/code]: The newly added child node.
resolve_gb_dependencies()- Default resolve hook used by the injector when injecting this system into
the scene. Host projects may implement their own
resolve_gb_dependencieson world or player scripts to capture the container pointer and to run validation. The default implementation here only captures a logger and prints a small diagnostic.
- Default resolve hook used by the injector when injecting this system into
the scene. Host projects may implement their own
inject_node()- Injects dependencies into a single node (not recursive). Also connects signals to monitor future children and node exiting.
inject_recursive()- Injects dependencies into the node and all its children recursively. Used only on startup to cover existing tree nodes.
set_injection_meta()- Sets the meta data on the object following a successful injection.
remove_injection_meta()- Removes the injection meta data from the object.
_on_child_entered_tree()- Handler for new nodes entering the tree at runtime. Injects only the single node; child nodes will trigger their own injections.
_on_node_exiting_tree()- Handler for node exiting tree to clean up signal connections[br]
_connect_child_entered_tree()- [b]Private helper: Connect child_entered_tree signal if not already connected.[/b][br]
_disconnect_child_entered_tree()- [b]Private helper: Disconnect child_entered_tree signal if connected.[/b][br]
_connect_tree_exiting()- [b]Private helper: Connect tree_exiting signal if not already connected.[/b][br]
_disconnect_tree_exiting()- [b]Private helper: Disconnect tree_exiting signal if connected.[/b][br]
_connect_scene_tree_node_added()_on_scene_tree_node_added()_validate_after_injection()- Automatically validates the Grid Building setup after injection completes. This is called deferred after initial_injection_completed to ensure all nodes are properly injected and GBLevelContext/GBOwner are configured.
_report_warning()- [b]Private helper: Report warnings through direct print or push_warning.[/b][br]