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>
2017-05-14 22:20:18 +02:00
public class ClientSyncer : Syncer {
2017-05-11 21:00:52 +02:00
2017-05-14 22:25:19 +02:00
/// <summary>
/// Creates a Client syncer, constructor only defined because of inheritance of <see cref="Syncer"/>.
/// </summary>
2017-05-14 22:20:18 +02:00
public ClientSyncer ( ) : base ( 1f / 10 ) { }
2017-05-11 21:00:52 +02:00
2017-05-14 22:25:19 +02:00
/// <summary>
/// Performs a client sync tick.
/// </summary>
/// <param name="Tick">The number of the tick, which can be used to determine a few things, like when to sync certain things.</param>
2017-05-14 22:20:18 +02:00
public override void PerformTick ( int Tick ) {
2017-05-11 21:00:52 +02:00
2017-05-14 22:20:18 +02:00
ClientSyncPkt SyncPkt = new ClientSyncPkt ( ) ;
2017-05-11 21:00:52 +02:00
2017-05-14 22:20:18 +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
2017-05-14 22:20:18 +02:00
Client . SendByChannel ( PktType . ClientSync , SyncPkt , NetworkChannelID . Unreliable ) ;
2017-05-11 21:00:52 +02:00
}
}
}