GBMetadataResolver
Summary
Section titled “Summary”Utility for resolving Grid Building metadata on nodes.
Provides metadata resolution for root node targeting and display name features. This class is stateless and all methods are static for maximum reusability.
Supported Metadata:
root_node: Specifies the logical root Node2D for targeting -display_name: Custom display name for UI
Methods
Section titled “Methods”static func resolve_root_node( collision_object: CollisionObject2D ) -> Node2DResolves the root node for a collision object by checking metadata and Manipulatable components. Uses a priority search strategy for flexible targeting:
Search priority:
-
Check collision object directly for “root_node” metadata (Node2D or NodePath)
-
Search sibling nodes for Manipulatable component (uses Manipulatable.root)
-
Search direct children (1 level deep) for Manipulatable component
-
Search entire scene tree from root for Manipulatable component (hierarchy-independent)
-
Return collision object if no metadata or Manipulatable found
collision_object: The CollisionObject2D to start searching fromReturns: The resolved root node (Node2D) or the collision object itself
-
static func _find_scene_root( node: Node ) -> NodeFinds the scene root by traversing up the tree to the top-most parent. The scene root is the highest parent node in the scene tree hierarchy.
node: Starting node to traverse from Returns: The scene root node, or null if node is nullstatic func _find_manipulatable_in_tree( node: Node ) -> ManipulatableRecursively searches for the first Manipulatable component in the scene tree. Uses depth-first search to find any Manipulatable anywhere in the hierarchy.
node: Root node to start searching from Returns: The first Manipulatable found, or null if none foundstatic func resolve_manipulation_target( collision_object: CollisionObject2D ) -> DictionaryResolves BOTH the root node AND Manipulatable component from a collision object. This is the recommended method for manipulation systems to avoid duplicate resolution.
Uses the same 5-priority search as resolve_root_node(), but returns both components in a single pass for efficiency.
collision_object: The CollisionObject2D to resolve fromReturns: Dictionary with keys: “root” (Node2D) and “manipulatable” (Manipulatable or null)
static func resolve_display_name( node: Node, fallback: String ) -> StringResolves display name for a node using multiple resolution strategies.
Priority order:
-
get_display_name()method (if exists on node) -
display_nameproperty (if exists on node) -
metadata/display_name(if present, non-empty string/StringName) -
node.name(standard node name) -
Fallback value (if node is null or has no name)
Accepts String or StringName for all display name sources.
node: The node to get display name forfallback: Value to return if node is null or has no valid name (default: “<none>”) Returns: The resolved display name string-
Source
Section titled “Source”addons/grid_building/utils/gb_metadata_resolver.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.