Class GridTargetingState
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
State for targeting objects within the Grid Building System.
class GridTargetingState extends GBResource
Properties
target
The placed node currently being targeted
var target: Node2D :
old
var old: Node2D = target
should_clear
var should_clear = not is_manual_targeting_active and not _is_same_context_update(value)
positioner
Parent node for positioning grid building objects onto the game world.
var positioner: Node2D :
target_map
The TileMapLayer or TileMap node to be used when determining grid distances in your game world [br][br] You could think of this as the main map node usually where characters stand on
var target_map: TileMapLayer :
maps
All maps to be known by the targeting state for testing against without casting for collisions. [br][br] You can exclude any purely cosmetic maps that shouldn't have gameplay impacts.
var maps: Array[TileMapLayer]:
tile_size
Tile size property that delegates to the target map's tile set
var tile_size: Vector2i :
collision_exclusions
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.\n\nIMPORTANT: This list is automatically cleared when: - The target changes (manipulation ends and switches to a different target) - Manually calling clear_collision_exclusions()\n\nUsage: Set this at the start of manipulation move operations and it will auto-clear when manipulation ends.
var collision_exclusions: Array[Node] = []
is_manual_targeting_active
Flag 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().
var is_manual_targeting_active: bool = false
tile_set
var tile_set = get_target_map_tile_set()
tile_set
var tile_set = get_target_map_tile_set()
tile_set
var tile_set = get_target_map_tile_set()
issues
var issues: Array[String] = []
was_ready
var was_ready = is_ready()
current_ready
var current_ready = is_ready()
issues
var issues: Array[String] = []
issues
var issues: Array[String] = []
current
var current: Node = new_target
Methods
is_ready
func is_ready() -> bool:
Returns
clear_collision_exclusions
func clear_collision_exclusions() -> void:
Returns
set_manual_target
func set_manual_target(p_target: Node2D) -> void:
Parameters
p_target
Returns
clear_manual_target
func clear_manual_target() -> void:
Returns
set_map_objects
func set_map_objects(p_target_map: TileMapLayer, p_maps: Array[TileMapLayer]) -> void:
Parameters
p_target_mapp_maps
Returns
get_target_map_tile_shape
func get_target_map_tile_shape() -> TileSet.TileShape:
Returns
get_target_map_tile_set
func get_target_map_tile_set() -> TileSet:
Returns
get_tile_size
func get_tile_size() -> Vector2i:
Returns
set_tile_size
func set_tile_size(size: Vector2i) -> void:
Parameters
size
Returns
validate_runtime
func validate_runtime(logger: GBLogger = null) -> bool:
Parameters
logger
Returns
get_owner
func get_owner() -> Node:
Returns
get_owner_root
func get_owner_root() -> Node:
Returns
get_origin
func get_origin() -> Node:
Returns
get_editor_issues
func get_editor_issues() -> Array[String]:
Returns
get_runtime_issues
func get_runtime_issues() -> Array[String]:
Returns
Events
ready_changed
Emitted when the readiness status of the state has changed - usually after successful validation.
signal ready_changed(value : bool)
target_changed
Emitted when the target node for the state is changed.\n\nNOTE: Typically target is set by a TargetingShapeCast2D or similar casting node from the runtime scene
signal target_changed(new : Node2D, old : Node2D)
positioner_changed
Emitted when the node responsible for positioning grid building placement objects and indicators is changed on the PlacementState.
signal positioner_changed(positioner : Node2D)
target_map_changed
Emitted when the targeted map node is changed. This represents the main target TileMapLayer node on the state.
signal target_map_changed(target_map : TileMapLayer)
maps_changed
Emitted when the list of known maps is changed.[br][br] This is a list of maps that can be accessed without the need for any collision check calls.
signal maps_changed(maps : Array[TileMapLayer])