33 lines
1.0 KiB
GDScript
33 lines
1.0 KiB
GDScript
class_name StateMachineAnimatedActor extends StateMachine
|
|
|
|
## I'm not sure I need a subtype anymore
|
|
func _ready():
|
|
print ("ready animactor state machine.")
|
|
for s in states:
|
|
print ("sname: ", s.name)
|
|
var this_state = s
|
|
if this_state is StateAnimatedActor:
|
|
print("Adding state ", this_state.name)
|
|
#check for empty state name
|
|
if this_state.name != '':
|
|
#check for unique state name
|
|
if !(states_index.has(this_state.name)):
|
|
# call setup
|
|
this_state.setup()
|
|
if debug_state_machine:
|
|
print("Initializing State Node: ", s)
|
|
this_state.debug_state = true
|
|
if this_state.state_timeout != null:
|
|
add_child(this_state.state_timeout)
|
|
# Add to state index
|
|
states_index[this_state.name] = this_state
|
|
else:
|
|
push_error("Multiple states with same name in: ")
|
|
else:
|
|
print("State missing name in: " )
|
|
|
|
if states_index.has(starting_state_name):
|
|
change_state(states_index[starting_state_name])
|
|
else:
|
|
push_error("State machine cannot find starting state: " + starting_state_name)
|