mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 09:35:26 +00:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using QSB.Messaging;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
class PlayerSuitEvent : QSBEvent<ToggleMessage>
|
|
{
|
|
public override MessageType Type => MessageType.SuitActiveChange;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger.AddListener("SuitUp", () => SendEvent(
|
|
new ToggleMessage
|
|
{
|
|
SenderId = LocalPlayerId,
|
|
ToggleValue = true
|
|
}));
|
|
GlobalMessenger.AddListener("RemoveSuit", () => SendEvent(
|
|
new ToggleMessage
|
|
{
|
|
SenderId = LocalPlayerId,
|
|
ToggleValue = false
|
|
}));
|
|
}
|
|
|
|
public override void OnReceiveRemote(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);
|
|
}
|
|
}
|
|
}
|