CollisionTestSetup2D

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

CollisionTestSetup2D

1
2
3
4
var test_setup = CollisionTestSetup2D.new(collision_object, Vector2(16, 16))
if test_setup.validate_setup():
Use test_setup.rect_collision_test_setups for collision testing
pass

Source File: addons/grid_building/placement/collsion_test/collision_test_setup_2d.gd

Extends: RefCounted

Properties

  • Property: collision_object: CollisionObject2D: - The CollisionObject2D being analyzed for collision testing.

  • Property: shape_stretch_size: Vector2

    Size to stretch collision shapes for comprehensive tile coverage. Recommended: Use your tile size (e.g., Vector2(16, 16) for 16x16 tiles). See advanced documentation for detailed sizing guidance.

  • Property: rect_collision_test_setups: Array[RectCollisionTestingSetup]

    Array of RectCollisionTestingSetup instances, one per shape owner. Use these setups to perform collision tests for placement indicators.

  • Property: issues: Array[String] = []

    Issues discovered during collision test setup. Check this array after initialization to identify configuration problems.

Public Methods

add_issue

1
add_issue(p_issue: String) -> void

Records an issue encountered during setup.


free_testing_nodes

1
free_testing_nodes() -> void

Frees all testing nodes created during setup. Call this when the setup is no longer needed to prevent memory leaks.


validate_setup

1
validate_setup() -> bool

Validates the collision test setup and reports any issues. Returns true if setup is valid and ready for use, false otherwise.


Private Methods

_init

1
2
3
4
_init(
    p_collision_object: CollisionObject2D,
    p_shape_stretch_size: Vector2
) -> void

Flags: private

Initializes collision test setup for the given CollisionObject2D.


_create_rect_tests_for_collision_object

1
2
3
_create_rect_tests_for_collision_object(
    p_collision_object: CollisionObject2D
) -> Array[RectCollisionTestingSetup]

Flags: private

Creates RectCollisionTestingSetup instances for each shape owner in the CollisionObject2D.


_get_testing_rect_for_owner

1
_get_testing_rect_for_owner(p_shape_owner: Node2D) -> Rect2

Flags: private

Calculates the testing rectangle for a shape owner node. Supports CollisionShape2D and CollisionPolygon2D nodes.


_adjust_rect_to_testing_size

1
2
3
4
_adjust_rect_to_testing_size(
    p_base_rect: Rect2,
    p_shape_owner_global_transform: Transform2D
) -> Rect2

Flags: private

Expands the rectangle by shape_stretch_size to ensure comprehensive tile coverage. Handles complex transforms by converting to squares when rotation/skew is present.