using QSB.EventsCore; using QSB.WorldSync; using QSB.WorldSync.Events; namespace QSB.ElevatorSync.Events { 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, bool direction) => SendEvent(CreateMessage(id, direction)); private BoolWorldObjectMessage CreateMessage(int id, bool direction) => new BoolWorldObjectMessage { State = direction, ObjectId = id }; public override void OnReceiveRemote(BoolWorldObjectMessage message) { var elevator = WorldRegistry.GetObject(message.ObjectId); elevator?.RemoteCall(message.State); } } }