2. Constructing the config
Updated 10 months agoDeclare your constructor as usual and add EasySync.SyncManager.RegisterForSyncing(this, GUID);
.
GUID
could be your PluginInfo.PLUGIN_GUID
or any string that is unique enough to not be used by others mistakenly.
For SyncedEntry<T>
variables, use the .BindSyncedEntry
extension provided by CSync.
public ExampleConfig(Config cfg)
{
EasySync.SyncManager.RegisterForSyncing(this, GUID);
clientOnlyVariable = cfg.Bind("Client Only Category", "clientVariable", 1,
"An example of a local only config that won't be synced.");
syncedVariable = cfg.BindSyncedEntry("Synced Settings Category", "syncedVariable", 5,
"An example of a synced config that will sync on player joins.");
}
Your class at this point should look something like this:
[DataContract]
public class ExampleConfig : SyncedInstance<ExampleConfig>
{
public ConfigEntry<float> clientOnlyVariable { get; private set; }
[DataMember] public SyncedEntry<float> syncedVariable { get; private set; }
public ExampleConfig(Config cfg)
{
EasySync.SyncManager.RegisterForSyncing(this, GUID);
clientOnlyVariable = cfg.Bind("Client Only Category", "clientVariable", 1,
"An example of a local only config that won't be synced.");
syncedVariable = cfg.BindSyncedEntry("Synced Settings Category", "syncedVariable", 5,
"An example of a synced config that will sync on player joins.");
}
}