forked from team-sg/hero-mark-2
more state chart updatres :/
This commit is contained in:
parent
02b85c7dd2
commit
32131e7e17
3 changed files with 22 additions and 9 deletions
|
@ -2,11 +2,15 @@ tool
|
|||
class_name StateChart, "state_chart.svg"
|
||||
extends Node
|
||||
|
||||
## whether chart should propagate processing events every frame
|
||||
export var idle_frame_event: bool = false
|
||||
export var physics_frame_event: bool = false
|
||||
|
||||
# root state of the state chart
|
||||
var _state: State = null
|
||||
|
||||
# values available to expression guards
|
||||
var _expression_properties: Dictionary = {}
|
||||
var _guard_properties: Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.editor_hint:
|
||||
|
@ -39,13 +43,22 @@ func send_event(event: String) -> void:
|
|||
_state._state_event(event)
|
||||
|
||||
## sets a property available to guard expressions in transitions
|
||||
func set_expression_property(property: String, value) -> void:
|
||||
_expression_properties[property] = value
|
||||
func set_guard_property(property: String, value) -> void:
|
||||
_guard_properties[property] = value
|
||||
|
||||
func _get_configuration_warning() -> String:
|
||||
if get_child_count() != 1:
|
||||
return "StateChart must have exactly one child"
|
||||
elif not get_child(0) is State:
|
||||
if not get_child(0) is State:
|
||||
return "StateChart's child must be a State"
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
# send frame events that transition can listen to if it should evaluate
|
||||
# its guard every frame
|
||||
func _process(delta: float) -> void:
|
||||
if idle_frame_event:
|
||||
send_event("idle_frame")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if physics_frame_event:
|
||||
send_event("physics_frame")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue