Workaround Needed

Started by FueledByOCHD, August 12, 2018, 10:41:03 PM

Previous topic - Next topic

FueledByOCHD

Hello so in the middle of working on my mod i found out that i can not directly override or patch the constant fields of GenDate, does anyone know a way of making a constant field return something other then it is supposed to?

RawCode

"constant" is just flag for compiler, check is value inlined, if not just use reflection.

if value is inlined, you will need to replace code of methods, as changing field won't have any effect.

FueledByOCHD

As the guy that worked on harmony and the Zombieland code said, harmony is for patching methods, not fields. I tried to use the transverse class to set the value of the fields, but it said that constant fields can not be changed so atm i have no way of patching them so the seasons and game use my longer time system, and i cant get the time to work right

FueledByOCHD

So maybe someone can tell me, could i use dnspy to edit the fields to turn them into properties and then package the exe with my mod so that way the function would be compatable. although that will make the steam version throw some bugs i belive

RawCode

you can't change field into property without rebuilding entire assembly, it will fail to bind at runtime othervice.

FueledByOCHD

Yea i will probably just end up patching the methods of the game so that way they use my modded code

LWM

You could use the Harmony Transpiler to replace every line with the hardcoded constant fields with a line that uses your own data?

Not super elegant, but you may not have any options, given limitations of compile-time constant fields.

If you rebuild the entire rimworld assembly, you could probably play with it just fine, but uploading it as a mod....doesn't seem quite right.  Don't know if you could do that if you use Steam, either.  I wouldn't go that route!

--LWM