Exemplo n.º 1
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.º 2
0
        public static void pathFindToSingleGoal(object data)
        {
            int             index = 0;
            List <TileNode> path  = new List <TileNode>();

            //path.Clear();
            //ModCore.CoreMonitor.Log("LET'S GO!!!!", LogLevel.Error);
            object[] obj = (object[])data;

            TileNode Source = (TileNode)obj[0];

            if (Source.parent != null)
            {
                Source.parent = null;
            }

            // ModCore.CoreMonitor.Log("PATH FROM SOURCE: "+Source.tileLocation, LogLevel.Error);

            TileNode Goal = (TileNode)obj[1];
            // ModCore.CoreMonitor.Log("PATH To GOAL: " + Goal.tileLocation, LogLevel.Error);
            List <TileNode> Queue = (List <TileNode>)obj[2];

            totalPathCost = 0;
            TileNode currentNode = Source;

            queue.Add(currentNode);
            index++;
            bool goalFound = false;

            while (currentNode.tileLocation != Goal.tileLocation && queue.Count != 0)
            {
                // ModCore.CoreMonitor.Log("LET'S GO SINGLE GOAL!!!!", LogLevel.Error);
                //Add children to current node
                int xMin = -1;
                int yMin = -1;
                int xMax = 1;
                int yMax = 1;

                //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
                        }
                        //TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);

                        TileNode.setSingleTileAsChild(currentNode, (int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y, false);
                        Vector2 check = new Vector2((int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y);
                        if (check.X == Goal.tileLocation.X && check.Y == Goal.tileLocation.Y)
                        {
                            Goal.parent           = currentNode;
                            currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightGreen);
                            currentNode           = Goal;
                            // ModCore.CoreMonitor.Log("SNAGED THE GOAL!!!!!!");
                            //System.Threading.Thread.Sleep(2000);
                            goalFound = true;
                        }
                    }
                }
                if (goalFound == true)
                {
                    currentNode = Goal;
                    //ModCore.CoreMonitor.Log("FOUND YOU!!!");
                    //System.Threading.Thread.Sleep(2000);
                    break;
                }
                List <TileNode> adjList = new List <TileNode>();
                foreach (var node in currentNode.children)
                {
                    //TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);
                    //TileNode.setSingleTileAsChild(source, (int)source.tileLocation.X + x, (int)source.tileLocation.Y + y);
                    if (node.parent == null)
                    {
                        ModCore.CoreMonitor.Log("I DONT UNDERSTAND!");
                        System.Threading.Thread.Sleep(delay);
                    }
                    //ModCore.CoreMonitor.Log("ok checking adj:" + node.tileLocation.ToString());


                    if (node.seenState == 0)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightPink); //Seen
                        adjList.Add(node);
                    }
                    if (node.seenState == 1)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue);
                    }
                    if (node.seenState == 2)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange);
                    }
                }



                foreach (var v in adjList)
                {
                    if (queue.Contains(v))
                    {
                        continue;
                    }
                    else
                    {
                        queue.Add(v);
                    }
                }
                currentNode.seenState = 2;

                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange); //Finished
                try
                {
                    currentNode = queue.ElementAt(index);
                }
                catch (Exception err)
                {
                    break;
                }
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue); //Working
                index++;
            }

            if (currentNode.tileLocation != Goal.tileLocation)
            {
                // ModCore.CoreMonitor.Log("NO PATH FOUND", LogLevel.Error);
                return;
            }

            if (currentNode.tileLocation == Goal.tileLocation)
            {
                // ModCore.CoreMonitor.Log("SWEET BEANS!!!!!!", LogLevel.Error);
                queue.Clear();
                index = 0;
                //ModCore.CoreMonitor.Log(currentNode.parent.ToString(), LogLevel.Error);
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightGreen);
                //currentGoal.drawColor=
            }

            while (currentNode.parent != null)
            {
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
                path.Add(currentNode);
                if (currentNode.parent.tileLocation.X < currentNode.tileLocation.X)
                {
                    currentNode.parent.animationManager.setAnimation("Right", 0);
                }
                if (currentNode.parent.tileLocation.X > currentNode.tileLocation.X)
                {
                    currentNode.parent.animationManager.setAnimation("Left", 0);
                }
                if (currentNode.parent.tileLocation.Y < currentNode.tileLocation.Y)
                {
                    currentNode.parent.animationManager.setAnimation("Down", 0);
                }
                if (currentNode.parent.tileLocation.Y > currentNode.tileLocation.Y)
                {
                    currentNode.parent.animationManager.setAnimation("Up", 0);
                }
                currentNode.parent.animationManager.enableAnimation();
                currentNode = currentNode.parent;
                System.Threading.Thread.Sleep(delay);
                if (currentNode.parent == null)
                {
                    currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
                    path.Add(currentNode);
                }
            }
            List <TileNode> removalList = new List <TileNode>();

            foreach (var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
            {
                if (v is TileNode)
                {
                    foreach (var exc in Utilities.tileExceptionList)
                    {
                        if (exc.tile == (v as TileNode))
                        {
                            continue;
                        }
                    }

                    if (path.Contains(v) || goals.Contains(v) || v.drawColor == StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red))
                    {
                        continue;
                    }
                    else
                    {
                        removalList.Add((TileNode)v);
                    }
                }
            }
            foreach (var v in removalList)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
                v.thisLocation.removeObject(v.tileLocation, false);
                //v.performRemoveAction(v.tileLocation, v.thisLocation);
                //StardustCore.Utilities.masterRemovalList.Add(v);
            }

            calculateMovement(path);
            // goals.Remove(Goal);
            //goals.Remove(Goal);
        }
Exemplo n.º 3
0
        public static void calculateMovement(List <TileNode> path)
        {
            path.Reverse();

            // ModCore.CoreMonitor.Log("PATH COUNT TIME!!!!: " + path.Count);
            bool            xTargetReached = false;
            bool            yTargetReached = false;
            List <TileNode> removalList    = new List <TileNode>();

            if (path.Count == 0)
            {
                return;
            }
            while (path.Count > 0)
            {
                TileNode w = path[0];

                // ModCore.CoreMonitor.Log("Here: " +Game1.player.position.ToString());
                //  ModCore.CoreMonitor.Log("LOC: " + Game1.player.currentLocation);
                Vector2 center2 = Utilities.parseCenterFromTile((int)w.tileLocation.X, (int)w.tileLocation.Y);
                // ModCore.CoreMonitor.Log("Goto: " + center2);
                //ModCore.CoreMonitor.Log("My position now: " + Game1.player.getTileLocation());
                //ModCore.CoreMonitor.Log("My Point position now: " + Game1.player.getTileLocationPoint());

                if (Game1.player.getTileX() == w.tileLocation.X && Game1.player.getTileY() == w.tileLocation.Y)
                {
                    removalList.Add(w);

                    path.Remove(w);
                    xTargetReached = false;
                    yTargetReached = false;

                    //ModCore.CoreMonitor.Log("LOOOP", LogLevel.Debug);
                    // return;
                    continue;
                }
                else
                {
                    Vector2 center = Utilities.parseCenterFromTile((int)w.tileLocation.X, (int)w.tileLocation.Y);

                    while (Game1.player.position.X > center.X && xTargetReached == false)
                    {
                        if (Utilities.isWithinRange(Game1.player.position.X, center.X, 6) == true)
                        {
                            //ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
                            xTargetReached = true;
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                            //break;
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_A) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
                        }
                    }


                    while (Game1.player.position.X < center.X && xTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("Player x: " + Game1.player.position.X);
                        //ModCore.CoreMonitor.Log("center x: " + center.X);
                        if (Utilities.isWithinRange(Game1.player.position.X, center.X, 6) == true)
                        {
                            xTargetReached = true;
                            //ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_D) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
                        }
                    }



                    while (Game1.player.position.Y < center.Y && yTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("banana");
                        if (Utilities.isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
                        {
                            yTargetReached = true;
                            //ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");

                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
                        }
                    }



                    while (Game1.player.position.Y > center.Y && yTargetReached == false)
                    {
                        //ModCore.CoreMonitor.Log("potato");
                        if (Utilities.isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
                        {
                            yTargetReached = true;
                            // ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
                            InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                            continue;
                        }
                        if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W) == false)
                        {
                            InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
                        }
                    }


                    if (xTargetReached == true && yTargetReached == true)
                    {
                        removalList.Add(w);

                        path.Remove(w);
                        xTargetReached = false;
                        yTargetReached = false;


                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                        InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                        //return;
                        //ModCore.CoreMonitor.Log("Reached goal!", LogLevel.Error);
                        //Game1.player.position = new Vector2(center.X, center.Y);
                        continue;
                    }


                    ModCore.CoreMonitor.Log("UNCAUGHT EXCEPTION", LogLevel.Error);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
                }
            }
            foreach (var v in removalList)
            {
                //v.thisLocation.objects.Remove(v.tileLocation);
                //v.thisLocation.removeObject(v.tileLocation, false);
                //v.performRemoveAction(v.tileLocation, v.thisLocation);
                //StardustCore.Utilities.masterRemovalList.Add(v);
                v.thisLocation.objects.Remove(v.tileLocation);
                //ModCore.CoreMonitor.Log("WHUT???"+v.tileLocation);
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
                //var ok = v;
                //ok = null;
            }
            //goals.Clear();
        }
Exemplo n.º 4
0
        public static List <TileNode> pathFindToSingleGoalReturnPathList(object data)
        {
            int             index = 0;
            List <TileNode> path  = new List <TileNode>();

            //path.Clear();
            //ModCore.CoreMonitor.Log("LET'S GO 2222!!!!", LogLevel.Error);
            object[] obj = (object[])data;

            TileNode Source = (TileNode)obj[0];

            if (Source.parent != null)
            {
                Source.parent = null;
            }

            //

            List <TileNode> Goals = (List <TileNode>)obj[1];
            List <TileNode> Queue = (List <TileNode>)obj[2];

            totalPathCost = 0;
            TileNode currentNode = Source;

            bool placement       = (bool)obj[3];
            bool checkForUtility = (bool)obj[4];

            queue.Add(currentNode);
            // index++;
            bool goalFound = false;

            while (doesNodeEqualGoal(currentNode, Goals).Key == false && queue.Count != 0)
            {
                //  ModCore.CoreMonitor.Log("LET'S GO PATH!!!!", LogLevel.Error);
                // ModCore.CoreMonitor.Log("PATH FROM Node: " + currentNode.tileLocation, LogLevel.Error);
                // ModCore.CoreMonitor.Log("PATH FROM Source: " + Source.tileLocation, LogLevel.Error);
                // ModCore.CoreMonitor.Log("GOALS COUNT " + Goals.Count, LogLevel.Error);

                // ModCore.CoreMonitor.Log("THIS IS MY MISTAKE!!!!!!! " + Goals.Count, LogLevel.Error);

                //Console.WriteLine("OK WTF IS GOING ON????");
                //Add children to current node
                int xMin = -1;
                int yMin = -1;
                int xMax = 1;
                int yMax = 1;

                //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
                        }
                        //TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);
                        //ModCore.CoreMonitor.Log("HERE1", LogLevel.Error);

                        TileNode.setSingleTileAsChild(currentNode, (int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y, checkForUtility, placement);
                        // ModCore.CoreMonitor.Log("OR NO?", LogLevel.Error);
                        Vector2 check = new Vector2((int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y);
                        if (doesNodeEqualGoal(check, Goals).Key == true)
                        {
                            doesNodeEqualGoal(check, Goals).Value.parent = currentNode;
                            // Goal = doesNodeEqualGoal(check, Goals).Value;
                            currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightGreen);
                            currentNode           = doesNodeEqualGoal(check, Goals).Value;
                            // ModCore.CoreMonitor.Log("SNAGED THE GOAL!!!!!!");
                            //System.Threading.Thread.Sleep(2000);
                            goalFound = true;
                        }
                    }
                }
                if (goalFound == true)
                {
                    currentNode = doesNodeEqualGoal(currentNode, Goals).Value;
                    // ModCore.CoreMonitor.Log("FOUND YOU!!!");

                    //  path.Add(currentNode);
                    //System.Threading.Thread.Sleep(2000);
                    break;
                }
                List <TileNode> adjList = new List <TileNode>();
                foreach (var node in currentNode.children)
                {
                    // ModCore.CoreMonitor.Log("MAYBE HERE",LogLevel.Warn);
                    //TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);
                    //TileNode.setSingleTileAsChild(source, (int)source.tileLocation.X + x, (int)source.tileLocation.Y + y);
                    if (node.parent == null)
                    {
                        //ModCore.CoreMonitor.Log("I DONT UNDERSTAND!");
                        System.Threading.Thread.Sleep(delay);
                    }
                    //ModCore.CoreMonitor.Log("ok checking adj:" + node.tileLocation.ToString());


                    if (node.seenState == 0)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightPink); //Seen
                    }
                    if (node.seenState == 1)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue);
                    }
                    if (node.seenState == 2)
                    {
                        node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange);
                    }
                    adjList.Add(node);
                }



                foreach (var v in adjList)
                {
                    if (queue.Contains(v))
                    {
                        continue;
                    }
                    else
                    {
                        queue.Add(v);
                    }
                }
                currentNode.seenState = 2;

                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange); //Finished
                try
                {
                    currentNode = queue.ElementAt(index);
                }
                catch (Exception err)
                {
                    //ModCore.CoreMonitor.Log("INDEX ERROR:"+index, LogLevel.Error);
                    break;
                }
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue); //Working
                index++;
            }

            if (doesNodeEqualGoal(currentNode, Goals).Key == false)
            {
                // ModCore.CoreMonitor.Log("NO PATH FOUND", LogLevel.Error);
                return(new List <TileNode>());
            }

            if (doesNodeEqualGoal(currentNode, Goals).Key == true)
            {
                // ModCore.CoreMonitor.Log("SWEET BEANS!!!!!!", LogLevel.Error);
                queue.Clear();
                index = 0;
                //ModCore.CoreMonitor.Log(currentNode.parent.ToString(), LogLevel.Error);
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightGreen);
                //currentGoal.drawColor=
            }

            while (currentNode.parent != null)
            {
                currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
                path.Add(currentNode);
                if (currentNode.parent.tileLocation.X < currentNode.tileLocation.X)
                {
                    currentNode.parent.animationManager.setAnimation("Right", 0);
                }
                if (currentNode.parent.tileLocation.X > currentNode.tileLocation.X)
                {
                    currentNode.parent.animationManager.setAnimation("Left", 0);
                }
                if (currentNode.parent.tileLocation.Y < currentNode.tileLocation.Y)
                {
                    currentNode.parent.animationManager.setAnimation("Down", 0);
                }
                if (currentNode.parent.tileLocation.Y > currentNode.tileLocation.Y)
                {
                    currentNode.parent.animationManager.setAnimation("Up", 0);
                }
                if (currentNode.parent.tileLocation == currentNode.tileLocation)
                {
                    currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Black); //Working
                }
                currentNode.parent.animationManager.enableAnimation();
                currentNode = currentNode.parent;
                System.Threading.Thread.Sleep(delay);
                if (currentNode.parent == null)
                {
                    currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
                    path.Add(currentNode);
                }
                // ModCore.CoreMonitor.Log("??????");
            }
            List <TileNode> removalList = new List <TileNode>();
            List <TileNode> ignoreList  = new List <TileNode>();

            foreach (var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
            {
                if (v is TileNode)
                {
                    // ModCore.CoreMonitor.Log("Removing item: " + why + " / " + StardustCore.ModCore.SerializationManager.trackedObjectList.Count);
                    removalList.Add((TileNode)v);
                }
            }

            foreach (var v in removalList)
            {
                StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
                //v.performRemoveAction(v.tileLocation, v.thisLocation);

                try
                {
                    StardewValley.Object ob = v.thisLocation.objects[v.tileLocation];

                    //ModCore.CoreMonitor.Log(ob.name);
                    if (v.name != "Generic Colored Tile")
                    {
                        continue;                                  // ModCore.CoreMonitor.Log("Culperate 3");
                    }
                    if (placement)
                    {
                        v.thisLocation.removeObject(v.tileLocation, false);
                    }
                }
                catch (Exception err)
                {
                }


                //StardustCore.Utilities.masterRemovalList.Add(v);
            }

            if (path.Count == 0 && goalFound == true)
            {
                path.Add(Source);
            }
            return(path);
            //calculateMovement(path);
            // goals.Remove(Goal);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Used to return the path to the destination without moving towards the goal.
 /// </summary>
 /// <param name="Source">The starting point to path from.</param>
 /// <param name="Goal">The goal to path to.</param>
 /// <param name="Queue">Depreciated for further builds.</param>
 /// <param name="Placement">Whether or not tiles are actually going to be placed</param>
 /// <returns></returns>
 public static List <TileNode> pathFindToSingleGoalReturnPath(TileNode Source, TileNode Goal, List <TileNode> Queue, bool Placement, bool CheckForUtility)
 {
     object[] obj = new object[5];
     obj[0] = Source;
     obj[1] = Goal;
     obj[2] = Queue;
     obj[3] = Placement;
     obj[4] = CheckForUtility;
     return(pathFindToSingleGoalReturnPath(obj));
 }
Exemplo n.º 6
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.º 7
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.º 8
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);
        }