refactor: Stop player & level activity by variable

This commit is contained in:
Dusk 2026-03-05 18:11:49 +01:00
parent 669447d58e
commit bb564d639e
2 changed files with 10 additions and 2 deletions

View File

@ -125,6 +125,9 @@ func initialize_world() -> void:
func _process(delta: float) -> 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 spawn_radius = $Player/SpawnArea/Collision.shape.radius + randf_range(-5, 5)
var rand_unit_vec = Vector3.RIGHT.rotated(Vector3.UP, randf() * TAU) var rand_unit_vec = Vector3.RIGHT.rotated(Vector3.UP, randf() * TAU)
var ped_pos = $Player.position + rand_unit_vec * spawn_radius var ped_pos = $Player.position + rand_unit_vec * spawn_radius
@ -138,7 +141,6 @@ func _process(delta: float) -> void:
add_child(new_ped) add_child(new_ped)
new_ped.position = ped_pos new_ped.position = ped_pos
func _on_player_station_reached(): func _on_player_station_reached():
for n in $ChunkContainer.get_children(): for n in $ChunkContainer.get_children():
$ChunkContainer.remove_child(n) $ChunkContainer.remove_child(n)

View File

@ -16,17 +16,20 @@ var stamina: float = max_stamina
var stage_counter: int = 0 var stage_counter: int = 0
var is_active: bool = true
func _ready() -> void: func _ready() -> void:
$Upgrades.update() $Upgrades.update()
$FailControl.visible = false $FailControl.visible = false
$FinishControl.visible = false $FinishControl.visible = false
is_active = true
$HUD.visible = true $HUD.visible = true
$TimeLimit.start() $TimeLimit.start()
func _process(delta: float) -> void: func _process(delta: float) -> void:
# On fail screen, ignore further input # On fail screen, ignore further input
if $FailControl.visible or $FinishControl.visible: if not is_active:
return return
$HUD/StaminaRect.scale.x = stamina / max_stamina $HUD/StaminaRect.scale.x = stamina / max_stamina
@ -62,6 +65,7 @@ func _on_area_area_entered(area: Area3D) -> void:
$FinishControl.visible = true $FinishControl.visible = true
$HUD.visible = false $HUD.visible = false
$TimeLimit.stop() $TimeLimit.stop()
is_active = false
func _on_area_area_exited(area: Area3D) -> void: 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(): func _on_time_limit_timeout():
is_active = false
$FailControl.visible = true $FailControl.visible = true
$HUD.visible = false $HUD.visible = false
@ -80,6 +85,7 @@ func _on_retry_button_pressed():
$FailControl.visible = false $FailControl.visible = false
$HUD.visible = true $HUD.visible = true
station_reached.emit() station_reached.emit()
is_active = true
$TimeLimit.start() $TimeLimit.start()
stamina = max_stamina stamina = max_stamina