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"); } } }
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)))); // } // } }
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(); }
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 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()); }
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()); }
static PatchLoader() { var instance = new HarmonyLib.Harmony("trader_costs"); instance.PatchAll(Assembly.GetExecutingAssembly()); //FileLog.Log("Harmony Loaded"); }
public static void asdf(Engine engine) { //string compatibilityHash = "z1mXkIlayLh4CfmTTUbRJw=="; //var t = typeof(Engine); //t.GetProperty("CompatibilityHash").SetValue(engine, compatibilityHash, null); NeosVersionHelpers.OverrideHash(engine); Harmony.PatchAll(); }
public static HarmonyLib.Harmony PatchAll(Type type, HarmonyLib.Harmony harmonyInstance = null) { if (harmonyInstance == null) { return(HarmonyLib.Harmony.CreateAndPatchAll(type)); } harmonyInstance.PatchAll(type); return(harmonyInstance); }
public ModLootBoxes(ModContentPack content) : base(content) { Settings = GetSettings <ModSettingsLootBoxes>(); #if V10 var harmony = HarmonyInstance.Create("rimworld.lanilor.lootboxes"); #else var harmony = new HarmonyLib.Harmony("rimworld.lanilor.lootboxes"); #endif harmony.PatchAll(Assembly.GetExecutingAssembly()); }
internal void Awake() { try { var harmony = new HarmonyLib.Harmony(ID); harmony.PatchAll(); MyLogger.LogDebug("Awaken"); } catch (Exception ex) { MyLogger.LogError(ex.Message); } }
/// <summary> /// Attempts to apply all the Harmony patches in this assembly. /// </summary> internal static void ApplyHarmonyPatches() { try { Plugin.Log?.Debug("Applying Harmony patches."); harmony.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception ex) { Plugin.Log?.Error("Error applying Harmony patches: " + ex.Message); Plugin.Log?.Debug(ex); } }
public static HarmonyLib.Harmony CreateAndPatchAll(Type type) { var harmony = new HarmonyLib.Harmony(Guid.NewGuid().ToString()); harmony.PatchAll(type); foreach (var method in type.GetMethods(AccessTools.all)) { foreach (var attr in method.GetCustomAttributes <HarmonyPatchExtAttribute>(false)) { attr.Patch(harmony, method); } } return(harmony); }
public override void OnEnabled() { try { Instance = this; Harmony = new HarmonyLib.Harmony("rptoolkit.instance"); Harmony.PatchAll(); EventHandlers = new EventHandlers(); if (!Directory.Exists(Config.RPToolkitRootPath)) { Directory.CreateDirectory(Config.RPToolkitRootPath); } if (!File.Exists(Config.NamesPath)) { StreamWriter sw = File.CreateText(Config.NamesPath); sw.Write(Config.Names); sw.Close(); } if (!File.Exists(Config.SurnamesPath)) { StreamWriter sw = File.CreateText(Config.SurnamesPath); sw.Write(Config.Surnames); sw.Close(); } Util.Init(); Handlers.Server.RoundStarted += EventHandlers.OnRoundStart; Handlers.Server.RoundEnded += EventHandlers.OnRoundEnd; Handlers.Player.ChangingRole += EventHandlers.OnRoleChange; Handlers.Player.PickingUpItem += EventHandlers.OnItemPickup; Handlers.Player.ChangingItem += EventHandlers.OnChangingItem; Log.Info($"RPToolkit plugin loaded. @gamehunt"); } catch (Exception e) { Log.Error($"There was an error loading the plugin: {e}"); } }
static Patcher() { var harmony = new HarmonyLib.Harmony("TGPAcher.Rimworld.Spotted"); harmony.PatchAll(Assembly.GetExecutingAssembly()); // Patch incidents which do not have special "patch" var listOfIncidents = (from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() from assemblyType in domainAssembly.GetTypes() where typeof(IncidentWorker).IsAssignableFrom(assemblyType) select assemblyType).ToArray(); foreach (var incident in listOfIncidents) { if (ConfigDefOf.IncidentConfig.GetArgs().Contains(incident.FullName)) { harmony.Patch(AccessTools.Method(AccessTools.TypeByName(incident.FullName), "TryExecuteWorker"), new HarmonyMethod( typeof(IncidentWorker_TryExecuteWorker) .GetMethod(nameof(IncidentWorker_TryExecuteWorker.Prefix)))); } } }
static HarmonyPatchesFS() { HarmonyLib.Harmony harmony = new HarmonyLib.Harmony("rimworld.facialstuff.mod"); // HarmonyLib.Harmony.DEBUG = true; harmony.PatchAll(Assembly.GetExecutingAssembly()); harmony.Patch( AccessTools.Method(typeof(Page_ConfigureStartingPawns), "DrawPortraitArea"), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(AddFaceEditButton))); harmony.Patch( AccessTools.Method(typeof(PawnGraphicSet), nameof(PawnGraphicSet.ResolveAllGraphics)), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(ResolveAllGraphics_Postfix))); harmony.Patch( AccessTools.Method(typeof(PawnGraphicSet), nameof(PawnGraphicSet.ResolveApparelGraphics)), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(ResolveApparelGraphics_Postfix))); harmony.Patch( AccessTools.Method(typeof(PawnRenderer), nameof(PawnRenderer.DrawEquipmentAiming)), new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(DrawEquipmentAiming_Prefix)), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(DrawEquipmentAiming_Transpiler))); harmony.Patch( AccessTools.Method(typeof(PawnRenderer), nameof(PawnRenderer.RenderPawnAt), new[] { typeof(Vector3), typeof(RotDrawMode), typeof(bool), typeof(bool) }), // new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(HarmonyPatchesFS.RenderPawnAt)), null, null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(RenderPawnAt_Transpiler)) ); harmony.Patch( AccessTools.Method(typeof(HediffSet), nameof(HediffSet.DirtyCache)), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(DirtyCache_Postfix))); harmony.Patch( AccessTools.Method(typeof(GraphicDatabaseHeadRecords), nameof(GraphicDatabaseHeadRecords.Reset)), null, new HarmonyMethod( typeof(GraphicDatabaseHeadRecordsModded), nameof(GraphicDatabaseHeadRecordsModded.Reset))); harmony.Patch( AccessTools.Method(typeof(PawnHairChooser), nameof(PawnHairChooser.RandomHairDefFor)), new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(RandomHairDefFor_PreFix)), null); harmony.Patch( AccessTools.Method(typeof(PawnSkinColors), "GetSkinDataIndexOfMelanin"), new HarmonyMethod( typeof(PawnSkinColors_FS), nameof(PawnSkinColors_FS.GetSkinDataIndexOfMelanin_Prefix)), null); harmony.Patch( AccessTools.Method(typeof(PawnSkinColors), nameof(PawnSkinColors.GetSkinColor)), new HarmonyMethod(typeof(PawnSkinColors_FS), nameof(PawnSkinColors_FS.GetSkinColor_Prefix)), null); harmony.Patch( AccessTools.Method(typeof(PawnSkinColors), nameof(PawnSkinColors.RandomMelanin)), new HarmonyMethod(typeof(PawnSkinColors_FS), nameof(PawnSkinColors_FS.RandomMelanin_Prefix)), null); harmony.Patch( AccessTools.Method(typeof(PawnSkinColors), nameof(PawnSkinColors.GetMelaninCommonalityFactor)), new HarmonyMethod( typeof(PawnSkinColors_FS), nameof(PawnSkinColors_FS.GetMelaninCommonalityFactor_Prefix)), null); harmony.Patch( AccessTools.Method(typeof(Pawn_InteractionsTracker), nameof(Pawn_InteractionsTracker.TryInteractWith)), null, new HarmonyMethod(typeof(HarmonyPatchesFS), nameof(TryInteractWith_Postfix))); Log.Message( "Facial Stuff successfully completed " + harmony.GetPatchedMethods().Count() + " patches with harmony."); foreach (ThingDef def in DefDatabase <ThingDef> .AllDefsListForReading.Where( td => td.category == ThingCategory.Pawn && td.race.Humanlike)) { if (def.inspectorTabs == null || def.inspectorTabs.Count == 0) { def.inspectorTabs = new List <Type>(); def.inspectorTabsResolved = new List <InspectTabBase>(); } if (def.inspectorTabs.Contains(typeof(ITab_Pawn_Weapons))) { return; } def.inspectorTabs.Add(typeof(ITab_Pawn_Weapons)); def.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Weapons))); def.inspectorTabs.Add(typeof(ITab_Pawn_Face)); def.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Face))); } List <HairDef> beardyHairList = DefDatabase <HairDef> .AllDefsListForReading.Where(x => x.IsBeardNotHair()).ToList(); for (int i = 0; i < beardyHairList.Count(); i++) { HairDef beardy = beardyHairList[i]; if (beardy.label.Contains("shaven")) { continue; } BeardDef beardDef = new BeardDef { defName = beardy.defName, label = "_VHE_" + beardy.label, hairGender = beardy.hairGender, texPath = beardy.texPath.Replace("Things/Pawn/Humanlike/Beards/", ""), hairTags = beardy.hairTags, beardType = BeardType.FullBeard }; if (beardDef.label.Contains("stubble") || beardDef.label.Contains("goatee") || beardDef.label.Contains("lincoln")) { beardDef.drawMouth = true; } DefDatabase <BeardDef> .Add(beardDef); } Dialog_FaceStyling.FullBeardDefs = DefDatabase <BeardDef> .AllDefsListForReading.Where(x => x.beardType == BeardType.FullBeard) .ToList(); Dialog_FaceStyling.LowerBeardDefs = DefDatabase <BeardDef> .AllDefsListForReading.Where(x => x.beardType != BeardType.FullBeard) .ToList(); Dialog_FaceStyling.MoustacheDefs = DefDatabase <MoustacheDef> .AllDefsListForReading; CheckAllInjected(); }
static SnowshoesHarmonyPatcher() { Harmony Harmony = new HarmonyLib.Harmony("udal.rimworld.snowshoes"); Harmony.PatchAll(); }
static ZonesAndStorageModStartup() { var harmony = new HarmonyLib.Harmony("net.littlewhitemouse.RimWorld.ZonesAndStorage"); harmony.PatchAll(); }
public Main(ModContentPack content) : base(content) { var harmony = new HarmonyLib.Harmony("BloodTypes.Harmony"); harmony.PatchAll(Assembly.GetExecutingAssembly()); }