more state chart updatres :/
This commit is contained in:
parent
02b85c7dd2
commit
32131e7e17
3 changed files with 22 additions and 9 deletions
|
@ -84,7 +84,7 @@ func _process(delta: float) -> void:
|
|||
return
|
||||
|
||||
# emit processing signal
|
||||
emit_signal("state_processing")
|
||||
emit_signal("state_processing", delta)
|
||||
|
||||
# process transitions if mode is IDLE
|
||||
if transition_process_mode == ProcessMode.IDLE:
|
||||
|
@ -95,7 +95,7 @@ func _physics_process(delta: float) -> void:
|
|||
return
|
||||
|
||||
# emit physics processing signal
|
||||
emit_signal("state_processing")
|
||||
emit_signal("state_physics_processing", delta)
|
||||
|
||||
# process transitions if mode is PHYSICS
|
||||
if transition_process_mode == ProcessMode.PHYSICS:
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -56,7 +56,7 @@ func evaluate_guard() -> bool:
|
|||
return false
|
||||
|
||||
# combine monitored states with expression properties
|
||||
var properties: Dictionary = root._expression_properties.duplicate()
|
||||
var properties: Dictionary = root._guard_properties.duplicate()
|
||||
for node in checked_states:
|
||||
var state = get_node_or_null(node)
|
||||
if is_instance_valid(state) and state is _State:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue