|
|
|
|
@ -8,17 +8,20 @@ var states = ['idle'] |
|
|
|
|
var current_state = null |
|
|
|
|
var previous_state = null |
|
|
|
|
var next_state = null |
|
|
|
|
var state_duration = 0 |
|
|
|
|
|
|
|
|
|
func set_states(new_states): |
|
|
|
|
self.states = new_states |
|
|
|
|
|
|
|
|
|
func _ready(): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
func _physics_process(delta): |
|
|
|
|
if current_state == null: |
|
|
|
|
next_state = states[0] |
|
|
|
|
_transition() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
_transition() |
|
|
|
|
|
|
|
|
|
func _physics_process(delta): |
|
|
|
|
if "before_state" in root: |
|
|
|
|
root.call("before_state", delta) |
|
|
|
|
|
|
|
|
|
@ -43,6 +46,7 @@ func _transition(): |
|
|
|
|
if on_exit_state_method in root: |
|
|
|
|
root.call(on_exit_state_method) |
|
|
|
|
|
|
|
|
|
state_duration = 0 |
|
|
|
|
var on_enter_state_method = "on_enter_" + current_state + "_state" |
|
|
|
|
if on_enter_state_method in root: |
|
|
|
|
root.call(on_enter_state_method) |
|
|
|
|
|