This commit is contained in:
Sofia 2017-05-14 23:25:19 +03:00
parent 1a7e44b733
commit 11e6fc00d8
3 changed files with 29 additions and 6 deletions

View File

@ -8,8 +8,15 @@ namespace Cyber.Networking.Clientside {
/// </summary>
public class ClientSyncer : Syncer {
/// <summary>
/// Creates a Client syncer, constructor only defined because of inheritance of <see cref="Syncer"/>.
/// </summary>
public ClientSyncer() : base(1f / 10) {}
/// <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>
public override void PerformTick(int Tick) {
ClientSyncPkt SyncPkt = new ClientSyncPkt();

View File

@ -3,7 +3,6 @@ using Cyber.Entities;
using Cyber.Networking.Messages;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Cyber.Networking.Serverside {
@ -17,6 +16,9 @@ namespace Cyber.Networking.Serverside {
private List<int> QueuedSyncs = new List<int>();
private List<int> DirtySyncBases = new List<int>();
/// <summary>
/// Creates a Server syncer, constructor only defined because of inheritance of <see cref="Syncer"/>.
/// </summary>
public ServerSyncer() : base(1f / 10) {}
/// <summary>
@ -31,9 +33,9 @@ namespace Cyber.Networking.Serverside {
}
/// <summary>
///
/// Performs a server sync tick.
/// </summary>
/// <param name="Tick"></param>
/// <param name="Tick">The number of the tick, which can be used to determine a few things, like when to sync certain things.</param>
public override void PerformTick(int Tick) {
var Categorized = Database.GetCategorizedDatabase();
List<int> checksummedIds = new List<int>();

View File

@ -3,7 +3,9 @@ using UnityEngine;
namespace Cyber.Networking {
/// <summary>
/// An abstract syncer, used by <see cref="Serverside.ServerSyncer"/> and <see cref="Clientside.ClientSyncer"/>.
/// </summary>
public abstract class Syncer : MonoBehaviour {
private int TickCounter = 0;
@ -13,15 +15,29 @@ namespace Cyber.Networking {
private int SyncPacketID = 0;
/// <summary>
/// Initializes the syncer, basically just sets the <see cref="TickInterval"/>.
/// </summary>
/// <param name="tickInterval"></param>
public Syncer(float tickInterval) {
TickInterval = tickInterval;
TimeSinceLastTick = tickInterval;
}
/// <summary>
/// Returns the next ID for a sync packet.
/// </summary>
/// <returns></returns>
public int NextSyncID() {
return SyncPacketID++;
}
/// <summary>
/// Performs a tick on the syncer, called from <see cref="Update"/>.
/// </summary>
/// <param name="Tick">The tick number, used to e.g. determine when to sync certain things.</param>
public abstract void PerformTick(int Tick);
private void Update() {
TimeSinceLastTick += Time.deltaTime;
@ -38,7 +54,5 @@ namespace Cyber.Networking {
}
}
public abstract void PerformTick(int Tick);
}
}