2024-04-12 11:06:25 +08:00
|
|
|
extends Node3D
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##车门
|
|
|
|
class_name TrainDoor
|
2024-04-12 11:06:25 +08:00
|
|
|
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
|
|
|
|
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
|
|
|
|
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
## 车门的状态枚举
|
2024-04-12 11:06:25 +08:00
|
|
|
enum Train_Door_STATE{
|
2024-05-28 15:40:46 +08:00
|
|
|
opening,# 正在开门
|
|
|
|
open,#开到位
|
|
|
|
closeing,#正在关门
|
|
|
|
close,# 关到位
|
2024-04-12 11:06:25 +08:00
|
|
|
}
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##车门的状态
|
|
|
|
@onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.close :
|
2024-04-12 11:06:25 +08:00
|
|
|
set(value):
|
|
|
|
if trainDoorState != value:
|
|
|
|
trainDoorState = value
|
|
|
|
if trainDoorState ==Train_Door_STATE.open :
|
|
|
|
left_animation_player.play("leftOpen")
|
|
|
|
right_animation_player.play("rightOpen")
|
|
|
|
elif trainDoorState ==Train_Door_STATE.close :
|
|
|
|
left_animation_player.play("leftClose")
|
|
|
|
right_animation_player.play("rightClose")
|
|
|
|
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##打开车门
|
|
|
|
func openTrainDoor ()-> void:
|
2024-05-28 15:40:46 +08:00
|
|
|
if trainDoorState == Train_Door_STATE.close and trainDoorFaultState != TrainDoor_Fault_State.openFault :
|
|
|
|
trainDoorState=Train_Door_STATE.open
|
2024-04-29 15:00:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
##关闭车门
|
|
|
|
func closeTrainDoor ()-> void:
|
2024-05-29 15:18:03 +08:00
|
|
|
if trainDoorState == Train_Door_STATE.open and trainDoorFaultState != TrainDoor_Fault_State.closeFault :
|
|
|
|
trainDoorState=Train_Door_STATE.close
|
|
|
|
|
|
|
|
##屏蔽门开关门到位信号
|
|
|
|
signal trainDoorOpenSignal(screenDoor:ScreenDoor)
|
|
|
|
signal trainDoorCloseSignal(screenDoor:ScreenDoor)
|
|
|
|
|
|
|
|
func _on_left_animation_player_animation_finished(anim_name: StringName) -> void:
|
|
|
|
if anim_name == 'leftOpen':
|
|
|
|
trainDoorOpenSignal.emit(self)
|
|
|
|
elif anim_name == 'leftClose':
|
|
|
|
trainDoorCloseSignal.emit(self)
|
2024-05-28 15:40:46 +08:00
|
|
|
|
|
|
|
## 车门的故障枚举
|
|
|
|
enum TrainDoor_Fault_State{
|
|
|
|
noFault,#无故障
|
|
|
|
openFault,# 开门故障
|
2024-05-29 15:18:03 +08:00
|
|
|
closeFault,# 关门故障
|
2024-05-28 15:40:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
##车门的故障状态
|
|
|
|
@onready var trainDoorFaultState : TrainDoor_Fault_State = TrainDoor_Fault_State.noFault :
|
|
|
|
set(value):
|
|
|
|
if trainDoorFaultState != value:
|
|
|
|
trainDoorFaultState = value
|
|
|
|
|
|
|
|
##设置故障
|
2024-06-04 09:15:28 +08:00
|
|
|
func setTrainDoorFault (faultType:TrainDoor_Fault_State)-> void:
|
2024-05-28 15:40:46 +08:00
|
|
|
trainDoorFaultState = faultType
|
|
|
|
|
|
|
|
##恢复故障
|
|
|
|
func removeTrainDoorFault ()-> void:
|
|
|
|
trainDoorFaultState = TrainDoor_Fault_State.noFault
|