Tidy UP!
This commit is contained in:
parent
7ce2863cfd
commit
e216364ec1
12 changed files with 84 additions and 71 deletions
|
|
@ -11,23 +11,32 @@ var _tween: Tween = null
|
|||
func _ready():
|
||||
$ElevatorDoorRight.position = Vector3(DOOR_CLOSED_X, 0, 0)
|
||||
$ElevatorDoorLeft.position = Vector3(-DOOR_CLOSED_X, 0, 0)
|
||||
_set_door_collision(true)
|
||||
EventBus.doors_opened.connect(_on_doors_opened)
|
||||
EventBus.doors_closed.connect(_on_doors_closed)
|
||||
EventBus.pulse_started.connect(_on_pulse_started)
|
||||
EventBus.pulse_blocked.connect(_on_pulse_blocked)
|
||||
|
||||
func _on_doors_opened():
|
||||
_set_door_collision(false)
|
||||
_tween_doors(DOOR_OPEN_X, DOOR_DEFAULT_TIME)
|
||||
|
||||
func _on_doors_closed(fast: bool):
|
||||
_set_door_collision(true)
|
||||
_tween_doors(DOOR_CLOSED_X, DOOR_FAST_CLOSE_TIME if fast else DOOR_DEFAULT_TIME)
|
||||
|
||||
func _on_pulse_started(duration: float):
|
||||
_set_door_collision(true)
|
||||
_tween_doors(DOOR_CLOSED_X, duration)
|
||||
|
||||
func _on_pulse_blocked():
|
||||
_set_door_collision(false)
|
||||
_tween_doors(DOOR_OPEN_X, DOOR_REOPEN_TIME)
|
||||
|
||||
func _set_door_collision(enabled: bool):
|
||||
$ElevatorDoorRight/CollisionShape3D.disabled = not enabled
|
||||
$ElevatorDoorLeft/CollisionShape3D.disabled = not enabled
|
||||
|
||||
func _tween_doors(target_x: float, duration: float):
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue