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:
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)

View File

@ -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