CollisionMapper
Summary
Section titled “Summary”Convert collision sources into tile-relative offsets for placement rules and indicators.
Responsibilities:
- Translate CollisionShape2D / CollisionPolygon2D geometry into tile offsets used by placement rules and indicators.
- Apply filtering, normalization, and heuristics to remove slivers and normalize pivots for consistent indicators.
- Provide caching and utility helpers consumed by IndicatorManager and the placement pipeline.
Properties
Section titled “Properties”indicator_contact_positions: Array = []
test_indicator: RuleCheckIndicator
collision_object_test_setups: Dictionary[Node2D, IndicatorCollisionTestSetup] = {}
Maps each CollisionObject2D to its IndicatorCollisionTestSetup for collision testing.
Methods
Section titled “Methods”get_runtime_issues( ) -> Array[String]
Validation Returns a list of issues if required state is missing; empty when valid. Returns: Array[String]
resolve_gb_dependencies( container: GBCompositionContainer ) -> bool
Manual Injection Resolve dependencies from the container after construction. Useful when the mapper is instantiated without the factory. Returns - bool - Whether the injection was successful or not
setup( p_test_indicator: RuleCheckIndicator, p_collision_object_test_setups: Dictionary[Node2D, IndicatorCollisionTestSetup] ) -> void
Setup Wire the test indicator and per-object collision test setups; invalidates internal caches. Call whenever either changes to ensure fresh geometry. Parameters: •
p_test_indicator
: RuleCheckIndicator – the reusable indicator shape/owner. •p_collision_object_test_setups
: Dictionary[Node2D, IndicatorCollisionTestSetup] – precomputed shape info.get_tile_offsets_for_test_collisions( test_data: IndicatorCollisionTestSetup ) -> Dictionary
Resolve tile offsets for a single node Dispatch to polygon or shape path depending on the object type. Returns
offset -> owners
. Parameters:test_data
– IndicatorCollisionTestSetup for a CollisionObject2D or the polygon node. Returns: Dictionary – offsets to contributing nodes for that source.get_rect_tile_positions( global_center_position: Vector2, transformed_rect_size: Vector2 ) -> Array[Vector2i]
Absolute tiles overlapped by an axis‑aligned rectangle Returns absolute tile coordinates overlapped by a rectangle centered at a world position. Uses symmetric distribution to avoid half‑tile drift. Parameters: •
global_center_position
: Vector2 – center in world space. •transformed_rect_size
: Vector2 – rectangle size in world units. Returns: Array[Vector2i]
Source
Section titled “Source”addons/grid_building/placement/manager/components/mapper/collision_mapper.gd
This page was auto-generated from GDScript source. Edit the source file to improve documentation.
Generated on 2025-09-07