public static void getAllSeasonalSeedsFromAllChestsAtLocation(object obj) { object[] objArr = (object[])obj; GameLocation location = (GameLocation)objArr[0]; foreach (var v in location.objects) { ModCore.CoreMonitor.Log(v.Value.name); if (v.Value is StardewValley.Objects.Chest) { //if contains seeds that can be planted this season. foreach (var item in (v.Value as StardewValley.Objects.Chest).items) { if (item.getCategoryName() == "Seed") { StardewValley.Crop c = new Crop(item.parentSheetIndex, 0, 0); if (c.seasonsToGrowIn.Contains(Game1.currentSeason)) { TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown)); //t.placementAction(Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize); t.tileLocation = new Vector2((int)v.Key.X, (int)v.Key.Y); t.position = new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize); t.thisLocation = location; //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(t, Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize)); Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Chest")); chestsAtThisLocation.Add(t); } } } } } foreach (var v in chestsAtThisLocation) { object[] objList = new object[2]; objList[0] = v; // ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj)); ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(pathToSingleChest, objList, new ExecutionCore.TaskMetaData("GetSeasonalSeedsFromChest", new ExecutionCore.TaskPrerequisites.LocationPrerequisite(v.thisLocation), null, null, new ExecutionCore.TaskPrerequisites.InventoryFullPrerequisite(true))); if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); continue; } ExecutionCore.TaskList.taskList.Add(task); //Utilities.clearExceptionListWithName(true, "Child"); if (task.taskMetaData.pathsToTake == null) { ModCore.CoreMonitor.Log("WTF???"); } ModCore.CoreMonitor.Log("COST:" + task.taskMetaData.cost); objList[1] = task.taskMetaData.pathsToTake[0]; task.objectParameterDataArray = objList; Utilities.clearExceptionListWithName("Child"); Utilities.clearExceptionListWithName("Navigation"); // waterSingleCrop(v); } chestsAtThisLocation.Clear(); }
public static void goToShippingBinShipItem(Item I) { List <TileNode> shippingTiles = new List <TileNode>(); ModCore.CoreMonitor.Log(I.Name); if (I == null) { ModCore.CoreMonitor.Log("DIE"); } if (Game1.player.currentLocation.name == "Farm") { //CHEATING AND STUPID WAY BUT WILL PATH TO SHIPPING BIN. for (int i = 0; i <= 1; i++) { TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown)); t.fakePlacementAction(Game1.currentLocation, 71 + i, 14); Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "ShippingBin")); shippingTiles.Add(t); } } int ok = 0; object[] objList = new object[4]; List <TileNode> tempList = new List <TileNode>(); foreach (var v in shippingTiles) { tempList.Add(v); } objList[0] = tempList; objList[3] = I; // ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj)); //ModCore.CoreMonitor.Log("Processing water tiles:" + shippingTiles.Count.ToString() + " / " + twingCount.ToString()); ok++; int numberOfUses = 1; ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToShippingBinShipItem, objList, new ExecutionCore.TaskMetaData("GoToShippingBin", new LocationPrerequisite(Game1.getLocationFromName("Farm")), null, null, null, null, new ItemPrerequisite(I, I.Stack))); task.objectParameterDataArray = objList; if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); return; } objList[1] = task.taskMetaData.pathsToTake[0]; objList[2] = task.taskMetaData.pathsToTake[0].ElementAt(0); ExecutionCore.TaskList.taskList.Add(task); Utilities.clearExceptionListWithName("Child"); Utilities.tileExceptionList.Clear(); }
public static void makeAsMuchDirtAsSpecifiedAroundFarmer(GameLocation location, int amount, int radius) { List <TileNode> hoeDirtThings = new List <TileNode>(); for (int i = -radius; i <= radius; i++) { for (int j = -radius; j <= radius; j++) { Vector2 position = new Vector2(Game1.player.getTileX() + i, Game1.player.getTileY() + j); //if (hoeDirtThings.Count >= amount) continue; if (canBeHoeDirt(location, position)) { TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightSkyBlue)); //t.placementAction(Game1.currentLocation, (int)i* Game1.tileSize, (int)j * Game1.tileSize); t.fakePlacementAction(location, (int)position.X, (int)position.Y); //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(t, Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize)); PathFindingCore.Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "HoeDirt")); hoeDirtThings.Add(t); } } } int taskAmount = 0; foreach (var v in hoeDirtThings) { if (taskAmount >= amount) { break; } object[] obj = new object[2]; obj[0] = v; // ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj)); StardewValley.Tools.Hoe w = new StardewValley.Tools.Hoe(); ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(hoeSingleTileOfDirt, obj, new ExecutionCore.TaskMetaData("Dig Dirt", new LocationPrerequisite(v.thisLocation), new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1))); if (task.taskMetaData.cost == Int32.MaxValue) { StarAI.PathFindingCore.Utilities.clearExceptionListWithNames(true); Utilities.tileExceptionList.Clear(); continue; } ExecutionCore.TaskList.taskList.Add(task); taskAmount++; obj[1] = task.taskMetaData.pathsToTake[0]; task.objectParameterDataArray = obj; // waterSingleCrop(v); StarAI.PathFindingCore.Utilities.clearExceptionListWithName("Child"); } hoeDirtThings.Clear(); }
public static CustomTask transitionToAdjacentMapReturnTask(GameLocation location, string targetName, int tileX, int tileY) { List <TileNode> warpGoals = new List <TileNode>(); foreach (var v in location.warps) { if (v.TargetName == targetName) { TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown)); t.fakePlacementAction(Game1.currentLocation, v.X, v.Y); Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "WarpGoal")); warpGoals.Add(t); } } int ok = 0; object[] objList = new object[10]; List <TileNode> tempList = new List <TileNode>(); foreach (var v in warpGoals) { tempList.Add(v); } objList[0] = tempList; ok++; int numberOfUses = 1; ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToAdjacentWarpGoalTile, objList, new ExecutionCore.TaskMetaData("GoTo adj map tile", null, null, null, null, null)); if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); return(null); } objList[1] = task.taskMetaData.pathsToTake[0]; objList[2] = task.taskMetaData.pathsToTake[0].ElementAt(0); objList[3] = targetName; objList[4] = new Vector2(tileX, tileY); task.objectParameterDataArray = objList; //ExecutionCore.TaskList.taskList.Add(task); Utilities.clearExceptionListWithName("Child"); Utilities.tileExceptionList.Clear(); warpGoals.Clear(); return(task); }
public static void getAllCropsNeededToBeHarvested() { foreach (var v in Game1.player.currentLocation.terrainFeatures) { if (v.Value is StardewValley.TerrainFeatures.HoeDirt) { if ((v.Value as StardewValley.TerrainFeatures.HoeDirt).crop != null) { //If my dirt needs to be watered and the crop isn't fully grown. if (isCropFullGrown((v.Value as StardewValley.TerrainFeatures.HoeDirt).crop)) { ModCore.CoreMonitor.Log("OK!!!!"); TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LimeGreen)); t.placementAction(Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize); //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(t, Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize)); StarAI.PathFindingCore.Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Harvest")); cropsToHarvest.Add(t); } } } } //Instead of just running this function I should add it to my execution queue. foreach (var v in cropsToHarvest) { object[] obj = new object[2]; obj[0] = v; //ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(harvestSingleCrop), obj)); ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(harvestSingleCrop, obj, new ExecutionCore.TaskMetaData("HarvestSingleCrop", new LocationPrerequisite(v.thisLocation), null, null, new ExecutionCore.TaskPrerequisites.InventoryFullPrerequisite(true))); if (task.taskMetaData.cost == Int32.MaxValue) { StarAI.PathFindingCore.Utilities.clearExceptionListWithNames(true); continue; } ExecutionCore.TaskList.taskList.Add(task); obj[1] = task.taskMetaData.pathsToTake[0]; task.objectParameterDataArray = obj; StarAI.PathFindingCore.Utilities.clearExceptionListWithName("Child"); // waterSingleCrop(v); } cropsToHarvest.Clear(); }
public static void getAllWaterTiles(object obj) { int twingCount = 0; object[] objArr = (object[])obj; GameLocation location = (GameLocation)objArr[0]; // string targetName = "Weeds"; Layer layer = location.map.GetLayer("Back"); for (int i = 0; i <= layer.LayerSize.Width; i++) { for (int j = 0; j <= layer.LayerSize.Height; j++) { if (location.isOpenWater(i, j)) { TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown)); t.fakePlacementAction(location, i, j); Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "ChopTree")); waterTilesAvailable.Add(t); twingCount++; } } } int ok = 0; object[] objList = new object[3]; List <TileNode> tempList = new List <TileNode>(); foreach (var v in waterTilesAvailable) { tempList.Add(v); } objList[0] = tempList; // ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj)); StardewValley.Tools.WateringCan w = new StardewValley.Tools.WateringCan(); ModCore.CoreMonitor.Log("Processing water tiles:" + waterTilesAvailable.Count.ToString() + " / " + twingCount.ToString()); ok++; int numberOfUses = 1; ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToSingleWaterTile, objList, new ExecutionCore.TaskMetaData("GoToWaterTile", new LocationPrerequisite(location), new StaminaPrerequisite(true, 2 * numberOfUses), new ToolPrerequisite(true, w.GetType(), numberOfUses))); if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); return; } objList[1] = task.taskMetaData.pathsToTake[0]; objList[2] = task.taskMetaData.pathsToTake[0].ElementAt(0); task.objectParameterDataArray = objList; ExecutionCore.TaskList.taskList.Add(task); Utilities.clearExceptionListWithName("Child"); waterTilesAvailable.Clear(); Utilities.tileExceptionList.Clear(); }
public static void plantSeeds(GameLocation location2) { List <TileNode> seedsToPlant = new List <TileNode>(); GameLocation location = Game1.getLocationFromName("Farm"); string name = ""; foreach (var seed in Game1.player.items) { if (seed == null) { continue; } if (seed.getCategoryName() == "Seed") { if (parseCropFromSeedIndex(seed.parentSheetIndex).seasonsToGrowIn.Contains(Game1.currentSeason)) { name = seed.Name; } } } if (name == "") { ModCore.CoreMonitor.Log("Error: No valid seeds to plant found in inventory. Try to go buy some"); Utilities.tileExceptionList.Clear(); return; } foreach (var terrain in location.terrainFeatures) { if (terrain.Value is StardewValley.TerrainFeatures.HoeDirt) { //Vector2 position = new Vector2(Game1.player.getTileX() + i, Game1.player.getTileY() + j); //if (hoeDirtThings.Count >= amount) continue; if ((terrain.Value as StardewValley.TerrainFeatures.HoeDirt).crop != null) { continue; } TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightSkyBlue)); //t.placementAction(Game1.currentLocation, (int)i* Game1.tileSize, (int)j * Game1.tileSize); t.fakePlacementAction(location, (int)terrain.Key.X, (int)terrain.Key.Y); //StardustCore.Utilities.masterAdditionList.Add(new StardustCore.DataNodes.PlacementNode(t, Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize)); PathFindingCore.Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "PlantSeeds")); seedsToPlant.Add(t); } } int taskAmount = 0; foreach (var v in seedsToPlant) { object[] obj = new object[2]; obj[0] = v; // ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj)); ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(plantSingleSeedPacket, obj, new ExecutionCore.TaskMetaData("Plant " + name, new LocationPrerequisite(v.thisLocation), null, null)); if (task.taskMetaData.cost == Int32.MaxValue) { StarAI.PathFindingCore.Utilities.clearExceptionListWithNames(true); Utilities.tileExceptionList.Clear(); continue; } ExecutionCore.TaskList.taskList.Add(task); taskAmount++; obj[1] = task.taskMetaData.pathsToTake[0]; task.objectParameterDataArray = obj; // waterSingleCrop(v); StarAI.PathFindingCore.Utilities.clearExceptionListWithName("Child"); Utilities.tileExceptionList.Clear(); } seedsToPlant.Clear(); }