Removing mod-content through C# and HugsLib settings?

Started by Mlie, January 12, 2020, 02:47:01 PM

Previous topic - Next topic

Mlie

Hello
I am trying to create a setting for my mod to be able to remove some Things from it through a setting, using HugsLib.
The problem is that I cannot simply use HugsLib references in my mod since I dont want all subscribers to have to add HugsLib to be able to use it.

I have found the advanced example for creating a setting in a try/catch from the bottom of the guide:
https://github.com/UnlimitedHugs/RimworldHugsLib/wiki/Adding-Mod-Settings

The issue is that I cannot figure out on how I can modify my xml. Can anyone help me out?

LWM

If you want examples, there are plenty out there of people who use Settings that are not HugsLib based (Deep Storage, a bunch of Mehni's mods, I think Common Sense, etc).

As far as removing content, it's not too hard via C#:


DefsDatabase.AllDefs<ThingDef/TerrainDef/PopsicleFlavorDef/Etc>().Remove(myDef); // If you have the def on hand
DefsDatabase.AllDefs<ThingDef/TerrainDef/PopsicleFlavorDef/Etc>().RemoveAll(x=>x.defName=="defNameYouWantToRemove"); // if you have the defname, etc.


It gives you a List of the defType you request, and if you remove it from the database, you remove it from the game.

Have fun, don't break anything :)