State animations, Finally coming together.

This commit is contained in:
Nitsud Yarg 2024-06-29 00:51:02 -07:00
parent aef17c3d81
commit b51d69a8f9
6 changed files with 203 additions and 148 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

View File

@ -169,179 +169,179 @@ region = Rect2( 1200, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=128]
atlas = SubResource( 90 )
region = Rect2( 2400, 0, 240, 160 )
region = Rect2( 240, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=129]
atlas = SubResource( 90 )
region = Rect2( 0, 160, 240, 160 )
region = Rect2( 1680, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=130]
atlas = SubResource( 90 )
region = Rect2( 240, 160, 240, 160 )
region = Rect2( 1920, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=131]
atlas = SubResource( 90 )
region = Rect2( 1680, 160, 240, 160 )
region = Rect2( 2160, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=132]
atlas = SubResource( 90 )
region = Rect2( 1920, 160, 240, 160 )
region = Rect2( 2400, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=133]
atlas = SubResource( 90 )
region = Rect2( 2160, 160, 240, 160 )
region = Rect2( 0, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=134]
atlas = SubResource( 90 )
region = Rect2( 2400, 160, 240, 160 )
region = Rect2( 240, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=135]
atlas = SubResource( 90 )
region = Rect2( 0, 320, 240, 160 )
region = Rect2( 480, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=136]
atlas = SubResource( 90 )
region = Rect2( 240, 320, 240, 160 )
region = Rect2( 720, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=137]
atlas = SubResource( 90 )
region = Rect2( 480, 320, 240, 160 )
region = Rect2( 960, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=138]
atlas = SubResource( 90 )
region = Rect2( 960, 320, 240, 160 )
region = Rect2( 1200, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=139]
atlas = SubResource( 90 )
region = Rect2( 1200, 320, 240, 160 )
region = Rect2( 1680, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=140]
atlas = SubResource( 90 )
region = Rect2( 1440, 320, 240, 160 )
region = Rect2( 1920, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=141]
atlas = SubResource( 90 )
region = Rect2( 1680, 640, 240, 160 )
region = Rect2( 2160, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=142]
atlas = SubResource( 90 )
region = Rect2( 1920, 640, 240, 160 )
region = Rect2( 2400, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=143]
atlas = SubResource( 90 )
region = Rect2( 2160, 640, 240, 160 )
region = Rect2( 0, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=144]
atlas = SubResource( 90 )
region = Rect2( 2400, 640, 240, 160 )
region = Rect2( 240, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=145]
atlas = SubResource( 90 )
region = Rect2( 0, 800, 240, 160 )
region = Rect2( 480, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=146]
atlas = SubResource( 90 )
region = Rect2( 240, 800, 240, 160 )
region = Rect2( 720, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=147]
atlas = SubResource( 90 )
region = Rect2( 480, 800, 240, 160 )
region = Rect2( 960, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=148]
atlas = SubResource( 90 )
region = Rect2( 720, 800, 240, 160 )
region = Rect2( 1200, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=149]
atlas = SubResource( 90 )
region = Rect2( 960, 800, 240, 160 )
region = Rect2( 1440, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=150]
atlas = SubResource( 90 )
region = Rect2( 1200, 800, 240, 160 )
region = Rect2( 1920, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=151]
atlas = SubResource( 90 )
region = Rect2( 1440, 800, 240, 160 )
region = Rect2( 2160, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=152]
atlas = SubResource( 90 )
region = Rect2( 1920, 320, 240, 160 )
region = Rect2( 2400, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=153]
atlas = SubResource( 90 )
region = Rect2( 2160, 320, 240, 160 )
region = Rect2( 0, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=154]
atlas = SubResource( 90 )
region = Rect2( 2400, 320, 240, 160 )
region = Rect2( 240, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=155]
atlas = SubResource( 90 )
region = Rect2( 0, 480, 240, 160 )
region = Rect2( 480, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=156]
atlas = SubResource( 90 )
region = Rect2( 240, 480, 240, 160 )
region = Rect2( 720, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=157]
atlas = SubResource( 90 )
region = Rect2( 480, 480, 240, 160 )
region = Rect2( 960, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=158]
atlas = SubResource( 90 )
region = Rect2( 720, 480, 240, 160 )
region = Rect2( 1200, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=159]
atlas = SubResource( 90 )
region = Rect2( 960, 480, 240, 160 )
region = Rect2( 1440, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=160]
atlas = SubResource( 90 )
region = Rect2( 1200, 480, 240, 160 )
region = Rect2( 1920, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=161]
atlas = SubResource( 90 )
region = Rect2( 1440, 480, 240, 160 )
region = Rect2( 2160, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=162]
atlas = SubResource( 90 )
region = Rect2( 1920, 480, 240, 160 )
region = Rect2( 2400, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=163]
atlas = SubResource( 90 )
region = Rect2( 2160, 480, 240, 160 )
region = Rect2( 0, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=164]
atlas = SubResource( 90 )
region = Rect2( 2400, 480, 240, 160 )
region = Rect2( 240, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=165]
atlas = SubResource( 90 )
region = Rect2( 0, 640, 240, 160 )
region = Rect2( 480, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=166]
atlas = SubResource( 90 )
region = Rect2( 240, 640, 240, 160 )
region = Rect2( 720, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=167]
atlas = SubResource( 90 )
region = Rect2( 480, 640, 240, 160 )
region = Rect2( 960, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=168]
atlas = SubResource( 90 )
region = Rect2( 720, 640, 240, 160 )
region = Rect2( 1200, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=169]
atlas = SubResource( 90 )
region = Rect2( 960, 640, 240, 160 )
region = Rect2( 1440, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=170]
atlas = SubResource( 90 )
region = Rect2( 1200, 640, 240, 160 )
region = Rect2( 2400, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=171]
atlas = SubResource( 90 )
region = Rect2( 1440, 640, 240, 160 )
region = Rect2( 0, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=172]
atlas = SubResource( 90 )
@ -479,36 +479,41 @@ animations = [ {
"name": "idle_shield",
"speed": 10.0
}, {
"frames": [ SubResource( 128 ), SubResource( 129 ), SubResource( 130 ) ],
"frames": [ SubResource( 128 ) ],
"loop": false,
"name": "idle_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 131 ), SubResource( 132 ), SubResource( 133 ), SubResource( 134 ), SubResource( 132 ), SubResource( 135 ), SubResource( 136 ), SubResource( 137 ) ],
"frames": [ SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ), SubResource( 130 ), SubResource( 133 ), SubResource( 134 ), SubResource( 135 ) ],
"loop": false,
"name": "jump",
"speed": 10.0
}, {
"frames": [ SubResource( 138 ), SubResource( 138 ), SubResource( 138 ), SubResource( 138 ), SubResource( 138 ), SubResource( 138 ), SubResource( 139 ), SubResource( 140 ) ],
"frames": [ SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 137 ), SubResource( 138 ) ],
"loop": false,
"name": "jump_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ), SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 151 ) ],
"frames": [ SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ), SubResource( 148 ), SubResource( 149 ) ],
"loop": false,
"name": "roll",
"speed": 10.0
}, {
"frames": [ SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ), SubResource( 158 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ) ],
"frames": [ SubResource( 150 ), SubResource( 151 ), SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ), SubResource( 158 ), SubResource( 159 ) ],
"loop": true,
"name": "run",
"speed": 10.0
}, {
"frames": [ SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ), SubResource( 168 ), SubResource( 169 ), SubResource( 170 ), SubResource( 171 ) ],
"frames": [ SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ), SubResource( 168 ), SubResource( 169 ) ],
"loop": true,
"name": "run_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 170 ), SubResource( 171 ), SubResource( 128 ) ],
"loop": false,
"name": "shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 172 ), SubResource( 173 ), SubResource( 174 ), SubResource( 174 ), SubResource( 175 ), SubResource( 176 ), SubResource( 177 ), SubResource( 178 ), SubResource( 178 ), SubResource( 179 ), SubResource( 180 ), SubResource( 181 ), SubResource( 182 ), SubResource( 183 ), SubResource( 184 ), SubResource( 185 ), SubResource( 186 ), SubResource( 187 ), SubResource( 188 ), SubResource( 189 ), SubResource( 190 ), SubResource( 191 ) ],
"loop": true,
"name": "slash",
@ -542,7 +547,7 @@ player_number = 1
position = Vector2( -1, -51 )
frames = SubResource( 198 )
animation = "idle_shoot"
frame = 2
frame = 0
flip_h = false
__meta__ = {
"_aseprite_wizard_config_": {
@ -562,12 +567,8 @@ script = ExtResource( 2 )
player_number = 1
interactable_node = NodePath("../Interactable_Receiver")
[node name="movement_state_machine" parent="." index="3"]
debug_state_machine = true
[node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 4 )
debug_state = true
move_speed = 1.0
animation_sequence = [ "idle" ]
jump_node = NodePath("../jump")
@ -601,6 +602,9 @@ jump_force = 250.0
[node name="attack" type="Node" parent="movement_state_machine" index="4"]
script = ExtResource( 10 )
debug_state = true
timeout_seconds = 1.5
animation_sequence = [ "shoot" ]
jump_node = NodePath("../jump")
idle_node = NodePath("../idle")
fall_node = NodePath("../fall")

View File

@ -18,24 +18,36 @@ signal do_attack()
var draw_weapon_modifier: StateModifier
func _ready():
state_timeout.connect("timeout", self, "disable_cooldown")
func disable_cooldown():
print("It's butt kicking time!")
state_ready = true
func enter() -> void:
#.enter()
if modifier:
if modifier.get_instance_id() == draw_weapon_modifier.get_instance_id():
print ("They the same cannot apply modifier: ", draw_weapon_modifier.get_instance_id())
modifier = null
.enter()
##TODO: Turn this to clear only the animation modifiers.
# modifier_stack_ref.clear()
mod_animation_sequence.clear()
#mod_animation_sequence = animation_sequence.duplicate(true)
mod_animation_sequence.append_array(animation_sequence)
# Reset animation suffix in case there isn't one
animation_suffix = '_shoot'
animation_index = 0
current_animation_sequence = 0
#var enter_animation = ''
var enter_frame = 0
if debug_state:
print(parent.name, " entering State: ", self.name)
move_component.current_movement_state = self.name
emit_signal("state_entered")
# mod_animation_sequence.clear()
# #mod_animation_sequence = animation_sequence.duplicate(true)
# mod_animation_sequence.append_array(animation_sequence)
# # Reset animation suffix in case there isn't one
# animation_suffix = '_shoot'
# animation_index = 0
# current_animation_sequence = 0
# #var enter_animation = ''
# var enter_frame = 0
#
# if debug_state:
# print(parent.name, " entering State: ", self.name)
# move_component.current_movement_state = self.name
# emit_signal("state_entered")
can_fire = true
# if modifier_stack_ref.has($"../draw_weapon") == false:
@ -46,7 +58,9 @@ func enter() -> void:
previous_state_frame_number, " ", previous_state_name)
match previous_animation_name:
"idle":
animations.play("idle_shoot")
#animations.play("idle_shoot")
if debug_state:
print("no need to change idle animation")
"run":
animations.play("run_shoot")
animations.frame = previous_state_frame_number
@ -65,6 +79,8 @@ func enter() -> void:
# An example where the current node subscribes
#mod_timer.connect("timeout", self, "_on_Timer_timeout")
state_timeout.start()
state_ready = false
animation_finished = false
func _on_Timer_timeout():
@ -73,11 +89,9 @@ func _on_Timer_timeout():
func process_frame(delta: float) -> State:
if animation_finished:
print("WTF!?!! Finish already!")
draw_weapon_modifier.state_timeout.start()
modifier = draw_weapon_modifier
return idle_state
.process_frame(delta)
# if animations.frame == 2:
# animations.stop()
# if state_timeout.time_left == 0 and animations.animation == "shoot":
@ -117,11 +131,3 @@ func process_physics(delta: float) -> State:
return null
func exit() -> void:
# force timer reset
# weapon_state_modifier.state_timeout.start()
# push_animation_state_modifier(weapon_state_modifier)
#$"../draw_weapon".state_timeout.start()
return

View File

@ -10,6 +10,7 @@ signal state_exited()
# Declare member variables here. Examples:
#var modifier_stack_ref: Array # Well this didn't work
var state_timeout: Timer
var state_ready: bool = true
# Called when the node enters the scene tree for the first time.
func _ready():

View File

@ -31,7 +31,6 @@ var frame_signal_emitted: bool = false
var animation_finished: bool = false
var transition_state: StateAnimatedActor
# this just wouldn't work well. Maybe I can try a resource
# export(Array, NodePath) var transition_state_nodes
@ -123,6 +122,24 @@ func update_animation(enter_frame := 0, index := 0, suffix := ''):
mod_animation_sequence.push_back(modifier.animation_name)
enter_frame = modifier.starting_frame
# Some safety checks with supplied update parameters
if animation_index != 0:
if mod_animation_sequence.size() < animation_index + 1:
if debug_state:
print("Warning!: attempting to set to non-existant index ")
animation_index = 0
current_animation_sequence = animation_index
if animations.frames.has_animation(mod_animation_sequence[animation_index] + animation_suffix) == false:
if debug_state:
print("Warning!: Animation doesn't exist! ")
if enter_frame != 0:
if animations.frames.get_frame_count(animations.animation) != animations.frames.get_frame_count(mod_animation_sequence[animation_index] + animation_suffix):
if debug_state:
print("Warning!: attempting to set a mismatched frame ")
enter_frame = 0
if mod_animation_sequence.size() > 0:
if debug_state:
print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
@ -135,55 +152,57 @@ func update_animation(enter_frame := 0, index := 0, suffix := ''):
func enter() -> void:
mod_animation_sequence.clear()
#mod_animation_sequence = animation_sequence.duplicate(true)
mod_animation_sequence.append_array(animation_sequence)
# Reset animation suffix in case there isn't one
animation_suffix = ''
animation_index = 0
current_animation_sequence = 0
#var enter_animation = ''
var enter_frame = 0
# mod_animation_sequence.clear()
# #mod_animation_sequence = animation_sequence.duplicate(true)
# mod_animation_sequence.append_array(animation_sequence)
# # Reset animation suffix in case there isn't one
# animation_suffix = ''
# animation_index = 0
# current_animation_sequence = 0
# #var enter_animation = ''
# var enter_frame = 0
if debug_state:
print(parent.name, " entering State: ", self.name)
move_component.current_movement_state = self.name
emit_signal("state_entered")
#modifier_stack_ref = state_modifiers
update_animation()
if modifier != null:
# if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
# #print("OHHH Modifier Applies! ", modifier.animation_name)
# mod_animation_sequence.push_front(modifier.animation_name)
# enter_frame = modifier.starting_frame
match modifier.modifier_type:
modifier.TYPE.EXIT_ANIMATION:
mod_animation_sequence.push_front(modifier.animation_name)
enter_frame = modifier.starting_frame
modifier.TYPE.ANIMATION_SUFFIX:
if animations.frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
animation_suffix = modifier.animation_name
else:
print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
mod_animation_sequence[animation_index] + modifier.animation_name)
modifier.TYPE.REPLACE_ANIMATION:
#animations.play(modifier_stack_ref[i].animation_name)
#animations.frame = modifier_stack_ref[i].starting_frame
mod_animation_sequence.clear()
mod_animation_sequence.push_back(modifier.animation_name)
enter_frame = modifier.starting_frame
if mod_animation_sequence.size() > 0:
if debug_state:
print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
animations.play(mod_animation_sequence[animation_index] + animation_suffix)
#TODO: maybe check current animatio has this frame
animations.frame = enter_frame
else:
print("Error! Resolved to empty animation sequence!?")
return
# if modifier != null:
## if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
## #print("OHHH Modifier Applies! ", modifier.animation_name)
## mod_animation_sequence.push_front(modifier.animation_name)
## enter_frame = modifier.starting_frame
# match modifier.modifier_type:
# modifier.TYPE.EXIT_ANIMATION:
# mod_animation_sequence.push_front(modifier.animation_name)
# enter_frame = modifier.starting_frame
#
# modifier.TYPE.ANIMATION_SUFFIX:
# if animations.frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
# animation_suffix = modifier.animation_name
# else:
# print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
# mod_animation_sequence[animation_index] + modifier.animation_name)
#
# modifier.TYPE.REPLACE_ANIMATION:
# #animations.play(modifier_stack_ref[i].animation_name)
# #animations.frame = modifier_stack_ref[i].starting_frame
# mod_animation_sequence.clear()
# mod_animation_sequence.push_back(modifier.animation_name)
# enter_frame = modifier.starting_frame
#
# if mod_animation_sequence.size() > 0:
# if debug_state:
# print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix ,
# " frame count ", animations.frames.get_frame_count(mod_animation_sequence[animation_index] + animation_suffix))
# animations.play(mod_animation_sequence[animation_index] + animation_suffix)
# #TODO: maybe check current animatio has this frame
# animations.frame = enter_frame
# else:
# print("Error! Resolved to empty animation sequence!?")
# return
# A new attempt at animation modifiers
@ -237,14 +256,14 @@ func enter() -> void:
# animations.frame = modifier_stack_ref[-1].starting_frame
# return
if mod_animation_sequence.size() > 0:
if debug_state:
print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
animations.play(mod_animation_sequence[animation_index] + animation_suffix)
#TODO: maybe check current animatio has this frame
animations.frame = enter_frame
else:
print("Error! Resolved to empty animation sequence!?")
# if mod_animation_sequence.size() > 0:
# if debug_state:
# print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
# animations.play(mod_animation_sequence[animation_index] + animation_suffix)
# #TODO: maybe check current animatio has this frame
# animations.frame = enter_frame
# else:
# print("Error! Resolved to empty animation sequence!?")
return
func exit() -> void:
@ -267,17 +286,38 @@ func transfer_modifiers(exiting_state_modifier : StateModifier):
func process_input(_event: InputEvent) -> State:
return null
func process_frame(_delta: float) -> State:
func process_animations():
if modifier != null:
if modifier.state_timeout and modifier.state_timeout.time_left == 0:
print("Expired Modifier, updating animation.")
modifier = null
update_animation()
#modifier = null
match modifier.modifier_type:
modifier.TYPE.ANIMATION_SUFFIX:
# Attempt to seemlessly transition animations.
modifier = null
update_animation(animations.frame,animation_index)
modifier.TYPE.REPLACE_ANIMATION:
if debug_state:
print("I don't have anything for replacements yet.")
modifier = null
update_animation()
_:
modifier = null
return
#if animation_sequence.size() > 0 and current_animation_sequence != animation_index:
if mod_animation_sequence.size() > animation_index and current_animation_sequence != animation_index:
# We have no more sequence animations and the current one doesn't loop
# we do this to prevent the default idle animation from playing.
##TODO: between this and the signal based iterator I get some really strange behavior
if animation_index >= mod_animation_sequence.size() and animations.frames.get_animation_loop(
animations.animation) == false:
#print(animations.animation, " Animation Stopped")
animations.stop()
#animation_finished = true
elif mod_animation_sequence.size() > animation_index and current_animation_sequence != animation_index:
#TODO: why was I doing this
# if animation_index >= mod_animation_sequence.size():
# animation_index = 0
@ -288,12 +328,7 @@ func process_frame(_delta: float) -> State:
animations.animation , " (", animation_index, ")")
current_animation_sequence = animation_index
# We have no more sequence animations and the current one doesn't loop
# we do this to prevent the default idle animation from playing.
if animation_index >= mod_animation_sequence.size() and animations.frames.get_animation_loop(
animations.animation) == false:
animations.stop()
animation_finished = true
##TODO: Could probably add some more checks here.
# Singal based frame call.
if emitter_frame_subscriptions.has(animations.frame):
@ -305,6 +340,7 @@ func process_frame(_delta: float) -> State:
else:
frame_signal_emitted = false
func process_frame(_delta: float) -> State:
return null
func process_physics(_delta: float) -> State:

View File

@ -1,6 +1,9 @@
class_name StateMachineAnimatedActor extends StateMachine
func change_state(new_state: State) -> void:
if new_state.state_ready == false:
# Don't transition to unready state
return
if current_state:
current_state.exit()
# Set parameters for information
@ -79,15 +82,16 @@ func process_frame(delta: float) -> void:
# if debug_state_machine:
# print("Pop State Modifier: ", state_modifiers[i].name)
# state_modifiers.pop_at(i)
if current_state is StateAnimatedActor:
current_state.process_animations()
var new_state = current_state.process_frame(delta)
if new_state:
change_state(new_state)
func _on_AnimatedSprite_animation_finished():
if debug_state_machine:
print("Stop!!!!!")
# if debug_state_machine:
# print("Stop!!!!!")
##TODO:
# It's hard to pop an exit animation off when it's stacked with another kind of animation.
# for i in state_modifiers.size():
@ -100,13 +104,17 @@ func _on_AnimatedSprite_animation_finished():
# current_state.animation_index += 1
# break
if current_state is StateAnimatedActor:
current_state.animation_finished = true
# if current_state is StateAnimatedActor:
# current_state.animation_finished = true
if current_state.animations.frames.get_animation_loop(
current_state.animations.animation) == false:
print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index)
if current_state.animation_sequence.size() > 0:
print("<-- next anim.")
current_state.animation_index += 1
if current_state.animation_index >= current_state.animation_sequence.size():
print("Stop!!!!!")
current_state.animation_finished = true