2021-12-26 00:53:43 -08:00
|
|
|
|
using QSB.Messaging;
|
2021-12-23 22:40:37 -08:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Player.TransformSync;
|
2022-01-27 01:27:15 -08:00
|
|
|
|
using QSB.WorldSync;
|
2021-12-23 22:40:37 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.Animation.Player.Messages;
|
|
|
|
|
|
|
|
|
|
public class PlayerSuitMessage : QSBMessage<bool>
|
2021-12-23 22:40:37 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
static PlayerSuitMessage()
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
GlobalMessenger.AddListener(OWEvents.SuitUp, () => Handle(true));
|
|
|
|
|
GlobalMessenger.AddListener(OWEvents.RemoveSuit, () => Handle(false));
|
|
|
|
|
}
|
2021-12-23 22:40:37 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private static void Handle(bool on)
|
|
|
|
|
{
|
|
|
|
|
if (PlayerTransformSync.LocalInstance)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
new PlayerSuitMessage(on).Send();
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-01-27 01:27:15 -08:00
|
|
|
|
|
2022-03-10 17:57:50 -08:00
|
|
|
|
public PlayerSuitMessage(bool on) : base(on) { }
|
2021-12-23 22:40:37 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.SuitedUp = Data;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (!player.IsReady)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
return;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
var animator = player.AnimationSync;
|
|
|
|
|
animator.SetSuitState(Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
QSBPlayerManager.LocalPlayer.SuitedUp = Data;
|
|
|
|
|
var animator = QSBPlayerManager.LocalPlayer.AnimationSync;
|
|
|
|
|
animator.InSuitedUpState = Data;
|
2021-12-23 22:40:37 -08:00
|
|
|
|
}
|
|
|
|
|
}
|