Implemented most movement. TODO: Pillbug ability. And find and fix bugs witht he movement. TODO: Deselect when not movable

This commit is contained in:
Sch1nken 2024-03-14 21:17:16 +01:00
parent 11f8a71f52
commit 76e4d6be34
33 changed files with 184 additions and 61 deletions

View file

@ -6,29 +6,26 @@ class_name MovementBehaviourAnt
# Maybe better: Get al "placecable tiles" from the map, go over those. Might be faster but more complicated
func simulate_move_recursive(start: Vector4i, exclude: Array[Vector4i], map: HexGrid, visited_cells: Array[Vector4i] = []) -> Array[Vector4i]:
var visited = visited_cells
var possible: Array[Vector4i] = []
#if max_num < 1:
# return [start]
for neighbour in map.get_empty_neighbours(start):
if neighbour in visited:
if neighbour in visited_cells:
continue
if not map.is_position_on_hive(neighbour):
continue
if not map.can_reach(start, neighbour):
continue
visited_cells.push_back(neighbour)
simulate_move_recursive(neighbour, exclude, map, visited_cells)
var same_neighbours = map.get_same_neighbours(start, neighbour)
for e in exclude:
same_neighbours.erase(e)
if same_neighbours.size() > 0:
visited.append(neighbour)
print("yay?")
possible.append_array(simulate_move_recursive(neighbour, exclude, map, visited))
return possible
return visited_cells
func get_available_spaces(pos: Vector4i, map: HexGrid) -> Array[Vector4i]:
var possible_places: Array[Vector4i] = []