Пример #1
0
        public static void pathToMap(string s, string[] args)
        {
            if (args.Length == 0)
            {
                ModCore.CoreMonitor.Log("Need 1 parameter. MapName");
                ModCore.CoreMonitor.Log("OR need 3 parameters. MapName, xTile, yTile");
                return;
            }
            else
            {
                if (args.Length == 1)
                {
                    //path to the map location.
                    WarpGoal.getWarpChain(Game1.player.currentLocation, args[0]);
                }

                if (args.Length >= 3)
                {
                    //path to the map location.
                    WarpGoal.pathToWorldTile(Game1.player.currentLocation, args[0], Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
                }
            }
        }
Пример #2
0
        public static bool interruptionTasks(CustomTask v)
        {
            if (v.taskMetaData.bedTimePrerequisite.enoughTimeToDoTask() == false)
            {
                CustomTask task = WayPoints.pathToWayPointReturnTask("bed");
                if (task == null)
                {
                    ModCore.CoreMonitor.Log("SOMETHING WENT WRONG WHEN TRYING TO GO TO BED", LogLevel.Error);
                    return(false);
                }
                ModCore.CoreMonitor.Log("Not enough time remaining in day. Going home and removing tasks.", LogLevel.Alert);
                task.runTask();
                return(true);
            }

            if (v.taskMetaData.locationPrerequisite.isPlayerAtLocation() == false)
            {
                //Force player to move to that location, but also need the cost again....
                // ModCore.CoreMonitor.Log("PLAYERS LOCATION:"+Game1.player.currentLocation.name);
                Utilities.tileExceptionList.Clear();
                CustomTask task = WarpGoal.getWarpChainReturnTask(Game1.player.currentLocation, v.taskMetaData.locationPrerequisite.location.name);
                if (task == null)
                {
                    ModCore.CoreMonitor.Log("SOMETHING WENT WRONG WHEN TRYING TO GO TO" + v.taskMetaData.locationPrerequisite.location.name, LogLevel.Error);
                    return(false);
                }

                task.runTask();
                object[]        arr = (object[])v.objectParameterDataArray;
                List <TileNode> path;
                try
                {
                    List <List <TileNode> > okList    = (arr[0] as List <List <TileNode> >);
                    List <TileNode>         smallList = okList.ElementAt(okList.Count - 1);
                    TileNode tile = smallList.ElementAt(smallList.Count - 1);
                    //arr[0] = WarpGoal.pathToWorldTileReturnTask(Game1.player.currentLocation, v.taskMetaData.locationPrerequisite.location.name,(int) tile.tileLocation.X,(int) tile.tileLocation.Y);
                    TileNode s = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
                    s.fakePlacementAction(Game1.player.currentLocation, Game1.player.getTileX(), Game1.player.getTileY());

                    path = Utilities.getIdealPath(tile, s);
                }
                catch (Exception err)
                {
                    Utilities.tileExceptionList.Clear();
                    List <TileNode> smallList = (arr[1] as List <TileNode>);
                    TileNode        tile      = smallList.ElementAt(smallList.Count - 1);
                    //ModCore.CoreMonitor.Log("LOC:" + tile.thisLocation + tile.thisLocation);


                    Warp         lastWarp     = new Warp(-1, -1, "Grahm", -1, -1, false);
                    GameLocation fakeLocation = Game1.getLocationFromName(Game1.player.currentLocation.name);
                    foreach (var ok in fakeLocation.warps)
                    {
                        if (ok.X == Game1.player.getTileX() && ok.Y == Game1.player.getTileY() + 1)
                        {
                            lastWarp = ok;
                        }
                    }

                    //ModCore.CoreMonitor.Log("MYLOC:" + lastWarp.TargetName + lastWarp.TargetX +" "+lastWarp.TargetY);
                    //arr[0] = WarpGoal.pathToWorldTileReturnTask(Game1.player.currentLocation, v.taskMetaData.locationPrerequisite.location.name,(int) tile.tileLocation.X,(int) tile.tileLocation.Y);
                    TileNode s = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
                    s.fakePlacementAction(Game1.getLocationFromName(lastWarp.TargetName), lastWarp.TargetX, lastWarp.TargetY);

                    path = Utilities.getIdealPath(tile, s);
                    //arr[0] = s;
                }

                // ModCore.CoreMonitor.Log("PATHCOUNT:"+path.Count);

                //arr[1] = path;
                //v.objectParameterDataArray = arr;
                PathFindingLogic.calculateMovement(path);
                return(false);
            }

            if (v.taskMetaData.name == "Water Crop")
            {
                StardewValley.Tools.WateringCan w = new WateringCan();
                bool found = false;
                foreach (var item in Game1.player.items)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.GetType() == typeof(StardewValley.Tools.WateringCan))
                    {
                        w     = (WateringCan)item;
                        found = true;
                    }
                }
                if (found == false)
                {
                    removalList.Add(v);
                    return(false);
                }
                if (w.WaterLeft == 0)
                {
                    CustomTask waterRefill = WaterLogic.getAllWaterTilesTask(Game1.player.currentLocation);
                    ModCore.CoreMonitor.Log("No water in can. Going to refil");
                    waterRefill.runTask();
                    return(true);
                }
                //
            }
            return(false);
        }