2020-08-09 09:17:00 +02:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Events
|
2020-08-08 12:23:23 +01:00
|
|
|
|
{
|
|
|
|
|
class PlayerSignalscopeEvent : QSBEvent
|
|
|
|
|
{
|
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 09:17:00 +02:00
|
|
|
|
GlobalMessenger<Signalscope>.AddListener("EquipSignalscope", var => SendEvent(PlayerRegistry.LocalPlayer.NetId, true));
|
|
|
|
|
GlobalMessenger.AddListener("UnequipSignalscope", () => SendEvent(PlayerRegistry.LocalPlayer.NetId, false));
|
2020-08-08 12:23:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceive(uint sender, object[] data)
|
|
|
|
|
{
|
|
|
|
|
var player = PlayerRegistry.GetPlayer(sender);
|
|
|
|
|
var tool = player.Signalscope;
|
|
|
|
|
player.UpdateState(State.Signalscope, (bool)data[0]);
|
|
|
|
|
if ((bool)data[0] == true)
|
|
|
|
|
{
|
|
|
|
|
tool.EquipTool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tool.UnequipTool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal(object[] data)
|
|
|
|
|
{
|
|
|
|
|
var tool = PlayerRegistry.LocalPlayer.Signalscope;
|
|
|
|
|
if ((bool)data[0] == true)
|
|
|
|
|
{
|
|
|
|
|
tool.EquipTool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tool.UnequipTool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|