mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 18:32:45 +00:00
52 lines
1016 B
C#
52 lines
1016 B
C#
using Mirror;
|
|
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.Animation.Player.Messages
|
|
{
|
|
internal class AnimationTriggerMessage : QSBMessage
|
|
{
|
|
private uint PlayerId;
|
|
private string Name;
|
|
|
|
public AnimationTriggerMessage(uint playerId, string name)
|
|
{
|
|
PlayerId = playerId;
|
|
Name = name;
|
|
}
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
writer.Write(PlayerId);
|
|
writer.Write(Name);
|
|
}
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
PlayerId = reader.Read<uint>();
|
|
Name = reader.ReadString();
|
|
}
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
var animationSync = QSBPlayerManager.GetPlayer(PlayerId).AnimationSync;
|
|
if (animationSync == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (animationSync.VisibleAnimator == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
animationSync.VisibleAnimator.SetTrigger(Name);
|
|
}
|
|
}
|
|
}
|