using QSB.Events; using QSB.TimeSync.Events; using QSB.Tools.ProbeLauncherTool.WorldObjects; using QSB.Utility; using QSB.WorldSync; using QSB.WorldSync.Events; namespace QSB.Tools.ProbeLauncherTool.Events { class RetrieveProbeEvent : QSBEvent { public override EventType Type => EventType.RetrieveProbe; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBRetrieveProbe, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBRetrieveProbe, Handler); private void Handler(QSBProbeLauncher launcher, bool playEffects) => SendEvent(CreateMessage(launcher, playEffects)); private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher, bool playEffects) => new BoolWorldObjectMessage { AboutId = LocalPlayerId, ObjectId = launcher.ObjectId, State = playEffects }; public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message) { DebugLog.DebugWrite($"receive retrieve event id:{message.ObjectId} playEffects:{message.State}"); var worldObject = QSBWorldSync.GetWorldFromId(message.ObjectId); worldObject.RetrieveProbe(message.State); } } }