using UnityEngine; using UnityEngine.Networking; namespace Cyber.Networking.Messages { /// /// This Packet contains sync data from the client to the server like movement direction and rotation. /// public class ClientSyncPkt : MessageBase { /// /// ID of this client sync packet. This is separate from the server sync id. /// public int ClientSyncID; /// /// Current movement direction of the player /// public Vector3 MoveDirection; /// /// Current rotation of the player /// public Vector3 Rotation; /// /// Create an empty client sync packet. /// public ClientSyncPkt() { } /// /// Deserializes the sync packet. Does not deserialize everything, only the ID. /// /// public override void Deserialize(NetworkReader reader) { ClientSyncID = reader.ReadInt32(); } /// /// Reads the rest of the sync packet. Must be deserialized first. /// /// public void ReadTheRest(NetworkReader reader) { MoveDirection = reader.ReadVector3(); Rotation = reader.ReadVector3(); } /// /// Serializes the entire packet for sending. /// /// public override void Serialize(NetworkWriter writer) { writer.Write(ClientSyncID); writer.Write(MoveDirection); writer.Write(Rotation); } } }