Refactor rhythm action architecture
This commit is contained in:
26
resources/chart_event.gd
Normal file
26
resources/chart_event.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
class_name ChartEvent
|
||||
extends Resource
|
||||
|
||||
@export var event_id: StringName = &""
|
||||
@export var beat_index := 0
|
||||
@export var subdivision := 0
|
||||
@export var subdivisions_per_beat := 1
|
||||
@export var event_type: StringName = &""
|
||||
@export var target_id: StringName = &""
|
||||
@export var payload: Dictionary = {}
|
||||
@export var lead_beats := 1.0
|
||||
|
||||
|
||||
func beat_position() -> float:
|
||||
var safe_subdivisions := maxi(1, subdivisions_per_beat)
|
||||
return float(beat_index) + float(subdivision) / float(safe_subdivisions)
|
||||
|
||||
|
||||
func time_seconds(beat_time: float) -> float:
|
||||
return beat_position() * maxf(0.001, beat_time)
|
||||
|
||||
|
||||
func key() -> StringName:
|
||||
if not event_id.is_empty():
|
||||
return event_id
|
||||
return StringName("%s:%s:%d:%d" % [event_type, target_id, beat_index, subdivision])
|
||||
Reference in New Issue
Block a user