示例#1
0
        static AdditionalVerbPatch()
        {
            HarmonyInstance harmonyInstance = HarmonyInstance.Create("com.AdditionalVerb.rimworld.mod");

            if (!harmonyInstance.HasAnyPatches("com.AdditionalVerb.rimworld.mod"))
            {
                harmonyInstance.Patch(AccessTools.Method(typeof(Pawn_EquipmentTracker), "GetGizmos", null, null), null, new HarmonyMethod(patchType, "GetGizmosPostfix", null));

                harmonyInstance.Patch(AccessTools.Method(typeof(Targeter), "BeginTargeting", new Type[] { typeof(Verb) }), new HarmonyMethod(patchType, "BeginTargetingPrefix", null));
                harmonyInstance.Patch(AccessTools.Method(typeof(Targeter), "OrderPawnForceTarget", null, null), null, new HarmonyMethod(patchType, "OrderPawnForceTargetPostfix", null));
                //harmonyInstance.Patch(AccessTools.Method(typeof(Targeter), "GetTargetingVerb", null, null), new HarmonyMethod(patchType, "GetTargetingVerbPrefix", null));
                harmonyInstance.Patch(AccessTools.Method(typeof(Targeter), "StopTargeting", null, null), new HarmonyMethod(patchType, "StopTargetingPrefix", null));

                harmonyInstance.Patch(AccessTools.Method(typeof(VerbTracker), "CreateVerbTargetCommand", null, null), new HarmonyMethod(patchType, "CreateVerbTargetCommandPrefix", null));
                harmonyInstance.Patch(AccessTools.Property(typeof(VerbTracker), "PrimaryVerb").GetGetMethod(), new HarmonyMethod(patchType, "PrimaryVerbPrefix", null));

                harmonyInstance.Patch(AccessTools.Method(typeof(VerbProperties), "AdjustedAccuracy", null, null), null, new HarmonyMethod(patchType, "AdjustedAccuracyPostfix", null));

                harmonyInstance.Patch(AccessTools.Method(typeof(TooltipUtility), "ShotCalculationTipString", null, null), new HarmonyMethod(patchType, "ShotCalculationTipStringPrefix", null));

                LongEventHandler.ExecuteWhenFinished
                (
                    delegate
                {
                    currentCommandTexture = ContentFinder <Texture2D> .Get("UI/Commands/Select");
                }
                );
            }
        }
        static DrawPatch()
        {
            HarmonyInstance harmonyInstance = HarmonyInstance.Create("com.SYS.rimworld.mod");

            if (!harmonyInstance.HasAnyPatches("com.SYS.rimworld.mod"))
            {
                harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());
            }
        }
示例#3
0
        private static void Patch(HarmonyInstance harmonyInstance)
        {
            if (harmonyInstance.HasAnyPatches("mod.mayall.compatibility.patches"))
            {
                return;
            }

            HarmonyInstance compatibilityInstance = HarmonyInstance.Create("mod.mayall.compatibility.patches");

            ConstructorInfo _KButtonEvent_Constructor = typeof(KButtonEvent).GetConstructor(new Type[] { typeof(KInputController), typeof(InputEventType), typeof(bool[]) });

            if (_KButtonEvent_Constructor == null)
            {
                Debug.LogError("Failed to apply compatibility patches! Expect stuff to be broken. \nError: Could not find KButtonEvent constructor to patch!");
            }

            else
            {
                HarmonyMethod postfix = new HarmonyMethod(typeof(Compatibility), "KButtonEvent_Constructor_Postfix");
                compatibilityInstance.Patch(_KButtonEvent_Constructor, null, postfix);
            }

            MethodInfo _GameInputMapping_FindEntry = typeof(GameInputMapping).GetMethod("FindEntry");

            if (_GameInputMapping_FindEntry == null)
            {
                Debug.LogError("Failed to apply compatibility patches! Expect stuff to be broken. \nError: Could not find GameInputMapping::FindEntry to patch!");
            }

            else
            {
                HarmonyMethod prefix = new HarmonyMethod(typeof(Compatibility), "GameInputMapping_FindEntry_Prefix");
                compatibilityInstance.Patch(_GameInputMapping_FindEntry, prefix);
            }

            MethodInfo _GameInputMapping_CompareActionKeyCodes = typeof(GameInputMapping).GetMethod("CompareActionKeyCodes");

            if (_GameInputMapping_CompareActionKeyCodes == null)
            {
                Debug.LogError("Failed to apply compatibility patches! Expect stuff to be broken. \nError: Could not find GameInputMapping::CompareActionKeyCodes to patch!");
            }

            else
            {
                HarmonyMethod prefix = new HarmonyMethod(typeof(Compatibility), "GameInputMapping_CompareActionKeyCodes_Prefix");
                compatibilityInstance.Patch(_GameInputMapping_CompareActionKeyCodes, prefix);
            }

            Debug.Log("Successfully applied compatibility patches!");
        }
示例#4
0
        /// <summary>
        ///     是否开启调试
        /// </summary>
        /// <param name="proxyType"></param>
        /// <returns></returns>
        public static bool IsSetupDebug(ProxyType proxyType)
        {
            Type loadType = ProxyHelper.GetType(proxyType);

            if (loadType == null)
            {
                throw new ProxyServiceException(string.Format("proxyType {0},{1} is not exist", proxyType.FullName,
                                                              proxyType.AssemblyName));
            }
            string          debugID  = GetDebugID(loadType.FullName);
            HarmonyInstance instance = HarmonyInstance.Create(debugID);

            return(instance.HasAnyPatches(debugID));
        }
示例#5
0
 public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
 {
     if (nextScene.name == "GameCore" && IsEnabled)
     {
         harmony.PatchAll(Assembly.GetExecutingAssembly());
         Spooper.Init();
     }
     else
     {
         if (harmony.HasAnyPatches("com.steven.happy.halloween"))
         {
             harmony.UnpatchAll("com.steven.happy.halloween");
         }
     }
 }
示例#6
0
 public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
 {
     if (nextScene.name == "GameCore" && isEnabled)
     {
         Logger.Log("Applying Harmony Patches");
         harmony.PatchAll(Assembly.GetExecutingAssembly());
     }
     else
     {
         if (harmony.HasAnyPatches(id))
         {
             Logger.Log("Removing Harmony Patches");
             harmony.UnpatchAll(id);
         }
     }
 }
示例#7
0
        /// <summary>
        ///     启用调试
        /// </summary>
        /// <returns></returns>
        public static bool SetupDebug(SQLDebugConfig debugConfig)
        {
            //设置参数
            SetConfig(debugConfig);
            HarmonyInstance instance = HarmonyInstance.Create(DebugID);

            if (instance.HasAnyPatches(DebugID))
            {
                instance.UnpatchAll(DebugID);
            }
            DebugGuid = Guid.NewGuid().ToString();
            try
            {
                if (debugConfig.IsContainInsert || debugConfig.IsContainDelete || debugConfig.IsContainUpdate ||
                    debugConfig.IsContainSelect)
                {
                    //启用SQL调试
                    Logger.Debug("启用SQL追踪:{0}", DebugGuid);
                    SetupSQLDebug(instance);
                }
                if (debugConfig.IsTraceBPSVTransaction || debugConfig.IsTraceCustomizeTransaction)
                {
                    //启用事务追踪
                    Logger.Debug("启用事务追踪:{0}", DebugGuid);
                    SetupTransactionScopeDebug(instance);
                }
            }
            catch (Exception ex)
            {
                try
                {
                    Logger.Debug("开启调试异常:{0}", DebugGuid);
                    Logger.Debug(ex);
                    //停止追踪
                    StopDebug();
                }
                catch (Exception)
                {
                }
                throw;
            }
            return(true);
        }
示例#8
0
        private static void Patch(HarmonyInstance harmonyInstance)
        {
            if (harmonyInstance.HasAnyPatches("mod.mayall.versiondisplayer.patches"))
            {
                return;
            }

            HarmonyInstance versionDisplayerInstance = HarmonyInstance.Create("mod.mayall.versiondisplayer.patches");

            MethodInfo _ModsScreen_OnActivate = typeof(ModsScreen).GetMethod("OnActivate", BindingFlags.NonPublic | BindingFlags.Instance);

            if (_ModsScreen_OnActivate == null)
            {
                Debug.LogError("Failed to apply version displayer patches! \nError: Could not find ModsScreen::OnActivate to patch!");
            }

            else
            {
                HarmonyMethod prefix = new HarmonyMethod(typeof(VersionDisplayer), "ModsScreen_OnActivate_Prefix");
                versionDisplayerInstance.Patch(_ModsScreen_OnActivate, prefix);
            }

            Debug.Log("Successfully applied version displayer patches!");
        }
示例#9
0
        /// <summary>
        ///     是否开启调试
        /// </summary>
        /// <returns></returns>
        public static bool IsSetupDebug()
        {
            HarmonyInstance instance = HarmonyInstance.Create(DebugID);

            return(instance.HasAnyPatches(DebugID));
        }
        // TODO, Chinese IME support
        public override void Load()
        {
            // Latest uses Mod.UpdateUI, added 0.10.1.2
            if (ModLoader.version < new Version(0, 10, 1, 2))
            {
                throw new Exception("\nThis mod uses functionality only present in the latest tModLoader. Please update tModLoader to use this mod\n\n");
            }

            instance = this;

            // Remember, this mod is NOT open source, don't steal these TagHandlers.
            ChatManager.Register <TagHandlers.LinkTagHandler>("l", "link");
            ChatManager.Register <TagHandlers.ImageTagHandler>("image");
            ChatManager.Register <TagHandlers.NPCTagHandler>("npc");
            ChatManager.Register <TagHandlers.ItemHoverFixTagHandler>("itemhover");
            //ChatManager.Register<TagHandlers.URLTagHandler>("u", "url");

            FieldInfo translationsField = typeof(Mod).GetField("translations", BindingFlags.Instance | BindingFlags.NonPublic);

            translations = (Dictionary <string, ModTranslation>)translationsField.GetValue(this);

            itemChecklistInstance = ModLoader.GetMod("ItemChecklist");
            if (itemChecklistInstance != null && itemChecklistInstance.Version < new Version(0, 2, 1))
            {
                itemChecklistInstance = null;
            }

            /*
             * Mod cheatSheet = ModLoader.GetMod("CheatSheet");
             * if (cheatSheet == null)
             * {
             */
            ToggleRecipeBrowserHotKey = RegisterHotKey("Toggle Recipe Browser", "OemCloseBrackets");
            QueryHoveredItemHotKey    = RegisterHotKey("Query Hovered Item", "Mouse3");

            /*
             *      CheatSheetLoaded = false;
             * }
             * else
             * {
             *      ToggleRecipeBrowserHotKey = null;
             *      CheatSheetLoaded = true;
             * }
             */
            if (!Main.dedServ /*&& !CheatSheetLoaded*/)
            {
                recipeBrowserTool = new RecipeBrowserTool();
                UIElements.UIRecipeSlot.favoritedBackgroundTexture           = GetTexture("Images/FavoritedOverlay");
                UIElements.UIRecipeSlot.selectedBackgroundTexture            = GetTexture("Images/SelectedOverlay");
                UIElements.UIRecipeSlot.ableToCraftBackgroundTexture         = GetTexture("Images/CanCraftBackground");
                UIElements.UIRecipeSlot.ableToCraftExtendedBackgroundTexture = GetTexture("Images/CanCraftExtendedBackground");
                UIElements.UIMockRecipeSlot.ableToCraftBackgroundTexture     = GetTexture("Images/CanCraftBackground");
                UIElements.UICheckbox.checkboxTexture  = GetTexture("UIElements/checkBox");
                UIElements.UICheckbox.checkmarkTexture = GetTexture("UIElements/checkMark");
                UIHorizontalGrid.moreLeftTexture       = GetTexture("UIElements/MoreLeft");
                UIHorizontalGrid.moreRightTexture      = GetTexture("UIElements/MoreRight");
                Utilities.tileTextures = new Dictionary <int, Texture2D>();
            }

            harmonyInstance = HarmonyInstance.Create(HarmonyID);
            if (!harmonyInstance.HasAnyPatches(HarmonyID))             // In case Unload failed, don't double up.
            {
                harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());
            }
        }