mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 06:35:45 +00:00
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using QSB.Messaging;
|
|
using QSB.Utility;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
class PlayerProbeLauncherEvent : QSBEvent<ToggleMessage>
|
|
{
|
|
public override MessageType Type => MessageType.ProbeLauncherActiveChange;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger<ProbeLauncher>.AddListener("ProbeLauncherEquipped", var => SendEvent(
|
|
new ToggleMessage {
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = true
|
|
}));
|
|
GlobalMessenger<ProbeLauncher>.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);
|
|
}
|
|
}
|
|
}
|