FantasyRun/Tiles/Tile.gd

52 lines
885 B
GDScript3
Raw Normal View History

2024-09-30 20:50:05 -07:00
extends Node3D
class_name Tile
@onready var spawn_point = $SpawnPoint as Marker3D
var paths: Array[TilePath]
var path_index: int = 0
var path: TilePath:
get = get_current_path
var follow: PathFollow3D:
get:
return path.follow
var progress_marker: Marker3D:
get:
return path.marker
var marker_position: Vector3:
get:
return progress_marker.global_position
var marker_rotation: Vector3:
get:
return progress_marker.global_rotation
2024-09-30 20:50:05 -07:00
func _ready():
paths.append($MainPath)
2024-09-30 20:50:05 -07:00
func _process(delta):
if is_equal_approx(follow.progress_ratio, 1) and has_next_path():
get_next_path().receive_marker(progress_marker)
path_index += 1
func get_current_path() -> TilePath:
return paths[path_index]
func has_next_path() -> bool:
return path_index + 1 < paths.size()
func get_next_path() -> TilePath:
if has_next_path():
return paths[path_index+1]
return null