How do I use Harmony to access an attribute of a compiler generated type?

Started by SamBucher, July 09, 2023, 08:13:36 AM

Previous topic - Next topic

SamBucher

I'm trying to make a mod that shows both eyes of a human pawn when it's facing east or west instead of just one. For that, I need to patch the PawnRenderer class and be able to read its CS$<>8__locals1 attribute. I can't treat it like a regular attribute since it's improperly named. While I figured out how to patch compiler generated methods, using compiler generated attributes within the patches is beyond my understanding at the moment. Any tips?

Image 1: method I'm trying to patch (aka replace with a prefix).You cannot view this attachment.
Image 2: the patch in its current form. The commented out snippet of code was to test if the patch was capable of targeting the method I needed, which it was. You cannot view this attachment.

SamBucher

Now that I have tried out ILSpy instead of dnSpy, I don't think I need to do anything this complicated. I just need to figure out how patch a local method (aka a method inside another method).

Kopp

Did you succeed?
I am curious because from my limited understanding of coding/harmony I would think that local stuff has to be changed by using a transpiler.