extends ActionBehaviour class_name ActionBehaviourPillbug func can_move_through(cellA: Vector4i, cellB: Vector4i, map: HexGrid) -> bool: cellA.w = 1 cellB.w = 1 return map.get_same_neighbours(cellA, cellB).size() < 2 func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void: # get action tile # place hex outline for action tile around source_tile var tiles: Array[Vector4i] = map.get_empty_neighbours(source_tile.coordinates) var possible_tiles: Array[Vector4i] = [] for tile in tiles: if can_move_through(source_tile.coordinates, tile, map): possible_tiles.push_back(tile) map.create_move_tiles(action_tile, possible_tiles) func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]: var neighbours = map.get_neighbours(source_pos) var possible_action_targets: Array[InsectTile] = [] var tiles: Array[Vector4i] = map.get_empty_neighbours(source_pos) var possible_tiles: Array[Vector4i] = [] if tiles.is_empty(): # no empty spaces left to move to print("no spaces left") return [] for tile in tiles: if can_move_through(source_pos, tile, map): possible_tiles.push_back(tile) if possible_tiles.size() == 0: print("no possible tiles?") # no possible spaces to move TO return [] for neighbour in neighbours: var tile = map.get_tile(neighbour) if tile == null: continue print(tile.move_round_penalty) if not tile.can_move(): continue if not map.can_hive_exist_without_tile(tile): continue if tile != null: if not tile.is_in_stack() and tile.can_move(): if can_move_through(source_pos, neighbour, map): # this tile can be picked up 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