CollisionProcessor
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
Unified Collision Processor
Source File: addons/grid_building/placement/manager/components/mapper/collision_processor.gd
Extends: GBInjectable
Private Properties
- Property:
_cache_manager: GeometryCacheManager(private) - Property:
_logger: [GBLogger](./gb-logger/)(private)
Constants
- Constant:
GeometryCacheManager = preload("res://addons/grid_building/placement/manager/components/mapper/geometry_cache_manager.gd")
Public Methods
invalidate_cache
Invalidate all cached geometry data
resolve_gb_dependencies
Resolve dependencies from composition container
get_runtime_issues
Get runtime validation issues
get_tile_offsets_for_collision
Unified public method to process any collision object type Automatically detects the type and delegates to the appropriate handler
RETURN VALUE COORDINATE SYSTEM: Returns Dictionary[Vector2i, Array] where Vector2i keys are RELATIVE tile offsets from the positioner’s tile position, NOT absolute world tile coordinates.
These offsets represent: “tiles relative to positioner where indicators should appear” IndicatorFactory will convert them back to world positions as: indicator_position = positioner.global_position + (offset * tile_size)
@param collision_obj: The collision object to process (CollisionObject2D or CollisionPolygon2D) @param test_data: CollisionTestSetup2D for CollisionObject2D (null for CollisionPolygon2D) @param map: The TileMapLayer to map offsets against @param positioner: The positioner node for coordinate transformations (CRITICAL for relative offsets) @return Dictionary[Vector2i, Array] containing RELATIVE tile offsets as keys and collision objects as values
process_shape_offsets
Process shape offsets for a single collision test setup
COORDINATE MIXING ZONE: This method combines absolute world coordinates (for collision detection) with relative tile coordinates (for return values). The center_tile parameter is the key bridge between these coordinate systems.
ABSOLUTE WORLD COORDINATES (used internally):
- shape_transform.origin: collision object’s world position
- tile_center_world, tile_top_left_world: world coordinates for overlap testing
- All geometric calculations happen in world space for accuracy
RELATIVE TILE COORDINATES (return values):
- tile_pos - center_tile: converts world tile positions to relative offsets
- These offsets will be added to positioner position by IndicatorFactory
calculate_tile_range
Calculate the tile range that needs to be checked for a shape Returns a dictionary with ‘start’ and ’end_exclusive’ Vector2i values
compute_shape_tile_offsets
Compute which tiles a shape overlaps with, returning offset positions
Private Methods
_init
Flags: private
_get_tile_offsets_for_collision_polygon
Flags: private
Handle CollisionPolygon2D processing Uses positioner as coordinate reference for consistent positioning behavior
_get_tile_offsets_for_collision_object
Flags: private
Handle CollisionObject2D with shapes processing CRITICAL: Returns offsets relative to positioner position for correct indicator placement. See positioning-regression-fix-guide.mdx for coordinate system details.
_initialize_collision_mapping
Flags: private
Initialize collision mapping with validation
_merge_offsets_into_positions
Flags: private
Merge offsets into positions with center tile conversion
FINAL COORDINATE VALIDATION: At this point, shape_offsets contains relative tile offsets (Vector2i) calculated as (tile_pos - center_tile) where center_tile is based on positioner.global_position. These offsets are ready for IndicatorFactory to convert back to world positions as: positioner_position + (offset * tile_size)
_merge_collision_positions
Flags: private
Merge two collision position dictionaries