28 lines
702 B
GDScript
28 lines
702 B
GDScript
class_name BeatChart
|
|
extends Resource
|
|
|
|
@export var chart_id: StringName = &""
|
|
@export var total_beats := 0
|
|
@export var tracks: Array = []
|
|
|
|
|
|
func all_events() -> Array:
|
|
var result: Array = []
|
|
for track in tracks:
|
|
if not track is Resource:
|
|
continue
|
|
for event in track.call("sorted_events"):
|
|
result.append(event)
|
|
result.sort_custom(func(a: Resource, b: Resource) -> bool:
|
|
var a_position := float(a.call("beat_position"))
|
|
var b_position := float(b.call("beat_position"))
|
|
if is_equal_approx(a_position, b_position):
|
|
return str(a.get("event_type")) < str(b.get("event_type"))
|
|
return a_position < b_position
|
|
)
|
|
return result
|
|
|
|
|
|
func is_empty() -> bool:
|
|
return all_events().is_empty()
|