Cyber/Assets/Scripts/Networking/Clientside/ClientSyncer.cs

27 lines
855 B
C#
Raw Normal View History

2017-05-11 21:00:52 +02:00

using Cyber.Networking.Messages;
namespace Cyber.Networking.Clientside {
/// <summary>
/// Syncer used on the clientside which sends sync packets from the client to the server containing their movement direction, rotation and possible checksums.
/// </summary>
public class ClientSyncer : Syncer {
2017-05-11 21:00:52 +02:00
public ClientSyncer() : base(1f / 10) {}
2017-05-11 21:00:52 +02:00
public override void PerformTick(int Tick) {
2017-05-11 21:00:52 +02:00
ClientSyncPkt SyncPkt = new ClientSyncPkt();
2017-05-11 21:00:52 +02:00
var PlayerCharacter = Client.GetConnectedPlayer().Character;
SyncPkt.ClientSyncID = NextSyncID();
SyncPkt.MoveDirection = PlayerCharacter.GetMovementDirection();
SyncPkt.Rotation = PlayerCharacter.GetRotation();
2017-05-11 21:00:52 +02:00
Client.SendByChannel(PktType.ClientSync, SyncPkt, NetworkChannelID.Unreliable);
2017-05-11 21:00:52 +02:00
}
}
}