Ejemplo n.º 1
0
		private static void HookMethods()
		{
			if (ApplyBleedMethod != null)
			{
				HookEndpointManager.Modify(ApplyBleedMethod, (ILContext.Manipulator)DisableBleedHook);
			}
		}
Ejemplo n.º 2
0
        public static void Load()
        {
            ContainerLibrary.Hooking.AlchemyApplyChance += () => Main.LocalPlayer.inventory.Any(item => item.modItem is AlchemistBag);
            ContainerLibrary.Hooking.ModifyAdjTiles     += player => player.adjTile[TileID.Bottles] = player.inventory.Any(item => item.modItem is AlchemistBag);

            Player.TryPurchasing += (orig, price, inv, coins, empty, bank, bank2, bank3) => false;

            #region IL

            IL.Terraria.Player.HasAmmo   += Player_HasAmmo;
            IL.Terraria.Player.QuickBuff += Player_QuickBuff;
            IL.Terraria.Player.PickAmmo  += Player_PickAmmo;
            ItemSlot.DrawSavings         += ItemSlot_DrawSavings;
            ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += ItemSlot_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color;
            IL.Terraria.Player.QuickHeal_GetItemToUse += Player_QuickHeal_GetItemToUse;
            IL.Terraria.Player.QuickMana    += Player_QuickMana;
            IL.Terraria.Player.SellItem     += Player_SellItem;
            IL.Terraria.Player.BuyItem      += Player_BuyItem;
            IL.Terraria.Player.ItemCheck    += Player_ItemCheck;
            IL.Terraria.Player.FishingLevel += Player_FishingLevel;
            IL.Terraria.Player.GetItem      += Player_GetItem;
            HookEndpointManager.Modify(typeof(Terraria.Player).GetMethod("CanBuyItem", BaseLibrary.Utility.defaultFlags), new Action <ILContext>(Player_CanBuyItem));

            #endregion
        }
Ejemplo n.º 3
0
        public override void Unload()
        {
            try
            {
                SaveConfig();

                HookEndpointManager.RemoveAllOwnedBy(this);
                HarmonyInstance.UnpatchAll(nameof(Localizer));
                Kernel.Dispose();

                HarmonyInstance = null;
                Kernel          = null;
                _gameCultures   = null;
                Config          = null;
                Instance        = null;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            finally
            {
                _initiated = false;
                Log        = null;
            }

            base.Unload();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// TitleContainer.OpenStream throws an error if it's fed a path that starts with '..\', treating paths like that as absolute, for some reason.
        /// </summary>
        public static void Init()
        {
#if XNA
            //Can't believe that this is enough, lmao.
            HookEndpointManager.Add(typeof(TitleContainer).FindMethod("IsCleanPathAbsolute"), new Func <string, bool>(path => false));
#endif
        }
Ejemplo n.º 5
0
        public override void Unload()
        {
            try
            {
                SaveConfig();

                PluginManager.UnloadPlugins();

                HookEndpointManager.RemoveAllOwnedBy(this);

                Kernel.Dispose();

                Kernel        = null;
                _gameCultures = null;
                Instance      = null;
                Config        = null;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            finally
            {
                Log = null;
            }

            base.Unload();
        }
Ejemplo n.º 6
0
        public void Destroy()
        {
            Instance = null;

            ModConfigCatalog.Remove(ModConfig);

            HookEndpointManager.Remove(onCurrentArtifactDiscovered, (Action <Action <ArtifactTrialMissionController, ArtifactDef>, ArtifactTrialMissionController, ArtifactDef>)OnCurrentArtifactDiscovered);
        }
Ejemplo n.º 7
0
        public void Import(IFile file, IMod mod)
        {
            if (file.GetType() != typeof(LdstrFile))
            {
                return;
            }

            var module = HookEndpointManager.GenerateCecilModule(mod.Code.GetName());

            var entryDict = (file as LdstrFile).LdstrEntries;

            foreach (var entryPair in entryDict)
            {
                var md = module.FindMethod(entryPair.Key);
                if (md == null)
                {
                    continue;
                }

                var method = MethodBase.GetMethodFromHandle(md.ResolveReflection().MethodHandle);

                var e = entryPair.Value;

                if (!HaveTranslation(e))
                {
                    continue;
                }

                var modification = new ILContext.Manipulator(il =>
                {
                    foreach (var instruction in il.Instrs)
                    {
                        var ins = e.Instructions.FirstOrDefault(i => instruction.MatchLdstr(i.Origin));
                        if (ins == null || string.IsNullOrEmpty(ins.Translation))
                        {
                            continue;
                        }

                        instruction.Operand = ins.Translation;

                        foreach (var label in il.Labels)
                        {
                            if (label.Target.MatchLdstr(ins.Origin))
                            {
                                label.Target = instruction;
                            }
                        }
                    }
                });

                if (!modifications.ContainsKey(method))
                {
                    HookEndpointManager.Modify(method, modification);
                    modifications.Add(method, modification);
                }
            }
        }
Ejemplo n.º 8
0
        public override void Unload()
        {
            IL.InputHandler.OnGUI -= OnGUI;

            HookEndpointManager.Unmodify
            (
                MethodBase.GetMethodFromHandle(typeof(ModHooks).GetMethod("OnCursor", BindingFlags.Instance | BindingFlags.NonPublic).MethodHandle),
                (ILContext.Manipulator) OnCursor
            );
        }
Ejemplo n.º 9
0
        public override void Unload()
        {
            base.Unload();

            SaveConfig();

            PluginManager.UnloadPlugins();

            HookEndpointManager.RemoveAllOwnedBy(this);
        }
Ejemplo n.º 10
0
        public static void Initialize()
        {
            var nestedType = typeof(WorldGen).GetNestedType("<>c__DisplayClass343_0", BindingFlags.NonPublic | BindingFlags.Instance);
            var methodInfo = nestedType.GetMethod("<GenerateWorld>b__12", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            HookEndpointManager.Modify(methodInfo, new Action <ILContext>(GenerationPass_SmallHoles));
            Player.IsAValidEquipmentSlotForIteration += (orig, self, slot) =>
            {
                return(slot < 3 || slot == 10 || slot == 11 || slot == 12);
            };
        }
Ejemplo n.º 11
0
        internal static void RemoveAll(Mod mod)
        {
            if (mod is ModLoaderMod)
            {
                return;
            }

            foreach (var asm in AssemblyManager.GetModAssemblies(mod.Name))
            {
                HookEndpointManager.RemoveAllOwnedBy(asm);
            }
        }
Ejemplo n.º 12
0
        private static void HookIntoLoad()
        {
            MonoModHooks.RequestNativeAccess();
            new Hook(
                typeof(ModContent).GetMethod("LoadModContent", BindingFlags.NonPublic | BindingFlags.Static),
                typeof(Fargowiltas).GetMethod(nameof(LoadHook), BindingFlags.NonPublic | BindingFlags.Static)).Apply();

            HookEndpointManager.Modify(
                typeof(ModContent).GetMethod("Load", BindingFlags.NonPublic | BindingFlags.Static),
                Delegate.CreateDelegate(typeof(ILContext.Manipulator),
                                        typeof(Fargowiltas).GetMethod(nameof(ModifyLoading),
                                                                      BindingFlags.NonPublic | BindingFlags.Static) ?? throw new Exception("Couldn't create IL manipulator.")));
        }
Ejemplo n.º 13
0
        protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)
        {
            Terraria.ModLoader.ContentInstance.Register(Utils.GetModByName(mod.Name));
            var module = mod.Code.ManifestModule;

            var entryDict = file.LdstrEntries;

            foreach (var entryPair in entryDict)
            {
                var method = Utils.FindMethodByID(module, entryPair.Key);
                if (method == null)
                {
                    continue;
                }

                var e = entryPair.Value;

                if (!HaveTranslation(e))
                {
                    continue;
                }

                var modification = new ILContext.Manipulator(il =>
                {
                    foreach (var instruction in il.Instrs)
                    {
                        var ins = e.Instructions.FirstOrDefault(i => instruction.MatchLdstr(i.Origin));
                        if (ins == null || string.IsNullOrEmpty(ins.Translation))
                        {
                            continue;
                        }

                        instruction.Operand = ins.Translation;

                        foreach (var label in il.Labels)
                        {
                            if (label.Target.MatchLdstr(ins.Origin))
                            {
                                label.Target = instruction;
                            }
                        }
                    }
                });

                if (!modifications.ContainsKey(method))
                {
                    HookEndpointManager.Modify(method, modification);
                    modifications.Add(method, modification);
                }
            }
        }
Ejemplo n.º 14
0
        public void Awake()
        {
            Instance = this;

            IsEnabled = Config.Bind("Main", "enabled", true, "Should accumulate artifacts or not?");
            ModConfig = new ModConfigEntry
            {
                DisplayName = "Accumulative Artifacts",
                EnableField = new InLobbyConfig.Fields.BooleanConfigField("", () => IsEnabled.Value, (newValue) => IsEnabled.Value = newValue)
            };

            ModConfigCatalog.Add(ModConfig);
            HookEndpointManager.Add(onCurrentArtifactDiscovered, (Action <Action <ArtifactTrialMissionController, ArtifactDef>, ArtifactTrialMissionController, ArtifactDef>)OnCurrentArtifactDiscovered);
        }
Ejemplo n.º 15
0
        private void Awake()
        {
            Instance = this;

            //Add actions to RoR2.InputCatalog
            ExtraInputs.AddActionsToInputCatalog();

            //Hook to method with some rewired initialization (or not? Anyway it works) to add custom actions
            var userDataInit = typeof(UserData).GetMethod(nameof(UserData.KFIfLMJhIpfzcbhqEXHpaKpGsgeZ), BindingFlags.NonPublic | BindingFlags.Instance);

            HookEndpointManager.Add(userDataInit, (Action <Action <UserData>, UserData>)ExtraInputs.AddCustomActions);

            //Adding default keybindings
            On.RoR2.UserProfile.LoadDefaultProfile += ExtraInputs.OnLoadDefaultProfile;
            On.RoR2.UserProfile.LoadUserProfiles   += ExtraInputs.OnLoadUserProfiles;

            //Adding custom actions to Settings
            On.RoR2.UI.SettingsPanelController.Start += UIHooks.SettingsPanelControllerStart;

            //Adding custom skill slots to HUD
            On.RoR2.UI.HUD.Awake += UIHooks.HUDAwake;

            //Applying overrides to SkillLocator to use extra skills
            On.RoR2.SkillLocator.GetSkill      += ExtraSkillLocator.GetSkillOverrideHook;
            On.RoR2.SkillLocator.FindSkillSlot += ExtraSkillLocator.FindSkillSlotOverrideHook;

            On.RoR2.InputBankTest.CheckAnyButtonDown += ExtraInputBankTest.CheckAnyButtonDownOverrideHook;

            //Applying overrides to GenericCharacterMain to be able to use extra skills
            On.EntityStates.GenericCharacterMain.PerformInputs += ExtraGenericCharacterMain.PerformInputsOverrideHook;
            On.EntityStates.GenericCharacterMain.GatherInputs  += ExtraGenericCharacterMain.GatherInputsOverrideHook;

            //Applying override to BaseSkillState
            IL.EntityStates.SkillStateMethods.IsKeyDownAuthority += ExtraBaseSkillState.IsKeyDownAuthorityILHook;

            //Adding custom PlayerCharacterMasterController
            On.RoR2.PlayerCharacterMasterController.Awake   += ExtraPlayerCharacterMasterController.AwakeHook;
            On.RoR2.PlayerCharacterMasterController.SetBody += ExtraPlayerCharacterMasterController.SetBodyOverrideHook;

            //Applying Brainstalks and Purity cooldown effect to extra skills
            IL.RoR2.CharacterBody.RecalculateStats += ExtraCharacterBody.RecalculateStatsILHook;

            //Fixing getting extra skill slots for UI
            IL.RoR2.UI.LoadoutPanelController.Row.FromSkillSlot += UIHooks.LoadoutPanelControllerFromSkillSlot;

            On.RoR2.Language.LoadStrings += LanguageConsts.OnLoadStrings;

            NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append($"{GUID};{Version}");
            RoR2Application.isModded = true;
        }
Ejemplo n.º 16
0
        internal static void IlEditing(ILContext il)
        {
            MethodReference getItemReference = null;
            MethodReference setItemReference = null;

            foreach (var instruction in il.Body.Instructions)
            {
                if (instruction.OpCode == OpCodes.Ldftn)
                {
                    MethodReference function = (MethodReference)instruction.Operand;
                    if (!function.Name.Contains(_blacklistLoadFnt[0]) && !function.Name.Contains(_blacklistLoadFnt[1]) && !function.Name.Contains(_blacklistLoadFnt[2]))
                    {
                        InfWorld.Instance.Logger.Info("Loadfnt detected : " + function.Name);
                        HookEndpointManager.Modify(function.ResolveReflection(), new ILContext.Manipulator(IlEditing));
                    }
                }
                else if (instruction.OpCode == OpCodes.Ldsfld)
                {
                    if (instruction.Operand is FieldReference fieldRef && fieldRef.DeclaringType.FullName == "Terraria.Main" && fieldRef.Name == "tile")
                    {
                        FieldReference tileReference =
                            il.Module.ImportReference(typeof(InfWorld).GetField("Tile",
                                                                                BindingFlags.Public | BindingFlags.Static));
                        instruction.Operand = tileReference;
                    }
                }
                else if (instruction.OpCode == OpCodes.Call && instruction.Operand is Mono.Cecil.MethodReference reference)
                {
                    if (reference.FullName == ("Terraria.Tile Terraria.Tile[0...,0...]::Get(System.Int32,System.Int32)"))
                    {
                        instruction.OpCode = OpCodes.Callvirt;
                        if (getItemReference == null)
                        {
                            getItemReference = il.Import(getItem);
                        }
                        instruction.Operand = getItemReference;
                    }
                    else if (reference.FullName == ("System.Void Terraria.Tile[0...,0...]::Set(System.Int32,System.Int32,Terraria.Tile)"))
                    {
                        instruction.OpCode = OpCodes.Callvirt;
                        if (setItemReference == null)
                        {
                            setItemReference = il.Import(setItem);
                        }
                        instruction.Operand = setItemReference;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public void Export(IPackage package, IExportConfig config)
        {
            if (package?.Mod == null)
            {
                return;
            }

            var asm = package.Mod.Code;

            var file = new LdstrFile();

            file.LdstrEntries = new Dictionary <string, LdstrEntry>();

            foreach (var type in HookEndpointManager.GenerateCecilModule(asm.GetName()).GetTypes())
            {
                /* The return value of GetTypes() and other methods will include types they derived from.
                 * So we should check the namespace to ensure it belongs to the assembly, but there still are
                 * some issues. */
                if (type.Namespace == null || !type.Namespace.StartsWith(package.Mod.Name))
                {
                    continue;
                }

                foreach (var method in type.Methods)
                {
                    if (method.DeclaringType?.Namespace == null || !method.DeclaringType.Namespace.StartsWith(
                            package.Mod.Name) ||
                        method.IsAbstract)
                    {
                        continue;
                    }

                    try
                    {
                        var entry = GetEntryFromMethod(method);
                        if (entry != null && !file.LdstrEntries.ContainsKey(method.GetFindableID()))
                        {
                            file.LdstrEntries.Add(method.GetFindableID(), entry);
                        }
                    }
                    catch (Exception e)
                    {
                        Localizer.Log.Error(e.ToString());
                    }
                }
            }

            package.AddFile(file);
        }
Ejemplo n.º 18
0
        internal static void Load()
        {
            Instance = new ModuleSerializer();

            HookEndpointManager.Add <hook_TryGetSerializer>(typeof(TagSerializer).GetMethod("TryGetSerializer", ReflectionUtility.DefaultFlags_Static), (hook_TryGetSerializer)((orig_TryGetSerializer orig, Type type, out TagSerializer serializer) =>
            {
                if (type == typeof(BaseModule) || type.IsSubclassOf(typeof(BaseModule)))
                {
                    serializer = Instance;
                    return(true);
                }

                return(orig(type, out serializer));
            }));
        }
Ejemplo n.º 19
0
        internal static void Load()
        {
            Instance = new FluidSerializer();

            HookEndpointManager.Add <hook_TryGetSerializer>(typeof(TagSerializer).GetMethod("TryGetSerializer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (hook_TryGetSerializer)((orig_TryGetSerializer orig, Type type, out TagSerializer serializer) =>
            {
                if (type == typeof(BaseFluid) || type.IsSubclassOf(typeof(BaseFluid)))
                {
                    serializer = Instance;
                    return(true);
                }

                return(orig(type, out serializer));
            }));
        }
Ejemplo n.º 20
0
        private static void HookMethods()
        {
            if (RageStatMethod != null)
            {
                HookEndpointManager.Modify(RageStatMethod, (ILContext.Manipulator)DisableStatHook);

                if (!rageStatHook)
                {
                    HookEndpointManager.Unmodify(RageStatMethod, (ILContext.Manipulator)DisableStatHook);
                    Logger.Warn("[PlasmaSpikeStripCompat] - DisableStatHook Failed! - Removing Hook");
                }
            }

            if (CloakOnHitMethod != null)
            {
                HookEndpointManager.Modify(CloakOnHitMethod, (ILContext.Manipulator)DisableCloakHook);
            }
        }
Ejemplo n.º 21
0
        public static void Apply()
        {
            if (applied)
            {
                return;
            }

            applied = true;

            var a = typeof(CSharpFormattingOptions).Assembly;
            var t = a.GetType("Microsoft.CodeAnalysis.CSharp.Formatting.NewLineUserSettingFormattingRule");

            HookEndpointManager.Modify(t.FindMethod("GetAdjustNewLinesOperation"), (Action <ILContext>)HookAdjustOperation);
            HookEndpointManager.Modify(t.FindMethod("GetAdjustSpacesOperation"), (Action <ILContext>)HookAdjustOperation);

            t = a.GetType("Microsoft.CodeAnalysis.CSharp.Formatting.SuppressFormattingRule");
            HookEndpointManager.Modify(t.GetMethods((BindingFlags)(-1)).Single(m => m.Name == "AddInitializerSuppressOperations" && m.GetParameters().Length == 2), (Action <ILContext>)HookSuppressOperations);
        }
Ejemplo n.º 22
0
        public void Unload(Assembly asm)
        {
            if (asm == null || Ignored.Contains(asm))
            {
                return;
            }

            // Unload any HookGen hooks after unloading the mod.
            HookEndpointManager.RemoveAllOwnedBy(asm);
            if (OwnedDetourLists.TryGetValue(asm, out List <IDetour> list))
            {
                OwnedDetourLists.Remove(asm);
                foreach (IDetour detour in list)
                {
                    detour.Dispose();
                }
            }
        }
Ejemplo n.º 23
0
        public static void Initialize()
        {
            UIElement.GetElementAt += UIElement_GetElementAt;

            ItemSlot.LeftClick_ItemArray_int_int += ItemSlot_LeftClick;
            ItemSlot.DrawSavings += ItemSlot_DrawSavings;
            ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += ItemSlot_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color;

            Player.DropSelectedItem       += Player_DropSelectedItem;
            Player.BuyItem                += Player_BuyItem;
            Player.SellItem               += Player_SellItem;
            Player.TryPurchasing          += (orig, price, inv, coins, empty, bank, bank2, bank3) => false;
            Player.HasAmmo                += Player_HasAmmo;
            Player.PickAmmo               += Player_PickAmmo;
            Player.QuickHeal_GetItemToUse += Player_QuickHeal_GetItemToUse;
            Player.QuickMana              += Player_QuickMana;
            Player.QuickBuff              += Player_QuickBuff;

            HookEndpointManager.Add(typeof(Terraria.Player).GetMethod("CanBuyItem", Utility.defaultFlags), new Func <Func <Terraria.Player, int, int, bool>, Terraria.Player, int, int, bool>(Player_CanBuyItem));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// When Ionic.Zip extracts an entry it uses \\ for all separators when it should use Path.DirectorySeparatorChar for platform compatibility
        /// </summary>
        public static void Init()
        {
            if (Path.DirectorySeparatorChar == '\\')
            {
                return;
            }

            HookEndpointManager.Modify(typeof(ZipEntry).FindMethod("ValidateOutput"), new Action <ILContext>(il => {
                var c  = new ILCursor(il);
                c.Next = null;                 // move to end

                // outFileName = outFileName.Replace("/", "\\")
                c.GotoPrev(MoveType.Before,
                           i => i.MatchLdstr("\\"),
                           i => i.MatchCallvirt <string>("Replace"));

                // replace the constant "\\" with Path.DirectorySeparatorChar
                c.Next.Operand = Path.DirectorySeparatorChar.ToString();
            }));
        }
    static void OnUnloadContent(Action <Mod> orig, Mod mod)
    {
        orig(mod);

        if (mod.Code == null || mod is TerrariaHooksMod)
        {
            return;
        }

        // Unload any HookGen hooks after unloading the mod.
        HookEndpointManager.RemoveAllOwnedBy(mod.Code);
        if (OwnedDetourLists.TryGetValue(mod.Code, out List <IDetour> list))
        {
            OwnedDetourLists.Remove(mod.Code);
            foreach (IDetour detour in list)
            {
                detour.Dispose();
            }
        }
    }
Ejemplo n.º 26
0
        //public static bool autoFireEnabled=false;

        private void Awake()
        {
            instance = this;
            //On.RoR2.Networking.NetworkManagerSystem.OnClientConnect += (self, user, t) => { };
            // Load/Configure assets and read Config

            Modules.Config.ReadConfig();

            Modules.Assets.Init();
            if (cancel)
            {
                return;
            }
            Modules.Shaders.init();
            Modules.Tokens.Init();
            Modules.Prefabs.Init();
            Modules.Buffs.Init();

            Modules.Unlockables.Init();


            ExtraInputs.AddActionsToInputCatalog();
            var userDataInit = typeof(UserData).GetMethod(nameof(UserData.wVZZKoPFwEvodLvLcYNvVAPKpUj), BindingFlags.NonPublic | BindingFlags.Instance);

            HookEndpointManager.Add(userDataInit, (Action <Action <UserData>, UserData>)ExtraInputs.AddCustomActions);


            //CustomBind();


            // Any debug stuff you need to do can go here before initialisation
            if (debug)
            {
                Modules.Helpers.AwakeDebug();
            }

            //Initialize Content Pack
            ContentPackProvider.Initialize();

            Hook();
        }
Ejemplo n.º 27
0
        private static void HookMethods()
        {
            if (AffixBlueDamageCoeffField != null)
            {
                if (OnHitAllMethod != null)
                {
                    HookEndpointManager.Modify(OnHitAllMethod, (ILContext.Manipulator)OverrideAffixBlueDamage);

                    if (affixBlueDamageHook != 2)
                    {
                        HookEndpointManager.Unmodify(OnHitAllMethod, (ILContext.Manipulator)OverrideAffixBlueDamage);

                        Debug.LogWarning("[EliteReworksCompat] - Failed to successfully hook OnHitAll.TriggerOnHitAllEffects, Unhooking!");
                    }
                    else
                    {
                        overrideAffixBlue = true;
                    }
                }
            }
        }
Ejemplo n.º 28
0
        public override void Unload()
        {
            try
            {
                SaveConfig();

                // MonoModHooks.RemoveAll use mod.Name to unload the mod assembly
                LoadedLocalizer.File.SetField("<name>k__BackingField", "!Localizer");
                LoadedLocalizer.SetField("name", "!Localizer");

                PackageUI?.Close();
                UIHost.Dispose();
                Main.OnPostDraw -= OnPostDraw;

                HookEndpointManager.RemoveAllOwnedBy(this);
                Harmony.UnpatchAll(nameof(Localizer));
                Harmony.UnpatchAll(nameof(Patches));
                Kernel.Dispose();

                PackageUI     = null;
                Harmony       = null;
                Kernel        = null;
                _gameCultures = null;
                Config        = null;
                Instance      = null;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            finally
            {
                _initiated = false;
                Log        = null;
            }

            base.Unload();
        }
Ejemplo n.º 29
0
 private static void PatchMethod(Type typeInfo)
 {
     MethodInfo[] array1 = typeInfo.GetMethods(REQUIRED_FLAGS);
     for (int i1 = 0; i1 < array1.Length; i1++)
     {
         try
         {
             MethodInfo methodInfo = array1[i1];
             if (methodInfo.Name == "do_playWorldCallBack")
             {
                 continue;
             }
             HookEndpointManager.Modify(methodInfo, new ILContext.Manipulator(IlEditing));
             if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONOMOD_DMD_TYPE")))
             {
                 InfWorld.DisableMonoModDumps();
             }
         }
         catch (Exception e)
         {
         }
     }
 }
Ejemplo n.º 30
0
        public static void Load()
        {
            ContainerLibrary.Hooking.AlchemyApplyChance += () => Main.LocalPlayer.inventory.Any(item => item.modItem is AlchemistBag);
            ContainerLibrary.Hooking.ModifyAdjTiles     += player => player.adjTile[TileID.Bottles] = player.inventory.Any(item => item.modItem is AlchemistBag);

            On.Terraria.Player.TryPurchasing += (orig, price, inv, coins, empty, bank, bank2, bank3) => false;
            On.Terraria.Player.FishingLevel  += Player_FishingLevel;

            ItemSlot.DrawSavings += ItemSlot_DrawSavings;
            ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += ItemSlot_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color;

            IL.Terraria.Player.HasAmmo   += Player_HasAmmo;
            IL.Terraria.Player.QuickBuff += Player_QuickBuff;
            IL.Terraria.Player.PickAmmo  += Player_PickAmmo;
            IL.Terraria.Player.QuickHeal_GetItemToUse += Player_QuickHeal_GetItemToUse;
            IL.Terraria.Player.QuickMana += Player_QuickMana;
            IL.Terraria.Player.SellItem  += Player_SellItem;
            IL.Terraria.Player.BuyItem   += Player_BuyItem;
            IL.Terraria.Player.ItemCheck += Player_ItemCheck;
            IL.Terraria.Player.GetItem   += Player_GetItem;

            IL.Terraria.Main.UpdateTime_SpawnTownNPCs += Main_UpdateTime_SpawnTownNPCs;

            if (ItemTextBags == null)
            {
                ItemTextBags = new Item[20];
                for (int i = 0; i < ItemTextBags.Length; i++)
                {
                    ItemTextBags[i] = new Item();
                }
            }

            IL.Terraria.ItemText.Update += ItemText_Update;
            IL.Terraria.Main.DoDraw     += Main_DoDraw;

            HookEndpointManager.Modify(typeof(Player).GetMethod("CanBuyItem", BaseLibrary.Utility.defaultFlags), new Action <ILContext>(Player_CanBuyItem));
        }