2021-12-26 08:53:43 +00:00
|
|
|
|
using QSB.Messaging;
|
2021-12-24 02:55:22 +00:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Player.TransformSync;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.Tools.SignalscopeTool.Messages;
|
|
|
|
|
|
|
|
|
|
public class PlayerSignalscopeMessage : QSBMessage<bool>
|
2021-12-24 02:55:22 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
static PlayerSignalscopeMessage()
|
2021-12-24 02:55:22 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
GlobalMessenger<Signalscope>.AddListener(OWEvents.EquipSignalscope, _ => Handle(true));
|
|
|
|
|
GlobalMessenger.AddListener(OWEvents.UnequipSignalscope, () => Handle(false));
|
|
|
|
|
}
|
2021-12-24 02:55:22 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
private static void Handle(bool equipped)
|
|
|
|
|
{
|
|
|
|
|
if (PlayerTransformSync.LocalInstance)
|
2021-12-24 02:55:22 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
new PlayerSignalscopeMessage(equipped).Send();
|
2021-12-24 02:55:22 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
2021-12-24 02:55:22 +00:00
|
|
|
|
|
2022-03-11 01:57:50 +00:00
|
|
|
|
private PlayerSignalscopeMessage(bool equipped) : base(equipped) { }
|
2022-02-25 06:04:54 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.SignalscopeEquipped = Data;
|
|
|
|
|
player.Signalscope?.ChangeEquipState(Data);
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal() =>
|
|
|
|
|
QSBPlayerManager.LocalPlayer.SignalscopeEquipped = Data;
|
2021-12-24 02:55:22 +00:00
|
|
|
|
}
|