-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformState.cs
30 lines (28 loc) · 917 Bytes
/
TransformState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Unity.Netcode;
using UnityEngine;
internal class TransformState : INetworkSerializable
{
internal int Tick;
internal Vector3 Position;
internal Quaternion Rotation;
internal bool HasStartedMoving;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
if (serializer.IsReader)
{
var reader = serializer.GetFastBufferReader();
reader.ReadValueSafe(out Tick);
reader.ReadValueSafe(out Position);
reader.ReadValueSafe(out Rotation);
reader.ReadValueSafe(out HasStartedMoving);
}
else
{
var writer = serializer.GetFastBufferWriter();
writer.WriteValueSafe(Tick);
writer.WriteValueSafe(Position);
writer.WriteValueSafe(Rotation);
writer.WriteValueSafe(HasStartedMoving);
}
}
}