qwbarch / mirage

A mod that mimics player voices for Unity games
https://thunderstore.io/c/lethal-company/p/qwbarch/Mirage
Other
12 stars 2 forks source link

Remove orphaned config entries #63

Open qwbarch opened 3 months ago

qwbarch commented 3 months ago

Quote from KittenJI on discord:

If you wanted to completely remove unused configurations in your mod, so It doesn't persist in the Config Editor on people that used your mod previous to that version, you can do the following:

// Do not bind unused property anymore.
// ConfigEntry<int> SpawnRateOverride = Config.Bind("Configuration", "Entity Spawn Rate", 10, "Description or whatever");

PropertyInfo orphanedEntriesProp = Config.GetType().GetProperty("OrphanedEntries", BindingFlags.NonPublic | BindingFlags.Instance);

var orphanedEntries = (Dictionary<ConfigDefinition, string>)orphanedEntriesProp.GetValue(Config, null);

orphanedEntries.Clear(); // Clear orphaned entries (Unbinded/Abandoned entries)
Config.Save(); // Save the config file