is a Custom FloatMenuMaker possible?

Started by Kailen_, December 17, 2015, 08:27:24 PM

Previous topic - Next topic

Kailen_

Hi, just got into modding Rimworld and although I have a fair amount of experience with c# it is pretty much all writing crap from scratch so I am rarely trying to override anything. I really want to change some of the methods in the static class RimWorld.FloatMenuMaker but can't seem to find a way to override it in anyway seeing as its static and doesn't seem to be defined in any of the XML as the mousebuttons don't seem to be rebindable. I also can't recall any other mods that do this.

Thanks.

Fluffy (l2032)

Short answer, no.

Long answer; you need to provide and alternative (mostly copy-pasta) class with the same functionality, and change all calls to the original to your alternative. Of course, you can't change many of the alternatives either, so you end up rerouting half the game. (EdB interface does this, actually replacing the root UI element.) This is a) a heck of a lot of work, and b) very likely uncompatible with other mods that do anything with the classes you're replacing.

An alternative would be something called detouring, where you use some tricks to 'detour' the compiled function pointers to whatever function you want. Theoretically this would allow you to reroute all calls of function Foo(x) to Bar(x), providing truly limitless modding potential (as well as truly monumental opportunities for bugs). This has been done in other games (cities skylines that I know of), but as of writing this I'm not aware of anyone having figured it out for 32 bit unity4/mono. It's also well above my skill levels, as you have to muck about with assembly code and have intimate knowledge of how it all works on the lowest level(s).

Kailen_

Thanks, I actually started down the trail of rerouting the UI but realized it went so far back it would be a huge pain in the ass. I didn't realize EdB interface did that, I might have to take a look at theirs.

I wonder how much he would gain by updating the game to unity 5