public bool IsApplicable(Game game)
        {
            var patchInfo = Harmony.GetPatchInfo(TargetMethodInfo);

            if (AlreadyPatchedByOthers(patchInfo))
            {
                return(false);
            }

            var bytes = TargetMethodInfo.GetCilBytes();

            if (bytes == null)
            {
                return(false);
            }

            var hash = bytes.GetSha256();

            return(hash.SequenceEqual(new byte[] {
                0x4C, 0x29, 0xDC, 0x2D, 0x78, 0x89, 0xA7, 0xA8,
                0xC6, 0xDA, 0x84, 0xDB, 0x07, 0x2E, 0x7D, 0xB4,
                0x99, 0xED, 0xB2, 0xB9, 0xC4, 0xBB, 0xAD, 0xE4,
                0xC9, 0xD1, 0xC8, 0x0F, 0xD7, 0x8C, 0x25, 0x15
            }));
        }
예제 #2
0
 public static void DoPatches(HarmonyLib.Harmony harm)
 {
     harm.Patch(AccessTools.Method(typeof(Verb), "OrderForceTarget"),
                new HarmonyMethod(typeof(VerbPatches), "Prefix_OrderForceTarget"));
     harm.Patch(AccessTools.Method(typeof(Verb), "get_EquipmentSource"),
                new HarmonyMethod(typeof(VerbPatches), "Prefix_EquipmentSource"));
 }
        static MeatShieldPatcher()
        {
            var          tp    = typeof(CoverUtils);
            BindingFlags attrs = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;

            FillageMethodReplacer = tp.GetMethod(nameof(CoverUtils.GetFillage), attrs);

            FillPercentageReplacer  = tp.GetMethod(nameof(CoverUtils.GetFillPercentage), attrs);
            FillPercentageTarget    = typeof(ThingDef).GetField(nameof(ThingDef.fillPercent), attrs);
            BaseBlockChanceReplacer = typeof(CoverUtils).GetMethod(nameof(CoverUtils.BaseBlockChance));
            BaseBlockChanceTarget   =
                typeof(CoverUtility).GetMethod(nameof(CoverUtility.BaseBlockChance), new Type[] { typeof(ThingDef) });
            FillageTarget = typeof(ThingDef)
                            .GetProperty(nameof(ThingDef.Fillage),
                                         attrs)
                            .GetGetMethod();

            ThingDefField = typeof(Thing).GetField(nameof(Thing.def));

            TranspilerMI = typeof(MeatShieldPatcher).GetMethod(nameof(Transpiler), attrs);

            var harmony = new HarmonyLib.Harmony(MeatShieldMod.MOD_ID);


            harmony.PatchAll();
            MassPatch(harmony);
        }
        public static bool CheckForCompetition(this HarmonyLib.Patches patches, HarmonyLib.Harmony domesticHarmoy, out string debugInfo, ReadOnlyCollection <string> ignoreList = null)
        {
            bool Result = CheckForCompetition(patches, domesticHarmoy, out StringBuilder debugInfoBuilder, ignoreList);

            debugInfo = debugInfoBuilder.ToString();
            return(Result);
        }
예제 #5
0
        public void TestMethod8()
        {
            var originalClass = typeof(Class8);

            Assert.IsNotNull(originalClass);
            var originalMethod = originalClass.GetMethod("Method8");

            Assert.IsNotNull(originalMethod);

            var patchClass = typeof(Class8Patch);
            var postfix    = patchClass.GetMethod("Postfix");

            Assert.IsNotNull(postfix);

            var instance = new HarmonyLib.Harmony("test");

            Assert.IsNotNull(instance);

            var patcher = instance.CreateProcessor(originalMethod);

            Assert.IsNotNull(patcher);
            patcher.AddPostfix(postfix);
            Assert.IsNotNull(patcher);

            patcher.Patch();

            var result = Class8.Method8("patched");

            Assert.IsTrue(Class8.mainRun);
            Assert.AreEqual(10, result.a);
            Assert.AreEqual(20, result.b);
        }
예제 #6
0
        public static void Apply()
        {
            if (Utility.CurrentOs == Platform.Windows)
            {
                return;
            }

            if (typeof(Console).Assembly.GetType("System.ConsoleDriver") == null)
            {
                // Mono version is too old, use our own TTY implementation instead
                return;
            }

            if (AccessTools.Method("System.TermInfoReader:DetermineVersion") != null)
            {
                // Fix has been applied officially
                return;
            }

            var harmony = new HarmonyLib.Harmony("com.bepinex.xtermfix");

            harmony.Patch(AccessTools.Method("System.TermInfoReader:ReadHeader"),
                          prefix: new HarmonyMethod(typeof(XTermFix), nameof(ReadHeaderPrefix)));

            harmony.Patch(AccessTools.Method("System.TermInfoReader:Get", new [] { AccessTools.TypeByName("System.TermInfoNumbers") }),
                          transpiler: new HarmonyMethod(typeof(XTermFix), nameof(GetTermInfoNumbersTranspiler)));

            harmony.Patch(AccessTools.Method("System.TermInfoReader:Get", new [] { AccessTools.TypeByName("System.TermInfoStrings") }),
                          transpiler: new HarmonyMethod(typeof(XTermFix), nameof(GetTermInfoStringsTranspiler)));

            harmony.Patch(AccessTools.Method("System.TermInfoReader:GetStringBytes", new [] { AccessTools.TypeByName("System.TermInfoStrings") }),
                          transpiler: new HarmonyMethod(typeof(XTermFix), nameof(GetTermInfoStringsTranspiler)));
        }
예제 #7
0
        static Harmony_Werewolf()
        {
            HarmonyLib.Harmony harmony = new HarmonyLib.Harmony("rimworld.facialstuff.werewolf_patch");

            try
            {
                ((Action)(() =>
                {
                    if (AccessTools.Method(
                            typeof(WerewolfUtility),
                            nameof(WerewolfUtility.IsClean)) == null)
                    {
                        return;
                    }

                    harmony.Patch(
                        AccessTools.Method(typeof(CompWerewolf), nameof(CompWerewolf.TransformInto)),
                        new HarmonyMethod(typeof(Werewolf_Patches), nameof(Werewolf_Patches.TransformInto_Prefix)),
                        null);

                    harmony.Patch(
                        AccessTools.Method(typeof(CompWerewolf), nameof(CompWerewolf.TransformBack)),
                        null,
                        new HarmonyMethod(
                            typeof(Werewolf_Patches),
                            nameof(Werewolf_Patches.TransformBack_Postfix)));
                }))();
            }
            catch (TypeLoadException)
            {
            }
        }
예제 #8
0
        public void TestMethod7()
        {
            var originalClass = typeof(Class7);

            Assert.IsNotNull(originalClass);
            var originalMethod = originalClass.GetMethod("Method7");

            Assert.IsNotNull(originalMethod);

            var patchClass = typeof(Class7Patch);
            var postfix    = patchClass.GetMethod("Postfix");

            Assert.IsNotNull(postfix);

            var instance = new HarmonyLib.Harmony("test");

            Assert.IsNotNull(instance);

            var patcher = instance.CreateProcessor(originalMethod);

            Assert.IsNotNull(patcher);
            patcher.AddPostfix(postfix);

            patcher.Patch();

            Class7.state2 = "before";
            var instance7 = new Class7();
            var result    = instance7.Method7("parameter");

            Console.WriteLine(Class7.state2);

            Assert.AreEqual("parameter", instance7.state1);
            Assert.AreEqual(10, result.a);
            Assert.AreEqual(20, result.b);
        }
예제 #9
0
        /// <summary>
        /// Unpatches patch.
        /// </summary>
        public static void SafeUnpatch(this HarmonyLib.Harmony harmony, Type patchType)
        {
            var metadata = patchType.GetCustomAttribute <SafePatchAttribute>();

            if (metadata == null)
            {
                ADOLib.Log($"Type {patchType} doesn't have SafePatch attribute.");
                return;
            }
            ADOLib.Log($"Unpatching {metadata.PatchId}");

            if (!metadata.IsEnabled)
            {
                ADOLib.Log($"{metadata.PatchId} is not patched!", LogType.Warning);
                return;
            }

            var classType = metadata.Assembly.GetType(metadata.ClassName);

            if (classType == null)
            {
                ADOLib.Log($"Type {metadata.ClassName} not found in assembly {metadata.Assembly}.");
                return;
            }

            var original = metadata.info.method;

            foreach (var patch in patchType.GetMethods())
            {
                harmony.Unpatch(original, patch);
            }

            metadata.IsEnabled = false;
            ADOLib.Log($"Successfully unpatched {metadata.PatchId}", LogType.Success);
        }
예제 #10
0
        public static void PatchCategory(this HarmonyLib.Harmony harmony, Type type)
        {
            ADOLib.Log($"Patching category {type}");
            var patchAttr = type.GetCustomAttribute <CategoryAttribute>();

            if (!patchAttr.isValid)
            {
                ADOLib.Log($"{type} is not valid for this ADOFAI version", LogType.Warning);
                return;
            }
            var patchClass = patchAttr.PatchClass;

            if (patchClass == null)
            {
                ADOLib.Log($"No patch class found in category {type}", LogType.Warning);
                return;
            }
            var patches = patchClass.GetNestedTypes(AccessTools.all).Where(t => t.GetCustomAttribute <SafePatchAttribute>() != null);

            foreach (var p in patches)
            {
                harmony.SafePatch(p);
            }
            ADOLib.Log($"Successfully patched category {type}", LogType.Success);
        }
예제 #11
0
 public static void DoExtraEquipmentPatches(HarmonyLib.Harmony harm)
 {
     harm.Patch(AccessTools.Method(typeof(ThingDef), "get_IsRangedWeapon"),
                new HarmonyMethod(typeof(MiscPatches), "Prefix_IsRangedWeapon"));
     harm.Patch(AccessTools.Method(typeof(FloatMenuMakerMap), "AddDraftedOrders"),
                transpiler: new HarmonyMethod(typeof(MiscPatches), "CheckForMelee"));
 }
예제 #12
0
        public static HarmonyLib.Harmony instance;              //Lt. Bob: 1.1

        static HarmonyMain()
        {
            //instance = HarmonyInstance.Create("DrCarlLuo.Rimworld.PreemptiveStrike");	//Lt. Bob: 1.1 - Replaced with below
            instance = new HarmonyLib.Harmony("DrCarlLuo.Rimworld.PreemptiveStrike");               //Lt. Bob: 1.1
            instance.PatchAll(Assembly.GetExecutingAssembly());
            ManualPatchings();
        }
예제 #13
0
        public void DoPatching()
        {
            var harmony = new HarmonyLib.Harmony("com.configfreaks.bundlepatcher");


            var assembly = typeof(AbstractGame).Assembly;
            var types    = assembly.GetTypes();

            var nodeInterfaceType = types.First(x => x.IsInterface && x.GetProperty("SameNameAsset") != null);

            _loaderType            = types.First(x => x.IsClass && x.GetProperty("SameNameAsset") != null);
            _bundleLockConstructor = types.First(x => x.IsClass && x.GetProperty("MaxConcurrentOperations") != null).GetConstructors().First();
            _loadState             = _loaderType.GetProperty("LoadState");
            _loadStateProperty     = _loadState.PropertyType.GetProperty("Value");
            _bundleField           = _loaderType.GetField("assetBundle_0", BindingFlags.Instance | BindingFlags.NonPublic);
            _taskField             = _loaderType.GetField("task_0", BindingFlags.Instance | BindingFlags.NonPublic);

            var originalLoader     = _loaderType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(x => x.GetParameters().Length == 0 && x.ReturnType == typeof(Task));
            var _loaderConstructor = _loaderType.GetConstructors().First();
            var getNodeType        = types
                                     .First(x => x.IsClass && x.GetMethod("GetNode") != null && string.IsNullOrWhiteSpace(x.Namespace)).MakeGenericType(nodeInterfaceType);
            var originalGetNodeConstructor = getNodeType.GetConstructors().First();

            var loaderPrefix      = typeof(Loader).GetMethod("LoaderPrefix", BindingFlags.Static | BindingFlags.Public);
            var loaderConstructor =
                typeof(Loader).GetMethod(nameof(LoaderConstructor), BindingFlags.Static | BindingFlags.Public);
            var getNodeContructor =
                typeof(Loader).GetMethod(nameof(NodeConstructor), BindingFlags.Static | BindingFlags.Public);

            harmony.Patch(originalLoader, new HarmonyMethod(loaderPrefix));
            harmony.Patch(_loaderConstructor, new HarmonyMethod(loaderConstructor));
            harmony.Patch(originalGetNodeConstructor, new HarmonyMethod(getNodeContructor));
        }
예제 #14
0
        public static bool LoadRimHUDCompatibility(HarmonyLib.Harmony instance, ModContentPack mod)
        {
            Assembly rimhudAssembly = mod.assemblies.loadedAssemblies.FirstOrDefault((Assembly assembly) => assembly.GetName().Name == "RimHUD");

            if (rimhudAssembly == null)
            {
                Log.Message("banish.animals : RimHUD installed, but not loaded or unexpected AssemblyName", false);
            }
            else
            {
                System.Type type = rimhudAssembly.GetType("RimHUD.Interface.InspectPanePlus");

                if (type != null)
                {
                    MethodInfo method = type.GetMethod("DrawButtons", BindingFlags.Static | BindingFlags.NonPublic);

                    if (method != null)
                    {
                        instance.Patch(method, null, new HarmonyMethod(typeof(BanishButton).GetMethod("DrawBanishButton", BindingFlags.Static | BindingFlags.Public)));
                        Log.Message("banish.animals : RimHUD installed, PostFix_InspectPanePlus_DrawButtons patched", false);
                        return(true);
                    }
                    else
                    {
                        Log.Message("banish.animals : RimHUD installed, could not find patch method name", false);
                    }
                }
                else
                {
                    Log.Message("banish.animals : RimHUD installed, could not find patch type", false);
                }
            }

            return(false);
        }
 public static void DoPatches(HarmonyLib.Harmony harm)
 {
     harm.Patch(AccessTools.Method(typeof(Pawn), "TryGetAttackVerb"),
                new HarmonyMethod(typeof(Pawn_TryGetAttackVerb), "Prefix"),
                new HarmonyMethod(typeof(Pawn_TryGetAttackVerb), "Postfix"));
     AggressiveJobs = new List <JobDef>
     {
         // Vanilla:
         JobDefOf.AttackStatic,
         JobDefOf.AttackMelee,
         JobDefOf.UseVerbOnThing,
         JobDefOf.UseVerbOnThingStatic,
         // Misc. Training:
         DefDatabase <JobDef> .GetNamedSilentFail("ArcheryShootArrows"),
         DefDatabase <JobDef> .GetNamedSilentFail("UseShootingRange"),
         DefDatabase <JobDef> .GetNamedSilentFail("UseShootingRange_NonJoy"),
         DefDatabase <JobDef> .GetNamedSilentFail("UseMartialArtsTarget"),
         DefDatabase <JobDef> .GetNamedSilentFail("UseMartialArtsTarget_NonJoy"),
         // Combat Training and Forked Version:
         DefDatabase <JobDef> .GetNamedSilentFail("TrainOnCombatDummy"),
         // Human Resources:
         DefDatabase <JobDef> .GetNamedSilentFail("TrainWeapon"),
         DefDatabase <JobDef> .GetNamedSilentFail("PlayAtDummy"),
         DefDatabase <JobDef> .GetNamedSilentFail("PlayAtTarget")
     }.Where(def => def != null).ToList();
 }
예제 #16
0
        static RestrictedStorage()
        {
            var harmony = new HarmonyLib.Harmony("net.littlewhitemouse.RimWorld.RestrictedStorage");

            harmony.PatchAll();
            // Add ITab and Comp to proper storage buildings:
            //   Add to all Building_Storage but not ones in Production (hoppers?)
            // This should be slightly faster than xpath xml patching.
            var desigProduction = DefDatabase <DesignationCategoryDef> .GetNamed("Production");

            var itabResolved = InspectTabManager.GetSharedInstance(typeof(ITab_RestrictedStorage));

            foreach (var b in DefDatabase <ThingDef> .AllDefs
                     .Where(d => (d?.thingClass != null &&
                                  (d.thingClass == typeof(Building_Storage) ||
                                   d.thingClass.IsSubclassOf(typeof(Building_Storage)))))
                     .Where(d => d.designationCategory != desigProduction))
            {
                // This should be the equivalent of
                //   <comps>
                //     <li>
                //       <compClass>CompRestrictedStorage</compClass>etc
                if (b.comps != null)
                {
                    b.comps.Add(new CompProperties {
                        compClass = typeof(CompRestrictedStorage)
                    });
                }
                else
                {
                    Log.Message("LWM.Restricted Storage: " + b + " does not have comps");
                    continue;
                }
                // but....we don't actually want to add this comp to EVERYTHING - I mean, why
                // bother?  It's not going to be used in the majority of cases.  Except...
                // the game won't load save-game-data unless the comp is already there.  Yes...
                // So we do add it to everything.
                //
                // On the other hand, we DO want to use the ITab for all storage buildings:
                // This mirrors ThingDef's resolve references - I didn't want to take the time
                //   to do a ResolveReferences for every single ThingDef, but if anything
                //   breaks, that's always an option...
                if (b.inspectorTabs != null)
                {
                    b.inspectorTabs.Add(typeof(ITab_RestrictedStorage));
                    if (b.inspectorTabsResolved != null)
                    {
                        b.inspectorTabsResolved.Add(itabResolved);
                    }
                    else
                    {
                        Log.Message("LWM.Restricted Storage: " + b + " does not have inspectorTabsResolved");
                    }
                }
                else
                {
                    Log.Message("LWM.Restricted Storage: " + b + " does not have inspectorTabs");
                }
            }
        }
예제 #17
0
        public Module(ModContentPack content) : base(content)
        {
            Log.Message("Frontier Developments Shields :: Loading Crash Landing support");

            var harmony = new HarmonyLib.Harmony("FrontierDevelopment.Shields.CrashLanding");

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            Harmony_Projectile.BlacklistType(typeof(CrashPod));

            // var baseType = Type.GetType("CrashLanding.CrashPod, CrashLanding");
            // var types = baseType.AllSubclassesNonAbstract();
            // var blockingTypes = "";
            //
            // foreach (var current in types)
            // {
            //     blockingTypes += current.Name + " ";
            //
            //     if (current.Name.Contains("_part"))
            //     {
            //         harmony.Patch(
            //             current.GetMethod("Impact", BindingFlags.NonPublic | BindingFlags.Instance),
            //             new HarmonyMethod(typeof(CrashPodHandler).GetMethod(nameof(CrashPodHandler.CrashPod_Part_Impact_Prefix))));
            //     }
            //     else
            //     {
            //         harmony.Patch(
            //             current.GetMethod("Impact", BindingFlags.NonPublic | BindingFlags.Instance),
            //             new HarmonyMethod(typeof(CrashPodHandler).GetMethod(nameof(CrashPodHandler.CrashPod_Impact_Prefix))));
            //     }
            // }
        }
예제 #18
0
        public override void OnApplicationStart()
        {
            var harmonyinf = new HarmonyLib.Harmony("PhasmophobiaPlayerCount"); // Sadly have to install 0harmony because ML is shit.

            harmonyinf.Patch(AccessTools.Method(typeof(LobbyManager), "CreateServer"), new HarmonyMethod(typeof(Main), "CreateServerFix"));
            harmonyinf.Patch(AccessTools.Method(typeof(ServerListItem), "SetUI"), new HarmonyMethod(typeof(Main), "UiFix"));
        }
예제 #19
0
        public static void ApplyFix()
        {
            TraceImplType = AppDomain.CurrentDomain.GetAssemblies()
                            .First(x => x.GetName().Name == "System")
                            .GetTypes()
                            .FirstOrDefault(x => x.Name == "TraceImpl");
            // assembly that has already fixed this
            if (TraceImplType == null)
            {
                return;
            }

            ListenersSyncRoot = AccessTools.Property(TraceImplType, "ListenersSyncRoot").GetValue(null, null);

            Listeners = (TraceListenerCollection)AccessTools.Property(TraceImplType, "Listeners").GetValue(null, null);

            prop_AutoFlush = AccessTools.Property(TraceImplType, "AutoFlush");


            HarmonyLib.Harmony instance = new HarmonyLib.Harmony("com.bepis.bepinex.tracefix");

            instance.Patch(
                typeof(Trace).GetMethod("DoTrace", BindingFlags.Static | BindingFlags.NonPublic),
                new HarmonyMethod(typeof(TraceFix).GetMethod(nameof(DoTraceReplacement), BindingFlags.Static | BindingFlags.NonPublic)));
        }
        public bool IsApplicable(Game game)
        {
            var patchInfo = Harmony.GetPatchInfo(TargetMethodInfo);

            if (AlreadyPatched(patchInfo))
            {
                return(false);
            }

            var bytes = TargetMethodInfo.GetCilBytes();

            if (bytes == null)
            {
                return(false);
            }

            var hash = bytes.GetSha256();

            return(hash.SequenceEqual(new byte[] {
                0x31, 0x81, 0x47, 0x2b, 0x6a, 0xde, 0xc8, 0x26,
                0x37, 0x68, 0xb3, 0x81, 0x0a, 0x47, 0x57, 0x51,
                0x37, 0x30, 0xa4, 0xa4, 0xb3, 0xde, 0xa7, 0x59,
                0x1a, 0x75, 0x90, 0x8a, 0x18, 0xdf, 0xa7, 0x2b
            }));
        }
예제 #21
0
파일: Gizmos.cs 프로젝트: legodude17/MVCF
 public static void DoHumanoidPatches(HarmonyLib.Harmony harm)
 {
     harm.Patch(AccessTools.Method(typeof(Pawn_DraftController), "GetGizmos"),
                postfix: new HarmonyMethod(typeof(Gizmos), "GetGizmos_Postfix"));
     harm.Patch(AccessTools.Method(typeof(PawnAttackGizmoUtility), "GetAttackGizmos"),
                postfix: new HarmonyMethod(typeof(Gizmos), "GetAttackGizmos_Postfix"));
 }
예제 #22
0
파일: Compat.cs 프로젝트: legodude17/MVCF
        public static void ApplyCompat(HarmonyLib.Harmony harm)
        {
            if (ModLister.HasActiveModWithName("RunAndGun") && Base.Features.EnabledAtAll)
            {
                Log.Message("[MVCF] Applying RunAndGun compatibility patch");
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryCastNextBurstShot, RunAndGun"),
                                              "SetStanceRunAndGun"),
                           transpiler: new HarmonyMethod(typeof(Compat), "RunAndGunSetStance"));
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryStartCastOn, RunAndGun"),
                                              "Prefix"),
                           new HarmonyMethod(typeof(Compat), "RunAndGunVerbCast"));
                harm.Patch(Type.GetType("RunAndGun.Extensions, RunAndGun")
                           ?.GetMethod("HasRangedWeapon"),
                           postfix: new HarmonyMethod(typeof(Compat), "RunAndGunHasRangedWeapon"));
            }

            if (ModLister.HasActiveModWithName("Dual Wield") && Base.Features.HumanoidVerbs)
            {
                Log.Message("[MVCF] Applying Dual Wield compatibility patch");
                GetStancesOffHand = AccessTools.Method(Type.GetType(
                                                           "DualWield.Ext_Pawn, DualWield"), "GetStancesOffHand")
                                    .CreateDelegate(typeof(Func <Pawn, Pawn_StanceTracker>));
                IsOffHand = AccessTools.Method(Type.GetType(
                                                   "DualWield.Ext_ThingWithComps, DualWield"), "IsOffHand")
                            .CreateDelegate(typeof(Func <ThingWithComps, bool>));
                harm.Patch(
                    Type.GetType("DualWield.Harmony.Pawn_RotationTracker_UpdateRotation, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    new HarmonyMethod(typeof(Compat), "UpdateRotation"));
                harm.Patch(
                    Type.GetType("DualWield.Harmony.PawnRenderer_RenderPawnAt, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    new HarmonyMethod(typeof(Compat), "RenderPawnAt"));
            }
        }
예제 #23
0
        public override void OnApplicationStart()
        {
            FileBasedPrefs.SetInt("PlayersMoney", 999999);
            var harmInst = new HarmonyLib.Harmony("PhagmoInfMoney");

            harmInst.Patch(AccessTools.Method(typeof(StoreManager), "BuyButton"), postfix: new HarmonyMethod(typeof(Main), "BuyFix"));
            harmInst.Patch(AccessTools.Method(typeof(AntiCheatSystem), "CheckPlayerMoney"), new HarmonyMethod(typeof(Main), "IgnoreMethod"));
        }
예제 #24
0
        public static void PatchPostfix <TClassToPatch, TMyPatchClass>(this HarmonyLib.Harmony harmonyInstance, string methodToPatch, string myPatchMethod)
        {
            var classToPatch = typeof(TClassToPatch);
            var myPatchClass = typeof(TMyPatchClass);
            var methodInfo   = classToPatch.GetMethod(methodToPatch);

            harmonyInstance.Patch(methodInfo, postfix: new HarmonyMethod(AccessTools.Method(myPatchClass, myPatchMethod)));
        }
예제 #25
0
        ////
        // Postfix patches
        ////
        public static void PatchPostfix <TClassToPatch, TMyPatchClass>(this HarmonyLib.Harmony harmonyInstance, int constructorIndex, string myPatchMethod)
        {
            var classToPatch = typeof(TClassToPatch);
            var myPatchClass = typeof(TMyPatchClass);
            var constructor  = classToPatch.GetConstructors()[constructorIndex];

            harmonyInstance.Patch(constructor, postfix: new HarmonyMethod(AccessTools.Method(myPatchClass, myPatchMethod)));
        }
예제 #26
0
        public static void PatchPrefix <TClassToPatch, TMyPatchClass>(this HarmonyLib.Harmony harmonyInstance, string methodToPatch, int methodOverloadIndex, string myPatchMethod)
        {
            var classToPatch = typeof(TClassToPatch);
            var myPatchClass = typeof(TMyPatchClass);
            var methodInfo   = classToPatch.GetMethods(methodToPatch)[methodOverloadIndex];

            harmonyInstance.Patch(methodInfo, prefix: new HarmonyMethod(AccessTools.Method(myPatchClass, myPatchMethod)));
        }
예제 #27
0
 public static void Patch(HarmonyObj obj)
 {
     if (obj.GetPatchedMethods().Any(x => x == coreGame))
     {
         obj.Unpatch(coreGame, transpiler);
     }
     obj.Patch(coreGame, null, null, new HarmonyMethod(transpiler));
 }
예제 #28
0
        public Module(ModContentPack content) : base(content)
        {
            Log.Message("Frontier Developments Shields :: Loading Centralized Climate Control (Continued) support");

            var harmony = new HarmonyLib.Harmony("FrontierDevelopment.Shields.ClimateControl");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
        }
        // List of assemblies to patch
        //public static IEnumerable<string> TargetDLLs => GetDLLs();
        //
        //public static IEnumerable<string> GetDLLs()
        //{
        //    // Do something before patching Assembly-CSharp.dll
        //
        //    Log("GetDLLs.Assembly-CSharp.dll");
        //    yield return "Assembly-CSharp.dll";
        //
        //    // Do something after Assembly-CSharp has been patched, and before UnityEngine.dll has been patched
        //
        //    Log("GetDLLs.UnityEngine.dll");
        //    yield return "UnityEngine.dll";
        //
        //    // Do something after patching is done
        //}

        // Called before patching occurs
        public static void Initialize()
        {
            Log("Initialize start");
            //HarmonyLib.Harmony.CreateAndPatchAll(typeof(Patcher));
            //var harmony = new HarmonyLib.Harmony("BepInEx.Lilly.Patcher.Patcher");
            instance = HarmonyLib.Harmony.CreateAndPatchAll(typeof(Patcher), "BepInEx.Lilly.Patcher.Patcher");
            Log("Initialize end");
        }
예제 #30
0
        public Module(ModContentPack content) : base(content)
        {
            Log.Message("Frontier Developments Shields :: Loading Dubs Bad Hygiene support");

            var harmony = new HarmonyLib.Harmony("FrontierDevelopment.Shields.BadHygiene");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
        }