Added static typing and enforced it
This commit is contained in:
parent
217f0ab18c
commit
cc80783d16
4 changed files with 47 additions and 29 deletions
|
|
@ -1,11 +1,19 @@
|
|||
extends TileMap
|
||||
class_name CustomTileMap
|
||||
|
||||
var astar : AStarGrid2D = AStarGrid2D.new()
|
||||
@onready var fog_overlay : ColorRect = $FogOverlay
|
||||
|
||||
@onready var tilemap_size : Vector2i = get_used_rect().end - get_used_rect().position
|
||||
@onready var map_rect : Rect2i = Rect2i(Vector2i.ZERO, tilemap_size)
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
var tile_size : Vector2i = get_tileset().tile_size
|
||||
var map_pixel_size : Vector2i = tilemap_size * tile_size
|
||||
fog_overlay.size = map_pixel_size
|
||||
|
||||
|
||||
setup_pathing()
|
||||
pass
|
||||
|
||||
|
|
@ -31,14 +39,14 @@ func update_passable() -> void:
|
|||
for i in tilemap_size.x:
|
||||
for j in tilemap_size.y:
|
||||
var coords : Vector2i = Vector2i(i, j)
|
||||
var tile_data = get_cell_tile_data(0, coords)
|
||||
var tile_data : TileData = get_cell_tile_data(0, coords)
|
||||
if tile_data and tile_data.get_custom_data('navtype') == 'wall':
|
||||
astar.set_point_solid(coords)
|
||||
|
||||
pass
|
||||
|
||||
func is_point_walkable(check_position) -> bool:
|
||||
var map_position = local_to_map(check_position)
|
||||
func is_point_walkable(check_position : Vector2i) -> bool:
|
||||
var map_position : Vector2i = local_to_map(check_position)
|
||||
if map_rect.has_point(map_position) and not astar.is_point_solid(map_position):
|
||||
return true
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue