mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using QSB.Messaging;
|
|
using QSB.Utility;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
class PlayerSignalscopeEvent : QSBEvent<ToggleMessage>
|
|
{
|
|
public override MessageType Type => MessageType.SignalscopeActiveChange;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger<Signalscope>.AddListener("EquipSignalscope", var => SendEvent(
|
|
new ToggleMessage {
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = true
|
|
}));
|
|
GlobalMessenger.AddListener("UnequipSignalscope", () => SendEvent(
|
|
new ToggleMessage {
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = false
|
|
}));
|
|
}
|
|
|
|
public override void OnReceive(ToggleMessage message)
|
|
{
|
|
var player = PlayerRegistry.GetPlayer(message.SenderId);
|
|
player.UpdateState(State.Signalscope, message.ToggleValue);
|
|
player.Signalscope.ChangeEquipState(message.ToggleValue);
|
|
}
|
|
|
|
public override void OnReceiveLocal(ToggleMessage message)
|
|
{
|
|
PlayerRegistry.LocalPlayer.Signalscope.ChangeEquipState(message.ToggleValue);
|
|
}
|
|
}
|
|
}
|