35 lines
1007 B
GDScript
35 lines
1007 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 action_id: StringName = &""
|
|
@export var payload: Dictionary = {}
|
|
@export var lead_beats := 1.0
|
|
@export var time_phase_mask: StringName = &"both"
|
|
|
|
|
|
func matches_time_phase(time_phase: StringName) -> bool:
|
|
if time_phase_mask.is_empty() or time_phase_mask == &"both":
|
|
return true
|
|
return time_phase_mask == time_phase
|
|
|
|
|
|
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])
|