using QSB.Messaging; using QSB.Utility; namespace QSB.Events { class PlayerProbeLauncherEvent : QSBEvent { public override MessageType Type => MessageType.ProbeLauncherActiveChange; public override void SetupListener() { GlobalMessenger.AddListener("ProbeLauncherEquipped", var => SendEvent( new ToggleMessage { SenderId = PlayerRegistry.LocalPlayer.NetId, ToggleValue = true })); GlobalMessenger.AddListener("ProbeLauncherUnequipped", var => SendEvent( new ToggleMessage { SenderId = PlayerRegistry.LocalPlayer.NetId, ToggleValue = false })); } public override void OnReceive(ToggleMessage message) { var player = PlayerRegistry.GetPlayer(message.SenderId); player.UpdateState(State.ProbeLauncher, message.ToggleValue); player.ProbeLauncher.ChangeEquipState(message.ToggleValue); } public override void OnReceiveLocal(ToggleMessage message) { PlayerRegistry.LocalPlayer.UpdateState(State.ProbeLauncher, message.ToggleValue); } } }