quantum-space-buddies/QSB/Animation/Events/QSBAnimationMessage.cs

35 lines
801 B
C#
Raw Normal View History

2020-11-08 14:41:16 +00:00
using UnityEngine.Networking;
2020-11-08 16:10:10 +00:00
namespace QSB.Animation.Events
2020-11-08 14:41:16 +00:00
{
2020-12-03 08:28:05 +00:00
internal class QSBAnimationMessage : MessageBase
2020-12-02 21:23:01 +00:00
{
public NetworkInstanceId netId;
public int stateHash;
public float normalizedTime;
public byte[] parameters;
2020-11-08 14:41:16 +00:00
2020-12-02 21:23:01 +00:00
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
stateHash = (int)reader.ReadPackedUInt32();
normalizedTime = reader.ReadSingle();
parameters = reader.ReadBytesAndSize();
}
2020-11-08 14:41:16 +00:00
2020-12-02 21:23:01 +00:00
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.WritePackedUInt32((uint)stateHash);
writer.Write(normalizedTime);
if (parameters == null)
{
writer.WriteBytesAndSize(parameters, 0);
}
else
{
writer.WriteBytesAndSize(parameters, parameters.Length);
}
}
}
2020-11-08 16:13:10 +00:00
}