Files
2026-02-01 23:17:51 +08:00

40 lines
1.2 KiB
GDScript

## Abstract class representing a range of notes in some kind of array,
## expressed by a beginning index and an ending index: [begin, end).
@abstract class_name View extends Node
## Get the array this View refers to.
@abstract func get_data() -> Variant
## Update the view to be relative to beat.
## Can be connected to a beat update signal.
@abstract func update(beat: float) -> void
## Reset the view.
func reset_view() -> void:
_begin = -1
_end = -1
## Beginning of the range relative to te current beat where notes will be visible.
## Any notes where (hit_beat < current_beat + offset_begin) will NOT be visible.
@export var offset_begin: float = -4.0
## End of the range relative to the current beat where notes will be visible.
## Any notes where (hit_beat > current_beat + offset_end) will NOT be visible.
@export var offset_end: float = 4.0
## Return the index to the first element.
func begin() -> int:
return _begin
## Return the index after the last element (equal to last index + 1).
func end() -> int:
return _end
## Size of the range encompassed by begin() and end().
func size() -> int:
return int(_begin >= 0) * _end - _begin
# ======= IMPLEMENETATION ======= #
var _begin: int = -1
var _end: int = -1