27 lines
744 B
GDScript
27 lines
744 B
GDScript
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])
|