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))); }
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")); }
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")); }
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) { } }
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)); }
/// <summary> /// Applies all patches in the order they were sent in. /// </summary> /// <returns>Returns a bool value if all of the patches were successful or not</returns> public bool ApplyPatches() { try { DistanceLoader.Util.Logger.Instance.Log($"[ApplyPatches] We have {_patches.Count} patches to process!"); foreach (var patch in _patches) { DistanceLoader.Util.Logger.Instance.Log($"Attempting to patch {patch.originalMethod.Name} in {patch.originalMethod.DeclaringType.FullName}"); if (patch.isPostFix) { _harmonyInstance.Patch(patch.originalMethod, postfix: patch.patchedMethod); } else { _harmonyInstance.Patch(patch.originalMethod, patch.patchedMethod, null); } DistanceLoader.Util.Logger.Instance.Log($"Patching {patch.originalMethod.Name} successful."); } return(true); } catch (Exception ex) { DistanceLoader.Util.Logger.Instance.Log($"ERROR: {ex.Message}\r\n\r\n{ex.InnerException?.Message}"); return(false); } }
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")); } }
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")); }
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")); }
public static void DoExtraEquipmentPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Pawn), "GetGizmos"), postfix: new HarmonyMethod(typeof(Gizmos), "Pawn_GetGizmos_Postfix")); harm.Patch(AccessTools.Method(typeof(CompEquippable), "GetVerbsCommands"), new HarmonyMethod(typeof(Gizmos), "GetVerbsCommands_Prefix")); CreateVerbTargetCommand = AccessTools.Method(typeof(VerbTracker), "CreateVerbTargetCommand"); }
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")); }
public static void DoPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(WorkGiver_HunterHunt), "HasHuntingWeapon"), postfix: new HarmonyMethod(typeof(Hunting), "HasHuntingWeapon")); harm.Patch(AccessTools.Method(typeof(Toils_Combat), "TrySetJobToUseAttackVerb"), new HarmonyMethod(typeof(Hunting), "TrySetJobToUseAttackVerb")); harm.Patch(AccessTools.Method(typeof(JobDriver_Hunt), "MakeNewToils"), postfix: new HarmonyMethod(typeof(Hunting), "MakeNewToils")); }
public static void DoIndependentPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Verb), "get_Caster"), postfix: new HarmonyMethod(typeof(VerbPatches), "Postfix_get_Caster")); harm.Patch(AccessTools.Method(typeof(Verb), "get_CasterPawn"), postfix: new HarmonyMethod(typeof(VerbPatches), "Postfix_get_CasterPawn")); harm.Patch(AccessTools.Method(typeof(Verb), "get_CasterIsPawn"), postfix: new HarmonyMethod(typeof(VerbPatches), "Postfix_get_CasterIsPawn")); }
public static void Equipment(HarmonyLib.Harmony harm) { var type = typeof(Pawn_EquipmentTracker); harm.Patch(AccessTools.Method(type, "Notify_EquipmentAdded"), postfix: new HarmonyMethod(typeof(Trackers), "EquipmentAdded_Postfix")); harm.Patch(AccessTools.Method(type, "Notify_EquipmentRemoved"), postfix: new HarmonyMethod(typeof(Trackers), "EquipmentRemoved_Postfix")); }
public static void Apparel(HarmonyLib.Harmony harm) { var type = typeof(Pawn_ApparelTracker); harm.Patch(AccessTools.Method(type, "Notify_ApparelAdded"), postfix: new HarmonyMethod(typeof(Trackers), "ApparelAdded_Postfix")); harm.Patch(AccessTools.Method(type, "Notify_ApparelRemoved"), postfix: new HarmonyMethod(typeof(Trackers), "ApparelRemoved_Postfix")); }
public static void DoPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Pawn), "SpawnSetup"), postfix: new HarmonyMethod(typeof(IndependentVerbs), nameof(Postfix_Pawn_SpawnSetup))); harm.Patch(AccessTools.Method(typeof(Pawn), "DeSpawn"), postfix: new HarmonyMethod(typeof(IndependentVerbs), nameof(Postfix_Pawn_DeSpawn))); harm.Patch(AccessTools.Method(typeof(Pawn_StanceTracker), "SetStance"), new HarmonyMethod(typeof(IndependentVerbs), nameof(Pawn_StanceTracker_SetStance))); }
public static void DoExtraEquipmentPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Pawn), "GetGizmos"), postfix: new HarmonyMethod(typeof(Gizmos), "Pawn_GetGizmos_Postfix")); harm.Patch(AccessTools.Method(typeof(Command), "GizmoOnGUIInt"), transpiler: new HarmonyMethod(typeof(Gizmos), "GizmoOnGUI_Transpile")); harm.Patch(AccessTools.Method(typeof(CompEquippable), "GetVerbsCommands"), new HarmonyMethod(typeof(Gizmos), "GetVerbsCommands_Prefix")); }
public static void DoPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Constructor(typeof(BattleLogEntry_RangedImpact), new[] { typeof(Thing), typeof(Thing), typeof(Thing), typeof(ThingDef), typeof(ThingDef), typeof(ThingDef) }), new HarmonyMethod(typeof(BatteLog), nameof(FixFakeCaster))); harm.Patch(AccessTools.Method(typeof(PlayLogEntryUtility), "RulesForOptionalWeapon"), postfix: new HarmonyMethod(typeof(BatteLog), nameof(PlayLogEntryUtility_RulesForOptionalWeapon_Postfix))); }
public static void DoPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Alert_BrawlerHasRangedWeapon), "GetReport"), new HarmonyMethod(typeof(Brawlers), "GetReport_Prefix")); harm.Patch(AccessTools.Method(typeof(ThoughtWorker_IsCarryingRangedWeapon), "CurrentStateInternal"), new HarmonyMethod(typeof(Brawlers), "CurrentStateInternal_Prefix")); harm.Patch(AccessTools.Method(typeof(HealthCardUtility), "GenerateSurgeryOption"), postfix: new HarmonyMethod(typeof(Brawlers), "GenerateSurgeryOption_Postfix")); harm.Patch(AccessTools.Method(typeof(FloatMenuMakerMap), "AddHumanlikeOrders"), postfix: new HarmonyMethod(typeof(Brawlers), "AddHumanlikeOrders_Postfix")); }
public static void Hediffs(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(Pawn_HealthTracker), "AddHediff", new[] { typeof(Hediff), typeof(BodyPartRecord), typeof(DamageInfo), typeof(DamageWorker.DamageResult) }), postfix: new HarmonyMethod(typeof(Trackers), "AddHediff_Postfix")); harm.Patch(AccessTools.Method(typeof(Hediff), "PostRemoved"), postfix: new HarmonyMethod(typeof(Trackers), "PostRemoved_Postfix")); }
public static void Apply() { try { var harmony = new HarmonyLib.Harmony("BepInEx.Preloader.RuntimeFixes.HarmonyFixes"); harmony.Patch(AccessTools.Method(typeof(Traverse), nameof(Traverse.GetValue), new Type[0]), null, new HarmonyMethod(typeof(HarmonyFixes), nameof(GetValue))); harmony.Patch(AccessTools.Method(typeof(Traverse), nameof(Traverse.SetValue), new [] { typeof(object) }), null, new HarmonyMethod(typeof(HarmonyFixes), nameof(SetValue))); } catch (Exception e) { Logging.Logger.LogError(e); } }
public static void ApplyCompat(HarmonyLib.Harmony harm) { if (ModLister.HasActiveModWithName("RunAndGun")) { Log.Message("[MVCF] Applying RunAndGun compatibility patch"); harm.Patch(Type.GetType("RunAndGun.Harmony.Verb_TryCastNextBurstShot, RunAndGun") ?.GetMethod("SetStanceRunAndGun"), transpiler: new HarmonyMethod(typeof(Compat), "RunAndGunSetStance")); harm.Patch(Type.GetType("RunAndGun.Extensions, RunAndGun") ?.GetMethod("HasRangedWeapon"), postfix: new HarmonyMethod(typeof(Compat), "RunAndGunHasRangedWeapon")); } }
public static void DoPatches(HarmonyLib.Harmony harm) { harm.Patch(AccessTools.Method(typeof(VerbUtility), "IsEMP"), new HarmonyMethod(typeof(VerbUtilityPatches), "IsEMP_Prefix")); harm.Patch(AccessTools.Method(typeof(VerbUtility), "IsIncendiary"), new HarmonyMethod(typeof(VerbUtilityPatches), "IsIncendiary_Prefix")); harm.Patch(AccessTools.Method(typeof(VerbUtility), "UsesExplosiveProjectiles"), new HarmonyMethod(typeof(VerbUtilityPatches), "UsesExplosiveProjectiles_Prefix")); harm.Patch(AccessTools.Method(typeof(VerbUtility), "ProjectileFliesOverhead"), new HarmonyMethod(typeof(VerbUtilityPatches), "ProjectileFliesOverhead_Prefix")); harm.Patch(AccessTools.Method(typeof(VerbUtility), "HarmsHealth"), new HarmonyMethod(typeof(VerbUtilityPatches), "HarmsHealth_Prefix")); }
public static void ApplyPatches(HarmonyLib.Harmony harmony) { harmony.Patch(typeof(IKSolverHeuristic).GetMethods().First(m => m.Name.Equals("IsValid") && m.GetParameters().Length == 1), new HarmonyMethod(typeof(FinalIkPatches), nameof(IkSolverIsValid))); harmony.Patch(typeof(IKSolverAim).GetMethod(nameof(IKSolverAim.GetClampedIKPosition)), new HarmonyMethod(typeof(FinalIkPatches), nameof(IkSolverAimGetClampedIKPosition))); harmony.Patch(typeof(IKSolverFullBody).GetMethod(nameof(IKSolverFullBody.Solve)), new HarmonyMethod(typeof(FinalIkPatches), nameof(IKSolverFullBodySolve))); harmony.Patch(typeof(IKSolverFABRIKRoot).GetMethod(nameof(IKSolverFABRIKRoot.OnUpdate)), new HarmonyMethod(typeof(FinalIkPatches), nameof(IKSolverFABRIKRootOnUpdate))); }
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(); }
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); }
internal static void PatchPushPopRand(MethodBase method, HarmonyMethod transpiler = null) { giddyUpMultiplayerHarmony.Patch(method, prefix: new HarmonyMethod(typeof(MultiplayerPatch), nameof(FixRNGPre)), postfix: new HarmonyMethod(typeof(MultiplayerPatch), nameof(FixRNGPos)), transpiler: transpiler); }
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 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))); }
//// // 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))); }