#TODO Split class into two. # One should be responsible for storing arrays of data, like a NoteData class? # Another represents a slice of the data, NoteView. # Before that, figure out how the part of a hold note between the hold start # and hold end will be implemented. class_name NoteLayout extends Node ## Controls at what beat notes are visible. @export_group("Note View Offset") ## At what beat offset from the current beat will notes will be visible. ## Example, spawn = 4.0 means notes are spawned 4 beats before ## they are meant to be hit. @export var spawn: float = 4.0 ## At what beat offset from the current beat will notes be invisible. ## Example, despawn = 4.0 means notes are despawned 4 beats after ## they are meant to be hit. @export var despawn: float = 4.0 ## The index in notes of the first active note. func start() -> int: return _start ## The index in notes after the last active note. func end() -> int: return _end func size() -> int: return _beat.size() func beat(index: int) -> float: return _beat[index] func lane(index: int) -> int: return _lane[index] func type(index: int) -> Note.TYPE: return _type[index] # ======= IMPLEMENTATION ======== # # All notes in the chart, arranged by ascending beat. var _beat: Array[float] = [] var _lane: Array[int] = [] var _type: Array[Note.TYPE] = [] var _start: int = 0 var _end: int = 0 func _push_note(_note: Note) -> void: pass # TODO FIX THESE func _update_forward(new_beat: float) -> void: var spawn_beat = new_beat + spawn while _end < size() and _beat[_end] <= spawn_beat: _end += 1 var despawn_beat = new_beat - despawn while _start < size() and _beat[_start] < despawn_beat: _start += 1 # TODO FIX THESE #func _update_backward(new_beat: float) -> void: #var spawn_beat = new_beat + note_spawn_offset # #while _end >= 0 and _beat[_end] > spawn_beat: #_end -= 1 # #var despawn_beat = new_beat - note_despawn_offset # #while _start >= 0 and _beat[_start] < despawn_beat: #_start -= 1