using QSB.Events; using QSB.Messaging; using QSB.WorldSync; namespace QSB.ElevatorSync { public class ElevatorEvent : QSBEvent { public override EventType Type => EventType.Elevator; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBStartLift, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBStartLift, Handler); private void Handler(int id, ElevatorDirection direction) => SendEvent(CreateMessage(id, direction)); private ElevatorMessage CreateMessage(int id, ElevatorDirection direction) => new ElevatorMessage { Direction = direction, ObjectId = id }; public override void OnReceiveRemote(ElevatorMessage message) { var elevator = WorldRegistry.GetObject(message.ObjectId); elevator?.RemoteCall(message.Direction); } } }