Refactor rhythm action architecture
This commit is contained in:
32
scenes/components/input_intent.gd
Normal file
32
scenes/components/input_intent.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
class_name InputIntent
|
||||
extends RefCounted
|
||||
|
||||
var symbol: StringName
|
||||
var rhythm_action: StringName
|
||||
var event_type: StringName
|
||||
var timestamp_ms := 0.0
|
||||
var judgement: Dictionary = {}
|
||||
|
||||
|
||||
static func create(next_symbol: StringName, next_rhythm_action: StringName, next_event_type: StringName, next_timestamp_ms: float) -> RefCounted:
|
||||
var script: Script = load("res://scenes/components/input_intent.gd")
|
||||
var intent: RefCounted = script.new()
|
||||
intent.symbol = next_symbol
|
||||
intent.rhythm_action = next_rhythm_action
|
||||
intent.event_type = next_event_type
|
||||
intent.timestamp_ms = next_timestamp_ms
|
||||
return intent
|
||||
|
||||
|
||||
func is_pressed() -> bool:
|
||||
return event_type == &"pressed"
|
||||
|
||||
|
||||
func is_released() -> bool:
|
||||
return event_type == &"released"
|
||||
|
||||
|
||||
func with_judgement(next_judgement: Dictionary) -> RefCounted:
|
||||
var copy: RefCounted = load("res://scenes/components/input_intent.gd").create(symbol, rhythm_action, event_type, timestamp_ms)
|
||||
copy.judgement = next_judgement.duplicate()
|
||||
return copy
|
||||
Reference in New Issue
Block a user