GBSearchUtils
Summary
Section titled “Summary”Small helpers for node and scene tree searches used across tests and systems.
Contains safe recursive lookup helpers for finding nodes and collision objects within a tree.
Methods
Section titled “Methods”static func find_first( parent: Node, type: Variant ) -> Node
Finds the first node under the original parent that is of the passed class type.
Recursively searches children (does not check the parent node itself).
parent
: Node - The parent node to search withintype
: Variant - The class type to search for. Can be:-
A Script resource (e.g.,
preload("res://path/to/script.gd")
) -
A built-in class (e.g.,
Node2D
,CharacterBody2D
) -
A class_name reference (e.g.,
BuildingSystem
if script hasclass_name BuildingSystem
)
Returns: The first matching node found, or
null
if none found-
static func get_collision_object_2ds( root: Node ) -> Array[CollisionObject2D]
Gets all collision object 2ds from the root (inclusive) and all child objects. Performs recursive search to find all CollisionObject2D instances in the node tree.
root
: Node - The root node to start searching from (inclusive)static func get_collision_shapes_and_polygons_2d( root: Node ) -> Array[Node2D]
Gets all collision shapes and collision polygons from the root (inclusive) and all child objects.
Performs recursive search to find all CollisionShape2D and CollisionPolygon2D instances in the node tree.
Returns
Array[Node2D]
because both CollisionShape2D and CollisionPolygon2D inherit from Node2D.root
: Node - The root node to start searching from (inclusive)static func find_visual_node_direct( parent: Node ) -> Node
Finds the first visual node (Sprite2D or AnimatedSprite2D) among the direct children of the given parent. Returns null if none found.
static func find_visual_node( root: Node, recursive: bool ) -> Node
Finds a visual node (Sprite2D or AnimatedSprite2D) optionally searching recursively. By default, searches recursively to act as a universal helper.
static func is_visual_visible( root: Node, recursive: bool ) -> bool
Returns true if a visual node exists under root and is currently visible.
Source
Section titled “Source”addons/grid_building/utils/gb_search_utils.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.