-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New translations v2-migration.md (Thai)
- Loading branch information
1 parent
c99aef0
commit afe91dc
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
prev: false | ||
next: false | ||
description: Guide to migrating from CSync v1 to v2. | ||
--- | ||
|
||
# v2.0.0 Migration Guide | ||
|
||
The boilerplate from previous versions is now redundant as **CSync** will handle things itself.<br> | ||
This means Steps 3 and 4 of the outdated guide are no longer necessary. | ||
|
||
To begin updating, replace `SyncedInstance` with `SyncedConfig`.<br> | ||
|
||
```cs | ||
MyConfig : SyncedInstance<MyConfig> // [!code --] | ||
MyConfig : SyncedConfig<MyConfig> // [!code ++] | ||
``` | ||
|
||
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); // [!code --] | ||
ConfigManager.Register(this); // [!code ++] | ||
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**<br> | ||
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; // [!code ++] | ||
} | ||
|
||
public void DoSomethingAfterSync(object sender, EventArgs args) { // [!code ++] | ||
// Run some logic here // [!code ++] | ||
} // [!code ++] | ||
``` |