extends Node3D ##车门 class_name TrainDoor @onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer @onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer ## 车门的状态枚举 enum Train_Door_STATE{ open,# 开门 close,# 关门 } ##车门的状态 @onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.close : 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") ##打开车门 func openTrainDoor ()-> void: trainDoorState=Train_Door_STATE.open ##关闭车门 func closeTrainDoor ()-> void: trainDoorState=Train_Door_STATE.close