Made the stick choping work and upgraded the pathfinding to store the cheapest path to prevent a TON of crashes and calculation time.
This commit is contained in:
parent
671eb1be49
commit
b05ee04e2b
|
@ -30,7 +30,7 @@ namespace StarAI.ExecutionCore
|
|||
objectTask = objTask;
|
||||
objectParameterDataArray = arrayData;
|
||||
this.taskMetaData = TaskMetaData;
|
||||
this.taskMetaData.calculateTaskCost((TileNode)arrayData[0]);
|
||||
this.taskMetaData.calculateTaskCost((TileNode)arrayData[0],true);
|
||||
}
|
||||
|
||||
public CustomTask(VoidTask vTask, TaskMetaData TaskMetaData)
|
||||
|
|
|
@ -26,15 +26,19 @@ namespace StarAI.ExecutionCore
|
|||
|
||||
|
||||
//recalculate cost expenses every time a task runs because we don't know where we will be at any given moment. Kind of costly unfortunately but works.
|
||||
foreach(var task2 in taskList)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
foreach (var task2 in taskList)
|
||||
{
|
||||
if (removalList.Contains(task2)) continue;
|
||||
object[] oArray = (object[])task2.objectParameterDataArray;
|
||||
TileNode t =(TileNode) oArray[0];
|
||||
task2.taskMetaData.calculateTaskCost((t));
|
||||
task2.taskMetaData.calculateTaskCost(t,false);
|
||||
//task.taskMetaData = new TaskMetaData(task.taskMetaData.name, PathFindingCore.Utilities.calculatePathCost(task.objectParameterDataArray), task.taskMetaData.staminaPrerequisite, task.taskMetaData.toolPrerequisite);
|
||||
}
|
||||
|
||||
*/
|
||||
//Some really cool delegate magic that sorts in place by the cost of the action!!!!
|
||||
taskList.Sort(delegate (CustomTask t1, CustomTask t2)
|
||||
{
|
||||
|
@ -52,6 +56,8 @@ namespace StarAI.ExecutionCore
|
|||
if (v.taskMetaData.verifyAllPrerequisitesHit() == true)
|
||||
{
|
||||
v.runTask();
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.clearExceptionListWithName("Navigation");
|
||||
removalList.Add(v);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -90,9 +90,10 @@ namespace StarAI.ExecutionCore
|
|||
this.prerequisitesList.Add(this.bedTimePrerequisite);
|
||||
}
|
||||
|
||||
public void calculateTaskCost(TileNode source)
|
||||
public void calculateTaskCost(TileNode source,bool unknownPath)
|
||||
{
|
||||
this.cost=TaskMetaDataHeuristics.calculateTaskCost(source, this.toolPrerequisite);
|
||||
this.cost=TaskMetaDataHeuristics.calculateTaskCost(source, this.toolPrerequisite,unknownPath);
|
||||
this.path = Utilities.pathStuff(source);
|
||||
//this.path = Utilities.calculatePath(source, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,10 @@ namespace StarAI.ExecutionCore
|
|||
return (parseToolCostMultiplier(t) * t.estimatedNumberOfUses);
|
||||
}
|
||||
|
||||
public static float calculateTaskCost(TileNode v,ToolPrerequisite t)
|
||||
public static float calculateTaskCost(TileNode v,ToolPrerequisite t,bool unknownPath)
|
||||
{
|
||||
PathFindingLogic.delay = 18;
|
||||
if(unknownPath) PathFindingLogic.delay = 18;
|
||||
else PathFindingLogic.delay = 0;
|
||||
int costCalculation = StarAI.PathFindingCore.Utilities.calculatePathCost(v,true);
|
||||
if (costCalculation == Int32.MaxValue) return Int32.MaxValue;
|
||||
float pathCost= costCalculation* pathCostMultiplier;
|
||||
|
|
|
@ -144,6 +144,10 @@ namespace StarAI
|
|||
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.U)
|
||||
{
|
||||
ExecutionCore.TaskList.printAllTaskMetaData();
|
||||
foreach(var v in PathFindingCore.Utilities.tileExceptionList)
|
||||
{
|
||||
ModCore.CoreMonitor.Log(v.actionType);
|
||||
}
|
||||
}
|
||||
|
||||
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.O)
|
||||
|
|
|
@ -68,7 +68,9 @@ namespace StarAI.PathFindingCore
|
|||
continue;
|
||||
}
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName(true, "Child");
|
||||
//Utilities.clearExceptionListWithName(true, "Child");
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
|
||||
// waterSingleCrop(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
StardewValley.Tools.WateringCan w = new StardewValley.Tools.WateringCan();
|
||||
ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(waterSingleCrop, obj,new ExecutionCore.TaskMetaData("Water Crop", new StaminaPrerequisite(true,3),new ToolPrerequisite(true,w.GetType(),1))));
|
||||
// waterSingleCrop(v);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,7 +273,7 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
obj[0] = v;
|
||||
//ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(harvestSingleCrop), obj));
|
||||
ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(harvestSingleCrop, obj,new ExecutionCore.TaskMetaData("HarvestSingleCrop",null,null,new ExecutionCore.TaskPrerequisites.InventoryFullPrerequisite(true))));
|
||||
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
// waterSingleCrop(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
|||
getAllSticksToChop(arr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DO NOT USE THIS UNLESS YOU WANT LAG UP THE WAZOO
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public static void getAllSticksToChop(object obj)
|
||||
{
|
||||
int twingCount = 0;
|
||||
|
@ -59,18 +63,24 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
|||
StardewValley.Tools.Axe w = new StardewValley.Tools.Axe();
|
||||
ModCore.CoreMonitor.Log("Processing twig:" + ok.ToString() + " / " + twingCount.ToString());
|
||||
ok++;
|
||||
ExecutionCore.CustomTask task= new ExecutionCore.CustomTask(chopSingleStick, objList, new ExecutionCore.TaskMetaData("Chop Single Stick", new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1)));
|
||||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(chopSingleStick, objList, new ExecutionCore.TaskMetaData("Chop Single Stick", new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1)));
|
||||
if (task.taskMetaData.cost == Int32.MaxValue)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
Utilities.clearExceptionListWithNames(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
ModCore.CoreMonitor.Log("TASK COST:"+task.taskMetaData.cost.ToString());
|
||||
|
||||
ModCore.CoreMonitor.Log("TASK COST:" + task.taskMetaData.cost.ToString());
|
||||
if (task.taskMetaData.cost.ToString()=="2.147484E+09")
|
||||
{
|
||||
ModCore.CoreMonitor.Log("OHH THAT's BAD");
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
}
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
ModCore.CoreMonitor.Log("TASK LIST COUNT:"+ExecutionCore.TaskList.taskList.Count.ToString());
|
||||
Utilities.clearExceptionListWithName(true, "Child");
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
// waterSingleCrop(v);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +100,8 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
|||
{
|
||||
for (int y = -radius; y <= radius; y++)
|
||||
{
|
||||
|
||||
bool f= Game1.player.currentLocation.isObjectAt((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize);
|
||||
if (f == false) continue;
|
||||
StardewValley.Object obj = Game1.player.currentLocation.getObjectAt((Game1.player.getTileX() + x)*Game1.tileSize, (Game1.player.getTileY() + y)*Game1.tileSize);
|
||||
if (obj == null) continue;
|
||||
if (obj.name==name)
|
||||
|
@ -154,29 +165,46 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
|||
foreach (var v in sticksToChop)
|
||||
{
|
||||
|
||||
object[] objList = new object[1];
|
||||
object[] objList = new object[2];
|
||||
objList[0] = v;
|
||||
// ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj));
|
||||
StardewValley.Tools.Axe w = new StardewValley.Tools.Axe();
|
||||
ModCore.CoreMonitor.Log("Processing twig:" + ok.ToString() + " / " + twingCount.ToString());
|
||||
ok++;
|
||||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(chopSingleStick, objList, new ExecutionCore.TaskMetaData("Chop Single Stick", new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1)));
|
||||
objList[1] = task.taskMetaData.path;
|
||||
task.objectParameterDataArray = objList;
|
||||
|
||||
|
||||
if (task.taskMetaData.cost == Int32.MaxValue)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
Utilities.clearExceptionListWithNames(true);
|
||||
continue;
|
||||
}
|
||||
if (task.taskMetaData.cost.ToString() == "2.147484E+09")
|
||||
{
|
||||
ModCore.CoreMonitor.Log("OHH THAT's BAD");
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
ModCore.CoreMonitor.Log("TASK COST:" + task.taskMetaData.cost.ToString());
|
||||
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
ModCore.CoreMonitor.Log("TASK LIST COUNT:" + ExecutionCore.TaskList.taskList.Count.ToString());
|
||||
//Utilities.clearExceptionListWithName(true, "Child");
|
||||
// waterSingleCrop(v);
|
||||
}
|
||||
sticksToChop.Clear();
|
||||
}
|
||||
|
||||
|
||||
public static void chopSingleStick(TileNode v)
|
||||
public static void chopSingleStick(TileNode v,List<TileNode> path)
|
||||
{
|
||||
object[] obj = new object[1];
|
||||
obj[0] = v;
|
||||
obj[1] = path;
|
||||
chopSingleStick(obj);
|
||||
}
|
||||
|
||||
|
@ -184,97 +212,11 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
|||
|
||||
public static void chopSingleStick(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 == "ChopStick")
|
||||
{
|
||||
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, "Navigation"));
|
||||
}
|
||||
}
|
||||
}
|
||||
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, false);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
object[] objArray=(object[])obj;
|
||||
|
||||
TileNode v = (TileNode)objArray[0];
|
||||
List<TileNode> correctPath = (List<TileNode>)objArray[1];
|
||||
foreach (var goodTile in correctPath)
|
||||
{
|
||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Add(goodTile);
|
||||
|
|
|
@ -508,7 +508,7 @@ namespace StarAI.PathFindingCore
|
|||
{
|
||||
StardewValley.Object ob = v.thisLocation.objects[v.tileLocation];
|
||||
|
||||
ModCore.CoreMonitor.Log(ob.name);
|
||||
//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);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace StarAI.PathFindingCore
|
|||
{
|
||||
foreach(var v in tileExceptionList)
|
||||
{
|
||||
if (t == v.tile) return v;
|
||||
if (t.tileLocation == v.tile.tileLocation) return v;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -90,6 +90,20 @@ namespace StarAI.PathFindingCore
|
|||
}
|
||||
}
|
||||
|
||||
public static void clearExceptionListWithName(string name)
|
||||
{
|
||||
List<TileExceptionMetaData> removalList = new List<TileExceptionMetaData>();
|
||||
foreach(var v in tileExceptionList)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("DING");
|
||||
if (v.actionType == name) removalList.Add(v);
|
||||
}
|
||||
foreach(var v in removalList)
|
||||
{
|
||||
Utilities.tileExceptionList.Remove(v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void clearExceptionListWithName(bool removeFromWorld,string name)
|
||||
{
|
||||
|
@ -282,35 +296,18 @@ namespace StarAI.PathFindingCore
|
|||
return correctPath.Count;
|
||||
}
|
||||
|
||||
public static List<TileNode> calculatePath(TileNode v, bool Placement = true)
|
||||
public static List<TileNode> pathStuff(TileNode t)
|
||||
{
|
||||
object[] obj = new object[2];
|
||||
obj[0] = v;
|
||||
obj[1] = Placement;
|
||||
return calculatePath(obj);
|
||||
object[] arr = new object[1];
|
||||
arr[0] = t;
|
||||
return pathStuff(arr);
|
||||
}
|
||||
|
||||
public static List<TileNode> calculatePath(object obj)
|
||||
public static List<TileNode> pathStuff(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;
|
||||
|
@ -332,17 +329,16 @@ namespace StarAI.PathFindingCore
|
|||
|
||||
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);
|
||||
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));
|
||||
if (placement) t.placementAction(Game1.currentLocation, (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));
|
||||
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, "CostCalculation"));
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Navigation"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,35 +346,32 @@ namespace StarAI.PathFindingCore
|
|||
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(Game1.player.currentLocation, Game1.player.getTileX(), Game1.player.getTileY());
|
||||
|
||||
List<TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, nav, new List<TileNode>(), false, true);
|
||||
|
||||
Utilities.clearExceptionListWithName(placement, "Child");
|
||||
|
||||
ModCore.CoreMonitor.Log(tempSource.tileLocation.ToString() + tempSource.tileLocation.ToString());
|
||||
ModCore.CoreMonitor.Log(nav.tileLocation.ToString() + nav.tileLocation.ToString());
|
||||
tempSource.placementAction(Game1.player.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
|
||||
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));
|
||||
List<TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, nav, new List<TileNode>(), true, false);
|
||||
|
||||
if (path.Count != 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("PATH WAS NOT NULL", LogLevel.Warn);
|
||||
//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) someTile.thisLocation.objects.Remove(someTile.tileLocation);
|
||||
someTile.thisLocation.objects.Remove(someTile.tileLocation);
|
||||
//someTile.performRemoveAction(someTile.tileLocation, someTile.thisLocation);
|
||||
//StardustCore.Utilities.masterRemovalList.Add(v);
|
||||
//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);
|
||||
q.thisLocation.objects.Remove(q.tileLocation);
|
||||
}
|
||||
removalList.Clear();
|
||||
int pathCost = 999999999;
|
||||
|
@ -388,21 +381,17 @@ namespace StarAI.PathFindingCore
|
|||
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 (correctPath.Count==0)return new List<TileNode>();
|
||||
|
||||
return correctPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue