2024-04-12 11:06:25 +08:00
|
|
|
extends Node3D
|
|
|
|
|
2024-04-17 15:26:37 +08:00
|
|
|
##屏蔽门
|
|
|
|
class_name ScreenDoor
|
2024-04-12 11:06:25 +08:00
|
|
|
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
|
|
|
|
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
|
2024-05-09 13:51:55 +08:00
|
|
|
@export var mtd_material: ShaderMaterial
|
2024-04-12 11:06:25 +08:00
|
|
|
|
2024-05-06 09:54:45 +08:00
|
|
|
##是否设置隔离带
|
2024-05-06 14:20:57 +08:00
|
|
|
@onready var isSetIsolationStrip:bool = false :
|
|
|
|
set(value):
|
|
|
|
if isSetIsolationStrip != value:
|
|
|
|
isSetIsolationStrip = value
|
|
|
|
if isSetIsolationStrip:
|
|
|
|
$IsolationStrip.visible = true
|
|
|
|
else :
|
|
|
|
$IsolationStrip.visible = false
|
|
|
|
|
|
|
|
##粘胶带
|
|
|
|
func adhesiveTape ()-> void:
|
|
|
|
if $leftDoor_broken.visible == true :
|
|
|
|
$left_tape.visible = true
|
2024-05-06 09:54:45 +08:00
|
|
|
|
2024-04-12 15:01:34 +08:00
|
|
|
## 屏蔽门的状态枚举
|
2024-04-29 17:13:14 +08:00
|
|
|
enum ScreenDoor_State{
|
|
|
|
opening,# 正在开门
|
|
|
|
open,#开到位
|
|
|
|
closeing,#正在关门
|
|
|
|
close,# 关到位
|
2024-04-12 11:06:25 +08:00
|
|
|
}
|
|
|
|
|
2024-04-12 15:01:34 +08:00
|
|
|
##屏蔽门的状态
|
2024-04-29 17:13:14 +08:00
|
|
|
@onready var screenDoorState : ScreenDoor_State = ScreenDoor_State.close :
|
2024-04-12 11:06:25 +08:00
|
|
|
set(value):
|
|
|
|
if screenDoorState != value:
|
|
|
|
screenDoorState = value
|
2024-04-29 17:13:14 +08:00
|
|
|
if screenDoorState == ScreenDoor_State.opening :
|
2024-04-12 11:06:25 +08:00
|
|
|
left_animation_player.play("leftOpen")
|
|
|
|
right_animation_player.play("rightOpen")
|
2024-05-15 13:44:54 +08:00
|
|
|
$AudioStreamPlayer.play()
|
2024-04-29 17:13:14 +08:00
|
|
|
elif screenDoorState == ScreenDoor_State.closeing :
|
2024-04-12 11:06:25 +08:00
|
|
|
left_animation_player.play("leftClose")
|
|
|
|
right_animation_player.play("rightClose")
|
2024-05-15 13:44:54 +08:00
|
|
|
$AudioStreamPlayer.play()
|
2024-04-12 11:06:25 +08:00
|
|
|
|
2024-04-12 16:55:38 +08:00
|
|
|
##打开屏蔽门
|
2024-05-07 18:06:54 +08:00
|
|
|
func openScreenDoor (isUseLCBKey=false)-> void:
|
2024-05-28 15:40:46 +08:00
|
|
|
if screenDoorState == ScreenDoor_State.close and ((screenDoorFaultState != ScreenDoor_Fault_State.openFault and screenDoorFaultState != ScreenDoor_Fault_State.glassBreakage and lcbKey.keyState ==LcbWindow.KNOB_STATE.AUTO ) or isUseLCBKey):
|
2024-04-29 17:13:14 +08:00
|
|
|
screenDoorState=ScreenDoor_State.opening
|
2024-05-09 14:43:36 +08:00
|
|
|
$Timer.start(0.3)
|
2024-04-29 17:13:14 +08:00
|
|
|
|
|
|
|
|
2024-04-12 15:01:34 +08:00
|
|
|
##关闭屏蔽门
|
2024-05-07 18:06:54 +08:00
|
|
|
func closeScreenDoor (isUseLCBKey=false)-> void:
|
2024-05-14 16:41:14 +08:00
|
|
|
if screenDoorState == ScreenDoor_State.open and ((screenDoorFaultState != ScreenDoor_Fault_State.closeFault and lcbKey.keyState ==LcbWindow.KNOB_STATE.AUTO) or isUseLCBKey):
|
2024-04-29 17:13:14 +08:00
|
|
|
screenDoorState=ScreenDoor_State.closeing
|
2024-05-09 14:43:36 +08:00
|
|
|
$Timer.start(0.3)
|
2024-05-10 16:53:03 +08:00
|
|
|
if screenDoorFaultState == ScreenDoor_Fault_State.pinchPeople :
|
|
|
|
$PinchPeople/Path3D/PathFollow3D.peopleWalkToScreenDoor()
|
2024-04-29 17:13:14 +08:00
|
|
|
|
2024-05-24 16:24:15 +08:00
|
|
|
func peopleWalkToPlatform()-> void:
|
|
|
|
$PinchPeople/pinchPeopleWalking.play("walkToPlatform")
|
|
|
|
|
2024-05-11 16:51:19 +08:00
|
|
|
##屏蔽门开关门到位信号
|
|
|
|
signal screenDoorOpenSignal(screenDoor:ScreenDoor)
|
|
|
|
signal screenDoorCloseSignal(screenDoor:ScreenDoor)
|
2024-04-29 17:13:14 +08:00
|
|
|
|
|
|
|
func _on_left_animation_player_animation_finished(anim_name: StringName) -> void:
|
|
|
|
if anim_name == 'leftOpen':
|
|
|
|
screenDoorState = ScreenDoor_State.open
|
2024-05-11 16:51:19 +08:00
|
|
|
screenDoorOpenSignal.emit(self)
|
2024-05-09 14:41:40 +08:00
|
|
|
$Timer.stop()
|
|
|
|
is_dark = false
|
|
|
|
_set_mtd(is_dark)
|
2024-04-29 17:13:14 +08:00
|
|
|
elif anim_name == 'leftClose':
|
|
|
|
screenDoorState = ScreenDoor_State.close
|
2024-05-11 16:51:19 +08:00
|
|
|
screenDoorCloseSignal.emit(self)
|
2024-05-08 13:48:44 +08:00
|
|
|
$Timer.stop()
|
2024-05-08 14:05:55 +08:00
|
|
|
is_dark = true
|
|
|
|
_set_mtd(is_dark)
|
2024-05-10 16:53:03 +08:00
|
|
|
if screenDoorFaultState == ScreenDoor_Fault_State.pinchPeople :
|
|
|
|
$PinchPeople/Path3D/PathFollow3D.peopleStopWalk()
|
2024-05-24 16:24:15 +08:00
|
|
|
$PinchPeople/pinchPeopleVoice.play()
|
|
|
|
|
2024-04-29 17:13:14 +08:00
|
|
|
|
|
|
|
## 屏蔽门的故障枚举
|
|
|
|
enum ScreenDoor_Fault_State{
|
|
|
|
noFault,#无故障
|
|
|
|
openFault,# 开门故障
|
|
|
|
closeFault,# 关门故障
|
|
|
|
pinchPeople,#夹人
|
|
|
|
glassBreakage,#玻璃破碎
|
|
|
|
}
|
|
|
|
|
|
|
|
##屏蔽门的故障状态
|
|
|
|
@onready var screenDoorFaultState : ScreenDoor_Fault_State = ScreenDoor_Fault_State.noFault :
|
|
|
|
set(value):
|
|
|
|
if screenDoorFaultState != value:
|
|
|
|
screenDoorFaultState = value
|
|
|
|
|
|
|
|
##设置故障
|
|
|
|
func setScreenDoorFault (faultType:ScreenDoor_Fault_State)-> void:
|
|
|
|
screenDoorFaultState = faultType
|
2024-05-08 16:15:27 +08:00
|
|
|
if faultType == ScreenDoor_Fault_State.glassBreakage :
|
|
|
|
$leftDoor_broken.visible = true
|
|
|
|
$leftDoor_broken/AudioStreamPlayer.play()
|
2024-04-29 17:13:14 +08:00
|
|
|
|
|
|
|
##恢复故障
|
|
|
|
func removeScreenDoorFault ()-> void:
|
|
|
|
screenDoorFaultState = ScreenDoor_Fault_State.noFault
|
2024-05-08 15:59:16 +08:00
|
|
|
|
2024-04-29 17:13:14 +08:00
|
|
|
##以下是lcb相关
|
|
|
|
class LcbKeyWindow :
|
|
|
|
var keyName: String
|
|
|
|
var keyState:LcbWindow.KNOB_STATE
|
|
|
|
func _init(keyName: String, keyState: LcbWindow.KNOB_STATE):
|
|
|
|
self.keyName = keyName
|
|
|
|
self.keyState = keyState
|
|
|
|
|
|
|
|
var lcbKey = LcbKeyWindow.new('',LcbWindow.KNOB_STATE.AUTO)
|
|
|
|
|
|
|
|
signal clickLcbSignalAndSent(screenDoor)
|
|
|
|
|
|
|
|
func _on_lcb_click() -> void:
|
2024-04-30 11:25:39 +08:00
|
|
|
clickLcbSignalAndSent.emit(self)
|
|
|
|
|
|
|
|
##点击屏蔽门
|
2024-04-30 16:02:08 +08:00
|
|
|
signal clicksScreenDoorSignal(screenDoor,mousePosition)
|
2024-05-08 13:48:44 +08:00
|
|
|
|
2024-05-08 14:05:55 +08:00
|
|
|
var is_dark = true
|
2024-05-08 13:48:44 +08:00
|
|
|
func _on_timer_timeout():
|
2024-05-10 09:30:37 +08:00
|
|
|
is_dark = !is_dark
|
|
|
|
_set_mtd(is_dark)
|
2024-05-08 14:05:55 +08:00
|
|
|
|
|
|
|
func _set_mtd(dark):
|
|
|
|
if is_dark:
|
2024-05-08 15:59:16 +08:00
|
|
|
$SpotLight3D.hide()
|
2024-05-08 14:05:55 +08:00
|
|
|
else:
|
2024-05-09 13:51:55 +08:00
|
|
|
$SpotLight3D.show()
|
2024-05-08 14:05:55 +08:00
|
|
|
|
|
|
|
func _ready():
|
2024-05-09 13:51:55 +08:00
|
|
|
$MTD.material_override = mtd_material
|
2024-05-10 09:30:37 +08:00
|
|
|
$Timer.connect('timeout', _on_timer_timeout)
|
2024-05-08 14:05:55 +08:00
|
|
|
_set_mtd(is_dark)
|