Implemented most movement. TODO: Pillbug ability. And find and fix bugs witht he movement. TODO: Deselect when not movable
This commit is contained in:
parent
11f8a71f52
commit
76e4d6be34
33 changed files with 184 additions and 61 deletions
|
|
@ -1,2 +1,33 @@
|
|||
extends MovementBehaviour
|
||||
class_name MovementBehaviourBeetle
|
||||
|
||||
@export var max_movement_reach: int = 1
|
||||
|
||||
func simulate_move_recursive(start: Vector4i, max_num: int, map: HexGrid, visited_cells: Array[Vector4i] = []) -> Array[Vector4i]:
|
||||
var visited = visited_cells.duplicate()
|
||||
var possible: Array[Vector4i] = []
|
||||
|
||||
visited.append(start)
|
||||
|
||||
if max_num < 1:
|
||||
return [start]
|
||||
|
||||
for neighbour in map.get_neighbours(start, true):
|
||||
if neighbour in visited:
|
||||
continue
|
||||
|
||||
# can reach... can_reach should only apply to our current level
|
||||
if not map.can_reach(start, neighbour):
|
||||
continue
|
||||
|
||||
visited.append(neighbour)
|
||||
possible.append_array(simulate_move_recursive(neighbour, max_num - 1, map, visited))
|
||||
|
||||
return possible
|
||||
|
||||
func get_available_spaces(pos: Vector4i, map: HexGrid) -> Array[Vector4i]:
|
||||
var possible_places: Array[Vector4i] = []
|
||||
|
||||
possible_places = simulate_move_recursive(pos, max_movement_reach, map)
|
||||
|
||||
return possible_places
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue