Silksong.DataManager
1.2.1
dotnet add package Silksong.DataManager --version 1.2.1
NuGet\Install-Package Silksong.DataManager -Version 1.2.1
<PackageReference Include="Silksong.DataManager" Version="1.2.1" />
<PackageVersion Include="Silksong.DataManager" Version="1.2.1" />
<PackageReference Include="Silksong.DataManager" />
paket add Silksong.DataManager --version 1.2.1
#r "nuget: Silksong.DataManager, 1.2.1"
#:package Silksong.DataManager@1.2.1
#addin nuget:?package=Silksong.DataManager&version=1.2.1
#tool nuget:?package=Silksong.DataManager&version=1.2.1
Silksong.DataManager
DataManager is a mod that saves and loads data - global as well as save slot-specific - on behalf of other mods.
Using the mod
To use DataManager as a developer, you will need to do the following:
- Add a dependency on the Silksong.DataManager NuGet package
- Add a
BepInDependencyattribute on your plugin class for theorg.silksong-modding.datamanagerplugin - Implement one of the data interfaces provided by DataManager (discussed in more depth below)
As a simple example:
using Silksong.DataManager;
using BepInEx;
public class SaveData
{
public long rngSeedForSomePurpose;
}
[BepInAutoPlugin(id: "io.github.username.my-mod")]
[BepInDependency("org.silksong-modding.datamanager")]
public partial class MyPlugin : BaseUnityPlugin, ISaveDataMod<SaveData>
{
public SaveData? SaveData { get; set; }
// rest of mod class
}
Types of data
DataManager supports global data, which is an alternative to BepInEx configuration, and per-save data which is effectively a modded extension to save data.
All data types are handled by generic interfaces, such as IGlobalDataMod<T> where T is the type of data you want to
store. DataManager will automatically serialize your data as JSON at appropriate times. DataManager uses the
Newtonsoft.Json library for serialization and the serialization behavior can be altered by using Newtonsoft.Json
attributes in advanced use cases.
In the case that a mod needs to add its own data manually instead of or in addition to these interfaces, the paths
used by DataManager can all be found in the DataPaths class.
Global data
Global data is available for cases where data is needed across multiple saves, or outside of saves such as in the menu. DataManager offers 2 types of global data which mod developers can choose between based on their use case. Save data is automatically sychronized across devices by Steam Cloud.
IProfileDataMod
IProfileDataMod<T> is ideal for mods that want a more powerful alternative to BepInEx configuration. Data is stored
in the same location as BepInEx configuration files, which means that is scoped to your profile in the mod loader. It
is loaded when the game opens and saved when the game closes; you can access it in your plugin's Start method.
IGlobalDataMod
IGlobalDataMod<T> is an alternative to IProfileDataMod<T> which is saved in the save data directory, in
<save directory>/Modded/Global/<plugin ID>.json.dat. There are 2 benefits of this location:
- It will be synced across devices by Steam Cloud
- It will be available across multiple profiles
Therefore, if either of these use cases are relevant to your mod, you should use IGlobalDataMod<T>. Similar to
IProfileDataMod<T>, this data is loaded when the game opens and saved when the game closes; you can access it in
your plugin's Start method.
Save-specific data
Save-specific data is a way for your mod to add its own data to a save file. DataManager supports both mutable and immutable data.
IOnceSaveDataMod
IOnceSaveDataMod<T> provides immutable data which is set at the beginning of the file and never updated again.
It is stored in <save directory>/Modded/userN/OncePerSave/<mod ID>.json.dat. Data is saved when a game starts,
specifically at the end of GameManager.StartNewGame and loaded when loading into a file. Immutable data results
in fewer disk operations which makes the game more performant, so developers are encouraged to use it when possible.
ISaveDataMod
ISaveDataMod<T> is used for all mutable save data. It is stored in
<save directory>/Modded/userN/SaveData/<mod ID>.json.dat. Data is saved when the game is saved and loaded when
loading into a file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- BepInEx.Core (>= 5.4.21)
- HarmonyX (>= 2.9.0)
- UnityEngine.Modules (>= 6000.0.50)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Silksong.DataManager:
| Package | Downloads |
|---|---|
|
Silksong.Benchwarp
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.