using QSB.Events; using QSB.Messaging; using QSB.Player; namespace QSB.ProbeSync.Events { internal class PlayerProbeEvent : QSBEvent> { public override EventType Type => EventType.ProbeEvent; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBProbeEvent, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBProbeEvent, Handler); private void Handler(ProbeEvent probeEvent) => SendEvent(CreateMessage(probeEvent)); private EnumMessage CreateMessage(ProbeEvent probeEvent) => new EnumMessage { AboutId = LocalPlayerId, EnumValue = probeEvent }; public override void OnReceiveRemote(bool server, EnumMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); var probe = player.Probe; probe.HandleEvent(message.EnumValue); } } }