Hello,
I am trying to improve my mod "WeaponStats" (https://steamcommunity.com/sharedfiles/filedetails/?id=974066449) by searching for weapons / apparel inside inventories (e.g. in [KV] Weapon Storage), but I do not want to add any of these mods as dependencies.
For example I could simply do:
foreach (WeaponStorage.Building_WeaponStorage ws in WeaponStorage.WorldComp.GetWeaponStorages(Find.CurrentMap))
{
foreach (ThingWithComps pth in ws.AllWeapons)
{ <code to add weapons to table> }
}
but this requires having WeaponStorage assembly as a dependency.
What is the best way out of this? I can use Reflection to some extent, but my knowledge is not deep enough (I can find out whether the WeaponStorage assembly is loaded, but that's all) - is Reflection best way to do this? Or should I try something different.. like create harmony patches for my own code (this I can do, but it would probably require lots of rewriting of the mod).
Thanks for help!
Generally mods are going to implement interfaces or extend classes from the base game that give most of the functionality that they need. Instead of searching for Building_WeaponStorage, why not look for Building_Storage (which includes derived classes)?