Interface ISyncable
An interface that allows syncing objects that inherit it.
Namespace: UnofficialMultiplayerAPI
Assembly: 0UnofficialMultiplayerAPI.dll
Syntax
public interface ISyncable
Methods
Sync(SyncWorker)
An entry point that is used when object is to be read/written.
Declaration
void Sync(SyncWorker sync)
Parameters
| Type | Name | Description |
|---|---|---|
| SyncWorker | sync | A SyncWorker that will read/write data bound with Bind methods. |
Remarks
Requires a default constructor that takes no parameters.
Check SyncerAttribute to see how to make a syncer that allows for a manual object construction.
Examples
A simple implementation that binds object's fields x, y, z for reading/writing.
public void Sync(SyncWorker sync)
{
sync.Bind(ref this.x);
sync.Bind(ref this.y);
sync.Bind(ref this.z);
}
An implementation that sends field a, but saves it back into field b when it's received.
public void Sync(SyncWorker sync)
{
if(sync.isWriting)
sync.Bind(ref this.a);
else
sync.Bind(ref this.b);
}