Ejemplo n.º 1
0
        public static void PatchAll(EnchantableScythes scytheFixes)
        {
            mod = scytheFixes;

            var harmony = new Harmony(mod.ModManifest.UniqueID);

            try
            {
                harmony.Patch(
                    original: AccessTools.Method(typeof(Game1), nameof(Game1.fixProblems)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(RespawnGoldenScythes)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(MeleeWeapon), nameof(MeleeWeapon.drawTooltip)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(AddEnchantmentTooltipToScythe)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(BaseWeaponEnchantment), nameof(BaseWeaponEnchantment.CanApplyTo)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(CanApplyEnchantmentToScythe)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(BaseEnchantment), nameof(BaseEnchantment.GetEnchantmentFromItem)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(GetEnchantmentFromItem_Post)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(MeleeWeapon), nameof(MeleeWeapon.Forge)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(Forge_Post)));
            }
            catch (Exception e)
            {
                mod.ErrorLog("Error while trying to setup required patches:", e);
            }
        }
Ejemplo n.º 2
0
        public static void SetUpModConfigMenu(ScytheConfig config, EnchantableScythes mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new ScytheConfig(), delegate { mod.Helper.WriteConfig(config); });

            api.RegisterLabel(manifest, "Enchanting", null);

            api.RegisterSimpleOption(manifest, "Enchantable Scythes", null, () => config.EnchantableScythes, (bool val) => config.EnchantableScythes = val);
            api.RegisterSimpleOption(manifest, "Scythes Can Only Get Haymaker", null, () => config.ScythesCanOnlyGetHaymaker, (bool val) => config.ScythesCanOnlyGetHaymaker = val);
            api.RegisterSimpleOption(manifest, "Other Weapons Cannot\nGet Haymaker Anymore", null, () => config.OtherWeaponsCannotGetHaymakerAnymore, (bool val) => config.OtherWeaponsCannotGetHaymakerAnymore = val);

            api.RegisterLabel(manifest, "Fixes", null);

            api.RegisterSimpleOption(manifest, "Golden Scythe Respawns", null, () => config.GoldenScytheRespawns, (bool val) => config.GoldenScytheRespawns = val);
        }