mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 21:59:16 +00:00
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using QSB.Events;
|
|
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.Player.TransformSync;
|
|
|
|
namespace QSB.Animation.Player.Messages
|
|
{
|
|
public class PlayerSuitMessage : QSBBoolMessage
|
|
{
|
|
static PlayerSuitMessage()
|
|
{
|
|
GlobalMessenger.AddListener(EventNames.SuitUp, () => Handle(true));
|
|
GlobalMessenger.AddListener(EventNames.RemoveSuit, () => Handle(false));
|
|
}
|
|
|
|
private static void Handle(bool on)
|
|
{
|
|
if (PlayerTransformSync.LocalInstance)
|
|
{
|
|
new PlayerSuitMessage(on).Send();
|
|
}
|
|
}
|
|
|
|
private PlayerSuitMessage(bool on) => Value = on;
|
|
|
|
public PlayerSuitMessage() { }
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
player.SuitedUp = Value;
|
|
|
|
if (!player.IsReady)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var animator = player.AnimationSync;
|
|
var type = Value ? AnimationType.PlayerSuited : AnimationType.PlayerUnsuited;
|
|
animator.SetAnimationType(type);
|
|
}
|
|
|
|
public override void OnReceiveLocal()
|
|
{
|
|
QSBPlayerManager.LocalPlayer.SuitedUp = Value;
|
|
var animator = QSBPlayerManager.LocalPlayer.AnimationSync;
|
|
var type = Value ? AnimationType.PlayerSuited : AnimationType.PlayerUnsuited;
|
|
animator.CurrentType = type;
|
|
}
|
|
}
|
|
} |