Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - CallMeDio

#1
Help / [Solved] Need help with Harmony Detour
June 12, 2017, 03:25:11 PM
After not modding since A14 im trying to recreate an old mod using harmony instead of ccl.
What im trying to do for this first test is replace the pawn.MainDesc with my method that returns "abc", this very first test has taken me more than 10 hours so far and no success, so time to ask for help as im sure this must be stupidly simple.
Current attempt:
namespace Stem_Cells
{
    [StaticConstructorOnStartup]
    class Main
    {
        static Main()
        {
            HarmonyInstance.DEBUG = true;
            var harmony = HarmonyInstance.Create("Dio.test.stmod");
            harmony.PatchAll(Assembly.GetExecutingAssembly());
        }
       
    }

    [HarmonyPatch(typeof(Pawn))]
    [HarmonyPatch("MainDesc")]
    static class PawnPatch
    {
        public static IEnumerable<CodeInstruction> Transpiler(
            MethodBase original,
            IEnumerable<CodeInstruction> instructions)
        {
            return instructions.MethodReplacer(
                AccessTools.Method(typeof(Pawn), "MainDesc"),
                AccessTools.Method(typeof(PawnPatch), "MainDescPatch"));
        }
        static string MainDescPatch(bool writeAge)
        {
            Log.Message("My method was executed");
           
            return "abc";
           
        }
    }
}



harmony log:
PATCHING Verse.Pawn System.String MainDesc(Boolean)
L_0000: Local var #0 System.String
L_0000: ldarg.0
L_0001: ldc.i4.1
L_0002: ldc.i4.1
L_0003: ldc.i4.0
L_0004: call System.String BestKindLabel(Verse.Pawn, Boolean, Boolean, Boolean)
L_0009: stloc.0
L_000a: ldarg.0
L_000b: call RimWorld.Faction get_Faction()
L_0010: brfalse Label #2
L_0015: ldarg.0
L_0016: call RimWorld.Faction get_Faction()
L_001b: ldfld RimWorld.FactionDef def
L_0020: ldfld System.Boolean hidden
L_0025: brtrue Label #3
L_002a: ldstr "PawnMainDescFactionedWrap"
L_002f: ldc.i4.2
L_0030: newarr System.Object
L_0035: dup
L_0036: ldc.i4.0
L_0037: ldloc.0
L_0038: stelem.ref
L_0039: dup
L_003a: ldc.i4.1
L_003b: ldarg.0
L_003c: call RimWorld.Faction get_Faction()
L_0041: callvirt System.String get_Name()
L_0046: stelem.ref
L_0047: call System.String Translate(System.String, System.Object[])
L_004c: stloc.0
L_004d: Label #2
L_004d: Label #3
L_004d: ldarg.1
L_004e: brfalse Label #4
L_0053: ldarg.0
L_0054: ldfld Verse.Pawn_AgeTracker ageTracker
L_0059: brfalse Label #5
L_005e: ldloc.0
L_005f: ldstr ", "
L_0064: ldstr "AgeIndicator"
L_0069: ldc.i4.1
L_006a: newarr System.Object
L_006f: dup
L_0070: ldc.i4.0
L_0071: ldarg.0
L_0072: ldfld Verse.Pawn_AgeTracker ageTracker
L_0077: callvirt System.String get_AgeNumberString()
L_007c: stelem.ref
L_007d: call System.String Translate(System.String, System.Object[])
L_0082: call System.String Concat(System.String, System.String, System.String)
L_0087: stloc.0
L_0088: Label #4
L_0088: Label #5
L_0088: ldloc.0
L_0089: call System.String CapitalizeFirst(System.String)
L_008e: br Label #0
L_0093: Label #0
L_0093: ret
DONE

PATCHING Verse.AreaManager Void ExposeData()
L_0000: ldarg.0
L_0001: call Void Prefix(Verse.AreaManager)
L_0006: ldarg.0
L_0007: ldflda System.Collections.Generic.List`1[Verse.Area] areas
L_000c: ldstr "areas"
L_0011: ldc.i4.2
L_0012: ldc.i4.0
L_0013: newarr System.Object
L_0018: call Void Look[Area](System.Collections.Generic.List`1[Verse.Area] ByRef, System.String, LookMode, System.Object[])
L_001d: ldsfld Verse.LoadSaveMode mode
L_0022: ldc.i4.2
L_0023: bne.un Label #2
L_0028: ldarg.0
L_0029: call Void UpdateAllAreasLinks()
L_002e: Label #2
L_002e: br Label #0
L_0033: Label #0
L_0033: ret
DONE

PATCHING RimWorld.PlaySettings Void DoPlaySettingsGlobalControls(Verse.WidgetRow, Boolean)
L_0000: Local var #0 System.Boolean
L_0000: Local var #1 System.Boolean
L_0000: Local var #2 System.Boolean
L_0000: Local var #3 System.Boolean
L_0000: ldarg.0
L_0001: ldfld System.Boolean showColonistBar
L_0006: stloc.0
L_0007: ldarg.2
L_0008: brfalse Label #2
L_000d: call ProgramState get_ProgramState()
L_0012: ldc.i4.2
L_0013: bne.un Label #3
L_0018: ldarg.1
L_0019: ldarg.0
L_001a: ldflda System.Boolean showColonistBar
L_001f: ldsfld UnityEngine.Texture2D ShowColonistBar
L_0024: ldstr "ShowColonistBarToggleButton"
L_0029: call System.String Translate(System.String)
L_002e: ldsfld Verse.SoundDef MouseoverToggle
L_0033: ldnull
L_0034: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0039: Label #3
L_0039: ldarg.0
L_003a: ldfld System.Boolean lockNorthUp
L_003f: stloc.1
L_0040: ldarg.1
L_0041: ldarg.0
L_0042: ldflda System.Boolean lockNorthUp
L_0047: ldsfld UnityEngine.Texture2D LockNorthUp
L_004c: ldstr "LockNorthUpToggleButton"
L_0051: call System.String Translate(System.String)
L_0056: ldsfld Verse.SoundDef MouseoverToggle
L_005b: ldnull
L_005c: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0061: ldloc.1
L_0062: ldarg.0
L_0063: ldfld System.Boolean lockNorthUp
L_0068: beq Label #4
L_006d: ldarg.0
L_006e: ldfld System.Boolean lockNorthUp
L_0073: brfalse Label #5
L_0078: call RimWorld.Planet.WorldCameraDriver get_WorldCameraDriver()
L_007d: ldc.i4.1
L_007e: callvirt Void RotateSoNorthIsUp(Boolean)
L_0083: Label #4
L_0083: Label #5
L_0083: ldarg.1
L_0084: ldarg.0
L_0085: ldflda System.Boolean usePlanetDayNightSystem
L_008a: ldsfld UnityEngine.Texture2D UsePlanetDayNightSystem
L_008f: ldstr "UsePlanetDayNightSystemToggleButton"
L_0094: call System.String Translate(System.String)
L_0099: ldsfld Verse.SoundDef MouseoverToggle
L_009e: ldnull
L_009f: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00a4: ldarg.1
L_00a5: ldarg.0
L_00a6: ldflda System.Boolean expandingIcons
L_00ab: ldsfld UnityEngine.Texture2D ExpandingIcons
L_00b0: ldstr "ExpandingIconsToggleButton"
L_00b5: call System.String Translate(System.String)
L_00ba: ldsfld Verse.SoundDef MouseoverToggle
L_00bf: ldnull
L_00c0: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00c5: br Label #6
L_00ca: Label #2
L_00ca: ldarg.1
L_00cb: ldarg.0
L_00cc: ldflda System.Boolean showLearningHelper
L_00d1: ldsfld UnityEngine.Texture2D ShowLearningHelper
L_00d6: ldstr "ShowLearningHelperWhenEmptyToggleButton"
L_00db: call System.String Translate(System.String)
L_00e0: ldsfld Verse.SoundDef MouseoverToggle
L_00e5: ldnull
L_00e6: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00eb: ldarg.1
L_00ec: ldarg.0
L_00ed: ldflda System.Boolean showZones
L_00f2: ldsfld UnityEngine.Texture2D ShowZones
L_00f7: ldstr "ZoneVisibilityToggleButton"
L_00fc: call System.String Translate(System.String)
L_0101: ldsfld Verse.SoundDef MouseoverToggle
L_0106: ldnull
L_0107: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_010c: ldarg.1
L_010d: ldarg.0
L_010e: ldflda System.Boolean showEnvironment
L_0113: ldsfld UnityEngine.Texture2D ShowEnvironment
L_0118: ldstr "ShowEnvironmentToggleButton"
L_011d: call System.String Translate(System.String)
L_0122: ldsfld Verse.SoundDef MouseoverToggle
L_0127: ldstr "InspectRoomStats"
L_012c: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0131: ldarg.1
L_0132: ldarg.0
L_0133: ldflda System.Boolean showColonistBar
L_0138: ldsfld UnityEngine.Texture2D ShowColonistBar
L_013d: ldstr "ShowColonistBarToggleButton"
L_0142: call System.String Translate(System.String)
L_0147: ldsfld Verse.SoundDef MouseoverToggle
L_014c: ldnull
L_014d: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0152: ldarg.1
L_0153: ldarg.0
L_0154: ldflda System.Boolean showRoofOverlay
L_0159: ldsfld UnityEngine.Texture2D ShowRoofOverlay
L_015e: ldstr "ShowRoofOverlayToggleButton"
L_0163: call System.String Translate(System.String)
L_0168: ldsfld Verse.SoundDef MouseoverToggle
L_016d: ldnull
L_016e: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0173: ldarg.1
L_0174: ldarg.0
L_0175: ldflda System.Boolean autoHomeArea
L_017a: ldsfld UnityEngine.Texture2D AutoHomeArea
L_017f: ldstr "AutoHomeAreaToggleButton"
L_0184: call System.String Translate(System.String)
L_0189: ldsfld Verse.SoundDef MouseoverToggle
L_018e: ldnull
L_018f: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0194: call Boolean get_ResourceReadoutCategorized()
L_0199: stloc.2
L_019a: ldloc.2
L_019b: stloc.3
L_019c: ldarg.1
L_019d: ldloca.s 2 (System.Boolean)
L_019f: ldsfld UnityEngine.Texture2D CategorizedResourceReadout
L_01a4: ldstr "CategorizedResourceReadoutToggleButton"
L_01a9: call System.String Translate(System.String)
L_01ae: ldsfld Verse.SoundDef MouseoverToggle
L_01b3: ldnull
L_01b4: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_01b9: ldloc.2
L_01ba: ldloc.3
L_01bb: beq Label #7
L_01c0: ldloc.2
L_01c1: call Void set_ResourceReadoutCategorized(Boolean)
L_01c6: Label #6
L_01c6: Label #7
L_01c6: ldloc.0
L_01c7: ldarg.0
L_01c8: ldfld System.Boolean showColonistBar
L_01cd: beq Label #8
L_01d2: call RimWorld.ColonistBar get_ColonistBar()
L_01d7: callvirt Void MarkColonistsDirty()
L_01dc: Label #8
L_01dc: br Label #0
L_01e1: Label #0
L_01e1: ldarg 1
L_01e7: ldarg 2
L_01ed: call Void Postfix(Verse.WidgetRow, Boolean)
L_01f2: ret
DONE

PATCHING Verse.Pawn System.String MainDesc(Boolean)
L_0000: Local var #0 System.String
L_0000: ldarg.0
L_0001: ldc.i4.1
L_0002: ldc.i4.1
L_0003: ldc.i4.0
L_0004: call System.String BestKindLabel(Verse.Pawn, Boolean, Boolean, Boolean)
L_0009: stloc.0
L_000a: ldarg.0
L_000b: call RimWorld.Faction get_Faction()
L_0010: brfalse Label #2
L_0015: ldarg.0
L_0016: call RimWorld.Faction get_Faction()
L_001b: ldfld RimWorld.FactionDef def
L_0020: ldfld System.Boolean hidden
L_0025: brtrue Label #3
L_002a: ldstr "PawnMainDescFactionedWrap"
L_002f: ldc.i4.2
L_0030: newarr System.Object
L_0035: dup
L_0036: ldc.i4.0
L_0037: ldloc.0
L_0038: stelem.ref
L_0039: dup
L_003a: ldc.i4.1
L_003b: ldarg.0
L_003c: call RimWorld.Faction get_Faction()
L_0041: callvirt System.String get_Name()
L_0046: stelem.ref
L_0047: call System.String Translate(System.String, System.Object[])
L_004c: stloc.0
L_004d: Label #2
L_004d: Label #3
L_004d: ldarg.1
L_004e: brfalse Label #4
L_0053: ldarg.0
L_0054: ldfld Verse.Pawn_AgeTracker ageTracker
L_0059: brfalse Label #5
L_005e: ldloc.0
L_005f: ldstr ", "
L_0064: ldstr "AgeIndicator"
L_0069: ldc.i4.1
L_006a: newarr System.Object
L_006f: dup
L_0070: ldc.i4.0
L_0071: ldarg.0
L_0072: ldfld Verse.Pawn_AgeTracker ageTracker
L_0077: callvirt System.String get_AgeNumberString()
L_007c: stelem.ref
L_007d: call System.String Translate(System.String, System.Object[])
L_0082: call System.String Concat(System.String, System.String, System.String)
L_0087: stloc.0
L_0088: Label #4
L_0088: Label #5
L_0088: ldloc.0
L_0089: call System.String CapitalizeFirst(System.String)
L_008e: br Label #0
L_0093: Label #0
L_0093: ret
DONE

PATCHING Verse.AreaManager Void ExposeData()
L_0000: ldarg.0
L_0001: call Void Prefix(Verse.AreaManager)
L_0006: ldarg.0
L_0007: ldflda System.Collections.Generic.List`1[Verse.Area] areas
L_000c: ldstr "areas"
L_0011: ldc.i4.2
L_0012: ldc.i4.0
L_0013: newarr System.Object
L_0018: call Void Look[Area](System.Collections.Generic.List`1[Verse.Area] ByRef, System.String, LookMode, System.Object[])
L_001d: ldsfld Verse.LoadSaveMode mode
L_0022: ldc.i4.2
L_0023: bne.un Label #2
L_0028: ldarg.0
L_0029: call Void UpdateAllAreasLinks()
L_002e: Label #2
L_002e: br Label #0
L_0033: Label #0
L_0033: ret
DONE

PATCHING RimWorld.PlaySettings Void DoPlaySettingsGlobalControls(Verse.WidgetRow, Boolean)
L_0000: Local var #0 System.Boolean
L_0000: Local var #1 System.Boolean
L_0000: Local var #2 System.Boolean
L_0000: Local var #3 System.Boolean
L_0000: ldarg.0
L_0001: ldfld System.Boolean showColonistBar
L_0006: stloc.0
L_0007: ldarg.2
L_0008: brfalse Label #2
L_000d: call ProgramState get_ProgramState()
L_0012: ldc.i4.2
L_0013: bne.un Label #3
L_0018: ldarg.1
L_0019: ldarg.0
L_001a: ldflda System.Boolean showColonistBar
L_001f: ldsfld UnityEngine.Texture2D ShowColonistBar
L_0024: ldstr "ShowColonistBarToggleButton"
L_0029: call System.String Translate(System.String)
L_002e: ldsfld Verse.SoundDef MouseoverToggle
L_0033: ldnull
L_0034: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0039: Label #3
L_0039: ldarg.0
L_003a: ldfld System.Boolean lockNorthUp
L_003f: stloc.1
L_0040: ldarg.1
L_0041: ldarg.0
L_0042: ldflda System.Boolean lockNorthUp
L_0047: ldsfld UnityEngine.Texture2D LockNorthUp
L_004c: ldstr "LockNorthUpToggleButton"
L_0051: call System.String Translate(System.String)
L_0056: ldsfld Verse.SoundDef MouseoverToggle
L_005b: ldnull
L_005c: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0061: ldloc.1
L_0062: ldarg.0
L_0063: ldfld System.Boolean lockNorthUp
L_0068: beq Label #4
L_006d: ldarg.0
L_006e: ldfld System.Boolean lockNorthUp
L_0073: brfalse Label #5
L_0078: call RimWorld.Planet.WorldCameraDriver get_WorldCameraDriver()
L_007d: ldc.i4.1
L_007e: callvirt Void RotateSoNorthIsUp(Boolean)
L_0083: Label #4
L_0083: Label #5
L_0083: ldarg.1
L_0084: ldarg.0
L_0085: ldflda System.Boolean usePlanetDayNightSystem
L_008a: ldsfld UnityEngine.Texture2D UsePlanetDayNightSystem
L_008f: ldstr "UsePlanetDayNightSystemToggleButton"
L_0094: call System.String Translate(System.String)
L_0099: ldsfld Verse.SoundDef MouseoverToggle
L_009e: ldnull
L_009f: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00a4: ldarg.1
L_00a5: ldarg.0
L_00a6: ldflda System.Boolean expandingIcons
L_00ab: ldsfld UnityEngine.Texture2D ExpandingIcons
L_00b0: ldstr "ExpandingIconsToggleButton"
L_00b5: call System.String Translate(System.String)
L_00ba: ldsfld Verse.SoundDef MouseoverToggle
L_00bf: ldnull
L_00c0: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00c5: br Label #6
L_00ca: Label #2
L_00ca: ldarg.1
L_00cb: ldarg.0
L_00cc: ldflda System.Boolean showLearningHelper
L_00d1: ldsfld UnityEngine.Texture2D ShowLearningHelper
L_00d6: ldstr "ShowLearningHelperWhenEmptyToggleButton"
L_00db: call System.String Translate(System.String)
L_00e0: ldsfld Verse.SoundDef MouseoverToggle
L_00e5: ldnull
L_00e6: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_00eb: ldarg.1
L_00ec: ldarg.0
L_00ed: ldflda System.Boolean showZones
L_00f2: ldsfld UnityEngine.Texture2D ShowZones
L_00f7: ldstr "ZoneVisibilityToggleButton"
L_00fc: call System.String Translate(System.String)
L_0101: ldsfld Verse.SoundDef MouseoverToggle
L_0106: ldnull
L_0107: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_010c: ldarg.1
L_010d: ldarg.0
L_010e: ldflda System.Boolean showEnvironment
L_0113: ldsfld UnityEngine.Texture2D ShowEnvironment
L_0118: ldstr "ShowEnvironmentToggleButton"
L_011d: call System.String Translate(System.String)
L_0122: ldsfld Verse.SoundDef MouseoverToggle
L_0127: ldstr "InspectRoomStats"
L_012c: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0131: ldarg.1
L_0132: ldarg.0
L_0133: ldflda System.Boolean showColonistBar
L_0138: ldsfld UnityEngine.Texture2D ShowColonistBar
L_013d: ldstr "ShowColonistBarToggleButton"
L_0142: call System.String Translate(System.String)
L_0147: ldsfld Verse.SoundDef MouseoverToggle
L_014c: ldnull
L_014d: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0152: ldarg.1
L_0153: ldarg.0
L_0154: ldflda System.Boolean showRoofOverlay
L_0159: ldsfld UnityEngine.Texture2D ShowRoofOverlay
L_015e: ldstr "ShowRoofOverlayToggleButton"
L_0163: call System.String Translate(System.String)
L_0168: ldsfld Verse.SoundDef MouseoverToggle
L_016d: ldnull
L_016e: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0173: ldarg.1
L_0174: ldarg.0
L_0175: ldflda System.Boolean autoHomeArea
L_017a: ldsfld UnityEngine.Texture2D AutoHomeArea
L_017f: ldstr "AutoHomeAreaToggleButton"
L_0184: call System.String Translate(System.String)
L_0189: ldsfld Verse.SoundDef MouseoverToggle
L_018e: ldnull
L_018f: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_0194: call Boolean get_ResourceReadoutCategorized()
L_0199: stloc.2
L_019a: ldloc.2
L_019b: stloc.3
L_019c: ldarg.1
L_019d: ldloca.s 2 (System.Boolean)
L_019f: ldsfld UnityEngine.Texture2D CategorizedResourceReadout
L_01a4: ldstr "CategorizedResourceReadoutToggleButton"
L_01a9: call System.String Translate(System.String)
L_01ae: ldsfld Verse.SoundDef MouseoverToggle
L_01b3: ldnull
L_01b4: callvirt Void ToggleableIcon(Boolean ByRef, UnityEngine.Texture2D, System.String, Verse.SoundDef, System.String)
L_01b9: ldloc.2
L_01ba: ldloc.3
L_01bb: beq Label #7
L_01c0: ldloc.2
L_01c1: call Void set_ResourceReadoutCategorized(Boolean)
L_01c6: Label #6
L_01c6: Label #7
L_01c6: ldloc.0
L_01c7: ldarg.0
L_01c8: ldfld System.Boolean showColonistBar
L_01cd: beq Label #8
L_01d2: call RimWorld.ColonistBar get_ColonistBar()
L_01d7: callvirt Void MarkColonistsDirty()
L_01dc: Label #8
L_01dc: br Label #0
L_01e1: Label #0
L_01e1: ldarg 1
L_01e7: ldarg 2
L_01ed: call Void Postfix(Verse.WidgetRow, Boolean)
L_01f2: ret
DONE




no error, no log message,it simply doesn't replace the text with "abc"
sorry if it is a dumb question/post but I simply can't spot the problem
#2
Help / How to give 'white text' warnings?
August 09, 2016, 11:52:28 PM
Hey again, the title pretty much says it all, Im looking at the decompiler and xmls for hours and I can't find how to make an alert such as the one that happens when a colonist dies:
*blipsound* white text on top of screen: "guy x died".
#3
Help / Reflect variables?
August 09, 2016, 08:12:41 PM
Hello, Its me again with my problematic detours, I need to detour a method that reads and writes to a private variable of its class, do anyone have a example of how I can reflect variables?
Just a generic example or point me to a source code that haves it
#4
Help / Detouring this
August 05, 2016, 10:36:21 AM
Hey, I want to detour this function that is on Bill_Medical.cs :

public override void Notify_IterationCompleted(Pawn billDoer, List<Thing> ingredients)
{
base.Notify_IterationCompleted(billDoer, ingredients);
Pawn giverPawn = this.GiverPawn;
if (this.recipe.Worker.GetPartsToApplyOn(giverPawn, this.recipe).Contains(this.Part))
{
this.recipe.Worker.ApplyOnPawn(giverPawn, this.Part, billDoer, ingredients);
if (giverPawn.RaceProps.IsFlesh)
{
giverPawn.records.Increment(RecordDefOf.OperationsReceived);
billDoer.records.Increment(RecordDefOf.OperationsPerformed);
}
}
this.billStack.Delete(this);
}



I based myself on the CCL detour and detour injector source and saw all that is injected is written as internal static, so Im lost on how to deal with the "this" and how can I use this values on my version as they come from other parts of the file.
Its my first detour, spent more hours than I think its necessary on this, I need some help.
#5
Help / How can i decompile this ?
August 03, 2016, 11:43:15 AM
Hello, Im making my first .dll mod and the hardest parts are already done. I just need to get usable code from this somehow because what I need is in there and I don't know how to:


[DebuggerHidden]
public virtual IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
RecipeWorker.<GetPartsToApplyOn>c__IteratorA4 <GetPartsToApplyOn>c__IteratorA = new RecipeWorker.<GetPartsToApplyOn>c__IteratorA4();
RecipeWorker.<GetPartsToApplyOn>c__IteratorA4 expr_07 = <GetPartsToApplyOn>c__IteratorA;
expr_07.$PC = -2;
return expr_07;
}


Full File:


using RimWorld;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Verse
{
public class RecipeWorker
{
public RecipeDef recipe;

[DebuggerHidden]
public virtual IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
RecipeWorker.<GetPartsToApplyOn>c__IteratorA4 <GetPartsToApplyOn>c__IteratorA = new RecipeWorker.<GetPartsToApplyOn>c__IteratorA4();
RecipeWorker.<GetPartsToApplyOn>c__IteratorA4 expr_07 = <GetPartsToApplyOn>c__IteratorA;
expr_07.$PC = -2;
return expr_07;
}

public virtual void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients)
{
}

public virtual bool IsViolationOnPawn(Pawn pawn, BodyPartRecord part, Faction billDoerFaction)
{
return pawn.Faction != billDoerFaction && this.recipe.isViolation;
}
}
}


I saw a thread where user RawCode said about a similar case on other file:

Quoteyou are missing internal class c__IteratorDD that contains all logic in pretty linear way.
you must enable "compiler\internal" code to see that type.

this is how iterators and enums actually looks, with a bit more skill you will be able to read such code without issues.

But how is that supposed to work out? I already tried changing this on ILSpy and also other settings without success and im not experienced enought to read it myself, how can I decompile this?