FantasyRun/Tiles/Tile.gd
Matthew Welch c1bb198be6 Start work on tile generator autoload
update tile positioning to work with the spawn points
2024-10-05 14:09:45 -07:00

52 lines
885 B
GDScript

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
func _ready():
paths.append($MainPath)
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