Many changes
Handle it
This commit is contained in:
parent
bf09402bc5
commit
214e0aa5e0
366 changed files with 24353 additions and 2096 deletions
|
|
@ -4,7 +4,7 @@ func _ready() -> void:
|
|||
Log.pr("CoordUtility ready")
|
||||
|
||||
|
||||
func all_cells(start : Vector2i, end : Vector2i) -> Array:
|
||||
func all_cells(start: Vector2i, end: Vector2i) -> Array:
|
||||
# Returns all cells between start and end
|
||||
var cells = []
|
||||
|
||||
|
|
@ -21,7 +21,6 @@ func perimeter_cells(start: Vector2i, end: Vector2i, inclusive: bool = true, wid
|
|||
# Returns cells on the perimeter between start and end
|
||||
# inclusive: if true, includes the area cells, if false, excludes them
|
||||
# width: the thickness of the perimeter (default: 1)
|
||||
|
||||
var cells: Array[Vector2i] = []
|
||||
var min_x: int = min(start.x, end.x)
|
||||
var max_x: int = max(start.x, end.x)
|
||||
|
|
@ -39,6 +38,7 @@ func perimeter_cells(start: Vector2i, end: Vector2i, inclusive: bool = true, wid
|
|||
var outer_max_y: int
|
||||
|
||||
if inclusive:
|
||||
Log.pr("Drawing within bounds of the original rectangle")
|
||||
# For inclusive, inner bounds are the original rectangle
|
||||
inner_min_x = min_x
|
||||
inner_min_y = min_y
|
||||
|
|
@ -51,6 +51,7 @@ func perimeter_cells(start: Vector2i, end: Vector2i, inclusive: bool = true, wid
|
|||
outer_max_x = max_x + (width - 1)
|
||||
outer_max_y = max_y + (width - 1)
|
||||
else:
|
||||
Log.pr("Drawing outside bounds of the original rectangle")
|
||||
# For exclusive, inner bounds are the original rectangle
|
||||
inner_min_x = min_x
|
||||
inner_min_y = min_y
|
||||
|
|
@ -77,4 +78,21 @@ func perimeter_cells(start: Vector2i, end: Vector2i, inclusive: bool = true, wid
|
|||
if x < inner_min_x or x > inner_max_x or y < inner_min_y or y > inner_max_y:
|
||||
cells.append(pos)
|
||||
|
||||
return cells
|
||||
return cells
|
||||
|
||||
func get_surrounding_tiles(given_tile: Vector2i, spread: int = 1) -> Array[Vector2i]:
|
||||
Log.pr("Getting surrounding tiles for tile: ", given_tile, " with spread: ", spread)
|
||||
var surrounding_tiles: Array[Vector2i] = []
|
||||
|
||||
# Loop from -spread to +spread in both directions
|
||||
for y in range(-spread, spread + 1):
|
||||
for x in range(-spread, spread + 1):
|
||||
# Skip the center tile if you don't want it included
|
||||
if x == 0 and y == 0:
|
||||
continue
|
||||
|
||||
var target_tile = given_tile + Vector2i(x, y)
|
||||
surrounding_tiles.append(target_tile)
|
||||
|
||||
Log.pr("Surrounding tiles: ", surrounding_tiles)
|
||||
return surrounding_tiles
|
||||
Loading…
Add table
Add a link
Reference in a new issue