Skip to content

v2.0.0 Migration Guide

The boilerplate from previous versions is now redundant as CSync will handle things itself.
This means Steps 3 and 4 of the outdated guide are no longer necessary.

To begin updating, replace SyncedInstance with SyncedConfig.

cs
MyConfig : SyncedInstance<MyConfig>
MyConfig : SyncedConfig<MyConfig>

We will now register our config with CSync through ConfigManager instead of InitInstance(this). Notice how we specify our mod's GUID through base() to ensure it doesn't overlap with others behind the scenes.

cs
public ExampleConfig(ConfigFile cfg) : base("MyModName") {
    InitInstance(this); 
    ConfigManager.Register(this); 

    EXAMPLE_VAR = cfg.BindSyncedEntry("General", "bExampleVar", true, "This is an example variable that will be synced.");
}

We are all done! If you previously had join/leave patches and request/receiver methods, you should remove these to prevent any possible issues.

OPTIONAL
This update also provides the SyncComplete event that you can hook into if desired.

cs
public ExampleConfig(ConfigFile cfg) : base("MyModName") {
    ConfigManager.Register(this);

    EXAMPLE_VAR = cfg.BindSyncedEntry("General", "bExampleVar", true, "This is an example variable that will be synced.");

    SyncComplete += DoSomethingAfterSync; 
}

public void DoSomethingAfterSync(object sender, EventArgs args) { 
    // Run some logic here
}