Waypoints, pathing in and out of buildings, to specific tiles, and returning home at the end of day.
This commit is contained in:
parent
ea2e7c134f
commit
4fcef655a8
|
@ -1,4 +1,5 @@
|
|||
using StardewValley;
|
||||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -16,9 +17,9 @@ namespace StarAI.CheatCore
|
|||
{
|
||||
foreach(var door in v.doors)
|
||||
{
|
||||
ModCore.CoreMonitor.Log(v.name.ToString());
|
||||
ModCore.CoreMonitor.Log(door.Key.ToString());
|
||||
ModCore.CoreMonitor.Log(door.Value);
|
||||
// ModCore.CoreMonitor.Log(v.name.ToString());
|
||||
// ModCore.CoreMonitor.Log(door.Key.ToString());
|
||||
// ModCore.CoreMonitor.Log(door.Value);
|
||||
|
||||
foreach(var warp in Game1.getLocationFromName(door.Value).warps)
|
||||
{
|
||||
|
@ -26,6 +27,7 @@ namespace StarAI.CheatCore
|
|||
{
|
||||
Warp w = new Warp(door.Key.X, door.Key.Y, door.Value, warp.X, warp.Y - 1,false);
|
||||
v.warps.Add(w);
|
||||
ModCore.CoreMonitor.Log("Star AI: Cheat Core: Adding warp on door at:" + door.Value + " " + new Vector2(door.Key.X, door.Key.Y));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StarAI;
|
||||
using StarAI.PathFindingCore.DebrisLogic;
|
||||
using StarAI.PathFindingCore.WaterLogic;
|
||||
using StarAI.PathFindingCore.CropLogic;
|
||||
using StarAI.PathFindingCore.MapTransitionLogic;
|
||||
using StarAI.TaskCore.MapTransitionLogic;
|
||||
using StarAI.TaskCore;
|
||||
using StarAI.TaskCore.CropLogic;
|
||||
using StarAI.TaskCore.DebrisLogic;
|
||||
|
||||
namespace StarAI
|
||||
{
|
||||
|
@ -51,7 +52,10 @@ namespace StarAI
|
|||
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("pathto", "Path to the adjacent map", new Action<string, string[]>(Commands.pathToMap));
|
||||
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("goto", "Path to the adjacent map", new Action<string, string[]>(Commands.goToMap));
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("goto", "Path to a given waypoint", new Action<string, string[]>(Commands.wayPoints));
|
||||
|
||||
ModCore.CoreHelper.ConsoleCommands.Add("waypoints", "Utilities to deal with waypoints", new Action<string, string[]>(Commands.wayPoints));
|
||||
|
||||
// ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
||||
pathfind("Initialize Delay 0", new string[] {
|
||||
"setDelay",
|
||||
|
@ -59,20 +63,95 @@ namespace StarAI
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
public static void taskListCommands(string s, string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Error: Need more parameters. Possible command paramaters are...");
|
||||
ModCore.CoreMonitor.Log("(Pop/pop): pop off the first task and remove it");
|
||||
ModCore.CoreMonitor.Log("(Clear/clear/Flush/flush):Remove all tasks from the task list");
|
||||
return;
|
||||
}
|
||||
if(args[0]=="Pop"|| args[0] == "pop")
|
||||
{
|
||||
ExecutionCore.TaskList.taskList.Remove(ExecutionCore.TaskList.taskList.ElementAt(0));
|
||||
ModCore.CoreMonitor.Log("Removed top task from tasklist.");
|
||||
return;
|
||||
}
|
||||
if (args[0] == "Clear" || args[0] == "clear")
|
||||
{
|
||||
ExecutionCore.TaskList.taskList.Clear();
|
||||
ModCore.CoreMonitor.Log("Cleared out the task list");
|
||||
return;
|
||||
}
|
||||
if (args[0] == "Flush" || args[0] == "flush")
|
||||
{
|
||||
ExecutionCore.TaskList.taskList.Clear();
|
||||
ModCore.CoreMonitor.Log("Cleared out the task list");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void wayPoints(string s, string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Invalid arguments. Possible arguments are:");
|
||||
ModCore.CoreMonitor.Log("Print: Print all waypoints");
|
||||
ModCore.CoreMonitor.Log("print: Print all waypoints");
|
||||
ModCore.CoreMonitor.Log("goto <waypointName>: Go to a specified waypoint in the world.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s == "goto")
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Please specify a waypoint name. They can be fetched with the command line \"waypoints print\"");
|
||||
return;
|
||||
}
|
||||
WayPoints.pathToWayPoint(args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args[0]=="Print"|| args[0] == "print")
|
||||
{
|
||||
WayPoints.printWayPoints();
|
||||
}
|
||||
if (args[0] == "goto" || args[0] == "GoTo" || args[0] == "goTo")
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Please specify a waypoint name. They can be fetched with the command line \"waypoints print\"");
|
||||
return;
|
||||
}
|
||||
WayPoints.pathToWayPoint(args[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +244,7 @@ namespace StarAI
|
|||
ModCore.CoreMonitor.Log("Need args length of 1. Param: Name of location to go to.");
|
||||
return;
|
||||
}
|
||||
PathFindingCore.MapTransitionLogic.TransitionLogic.transitionToAdjacentMap(Game1.player.currentLocation, args[0]);
|
||||
TaskCore.MapTransitionLogic.TransitionLogic.transitionToAdjacentMap(Game1.player.currentLocation, args[0]);
|
||||
}
|
||||
|
||||
public static void breakAllStones(string s, string[] args)
|
||||
|
@ -200,16 +279,14 @@ namespace StarAI
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void waterCrops(string s, string[] args)
|
||||
{
|
||||
PathFindingCore.CropLogic.CropLogic.getAllCropsNeededToBeWatered();
|
||||
CropLogic.getAllCropsNeededToBeWatered();
|
||||
}
|
||||
|
||||
public static void harvestCrops(string s,string[] args)
|
||||
{
|
||||
PathFindingCore.CropLogic.CropLogic.getAllCropsNeededToBeHarvested();
|
||||
CropLogic.getAllCropsNeededToBeHarvested();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using StarAI.PathFindingCore;
|
||||
using StarAI.PathFindingCore.WaterLogic;
|
||||
using StarAI.TaskCore.MapTransitionLogic;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Tools;
|
||||
|
@ -17,6 +18,8 @@ namespace StarAI.ExecutionCore
|
|||
public static Task executioner = new Task(new Action(runTaskList));
|
||||
|
||||
public static List<CustomTask> removalList = new List<CustomTask>();
|
||||
|
||||
public static bool pathafterLocationChange;
|
||||
public static void runTaskList()
|
||||
{
|
||||
|
||||
|
@ -24,9 +27,22 @@ namespace StarAI.ExecutionCore
|
|||
|
||||
bool assignNewTask = true;
|
||||
|
||||
while(ranAllTasks()==false)
|
||||
if(TaskPrerequisites.BedTimePrerequisite.enoughTimeToDoTaskStatic() == false)
|
||||
{
|
||||
foreach (var task2 in taskList)
|
||||
CustomTask task = WayPoints.pathToWayPointReturnTask("bed");
|
||||
if (task == null) ModCore.CoreMonitor.Log("SOMETHING WENT WRONG WHEN TRYING TO GO TO BED", LogLevel.Error);
|
||||
ModCore.CoreMonitor.Log("Not enough time remaining in day. Going home.", LogLevel.Alert);
|
||||
task.runTask();
|
||||
Utilities.tileExceptionList.Clear();
|
||||
taskList.Clear();
|
||||
removalList.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
while(ranAllTasks()==false||TaskPrerequisites.BedTimePrerequisite.enoughTimeToDoTaskStatic()==false)
|
||||
{
|
||||
Utilities.tileExceptionList.Clear();
|
||||
foreach (var task2 in taskList)
|
||||
{
|
||||
if (removalList.Contains(task2)) continue;
|
||||
recalculateTask(task2);
|
||||
|
@ -64,7 +80,7 @@ namespace StarAI.ExecutionCore
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Utilities.tileExceptionList.Clear();
|
||||
taskList.Clear();
|
||||
removalList.Clear();
|
||||
|
||||
|
@ -74,15 +90,15 @@ namespace StarAI.ExecutionCore
|
|||
{
|
||||
object[] oArray = (object[])v.objectParameterDataArray;
|
||||
ModCore.CoreMonitor.Log("RECALCULATING: "+ v.taskMetaData.name);
|
||||
|
||||
|
||||
if (v.taskMetaData.name.Contains("Path to "))
|
||||
{
|
||||
Utilities.tileExceptionList.Clear();
|
||||
ModCore.CoreMonitor.Log("POKE DEW VALLEY: " + v.taskMetaData.name);
|
||||
string[] s = v.taskMetaData.name.Split(' ');
|
||||
ModCore.CoreMonitor.Log(s.ElementAt(s.Length-1));
|
||||
List<List<TileNode>> newPaths = new List<List<TileNode>>();
|
||||
newPaths = PathFindingCore.MapTransitionLogic.WarpGoal.getWarpChainReturn(Game1.player.currentLocation, s.ElementAt(s.Length-1));
|
||||
newPaths = TaskCore.MapTransitionLogic.WarpGoal.getWarpChainReturn(Game1.player.currentLocation, s.ElementAt(s.Length-1));
|
||||
v.taskMetaData.cost = 0;
|
||||
int value = 0;
|
||||
foreach (var path in newPaths)
|
||||
|
@ -96,23 +112,53 @@ namespace StarAI.ExecutionCore
|
|||
ModCore.CoreMonitor.Log("IDK ANY MORE: " + v.taskMetaData.cost);
|
||||
return;
|
||||
}
|
||||
|
||||
Utilities.tileExceptionList.Clear();
|
||||
try
|
||||
{
|
||||
Utilities.tileExceptionList.Clear();
|
||||
TileNode t = (TileNode)oArray[0];
|
||||
Utilities.tileExceptionList.Clear();
|
||||
ModCore.CoreMonitor.Log("Premtive calculate 1");
|
||||
v.taskMetaData.calculateTaskCost(t, false);
|
||||
object[] objArr = new object[3];
|
||||
object[] objArr = new object[10];
|
||||
objArr[0] = (object)t;
|
||||
objArr[1] = (object)v.taskMetaData.pathsToTake[0];
|
||||
int malcolm = 0;
|
||||
objArr[2] = (object)v.taskMetaData.pathsToTake[0].ElementAt(malcolm); //source of whatever is hit.
|
||||
try
|
||||
{
|
||||
objArr[3] = oArray[3];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[4] = oArray[4];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[5] = oArray[5];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
v.objectParameterDataArray = objArr;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Utilities.tileExceptionList.Clear();
|
||||
List<TileNode> t = (List<TileNode>)oArray[0];
|
||||
ModCore.CoreMonitor.Log("Premtive calculate 2");
|
||||
foreach (var s in Utilities.tileExceptionList)
|
||||
|
@ -120,7 +166,7 @@ namespace StarAI.ExecutionCore
|
|||
ModCore.CoreMonitor.Log(s.actionType);
|
||||
}
|
||||
v.taskMetaData.calculateTaskCost(t, false);
|
||||
object[] objArr = new object[4];
|
||||
object[] objArr = new object[10];
|
||||
objArr[0] = (object)t; //List of trees to use for path calculations
|
||||
objArr[1] = (object)v.taskMetaData.pathsToTake[0]; //The path itself.
|
||||
int malcolm = 0;
|
||||
|
@ -133,6 +179,22 @@ namespace StarAI.ExecutionCore
|
|||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[4] = oArray[4];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[5] = oArray[5];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
v.objectParameterDataArray = objArr;
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
@ -144,14 +206,15 @@ namespace StarAI.ExecutionCore
|
|||
|
||||
try
|
||||
{
|
||||
Utilities.tileExceptionList.Clear();
|
||||
List<List<TileNode>> t = (List<List<TileNode>>)oArray[3];
|
||||
ModCore.CoreMonitor.Log("Premtive calculate 2");
|
||||
ModCore.CoreMonitor.Log("Premtive calculate 3");
|
||||
foreach (var s in Utilities.tileExceptionList)
|
||||
{
|
||||
ModCore.CoreMonitor.Log(s.actionType);
|
||||
}
|
||||
v.taskMetaData.calculateTaskCost(t, false);
|
||||
object[] objArr = new object[4];
|
||||
object[] objArr = new object[10];
|
||||
objArr[0] = (object)t; //List of trees to use for path calculations
|
||||
objArr[1] = (object)v.taskMetaData.pathsToTake; //The path itself.
|
||||
int malcolm = 0;
|
||||
|
@ -164,6 +227,22 @@ namespace StarAI.ExecutionCore
|
|||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[4] = oArray[4];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
objArr[5] = oArray[5];
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
}
|
||||
v.objectParameterDataArray = objArr;
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
@ -176,9 +255,34 @@ namespace StarAI.ExecutionCore
|
|||
|
||||
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();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (v.taskMetaData.name == "Water Crop")
|
||||
|
|
|
@ -33,6 +33,23 @@ namespace StarAI.ExecutionCore.TaskPrerequisites
|
|||
else return false;
|
||||
}
|
||||
|
||||
public static int timeRemainingInDayStatic()
|
||||
{
|
||||
int passOutTime = 2600;
|
||||
return passOutTime - Game1.timeOfDay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default here will give you 2 hrs which should be enough for bedTime.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool enoughTimeToDoTaskStatic()
|
||||
{
|
||||
int timeRemaining = timeRemainingInDayStatic();
|
||||
if (timeRemaining > 200) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public bool enoughTimeToDoTask(int timeToDoTask)
|
||||
{
|
||||
int timeRemaining = timeRemainingInDay();
|
||||
|
|
|
@ -18,8 +18,17 @@ namespace StarAI.ExecutionCore.TaskPrerequisites
|
|||
|
||||
public bool isPlayerAtLocation()
|
||||
{
|
||||
if (this.location == null) return true;
|
||||
if (Game1.player.currentLocation == this.location || Game1.player.currentLocation.name == this.location.name || Game1.player.currentLocation.uniqueName == this.location.uniqueName) return true;
|
||||
if (this.location == null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Location calculation is null");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CoreMonitor.Log("THIS IS THE LOCATION"+this.location);
|
||||
|
||||
}
|
||||
if (Game1.player.currentLocation == this.location || Game1.player.currentLocation.name == this.location.name) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ using StarAI.PathFindingCore;
|
|||
using System.IO;
|
||||
using StardustCore;
|
||||
using StardewValley.Menus;
|
||||
using StarAI.TaskCore.MapTransitionLogic;
|
||||
|
||||
namespace StarAI
|
||||
{
|
||||
|
@ -34,23 +35,31 @@ namespace StarAI
|
|||
obj[2] = PathFindingLogic.queue;
|
||||
CoreHelper = helper;
|
||||
throwUpShippingMenu = false;
|
||||
// string[] s = new string[10];
|
||||
|
||||
CoreMonitor = this.Monitor;
|
||||
CoreMonitor.Log("Hello AI WORLD!", LogLevel.Info);
|
||||
|
||||
initializeEverything();
|
||||
|
||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||
StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
|
||||
StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave;
|
||||
|
||||
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_AfterSave(object sender, EventArgs e)
|
||||
{
|
||||
WayPoints.setUpBedWaypoint();
|
||||
}
|
||||
|
||||
public void initializeEverything()
|
||||
{
|
||||
Commands.initializeCommands();
|
||||
PathFindingCore.Utilities.initializeTileExceptionList();
|
||||
ExecutionCore.TaskMetaDataHeuristics.initializeToolCostDictionary();
|
||||
//throw new NotImplementedException();
|
||||
//StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
|
||||
|
||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||
// 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)));
|
||||
|
||||
WayPoints.initializeWaypoints();
|
||||
}
|
||||
|
||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
||||
|
@ -81,31 +90,10 @@ namespace StarAI
|
|||
|
||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||
{
|
||||
loadExceptionTiles();
|
||||
// loadExceptionTiles();
|
||||
CheatCore.DoorsToWarps.makeAllDoorsWarps();
|
||||
}
|
||||
|
||||
public void loadExceptionTiles()
|
||||
{
|
||||
if (!Directory.Exists(Path.Combine(CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
|
||||
}
|
||||
// Process the list of files found in the directory.
|
||||
string[] fileEntries = Directory.GetFiles(Path.Combine(CoreHelper.DirectoryPath,PathFindingCore.Utilities.folderForExceptionTiles));
|
||||
foreach (string fileName in fileEntries)
|
||||
{
|
||||
try
|
||||
{
|
||||
TileExceptionNode t = TileExceptionNode.parseJson(fileName);
|
||||
PathFindingCore.Utilities.ignoreCheckTiles.Add(t);
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
ModCore.CoreMonitor.Log(err.ToString(), LogLevel.Error);
|
||||
}
|
||||
}
|
||||
|
||||
WayPoints.setUpBedWaypoint();
|
||||
WayPoints.verifyWayPoints();
|
||||
}
|
||||
|
||||
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WindowsInput;
|
||||
|
||||
namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||
{
|
||||
class TransitionLogic
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Will transition to the next map by using warp goals if the map is adjacent to the one I am at and I can path to it.
|
||||
/// </summary>
|
||||
/// <param name="location"></param>
|
||||
/// <param name="targetName"></param>
|
||||
public static void transitionToAdjacentMap(GameLocation location,string targetName)
|
||||
{
|
||||
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[4];
|
||||
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(goToAdjacentWarpGoal, 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.pathsToTake[0];
|
||||
objList[2] = task.taskMetaData.pathsToTake[0].ElementAt(0);
|
||||
objList[3] = targetName;
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
warpGoals.Clear();
|
||||
}
|
||||
|
||||
public static List<TileNode> transitionToAdjacentMapReturn(GameLocation location, string targetName)
|
||||
{
|
||||
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[4];
|
||||
List<TileNode> tempList = new List<TileNode>();
|
||||
foreach (var v in warpGoals)
|
||||
{
|
||||
tempList.Add(v);
|
||||
}
|
||||
return tempList;
|
||||
objList[0] = tempList;
|
||||
ok++;
|
||||
int numberOfUses = 1;
|
||||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToAdjacentWarpGoal, objList, new ExecutionCore.TaskMetaData("GoToShippingBin", null, null, null, null, null));
|
||||
|
||||
task.objectParameterDataArray = objList;
|
||||
|
||||
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;
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
warpGoals.Clear();
|
||||
}
|
||||
|
||||
|
||||
public static void goToAdjacentWarpGoal(TileNode v, List<TileNode> path)
|
||||
{
|
||||
object[] obj = new object[2];
|
||||
obj[0] = v;
|
||||
obj[1] = path;
|
||||
goToAdjacentWarpGoal(obj);
|
||||
}
|
||||
|
||||
public static void goToAdjacentWarpGoal(object obj)
|
||||
{
|
||||
object[] objArray = (object[])obj;
|
||||
|
||||
TileNode v = (TileNode)objArray[2];
|
||||
string locationName = (string)objArray[3];
|
||||
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;
|
||||
|
||||
for(int i = -1; i <= 1; i++)
|
||||
{
|
||||
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
foreach (var warp in v.thisLocation.warps)
|
||||
{
|
||||
if (warp.X == Game1.player.getTileX()+i && warp.Y == Game1.player.getTileY()+j)
|
||||
{
|
||||
Game1.warpFarmer(warp.TargetName, warp.TargetX, warp.TargetY, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (Game1.player.facingDirection == 2)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
|
||||
}
|
||||
if (Game1.player.facingDirection == 1)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_D) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
|
||||
}
|
||||
if (Game1.player.facingDirection == 0)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
|
||||
|
||||
}
|
||||
if (Game1.player.facingDirection == 3)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_A) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
|
||||
}
|
||||
|
||||
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
||||
*/
|
||||
//ModCore.CoreMonitor.Log(tileLocation.ToString());
|
||||
//if(v.thisLocation.isTerrainFeatureAt)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,547 +0,0 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StarAI.ExecutionCore;
|
||||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||
{
|
||||
public class WarpGoal
|
||||
{
|
||||
public WarpGoal parentWarpGoal;
|
||||
public Warp warp;
|
||||
public List<WarpGoal> childrenWarps;
|
||||
|
||||
|
||||
public static List<GameLocation> checkedLocations = new List<GameLocation>();
|
||||
public static List<Warp> exploredLocations = new List<Warp>();
|
||||
|
||||
public WarpGoal(WarpGoal Parent, Warp CurrentWarp)
|
||||
{
|
||||
this.parentWarpGoal = Parent;
|
||||
this.warp = CurrentWarp;
|
||||
this.childrenWarps = new List<WarpGoal>();
|
||||
}
|
||||
|
||||
|
||||
public static void getWarpChain(GameLocation location, string mapName)
|
||||
{
|
||||
List<GameLocation> blerp = new List<GameLocation>();
|
||||
GameLocation check = Game1.getLocationFromName(mapName);
|
||||
if (check == null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("INVALID LOCATION");
|
||||
return;
|
||||
}
|
||||
//init
|
||||
List<WarpGoal> startinggoals = new List<WarpGoal>();
|
||||
foreach (var Warp in location.warps)
|
||||
{
|
||||
WarpGoal child = new WarpGoal(null, Warp);
|
||||
startinggoals.Add(child);
|
||||
if (Warp.TargetName == mapName)
|
||||
{
|
||||
TransitionLogic.transitionToAdjacentMap(location, mapName);
|
||||
return;
|
||||
}
|
||||
exploredLocations.Add(Warp);
|
||||
}
|
||||
|
||||
//keep chaining children
|
||||
//exploredLocations.Add(location);
|
||||
checkedLocations.Add(location);
|
||||
List<WarpGoal> warpChain = okBye(startinggoals, mapName, location,checkedLocations);
|
||||
|
||||
checkedLocations.Clear();
|
||||
exploredLocations.Clear();
|
||||
if (warpChain == null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
||||
return;
|
||||
}
|
||||
if (warpChain.Count == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN OR CAN't FIND PATH TO LOCATION");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var v in warpChain)
|
||||
{
|
||||
if (v.parentWarpGoal != null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Take this warp from location to destination:" + v.parentWarpGoal.warp.TargetName + " To " + v.warp.TargetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Take this warp from location to destination:" + Game1.player.currentLocation.name + " To " + v.warp.TargetName);
|
||||
}
|
||||
}
|
||||
|
||||
List<List<TileNode>> pathMaster = new List<List<TileNode>>();
|
||||
warpChain.Reverse();
|
||||
|
||||
foreach (var v in startinggoals)
|
||||
{
|
||||
if (v.warp.TargetName == warpChain.ElementAt(0).warp.TargetName)
|
||||
{
|
||||
//v.parentWarpGoal = warpChain.ElementAt(warpChain.Count - 1);
|
||||
warpChain.Insert(0, v);
|
||||
ModCore.CoreMonitor.Log("Insert from" + Game1.player.currentLocation.name + " To " + v.warp.TargetName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < warpChain.Count; i++)
|
||||
{
|
||||
WarpGoal v = warpChain[i];
|
||||
ModCore.CoreMonitor.Log("Processing:" + v.warp.TargetName);
|
||||
if (i == 0)
|
||||
{
|
||||
|
||||
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());
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(s, "WarpGoal"));
|
||||
|
||||
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.warp.X, v.warp.Y);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "WarpGoal"));
|
||||
pathMaster.Add(Utilities.getIdealPath(t, s));
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
ModCore.CoreMonitor.Log("OK COUNT:" + pathMaster.Count.ToString());
|
||||
|
||||
ModCore.CoreMonitor.Log(("Name: " + Game1.currentLocation + " X " + warpChain[i].warp.X + " Y " + warpChain[i].warp.Y));
|
||||
// List<TileNode> miniPath = pathMaster.ElementAt(pathMaster.Count - 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == warpChain.Count - 1) continue;
|
||||
ModCore.CoreMonitor.Log("Count:" + warpChain.Count.ToString());
|
||||
ModCore.CoreMonitor.Log("I:" + i.ToString());
|
||||
int index = i + 1;
|
||||
ModCore.CoreMonitor.Log(("Name Source: " + warpChain[i].warp.TargetName + " X " + warpChain[index - 1].warp.TargetX + " Y " + warpChain[index - 1].warp.TargetY));
|
||||
ModCore.CoreMonitor.Log(("Name Destination: " + warpChain[i].warp.TargetName + " X " + warpChain[index].warp.X + " Y " + warpChain[index].warp.Y));
|
||||
try
|
||||
{
|
||||
TileNode tears = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
|
||||
tears.fakePlacementAction(Game1.getLocationFromName(warpChain[i].warp.TargetName), warpChain[index].warp.X, warpChain[index].warp.Y);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(tears, "WarpGoal"));
|
||||
|
||||
TileNode source = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
|
||||
source.fakePlacementAction(Game1.getLocationFromName(warpChain[i].warp.TargetName), warpChain[index - 1].warp.TargetX, warpChain[index - 1].warp.TargetY);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(source, "WarpGoal"));
|
||||
|
||||
|
||||
pathMaster.Add(Utilities.getIdealPath(tears, source));
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
continue;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("WTF ME I GUESS");
|
||||
ModCore.CoreMonitor.Log(err.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
bool once = false;
|
||||
|
||||
|
||||
foreach (var path in pathMaster)
|
||||
{
|
||||
foreach (var v in path)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("This is my path LOL:" + v.thisLocation.ToString() + v.tileLocation.ToString(), StardewModdingAPI.LogLevel.Warn);
|
||||
}
|
||||
}
|
||||
|
||||
object[] arr = new object[4];
|
||||
arr[3] = pathMaster;
|
||||
arr[0] = pathMaster;
|
||||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(pathToLocation,arr ,new TaskMetaData("Path to " + mapName, new ExecutionCore.TaskPrerequisites.LocationPrerequisite(location), null, null, null, new ExecutionCore.TaskPrerequisites.BedTimePrerequisite(true), null));
|
||||
|
||||
task.taskMetaData.pathsToTake=pathMaster;
|
||||
task.taskMetaData.cost = 0;
|
||||
foreach(var v in task.taskMetaData.pathsToTake)
|
||||
{
|
||||
task.taskMetaData.cost += (v.Count * TaskMetaDataHeuristics.pathCostMultiplier);
|
||||
}
|
||||
//arr[0] = task.taskMetaData.pathsToTake;
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
|
||||
Utilities.tileExceptionList.Clear();
|
||||
//return warpChain;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static List<List<TileNode>> getWarpChainReturn(GameLocation location,string mapName)
|
||||
{
|
||||
GameLocation check = Game1.getLocationFromName(mapName);
|
||||
|
||||
List<GameLocation> blerp = new List<GameLocation>();
|
||||
if (check.isStructure) mapName = check.uniqueName;
|
||||
if (check == null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("INVALID LOCATION");
|
||||
return null;
|
||||
}
|
||||
//init
|
||||
List<WarpGoal> startinggoals = new List<WarpGoal>();
|
||||
foreach(var Warp in location.warps)
|
||||
{
|
||||
WarpGoal child = new WarpGoal(null, Warp);
|
||||
startinggoals.Add(child);
|
||||
exploredLocations.Add(Warp);
|
||||
/*
|
||||
if (Warp.TargetName == mapName)
|
||||
{
|
||||
List < List < TileNode >>ok= new List<List<TileNode>>();
|
||||
List<TileNode> listOfOne = TransitionLogic.transitionToAdjacentMapReturn(location, mapName);
|
||||
ok.Add(listOfOne);
|
||||
return ok;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//keep chaining children
|
||||
// exploredLocations.Add(location);
|
||||
checkedLocations.Add(location);
|
||||
List<WarpGoal> warpChain= okBye(startinggoals, mapName,location,checkedLocations);
|
||||
checkedLocations.Clear();
|
||||
exploredLocations.Clear();
|
||||
if (warpChain == null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
||||
return null;
|
||||
}
|
||||
if (warpChain.Count == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN OR CAN't FIND PATH TO LOCATION");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach(var v in warpChain)
|
||||
{
|
||||
if (v.parentWarpGoal != null)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Take this warp from location to destination:" +v.parentWarpGoal.warp.TargetName +" To " + v.warp.TargetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Take this warp from location to destination:" + Game1.player.currentLocation.name + " To " + v.warp.TargetName);
|
||||
}
|
||||
}
|
||||
|
||||
List<List<TileNode>> pathMaster = new List<List<TileNode>>();
|
||||
warpChain.Reverse();
|
||||
|
||||
foreach (var v in startinggoals)
|
||||
{
|
||||
if (v.warp.TargetName == warpChain.ElementAt(0).warp.TargetName)
|
||||
{
|
||||
//v.parentWarpGoal = warpChain.ElementAt(warpChain.Count - 1);
|
||||
warpChain.Insert(0,v);
|
||||
ModCore.CoreMonitor.Log("Insert from" + Game1.player.currentLocation.name + " To " + v.warp.TargetName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//add to end of warpChain
|
||||
//Path to last location tile.
|
||||
for (int i=0;i<warpChain.Count;i++)
|
||||
{
|
||||
WarpGoal v = warpChain[i];
|
||||
ModCore.CoreMonitor.Log("Processing:" +v.warp.TargetName);
|
||||
if (i == 0)
|
||||
{
|
||||
|
||||
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());
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(s, "WarpGoal"));
|
||||
|
||||
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.warp.X, v.warp.Y);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "WarpGoal"));
|
||||
pathMaster.Add(Utilities.getIdealPath(t,s));
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
ModCore.CoreMonitor.Log("OK COUNT:"+pathMaster.Count.ToString());
|
||||
|
||||
ModCore.CoreMonitor.Log(("Name: " + Game1.currentLocation + " X " + warpChain[i].warp.X + " Y " + warpChain[i].warp.Y));
|
||||
// List<TileNode> miniPath = pathMaster.ElementAt(pathMaster.Count - 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == warpChain.Count - 1) continue;
|
||||
ModCore.CoreMonitor.Log("Count:" +warpChain.Count.ToString());
|
||||
ModCore.CoreMonitor.Log("I:" + i.ToString());
|
||||
int index = i + 1;
|
||||
ModCore.CoreMonitor.Log(("Name Source: " + warpChain[i].warp.TargetName + " X " + warpChain[index-1].warp.TargetX + " Y " + warpChain[index-1].warp.TargetY));
|
||||
ModCore.CoreMonitor.Log(("Name Destination: " + warpChain[i].warp.TargetName + " X " + warpChain[index].warp.X + " Y " + warpChain[index].warp.Y));
|
||||
try
|
||||
{
|
||||
TileNode tears = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
|
||||
tears.fakePlacementAction(Game1.getLocationFromName(warpChain[i].warp.TargetName), warpChain[index].warp.X, warpChain[index].warp.Y);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(tears, "WarpGoal"));
|
||||
|
||||
TileNode source = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Brown));
|
||||
source.fakePlacementAction(Game1.getLocationFromName(warpChain[i].warp.TargetName), warpChain[index-1].warp.TargetX, warpChain[index-1].warp.TargetY);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(source, "WarpGoal"));
|
||||
|
||||
|
||||
pathMaster.Add(Utilities.getIdealPath(tears,source));
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
continue;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("WTF ME I GUESS");
|
||||
ModCore.CoreMonitor.Log(err.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
bool once = false;
|
||||
|
||||
|
||||
foreach(var path in pathMaster)
|
||||
{
|
||||
foreach(var v in path)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("This is my path LOL:" + v.thisLocation.ToString() + v.tileLocation.ToString(),StardewModdingAPI.LogLevel.Warn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pathMaster;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void pathToLocation(List<List<TileNode>> pathMaster)
|
||||
{
|
||||
object[] arr = new object[4];
|
||||
arr[3] = pathMaster;
|
||||
pathToLocation(arr);
|
||||
}
|
||||
|
||||
public static void pathToLocation(object o)
|
||||
{
|
||||
object[] arr = (object[])o;
|
||||
List<List<TileNode>> pathMaster = (List<List<TileNode>>)arr[3];
|
||||
bool once = false;
|
||||
|
||||
while (pathMaster.Count != 0)
|
||||
{
|
||||
pathMaster.ElementAt(0).Remove(pathMaster.ElementAt(0).ElementAt((pathMaster.ElementAt(0).Count - 1))); //get first path and remove first element from it because it will force me to warp back.
|
||||
ModCore.CoreMonitor.Log("Pathing to:" + pathMaster.ElementAt(0).ElementAt(0).thisLocation.ToString() + pathMaster.ElementAt(0).ElementAt(0).tileLocation.ToString());
|
||||
ModCore.CoreMonitor.Log("Pathing from:" + pathMaster.ElementAt(0).ElementAt(pathMaster.ElementAt(0).Count - 1).thisLocation.ToString() + pathMaster.ElementAt(0).ElementAt(pathMaster.ElementAt(0).Count - 1).tileLocation.ToString());
|
||||
|
||||
if (once == false)
|
||||
{
|
||||
|
||||
foreach (var v in pathMaster.ElementAt(0))
|
||||
{
|
||||
ModCore.CoreMonitor.Log("This is my path:" + v.thisLocation.ToString() + v.tileLocation.ToString());
|
||||
}
|
||||
//pathMaster.ElementAt(0).Remove(pathMaster.ElementAt(0).ElementAt(0));
|
||||
PathFindingLogic.calculateMovement(pathMaster.ElementAt(0));
|
||||
ModCore.CoreMonitor.Log("WTF???");
|
||||
once = true;
|
||||
//warped = false;
|
||||
}
|
||||
else if (once == true)
|
||||
{
|
||||
List<TileNode> temp = new List<TileNode>();
|
||||
for (int i = 0; i < pathMaster.ElementAt(0).Count; i++)
|
||||
{
|
||||
|
||||
temp.Add(pathMaster.ElementAt(0).ElementAt(i));
|
||||
|
||||
}
|
||||
ModCore.CoreMonitor.Log("Pathing from FIX:" + temp.ElementAt(temp.Count - 1).thisLocation.ToString() + temp.ElementAt(temp.Count - 1).tileLocation.ToString());
|
||||
|
||||
foreach (var v in temp)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("This is my path modified:" + v.thisLocation.ToString() + v.tileLocation.ToString() + v.position.ToString());
|
||||
}
|
||||
// temp.Remove(temp.ElementAt(0));
|
||||
Game1.player.position = temp.ElementAt(temp.Count - 1).position;
|
||||
PathFindingLogic.calculateMovement(temp);
|
||||
}
|
||||
|
||||
bool warped = false;
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
foreach (var warp in Game1.player.currentLocation.warps) //get location of tiles.
|
||||
{
|
||||
if (warp.X == Game1.player.getTileX() + i && warp.Y == Game1.player.getTileY() + j)
|
||||
{
|
||||
Game1.warpFarmer(warp.TargetName, warp.TargetX, warp.TargetY, false);
|
||||
ModCore.CoreMonitor.Log("WARP:" + warped.ToString());
|
||||
warped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (warped == true) break;
|
||||
}
|
||||
if (warped == true) break;
|
||||
}
|
||||
warped = false;
|
||||
pathMaster.Remove(pathMaster.ElementAt(0));
|
||||
once = true;
|
||||
}
|
||||
|
||||
|
||||
//Do final location walk to stuff here.
|
||||
}
|
||||
|
||||
/*
|
||||
public static List<WarpGoal> okByeGOODLOCATION(List<WarpGoal> param, string targetMapName, GameLocation lastCheckedLocation)
|
||||
{
|
||||
|
||||
List<GameLocation> placesToExplore = new List<GameLocation>();
|
||||
List<GameLocation> placesIHaveBeen = new List<GameLocation>();
|
||||
|
||||
foreach(var warpGoal in param)
|
||||
{
|
||||
ModCore.CoreMonitor.Log(warpGoal.warp.TargetName);
|
||||
placesToExplore.Add(Game1.getLocationFromName(warpGoal.warp.TargetName));
|
||||
}
|
||||
placesIHaveBeen.Add(lastCheckedLocation);
|
||||
|
||||
|
||||
while (placesToExplore.Count != 0)
|
||||
{
|
||||
GameLocation currentCheckingLocation = placesToExplore.ElementAt(0);
|
||||
while(checkedLocations.Contains(currentCheckingLocation))
|
||||
{
|
||||
placesToExplore.Remove(currentCheckingLocation);
|
||||
currentCheckingLocation = placesToExplore.ElementAt(0);
|
||||
ModCore.CoreMonitor.Log("REMOVING " + currentCheckingLocation.name, StardewModdingAPI.LogLevel.Warn);
|
||||
|
||||
}
|
||||
foreach(var warp in currentCheckingLocation.warps)
|
||||
{
|
||||
bool addNewLocation = true;
|
||||
foreach (var checkedPlace in placesIHaveBeen)
|
||||
{
|
||||
|
||||
if (checkedPlace.name == warp.TargetName)
|
||||
{
|
||||
addNewLocation = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
foreach(var location in placesToExplore)
|
||||
{
|
||||
if(location.name== warp.TargetName)
|
||||
{
|
||||
addNewLocation = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (addNewLocation == true)
|
||||
{
|
||||
placesToExplore.Add(Game1.getLocationFromName(warp.TargetName));
|
||||
ModCore.CoreMonitor.Log("ADDING NEW LOCATION" + warp.TargetName, StardewModdingAPI.LogLevel.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CoreMonitor.Log("ALREADY BEEN AT THIS LOCATION: " + currentCheckingLocation.name, StardewModdingAPI.LogLevel.Warn);
|
||||
}
|
||||
}
|
||||
placesIHaveBeen.Add(currentCheckingLocation);
|
||||
placesToExplore.Remove(currentCheckingLocation);
|
||||
ModCore.CoreMonitor.Log("CHECKING LOCATION: " + currentCheckingLocation.name,StardewModdingAPI.LogLevel.Alert);
|
||||
}
|
||||
return new List<WarpGoal>();
|
||||
}
|
||||
*/
|
||||
public static List<WarpGoal> okBye(List<WarpGoal> param, string targetMapName, GameLocation lastCheckedLocation,List<GameLocation> place)
|
||||
{
|
||||
|
||||
// List<GameLocation> placesToExplore = new List<GameLocation>();
|
||||
List<GameLocation> placesIHaveBeen = place;
|
||||
|
||||
List<GameLocation> initialLocations = new List<GameLocation>();
|
||||
|
||||
|
||||
|
||||
placesIHaveBeen.Add(lastCheckedLocation);
|
||||
bool found = false;
|
||||
if (param.Count == 0)
|
||||
{
|
||||
return new List<WarpGoal>();
|
||||
}
|
||||
|
||||
foreach(var warpGoal in param)
|
||||
{
|
||||
|
||||
WarpGoal lastWarp = warpGoal;
|
||||
|
||||
GameLocation targetLocation = Game1.getLocationFromName(warpGoal.warp.TargetName);
|
||||
|
||||
if (targetLocation.name == targetMapName)
|
||||
{
|
||||
List<WarpGoal> hate = new List<WarpGoal>();
|
||||
while (lastWarp.parentWarpGoal!=null)
|
||||
{
|
||||
hate.Add(lastWarp);
|
||||
lastWarp = lastWarp.parentWarpGoal;
|
||||
}
|
||||
hate.Add(lastWarp);
|
||||
return hate;
|
||||
}
|
||||
|
||||
bool ignore = false;
|
||||
|
||||
foreach (var v in placesIHaveBeen)
|
||||
{
|
||||
if (v.name == targetLocation.name)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("I guve ps"+v.name);
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ignore == true) continue;
|
||||
ModCore.CoreMonitor.Log("I AM HERE:"+targetLocation.name);
|
||||
foreach (Warp warp in targetLocation.warps)
|
||||
{
|
||||
WarpGoal fun = new WarpGoal(warpGoal, warp);
|
||||
warpGoal.childrenWarps.Add(fun);
|
||||
}
|
||||
placesIHaveBeen.Add(targetLocation);
|
||||
List<WarpGoal> idk = okBye(lastWarp.childrenWarps, targetMapName, targetLocation,placesIHaveBeen);
|
||||
if (idk.Count == 0) continue;
|
||||
if (idk.ElementAt(0).warp.TargetName == targetMapName) return idk;
|
||||
// placesIHaveBeen.Clear();
|
||||
|
||||
}
|
||||
|
||||
return new List<WarpGoal>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -303,7 +303,7 @@ namespace StarAI.PathFindingCore
|
|||
int index = 0;
|
||||
List<TileNode> path = new List<TileNode>();
|
||||
//path.Clear();
|
||||
ModCore.CoreMonitor.Log("LET'S GO!!!!", LogLevel.Error);
|
||||
//ModCore.CoreMonitor.Log("LET'S GO!!!!", LogLevel.Error);
|
||||
object[] obj = (object[])data;
|
||||
|
||||
TileNode Source = (TileNode)obj[0];
|
||||
|
|
|
@ -25,19 +25,6 @@ namespace StarAI.PathFindingCore
|
|||
index = TileIndex;
|
||||
}
|
||||
|
||||
public static TileExceptionNode parseJson(string s)
|
||||
{
|
||||
dynamic obj = JObject.Parse(s);
|
||||
TileExceptionNode t = new TileExceptionNode();
|
||||
t.imageSource = obj.imageSource;
|
||||
t.index = obj.index;
|
||||
return t;
|
||||
}
|
||||
|
||||
public void serializeJson(string s)
|
||||
{
|
||||
StardustCore.ModCore.SerializationManager.WriteToJsonFile(Path.Combine(s, "tileExceptionData"+ this.index.ToString() + ".json"), (TileExceptionNode)this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace StarAI.PathFindingCore
|
|||
|
||||
public TileNode parent;
|
||||
|
||||
public static bool checkIfICanPlaceHere(TileNode t, Vector2 pos, GameLocation loc = null,bool idk=true, bool utilityCheck=false)
|
||||
public static bool checkIfICanPlaceHere(TileNode t, Vector2 pos, GameLocation loc = null,bool ignorePlacement=true, bool utilityCheck=false)
|
||||
{
|
||||
bool cry = false;
|
||||
if (t.thisLocation == null)
|
||||
|
@ -127,14 +127,15 @@ namespace StarAI.PathFindingCore
|
|||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
||||
if (ignorePlacement == false)
|
||||
{
|
||||
// ModCore.CoreMonitor.Log("Tile Not placeable at location. " + t.thisLocation.name, LogLevel.Error);
|
||||
if (cry == true) t.thisLocation = null;
|
||||
return false;
|
||||
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
||||
{
|
||||
// ModCore.CoreMonitor.Log("Tile Not placeable at location. " + t.thisLocation.name, LogLevel.Error);
|
||||
if (cry == true) t.thisLocation = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (t.thisLocation.isTilePassable(new xTile.Dimensions.Location((int)(pos.X/Game1.tileSize), (int)(pos.Y/Game1.tileSize)), Game1.viewport)==false)
|
||||
|
|
|
@ -383,7 +383,7 @@ namespace StarAI.PathFindingCore
|
|||
if (f == false)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("FAILED TO PUT DOWN A GOAL????");
|
||||
ModCore.CoreMonitor.Log(v.thisLocation.ToString()+v.tileLocation.ToString());
|
||||
ModCore.CoreMonitor.Log(v.thisLocation.ToString()+pos.ToString());
|
||||
}
|
||||
// ModCore.CoreMonitor.Log("OK THIS IS THE RESULT F: " + f, LogLevel.Alert);
|
||||
if (f == true)
|
||||
|
@ -436,52 +436,8 @@ namespace StarAI.PathFindingCore
|
|||
//ModCore.CoreMonitor.Log("CAUGHT MY CULPERATE", LogLevel.Warn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
foreach (var nav in miniGoals) //change this??????
|
||||
{
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.clearExceptionListWithName("Navigation");
|
||||
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());
|
||||
|
||||
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));
|
||||
|
||||
|
||||
//have this take in a list of goals and see which goal it reaches first
|
||||
List<TileNode> path = PathFindingCore.PathFindingLogic.pathFindToSingleGoalReturnPath(tempSource, nav, new List<TileNode>(), placement, utility);
|
||||
if (path.Count == 0)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("NOPE, no path I guess.",LogLevel.Warn);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CoreMonitor.Log("There is a path", LogLevel.Alert);
|
||||
ModCore.CoreMonitor.Log("COST OF THE PATH IS: "+path.Count.ToString(), LogLevel.Alert);
|
||||
}
|
||||
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);
|
||||
if(placement) 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);
|
||||
|
||||
// Console.WriteLine("GOALS COUNT:" + miniGoals.Count);
|
||||
foreach (var q in removalList)
|
||||
{
|
||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(q);
|
||||
|
|
|
@ -70,19 +70,20 @@
|
|||
<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\MapTransitionLogic\TransitionLogic.cs" />
|
||||
<Compile Include="PathFindingCore\MapTransitionLogic\WarpGoal.cs" />
|
||||
<Compile Include="TaskCore\ChestLogic.cs" />
|
||||
<Compile Include="TaskCore\CropLogic\CropLogic.cs" />
|
||||
<Compile Include="TaskCore\CropLogic\ShippingLogic.cs" />
|
||||
<Compile Include="TaskCore\DebrisLogic\DebrisLogic.cs" />
|
||||
<Compile Include="TaskCore\MapTransitionLogic\TransitionLogic.cs" />
|
||||
<Compile Include="TaskCore\MapTransitionLogic\WarpGoal.cs" />
|
||||
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
||||
<Compile Include="TaskCore\MapTransitionLogic\WayPoints.cs" />
|
||||
<Compile Include="PathFindingCore\TileNodes\PlacementNode.cs" />
|
||||
<Compile Include="PathFindingCore\TileNodes\TileExceptionMetaData.cs" />
|
||||
<Compile Include="PathFindingCore\TileNodes\TileExceptionNode.cs" />
|
||||
<Compile Include="PathFindingCore\TileNodes\TileNodeObject.cs" />
|
||||
<Compile Include="PathFindingCore\Utilities.cs" />
|
||||
<Compile Include="PathFindingCore\WaterLogic\WaterLogic.cs" />
|
||||
<Compile Include="TaskCore\WaterLogic\WaterLogic.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StarAI.PathFindingCore;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Objects;
|
||||
|
@ -9,7 +10,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarAI.PathFindingCore
|
||||
namespace StarAI.TaskCore
|
||||
{
|
||||
class ChestLogic
|
||||
{
|
|
@ -9,8 +9,9 @@ using StardewValley;
|
|||
using Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
using StarAI.ExecutionCore.TaskPrerequisites;
|
||||
using StarAI.PathFindingCore;
|
||||
|
||||
namespace StarAI.PathFindingCore.CropLogic
|
||||
namespace StarAI.TaskCore.CropLogic
|
||||
{
|
||||
|
||||
|
||||
|
@ -35,7 +36,7 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
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)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));
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Water"));
|
||||
PathFindingCore.Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Water"));
|
||||
cropsToWater.Add(t);
|
||||
}
|
||||
}
|
||||
|
@ -52,14 +53,14 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(waterSingleCrop, obj, new ExecutionCore.TaskMetaData("Water Crop", new LocationPrerequisite(v.thisLocation),new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1)));
|
||||
if (task.taskMetaData.cost == Int32.MaxValue)
|
||||
{
|
||||
Utilities.clearExceptionListWithNames(true);
|
||||
StarAI.PathFindingCore.Utilities.clearExceptionListWithNames(true);
|
||||
continue;
|
||||
}
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
obj[1] = task.taskMetaData.pathsToTake[0];
|
||||
task.objectParameterDataArray = obj;
|
||||
// waterSingleCrop(v);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
StarAI.PathFindingCore.Utilities.clearExceptionListWithName("Child");
|
||||
}
|
||||
cropsToWater.Clear();
|
||||
}
|
||||
|
@ -121,23 +122,23 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
Vector2 center=new Vector2();
|
||||
if (Game1.player.facingDirection == 2)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X+1, (int)v.tileLocation.Y);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X+1, (int)v.tileLocation.Y);
|
||||
continue;
|
||||
}
|
||||
if (Game1.player.facingDirection == 1)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X-1, (int)v.tileLocation.Y);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X-1, (int)v.tileLocation.Y);
|
||||
continue;
|
||||
}
|
||||
if (Game1.player.facingDirection == 0)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y+1);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y+1);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (Game1.player.facingDirection == 3)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y-1);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y-1);
|
||||
continue;
|
||||
}
|
||||
Game1.player.position = center;
|
||||
|
@ -148,7 +149,7 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
ModCore.CoreMonitor.Log("player pos: "+Game1.player.position.ToString(),LogLevel.Warn);
|
||||
ModCore.CoreMonitor.Log("TilePos: "+v.position.ToString(), LogLevel.Error);
|
||||
}
|
||||
Utilities.cleanExceptionList(v);
|
||||
StarAI.PathFindingCore.Utilities.cleanExceptionList(v);
|
||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
|
||||
// StardustCore.Utilities.masterRemovalList.Add(v);
|
||||
//v.performRemoveAction(v.tileLocation, v.thisLocation);
|
||||
|
@ -186,7 +187,7 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
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));
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Harvest"));
|
||||
StarAI.PathFindingCore.Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "Harvest"));
|
||||
cropsToHarvest.Add(t);
|
||||
}
|
||||
}
|
||||
|
@ -203,14 +204,14 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
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)
|
||||
{
|
||||
Utilities.clearExceptionListWithNames(true);
|
||||
StarAI.PathFindingCore.Utilities.clearExceptionListWithNames(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
obj[1] = task.taskMetaData.pathsToTake[0];
|
||||
task.objectParameterDataArray = obj;
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
StarAI.PathFindingCore.Utilities.clearExceptionListWithName("Child");
|
||||
// waterSingleCrop(v);
|
||||
}
|
||||
cropsToHarvest.Clear();
|
||||
|
@ -274,28 +275,28 @@ namespace StarAI.PathFindingCore.CropLogic
|
|||
Vector2 center = new Vector2();
|
||||
if (Game1.player.facingDirection == 2)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X + 1, (int)v.tileLocation.Y);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X + 1, (int)v.tileLocation.Y);
|
||||
continue;
|
||||
}
|
||||
if (Game1.player.facingDirection == 1)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X - 1, (int)v.tileLocation.Y);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X - 1, (int)v.tileLocation.Y);
|
||||
continue;
|
||||
}
|
||||
if (Game1.player.facingDirection == 0)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y + 1);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y + 1);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (Game1.player.facingDirection == 3)
|
||||
{
|
||||
center = Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y - 1);
|
||||
center = StarAI.PathFindingCore.Utilities.parseCenterFromTile((int)v.tileLocation.X, (int)v.tileLocation.Y - 1);
|
||||
continue;
|
||||
}
|
||||
Game1.player.position = center;
|
||||
}
|
||||
Utilities.cleanExceptionList(v);
|
||||
StarAI.PathFindingCore.Utilities.cleanExceptionList(v);
|
||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
|
||||
v.thisLocation.objects.Remove(v.tileLocation);
|
||||
//v.performRemoveAction(v.tileLocation, v.thisLocation);
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StarAI.ExecutionCore.TaskPrerequisites;
|
||||
using StarAI.PathFindingCore;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using System;
|
||||
|
@ -9,7 +10,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarAI.PathFindingCore.CropLogic
|
||||
namespace StarAI.TaskCore.CropLogic
|
||||
{
|
||||
class ShippingLogic
|
||||
{
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StarAI.ExecutionCore.TaskPrerequisites;
|
||||
using StarAI.PathFindingCore;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using System;
|
||||
|
@ -9,7 +10,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarAI.PathFindingCore.DebrisLogic
|
||||
namespace StarAI.TaskCore.DebrisLogic
|
||||
{
|
||||
class DebrisLogic
|
||||
{
|
|
@ -0,0 +1,398 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WindowsInput;
|
||||
using StarAI.PathFindingCore;
|
||||
using StarAI.ExecutionCore;
|
||||
|
||||
namespace StarAI.TaskCore.MapTransitionLogic
|
||||
{
|
||||
class TransitionLogic
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Will transition to the next map by using warp goals if the map is adjacent to the one I am at and I can path to it.
|
||||
/// </summary>
|
||||
/// <param name="location"></param>
|
||||
/// <param name="targetName"></param>
|
||||
public static void transitionToAdjacentMap(GameLocation location,string targetName)
|
||||
{
|
||||
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[4];
|
||||
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(goToAdjacentWarpGoal, objList, new ExecutionCore.TaskMetaData("GoTo adj map", null, null, null, null, null));
|
||||
|
||||
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);
|
||||
objList[3] = targetName;
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
warpGoals.Clear();
|
||||
}
|
||||
|
||||
public static CustomTask transitionToAdjacentMapReturnTask(GameLocation location, string targetName)
|
||||
{
|
||||
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[4];
|
||||
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(goToAdjacentWarpGoal, objList, new ExecutionCore.TaskMetaData("GoTo adj map", null, null, null, null, null));
|
||||
|
||||
task.objectParameterDataArray = objList;
|
||||
|
||||
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;
|
||||
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
warpGoals.Clear();
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
public static List<TileNode> transitionToAdjacentMapReturn(GameLocation location, string targetName)
|
||||
{
|
||||
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[4];
|
||||
List<TileNode> tempList = new List<TileNode>();
|
||||
foreach (var v in warpGoals)
|
||||
{
|
||||
tempList.Add(v);
|
||||
}
|
||||
return tempList;
|
||||
objList[0] = tempList;
|
||||
ok++;
|
||||
int numberOfUses = 1;
|
||||
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(goToAdjacentWarpGoal, objList, new ExecutionCore.TaskMetaData("Path to adj map", null, null, null, null, null));
|
||||
|
||||
task.objectParameterDataArray = objList;
|
||||
|
||||
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;
|
||||
ExecutionCore.TaskList.taskList.Add(task);
|
||||
Utilities.clearExceptionListWithName("Child");
|
||||
Utilities.tileExceptionList.Clear();
|
||||
|
||||
warpGoals.Clear();
|
||||
}
|
||||
|
||||
|
||||
public static void goToAdjacentWarpGoal(TileNode v, List<TileNode> path)
|
||||
{
|
||||
object[] obj = new object[2];
|
||||
obj[0] = v;
|
||||
obj[1] = path;
|
||||
goToAdjacentWarpGoal(obj);
|
||||
}
|
||||
|
||||
public static void goToAdjacentWarpGoal(object obj)
|
||||
{
|
||||
object[] objArray = (object[])obj;
|
||||
|
||||
TileNode v = (TileNode)objArray[2];
|
||||
string locationName = (string)objArray[3];
|
||||
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;
|
||||
|
||||
for(int i = -1; i <= 1; i++)
|
||||
{
|
||||
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
foreach (var warp in v.thisLocation.warps)
|
||||
{
|
||||
if (warp.X == Game1.player.getTileX()+i && warp.Y == Game1.player.getTileY()+j)
|
||||
{
|
||||
Game1.warpFarmer(warp.TargetName, warp.TargetX, warp.TargetY, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (Game1.player.facingDirection == 2)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_S) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
|
||||
}
|
||||
if (Game1.player.facingDirection == 1)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_D) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
|
||||
}
|
||||
if (Game1.player.facingDirection == 0)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_W) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
|
||||
|
||||
}
|
||||
if (Game1.player.facingDirection == 3)
|
||||
{
|
||||
if (InputSimulator.IsKeyDown(VirtualKeyCode.VK_A) == false) InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
|
||||
}
|
||||
|
||||
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
||||
*/
|
||||
//ModCore.CoreMonitor.Log(tileLocation.ToString());
|
||||
//if(v.thisLocation.isTerrainFeatureAt)
|
||||
|
||||
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 transitionToAdjacentMap(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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
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 goToAdjacentWarpGoalTile(TileNode v, List<TileNode> path,string mapName ,Vector2 position)
|
||||
{
|
||||
object[] obj = new object[2];
|
||||
obj[0] = v;
|
||||
obj[1] = path;
|
||||
obj[3] = mapName;
|
||||
obj[4] = position;
|
||||
goToAdjacentWarpGoalTile(obj);
|
||||
}
|
||||
|
||||
public static void goToAdjacentWarpGoalTile(object obj)
|
||||
{
|
||||
object[] objArray = (object[])obj;
|
||||
|
||||
List<TileNode> tileList = (List<TileNode>)objArray[0];
|
||||
string locationName = (string)objArray[3];
|
||||
Vector2 position = (Vector2)objArray[4];
|
||||
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);
|
||||
Warp lastWarp = new Warp(-1, -1, "Claire", -1, -1, false);
|
||||
foreach (var v in tileList)
|
||||
{
|
||||
Vector2 tileLocation = v.tileLocation;
|
||||
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
foreach (var warp in v.thisLocation.warps)
|
||||
{
|
||||
if (warp.X == Game1.player.getTileX() + i && warp.Y == Game1.player.getTileY() + j)
|
||||
{
|
||||
Game1.warpFarmer(warp.TargetName, warp.TargetX, warp.TargetY, false);
|
||||
lastWarp = warp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
ModCore.CoreMonitor.Log("Going here I guess???" + locationName + " : " + position);
|
||||
ModCore.CoreMonitor.Log("From Here???" + Game1.getLocationFromName(lastWarp.TargetName) + " " + lastWarp.TargetX + " " + lastWarp.TargetY);
|
||||
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);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(s, "WarpGoal"));
|
||||
|
||||
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.getLocationFromName(locationName), (int)position.X, (int)position.Y);
|
||||
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "WarpGoal"));
|
||||
|
||||
PathFindingLogic.calculateMovement(Utilities.getIdealPath(t, s));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,127 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using StarAI.ExecutionCore;
|
||||
using StarAI.PathFindingCore;
|
||||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarAI.TaskCore.MapTransitionLogic
|
||||
{
|
||||
public class WayPoints
|
||||
{
|
||||
public static Dictionary<string, KeyValuePair<string, Vector2>> wayPoints = new Dictionary<string, KeyValuePair<string, Vector2>>();
|
||||
|
||||
//Positions listed here will always put the player exactly 1 tile away from what is listed here.
|
||||
public static void initializeWaypoints()
|
||||
{
|
||||
wayPoints.Add("seeds", new KeyValuePair<string, Vector2>("SeedShop", new Vector2(5, 18))); //This waypoint will position the player at the General store 1 tile below the counter.
|
||||
wayPoints.Add("bed", new KeyValuePair<string, Vector2>("FarmHouse", new Vector2(-1, -1))); //to be initialized after load.
|
||||
|
||||
ModCore.CoreMonitor.Log("Star AI WayPoints: Done initializing: " + wayPoints.Count + " waypoints.");
|
||||
}
|
||||
|
||||
|
||||
public static void pathToWayPoint(string wayPointName)
|
||||
{
|
||||
KeyValuePair<string, Vector2> outValue;
|
||||
bool isAvailable = wayPoints.TryGetValue(wayPointName, out outValue);
|
||||
if (isAvailable == true)
|
||||
{
|
||||
MapTransitionLogic.WarpGoal.pathToWorldTile(Game1.player.currentLocation, outValue.Key, (int)outValue.Value.X, (int)outValue.Value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public static CustomTask pathToWayPointReturnTask(string wayPointName)
|
||||
{
|
||||
KeyValuePair<string, Vector2> outValue;
|
||||
bool isAvailable = wayPoints.TryGetValue(wayPointName, out outValue);
|
||||
if (isAvailable == true)
|
||||
{
|
||||
return MapTransitionLogic.WarpGoal.pathToWorldTileReturnTask(Game1.player.currentLocation, outValue.Key, (int)outValue.Value.X, (int)outValue.Value.Y);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void printWayPoints()
|
||||
{
|
||||
foreach(var v in wayPoints)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Waypoint Name:" + v.Key);
|
||||
ModCore.CoreMonitor.Log("Waypoint Position:" + v.Value.Key+" "+v.Value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// To be called after load and after save.
|
||||
/// </summary>
|
||||
public static void setUpBedWaypoint()
|
||||
{
|
||||
Vector2 vec = Game1.player.mostRecentBed / Game1.tileSize;
|
||||
int x = (int)Math.Floor(vec.X);
|
||||
x += 2;
|
||||
int y = (int)Math.Floor(vec.Y);
|
||||
vec = new Vector2(x, y);
|
||||
wayPoints["bed"] = new KeyValuePair<string, Vector2>("FarmHouse",vec);
|
||||
}
|
||||
|
||||
public static void verifyWayPoints()
|
||||
{
|
||||
List<string> removalList = new List<string>();
|
||||
int i = 0;
|
||||
foreach(var waypoint in wayPoints)
|
||||
{
|
||||
i++;
|
||||
ModCore.CoreMonitor.Log("Validating waypoints " + i + " / " + wayPoints.Count);
|
||||
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.getLocationFromName(waypoint.Value.Key),(int)waypoint.Value.Value.X,(int)waypoint.Value.Value.Y);
|
||||
|
||||
// bool canWaypointBeHere=TileNode.checkIfICanPlaceHere(t, waypoint.Value.Value * Game1.tileSize, Game1.getLocationFromName(waypoint.Value.Key), true, false);
|
||||
bool canPathHere = false;
|
||||
foreach(Warp w in Game1.getLocationFromName(waypoint.Value.Key).warps)
|
||||
{
|
||||
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(waypoint.Value.Key), w.X, w.Y);
|
||||
|
||||
var path=Utilities.getIdealPath(t, s);
|
||||
//If I can't find the goal at first keep trying.
|
||||
if (path.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{ //I found the goal so this is a valid waypoint.
|
||||
canPathHere = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Valid waypoint don't remove.
|
||||
if (canPathHere == true)
|
||||
{
|
||||
ModCore.CoreMonitor.Log("Waypoint: " + waypoint.Key + " has been validated as a valid waypoint position at:" + waypoint.Value.Key + " " + waypoint.Value.Value,StardewModdingAPI.LogLevel.Alert);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Couldn't path to this location. Guess I'll remove it.
|
||||
ModCore.CoreMonitor.Log("Removing waypoint: " + waypoint.Key, StardewModdingAPI.LogLevel.Alert);
|
||||
ModCore.CoreMonitor.Log("Can't find path at the location to: " + waypoint.Value.Key + " " + waypoint.Value.Value, StardewModdingAPI.LogLevel.Alert);
|
||||
removalList.Add(waypoint.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var wayPointName in removalList)
|
||||
{
|
||||
wayPoints.Remove(wayPointName);
|
||||
}
|
||||
|
||||
Utilities.tileExceptionList.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue