mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-10 15:53:19 +00:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using QSB.Messaging;
|
|
using QSB.Utility;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
class PlayerSuitEvent : QSBEvent<ToggleMessage>
|
|
{
|
|
public override MessageType Type => MessageType.SuitActiveChange;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger.AddListener("SuitUp", () => SendEvent(
|
|
new ToggleMessage
|
|
{
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = true
|
|
}));
|
|
GlobalMessenger.AddListener("RemoveSuit", () => SendEvent(
|
|
new ToggleMessage
|
|
{
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = false
|
|
}));
|
|
}
|
|
|
|
public override void OnReceive(ToggleMessage message)
|
|
{
|
|
var player = PlayerRegistry.GetPlayer(message.SenderId);
|
|
player.UpdateState(State.Suit, message.ToggleValue);
|
|
}
|
|
|
|
public override void OnReceiveLocal(ToggleMessage message)
|
|
{
|
|
PlayerRegistry.LocalPlayer.UpdateState(State.Suit, message.ToggleValue);
|
|
}
|
|
}
|
|
}
|