From bb564d639e64e8999deeeab3f72e5a473b452d10 Mon Sep 17 00:00:00 2001 From: Dusk Date: Thu, 5 Mar 2026 18:11:49 +0100 Subject: [PATCH] refactor: Stop player & level activity by variable --- level.gd | 4 +++- player.gd | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/level.gd b/level.gd index 8af54a8..74bfe41 100644 --- a/level.gd +++ b/level.gd @@ -125,6 +125,9 @@ func initialize_world() -> void: func _process(delta: float) -> void: + if not $Player.is_active: + return + var spawn_radius = $Player/SpawnArea/Collision.shape.radius + randf_range(-5, 5) var rand_unit_vec = Vector3.RIGHT.rotated(Vector3.UP, randf() * TAU) var ped_pos = $Player.position + rand_unit_vec * spawn_radius @@ -138,7 +141,6 @@ func _process(delta: float) -> void: add_child(new_ped) new_ped.position = ped_pos - func _on_player_station_reached(): for n in $ChunkContainer.get_children(): $ChunkContainer.remove_child(n) diff --git a/player.gd b/player.gd index b19bdbf..f3d4133 100644 --- a/player.gd +++ b/player.gd @@ -16,17 +16,20 @@ var stamina: float = max_stamina var stage_counter: int = 0 +var is_active: bool = true + func _ready() -> void: $Upgrades.update() $FailControl.visible = false $FinishControl.visible = false + is_active = true $HUD.visible = true $TimeLimit.start() func _process(delta: float) -> void: # On fail screen, ignore further input - if $FailControl.visible or $FinishControl.visible: + if not is_active: return $HUD/StaminaRect.scale.x = stamina / max_stamina @@ -62,6 +65,7 @@ func _on_area_area_entered(area: Area3D) -> void: $FinishControl.visible = true $HUD.visible = false $TimeLimit.stop() + is_active = false func _on_area_area_exited(area: Area3D) -> void: @@ -71,6 +75,7 @@ func _on_area_area_exited(area: Area3D) -> void: func _on_time_limit_timeout(): + is_active = false $FailControl.visible = true $HUD.visible = false @@ -80,6 +85,7 @@ func _on_retry_button_pressed(): $FailControl.visible = false $HUD.visible = true station_reached.emit() + is_active = true $TimeLimit.start() stamina = max_stamina