Added functionality for shipping objects
This commit is contained in:
parent
3e9d7f6f49
commit
175a385977
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string, string[]>(Commands.fillWateringCan));
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("fillcan", "Fill my watering can.", new Action<string, string[]>(Commands.fillWateringCan));
|
||||
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("shippingbin", "Goto shipping bin", new Action<string, string[]>(Commands.goToShippingBin));
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("shipItem", "Fill my watering can.", new Action<string, string[]>(Commands.shipItem));
|
||||
// ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(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<TileNode>();
|
||||
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<object>(PathFindingLogic.pathFindToSingleGoal),obj));
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<TaskPrerequisites.GenericPrerequisite> prerequisitesList;
|
||||
|
||||
|
||||
public List<TileNode> path = new List<TileNode>();
|
||||
|
||||
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<TaskPrerequisites.GenericPrerequisite>();
|
||||
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<TaskPrerequisites.GenericPrerequisite>();
|
||||
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<TaskPrerequisites.GenericPrerequisite>();
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<Warp> warpGoals = new List<Warp>();
|
||||
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<IClickableMenu> menus = new Stack<IClickableMenu>();
|
||||
|
||||
if (throwUpShippingMenu == true)
|
||||
{
|
||||
List<Item> itemList = new List<Item>();
|
||||
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();
|
||||
|
|
|
@ -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<TileNode> shippingTiles = new List<TileNode>();
|
||||
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<TileNode> tempList = new List<TileNode>();
|
||||
foreach (var v in shippingTiles)
|
||||
{
|
||||
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:" + 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<TileNode> 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<TileNode> correctPath = (List<TileNode>)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<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", 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<TileNode> 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<TileNode> correctPath = (List<TileNode>)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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -64,11 +64,13 @@
|
|||
<Compile Include="ExecutionCore\TaskPrerequisites\BedTimePrerequisite.cs" />
|
||||
<Compile Include="ExecutionCore\TaskPrerequisites\GenericPrerequisite.cs" />
|
||||
<Compile Include="ExecutionCore\TaskPrerequisites\InventoryFullPrerequisite.cs" />
|
||||
<Compile Include="ExecutionCore\TaskPrerequisites\ItemPrerequisite.cs" />
|
||||
<Compile Include="ExecutionCore\TaskPrerequisites\StaminaPrerequisite.cs" />
|
||||
<Compile Include="ExecutionCore\TaskPrerequisites\ToolPrerequisite.cs" />
|
||||
<Compile Include="ModCore.cs" />
|
||||
<Compile Include="PathFindingCore\ChestLogic.cs" />
|
||||
<Compile Include="PathFindingCore\CropLogic\CropLogic.cs" />
|
||||
<Compile Include="PathFindingCore\CropLogic\ShippingLogic.cs" />
|
||||
<Compile Include="PathFindingCore\DebrisLogic\DebrisLogic.cs" />
|
||||
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
||||
<Compile Include="PathFindingCore\PlacementNode.cs" />
|
||||
|
|
Loading…
Reference in New Issue