forked from team-sg/hero-mark-2
state chart additions: consumed events export and auto_initialize toggle
This commit is contained in:
parent
941f8f0f09
commit
79cbd62a69
2 changed files with 13 additions and 1 deletions
|
@ -22,6 +22,8 @@ enum ProcessMode {IDLE, PHYSICS}
|
|||
|
||||
## whether to process transition delays during physics or idle frames
|
||||
export (ProcessMode) var transition_process_mode: int = ProcessMode.PHYSICS
|
||||
## events to consume so that parent state can not
|
||||
export (Array, String) var consumed_events: Array = []
|
||||
|
||||
## whether the current state is active
|
||||
var active: bool setget _set_active
|
||||
|
@ -77,6 +79,10 @@ func _state_event(event: String) -> bool:
|
|||
# first match is taken
|
||||
_queue_transition(transition)
|
||||
return true
|
||||
|
||||
if event in consumed_events:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
@ -113,6 +119,7 @@ func _process_transition(delta: float) -> void:
|
|||
_queued_transition_time -= delta
|
||||
# if ready, handle transition and clear queue
|
||||
if _queued_transition_time <= 0.0:
|
||||
print(_queued_transition.name)
|
||||
var transition = _queued_transition
|
||||
_queued_transition = null
|
||||
_queued_transition_time = 0.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue