Incident Not Initialised. It’s a fairly informative error message. It tells me that I’ve broken one of my mods again.

To explain in more detail, I had a lucky break today when I released a broken update for a mod on Steam and here on the site. I might not have noticed the problem until some irate user complained about getting errors. As it turned out, I had a feeling that I’d done something wrong, so I loaded up RimWorld and did a bit of basic testing, finding an error right away.

This isn’t the first time I’ve managed to break a mod that was working fine by adding a new wrinkle and then not doing all the necessary testing. In future, I’ll have to stop and think about whether I’ve really covered all the possible cases.

Because I didn’t. I loaded up an existing save, didn’t see anything immediately wrong, and then I went ahead and updated the mod on Workshop. What I should have done was start a new game and fired the Solar Flare incident at least once. 😛

However, I did come up with a fairly neat solution to the problem.

Basically, my modded incident worker in the original DLL did not inherit the necessary features to work properly, because I goofed and set it to inherit directly from IncidentWorker, instead of IncidentWorker_MakeMapCondition.

What a dumb mistake that was. Maybe I meant to type that in full or copy and paste, but obviously that didn’t happen and now I’m writing this cautionary tale.

I don’t have a code repository and I wasn’t at home so I had to copy my mod from the Workshop directory, decompile my DLL, and make a new project to patch it. The decompile wasn’t clean because I didn’t think to download Zhentar’s awesome fork of ILSpy from his GitHub. So I had to fix a few little things here and there.

Maybe now I will consider the benefits of using a repository.

Anyway, the neat part is that instead of overwriting the entire DLL, I just needed to add a second one and point to that one instead from the incident XML file. The broken class is still there in the original DLL, but it isn’t referenced.

Good enough for a quick fix.

Obviously, this isn’t an impressive feat in the eyes of a professional coder. But that’s not the audience I’m writing for. There’s plenty of modders out there, experimenting with all sorts of interesting stuff that they might not know the ins and outs of.

If one of them is you, the point I’m trying to make is that your projects don’t need to be single monolithic screeds of code. They can be modular. And it might make it easier to fix things when they go wrong.

Obviously for the purposes of efficiency you might want some things to be bundled up in the same library, but it doesn’t always have to be so.

Thanks for reading. 🙂