31 lines
817 B
GDScript
31 lines
817 B
GDScript
extends Node3D
|
|
|
|
signal level_lost
|
|
|
|
## The tether whose parting ends the run.
|
|
@export var tether_path : NodePath = ^"Path3DRope"
|
|
|
|
## Beat between the rope parting and the lost screen, in seconds, so the break
|
|
## is actually seen instead of being covered by the menu on the same frame.
|
|
@export var lose_delay := 0.5
|
|
|
|
var _lost := false
|
|
|
|
|
|
func _ready() -> void:
|
|
var tether := get_node_or_null(tether_path)
|
|
if tether != null and tether.has_signal(&"snapped"):
|
|
tether.snapped.connect(_on_tether_snapped)
|
|
|
|
|
|
func _on_tether_snapped(_at_position : Vector3) -> void:
|
|
if _lost:
|
|
return
|
|
_lost = true
|
|
if lose_delay > 0.0:
|
|
await get_tree().create_timer(lose_delay).timeout
|
|
for player in get_tree().get_nodes_in_group(&"players"):
|
|
if player is Player:
|
|
(player as Player).controls_enabled = false
|
|
level_lost.emit()
|