CollisionObjectResolver
Summary
Section titled “Summary”Collision Object Resolver
Internal utility for resolving collision objects and their test setups. Handles the logic for determining appropriate CollisionObject2D instances for layer checking and finding corresponding CollisionTestSetup2D objects.
This is an internal implementation detail of CollisionMapper and should not be used directly. Unit tests access it for testing the resolution logic.
Responsibilities:
- Resolve CollisionObject2D for layer checking from various collision node types - Find appropriate CollisionTestSetup2D for collision objects - Validate collision object hierarchies - Provide type-safe collision object handling
Supported Collision Types:
- CollisionObject2D (direct) - CollisionShape2D (via parent CollisionObject2D) - CollisionPolygon2D (via parent CollisionObject2D)
Methods
Section titled “Methods”func resolve_collision_object( collision_node: Node2D, test_setups: Array[CollisionTestSetup2D] ) -> ResolutionResult
Resolve a collision object for layer checking and test setup lookup
collision_node
: The collision node to resolve (CollisionObject2D, CollisionShape2D, or CollisionPolygon2D)test_setups
: Array of available CollisionTestSetup2D objects Returns: ResolutionResult containing the resolved collision object and test setupfunc _resolve_direct_collision_object( collision_obj: CollisionObject2D, test_setups: Array[CollisionTestSetup2D] ) -> ResolutionResult
Resolve direct CollisionObject2D
Processes a CollisionObject2D node to find its corresponding test setup or determine if it can be processed without one (e.g., when it contains CollisionPolygon2D children).
Parameters: •
collision_obj
: CollisionObject2D - The collision object to resolve •test_setups
: Array[CollisionTestSetup2D] - Available test setups to search throughReturns: ResolutionResult - Contains the collision object, found test setup (may be null), validity flag, and descriptive message
Behavior: • First attempts to find a matching CollisionTestSetup2D for the collision object • If no test setup found, checks if the object has CollisionPolygon2D children • CollisionPolygon2D children allow processing without test setups (polygon-based geometry) • Returns valid=true for polygon children, valid=false otherwise
func _resolve_child_collision_object( collision_node: Node2D, test_setups: Array[CollisionTestSetup2D] ) -> ResolutionResult
Resolve CollisionShape2D or CollisionPolygon2D via parent CollisionObject2D
func _find_test_setup_for_collision_object( collision_obj: CollisionObject2D, test_setups ) -> CollisionTestSetup2D
Find test setup for a collision object
func object_matches_layer_mask( collision_obj: CollisionObject2D, layer_mask: int ) -> bool
Check if a collision object matches the given layer mask
collision_obj
: The CollisionObject2D to checklayer_mask
: The layer mask to match against Returns: true if the object matches the layer mask
Source
Section titled “Source”addons/grid_building/placement/manager/components/mapper/collision_object_resolver.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.