fix: dead player ragdoll no longer triggers leaving the combat area

This commit is contained in:
DottsGit
2026-06-06 13:09:01 -04:00
parent 2aa7ff0337
commit 45353dc982
+14 -1
View File
@@ -18,6 +18,12 @@ func _ready() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
if _player_out_of_bounds: if _player_out_of_bounds:
# If the player dies while out of bounds, stop the timer and remove the UI
if "is_dead" in _player_out_of_bounds and _player_out_of_bounds.is_dead:
_player_out_of_bounds = null
_remove_ui()
return
# Player is outside the combat area! # Player is outside the combat area!
time_left -= delta time_left -= delta
if time_left <= 0.0: if time_left <= 0.0:
@@ -39,6 +45,12 @@ func _process(delta: float) -> void:
func _on_body_exited(body: Node3D) -> void: func _on_body_exited(body: Node3D) -> void:
if body.name == "Player": if body.name == "Player":
# Don't trigger if the player is already dead or the scene is tearing down
if "is_dead" in body and body.is_dead:
return
if body.is_queued_for_deletion() or not is_inside_tree():
return
_player_out_of_bounds = body _player_out_of_bounds = body
time_safe = 0.0 # Reset recovery timer time_safe = 0.0 # Reset recovery timer
_create_ui() _create_ui()
@@ -74,7 +86,8 @@ func _create_ui() -> void:
_ui_layer.add_child(_ui_label) _ui_layer.add_child(_ui_label)
get_tree().current_scene.add_child(_ui_layer) if get_tree().current_scene:
get_tree().current_scene.call_deferred("add_child", _ui_layer)
func _remove_ui() -> void: func _remove_ui() -> void:
if _ui_layer: if _ui_layer: