From 175a38597703896a9477f2a528fecb48f5ce8db9 Mon Sep 17 00:00:00 2001 From: Date: Fri, 1 Dec 2017 00:16:53 -0800 Subject: [PATCH] Added functionality for shipping objects --- GeneralMods/StardustCore/Utilities.cs | 17 +- StarAI/StarAI/Commands.cs | 35 ++- StarAI/StarAI/ExecutionCore/TaskList.cs | 10 +- StarAI/StarAI/ExecutionCore/TaskMetaData.cs | 63 ++---- .../TaskPrerequisites/ItemPrerequisite.cs | 56 +++++ StarAI/StarAI/ModCore.cs | 35 ++- .../CropLogic/ShippingLogic.cs | 213 ++++++++++++++++++ .../PathFindingCore/WaterLogic/WaterLogic.cs | 18 +- StarAI/StarAI/StarAI.csproj | 2 + 9 files changed, 390 insertions(+), 59 deletions(-) create mode 100644 StarAI/StarAI/ExecutionCore/TaskPrerequisites/ItemPrerequisite.cs create mode 100644 StarAI/StarAI/PathFindingCore/CropLogic/ShippingLogic.cs diff --git a/GeneralMods/StardustCore/Utilities.cs b/GeneralMods/StardustCore/Utilities.cs index 1b6835d6..c858f792 100644 --- a/GeneralMods/StardustCore/Utilities.cs +++ b/GeneralMods/StardustCore/Utilities.cs @@ -832,6 +832,21 @@ namespace StardustCore return false; } - + public static Item getItemFromInventory(int index) + { + foreach(var v in Game1.player.items) + { + if (v.parentSheetIndex == index) return v; + } + return null; + } + public static Item getItemFromInventory(string name) + { + foreach (var v in Game1.player.items) + { + if (v.Name == name) return v; + } + return null; + } } } diff --git a/StarAI/StarAI/Commands.cs b/StarAI/StarAI/Commands.cs index 1e2c4f0b..e15bd2c9 100644 --- a/StarAI/StarAI/Commands.cs +++ b/StarAI/StarAI/Commands.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using StarAI; using StarAI.PathFindingCore.DebrisLogic; using StarAI.PathFindingCore.WaterLogic; +using StarAI.PathFindingCore.CropLogic; namespace StarAI { @@ -43,6 +44,9 @@ namespace StarAI ModCore.CoreHelper.ConsoleCommands.Add("watercan", "Fill my watering can.", new Action(Commands.fillWateringCan)); ModCore.CoreHelper.ConsoleCommands.Add("fillcan", "Fill my watering can.", new Action(Commands.fillWateringCan)); + + ModCore.CoreHelper.ConsoleCommands.Add("shippingbin", "Goto shipping bin", new Action(Commands.goToShippingBin)); + ModCore.CoreHelper.ConsoleCommands.Add("shipItem", "Fill my watering can.", new Action(Commands.shipItem)); // ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action(Commands.chopAllTwigs)); pathfind("Initialize Delay 0", new string[] { "setDelay", @@ -55,6 +59,35 @@ namespace StarAI ChestLogic.getAllSeasonalSeedsFromAllChestsAtLocation(Game1.player.currentLocation); } + public static void shipItem(string s, string[] args) + { + if (args.Length < 2) + { + ModCore.CoreMonitor.Log("NOT ENOUGH PARAMETERS. NEED 2 ARGS. ItemIndex,Amount"); + return; + } + StardewValley.Object ok =new StardewValley.Object(Convert.ToInt32(args[0]),Convert.ToInt32(args[1])); + + if (ok == null) { + ModCore.CoreMonitor.Log("ITEM IS NULL????"); + return; + } + ExecutionCore.TaskPrerequisites.ItemPrerequisite pre = new ExecutionCore.TaskPrerequisites.ItemPrerequisite(ok, ok.stack); + if (pre.doesPlayerHaveEnoughOfMe()) + { + ShippingLogic.goToShippingBinShipItem(ok); + } + else + { + ModCore.CoreMonitor.Log("Player does not have: " + ok.name + ": amount: " + ok.stack.ToString()); + } + } + + public static void goToShippingBin(string s, string[] args) + { + ShippingLogic.goToShippingBinSetUp(); + } + public static void fillWateringCan(string s, string[] args) { WaterLogic.getAllWaterTiles(Game1.player.currentLocation); @@ -372,7 +405,7 @@ namespace StarAI obj[1] = PathFindingLogic.currentGoal; PathFindingLogic.queue = new List(); obj[2] = PathFindingLogic.queue; - ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(PathFindingLogic.pathFindToSingleGoal, obj,new ExecutionCore.TaskMetaData("Pathfind Command",PathFindingCore.Utilities.calculatePathCost(PathFindingLogic.source,false)))); + // ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(PathFindingLogic.pathFindToSingleGoal, obj,new ExecutionCore.TaskMetaData("Pathfind Command",PathFindingCore.Utilities.calculatePathCost(PathFindingLogic.source,false)))); //ExecutionCore.TaskList.taskList.Add(new Task(new Action(PathFindingLogic.pathFindToSingleGoal),obj)); } #endregion diff --git a/StarAI/StarAI/ExecutionCore/TaskList.cs b/StarAI/StarAI/ExecutionCore/TaskList.cs index 9f5c6385..acfd4e9a 100644 --- a/StarAI/StarAI/ExecutionCore/TaskList.cs +++ b/StarAI/StarAI/ExecutionCore/TaskList.cs @@ -93,12 +93,20 @@ namespace StarAI.ExecutionCore ModCore.CoreMonitor.Log(s.actionType); } v.taskMetaData.calculateTaskCost(t, false); - object[] objArr = new object[3]; + object[] objArr = new object[4]; objArr[0] = (object)t; //List of trees to use for path calculations objArr[1] = (object)v.taskMetaData.path; //The path itself. int malcolm = 0; ModCore.CoreMonitor.Log("THIS IS MALCOLM:" + malcolm); objArr[2] = (object)v.taskMetaData.path.ElementAt(malcolm); //source of whatever is hit. + try + { + objArr[3] = oArray[3]; + } + catch(Exception err2) + { + + } v.objectParameterDataArray = objArr; Utilities.tileExceptionList.Clear(); } diff --git a/StarAI/StarAI/ExecutionCore/TaskMetaData.cs b/StarAI/StarAI/ExecutionCore/TaskMetaData.cs index 7547512c..de15c695 100644 --- a/StarAI/StarAI/ExecutionCore/TaskMetaData.cs +++ b/StarAI/StarAI/ExecutionCore/TaskMetaData.cs @@ -1,4 +1,5 @@ -using StarAI.PathFindingCore; +using StarAI.ExecutionCore.TaskPrerequisites; +using StarAI.PathFindingCore; using System; using System.Collections.Generic; using System.Linq; @@ -20,57 +21,16 @@ namespace StarAI.ExecutionCore public TaskPrerequisites.BedTimePrerequisite bedTimePrerequisite; + public TaskPrerequisites.ItemPrerequisite itemPrerequisite; + public List prerequisitesList; public List path = new List(); - public TaskMetaData(string Name, float Priority, float Cost, float Utility, float Frequency, TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite=null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite=null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull = null, TaskPrerequisites.BedTimePrerequisite BedTimePrereq=null) - { - this.name = Name; - this.priority = Priority; - this.cost = Cost; - this.utility = Utility; - this.frequency = Frequency; - this.staminaPrerequisite = StaminaPrerequisite; - this.toolPrerequisite = ToolPrerequisite; - this.inventoryPrerequisite = InventoryFull; - this.bedTimePrerequisite = BedTimePrereq; - //Make sure to set values correctly incase of null - setUpStaminaPrerequisiteIfNull(); - setUpToolPrerequisiteIfNull(); - setUpInventoryPrerequisiteIfNull(); - setUpBedTimeIfNull(); - this.prerequisitesList = new List(); - this.prerequisitesList.Add(this.staminaPrerequisite); - this.prerequisitesList.Add(this.toolPrerequisite); - this.prerequisitesList.Add(this.inventoryPrerequisite); - this.prerequisitesList.Add(this.bedTimePrerequisite); - } - public TaskMetaData(string Name,float Cost,TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite = null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite = null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull = null,TaskPrerequisites.BedTimePrerequisite BedTimePrereq=null) - { - this.name = Name; - this.cost = Cost; - this.staminaPrerequisite = StaminaPrerequisite; - this.toolPrerequisite = ToolPrerequisite; - this.inventoryPrerequisite = InventoryFull; - - this.bedTimePrerequisite = BedTimePrereq; - //Make sure to set values correctly incase of null - setUpStaminaPrerequisiteIfNull(); - setUpToolPrerequisiteIfNull(); - setUpInventoryPrerequisiteIfNull(); - setUpBedTimeIfNull(); - this.prerequisitesList = new List(); - this.prerequisitesList.Add(this.staminaPrerequisite); - this.prerequisitesList.Add(this.toolPrerequisite); - this.prerequisitesList.Add(this.inventoryPrerequisite); - this.prerequisitesList.Add(this.bedTimePrerequisite); - } - - public TaskMetaData(string Name, TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite = null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite = null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull=null,TaskPrerequisites.BedTimePrerequisite bedTimePrereq=null) + public TaskMetaData(string Name, StaminaPrerequisite StaminaPrerequisite = null, ToolPrerequisite ToolPrerequisite = null, InventoryFullPrerequisite InventoryFull=null,BedTimePrerequisite bedTimePrereq=null, ItemPrerequisite ItemPrereque = null) { this.name = Name; this.staminaPrerequisite = StaminaPrerequisite; @@ -78,16 +38,20 @@ namespace StarAI.ExecutionCore this.inventoryPrerequisite = InventoryFull; this.bedTimePrerequisite = bedTimePrereq; + + this.itemPrerequisite = ItemPrereque; //Make sure to set values correctly incase of null setUpStaminaPrerequisiteIfNull(); setUpToolPrerequisiteIfNull(); setUpInventoryPrerequisiteIfNull(); setUpBedTimeIfNull(); + setUpItemPrerequisiteIfNull(); this.prerequisitesList = new List(); this.prerequisitesList.Add(this.staminaPrerequisite); this.prerequisitesList.Add(this.toolPrerequisite); this.prerequisitesList.Add(this.inventoryPrerequisite); this.prerequisitesList.Add(this.bedTimePrerequisite); + this.prerequisitesList.Add(this.itemPrerequisite); } public void calculateTaskCost(TileNode source,bool unknownPath) @@ -113,6 +77,15 @@ namespace StarAI.ExecutionCore this.toolPrerequisite = new TaskPrerequisites.ToolPrerequisite(false, null,0); } } + + private void setUpItemPrerequisiteIfNull() + { + if (this.itemPrerequisite == null) + { + this.itemPrerequisite = new TaskPrerequisites.ItemPrerequisite(null, 0); + } + } + private void setUpStaminaPrerequisiteIfNull() { if (this.staminaPrerequisite == null) diff --git a/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ItemPrerequisite.cs b/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ItemPrerequisite.cs new file mode 100644 index 00000000..de3751d9 --- /dev/null +++ b/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ItemPrerequisite.cs @@ -0,0 +1,56 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StarAI.ExecutionCore.TaskPrerequisites +{ + public class ItemPrerequisite:GenericPrerequisite + { + public Item item; + public int amount; + + public ItemPrerequisite(Item DesiredItem, int Amount) + { + this.item = DesiredItem; + this.amount = Amount; + } + + public override bool checkAllPrerequisites() + { + if (this.item == null || this.amount == 0) return true; + if (doesPlayerInventoryContainMe() == false) return false; + if (doesPlayerHaveEnoughOfMe() == false) return false; + return true; + } + + public bool doesPlayerInventoryContainMe() + { + foreach(var item in Game1.player.items) + { + if (item == null) continue; + if (isItemSameTypeAsMe(item)) return true; + } + return false; + } + + public bool isItemSameTypeAsMe(Item I) + { + if (I.GetType() == this.item.GetType()) return true; + else return false; + } + + public bool doesPlayerHaveEnoughOfMe() + { + foreach (var item in Game1.player.items) + { + if (item == null) continue; + if (isItemSameTypeAsMe(item)&&item.Stack>=amount) return true; + } + return false; + } + + } +} diff --git a/StarAI/StarAI/ModCore.cs b/StarAI/StarAI/ModCore.cs index 2aa761eb..76bb8060 100644 --- a/StarAI/StarAI/ModCore.cs +++ b/StarAI/StarAI/ModCore.cs @@ -10,6 +10,7 @@ using Microsoft.Xna.Framework; using StarAI.PathFindingCore; using System.IO; using StardustCore; +using StardewValley.Menus; namespace StarAI { @@ -24,13 +25,15 @@ namespace StarAI public static List warpGoals = new List(); public static object[] obj = new object[3]; + public static bool throwUpShippingMenu; + public override void Entry(IModHelper helper) { obj[0] = PathFindingLogic.source; obj[1] = PathFindingLogic.currentGoal; obj[2] = PathFindingLogic.queue; CoreHelper = helper; - + throwUpShippingMenu = false; // string[] s = new string[10]; CoreMonitor = this.Monitor; @@ -43,12 +46,38 @@ namespace StarAI StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; - // StardewModdingAPI.Events.GraphicsEvents.OnPreRenderEvent += PathFindingCore.Utilities.addFromPlacementListBeforeDraw; - + // StardewModdingAPI.Events.GraphicsEvents.OnPreRenderEvent += PathFindingCore.Utilities.addFromPlacementListBeforeDraw; + StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; StardustCore.ModCore.SerializationManager.acceptedTypes.Add("StarAI.PathFindingCore.TileNode", new StardustCore.Serialization.SerializerDataNode(new StardustCore.Serialization.SerializerDataNode.SerializingFunction(StarAI.PathFindingCore.TileNode.Serialize), new StardustCore.Serialization.SerializerDataNode.ParsingFunction(StarAI.PathFindingCore.TileNode.ParseIntoInventory), new StardustCore.Serialization.SerializerDataNode.WorldParsingFunction(StarAI.PathFindingCore.TileNode.SerializeFromWorld), new StardustCore.Serialization.SerializerDataNode.SerializingToContainerFunction(StarAI.PathFindingCore.TileNode.Serialize))); } + private void SaveEvents_BeforeSave(object sender, EventArgs e) + { + + Stack menus = new Stack(); + + if (throwUpShippingMenu == true) + { + List itemList = new List(); + foreach (var item in Game1.shippingBin) + { + itemList.Add(item); + } + menus.Push(new StardewValley.Menus.ShippingMenu(itemList)); + foreach (var q in Game1.shippingBin) + { + ModCore.CoreMonitor.Log(q.name); + } + throwUpShippingMenu = false; + } + foreach(var v in Game1.endOfNightMenus) + { + menus.Push(v); + } + Game1.endOfNightMenus = menus; + } + private void SaveEvents_AfterLoad(object sender, EventArgs e) { loadExceptionTiles(); diff --git a/StarAI/StarAI/PathFindingCore/CropLogic/ShippingLogic.cs b/StarAI/StarAI/PathFindingCore/CropLogic/ShippingLogic.cs new file mode 100644 index 00000000..9cfca82d --- /dev/null +++ b/StarAI/StarAI/PathFindingCore/CropLogic/ShippingLogic.cs @@ -0,0 +1,213 @@ +using Microsoft.Xna.Framework; +using StarAI.ExecutionCore.TaskPrerequisites; +using StardewValley; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StarAI.PathFindingCore.CropLogic +{ + class ShippingLogic + { + public static void goToShippingBinSetUp() + { + List shippingTiles = new List(); + 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[3]; + List tempList = new List(); + foreach (var v in shippingTiles) + { + tempList.Add(v); + } + objList[0] = tempList; + + // ExecutionCore.TaskList.taskList.Add(new Task(new Action(waterSingleCrop), obj)); + StardewValley.Tools.WateringCan w = new StardewValley.Tools.WateringCan(); + //ModCore.CoreMonitor.Log("Processing water tiles:" + shippingTiles.Count.ToString() + " / " + twingCount.ToString()); + ok++; + int numberOfUses = 1; + ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToShippingBin, objList, new ExecutionCore.TaskMetaData("GoToShippingBin", null, null,null,null,null)); + + task.objectParameterDataArray = objList; + + if (task.taskMetaData.cost == Int32.MaxValue) + { + Utilities.clearExceptionListWithNames(true); + return; + } + objList[1] = task.taskMetaData.path; + objList[2] = task.taskMetaData.path.ElementAt(0); + ExecutionCore.TaskList.taskList.Add(task); + Utilities.clearExceptionListWithName("Child"); + Utilities.tileExceptionList.Clear(); + + + } + + + public static void goToShippingBin(TileNode v, List path) + { + object[] obj = new object[2]; + obj[0] = v; + obj[1] = path; + goToShippingBin(obj); + } + + + + public static void goToShippingBin(object obj) + { + object[] objArray = (object[])obj; + + TileNode v = (TileNode)objArray[2]; + List correctPath = (List)objArray[1]; + 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); + } + PathFindingLogic.calculateMovement(correctPath); + Vector2 tileLocation = v.tileLocation; + //ModCore.CoreMonitor.Log(tileLocation.ToString()); + //if(v.thisLocation.isTerrainFeatureAt) + + //DO SOME LOGIC HERE IF I WANT TO SHIP??? + + Utilities.cleanExceptionList(v); + StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v); + foreach (var goodTile in correctPath) + { + StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(goodTile); + goodTile.performRemoveAction(goodTile.tileLocation, goodTile.thisLocation); + } + + } + + + + public static void goToShippingBinShipItem(Item I) + { + List shippingTiles = new List(); + 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 tempList = new List(); + foreach (var v in shippingTiles) + { + tempList.Add(v); + } + objList[0] = tempList; + objList[3] = I; + // ExecutionCore.TaskList.taskList.Add(new Task(new Action(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", 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.path; + objList[2] = task.taskMetaData.path.ElementAt(0); + ExecutionCore.TaskList.taskList.Add(task); + Utilities.clearExceptionListWithName("Child"); + Utilities.tileExceptionList.Clear(); + + + } + + + public static void goToShippingBinShipItem(TileNode v, List path) + { + object[] obj = new object[2]; + obj[0] = v; + obj[1] = path; + goToShippingBinShipItem(obj); + } + + + + public static void goToShippingBinShipItem(object obj) + { + object[] objArray = (object[])obj; + Item I= (Item)objArray[3]; + + TileNode v = (TileNode)objArray[2]; + List correctPath = (List)objArray[1]; + 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); + } + PathFindingLogic.calculateMovement(correctPath); + Vector2 tileLocation = v.tileLocation; + //ModCore.CoreMonitor.Log(tileLocation.ToString()); + //if(v.thisLocation.isTerrainFeatureAt) + + //DO SOME LOGIC HERE IF I WANT TO SHIP??? + int amount = I.Stack; + + Item ok= StardustCore.Utilities.getItemFromInventory(I.Name); + Item cool = new StardewValley.Object(I.parentSheetIndex, amount); + //Game1.player.removeItemsFromInventory(StardewValley.Game1.player.getIndexOfInventoryItem(ok), 1); + Game1.shippingBin.Add((StardewValley.Object)cool); + + int value= ok.Stack - amount; + ModCore.CoreMonitor.Log("AMOUNT:" + amount); + if (value <= 0) { + Game1.player.items.Remove(ok); + ok = null; + } + else ok.Stack = value; + //Game1.shipObject((StardewValley.Object)I); + + ModCore.throwUpShippingMenu = true; + + + Utilities.cleanExceptionList(v); + StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v); + foreach (var goodTile in correctPath) + { + StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(goodTile); + goodTile.performRemoveAction(goodTile.tileLocation, goodTile.thisLocation); + } + + } + + + } +} diff --git a/StarAI/StarAI/PathFindingCore/WaterLogic/WaterLogic.cs b/StarAI/StarAI/PathFindingCore/WaterLogic/WaterLogic.cs index 19b2df2b..37a22e37 100644 --- a/StarAI/StarAI/PathFindingCore/WaterLogic/WaterLogic.cs +++ b/StarAI/StarAI/PathFindingCore/WaterLogic/WaterLogic.cs @@ -69,15 +69,16 @@ namespace StarAI.PathFindingCore.WaterLogic ok++; int numberOfUses = 1; ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToSingleWaterTile, objList, new ExecutionCore.TaskMetaData("GoToWaterTile", new StaminaPrerequisite(true, 2 * numberOfUses), new ToolPrerequisite(true, w.GetType(), numberOfUses))); - objList[1] = task.taskMetaData.path; - objList[2] = task.taskMetaData.path.ElementAt(0); - task.objectParameterDataArray = objList; + if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); return; } + objList[1] = task.taskMetaData.path; + objList[2] = task.taskMetaData.path.ElementAt(0); + task.objectParameterDataArray = objList; ExecutionCore.TaskList.taskList.Add(task); Utilities.clearExceptionListWithName("Child"); @@ -109,7 +110,7 @@ namespace StarAI.PathFindingCore.WaterLogic { 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, i, j); - Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "ChopTree")); + Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "WaterTile")); waterTilesAvailable.Add(t); twingCount++; } @@ -134,16 +135,17 @@ namespace StarAI.PathFindingCore.WaterLogic ok++; int numberOfUses = 1; ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToSingleWaterTile, objList, new ExecutionCore.TaskMetaData("GoToWaterTile", new StaminaPrerequisite(true, 2 * numberOfUses), new ToolPrerequisite(true, w.GetType(), numberOfUses))); - objList[1] = task.taskMetaData.path; - objList[2] = task.taskMetaData.path.ElementAt(0); - task.objectParameterDataArray = objList; + if (task.taskMetaData.cost == Int32.MaxValue) { Utilities.clearExceptionListWithNames(true); return null; } - // ExecutionCore.TaskList.taskList.Add(task); + objList[1] = task.taskMetaData.path; + objList[2] = task.taskMetaData.path.ElementAt(0); + task.objectParameterDataArray = objList; + // ExecutionCore.TaskList.taskList.Add(task); Utilities.clearExceptionListWithName("Child"); waterTilesAvailable.Clear(); diff --git a/StarAI/StarAI/StarAI.csproj b/StarAI/StarAI/StarAI.csproj index 37befe88..a2e292e8 100644 --- a/StarAI/StarAI/StarAI.csproj +++ b/StarAI/StarAI/StarAI.csproj @@ -64,11 +64,13 @@ + +