Implemented Pillbug/Mosquito actions. Implemented pre-game settings. TODO: Game settings + bug testing

This commit is contained in:
Sch1nken 2024-03-30 01:43:38 +01:00
parent 397082f966
commit 2343638749
15 changed files with 477 additions and 70 deletions

View file

@ -1,18 +1,52 @@
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:
pass
# 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:
if not tile.is_in_stack() and tile.can_move():
possible_action_targets.push_back(tile)
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)