Refactor rhythm action architecture
This commit is contained in:
27
resources/beat_chart.gd
Normal file
27
resources/beat_chart.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user