Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }