Add muzak, muffled screams, virtua hand

This commit is contained in:
Jennie Robinson Faber 2026-05-16 16:15:50 +01:00
parent acb10d18a4
commit 54067d2087
15 changed files with 198 additions and 29 deletions

View file

@ -5,8 +5,14 @@ const DOOR_CLOSED_X := 0.7
const DOOR_DEFAULT_TIME := 3.0
const DOOR_FAST_CLOSE_TIME := 1.0
const DOOR_REOPEN_TIME := 0.4
const PULSE_CLOSE_LAG_TOP := 1.0
const PULSE_CLOSE_LAG_PER_FLOOR := 0.09
const PULSE_CLOSE_LAG_MIN := 0.2
const DOORS_NEARLY_OPEN_LEAD := 0.4
var _tween: Tween = null
var _pulse_close_pending: bool = false
var _current_floor: int = EventBus.STARTING_FLOOR
func _ready():
$ElevatorDoorRight.position = Vector3(DOOR_CLOSED_X, 0, 0)
@ -16,21 +22,39 @@ func _ready():
EventBus.doors_closed.connect(_on_doors_closed)
EventBus.pulse_started.connect(_on_pulse_started)
EventBus.pulse_blocked.connect(_on_pulse_blocked)
EventBus.floor_changed.connect(func(f): _current_floor = f)
func _on_doors_opened():
_pulse_close_pending = false
_set_door_collision(false)
_tween_doors(DOOR_OPEN_X, DOOR_DEFAULT_TIME)
_tween.chain().tween_callback(func(): EventBus.doors_fully_opened.emit())
get_tree().create_timer(DOOR_DEFAULT_TIME - DOORS_NEARLY_OPEN_LEAD, false).timeout.connect(
func(): EventBus.doors_nearly_opened.emit(),
CONNECT_ONE_SHOT
)
func _on_doors_closed(fast: bool):
_pulse_close_pending = false
_set_door_collision(true)
_tween_doors(DOOR_CLOSED_X, DOOR_FAST_CLOSE_TIME if fast else DOOR_DEFAULT_TIME)
_tween.chain().tween_callback(func(): EventBus.doors_fully_closed.emit())
func _on_pulse_started(duration: float):
_set_door_collision(true)
_tween_doors(DOOR_CLOSED_X, duration)
_pulse_close_pending = true
var floors_descended = EventBus.STARTING_FLOOR - _current_floor
var lag = max(PULSE_CLOSE_LAG_MIN, PULSE_CLOSE_LAG_TOP - floors_descended * PULSE_CLOSE_LAG_PER_FLOOR)
get_tree().create_timer(lag, false).timeout.connect(
func():
if _pulse_close_pending:
_pulse_close_pending = false
_tween_doors(DOOR_CLOSED_X, duration),
CONNECT_ONE_SHOT
)
func _on_pulse_blocked():
_pulse_close_pending = false
_set_door_collision(false)
_tween_doors(DOOR_OPEN_X, DOOR_REOPEN_TIME)