using QSB.ElevatorSync.WorldObjects; using QSB.Events; using QSB.WorldSync; using QSB.WorldSync.Events; namespace QSB.ElevatorSync.Events { public class ElevatorEvent : QSBEvent { public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBStartLift, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBStartLift, Handler); private void Handler(int id, bool isGoingUp) => SendEvent(CreateMessage(id, isGoingUp)); private BoolWorldObjectMessage CreateMessage(int id, bool isGoingUp) => new() { State = isGoingUp, ObjectId = id }; public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message) { var elevator = QSBWorldSync.GetWorldFromId(message.ObjectId); elevator?.RemoteCall(message.State); } } }