Class SyncerAttribute
An attribute that marks a method as a syncer for a type specified in its second parameter.
Namespace: UnofficialMultiplayerAPI
Assembly: 0UnofficialMultiplayerAPI.dll
Syntax
[AttributeUsage(AttributeTargets.Method)]
public class SyncerAttribute : Attribute, _Attribute
Remarks
Method with this attribute has to be static.
Examples
An implementation that manually constructs an object.
[Syncer(shouldConstruct = false)]
public static void MySyncer(SyncWorker sync, ref MyClass inst)
{
if(!sync.isWriting)
inst = new MyClass("hello");
sync.bind(ref inst.myField);
}
An implementation that instead of creating a new object, references its existing one which resides in MyThingComp that inherits ThingComp class.
Subclasses of ThingComp are sent as a reference by the multiplayer mod itself.
[Syncer(shouldConstruct = false)]
public static void MySyncer(SyncWorker sync, ref MyClass inst)
{
if(!sync.isWriting)
MyThingComp parent = null;
sync.Bind(ref parent); // Receive its parent
inst = new MyClass(parent);
else
sync.Bind(ref inst.parent); // Send its parent
sync.bind(ref inst.myField);
}
Fields
isImplicit
Decides if the type specified in the second parameter should also be used as a syncer for all of its subclasses.
Declaration
public bool isImplicit
Field Value
| Type | Description |
|---|---|
| Boolean |
shouldConstruct
Decides if the method should get an already constructed object in case of reading data.
Declaration
public bool shouldConstruct
Field Value
| Type | Description |
|---|---|
| Boolean |