Cleanup Grid.gd

This commit is contained in:
CactiChameleon9 2022-03-13 18:31:17 +00:00
parent 5071247b69
commit 25a400f31f

View File

@ -172,6 +172,7 @@ func position_to_coordinates (node_position : Vector2, height : int) -> Vector2:
return out
func _is_in_grid (coordinates : Vector2) -> bool:
if (coordinates.x >= GRID_SIZE.x or
coordinates.y >= GRID_SIZE.y or
@ -180,6 +181,7 @@ func _is_in_grid (coordinates : Vector2) -> bool:
return false
return true
func get_tile_behind_state (coordinates : Vector2) -> String:
#checking if tiles are directly behind
#the plus 1 and plus 2 mean that its a height difference of 2 or 3 required respectively
@ -200,7 +202,8 @@ func get_tile_behind_state (coordinates : Vector2) -> String:
else:
return "n" #no
func get_around_coordinate(coordinate : Vector2, movement_distance : int):
func get_around_coordinate (coordinate : Vector2, movement_distance : int):
#found https://godotengine.org/qa/64496/how-to-get-a-random-tile-in-a-radious
#disclude the tile being stood on
@ -228,7 +231,8 @@ func get_around_coordinate(coordinate : Vector2, movement_distance : int):
return positions
func _filter_moveable_spaces(positions_array, water_walk : bool = false, air_walk : bool = false, lava_walk : bool = false):
func _filter_moveable_spaces (positions_array, water_walk : bool = false, air_walk : bool = false, lava_walk : bool = false):
#this uses happy path to filter out the invalid move spaces
var new_pos_array = []
for i in positions_array.size():
@ -252,7 +256,8 @@ func _filter_moveable_spaces(positions_array, water_walk : bool = false, air_wal
new_pos_array.append(positions_array[i])
return new_pos_array
func display_selection(coordinate : Vector2, unit : Unit):
func display_selection (coordinate : Vector2, unit : Unit):
var movement_amount = unit.movement_points
print("hi")
for i in range (movement_amount, -1, -1):
@ -268,7 +273,8 @@ func display_selection(coordinate : Vector2, unit : Unit):
var area_moveable = _filter_moveable_spaces(area_around, unit.water_walk, unit.air_walk, unit.lava_walk)
$SelectionAreaController.create_selection_from_array(area_moveable, i)
func remove_selection():
func remove_selection ():
$SelectionAreaController.emit_signal("remove_selection")