Exemple #1
0
        public static bool performToolAction_Prefix(ref Object __instance, Tool t, GameLocation location, ref bool __result)
        {
            // If the tool is a mattock and this object is one that requires a specific type of tool that is supported,
            // run the function with a stand-in tool instead.
            if (t is Mattock mattock && !mattock.struckObjects.Contains(__instance))
            {
                // Treat the mattock as a pickaxe for stones.
                if (__instance.name.Equals("Stone") || __instance.name.Equals("Boulder"))
                {
                    Pickaxe standinPickaxe = mattock.asPickaxe();
                    standinPickaxe.DoFunction(location, (int)(__instance.TileLocation.X * 64 + 32), (int)(__instance.TileLocation.Y * 64 + 32), 1, Game1.player);
                    mattock.struckObjects.Add(__instance);
                    return(false);
                }
                // Treat the mattock as an axe for twigs.
                else if (__instance.name.Contains("Twig"))
                {
                    Axe standinAxe = mattock.asAxe();
                    standinAxe.DoFunction(location, (int)(__instance.TileLocation.X * 64 + 32), (int)(__instance.TileLocation.Y * 64 + 32), 1, Game1.player);
                    mattock.struckObjects.Add(__instance);
                    return(false);
                }
            }

            // Otherwise, just do the default functionality.
            return(true);
        }
        public static bool checkAction_Prefix(ref GameLocation __instance, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who, ref bool __result)
        {
            GameLocation location = __instance;
            ModHooks     hooks    = (ModHooks)typeof(Game1).GetField("hooks", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            __result = hooks.OnGameLocation_CheckAction(__instance, tileLocation, viewport, who, delegate
            {
                if (who.IsSitting())
                {
                    who.StopSitting();
                    return(true);
                }
                Microsoft.Xna.Framework.Rectangle value = new Microsoft.Xna.Framework.Rectangle(tileLocation.X * 64, tileLocation.Y * 64, 64, 64);
                foreach (Farmer current in location.farmers)
                {
                    if (current != Game1.player && current.GetBoundingBox().Intersects(value) && current.checkAction(who, location))
                    {
                        return(true);
                    }
                }
                if (location.currentEvent != null && location.currentEvent.isFestival)
                {
                    return(location.currentEvent.checkAction(tileLocation, viewport, who));
                }
                foreach (NPC current2 in location.characters)
                {
                    if (current2 != null && !current2.IsMonster && (!who.isRidingHorse() || !(current2 is Horse)) && current2.GetBoundingBox().Intersects(value) && current2.checkAction(who, location))
                    {
                        if (who.FarmerSprite.IsPlayingBasicAnimation(who.FacingDirection, carrying: false) || who.FarmerSprite.IsPlayingBasicAnimation(who.FacingDirection, carrying: true))
                        {
                            who.faceGeneralDirection(current2.getStandingPosition(), 0, opposite: false, useTileCalculations: false);
                        }
                        return(true);
                    }
                }
                if (who.IsLocalPlayer && who.currentUpgrade != null && location.name.Equals("Farm") && tileLocation.Equals(new Location((int)(who.currentUpgrade.positionOfCarpenter.X + 32f) / 64, (int)(who.currentUpgrade.positionOfCarpenter.Y + 32f) / 64)))
                {
                    if (who.currentUpgrade.daysLeftTillUpgradeDone == 1)
                    {
                        Game1.drawDialogue(Game1.getCharacterFromName("Robin"), Game1.content.LoadString("Data\\ExtraDialogue:Farm_RobinWorking_ReadyTomorrow"));
                    }
                    else
                    {
                        Game1.drawDialogue(Game1.getCharacterFromName("Robin"), Game1.content.LoadString("Data\\ExtraDialogue:Farm_RobinWorking" + (Game1.random.Next(2) + 1)));
                    }
                }
                foreach (ResourceClump current3 in location.resourceClumps)
                {
                    if (current3.getBoundingBox(current3.tile).Intersects(value) && current3.performUseAction(new Vector2(tileLocation.X, tileLocation.Y), location))
                    {
                        return(true);
                    }
                }
                Vector2 vector = new Vector2(tileLocation.X, tileLocation.Y);
                if (location.objects.ContainsKey(vector) && location.objects[vector].Type != null)
                {
                    if (who.isRidingHorse() && !(location.objects[vector] is Fence))
                    {
                        return(false);
                    }
                    if (vector.Equals(who.getTileLocation()) && !location.objects[vector].isPassable())
                    {
                        Tool tool = new Pickaxe();
                        tool.DoFunction(Game1.currentLocation, -1, -1, 0, who);
                        if (location.objects[vector].performToolAction(tool, location))
                        {
                            location.objects[vector].performRemoveAction(location.objects[vector].tileLocation, Game1.currentLocation);
                            location.objects[vector].dropItem(location, who.GetToolLocation(), new Vector2(who.GetBoundingBox().Center.X, who.GetBoundingBox().Center.Y));
                            Game1.currentLocation.Objects.Remove(vector);
                            return(true);
                        }
                        tool = new Axe();
                        tool.DoFunction(Game1.currentLocation, -1, -1, 0, who);
                        if (location.objects.ContainsKey(vector) && location.objects[vector].performToolAction(tool, location))
                        {
                            location.objects[vector].performRemoveAction(location.objects[vector].tileLocation, Game1.currentLocation);
                            location.objects[vector].dropItem(location, who.GetToolLocation(), new Vector2(who.GetBoundingBox().Center.X, who.GetBoundingBox().Center.Y));
                            Game1.currentLocation.Objects.Remove(vector);
                            return(true);
                        }
                        if (!location.objects.ContainsKey(vector))
                        {
                            return(true);
                        }
                    }
                    if (location.objects.ContainsKey(vector) && (location.objects[vector].Type.Equals("Crafting") || location.objects[vector].Type.Equals("interactive")))
                    {
                        if (who.ActiveObject == null && location.objects[vector].checkForAction(who))
                        {
                            return(true);
                        }
                        if (location.objects.ContainsKey(vector))
                        {
                            if (who.CurrentItem != null)
                            {
                                StardewValley.Object value2 = location.objects[vector].heldObject.Value;
                                location.objects[vector].heldObject.Value = null;
                                bool flag = location.objects[vector].performObjectDropInAction(who.CurrentItem, probe: true, who);
                                location.objects[vector].heldObject.Value = value2;
                                bool flag2 = location.objects[vector].performObjectDropInAction(who.CurrentItem, probe: false, who);
                                if ((flag | flag2) && who.isMoving())
                                {
                                    Game1.haltAfterCheck = false;
                                }
                                if (flag2)
                                {
                                    who.reduceActiveItemByOne();
                                    return(true);
                                }
                                return(location.objects[vector].checkForAction(who) | flag);
                            }
                            return(location.objects[vector].checkForAction(who));
                        }
                    }
                    else if (location.objects.ContainsKey(vector) && (bool)location.objects[vector].isSpawnedObject)
                    {
                        int quality   = location.objects[vector].quality;
                        Random random = new Random((int)Game1.uniqueIDForThisGame / 2 + (int)Game1.stats.DaysPlayed + (int)vector.X + (int)vector.Y * 777);
                        if (who.professions.Contains(16) && location.objects[vector].isForage(location))
                        {
                            location.objects[vector].Quality = 4;
                        }
                        else if (location.objects[vector].isForage(location))
                        {
                            if (random.NextDouble() < (double)((float)who.ForagingLevel / 30f))
                            {
                                location.objects[vector].Quality = 2;
                            }
                            else if (random.NextDouble() < (double)((float)who.ForagingLevel / 15f))
                            {
                                location.objects[vector].Quality = 1;
                            }
                        }
                        if ((bool)location.objects[vector].questItem && location.objects[vector].questId.Value != 0 && !who.hasQuest(location.objects[vector].questId))
                        {
                            return(false);
                        }
                        if (who.couldInventoryAcceptThisItem(location.objects[vector]))
                        {
                            if (who.IsLocalPlayer)
                            {
                                location.localSound("pickUpItem");
                                DelayedAction.playSoundAfterDelay("coin", 300);
                            }
                            who.animateOnce(279 + who.FacingDirection);
                            if (!location.isFarmBuildingInterior())
                            {
                                if (location.objects[vector].isForage(location))
                                {
                                    who.gainExperience(2, 7);
                                }
                            }
                            else
                            {
                                who.gainExperience(0, 5);
                            }
                            who.addItemToInventoryBool(location.objects[vector].getOne());
                            Game1.stats.ItemsForaged++;
                            if (who.professions.Contains(13) && random.NextDouble() < 0.2 && !location.objects[vector].questItem && who.couldInventoryAcceptThisItem(location.objects[vector]) && !location.isFarmBuildingInterior())
                            {
                                who.addItemToInventoryBool(location.objects[vector].getOne());
                                who.gainExperience(2, 7);
                            }
                            location.objects.Remove(vector);
                            return(true);
                        }
                        location.objects[vector].Quality = quality;
                    }
                }
                if (who.isRidingHorse())
                {
                    who.mount.checkAction(who, location);
                    return(true);
                }
                foreach (MapSeat current4 in location.mapSeats)
                {
                    if (current4.OccupiesTile(tileLocation.X, tileLocation.Y) && !current4.IsBlocked(location))
                    {
                        who.BeginSitting(current4);
                        return(true);
                    }
                }
                foreach (KeyValuePair <Vector2, TerrainFeature> current5 in location.terrainFeatures.Pairs)
                {
                    if (current5.Value.getBoundingBox(current5.Key).Intersects(value) && current5.Value.performUseAction(current5.Key, location))
                    {
                        Game1.haltAfterCheck = false;
                        return(true);
                    }
                }
                if (location.largeTerrainFeatures != null)
                {
                    foreach (LargeTerrainFeature current6 in location.largeTerrainFeatures)
                    {
                        if (current6.getBoundingBox().Intersects(value) && current6.performUseAction(current6.tilePosition, location))
                        {
                            Game1.haltAfterCheck = false;
                            return(true);
                        }
                    }
                }
                string text = null;
                Tile tile   = location.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size);
                if (tile != null)
                {
                    tile.Properties.TryGetValue("Action", out PropertyValue value3);
                    if (value3 != null)
                    {
                        text = value3.ToString();
                    }
                }
                if (text == null)
                {
                    text = location.doesTileHaveProperty(tileLocation.X, tileLocation.Y, "Action", "Buildings");
                }
                NPC nPC = location.isCharacterAtTile(vector + new Vector2(0f, 1f));
                if (text != null)
                {
                    if (location.currentEvent == null && nPC != null && !nPC.IsInvisible && !nPC.IsMonster && (!who.isRidingHorse() || !(nPC is Horse)) && Utility.withinRadiusOfPlayer(nPC.getStandingX(), nPC.getStandingY(), 1, who) && nPC.checkAction(who, location))
                    {
                        if (who.FarmerSprite.IsPlayingBasicAnimation(who.FacingDirection, who.IsCarrying()))
                        {
                            who.faceGeneralDirection(nPC.getStandingPosition(), 0, opposite: false, useTileCalculations: false);
                        }
                        return(true);
                    }
                    return(location.performAction(text, who, tileLocation));
                }
                if (tile != null && location.checkTileIndexAction(tile.TileIndex))
                {
                    return(true);
                }
                Point value4 = new Point(tileLocation.X * 64, (tileLocation.Y - 1) * 64);
                bool flag3   = Game1.didPlayerJustRightClick();
                foreach (Furniture current7 in location.furniture)
                {
                    if (current7.boundingBox.Value.Contains((int)(vector.X * 64f), (int)(vector.Y * 64f)) && (int)current7.furniture_type != 12)
                    {
                        if (flag3)
                        {
                            if (who.ActiveObject != null && current7.performObjectDropInAction(who.ActiveObject, probe: false, who))
                            {
                                return(true);
                            }

                            if (who.CurrentTool != null && (who.CurrentTool is MeleeWeapon || who.CurrentTool is Slingshot) && current7.performObjectDropInAction(who.CurrentTool, probe: false, who))
                            {
                                return(true);
                            }
                            return(current7.checkForAction(who));
                        }
                        return(current7.clicked(who));
                    }
                    if ((int)current7.furniture_type == 6 && current7.boundingBox.Value.Contains(value4))
                    {
                        if (flag3)
                        {
                            if (who.ActiveObject != null && current7.performObjectDropInAction(who.ActiveObject, probe: false, who))
                            {
                                return(true);
                            }
                            return(current7.checkForAction(who));
                        }
                        return(current7.clicked(who));
                    }
                }
                return(false);
            });
        private void ClearCurrentLocation(GameLocation loc)
        {
            Axe fakeAxe = new Axe {
                UpgradeLevel = 4
            };
            Pickaxe fakePick = new Pickaxe {
                UpgradeLevel = 4
            };

            Game1.player.MagneticRadius = 650;
            int curStam = Convert.ToInt32(Game1.player.Stamina);

            for (int xTile = 0; xTile < loc.Map.Layers[0].LayerWidth; ++xTile)
            {
                for (int yTile = 0; yTile < loc.Map.Layers[0].LayerHeight; ++yTile)
                {
                    loc.objects.TryGetValue(new Vector2(xTile, yTile), out var obj);
                    loc.terrainFeatures.TryGetValue(new Vector2(xTile, yTile), out var ter);
                    SFarmer who   = Game1.player;
                    Vector2 useAt = (new Vector2(xTile, yTile) * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);
                    if (obj != null)
                    {
                        bool forage = obj.IsSpawnedObject;//checkForAction(Game1.player);
                        if (forage)
                        {
                            DoForageHarvest(obj, loc, who);
                        }
                        if (obj.Name.ToLower().Contains("twig"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                        }
                        if (obj.Name.ToLower().Contains("stone"))
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                        }
                        if (obj.Name.ToLower().Contains("weed"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                        }
                    }

                    if (ter != null)
                    {
                        if (ter is Tree tree)
                        {
                            tree.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                        }

                        if (ter is Grass)
                        {
                            Random rdn = new Random();
                            loc.terrainFeatures.Remove(new Vector2(xTile, yTile));
                            Game1.createMultipleObjectDebris(178, xTile, yTile, rdn.Next(2), loc);
                        }
                        if (ter is HoeDirt dirt)
                        {
                            if (dirt.crop != null)
                            {
                                dirt.fertilizer.Value = 369;
                                dirt.state.Value      = 1;
                            }
                        }
                    }

                    //Lets try bush shit

                    Rectangle rectangle = new Rectangle((int)useAt.X + 32, (int)useAt.Y - 32, 4, 192);
                    foreach (LargeTerrainFeature largeTerrainFeature in loc.largeTerrainFeatures)
                    {
                        if (largeTerrainFeature is Bush bush && bush.getBoundingBox().Intersects(rectangle))
                        {
                            bush.performUseAction(bush.tilePosition.Value, loc);
                        }
                    }


                    //Try to do monsters
                    Rectangle rect = new Rectangle((int)useAt.X, (int)useAt.Y, 4, 4);
                    loc.damageMonster(rect, 1000, 1000, false, Game1.player);

                    /*var monster = loc.characters;
                     *
                     * foreach (var m in monster)
                     * {
                     *  if (m is Monster mon)
                     *  {
                     *      mon.Health = 1;
                     *      fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, who);
                     *      //MeleeWeapon wep = new MeleeWeapon();
                     *      //wep.minDamage.Value = 100;
                     *      //wep.maxDamage.Value = 1000;
                     *      //wep.DoDamage(loc, mon.getTileX(), mon.getStandingY(), Game1.player.facingDirection.Value,  1, Game1.player);
                     *  }
                     * }*/

                    //Reset Stamina
                    Game1.player.Stamina = curStam;
                }
            }
        }
        private void UseTool(Vector2 startPos, Vector2 endPos, GameLocation loc)
        {
            var player = Game1.player;

            Axe fakeAxe = new Axe {
                UpgradeLevel = 4
            };
            Pickaxe fakePick = new Pickaxe {
                UpgradeLevel = 4
            };
            MeleeWeapon fakeSickle = new MeleeWeapon {
                UpgradeLevel = 4
            };
            Hoe fakeHoe = new Hoe {
                UpgradeLevel = 4
            };
            WateringCan fakeCan = new WateringCan {
                UpgradeLevel = 4
            };

            Game1.player.MagneticRadius = 650;

            for (int xTile = Convert.ToInt32(startPos.X); xTile <= Convert.ToInt32(endPos.X); ++xTile)
            {
                for (int yTile = Convert.ToInt32(startPos.Y); yTile <= Convert.ToInt32(endPos.Y); ++yTile)
                {
                    Vector2 useAt = (new Vector2(xTile, yTile) * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);
                    Game1.player.lastClick = useAt;

                    loc.objects.TryGetValue(new Vector2(xTile, yTile), out var obj);
                    loc.terrainFeatures.TryGetValue(new Vector2(xTile, yTile), out var ter);

                    //Check obj
                    if (obj != null)
                    {
                        bool forage = obj.IsSpawnedObject;//checkForAction(Game1.player);
                        if (forage)
                        {
                            DoForageHarvest(obj, loc, player);
                        }
                        if (obj.Name.ToLower().Contains("twig"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("stone"))
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("weed"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                    }
                    //Check ter
                    if (ter != null)
                    {
                        if (ter is Tree tree)
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }

                        if (ter is Grass)
                        {
                            Random rdn = new Random();
                            loc.terrainFeatures.Remove(new Vector2(xTile, yTile));
                            Game1.createMultipleObjectDebris(178, xTile, yTile, rdn.Next(2), loc);
                        }
                    }

                    if (ter != null && ter is HoeDirt dirt)
                    {
                        if (dirt.crop == null &&
                            player.ActiveObject != null &&
                            ((player.ActiveObject.Category == SObject.SeedsCategory || player.ActiveObject.Category == -19) &&
                             dirt.canPlantThisSeedHere(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player.ActiveObject.Category == -19)))
                        {
                            if ((dirt.plant(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player, player.ActiveObject.Category == -19, loc) && player.IsLocalPlayer))
                            {
                                player.reduceActiveItemByOne();
                            }
                            Game1.haltAfterCheck = false;
                        }
                        else if (dirt.crop != null)
                        {
                            if (dirt.crop.fullyGrown.Value)
                            {
                                dirt.crop.harvest((int)useAt.X, (int)useAt.Y, dirt);
                            }
                            else if (player.ActiveObject != null && player.ActiveObject.Category == -19)
                            {
                                dirt.fertilizer.Value = player.ActiveObject.ParentSheetIndex;
                                player.reduceActiveItemByOne();
                            }
                            else
                            {
                                fakeCan.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                            }
                        }
                        else
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                        }
                    }
                    else
                    {
                        fakeHoe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                    }


                    //Lets try bush shit
                    Rectangle rectangle = new Rectangle((int)useAt.X + 32, (int)useAt.Y - 32, 4, 192);
                    foreach (LargeTerrainFeature largeTerrainFeature in loc.largeTerrainFeatures)
                    {
                        if (largeTerrainFeature is Bush bush && bush.getBoundingBox().Intersects(rectangle))
                        {
                            bush.performUseAction(bush.tilePosition.Value, loc);
                        }
                    }

                    //Resource Clumps
                    ResourceClump clump = GetResourceClumpCoveringTile(loc, new Vector2(useAt.X, useAt.Y));
                    if (clump != null)
                    {
                        if (clump.parentSheetIndex.Value == 600)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 602)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 672)
                        {
                            clump.health.Value = 1;
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }
                    }

                    Game1.player.Stamina = Game1.player.MaxStamina;//So we dont passout lol
                }
            }
        }
Exemple #5
0
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (!(e.IsDown(_actKey) || e.IsDown(_cropKey)) || !Context.IsWorldReady)
            {
                return;
            }
            if (Game1.currentLocation == null || Game1.player == null || (Game1.player.UsingTool || !Game1.player.CanMove || (Game1.activeClickableMenu != null || Game1.CurrentEvent != null)) || Game1.gameMode != 3)
            {
                return;
            }
            GameLocation    currentLocation = Game1.currentLocation;
            ICursorPosition cur             = Helper.Input.GetCursorPosition();
            var             c = Game1.getMousePosition();

            Vector2[] grid = GetTileGrid(cur.Tile * 64f, _upgradeLevel).ToArray();



            if (_powerLevel <= -1)
            {
                _powerLevel = 1;
            }
            Game1.player.toolPower = _powerLevel;

            //May need to rewrite this crap

            //Action key pressed.
            if (e.IsDown(_actKey))
            {
                foreach (var i in grid)
                {
                    var g = i;
                    currentLocation.Objects.TryGetValue(g, out SObject @object);
                    currentLocation.terrainFeatures.TryGetValue(g, out TerrainFeature @terain);

                    //Not sure if this will work lets test
                    g = (g * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);

                    /*
                     * if (currentLocation.doesTileHaveProperty((int)(i.X), (int)(i.Y), "Water", "Back") != null ||
                     * currentLocation.doesTileHaveProperty((int)(i.X), (int)(i.Y), "WaterSource", "Back") != null ||
                     * (currentLocation as BuildableGameLocation)?.getBuildingAt(g) != null &&
                     * (currentLocation as BuildableGameLocation).getBuildingAt(g).buildingType.Value.Equals("Well"))
                     * {
                     *  // ISSUE: explicit non-virtual call
                     *  if (currentLocation.orePanPoint.Value != Point.Zero)
                     *      _ghostPan.DoFunction(currentLocation, (int)i.X, (int)i.Y, 1, Game1.player);
                     *  else
                     *      UseghostWaterCan(currentLocation, (int)i.X, (int)i.Y);
                     * }
                     * else*/
                    Vector2 ca = new Vector2(i.X, i.Y) * 64f;

                    if (@object != null)
                    {
                        if (@object.Name.Equals("Twig") || @object.Name.Contains("ood Fence"))
                        {
                            _ghostAxe.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, 0, Game1.player);
                        }
                        else if (@object.Name.Contains("Weed"))
                        {
                            _ghostScythe.DoDamage(currentLocation, (int)ca.X, (int)ca.Y, Game1.player.getFacingDirection(), 0, Game1.player);
                        }
                        else if (@object.Name.Contains("Stone"))
                        {
                            _ghostPickaxe.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, 0, Game1.player);
                        }
                    }
                    else if (currentLocation is AnimalHouse &&
                             _ghostShearPail.TargetAnimal(currentLocation,
                                                          (int)ca.X,
                                                          (int)ca.Y,
                                                          Game1.player) !=
                             null)
                    {
                        _ghostShearPail.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, 0, Game1.player);
                    }
                    else if (@terain != null)
                    {
                        //Monitor.Log($"terrainFeature wasn't null ....");
                        //Lets do som checks

                        if (@terain is Tree tree)
                        {
                            _ghostAxe.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, 0, Game1.player);
                        }
                        else if (@terain is HoeDirt dirt)
                        {
                            if (currentLocation.IsFarm || currentLocation.Name.Contains("Greenhouse"))
                            {
                                if (dirt.crop != null || dirt.fertilizer.Value != 0)
                                {
                                    if (dirt.crop != null && (dirt.crop.harvestMethod.Value == 1 && dirt.readyForHarvest() || !dirt.crop.dead.Value))
                                    {
                                        _ghostScythe.DoDamage(currentLocation, (int)ca.X, (int)ca.Y, Game1.player.getFacingDirection(), 0, Game1.player);
                                    }
                                    else
                                    {
                                        UseghostWaterCan(currentLocation, (int)ca.X, (int)ca.Y);
                                    }
                                }
                                else if (_hoeDirtTool.Equals("Pickaxe", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    _ghostPickaxe.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, 1, Game1.player);
                                }
                                else if (_hoeDirtTool.Equals("Hoe", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    _ghostHoe.DoFunction(currentLocation, (int)ca.X, (int)ca.Y, _powerLevel + 1, Game1.player);
                                }
                                else
                                {
                                    UseghostWaterCan(currentLocation, (int)ca.X, (int)ca.Y);
                                }
                            }
                        }
                        else if (@terain is Grass grass)
                        {
                            _ghostScythe.DoDamage(currentLocation, (int)ca.X, (int)ca.Y, Game1.player.getFacingDirection(), 0, Game1.player);
                        }
                    }
                    else if (currentLocation is SlimeHutch)
                    {
                        UseghostWaterCan(currentLocation, (int)ca.X, (int)ca.Y);
                    }
                    else
                    {
                        //Monitor.Log("All if's failed... run for the hills.");
                        //if (currentLocation.doesTileHaveProperty((int)(i.X), (int)(i.Y), "Diggable", "Back") != null)
                        // _ghostHoe.DoFunction(currentLocation, (int)i.X, (int)i.Y, 0, Game1.player);

                        /*
                         * Farmer player1 = Game1.player;
                         * player1.stamina = (float)(player1.stamina + (2.0 - Game1.player.MiningLevel * 0.100000001490116));
                         * _ghostAxe.DoFunction(currentLocation, (int)i.X, (int)i.Y, 1, Game1.player);
                         * _ghostPickaxe.DoFunction(currentLocation, (int)i.X, (int)i.Y, 1, Game1.player);
                         * if (currentLocation.doesTileHaveProperty((int)(i.X), (int)(i.Y), "Diggable", "Back") != null)
                         * {
                         *  Game1.player.toolPower = Game1.player.toolPower >= _ghostHoe.UpgradeLevel ? _ghostHoe.UpgradeLevel : Game1.player.toolPower;
                         *  Farmer player2 = Game1.player;
                         *  player2.stamina = (float)(player2.stamina + (2.0 - Game1.player.FarmingLevel * 0.100000001490116));
                         *  _ghostHoe.DoFunction(currentLocation, (int)i.X, (int)i.Y, _powerLevel + 1, Game1.player);
                         * }*/
                    }
                }
            }
            //Crop key pressed
            if (e.IsDown(_cropKey))
            {
                foreach (var i in grid)
                {
                    var g = i;
                    currentLocation.Objects.TryGetValue(g, out SObject @object);
                    currentLocation.terrainFeatures.TryGetValue(g, out TerrainFeature @terrain);

                    //Not sure if this will work lets test
                    g = (g * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);

                    if (@object != null)
                    {
                        if (@object.Name.Equals("Artifact Spot"))
                        {
                            _ghostHoe.DoFunction(currentLocation, (int)i.X, (int)i.Y, 0, Game1.player);
                        }
                    }
                    else if (@terrain != null)
                    {
                        Farmer player = Game1.player;

                        /*
                         *  public const int dry = 0;
                         *  public const int watered = 1;
                         *  public const int invisible = 2;
                         *  public const int noFertilizer = 0;
                         *  public const int fertilizerLowQuality = 368;
                         *  public const int fertilizerHighQuality = 369;
                         *  public const int waterRetentionSoil = 370;
                         *  public const int waterRetentionSoilQUality = 371;
                         *  public const int speedGro = 465;
                         *  public const int superSpeedGro = 466;
                         *  Plant Category = -74
                         *  Fertilizer = -19
                         */
                        if (@terrain is HoeDirt dirt)
                        {
                            if (dirt.crop == null &&
                                player.ActiveObject != null &&
                                ((player.ActiveObject.Category == SObject.SeedsCategory || player.ActiveObject.Category == -19) &&
                                 dirt.canPlantThisSeedHere(player.ActiveObject.ParentSheetIndex, (int)i.X, (int)i.Y, player.ActiveObject.Category == -19)))
                            {
                                if ((dirt.plant(player.ActiveObject.ParentSheetIndex, (int)i.X, (int)i.Y, player, player.ActiveObject.Category == -19, currentLocation) && player.IsLocalPlayer))
                                {
                                    player.reduceActiveItemByOne();
                                }
                                Game1.haltAfterCheck = false;
                            }
                        }
                    }
                    else
                    {
                        //@object and terrainFeature was null, must be dirt.
                        _ghostHoe.DoFunction(currentLocation, (int)i.X, (int)i.Y, 0, Game1.player);
                    }
                }
            }
            _powerLevel          = -1;
            Game1.player.Stamina = Game1.player.MaxStamina;
            //End May need to rewrite
        }