make hatch mildly more stable

This commit is contained in:
Haze Weathers 2023-03-22 02:07:43 -04:00
parent 0a5c111615
commit d012e9f5ac

View file

@ -30,6 +30,7 @@ onready var map = get_owner()
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT,HATCH} enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT,HATCH}
var current_state = State.IDLE var current_state = State.IDLE
var can_die = true var can_die = true
var dead = false
##Runtime ##Runtime
var axis = Vector2.ZERO #Current direction being held var axis = Vector2.ZERO #Current direction being held
var trail_color = Color(0.25,0,1,0.4) var trail_color = Color(0.25,0,1,0.4)
@ -312,6 +313,8 @@ func exit_transport():
current_state = State.FALL current_state = State.FALL
func enter_hatch(snap_position): func enter_hatch(snap_position):
if dead:
return
position = snap_position position = snap_position
current_state = State.INACTIVE current_state = State.INACTIVE
hitbox.disabled = true hitbox.disabled = true
@ -319,11 +322,12 @@ func enter_hatch(snap_position):
anims.play("enter hatch", -1, 1.25) anims.play("enter hatch", -1, 1.25)
func die(): func die():
#If the player is already dead, don't kill them again
if current_state == State.INACTIVE or current_state == State.HATCH:
return
if can_die: if can_die:
dead = true
Audio.ac_climb.set_stream(null) # stop climbing sound\ Audio.ac_climb.set_stream(null) # stop climbing sound\
#If the player is already dead, don't kill them again
if current_state == State.INACTIVE:
return
#Create particles #Create particles
var new_particles = death_particles.duplicate() var new_particles = death_particles.duplicate()
get_parent().add_child(new_particles) get_parent().add_child(new_particles)
@ -363,6 +367,7 @@ func die():
#Respawn player #Respawn player
current_state = State.IDLE current_state = State.IDLE
sprite.visible = true sprite.visible = true
dead = false
func _on_AnimationPlayer_animation_finished(anim_name): func _on_AnimationPlayer_animation_finished(anim_name):
#Set hatch state #Set hatch state
@ -375,6 +380,7 @@ func _on_AnimationPlayer_animation_finished(anim_name):
current_state = State.IDLE current_state = State.IDLE
hitbox.disabled = false hitbox.disabled = false
collision_layer = 2 collision_layer = 2
return
if current_state == State.INACTIVE: if current_state == State.INACTIVE:
return return
#Return to idle after slash #Return to idle after slash