2017-05-09 16:15:21 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Networking;
|
2017-05-08 23:03:02 +02:00
|
|
|
|
|
2017-05-10 15:05:02 +02:00
|
|
|
|
namespace Cyber.Entities.SyncBases {
|
2017-05-08 23:03:02 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A base class for all syncable components. An instance of
|
|
|
|
|
/// <see cref="SyncDB"/> will contain all of the game's synced components.
|
|
|
|
|
/// </summary>
|
2017-05-09 16:15:21 +02:00
|
|
|
|
public abstract class SyncBase : MonoBehaviour {
|
2017-05-08 23:03:02 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The ID this syncable component can be found with from its parent
|
|
|
|
|
/// <see cref="SyncDB"/>.
|
|
|
|
|
/// </summary>
|
2017-05-09 05:13:30 +02:00
|
|
|
|
public int ID;
|
2017-05-09 16:15:21 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Return the Sync Handletype information for <see cref="Syncer"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Sync Handletype containing sync information.</returns>
|
|
|
|
|
public abstract SyncHandletype GetSyncHandletype();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deserializes this SyncBase for further use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reader"></param>
|
|
|
|
|
public abstract void Deserialize(NetworkReader reader);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Serialize this SyncBase into a sync packet.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="writer"></param>
|
|
|
|
|
public abstract void Serialize(NetworkWriter writer);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates a checksum of the contents, or 0 if no checksum is overriden.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The integer checksum.</returns>
|
|
|
|
|
public virtual int GenerateChecksum() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-05-08 23:03:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|