2020-08-09 09:17:00 +02:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Events
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
2020-08-09 09:37:32 +02:00
|
|
|
|
class PlayerSignalscopeEvent : QSBEvent<ToggleMessage>
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
2020-08-09 09:17:00 +02:00
|
|
|
|
public override MessageType Type => MessageType.SignalscopeActiveChange;
|
2020-08-08 12:23:23 +01:00
|
|
|
|
|
|
|
|
|
public override void SetupListener()
|
|
|
|
|
{
|
2020-08-09 12:19:51 +01:00
|
|
|
|
GlobalMessenger<Signalscope>.AddListener("EquipSignalscope", var => SendEvent(new ToggleMessage { SenderId = PlayerRegistry.LocalPlayer.NetId, On = true }));
|
|
|
|
|
GlobalMessenger.AddListener("UnequipSignalscope", () => SendEvent(new ToggleMessage { SenderId = PlayerRegistry.LocalPlayer.NetId, On = false }));
|
2020-08-08 12:23:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-09 12:19:51 +01:00
|
|
|
|
public override void OnReceive(ToggleMessage message)
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
2020-08-09 12:19:51 +01:00
|
|
|
|
var player = PlayerRegistry.GetPlayer(message.SenderId);
|
2020-08-08 12:23:23 +01:00
|
|
|
|
var tool = player.Signalscope;
|
2020-08-09 09:37:32 +02:00
|
|
|
|
player.UpdateState(State.Signalscope, message.On);
|
|
|
|
|
if (message.On)
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
|
|
|
|
tool.EquipTool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tool.UnequipTool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-09 09:37:32 +02:00
|
|
|
|
public override void OnReceiveLocal(ToggleMessage message)
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
|
|
|
|
var tool = PlayerRegistry.LocalPlayer.Signalscope;
|
2020-08-09 09:37:32 +02:00
|
|
|
|
if (message.On)
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
|
|
|
|
tool.EquipTool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tool.UnequipTool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|