Grid Placement

CollisionObjectResolver

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: placement/manager/components/mapper/collision_object_resolver.gd

Version: 5.0

class_name: CollisionObjectResolver extends: RefCounted

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.

[b]Responsibilities:[/b]

  • 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

[b]Supported Collision Types:[/b]

  • CollisionObject2D (direct)
  • CollisionShape2D (via parent CollisionObject2D)
  • CollisionPolygon2D (via parent CollisionObject2D)

Signals

(none)

Exports

(none)

Methods

  • _init()
  • resolve_collision_object()
    • Resolve a collision object for layer checking and test setup lookup

@param collision_node: The collision node to resolve (CollisionObject2D, CollisionShape2D, or CollisionPolygon2D) @param test_setups: Array of available CollisionTestSetup2D objects @return ResolutionResult containing the resolved collision object and test setup

  • _resolve_direct_collision_object()
    • 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).

[b]Parameters:[/b] • [code]collision_obj[/code]: [i]CollisionObject2D[/i] - The collision object to resolve • [code]test_setups[/code]: [i]Array[CollisionTestSetup2D][/i] - Available test setups to search through

[b]Returns:[/b] [i]ResolutionResult[/i] - Contains the collision object, found test setup (may be null), validity flag, and descriptive message

[b]Behavior:[/b] • 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

  • _resolve_child_collision_object()
    • Resolve CollisionShape2D or CollisionPolygon2D via parent CollisionObject2D
  • _find_test_setup_for_collision_object()
    • Find test setup for a collision object
  • object_matches_layer_mask()
    • Check if a collision object matches the given layer mask

@param collision_obj: The CollisionObject2D to check @param layer_mask: The layer mask to match against @return true if the object matches the layer mask