Attack state is better. Hopefully no more crashes with new single modifier system.

This commit is contained in:
Nitsud Yarg 2024-06-29 08:27:04 -07:00
parent b51d69a8f9
commit bc5c67ca82
4 changed files with 22 additions and 7 deletions

View File

@ -593,6 +593,7 @@ attack_node = NodePath("../attack")
[node name="jump" type="Node" parent="movement_state_machine" index="3"]
script = ExtResource( 8 )
debug_state = true
move_speed = 90.0
animation_sequence = [ "jump" ]
idle_node = NodePath("../idle")
@ -602,7 +603,6 @@ 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")

View File

@ -67,6 +67,8 @@ func enter() -> void:
"jump":
animations.play("jump_shoot")
animations.frame = previous_state_frame_number
if debug_state:
print("Starting Animation: jump_shoot at frame ", animations.animation , animations.frame)
_:
print("Warning!: Attack state encountered unhandled prev animation: ", previous_animation_name)
@ -80,6 +82,7 @@ func enter() -> void:
#mod_timer.connect("timeout", self, "_on_Timer_timeout")
state_timeout.start()
draw_weapon_modifier.state_timeout.start()
state_ready = false
animation_finished = false
@ -106,14 +109,16 @@ func process_physics(delta: float) -> State:
can_fire = false
if move_component.wants_jump() and parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
jump_state.modifier = draw_weapon_modifier
return jump_state
move_actor_as_desired(delta)
if previous_state_name == "move" and move_component.velocity.x == 0.0:
return idle_state
# if previous_state_name == "move" and move_component.velocity.x == 0.0:
# return idle_state
if previous_state_name == "idle" and move_component.velocity.x != 0.0:
if move_component.velocity.x != 0.0:
draw_weapon_modifier.state_timeout.start()
move_state.modifier = draw_weapon_modifier
#draw_weapon_modifier.transfer_owner(move_state)
@ -126,6 +131,8 @@ func process_physics(delta: float) -> State:
# return move_state
if !parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
fall_state.modifier = draw_weapon_modifier
return fall_state

View File

@ -6,7 +6,14 @@ onready var idle_state: State = get_node(idle_node)
var flash_color = Color.yellow
var store_modifier: StateModifier
func enter() -> void:
if modifier:
if debug_state:
print(name, " skipping modifier and holding for next state.")
store_modifier = modifier
modifier = null
# modifier_stack_ref.clear()
.enter()
move_component.velocity.x = 0
@ -15,6 +22,7 @@ func enter() -> void:
state_timeout.start()
func exit() -> void:
modifier = store_modifier
.exit()
animations.modulate = Color.white

View File

@ -108,12 +108,12 @@ func _on_AnimatedSprite_animation_finished():
# 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)
#print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index)
if current_state.animation_sequence.size() > 0:
print("<-- next anim.")
#print("<-- next anim.")
current_state.animation_index += 1
if current_state.animation_index >= current_state.animation_sequence.size():
print("Stop!!!!!")
#print("Stop!!!!!")
current_state.animation_finished = true