2024-09-27 13:39:45 -07:00
|
|
|
extends Node3D
|
|
|
|
|
2024-09-30 20:50:05 -07:00
|
|
|
@onready var character = $Character as Character
|
2024-09-27 13:39:45 -07:00
|
|
|
|
|
|
|
var change_distance: float
|
2024-09-30 20:50:05 -07:00
|
|
|
var tiles: Array[Tile]
|
2024-10-04 10:01:33 -07:00
|
|
|
var tile_index: int = 0
|
|
|
|
|
|
|
|
var current_tile: Tile:
|
|
|
|
get = get_current_tile
|
2024-09-27 16:49:56 -07:00
|
|
|
|
2024-09-27 13:39:45 -07:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2024-09-30 20:50:05 -07:00
|
|
|
tiles.assign(Utils.get_nodes_of_class(self, Tile))
|
|
|
|
if tiles.size() == 0:
|
|
|
|
printerr("There are no Tiles in the scene.")
|
2024-09-27 16:49:56 -07:00
|
|
|
return
|
2024-10-04 10:01:33 -07:00
|
|
|
if character.tile == null:
|
|
|
|
character.tile = current_tile
|
2024-09-27 13:39:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
2024-10-04 10:01:33 -07:00
|
|
|
if tiles.size() == 0:
|
|
|
|
return
|
|
|
|
if is_equal_approx(current_tile.follow.progress_ratio, 1) and has_next_tile():
|
|
|
|
if current_tile.has_next_path():
|
2024-09-27 16:49:56 -07:00
|
|
|
return
|
2024-10-04 10:01:33 -07:00
|
|
|
tile_index += 1
|
|
|
|
character.tile = current_tile
|
|
|
|
|
|
|
|
|
|
|
|
func has_next_tile() -> bool:
|
|
|
|
return tile_index + 1 < tiles.size()
|
|
|
|
|
|
|
|
|
|
|
|
func get_current_tile() -> Tile:
|
|
|
|
return tiles[tile_index]
|