GridTargetingState
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
State for targeting objects within the Grid Building System.
Source File: addons/grid_building/systems/grid_targeting/grid_targeting_state.gd
Extends: GBResource
Signals
Signal:
ready_changed(value : bool)- Emitted when the readiness status of the state has changed - usually after successful validation.Signal:
target_changed(new : Node2D, old : Node2D)Emitted when the target node for the state is changed.
NOTE: Typically target is set by a TargetingShapeCast2D or similar casting node from the runtime scene
Signal:
positioner_changed(positioner : Node2D)- Emitted when the node responsible for positioning grid building placement objects and indicators is changed on the BuildingState.Signal:
target_map_changed(target_map : TileMapLayer)Emitted when the targeted map node is changed. This represents the main target TileMapLayer node on the state.
Signal:
maps_changed(maps : Array[TileMapLayer])Emitted when the list of known maps is changed.
This is a list of maps that can be accessed without the need for any collision check calls.
Properties
Property:
target : Node2D :- The placed node currently being targetedProperty:
positioner : Node2D :- Parent node for positioning grid building objects onto the game world.Property:
target_map : TileMapLayer :The TileMapLayer or TileMap node to be used when determining grid distances in your game world
You could think of this as the main map node usually where characters stand on
Property:
maps : Array[TileMapLayer]:All maps to be known by the targeting state for testing against without casting for collisions.
You can exclude any purely cosmetic maps that shouldn’t have gameplay impacts.
Property:
tile_size: Vector2i :- Tile size property that delegates to the target map’s tile setProperty:
collision_exclusions: Array[Node] = []Nodes that should be excluded from collision detection during indicator validation. This is primarily used during manipulation move operations to exclude the original object being moved, so indicators only detect collisions with OTHER objects.
IMPORTANT: This list is automatically cleared when:
- The target changes (manipulation ends and switches to a different target)
- Manually calling clear_collision_exclusions()
Usage: Set this at the start of manipulation move operations and it will auto-clear when manipulation ends.
Property:
is_manual_targeting_active: bool = falseFlag indicating whether manual targeting mode is currently active. When true, automatic targeting systems (like TargetingShapeCast2D) will not overwrite the manually-set target, and collision_exclusions will persist across target updates. Used during BUILD mode (preview) and MOVE mode (manipulation copy). Set via set_manual_target() and cleared via clear_manual_target().
Private Properties
- Property:
_owner_context : [GBOwnerContext](./gb-owner-context/)(private) - References the user root that serves as the origin for this targeting state - Property:
_target_signal_connected : bool = false(private)
Public Methods
is_ready
Returns true if the targeting state has all runtime requirements met for operation
clear_collision_exclusions
Clears the collision exclusion list. This is called automatically when the target changes (and manipulation is not active), but can also be called manually when ending manipulation operations.
set_manual_target
Sets a manual target and prevents automatic targeting updates. This prevents automatic targeting systems (like TargetingShapeCast2D) from overwriting the manually-set target. Used during:
- BUILD mode: Locks preview as target
- MOVE mode: Locks manipulation copy as target
If p_target is null, clears manual targeting mode (equivalent to clear_manual_target()). Otherwise, enables manual targeting and assigns the target.
p_target The node to manually target, or null to clear manual targeting
clear_manual_target
Clears manual targeting mode and resumes automatic targeting. Call this when BUILD or MOVE mode ends to allow TargetingShapeCast2D to automatically update the target again. Note: Does NOT clear the target node itself - only disables the manual targeting flag.
set_map_objects
Sets the target map and maps array for this targeting state
get_target_map_tile_shape
Get the shape of the currently targeted TileMapLayer’s tileset tiles
get_target_map_tile_set
Gets the tileset of the currently targeted TileMapLayer
get_tile_size
Gets the tile size from the target map’s tile set
set_tile_size
Sets the tile size on the target map’s tile set
validate_runtime
Ensures that the targeting state is ready for runtime operation and logs any issues found
get_owner
get_owner_root
get_origin
Returns the origin node associated with this targeting state. [return] The origin node provided by the owner context or null when unavailable.
get_editor_issues
Returns an array of issues found during editor validation
get_runtime_issues
Should be called AFTER necessary properties on the state have been set Checks the minimum setup dependencies for the state.
Private Methods
_init
Flags: private
_revalidate_on_change
Flags: private
Internal: Re-validate when critical properties change so ‘ready’ flips to true at the right time.
_disconnect_target_signal
Flags: private
Disconnects the tree_exiting signal from the current target (if connected)
_on_target_tree_exiting
Flags: private
Called when the current target is about to exit the scene tree
_is_same_context_update
Flags: private
Checks if the new target is part of the same object tree as any exclusion Returns true if new_target is a child/descendant of an excluded node This helps detect when TargetingShapeCast2D detects a different node of the same logical object