Swarm/ActionBehaviour/Prefabs/ActionBehaviourPillbug.gd

24 lines
879 B
GDScript

extends ActionBehaviour
class_name ActionBehaviourPillbug
func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void:
pass
func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
var neighbours = map.get_neighbours(source_pos)
var possible_action_targets: Array[InsectTile] = []
for neighbour in neighbours:
var tile = map.get_tile(neighbour)
if tile != null:
if not tile.is_in_stack() and tile.can_move():
possible_action_targets.push_back(tile)
#GameEvents.insect_tiles_selected_for_action.emit(source_pos, possible_action_targets)
return possible_action_targets
# 2nd level has to be clear (move through narrow gap rule)
# We could do the following: Get neighbours in 2nd level of source (pillbug) and target
# we we have two overlapping/same neighbours, we have a narrow gap and can't move the target