Esempio n. 1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="farmer">The lookup target.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="reflectionHelper">Simplifies access to private game code.</param>
 public FarmerSubject(SFarmer farmer, ITranslationHelper translations, IReflectionHelper reflectionHelper)
     : base(farmer.Name, null, translations.Get(L10n.Types.Player), translations)
 {
     this.Target     = farmer;
     this.Reflection = reflectionHelper;
 }
Esempio n. 2
0
 public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
 {
     return;
 }
Esempio n. 3
0
 internal static void Shift(StardewValley.Farmer who, string[] arguments, Vector2 tile)
 {
     Game1.warpFarmer(who.currentLocation, Convert.ToInt32(arguments[0]), Convert.ToInt32(arguments[1]), who.facingDirection, who.currentLocation.isStructure);
 }
Esempio n. 4
0
        /// <summary>Apply the tool to the given tile.</summary>
        /// <param name="tile">The tile to modify.</param>
        /// <param name="tileObj">The object on the tile.</param>
        /// <param name="tileFeature">The feature on the tile.</param>
        /// <param name="player">The current player.</param>
        /// <param name="tool">The tool selected by the player (if any).</param>
        /// <param name="item">The item selected by the player (if any).</param>
        /// <param name="location">The current location.</param>
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer player, Tool tool, Item item, GameLocation location)
        {
            // clear twigs & weeds
            if (this.Config.ClearDebris && (tileObj?.Name == "Twig" || this.IsWeed(tileObj)))
            {
                return(this.UseToolOnTile(tool, tile));
            }

            // check terrain feature
            switch (tileFeature)
            {
            // cut non-fruit tree
            case Tree tree:
                if (tree.tapped.Value ? this.Config.CutTappedTrees : this.Config.CutTrees)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                break;

            // cut fruit tree
            case FruitTree _:
                if (this.Config.CutFruitTrees)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                break;

            // clear crops
            case HoeDirt dirt when dirt.crop != null:
                if (this.Config.ClearDeadCrops && dirt.crop.dead.Value)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                if (this.Config.ClearLiveCrops && !dirt.crop.dead.Value)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                break;
            }

            // clear stumps
            // This needs to check if the axe upgrade level is high enough first, to avoid spamming
            // 'need to upgrade your tool' messages. Based on ResourceClump.performToolAction.
            if (this.Config.ClearDebris)
            {
                ResourceClump clump = this.GetResourceClumpCoveringTile(location, tile);
                if (clump != null && this.ResourceUpgradeLevelsNeeded.ContainsKey(clump.parentSheetIndex.Value) && tool.UpgradeLevel >= this.ResourceUpgradeLevelsNeeded[clump.parentSheetIndex.Value])
                {
                    this.UseToolOnTile(tool, tile);
                }
            }

            return(false);
        }
Esempio n. 5
0
 public override bool onRelease(GameLocation location, int x, int y, StardewValley.Farmer who)
 {
     return(false);
 }
Esempio n. 6
0
 public override bool isActionable(StardewValley.Farmer who)
 {
     return(this.checkForAction(who, true));
 }
Esempio n. 7
0
        /// <summary>Apply the tool to the given tile.</summary>
        /// <param name="tile">The tile to modify.</param>
        /// <param name="tileObj">The object on the tile.</param>
        /// <param name="tileFeature">The feature on the tile.</param>
        /// <param name="player">The current player.</param>
        /// <param name="tool">The tool selected by the player (if any).</param>
        /// <param name="item">The item selected by the player (if any).</param>
        /// <param name="location">The current location.</param>
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer player, Tool tool, Item item, GameLocation location)
        {
            // clear twigs & weeds
            if (this.Config.ClearWeeds && this.IsWeed(tileObj))
            {
                return(this.UseToolOnTile(tool, tile));
            }

            // till plain dirt
            if (this.Config.TillDirt && tileFeature == null && tileObj == null)
            {
                return(this.UseToolOnTile(tool, tile));
            }

            // collect artifact spots
            if (this.Config.DigArtifactSpots && tileObj?.ParentSheetIndex == HoeAttachment.ArtifactSpotItemID)
            {
                return(this.UseToolOnTile(tool, tile));
            }

            return(false);
        }
Esempio n. 8
0
 public static int[] FishingZeroes(this SFarmer player)
 {
     return(Enumerable.Range(0, (player ?? Game1.player).FishingLevel - 3).ToArray());
 }
Esempio n. 9
0
        private bool AddItemToInventory(SObject obj, SFarmer farmer, Farm farm)
        {
            bool wasAdded = false;

            if (farmer.couldInventoryAcceptThisItem(obj) && !this.BypassInventory)
            {
                farmer.addItemToInventory(obj);
                wasAdded = true;

                if (this.LoggingEnabled)
                {
                    this.Monitor.Log("Was able to add item to inventory.", LogLevel.Trace);
                }
            }
            else
            {
                farm.objects.TryGetValue(this.ChestCoords, out SObject chestObj);

                if (chestObj is Chest chest)
                {
                    if (this.LoggingEnabled)
                    {
                        this.Monitor.Log($"Found a chest at {(int)this.ChestCoords.X},{(int)this.ChestCoords.Y}", LogLevel.Trace);
                    }

                    Item i = chest.addItem(obj);
                    if (i == null)
                    {
                        wasAdded = true;

                        if (this.LoggingEnabled)
                        {
                            this.Monitor.Log("Was able to add items to chest.", LogLevel.Trace);
                        }
                    }
                    else
                    {
                        this.InventoryAndChestFull = true;

                        if (this.LoggingEnabled)
                        {
                            this.Monitor.Log("Was NOT able to add items to chest.", LogLevel.Trace);
                        }
                    }
                }
                else
                {
                    if (this.LoggingEnabled)
                    {
                        this.Monitor.Log($"Did not find a chest at {(int)this.ChestCoords.X},{(int)this.ChestCoords.Y}", LogLevel.Trace);
                    }

                    // If bypassInventory is set to true, but there's no chest: try adding to the farmer's inventory.
                    if (this.BypassInventory)
                    {
                        if (this.LoggingEnabled)
                        {
                            this.Monitor.Log($"No chest at {(int)this.ChestCoords.X},{(int)this.ChestCoords.Y}, you should place a chest there, or set bypassInventory to \'false\'.", LogLevel.Trace);
                        }

                        if (farmer.couldInventoryAcceptThisItem(obj))
                        {
                            farmer.addItemToInventory(obj);
                            wasAdded = true;

                            if (this.LoggingEnabled)
                            {
                                this.Monitor.Log("Was able to add item to inventory. (No chest found, bypassInventory set to 'true')", LogLevel.Trace);
                            }
                        }
                        else
                        {
                            this.InventoryAndChestFull = true;

                            if (this.LoggingEnabled)
                            {
                                this.Monitor.Log("Was NOT able to add item to inventory or a chest.  (No chest found, bypassInventory set to 'true')", LogLevel.Trace);
                            }
                        }
                    }
                    else
                    {
                        this.InventoryAndChestFull = true;

                        if (this.LoggingEnabled)
                        {
                            this.Monitor.Log("Was NOT able to add item to inventory or a chest.  (No chest found, bypassInventory set to 'false')", LogLevel.Trace);
                        }
                    }
                }
            }

            return(wasAdded);
        }
Esempio n. 10
0
        /// <summary>Apply the tool to the given tile.</summary>
        /// <param name="tile">The tile to modify.</param>
        /// <param name="tileObj">The object on the tile.</param>
        /// <param name="tileFeature">The feature on the tile.</param>
        /// <param name="player">The current player.</param>
        /// <param name="tool">The tool selected by the player (if any).</param>
        /// <param name="item">The item selected by the player (if any).</param>
        /// <param name="location">The current location.</param>
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer player, Tool tool, Item item, GameLocation location)
        {
            // spawned forage
            if (tileObj?.isSpawnedObject == true)
            {
                this.CheckTileAction(location, tile, player);
                return(true);
            }

            // crop or spring onion
            if (tileFeature is HoeDirt dirt)
            {
                if (dirt.crop == null)
                {
                    return(false);
                }

                if (dirt.crop.dead)
                {
                    this.UseToolOnTile(new Pickaxe(), tile); // clear dead crop
                    return(true);
                }
                if (dirt.crop.harvestMethod == Crop.sickleHarvest)
                {
                    dirt.performToolAction(tool, 0, tile, location);
                }
                else
                {
                    this.CheckTileAction(location, tile, player);
                }
                return(true);
            }

            // fruit tree
            if (tileFeature is FruitTree tree)
            {
                tree.performUseAction(tile);
                return(true);
            }

            // grass
            if (tileFeature is Grass _)
            {
                location.terrainFeatures.Remove(tile);
                if (Game1.getFarm().tryToAddHay(1) == 0) // returns number left
                {
                    Game1.addHUDMessage(new HUDMessage("Hay", HUDMessage.achievement_type, true, Color.LightGoldenrodYellow, new SObject(178, 1)));
                }
                return(true);
            }

            // weeds
            if (tileObj?.Name.ToLower().Contains("weed") == true)
            {
                this.UseToolOnTile(tool, tile);  // doesn't do anything to the weed, but sets up for the tool action (e.g. sets last user)
                tileObj.performToolAction(tool); // triggers weed drops, but doesn't remove weed
                location.removeObject(tile, false);
                return(true);
            }

            return(false);
        }
Esempio n. 11
0
 /// <summary>
 /// Functionality used when interacting with the npc.
 /// </summary>
 /// <param name="who"></param>
 /// <param name="l"></param>
 /// <returns></returns>
 public override bool checkAction(StardewValley.Farmer who, GameLocation l)
 {
     base.checkAction(who, l);
     return(false);
 }
Esempio n. 12
0
 /*********
 ** Public methods
 *********/
 /// <summary>Get whether the tool is currently enabled.</summary>
 /// <param name="player">The current player.</param>
 /// <param name="tool">The tool selected by the player (if any).</param>
 /// <param name="item">The item selected by the player (if any).</param>
 /// <param name="location">The current location.</param>
 public override bool IsEnabled(SFarmer player, Tool tool, Item item, GameLocation location)
 {
     return(tool is MeleeWeapon && tool.name.ToLower().Contains("scythe"));
 }
Esempio n. 13
0
        /// <summary>Apply the tool to the given tile.</summary>
        /// <param name="tile">The tile to modify.</param>
        /// <param name="tileObj">The object on the tile.</param>
        /// <param name="tileFeature">The feature on the tile.</param>
        /// <param name="player">The current player.</param>
        /// <param name="tool">The tool selected by the player (if any).</param>
        /// <param name="item">The item selected by the player (if any).</param>
        /// <param name="location">The current location.</param>
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer player, Tool tool, Item item, GameLocation location)
        {
            // break stones
            if (tileObj?.Name == "Stone")
            {
                return(this.UseToolOnTile(tool, tile));
            }

            // break flooring & paths
            if (tileFeature is Flooring)
            {
                return(this.BreakFlooring && this.UseToolOnTile(tool, tile));
            }

            // handle dirt
            if (tileFeature is HoeDirt dirt)
            {
                // clear tilled dirt
                if (dirt.crop == null)
                {
                    return(this.ClearDirt && this.UseToolOnTile(tool, tile));
                }

                // clear dead crops
                if (dirt.crop?.dead == true)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
            }

            // clear boulders / meteorites
            // This needs to check if the axe upgrade level is high enough first, to avoid spamming
            // 'need to upgrade your tool' messages. Based on ResourceClump.performToolAction.
            {
                Rectangle     tileArea = this.GetAbsoluteTileArea(tile);
                ResourceClump stump    =
                    (
                        from clump in this.GetResourceClumps(location)
                        where
                        clump.getBoundingBox(clump.tile).Intersects(tileArea) &&
                        this.ResourceUpgradeLevelsNeeded.ContainsKey(clump.parentSheetIndex) &&
                        tool.upgradeLevel >= this.ResourceUpgradeLevelsNeeded[clump.parentSheetIndex]
                        select clump
                    )
                    .FirstOrDefault();
                if (stump != null)
                {
                    this.UseToolOnTile(tool, tile);
                }
            }

            return(false);
        }
Esempio n. 14
0
 public Farmer(StardewValley.Farmer original)
     : base(original)
 {
 }
Esempio n. 15
0
        public LuckLevelUpMenu(int skill, int level)
            : base(Game1.viewport.Width / 2 - 384, Game1.viewport.Height / 2 - 256, 768, 512, false)
        {
            this.timerBeforeStart = 250;
            this.isActive         = true;
            this.width            = Game1.tileSize * 12;
            this.height           = Game1.tileSize * 8;
            this.okButton         = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
            this.newCraftingRecipes.Clear();
            this.extraInfoForLevel.Clear();
            Game1.player.completelyStopAnimatingOrDoingAction();
            this.informationUp       = true;
            this.isProfessionChooser = false;
            this.currentLevel        = level;
            this.currentSkill        = skill;
            if (level == 10)
            {
                Game1.getSteamAchievement("Achievement_SingularTalent");
                if (Game1.player.farmingLevel.Value == 10 && Game1.player.miningLevel.Value == 10 && Game1.player.fishingLevel.Value == 10 && Game1.player.foragingLevel.Value == 10 && Game1.player.combatLevel.Value == 10)
                {
                    Game1.getSteamAchievement("Achievement_MasterOfTheFiveWays");
                }
            }
            this.title = string.Concat(new object[]
            {
                "Level ",
                this.currentLevel,
                " ",
                SFarmer.getSkillNameFromIndex(this.currentSkill)
            });
            this.extraInfoForLevel = this.getExtraInfoForLevel(this.currentSkill, this.currentLevel);
            switch (this.currentSkill)
            {
            case 0:
                this.sourceRectForLevelIcon = new Rectangle(0, 0, 16, 16);
                break;

            case 1:
                this.sourceRectForLevelIcon = new Rectangle(16, 0, 16, 16);
                break;

            case 2:
                this.sourceRectForLevelIcon = new Rectangle(80, 0, 16, 16);
                break;

            case 3:
                this.sourceRectForLevelIcon = new Rectangle(32, 0, 16, 16);
                break;

            case 4:
                this.sourceRectForLevelIcon = new Rectangle(128, 16, 16, 16);
                break;

            case 5:
                this.sourceRectForLevelIcon = new Rectangle(64, 0, 16, 16);
                break;
            }
            if ((this.currentLevel == 5 || this.currentLevel == 10) /*&& this.currentSkill != 5*/)
            {
                this.professionsToChoose.Clear();
                this.isProfessionChooser = true;
                if (this.currentLevel == 5)
                {
                    this.professionsToChoose.Add(this.currentSkill * 6);
                    this.professionsToChoose.Add(this.currentSkill * 6 + 1);
                }
                else if (Game1.player.professions.Contains(this.currentSkill * 6))
                {
                    this.professionsToChoose.Add(this.currentSkill * 6 + 2);
                    this.professionsToChoose.Add(this.currentSkill * 6 + 3);
                }
                else
                {
                    this.professionsToChoose.Add(this.currentSkill * 6 + 4);
                    this.professionsToChoose.Add(this.currentSkill * 6 + 5);
                }
                this.leftProfessionDescription  = LuckLevelUpMenu.getProfessionDescription(this.professionsToChoose[0]);
                this.rightProfessionDescription = LuckLevelUpMenu.getProfessionDescription(this.professionsToChoose[1]);
            }
            int num = 0;

            foreach (KeyValuePair <string, string> current in CraftingRecipe.craftingRecipes)
            {
                string text = current.Value.Split(new char[]
                {
                    '/'
                })[4];
                if (text.Contains(SFarmer.getSkillNameFromIndex(this.currentSkill)) && text.Contains(string.Concat(this.currentLevel)))
                {
                    this.newCraftingRecipes.Add(new CraftingRecipe(current.Key, false));
                    if (!Game1.player.craftingRecipes.ContainsKey(current.Key))
                    {
                        Game1.player.craftingRecipes.Add(current.Key, 0);
                    }
                    num += (this.newCraftingRecipes.Last <CraftingRecipe>().bigCraftable ? (Game1.tileSize * 2) : Game1.tileSize);
                }
            }
            foreach (KeyValuePair <string, string> current2 in CraftingRecipe.cookingRecipes)
            {
                string text2 = current2.Value.Split(new char[]
                {
                    '/'
                })[3];
                if (text2.Contains(SFarmer.getSkillNameFromIndex(this.currentSkill)) && text2.Contains(string.Concat(this.currentLevel)))
                {
                    this.newCraftingRecipes.Add(new CraftingRecipe(current2.Key, true));
                    if (!Game1.player.cookingRecipes.ContainsKey(current2.Key))
                    {
                        Game1.player.cookingRecipes.Add(current2.Key, 0);
                        if (!Game1.player.hasOrWillReceiveMail("robinKitchenLetter"))
                        {
                            Game1.mailbox.Add("robinKitchenLetter");
                        }
                    }
                    num += (this.newCraftingRecipes.Last <CraftingRecipe>().bigCraftable ? (Game1.tileSize * 2) : Game1.tileSize);
                }
            }
            this.height = num + Game1.tileSize * 4 + this.extraInfoForLevel.Count <string>() * Game1.tileSize * 3 / 4;
            Game1.player.freezePause = 100;
            this.gameWindowSizeChanged(Rectangle.Empty, Rectangle.Empty);
        }
Esempio n. 16
0
 private bool CanAfford(SFarmer farmer, int amount, CrabNetStats stats)
 {
     // Calculate the running cost (need config passed for that) and determine if additional puts you over.
     return((amount + stats.RunningTotal) <= farmer.Money);
 }
Esempio n. 17
0
 public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
 {
     spriteBatch.Draw(SDVX3Mod.texture, objectPosition, GetSpriteSourceRect(), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
 }
Esempio n. 18
0
 public override bool performDropDownAction(StardewValley.Farmer who)
 {
     this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
     return(false);
 }
Esempio n. 19
0
 /// <summary>Get whether the tool is currently enabled.</summary>
 /// <param name="player">The current player.</param>
 /// <param name="tool">The tool selected by the player (if any).</param>
 /// <param name="item">The item selected by the player (if any).</param>
 /// <param name="location">The current location.</param>
 public override bool IsEnabled(SFarmer player, Tool tool, Item item, GameLocation location)
 {
     return((this.Config.TillDirt || this.Config.ClearWeeds) && tool is Hoe && tool.GetType().FullName != SeedBagAttachment.SeedBagTypeName);
 }
Esempio n. 20
0
 public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who)
 {
     if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is ModularDecoration) || ((dropIn as ModularDecoration).getTilesWide() == 1 && (dropIn as ModularDecoration).getTilesHigh() == 1)))
     {
         this.heldObject = (StardewValley.Object)dropIn.getOne();
         this.heldObject.tileLocation  = this.tileLocation;
         this.heldObject.boundingBox.X = this.boundingBox.X;
         this.heldObject.boundingBox.Y = this.boundingBox.Y;
         //  Log.AsyncO(getDefaultBoundingBoxForType((dropIn as Decoration).Decoration_type));
         this.heldObject.performDropDownAction(who);
         if (!probe)
         {
             Game1.playSound("woodyStep");
             //   Log.AsyncC("HUH?");
             if (who != null)
             {
                 who.reduceActiveItemByOne();
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 21
0
 /// <summary>Get whether the tool is currently enabled.</summary>
 /// <param name="player">The current player.</param>
 /// <param name="tool">The tool selected by the player (if any).</param>
 /// <param name="item">The item selected by the player (if any).</param>
 /// <param name="location">The current location.</param>
 public override bool IsEnabled(SFarmer player, Tool tool, Item item, GameLocation location)
 {
     return(tool is Axe);
 }
Esempio n. 22
0
        public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
        {
            Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);


            this.tileLocation = new Vector2((float)point.X, (float)point.Y);
            bool flag = false;

            if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
            {
                int  num   = (this.parentSheetIndex == 1293) ? 3 : 0;
                bool flag2 = false;

                if (!flag2)
                {
                    Game1.showRedMessage("Must be placed on wall");
                    return(false);
                }
                flag = true;
            }
            for (int i = point.X; i < point.X + this.getTilesWide(); i++)
            {
                for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
                {
                    if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
                    {
                        Game1.showRedMessage("Furniture can't be placed here");
                        return(false);
                    }

                    if (location.getTileIndexAt(i, j, "Buildings") != -1)
                    {
                        return(false);
                    }
                }
            }
            if (this.boundingBox.Width == 0 && this.boundingBox.Height == 0)
            {
                this.boundingBox = new Rectangle(Int32.MinValue, y / Game1.tileSize * Game1.tileSize, 0, 0);
            }

            else
            {
                this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
            }

            /*
             * foreach (Furniture current2 in (location as DecoratableLocation).furniture)
             *  {
             *      if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
             *      {
             *          current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
             *          bool result = true;
             *          return result;
             *      }
             *  }
             */
            using (List <StardewValley.Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox))
                    {
                        Game1.showRedMessage("Can't place on top of a person.");
                        bool result = false;
                        return(result);
                    }
                }
            }
            this.updateDrawPosition();
            bool f = Util.placementAction(this, location, x, y, who);

            Log.AsyncM(this.sourceRect);
            int fff = 1;

            for (int X = 0; X < (this.sourceRect.Width / 16) * Game1.tileSize; X += Game1.tileSize)
            {
                for (int Y = 0; Y < (this.sourceRect.Height / 16) * Game1.tileSize; Y += Game1.tileSize)
                {
                    if (X == 0 && Y == 0)
                    {
                        continue;
                    }

                    ModularDecoration newThing = new ModularDecoration(this.parentSheetIndex, Vector2.Zero, this.SourceFilePathAndName, false, (X / Game1.tileSize), Y / Game1.tileSize);
                    newThing.placementActionNonRecursive(location, x + X, y + Y, who);
                    fff++;
                    Log.AsyncO("Placed an object: " + fff + " times.");
                    // f = Util.placementAction(newThing, location, x+X, y+Y, who);
                    //Log.AsyncG("X: "+X+" Y: "+Y);
                }
            }

            /*
             * if (f == true)
             * {
             *   foreach(var v in blankSpace)
             *   {
             *       v.placementAction(Game1.player.currentLocation, x+(v.xTileOffset), y+(v.yTileOffset), who);
             *   }
             * }
             */
            return(f);
            //  Game1.showRedMessage("Can only be placed in House");
            //  return false;
        }
Esempio n. 23
0
        /// <summary>Get metadata for a menu element at the specified position.</summary>
        /// <param name="menu">The active menu.</param>
        /// <param name="cursorPos">The cursor's viewport-relative coordinates.</param>
        public ISubject GetSubjectFrom(IClickableMenu menu, Vector2 cursorPos)
        {
            switch (menu)
            {
            // calendar
            case Billboard billboard:
            {
                // get target day
                int selectedDay = -1;
                for (int i = 0; i < billboard.calendarDays.Count; i++)
                {
                    if (billboard.calendarDays[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        selectedDay = i + 1;
                        break;
                    }
                }
                if (selectedDay == -1)
                {
                    return(null);
                }

                // get villager with a birthday on that date
                NPC target = GameHelper.GetAllCharacters().FirstOrDefault(p => p.Birthday_Season == Game1.currentSeason && p.Birthday_Day == selectedDay);
                if (target != null)
                {
                    return(new CharacterSubject(target, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                }
            }
            break;

            // chest
            case MenuWithInventory inventoryMenu:
            {
                Item item = inventoryMenu.hoveredItem;
                if (item != null)
                {
                    return(new ItemSubject(this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // inventory
            case GameMenu gameMenu:
            {
                List <IClickableMenu> tabs   = this.Reflection.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue();
                IClickableMenu        curTab = tabs[gameMenu.currentTab];
                switch (curTab)
                {
                case InventoryPage _:
                {
                    Item item = this.Reflection.GetField <Item>(curTab, "hoveredItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
                break;

                case CraftingPage _:
                {
                    Item item = this.Reflection.GetField <Item>(curTab, "hoverItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
                break;

                case SocialPage _:
                {
                    // get villagers on current page
                    int scrollOffset = this.Reflection.GetField <int>(curTab, "slotPosition").GetValue();
                    ClickableTextureComponent[] entries = this.Reflection
                                                          .GetField <List <ClickableTextureComponent> >(curTab, "sprites")
                                                          .GetValue()
                                                          .Skip(scrollOffset)
                                                          .ToArray();

                    // find hovered villager
                    ClickableTextureComponent entry = entries.FirstOrDefault(p => p.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                    if (entry != null)
                    {
                        int    index    = Array.IndexOf(entries, entry) + scrollOffset;
                        object socialID = this.Reflection.GetField <List <object> >(curTab, "names").GetValue()[index];
                        if (socialID is long playerID)
                        {
                            SFarmer player = Game1.getFarmer(playerID);
                            return(new FarmerSubject(player, this.Translations, this.Reflection));
                        }
                        else if (socialID is string villagerName)
                        {
                            NPC npc = GameHelper.GetAllCharacters().FirstOrDefault(p => p.isVillager() && p.Name == villagerName);
                            if (npc != null)
                            {
                                return(new CharacterSubject(npc, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                            }
                        }
                    }
                }
                break;
                }
            }
            break;

            // Community Center bundle menu
            case JunimoNoteMenu bundleMenu:
            {
                // hovered inventory item
                {
                    Item item = this.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of required ingredients
                for (int i = 0; i < bundleMenu.ingredientList.Count; i++)
                {
                    if (bundleMenu.ingredientList[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        Bundle bundle     = this.Reflection.GetField <Bundle>(bundleMenu, "currentPageBundle").GetValue();
                        var    ingredient = bundle.ingredients[i];
                        var    item       = GameHelper.GetObjectBySpriteIndex(ingredient.index, ingredient.stack);
                        item.Quality = ingredient.quality;
                        return(new ItemSubject(this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of submitted ingredients
                foreach (ClickableTextureComponent slot in bundleMenu.ingredientSlots)
                {
                    if (slot.item != null && slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        return(new ItemSubject(this.Translations, slot.item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
            }
            break;

            // kitchen
            case CraftingPage _:
            {
                CraftingRecipe recipe = this.Reflection.GetField <CraftingRecipe>(menu, "hoverRecipe").GetValue();
                if (recipe != null)
                {
                    return(new ItemSubject(this.Translations, recipe.createItem(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;


            // shop
            case ShopMenu _:
            {
                Item item = this.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                if (item != null)
                {
                    return(new ItemSubject(this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // toolbar
            case Toolbar _:
            {
                // find hovered slot
                List <ClickableComponent> slots       = this.Reflection.GetField <List <ClickableComponent> >(menu, "buttons").GetValue();
                ClickableComponent        hoveredSlot = slots.FirstOrDefault(slot => slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                if (hoveredSlot == null)
                {
                    return(null);
                }

                // get inventory index
                int index = slots.IndexOf(hoveredSlot);
                if (index < 0 || index > Game1.player.Items.Count - 1)
                {
                    return(null);
                }

                // get hovered item
                Item item = Game1.player.Items[index];
                if (item != null)
                {
                    return(new ItemSubject(this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // by convention (for mod support)
            default:
            {
                Item item = this.Reflection.GetField <Item>(menu, "HoveredItem", required: false)?.GetValue();        // ChestsAnywhere
                if (item != null)
                {
                    return(new ItemSubject(this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;
            }

            return(null);
        }
Esempio n. 24
0
        public bool placementActionNonRecursive(GameLocation location, int x, int y, StardewValley.Farmer who = null)
        {
            Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);


            this.tileLocation = new Vector2((float)point.X, (float)point.Y);
            bool flag = false;

            if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
            {
                int  num   = (this.parentSheetIndex == 1293) ? 3 : 0;
                bool flag2 = false;

                if (!flag2)
                {
                    Game1.showRedMessage("Must be placed on wall");
                    return(false);
                }
                flag = true;
            }
            for (int i = point.X; i < point.X + this.getTilesWide(); i++)
            {
                for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
                {
                    if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
                    {
                        Game1.showRedMessage("Furniture can't be placed here");
                        return(false);
                    }

                    if (location.getTileIndexAt(i, j, "Buildings") != -1)
                    {
                        return(false);
                    }
                }
            }
            //if(this.xTileOffset!=0 || this.yTileOffset!=0) this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, Game1.tileSize/2);
            if (this.boundingBox.Width == 0 && this.boundingBox.Height == 0)
            {
                this.boundingBox = new Rectangle(Int32.MinValue, y / Game1.tileSize * Game1.tileSize, 0, 0);
            }

            else
            {
                this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
            }
            Log.AsyncC(this.boundingBox);

            /*
             * foreach (Furniture current2 in (location as DecoratableLocation).furniture)
             *  {
             *      if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
             *      {
             *          current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
             *          bool result = true;
             *          return result;
             *      }
             *  }
             */
            using (List <StardewValley.Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox))
                    {
                        Game1.showRedMessage("Can't place on top of a person.");
                        bool result = false;
                        return(result);
                    }
                }
            }
            this.updateDrawPosition();
            bool f = Util.placementAction(this, location, x, y, who);

            /*
             * if (f == true)
             * {
             *   foreach(var v in blankSpace)
             *   {
             *       v.placementAction(Game1.player.currentLocation, x+(v.xTileOffset), y+(v.yTileOffset), who);
             *   }
             * }
             */
            if (f == true)
            {
                Lists.DecorationsToDraw.Add(this);
            }
            return(f);
            //  Game1.showRedMessage("Can only be placed in House");
            //  return false;
        }
Esempio n. 25
0
 public override bool beginUsing(GameLocation location, int x, int y, StardewValley.Farmer who)
 {
     return(false);
 }
Esempio n. 26
0
 /// <summary>
 /// Will override traditional drawn when held logic to get all of the furniture at once, not just the pieces.
 /// </summary>
 /// <param name="spriteBatch"></param>
 /// <param name="objectPosition"></param>
 /// <param name="f"></param>
 public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
 {
     base.drawWhenHeld(spriteBatch, objectPosition, f);
 }
Esempio n. 27
0
        /// <summary>
        /// For some reason without this constructor the DoFunction code will cause execution exceptions at runtime.
        /// </summary>
        //public ShearsReplacement()
        //    : base("Shears", -1, 7, 7, false)
        //{
        //}

        /// <summary>
        /// Replaces the existing DoFunction in Shears, adding a quantity increase.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="power"></param>
        /// <param name="who"></param>
        public new void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            Logger.LogInformation("using replacement shears DoFunction...");
            base.DoFunction(location, x, y, power, who);
            Logger.LogInformation("<The rest of the replacement shears DoFunction.>");
        }
Esempio n. 28
0
        public override void update(GameTime time)
        {
            if (!this.isActive)
            {
                base.exitThisMenu(true);
                return;
            }
            for (int i = this.littleStars.Count - 1; i >= 0; i--)
            {
                if (this.littleStars[i].update(time))
                {
                    this.littleStars.RemoveAt(i);
                }
            }
            if (Game1.random.NextDouble() < 0.03)
            {
                Vector2 position = new Vector2(0f, (float)(Game1.random.Next(this.yPositionOnScreen - Game1.tileSize * 2, this.yPositionOnScreen - Game1.pixelZoom) / (Game1.pixelZoom * 5) * Game1.pixelZoom * 5 + Game1.tileSize / 2));
                if (Game1.random.NextDouble() < 0.5)
                {
                    position.X = (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 - 57 * Game1.pixelZoom, this.xPositionOnScreen + this.width / 2 - 33 * Game1.pixelZoom);
                }
                else
                {
                    position.X = (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 + 29 * Game1.pixelZoom, this.xPositionOnScreen + this.width - 40 * Game1.pixelZoom);
                }
                if (position.Y < (float)(this.yPositionOnScreen - Game1.tileSize - Game1.pixelZoom * 2))
                {
                    position.X = (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 - 29 * Game1.pixelZoom, this.xPositionOnScreen + this.width / 2 + 29 * Game1.pixelZoom);
                }
                position.X = position.X / (float)(Game1.pixelZoom * 5) * (float)Game1.pixelZoom * 5f;
                this.littleStars.Add(new TemporaryAnimatedSprite(Game1.mouseCursorsName, new Rectangle(364, 79, 5, 5), 80f, 7, 1, position, false, false, 1f, 0f, Color.White, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
                {
                    local = true
                });
            }
            if (this.timerBeforeStart > 0)
            {
                this.timerBeforeStart -= time.ElapsedGameTime.Milliseconds;
                return;
            }
            if (this.isActive && this.isProfessionChooser)
            {
                this.leftProfessionColor  = Game1.textColor;
                this.rightProfessionColor = Game1.textColor;
                Game1.player.completelyStopAnimatingOrDoingAction();
                Game1.player.freezePause = 100;
                if (Game1.getMouseY() > this.yPositionOnScreen + Game1.tileSize * 3 && Game1.getMouseY() < this.yPositionOnScreen + this.height)
                {
                    if (Game1.getMouseX() > this.xPositionOnScreen && Game1.getMouseX() < this.xPositionOnScreen + this.width / 2)
                    {
                        this.leftProfessionColor = Color.Green;
                        if (((Mouse.GetState().LeftButton == ButtonState.Pressed && this.oldMouseState.LeftButton == ButtonState.Released) || (Game1.options.gamepadControls && GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A) && !Game1.oldPadState.IsButtonDown(Buttons.A))) && this.readyToClose())
                        {
                            Game1.player.professions.Add(this.professionsToChoose[0]);
                            this.getImmediateProfessionPerk(this.professionsToChoose[0]);
                            this.isActive            = false;
                            this.informationUp       = false;
                            this.isProfessionChooser = false;
                        }
                    }
                    else if (Game1.getMouseX() > this.xPositionOnScreen + this.width / 2 && Game1.getMouseX() < this.xPositionOnScreen + this.width)
                    {
                        this.rightProfessionColor = Color.Green;
                        if (((Mouse.GetState().LeftButton == ButtonState.Pressed && this.oldMouseState.LeftButton == ButtonState.Released) || (Game1.options.gamepadControls && GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A) && !Game1.oldPadState.IsButtonDown(Buttons.A))) && this.readyToClose())
                        {
                            Game1.player.professions.Add(this.professionsToChoose[1]);
                            this.getImmediateProfessionPerk(this.professionsToChoose[1]);
                            this.isActive            = false;
                            this.informationUp       = false;
                            this.isProfessionChooser = false;
                        }
                    }
                }
                this.height = Game1.tileSize * 8;
            }
            this.oldMouseState = Mouse.GetState();
            if (this.isActive && !this.informationUp && this.starIcon != null)
            {
                if (this.starIcon.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()))
                {
                    this.starIcon.sourceRect.X = 294;
                }
                else
                {
                    this.starIcon.sourceRect.X = 310;
                }
            }
            if (this.isActive && this.starIcon != null && !this.informationUp && (this.oldMouseState.LeftButton == ButtonState.Pressed || (Game1.options.gamepadControls && Game1.oldPadState.IsButtonDown(Buttons.A))) && this.starIcon.containsPoint(this.oldMouseState.X, this.oldMouseState.Y))
            {
                this.newCraftingRecipes.Clear();
                this.extraInfoForLevel.Clear();
                Game1.player.completelyStopAnimatingOrDoingAction();
                Game1.playSound("bigSelect");
                this.informationUp       = true;
                this.isProfessionChooser = false;
                this.currentLevel        = Game1.player.newLevels.First <Point>().Y;
                this.currentSkill        = Game1.player.newLevels.First <Point>().X;
                this.title = Game1.content.LoadString("Strings\\UI:LevelUp_Title", new object[]
                {
                    this.currentLevel,
                    SFarmer.getSkillNameFromIndex(this.currentSkill)
                });
                this.extraInfoForLevel = this.getExtraInfoForLevel(this.currentSkill, this.currentLevel);
                switch (this.currentSkill)
                {
                case 0:
                    this.sourceRectForLevelIcon = new Rectangle(0, 0, 16, 16);
                    break;

                case 1:
                    this.sourceRectForLevelIcon = new Rectangle(16, 0, 16, 16);
                    break;

                case 2:
                    this.sourceRectForLevelIcon = new Rectangle(80, 0, 16, 16);
                    break;

                case 3:
                    this.sourceRectForLevelIcon = new Rectangle(32, 0, 16, 16);
                    break;

                case 4:
                    this.sourceRectForLevelIcon = new Rectangle(128, 16, 16, 16);
                    break;

                case 5:
                    this.sourceRectForLevelIcon = new Rectangle(64, 0, 16, 16);
                    break;
                }
                if ((this.currentLevel == 5 || this.currentLevel == 10) /*&& this.currentSkill != 5*/)
                {
                    this.professionsToChoose.Clear();
                    this.isProfessionChooser = true;
                    if (this.currentLevel == 5)
                    {
                        this.professionsToChoose.Add(this.currentSkill * 6);
                        this.professionsToChoose.Add(this.currentSkill * 6 + 1);
                    }
                    else if (Game1.player.professions.Contains(this.currentSkill * 6))
                    {
                        this.professionsToChoose.Add(this.currentSkill * 6 + 2);
                        this.professionsToChoose.Add(this.currentSkill * 6 + 3);
                    }
                    else
                    {
                        this.professionsToChoose.Add(this.currentSkill * 6 + 4);
                        this.professionsToChoose.Add(this.currentSkill * 6 + 5);
                    }
                    this.leftProfessionDescription  = LuckLevelUpMenu.getProfessionDescription(this.professionsToChoose[0]);
                    this.rightProfessionDescription = LuckLevelUpMenu.getProfessionDescription(this.professionsToChoose[1]);
                }
                int num = 0;
                foreach (KeyValuePair <string, string> current in CraftingRecipe.craftingRecipes)
                {
                    string text = current.Value.Split(new char[]
                    {
                        '/'
                    })[4];
                    if (text.Contains(SFarmer.getSkillNameFromIndex(this.currentSkill)) && text.Contains(string.Concat(this.currentLevel)))
                    {
                        this.newCraftingRecipes.Add(new CraftingRecipe(current.Key, false));
                        if (!Game1.player.craftingRecipes.ContainsKey(current.Key))
                        {
                            Game1.player.craftingRecipes.Add(current.Key, 0);
                        }
                        num += (this.newCraftingRecipes.Last <CraftingRecipe>().bigCraftable ? (Game1.tileSize * 2) : Game1.tileSize);
                    }
                }
                foreach (KeyValuePair <string, string> current2 in CraftingRecipe.cookingRecipes)
                {
                    string text2 = current2.Value.Split(new char[]
                    {
                        '/'
                    })[3];
                    if (text2.Contains(SFarmer.getSkillNameFromIndex(this.currentSkill)) && text2.Contains(string.Concat(this.currentLevel)))
                    {
                        this.newCraftingRecipes.Add(new CraftingRecipe(current2.Key, true));
                        if (!Game1.player.cookingRecipes.ContainsKey(current2.Key))
                        {
                            Game1.player.cookingRecipes.Add(current2.Key, 0);
                        }
                        num += (this.newCraftingRecipes.Last <CraftingRecipe>().bigCraftable ? (Game1.tileSize * 2) : Game1.tileSize);
                    }
                }
                this.height = num + Game1.tileSize * 4 + this.extraInfoForLevel.Count <string>() * Game1.tileSize * 3 / 4;
                Game1.player.freezePause = 100;
            }
            if (this.isActive && this.informationUp)
            {
                Game1.player.completelyStopAnimatingOrDoingAction();
                if (this.okButton.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()) && !this.isProfessionChooser)
                {
                    this.okButton.scale = Math.Min(1.1f, this.okButton.scale + 0.05f);
                    if ((this.oldMouseState.LeftButton == ButtonState.Pressed || (Game1.options.gamepadControls && Game1.oldPadState.IsButtonDown(Buttons.A))) && this.readyToClose())
                    {
                        this.getLevelPerk(this.currentSkill, this.currentLevel);
                        this.isActive      = false;
                        this.informationUp = false;
                    }
                }
                else
                {
                    this.okButton.scale = Math.Max(1f, this.okButton.scale - 0.05f);
                }
                Game1.player.freezePause = 100;
            }
        }
Esempio n. 29
0
 internal static void Message(StardewValley.Farmer who, string[] arguments, Vector2 tile)
 {
     Game1.drawDialogueNoTyping(ModEntry.Strings.Get(arguments[0] + ":" + arguments[1]));
 }
Esempio n. 30
0
        /// <summary>Raised after the game state is updated (≈60 times per second).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady || Game1.paused || Game1.activeClickableMenu != null)
                return;

            SFarmer player = Game1.player;

            /********************************************************************************************************
             * The following section of code is for tallying and calculating the player's max health and stamina.
             *******************************************************************************************************/
            // checks Stardrops acquired ingame and tallies them.
            if (Game1.player.hasOrWillReceiveMail("CF_Fair") && !drop1)
            {
                drop1 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("CF_Fish") && !drop2)
            {
                drop2 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("CF_Mines") && !drop3)
            {
                drop3 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("CF_Sewer") && !drop4)
            {
                drop4 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("museumComplete") && !drop5)
            {
                drop5 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("CF_Spouse") && !drop6)
            {
                drop6 = true;
                ++starDropTally;
            }
            if (Game1.player.hasOrWillReceiveMail("CF_Statue") && !drop7)
            {
                drop7 = true;
                ++starDropTally;
            }

            // checks Iridium Snake Milk acquired ingame and tallies them.
            if (Game1.player.mailReceived.Contains("qiCave") && !snakeMilk)
            {
                snakeMilk = true;
                ++snakeMilkTally;
            }

            // accumulated values that make up the player's maximum health and stamina.
            // it should be noted that the way this is setup, the player won't be able to gain additional life or stamina by cheating in Stardrops and Iridium Snake Milk.
            maxHealth = Config.StartingHealth + (starDropTally * Config.StarDropHealth) + (snakeMilkTally * Config.SnakeMilkHealth) + (player.combatLevel * Config.CombatLevelHealth);
            maxStamina = Config.StartingStamina + (starDropTally * Config.StarDropStamina) + (snakeMilkTally * Config.SnakeMilkStamina) + ((player.farmingLevel + player.foragingLevel + player.miningLevel + player.fishingLevel) * Config.SkillLevelStamina);

            // sets max health and stamina to their appropriate values based on the above calculation.
            if (player.maxHealth != maxHealth)
                player.maxHealth = maxHealth;

            if (player.MaxStamina != maxStamina)
                player.MaxStamina = maxStamina;

            /********************************************************************************************************
             * End max health and stamina section.
            ********************************************************************************************************/


            /********************************************************************************************************
             * The following section of code handles the regeneration of health and stamina.
             *******************************************************************************************************/
            // establish whether the player is fishing or there's an event occuring
            bool Fishing = player.usingTool && player.CurrentTool is FishingRod && ((FishingRod)player.CurrentTool).isFishing;
            bool Event = !Game1.shouldTimePass() && !Game1.player.canMove;

            // detect movement or tool use
            TimeSinceLastMoved += Game1.currentGameTime.ElapsedGameTime.TotalMilliseconds;
            TimeSinceToolUsed += Game1.currentGameTime.ElapsedGameTime.TotalMilliseconds;
            if (player.timerSinceLastMovement == 0)
                TimeSinceLastMoved = 0;
            if (player.UsingTool && !Fishing)
                TimeSinceToolUsed = 0;

            // health regen
            if (Config.RegenHealthConstant && TimeSinceToolUsed > Config.RegenHealthStillTimeRequiredMS)
            {
                if (TimeSinceLastMoved > Config.RegenHealthStillTimeRequiredMS)
                {
                    if ((!Config.RegenHealthEvent && Event) || (!Config.RegenHealthFishing && Fishing))
                        Health += 0;
                    else
                        Health += Config.RegenHealthConstantAmountPerSecond * ElapsedSeconds;
                }
                if (Config.RegenHealthMoving && TimeSinceLastMoved < Config.RegenHealthStillTimeRequiredMS)
                {
                    if ((!Config.RegenHealthEvent && Event) || (!Config.RegenHealthFishing && Fishing))
                        Health += 0;
                    else
                        Health += Config.RegenHealthConstantAmountPerSecond * ElapsedSeconds * Config.RegenHealthMovingMult;
                }
            }
            if (Config.RegenHealthPercent && TimeSinceToolUsed > Config.RegenHealthStillTimeRequiredMS)
            {
                if (TimeSinceLastMoved > Config.RegenHealthStillTimeRequiredMS)
                {
                    if ((!Config.RegenHealthEvent && Event) || (!Config.RegenHealthFishing && Fishing))
                        Health += 0;
                    else
                        Health += ((Config.RegenHealthPercentPerSecond / 100) * player.maxHealth) * ElapsedSeconds;
                }
                if (Config.RegenHealthMoving && TimeSinceLastMoved < Config.RegenHealthStillTimeRequiredMS)
                {
                    if ((Config.RegenHealthEvent && Event) || (!Config.RegenHealthFishing && Fishing))
                        Health += 0;
                    else
                        Health += ((Config.RegenHealthPercentPerSecond / 100) * player.maxHealth) * ElapsedSeconds * Config.RegenHealthMovingMult;
                }
            }

            // make sure health doesn't overflow.
            if (player.health + Health >= player.maxHealth)
            {
                player.health = player.maxHealth;
                Health = 0;
            }
            else if (Health >= 1)
            {
                player.health += 1;
                Health -= 1;
            }
            else if (Health <= -1)
            {
                player.health -= 1;
                Health += 1;
            }

            // stamina regen
            if (Config.RegenStaminaConstant && TimeSinceToolUsed > Config.RegenStaminaStillTimeRequiredMS)
            {
                if (TimeSinceLastMoved > Config.RegenStaminaStillTimeRequiredMS)
                {
                    if ((!Config.RegenStaminaEvent && Event) || (!Config.RegenStaminaFishing && Fishing))
                        Stamina += 0;
                    else
                        Stamina += Config.RegenStaminaConstantAmountPerSecond * ElapsedSeconds;
                }
                if (Config.RegenStaminaMoving && TimeSinceLastMoved < Config.RegenStaminaStillTimeRequiredMS)
                {
                    if ((!Config.RegenStaminaEvent && Event) || (!Config.RegenStaminaFishing && Fishing))
                        Stamina += 0;
                    else
                        Stamina += Config.RegenStaminaConstantAmountPerSecond * ElapsedSeconds * Config.RegenStaminaMovingMult;
                }
            }
            if (Config.RegenStaminaPercent && TimeSinceToolUsed > Config.RegenStaminaStillTimeRequiredMS)
            {
                if (TimeSinceLastMoved > Config.RegenStaminaStillTimeRequiredMS)
                {
                    if ((!Config.RegenStaminaEvent && Event) || (!Config.RegenStaminaFishing && Fishing))
                        Stamina += 0;
                    else
                        Stamina += ((Config.RegenStaminaPercentPerSecond / 100) * player.maxStamina) * ElapsedSeconds;
                }
                if (Config.RegenStaminaMoving && TimeSinceLastMoved < Config.RegenStaminaStillTimeRequiredMS)
                {
                    if ((!Config.RegenStaminaEvent && Event) || (!Config.RegenStaminaFishing && Fishing))
                        Stamina += 0;
                    else
                        Stamina += ((Config.RegenStaminaPercentPerSecond / 100) * player.maxStamina) * ElapsedSeconds * Config.RegenStaminaMovingMult;
                }
            }

            // make sure stamina doesn't overflow.
            if (player.Stamina + Stamina >= player.MaxStamina)
            {
                player.Stamina = player.MaxStamina;
                Stamina = 0;
            }
            else if (Stamina >= 1)
            {
                player.Stamina += 1;
                Stamina -= 1;
            }
            else if (Stamina <= -1)
            {
                player.Stamina -= 1;
                Stamina += 1;
            }
        }