Exemplo n.º 1
0
        public static void setSingleTileAsChild(TileNode t, int x, int y, bool placementAction = true)
        {
            Vector2 pos = new Vector2(x * Game1.tileSize, y * Game1.tileSize);

            bool f = checkIfICanPlaceHere(t, new Vector2(pos.X, pos.Y));

            if (f == false)
            {
                return;
            }
            else
            {
                // ModCore.CoreMonitor.Log("Adding a child!");
                System.Threading.Thread.Sleep(PathFindingCore.PathFindingLogic.delay);
                TileNode child = new TileNode(1, Vector2.Zero, t.texturePath, t.dataPath, StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Cyan));
                child.seenState = (int)stateEnum.NotVisited;
                child.parent    = t;
                if (placementAction)
                {
                    child.placementAction(t.thisLocation, (int)pos.X, (int)pos.Y);
                }
                else
                {
                    child.fakePlacementAction(t.thisLocation, x, y);
                }
                //StarAI.PathFindingCore.Utilities.masterAdditionList.Add(new StarAI.PathFindingCore.PlacementNode(child, Game1.currentLocation, (int)pos.X, (int)pos.Y));
                t.children.Add(child);
            }
        }
Exemplo n.º 2
0
        private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
        {
            //J key for shop
            #region
            if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.J)
            {
                CoreMonitor.Log("OK THE J KEY WAS PRESSED!");
                List <Item> shoppingList          = new List <Item>();
                StarAI.PathFindingCore.TileNode t = new StarAI.PathFindingCore.TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Aqua));
                if (t == null)
                {
                    CoreMonitor.Log("WTF?????");
                }
                try
                {
                    if (t == null)
                    {
                        return;
                    }
                    shoppingList.Add((Item)t);
                    Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shoppingList);
                }
                catch (Exception err)
                {
                    CoreMonitor.Log(Convert.ToString(err));
                }
            }
            #endregion

            //K key for placing a tile.
            #region
            if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
            {
                CoreMonitor.Log("OK THE K KEY WAS PRESSED!");

                StarAI.PathFindingCore.TileNode t = new StarAI.PathFindingCore.TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.randomColor());
                if (t == null)
                {
                    CoreMonitor.Log("WTF?????");
                }
                try
                {
                    if (t == null)
                    {
                        return;
                    }
                    CoreMonitor.Log(new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize).ToString());

                    int       xPos = (int)(Game1.player.getTileX()) * Game1.tileSize;
                    int       yPos = (int)(Game1.player.getTileY()) * Game1.tileSize;
                    Rectangle r    = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
                    Vector2   pos  = new Vector2(r.X, r.Y);
                    bool      ok   = StarAI.PathFindingCore.TileNode.checkIfICanPlaceHere(t, pos, Game1.player.currentLocation);
                    if (ok == false)
                    {
                        return;
                    }
                    t.placementAction(Game1.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
                    //t.setAdjacentTiles(true);
                }
                catch (Exception err)
                {
                    CoreMonitor.Log(Convert.ToString(err));
                }
            }
            #endregion

            if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.U)
            {
                ExecutionCore.TaskList.printAllTaskMetaData();
            }

            if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.O)
            {
                foreach (var v in Game1.player.currentLocation.map.TileSheets)
                {
                    foreach (var q in Game1.player.currentLocation.map.Layers)
                    {
                        string[] s     = q.ToString().Split(':');
                        string   layer = s[1].Trim();
                        if (Game1.player.currentLocation.map.GetLayer(layer) == null)
                        {
                            ModCore.CoreMonitor.Log("SHITTTTTT: " + layer, LogLevel.Error);
                        }
                        int tileIndex = Game1.player.currentLocation.getTileIndexAt((int)Game1.player.getTileX() / Game1.tileSize, (int)Game1.player.getTileY() / Game1.tileSize, layer);
                        if (tileIndex == -1)
                        {
                            continue;
                        }
                        //ModCore.CoreMonitor.Log("Position: " + (Game1.player.getTileLocation() / Game1.tileSize).ToString(), LogLevel.Warn);
                        //ModCore.CoreMonitor.Log("Layer: " + layer, LogLevel.Warn);
                        //ModCore.CoreMonitor.Log("Index: " + tileIndex.ToString(), LogLevel.Warn);
                        //ModCore.CoreMonitor.Log("Image Source: " + v.ImageSource, LogLevel.Warn);

                        if (layer == "Buildings")
                        {
                            TileExceptionNode tileException = new TileExceptionNode(v.ImageSource, tileIndex);
                            foreach (var tile in PathFindingCore.Utilities.ignoreCheckTiles)
                            {
                                if (tile.imageSource == tileException.imageSource && tile.index == tileException.index)
                                {
                                    ModCore.CoreMonitor.Log("Tile exception already initialized!");
                                    return; //tile is already initialized.
                                }
                            }
                            PathFindingCore.Utilities.ignoreCheckTiles.Add(tileException);
                            tileException.serializeJson(Path.Combine(ModCore.CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
                            //StardustCore.ModCore.SerializationManager.
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static int calculatePathCost(object obj)
        {
            object[] objArr = (object[])obj;
            TileNode v      = (TileNode)objArr[0];
            bool     placement;

            try
            {
                placement = (bool)objArr[1];
            }
            catch (Exception err)
            {
                placement = true;
            }
            foreach (var q in objArr)
            {
                ModCore.CoreMonitor.Log("OK THIS IS THE RESULT !: " + q, LogLevel.Alert);
            }
            if (v == null)
            {
                ModCore.CoreMonitor.Log("WTF MARK!!!!!!: ", LogLevel.Alert);
            }
            bool moveOn = false;

            WindowsInput.InputSimulator.SimulateKeyUp(WindowsInput.VirtualKeyCode.VK_X);
            int                     xMin      = -1;
            int                     yMin      = -1;
            int                     xMax      = 1;
            int                     yMax      = 1;
            List <TileNode>         miniGoals = new List <TileNode>();
            List <List <TileNode> > paths     = new List <List <TileNode> >();

            //try to set children to tiles where children haven't been before
            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    if (x == 0 && y == 0)
                    {
                        continue;
                    }

                    //Include these 4 checks for just left right up down movement. Remove them to enable 8 direction path finding
                    if (x == -1 && y == -1)
                    {
                        continue;                     //upper left
                    }
                    if (x == -1 && y == 1)
                    {
                        continue;                    //bottom left
                    }
                    if (x == 1 && y == -1)
                    {
                        continue;                    //upper right
                    }
                    if (x == 1 && y == 1)
                    {
                        continue;                   //bottom right
                    }
                    Vector2 pos = new Vector2(v.tileLocation.X + x, v.tileLocation.Y + y);
                    //ModCore.CoreMonitor.Log("AHHHHHHH POSITION: " + pos.ToString(), LogLevel.Alert);
                    bool f = PathFindingCore.TileNode.checkIfICanPlaceHere(v, pos * Game1.tileSize, v.thisLocation, true, true);
                    ModCore.CoreMonitor.Log("OK THIS IS THE RESULT F: " + f, LogLevel.Alert);
                    if (f == true)
                    {
                        TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));
                        if (placement)
                        {
                            t.placementAction(v.thisLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize);
                        }
                        else
                        {
                            t.fakePlacementAction(v.thisLocation, (int)pos.X, (int)pos.Y);
                        }
                        //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(t, Game1.currentLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize));
                        miniGoals.Add(t);
                        //Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "CostCalculation"));
                    }
                }
            }
            List <TileNode> removalList = new List <TileNode>();

            foreach (var nav in miniGoals)
            {
                TileNode tempSource = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));
                if (placement)
                {
                    tempSource.placementAction(Game1.player.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
                }
                else
                {
                    tempSource.fakePlacementAction(v.thisLocation, (int)v.tileLocation.X, (int)v.tileLocation.Y);
                }

                List <TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, nav, new List <TileNode>(), true, true);

                Utilities.clearExceptionListWithName(placement, "Child");

                ModCore.CoreMonitor.Log(tempSource.tileLocation.ToString() + tempSource.tileLocation.ToString());
                ModCore.CoreMonitor.Log(nav.tileLocation.ToString() + nav.tileLocation.ToString());

                if (path.Count != 0)
                {
                    ModCore.CoreMonitor.Log("PATH WAS NOT NULL", LogLevel.Warn);
                    paths.Add(path);
                    foreach (var someTile in path)
                    {
                        if (someTile == nav)
                        {
                            removalList.Add(someTile);
                        }
                        StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(someTile);
                        if (placement)
                        {
                            try
                            {
                                StardewValley.Object ob = someTile.thisLocation.objects[someTile.tileLocation];
                                ModCore.CoreMonitor.Log(ob.name);
                                if (ob.name == "Twig")
                                {
                                    ModCore.CoreMonitor.Log("Culperate 2");
                                }
                                someTile.thisLocation.objects.Remove(someTile.tileLocation);
                            }
                            catch (Exception err)
                            {
                            }
                        }
                        //someTile.performRemoveAction(someTile.tileLocation, someTile.thisLocation);
                        //StardustCore.Utilities.masterRemovalList.Add(v);
                    }
                }
            }
            foreach (var q in removalList)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(q);
                if (placement)
                {
                    try
                    {
                        StardewValley.Object ob = q.thisLocation.objects[q.tileLocation];
                        ModCore.CoreMonitor.Log(ob.name);
                        if (ob.name == "Twig")
                        {
                            ModCore.CoreMonitor.Log("Culperate 1");
                        }
                        q.thisLocation.objects.Remove(q.tileLocation);
                    }
                    catch (Exception err)
                    {
                    }
                }
            }
            removalList.Clear();
            int             pathCost    = 999999999;
            List <TileNode> correctPath = new List <TileNode>();

            foreach (var potentialPath in paths)
            {
                if (potentialPath.Count == 0)
                {
                    continue;
                }
                if (potentialPath.Count < pathCost)
                {
                    pathCost    = potentialPath.Count;
                    correctPath = potentialPath;
                }
            }

            foreach (var goodTile in correctPath)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Add(goodTile);
                //goodTile.placementAction(goodTile.thisLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize);
                //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(goodTile, Game1.currentLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize));
            }
            //END HERE FOR JUST CALCULATING PATH COST
            if (paths.Count == 0)
            {
                return(Int32.MaxValue);
            }
            return(correctPath.Count);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This is used to pathfind to any target that statisfies conditions. The first one hit becomes the new goal.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static List <TileNode> getAnyIdealPath(object obj)
        {
            object[]        objArr = (object[])obj;
            List <TileNode> vList  = (List <TileNode>)objArr[0];

            bool utility = true;

            int                     xMin      = -1;
            int                     yMin      = -1;
            int                     xMax      = 1;
            int                     yMax      = 1;
            List <TileNode>         miniGoals = new List <TileNode>();
            List <List <TileNode> > paths     = new List <List <TileNode> >();

            //try to set children to tiles where children haven't been before
            foreach (var v in vList)
            {
                for (int x = xMin; x <= xMax; x++)
                {
                    for (int y = yMin; y <= yMax; y++)
                    {
                        if (x == 0 && y == 0)
                        {
                            continue;
                        }

                        //Include these 4 checks for just left right up down movement. Remove them to enable 8 direction path finding
                        if (x == -1 && y == -1)
                        {
                            continue;                     //upper left
                        }
                        if (x == -1 && y == 1)
                        {
                            continue;                    //bottom left
                        }
                        if (x == 1 && y == -1)
                        {
                            continue;                    //upper right
                        }
                        if (x == 1 && y == 1)
                        {
                            continue;                   //bottom right
                        }
                        Vector2 pos = new Vector2(v.tileLocation.X + x, v.tileLocation.Y + y);
                        //ModCore.CoreMonitor.Log("AHHHHHHH POSITION: " + pos.ToString(), LogLevel.Alert);
                        bool f = PathFindingCore.TileNode.checkIfICanPlaceHere(v, pos * Game1.tileSize, v.thisLocation, true, utility);
                        // ModCore.CoreMonitor.Log("OK THIS IS THE RESULT F: " + f, LogLevel.Alert);
                        if (f == true)
                        {
                            TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));
                            if (placement)
                            {
                                t.placementAction(v.thisLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize);
                            }
                            else
                            {
                                t.fakePlacementAction(v.thisLocation, (int)pos.X, (int)pos.Y);
                            }
                            //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode( t, Game1.currentLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize));
                            miniGoals.Add(t);
                            Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Navigation"));
                        }
                    }
                }
            }
            List <TileNode> removalList = new List <TileNode>();

            Utilities.clearExceptionListWithName("Child");
            Utilities.clearExceptionListWithName("Navigation");
            TileNode tempSource = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));

            if (placement)
            {
                tempSource.placementAction(Game1.player.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
            }
            else
            {
                tempSource.fakePlacementAction(Game1.player.currentLocation, Game1.player.getTileX(), Game1.player.getTileY());
            }

            Utilities.tileExceptionList.Add(new TileExceptionMetaData(tempSource, "Navigation"));
            //StaardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(tempSource, Game1.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize));


            //have this take in a list of goals and see which goal it reaches first
            List <TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, miniGoals, new List <TileNode>(), placement, utility);

            ModCore.CoreMonitor.Log("OK MY PATH IS:" + path.Count);

            Utilities.clearExceptionListWithName("Child");
            Utilities.clearExceptionListWithName("Navigation");
            if (path.Count == 0)
            {
                ModCore.CoreMonitor.Log("NOPE, no path I guess.", LogLevel.Warn);
            }
            else
            {
                ModCore.CoreMonitor.Log("There is a path", LogLevel.Alert);
                ModCore.CoreMonitor.Log("COST OF THE PATH IS: " + path.Count.ToString(), LogLevel.Alert);
            }
            if (path.Count != 0)
            {
                //ModCore.CoreMonitor.Log("PATH WAS NOT NULL", LogLevel.Warn);
                paths.Add(path);
                foreach (var someTile in path)
                {
                    removalList.Add(someTile);
                    StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(someTile);
                    if (placement)
                    {
                        someTile.thisLocation.objects.Remove(someTile.tileLocation);
                    }

                    //someTile.performRemoveAction(someTile.tileLocation, someTile.thisLocation);
                    //StardustCore.Utilities.masterRemovalList.Add(someTile);
                    //ModCore.CoreMonitor.Log("CAUGHT MY CULPERATE", LogLevel.Warn);
                }
            }

            Console.WriteLine("GOALS COUNT:" + miniGoals.Count);
            foreach (var q in removalList)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(q);
                if (placement)
                {
                    q.thisLocation.objects.Remove(q.tileLocation);
                }
            }
            removalList.Clear();
            int             pathCost    = 999999999;
            List <TileNode> correctPath = new List <TileNode>();

            foreach (var potentialPath in paths)
            {
                if (potentialPath.Count == 0)
                {
                    continue;
                }
                if (potentialPath.Count < pathCost)
                {
                    pathCost    = potentialPath.Count;
                    correctPath = potentialPath;
                }
            }


            return(correctPath);
        }
Exemplo n.º 5
0
        public static void pathToSingleChest(object obj)
        {
            object[] objArr = (object[])obj;
            TileNode v      = (TileNode)objArr[0];
            bool     moveOn = false;

            foreach (var q in Utilities.tileExceptionList)
            {
                if (q.tile == v && q.actionType == "Chest")
                {
                    moveOn = true;
                }
            }
            if (moveOn == false)
            {
                return;
            }

            WindowsInput.InputSimulator.SimulateKeyUp(WindowsInput.VirtualKeyCode.VK_C);
            int                     xMin      = -1;
            int                     yMin      = -1;
            int                     xMax      = 1;
            int                     yMax      = 1;
            List <TileNode>         miniGoals = new List <TileNode>();
            List <List <TileNode> > paths     = new List <List <TileNode> >();

            //try to set children to tiles where children haven't been before
            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    if (x == 0 && y == 0)
                    {
                        continue;
                    }

                    //Include these 4 checks for just left right up down movement. Remove them to enable 8 direction path finding
                    if (x == -1 && y == -1)
                    {
                        continue;                     //upper left
                    }
                    if (x == -1 && y == 1)
                    {
                        continue;                    //bottom left
                    }
                    if (x == 1 && y == -1)
                    {
                        continue;                    //upper right
                    }
                    if (x == 1 && y == 1)
                    {
                        continue;                   //bottom right
                    }
                    Vector2 pos = new Vector2(v.tileLocation.X + x, v.tileLocation.Y + y);
                    //ModCore.CoreMonitor.Log("AHHHHHHH POSITION: " + pos.ToString(), LogLevel.Alert);
                    bool f = PathFindingCore.TileNode.checkIfICanPlaceHere(v, pos * Game1.tileSize, v.thisLocation, true);
                    // ModCore.CoreMonitor.Log("OK THIS IS THE RESULT F: " + f, LogLevel.Alert);
                    if (f == true)
                    {
                        TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));
                        t.placementAction(Game1.currentLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize);
                        //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode( t, Game1.currentLocation, (int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize));
                        miniGoals.Add(t);
                        Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "CropNavigation"));
                    }
                }
            }
            List <TileNode> removalList = new List <TileNode>();

            foreach (var nav in miniGoals)
            {
                TileNode tempSource = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.RosyBrown));
                tempSource.placementAction(Game1.player.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
                //StaardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(tempSource, Game1.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize));
                List <TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, nav, new List <TileNode>(), true);

                if (path.Count != 0)
                {
                    //ModCore.CoreMonitor.Log("PATH WAS NOT NULL", LogLevel.Warn);
                    paths.Add(path);
                    foreach (var someTile in path)
                    {
                        if (someTile == nav)
                        {
                            removalList.Add(someTile);
                        }
                        StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(someTile);
                        someTile.thisLocation.objects.Remove(someTile.tileLocation);
                        //someTile.performRemoveAction(someTile.tileLocation, someTile.thisLocation);
                        //StardustCore.Utilities.masterRemovalList.Add(someTile);
                        //ModCore.CoreMonitor.Log("CAUGHT MY CULPERATE", LogLevel.Warn);
                    }
                }
            }
            Console.WriteLine("GOALS COUNT:" + miniGoals.Count);
            foreach (var q in removalList)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(q);
                q.thisLocation.objects.Remove(q.tileLocation);
            }
            removalList.Clear();
            int             pathCost    = 999999999;
            List <TileNode> correctPath = new List <TileNode>();

            foreach (var potentialPath in paths)
            {
                if (potentialPath.Count == 0)
                {
                    continue;
                }
                if (potentialPath.Count < pathCost)
                {
                    pathCost    = potentialPath.Count;
                    correctPath = potentialPath;
                }
            }

            foreach (var goodTile in correctPath)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Add(goodTile);
                //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(goodTile, Game1.currentLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize));
                goodTile.placementAction(goodTile.thisLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize);
            }
            PathFindingLogic.calculateMovement(correctPath);
            if (v.tileLocation.X < Game1.player.getTileX())
            {
                Game1.player.faceDirection(3);
            }
            else if (v.tileLocation.X > Game1.player.getTileX())
            {
                Game1.player.faceDirection(1);
            }
            else if (v.tileLocation.Y < Game1.player.getTileY())
            {
                Game1.player.faceDirection(0);
            }
            else if (v.tileLocation.Y > Game1.player.getTileY())
            {
                Game1.player.faceDirection(2);
            }

            bool        move             = false;
            Chest       chest            = (Chest)v.thisLocation.objects[v.tileLocation];
            List <Item> removalListSeeds = new List <Item>();

            //Try to grab all the seeds I can from the chest.
            while (Game1.player.isInventoryFull() == false && chest.items.Count > 0)
            {
                if (chest.giftbox)
                {
                    ModCore.CoreMonitor.Log("GIFT BOX", LogLevel.Warn);
                    v.thisLocation.objects.Remove(v.tileLocation);
                }
                foreach (var item in chest.items)
                {
                    if (item.getCategoryName() == "Seed")
                    {
                        int seedIndex = item.parentSheetIndex;

                        if (seedIndex == 770)
                        {
                            seedIndex = Crop.getRandomLowGradeCropForThisSeason(Game1.currentSeason);
                            if (seedIndex == 473)
                            {
                                --seedIndex;
                            }
                        }

                        StardewValley.Crop c = new Crop(seedIndex, 0, 0);

                        if (c.seasonsToGrowIn.Contains(Game1.currentSeason))
                        {
                            Game1.player.addItemByMenuIfNecessary(item);
                            removalListSeeds.Add(item);
                            break;
                        }
                    }
                }


                foreach (var remove in removalListSeeds)
                {
                    chest.items.Remove(remove);
                }
                // if (WindowsInput.InputSimulator.IsKeyDown(WindowsInput.VirtualKeyCode.VK_C) == false) WindowsInput.InputSimulator.SimulateKeyDown(WindowsInput.VirtualKeyCode.VK_C);



                Vector2 center = new Vector2();
                if (Game1.player.facingDirection == 2)
                {
                    center = Utilities.parseCenterFromTile((int)v.tileLocation.X + 1, (int)v.tileLocation.Y);
                    continue;
                }
                if (Game1.player.facingDirection == 1)
                {
                    center = Utilities.parseCenterFromTile((int)v.tileLocation.X - 1, (int)v.tileLocation.Y);
                    continue;
                }
                if (Game1.player.facingDirection == 0)
                {
                    center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y + 1);
                    continue;
                }
                if (Game1.player.facingDirection == 3)
                {
                    center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y - 1);
                    continue;
                }
                Game1.player.position = center;
            }
            Utilities.cleanExceptionList(v);
            StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
            // StardustCore.Utilities.masterRemovalList.Add(v);
            //v.performRemoveAction(v.tileLocation, v.thisLocation);
            // v.thisLocation.objects.Remove(v.tileLocation);
            foreach (var goodTile in correctPath)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(goodTile);
                //StardustCore.Utilities.masterRemovalList.Add(v);
                goodTile.performRemoveAction(goodTile.tileLocation, goodTile.thisLocation);
                //goodTile.placementAction(goodTile.thisLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize);
            }
            //WindowsInput.InputSimulator.SimulateKeyUp(WindowsInput.VirtualKeyCode.VK_C);
        }