コード例 #1
0
        public static bool PatchTapperMachineOutput(ref object __instance)
        {
            try
            {
                if (mod.Config.AutomationHarvestsGrantXP)
                {
                    TapperAndMushroomQualityLogic.RewardTapperExp(mod);
                }

                var tapper = mod.Helper.Reflection.GetProperty <StardewObject>(__instance, "Machine").GetValue();

                var tree = mod.Helper.Reflection.GetField <Tree>(__instance, "Tree").GetValue();

                if (mod.Config.TapperQualityOptions > 0 && mod.Config.TapperQualityOptions <= 4 && tree != null && tree is Tree)
                {
                    tapper.heldObject.Value.quality.Value = TapperAndMushroomQualityLogic.DetermineTapperQuality(mod, Game1.player, tapper, tree);
                }
                else
                {
                    tapper.heldObject.Value.quality.Value = 0;
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
コード例 #2
0
        public override void Entry(IModHelper helper)
        {
            Config = Helper.ReadConfig <ForageFantasyConfig>();

            ForageFantasyConfig.VerifyConfigValues(Config, this);

            Helper.Events.GameLoop.GameLaunched += delegate { ForageFantasyConfig.SetUpModConfigMenu(Config, this); };

            Helper.Events.GameLoop.GameLaunched += delegate { DeluxeGrabberCompatibility.Setup(this); };

            Helper.Events.GameLoop.DayStarted += delegate
            {
                TapperAndMushroomQualityLogic.IncreaseTreeAges(this);
                GrapeLogic.SetDropToNewGrapes(this);
                CheckForTappersDream();
            };

            Helper.Events.GameLoop.DayEnding += delegate { GrapeLogic.ResetGrapes(this); };

            Helper.Events.GameLoop.SaveLoaded += delegate { FernAndBurgerLogic.ChangeBundle(this); };

            helper.Events.Input.ButtonsChanged += OnButtonsChanged;

            Patcher.PatchAll(this);
        }
コード例 #3
0
        public static bool PatchMushroomBoxMachineOutput(ref object __instance)
        {
            try
            {
                if (mod.Config.AutomationHarvestsGrantXP)
                {
                    TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod);
                }

                var mushroomBox = mod.Helper.Reflection.GetProperty <StardewObject>(__instance, "Machine").GetValue();

                if (!mod.Config.MushroomBoxQuality)
                {
                    mushroomBox.heldObject.Value.quality.Value = 0;
                }
                else
                {
                    mushroomBox.heldObject.Value.quality.Value = ForageFantasy.DetermineForageQuality(Game1.player);
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
コード例 #4
0
        public static bool PatchTapperAndMushroomQuality(ref StardewObject __instance, ref Farmer who, ref bool justCheckingForActivity)
        {
            try
            {
                if (!justCheckingForActivity && __instance != null && __instance.minutesUntilReady <= 0 && __instance.heldObject != null && __instance.heldObject.Value != null)
                {
                    if (TapperAndMushroomQualityLogic.IsTapper(__instance))
                    {
                        TapperAndMushroomQualityLogic.RewardTapperExp(mod);

                        if (mod.Config.TapperQualityOptions <= 0 && mod.Config.TapperQualityOptions > 4)
                        {
                            __instance.heldObject.Value.quality.Value = 0;
                            return(true);
                        }

                        TerrainFeature terrain;
                        who.currentLocation.terrainFeatures.TryGetValue(__instance.TileLocation, out terrain);

                        if (terrain != null && terrain is Tree tree)
                        {
                            __instance.heldObject.Value.quality.Value = TapperAndMushroomQualityLogic.DetermineTapperQuality(mod, who, __instance, tree);
                        }
                        else
                        {
                            __instance.heldObject.Value.quality.Value = 0;
                        }

                        return(true);
                    }

                    if (TapperAndMushroomQualityLogic.IsMushroomBox(__instance))
                    {
                        TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod);

                        if (!mod.Config.MushroomBoxQuality)
                        {
                            __instance.heldObject.Value.quality.Value = 0;
                        }
                        else
                        {
                            __instance.heldObject.Value.quality.Value = ForageFantasy.DetermineForageQuality(who);
                        }

                        return(true);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
コード例 #5
0
        public override void Entry(IModHelper helper)
        {
            Config = Helper.ReadConfig <ForageFantasyConfig>();

            ForageFantasyConfig.VerifyConfigValues(Config, this);

            Helper.Events.GameLoop.GameLaunched += delegate { ForageFantasyConfig.SetUpModConfigMenu(Config, this); };

            Helper.Events.GameLoop.GameLaunched += delegate { DeluxeGrabberCompatibility.Setup(this); };

            Helper.Events.GameLoop.DayStarted += delegate { TapperAndMushroomQualityLogic.IncreaseTreeAges(this); };

            Helper.Events.GameLoop.SaveLoaded += delegate { FernAndBurgerLogic.ChangeBundle(this); };

            Patcher.PatchAll(this);
        }
コード例 #6
0
 public static void TryAddItemToPlayerInventory_Post(ref StardewObject container, ref bool __result)
 {
     try
     {
         // I can't reduce the quality of a non successfully harvested box here,
         // because it doesn't get called if the method throws a inventoryfull exception
         if (__result && TapperAndMushroomQualityLogic.IsMushroomBox(container))
         {
             if (mod.Config.AutomationHarvestsGrantXP)
             {
                 TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod);
             }
         }
     }
     catch (Exception e)
     {
         mod.ErrorLog("There was an exception in a patch", e);
     }
 }
コード例 #7
0
        public static bool TryAddItemToPlayerInventory_Pre(ref Farmer player, ref Item item, ref StardewObject container)
        {
            try
            {
                if (TapperAndMushroomQualityLogic.IsMushroomBox(container))
                {
                    if (mod.Config.MushroomBoxQuality)
                    {
                        (item as StardewObject).Quality = ForageFantasy.DetermineForageQuality(player);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
コード例 #8
0
 public static void ReduceQualityAfterHarvest(ref GameLocation location)
 {
     // reduce quality of non successfully harvested items and reset in general
     try
     {
         foreach (var item in location.Objects.Values)
         {
             if (TapperAndMushroomQualityLogic.IsMushroomBox(item))
             {
                 if (item.heldObject != null && item.heldObject.Value != null)
                 {
                     item.heldObject.Value.Quality = StardewObject.lowQuality;
                 }
             }
         }
     }
     catch (Exception e)
     {
         mod.ErrorLog("There was an exception in a patch", e);
     }
 }
コード例 #9
0
        public static void Edit <T>(IAssetData asset, ForageFantasyConfig config)
        {
            if (config.TapperDaysNeededChangesEnabled && asset.AssetNameEquals("Data/ObjectInformation"))
            {
                /*  here is the reasoning for the math
                 *
                 *  normal tapper:
                 *  maple syrup 9 days 200g
                 *  oak resin 7 days 150g
                 *  pine tar 5 days 100g
                 *
                 *  so 22,2g per day, 21,4g per day, 20g per day
                 *
                 *  heavy tapper:
                 *  maple syrup 4 days 200g
                 *  oak resin 3 days 150g
                 *  pine tar 2 days 100g
                 *
                 *  so 50g per day for all of them
                 *
                 *  ----
                 *
                 *  wanted values:
                 *  maple syrup 7 days 150g
                 *  oak resin 7 days 150g
                 *  pine tar 7 days 150g
                 *
                 *  so the calculation is:
                 *  newSellPrice = (int)Math.Round(daysNeeded * (150f / 7f), MidpointRounding.AwayFromZero);
                 */

                IDictionary <int, string> data = asset.AsDictionary <int, string>().Data;

                var priceChanges = new Dictionary <int, int>()
                {
                    { 724, config.MapleDaysNeeded }, { 725, config.OakDaysNeeded }, { 726, config.PineDaysNeeded }
                };

                foreach (var item in priceChanges)
                {
                    var entry    = data[item.Key];
                    var fields   = entry.Split('/');
                    var newPrice = TapperAndMushroomQualityLogic.GetTapperProductValueForDaysNeeded(item.Value);
                    fields[1]      = newPrice.ToString();
                    data[item.Key] = string.Join("/", fields);
                }
            }

            if (config.CommonFiddleheadFern)
            {
                if (asset.AssetNameEquals("Data/CraftingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    data["Wild Seeds (Su)"] = "396 1 398 1 402 1 259 1/Field/496 10/false/Foraging 4";
                }

                if (asset.AssetNameEquals("Data/Locations"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    var keys = data.Keys.ToList();

                    for (int i = 0; i < keys.Count; i++)
                    {
                        string   location = keys[i];
                        string[] fields   = data[location].Split('/');

                        switch (location)
                        {
                        case "BusStop":
                            fields[1] = "396 .6 398 .6 402 .6";
                            break;

                        case "Forest":
                            fields[1] = "396 .8 398 .8 259 .8";
                            break;

                        case "Mountain":
                            fields[1] = "396 .7 398 .7 259 .8";
                            break;

                        case "Backwoods":
                            fields[1] = "396 .7 398 .7 259 .8";
                            break;

                        case "Railroad":
                            fields[1] = "396 .6 398 .6 402 .6";
                            break;

                        case "Woods":
                            fields[1] = "259 .7 420 .7";
                            break;
                        }

                        data[location] = string.Join("/", fields);
                    }
                }
            }

            if (config.ForageSurvivalBurger)
            {
                if (asset.AssetNameEquals("Data/CookingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    data.Remove("Survival Burger");
                    data.Add("Survival Burger (Sp)", "216 1 16 1 20 1 22 1/70 1/241 2/s Foraging 2/Survival Burger (Sp)");
                    data.Add("Survival Burger (Su)", "216 1 398 1 396 1 259 1/70 1/241 2/s Foraging 2/Survival Burger (Su)");
                    data.Add("Survival Burger (Fa)", "216 1 404 1 406 1 408 1/70 1/241 2/s Foraging 2/Survival Burger (Fa)");
                    data.Add("Survival Burger (Wi)", "216 1 412 1 414 1 416 1/70 1/241 2/s Foraging 2/Survival Burger (Wi)");
                }

                if (asset.AssetNameEquals("Data/CraftingRecipes"))
                {
                    IDictionary <string, string> data = asset.AsDictionary <string, string>().Data;

                    data.Add("Survival Burger (Sp)", "216 1 16 1 20 1 22 1/Field/241/false/s Foraging 2/Survival Burger (Sp)");
                    data.Add("Survival Burger (Su)", "216 1 398 1 396 1 259 1/Field/241/false/s Foraging 2/Survival Burger (Su)");
                    data.Add("Survival Burger (Fa)", "216 1 404 1 406 1 408 1/Field/241/false/s Foraging 2/Survival Burger (Fa)");
                    data.Add("Survival Burger (Wi)", "216 1 412 1 414 1 416 1/Field/241/false/s Foraging 2/Survival Burger (Wi)");
                }
            }
        }