Fined tuned some pathfinding stuff b adding pathTo and Delay functions. As long as I don't have to cross a bridge pathfinding works.
This commit is contained in:
parent
d722144c21
commit
cd0ac16a22
|
@ -169,7 +169,7 @@ namespace StardustCore.Animations
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Animation ani = new Animation(new Rectangle(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]), Convert.ToInt32(array[4])), Convert.ToInt32(array[5]));
|
Animation ani = new Animation(new Rectangle(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]), Convert.ToInt32(array[4])), Convert.ToInt32(array[5]));
|
||||||
ModCore.ModMonitor.Log(ani.sourceRectangle.ToString());
|
// ModCore.ModMonitor.Log(ani.sourceRectangle.ToString());
|
||||||
ok.Add(ani);
|
ok.Add(ani);
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch(Exception err)
|
||||||
|
|
|
@ -612,7 +612,7 @@ namespace StardustCore
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Game1.showRedMessage("STEP 2");
|
// Game1.showRedMessage("STEP 2");
|
||||||
ModCore.ModMonitor.Log(vector.ToString());
|
//ModCore.ModMonitor.Log(vector.ToString());
|
||||||
|
|
||||||
Vector2 newVec = new Vector2(vector.X, vector.Y);
|
Vector2 newVec = new Vector2(vector.X, vector.Y);
|
||||||
// cObj.boundingBox.Inflate(32, 32);
|
// cObj.boundingBox.Inflate(32, 32);
|
||||||
|
|
|
@ -0,0 +1,243 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using StarAI.PathFindingCore;
|
||||||
|
using StardewModdingAPI;
|
||||||
|
using StardewValley;
|
||||||
|
using StardustCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using StarAI;
|
||||||
|
|
||||||
|
namespace StarAI
|
||||||
|
{
|
||||||
|
class Commands
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void initializeCommands()
|
||||||
|
{
|
||||||
|
ModCore.CoreHelper.ConsoleCommands.Add("hello", "Ok?", new Action<string, string[]>(hello));
|
||||||
|
ModCore.CoreHelper.ConsoleCommands.Add("pathfind", "pathy?", new Action<string, string[]>(Commands.pathfind));
|
||||||
|
ModCore.CoreHelper.ConsoleCommands.Add("pathfinding", "pathy?", new Action<string, string[]>(Commands.pathfind));
|
||||||
|
|
||||||
|
pathfind("Initialize Delay 0", new string[] {
|
||||||
|
"setDelay",
|
||||||
|
"0"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void pathfind(string s, string[] args)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.Length < 1)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("No args passed into path finding function", LogLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set delay code
|
||||||
|
#region
|
||||||
|
if (args[0]=="setDelay"|| args[0]=="delay" || args[0]=="setdelay"|| args[0] == "SetDelay")
|
||||||
|
{
|
||||||
|
PathFindingLogic.delay = Convert.ToInt32(args[1]);
|
||||||
|
ModCore.CoreMonitor.Log("Pathfinding node delay set to: " + Convert.ToString(PathFindingLogic.delay) + " milliseconds.");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//PathTo Code
|
||||||
|
#region
|
||||||
|
if (args[0]=="pathTo"|| args[0]=="pathto"|| args[0]=="PathTo"|| args[0] == "Pathto")
|
||||||
|
{
|
||||||
|
pathfind(s,new string[]{
|
||||||
|
|
||||||
|
"setStart",
|
||||||
|
"currentPosition"
|
||||||
|
});
|
||||||
|
int currentX = Game1.player.getTileX();
|
||||||
|
int currentY = Game1.player.getTileY();
|
||||||
|
int xOffset = Convert.ToInt32(args[1]);
|
||||||
|
int yOffset = Convert.ToInt32(args[2]);
|
||||||
|
int destX = currentX + xOffset;
|
||||||
|
int destY = currentY + yOffset;
|
||||||
|
pathfind(s, new string[]
|
||||||
|
{
|
||||||
|
"addGoal",
|
||||||
|
destX.ToString(),
|
||||||
|
destY.ToString()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
pathfind("pathfind restart", new string[]
|
||||||
|
{
|
||||||
|
"start"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//Add goal code
|
||||||
|
#region
|
||||||
|
if (args[0] == "addGoal" || args[0] == "setGoal")
|
||||||
|
{
|
||||||
|
|
||||||
|
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Green));
|
||||||
|
Vector2 pos = new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
|
||||||
|
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X, pos.Y), Game1.player.currentLocation);
|
||||||
|
if (ok == false)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("Can't place a goal point here!!!", LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
t.placementAction(Game1.currentLocation, (int)pos.X, (int)pos.Y);
|
||||||
|
PathFindingLogic.currentGoal = t;
|
||||||
|
PathFindingLogic.goals.Add(t);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//Add start
|
||||||
|
#region
|
||||||
|
if (args[0] == "addStart" || args[0] == "setStart")
|
||||||
|
{
|
||||||
|
|
||||||
|
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Magenta));
|
||||||
|
Vector2 pos;
|
||||||
|
if (args[1] == "currentPosition")
|
||||||
|
{
|
||||||
|
pos = new Vector2((int)(Game1.player.getTileX() * Game1.tileSize), Game1.player.getTileY() * Game1.tileSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pos = new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X, pos.Y), Game1.player.currentLocation);
|
||||||
|
if (ok == false)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("Can't place a start point here!!!", LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
t.placementAction(Game1.currentLocation, (int)pos.X, (int)pos.Y);
|
||||||
|
PathFindingLogic.source = t;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//Restart Code
|
||||||
|
#region
|
||||||
|
if (args[0] == "restart")
|
||||||
|
{
|
||||||
|
List<CoreObject> removalList = new List<CoreObject>();
|
||||||
|
foreach (var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
|
||||||
|
{
|
||||||
|
removalList.Add(v);
|
||||||
|
}
|
||||||
|
foreach (var v in removalList)
|
||||||
|
{
|
||||||
|
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
|
||||||
|
Game1.player.currentLocation.objects.Remove(v.TileLocation);
|
||||||
|
pathfind("pathfind restart", new string[]
|
||||||
|
{
|
||||||
|
"addGoal",
|
||||||
|
PathFindingLogic.currentGoal.tileLocation.X.ToString(),
|
||||||
|
PathFindingLogic.currentGoal.tileLocation.Y.ToString(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
removalList.Clear();
|
||||||
|
pathfind("pathfind restart", new string[]
|
||||||
|
{
|
||||||
|
"addStart",
|
||||||
|
PathFindingLogic.source.tileLocation.X.ToString(),
|
||||||
|
PathFindingLogic.source.tileLocation.Y.ToString(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
pathfind("pathfind restart", new string[]
|
||||||
|
{
|
||||||
|
"start"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//start code
|
||||||
|
#region
|
||||||
|
if (args[0] == "start")
|
||||||
|
{
|
||||||
|
if (Game1.player == null) return;
|
||||||
|
if (Game1.hasLoadedGame == false) return;
|
||||||
|
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
|
||||||
|
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
|
||||||
|
if (PathFindingCore.PathFindingLogic.currentGoal == null)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("NO VALID GOAL SET FOR PATH FINDING!", LogLevel.Error);
|
||||||
|
}
|
||||||
|
if (PathFindingCore.PathFindingLogic.source == null)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("NO VALID START SET FOR PATH FINDING!", LogLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ModCore.fun.Status == TaskStatus.Running)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("TASK IS RUNNING CAN'T PATHFIND AT THE MOMENT", LogLevel.Alert);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ModCore.fun.Status == TaskStatus.RanToCompletion)
|
||||||
|
{
|
||||||
|
|
||||||
|
ModCore.CoreMonitor.Log("TASK IS Finished PATHFINDING", LogLevel.Warn);
|
||||||
|
ModCore.obj[0] = PathFindingLogic.source;
|
||||||
|
ModCore.obj[1] = PathFindingLogic.currentGoal;
|
||||||
|
ModCore.obj[2] = PathFindingLogic.queue;
|
||||||
|
ModCore.fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), ModCore.obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ModCore.fun.Status == TaskStatus.Created)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
|
||||||
|
ModCore.obj[0] = PathFindingLogic.source;
|
||||||
|
ModCore.obj[1] = PathFindingLogic.currentGoal;
|
||||||
|
ModCore.obj[2] = PathFindingLogic.queue;
|
||||||
|
ModCore.fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), ModCore.obj);
|
||||||
|
|
||||||
|
ModCore.fun.Start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ModCore.CoreMonitor.Log(ModCore.fun.Status.ToString());
|
||||||
|
if (ModCore.fun.Status == TaskStatus.Faulted)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(ModCore.fun.Exception.ToString());
|
||||||
|
ModCore.CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
|
||||||
|
ModCore.obj[0] = PathFindingLogic.source;
|
||||||
|
ModCore.obj[1] = PathFindingLogic.currentGoal;
|
||||||
|
ModCore.obj[2] = PathFindingLogic.queue;
|
||||||
|
ModCore.fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), ModCore.obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A test function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">This is the command's name</param>
|
||||||
|
/// <param name="sarray">This is the parameters that follow.</param>
|
||||||
|
public static void hello(string s, string[] sarray)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(s, LogLevel.Info);
|
||||||
|
|
||||||
|
foreach (var word in sarray)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(word, LogLevel.Info);
|
||||||
|
}
|
||||||
|
ModCore.CoreMonitor.Log("FUDGE");
|
||||||
|
// Game1.player.tryToMoveInDirection(2, true, 0, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -21,176 +21,67 @@ namespace StarAI
|
||||||
{
|
{
|
||||||
public static StardewModdingAPI.IMonitor CoreMonitor;
|
public static StardewModdingAPI.IMonitor CoreMonitor;
|
||||||
public static StardewModdingAPI.IModHelper CoreHelper;
|
public static StardewModdingAPI.IModHelper CoreHelper;
|
||||||
public static List<Warp> warpGoals= new List<Warp>();
|
public static List<Warp> warpGoals = new List<Warp>();
|
||||||
public static object[] obj = new object[3];
|
public static object[] obj = new object[3];
|
||||||
|
|
||||||
public static Task fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal),obj);
|
public static Task fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
obj[0] = PathFindingLogic.source;
|
obj[0] = PathFindingLogic.source;
|
||||||
obj[1] = PathFindingLogic.currentGoal;
|
obj[1] = PathFindingLogic.currentGoal;
|
||||||
obj[2] = PathFindingLogic.queue;
|
obj[2] = PathFindingLogic.queue;
|
||||||
CoreHelper = helper;
|
CoreHelper = helper;
|
||||||
helper.ConsoleCommands.Add("hello", "Ok?", new Action<string, string[]>(hello));
|
|
||||||
helper.ConsoleCommands.Add("pathfind", "pathy?", new Action<string, string[]>(pathfind));
|
// string[] s = new string[10];
|
||||||
string[] s = new string[10];
|
|
||||||
|
|
||||||
CoreMonitor = this.Monitor;
|
CoreMonitor = this.Monitor;
|
||||||
CoreMonitor.Log("Hello AI WORLD!", LogLevel.Info);
|
CoreMonitor.Log("Hello AI WORLD!", LogLevel.Info);
|
||||||
|
Commands.initializeCommands();
|
||||||
|
PathFindingCore.Utilities.initializeTileExceptionList();
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
|
||||||
StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
|
StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
|
||||||
StardewModdingAPI.Events.GameEvents.SecondUpdateTick += GameEvents_SecondUpdateTick;
|
StardewModdingAPI.Events.GameEvents.SecondUpdateTick += GameEvents_SecondUpdateTick;
|
||||||
|
|
||||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||||
|
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||||
|
|
||||||
StardustCore.ModCore.SerializationManager.acceptedTypes.Add("StarAI.PathFindingCore.TileNode", new StardustCore.Serialization.SerializerDataNode(new StardustCore.Serialization.SerializerDataNode.SerializingFunction(TileNode.Serialize), new StardustCore.Serialization.SerializerDataNode.ParsingFunction(TileNode.ParseIntoInventory), new StardustCore.Serialization.SerializerDataNode.WorldParsingFunction(TileNode.SerializeFromWorld), new StardustCore.Serialization.SerializerDataNode.SerializingToContainerFunction(TileNode.Serialize)));
|
StardustCore.ModCore.SerializationManager.acceptedTypes.Add("StarAI.PathFindingCore.TileNode", new StardustCore.Serialization.SerializerDataNode(new StardustCore.Serialization.SerializerDataNode.SerializingFunction(TileNode.Serialize), new StardustCore.Serialization.SerializerDataNode.ParsingFunction(TileNode.ParseIntoInventory), new StardustCore.Serialization.SerializerDataNode.WorldParsingFunction(TileNode.SerializeFromWorld), new StardustCore.Serialization.SerializerDataNode.SerializingToContainerFunction(TileNode.Serialize)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pathfind(string s, string[] args)
|
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (args.Length < 1)
|
loadExceptionTiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadExceptionTiles()
|
||||||
|
{
|
||||||
|
|
||||||
|
// 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)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("No args passed into path finding function",LogLevel.Error);
|
try
|
||||||
}
|
{
|
||||||
if (args[0] == "addGoal")
|
TileExceptionNode t = TileExceptionNode.parseJson(fileName);
|
||||||
{
|
PathFindingCore.Utilities.tileExceptionList.Add(t);
|
||||||
|
}
|
||||||
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Green));
|
catch(Exception err)
|
||||||
Vector2 pos=new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
|
{
|
||||||
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X,pos.Y), Game1.player.currentLocation);
|
ModCore.CoreMonitor.Log(err.ToString(), LogLevel.Error);
|
||||||
if (ok == false)
|
}
|
||||||
{
|
|
||||||
CoreMonitor.Log("Can't place a goal point here!!!", LogLevel.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
t.placementAction(Game1.currentLocation,(int) pos.X,(int) pos.Y);
|
|
||||||
PathFindingLogic.currentGoal = t;
|
|
||||||
PathFindingLogic.goals.Add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0] == "addStart")
|
|
||||||
{
|
|
||||||
|
|
||||||
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Magenta));
|
|
||||||
Vector2 pos;
|
|
||||||
if (args[1] == "currentPosition")
|
|
||||||
{
|
|
||||||
pos = new Vector2((int)(Game1.player.getTileX() * Game1.tileSize), Game1.player.getTileY() * Game1.tileSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pos = new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X, pos.Y), Game1.player.currentLocation);
|
|
||||||
if (ok == false)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log("Can't place a start point here!!!", LogLevel.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
t.placementAction(Game1.currentLocation, (int)pos.X, (int)pos.Y);
|
|
||||||
PathFindingLogic.source = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0] == "restart")
|
|
||||||
{
|
|
||||||
List<CoreObject> removalList = new List<CoreObject>();
|
|
||||||
foreach(var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
|
|
||||||
{
|
|
||||||
removalList.Add(v);
|
|
||||||
}
|
|
||||||
foreach (var v in removalList)
|
|
||||||
{
|
|
||||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
|
|
||||||
Game1.player.currentLocation.objects.Remove(v.TileLocation);
|
|
||||||
pathfind("pathfind restart", new string[]
|
|
||||||
{
|
|
||||||
"addGoal",
|
|
||||||
PathFindingLogic.currentGoal.tileLocation.X.ToString(),
|
|
||||||
PathFindingLogic.currentGoal.tileLocation.Y.ToString(),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
removalList.Clear();
|
|
||||||
pathfind("pathfind restart", new string[]
|
|
||||||
{
|
|
||||||
"addStart",
|
|
||||||
PathFindingLogic.source.tileLocation.X.ToString(),
|
|
||||||
PathFindingLogic.source.tileLocation.Y.ToString(),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
pathfind("pathfind restart", new string[]
|
|
||||||
{
|
|
||||||
"start"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0] == "start")
|
|
||||||
{
|
|
||||||
if (Game1.player == null) return;
|
|
||||||
if (Game1.hasLoadedGame == false) return;
|
|
||||||
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
|
|
||||||
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
|
|
||||||
if (PathFindingCore.PathFindingLogic.currentGoal == null)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log("NO VALID GOAL SET FOR PATH FINDING!",LogLevel.Error);
|
|
||||||
}
|
|
||||||
if (PathFindingCore.PathFindingLogic.source == null)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log("NO VALID START SET FOR PATH FINDING!", LogLevel.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fun.Status == TaskStatus.Running)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log("TASK IS RUNNING CAN'T PATHFIND AT THE MOMENT", LogLevel.Alert);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fun.Status == TaskStatus.RanToCompletion)
|
|
||||||
{
|
|
||||||
|
|
||||||
CoreMonitor.Log("TASK IS Finished PATHFINDING", LogLevel.Warn);
|
|
||||||
obj[0] = PathFindingLogic.source;
|
|
||||||
obj[1] = PathFindingLogic.currentGoal;
|
|
||||||
obj[2] = PathFindingLogic.queue;
|
|
||||||
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fun.Status == TaskStatus.Created)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
|
|
||||||
obj[0] = PathFindingLogic.source;
|
|
||||||
obj[1] = PathFindingLogic.currentGoal;
|
|
||||||
obj[2] = PathFindingLogic.queue;
|
|
||||||
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
|
|
||||||
|
|
||||||
fun.Start();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CoreMonitor.Log(fun.Status.ToString());
|
|
||||||
if (fun.Status == TaskStatus.Faulted)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log(fun.Exception.ToString());
|
|
||||||
CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
|
|
||||||
obj[0] = PathFindingLogic.source;
|
|
||||||
obj[1] = PathFindingLogic.currentGoal;
|
|
||||||
obj[2] = PathFindingLogic.queue;
|
|
||||||
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||||
{
|
{
|
||||||
|
//J key for shop
|
||||||
|
#region
|
||||||
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.J)
|
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.J)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("OK THE J KEY WAS PRESSED!");
|
CoreMonitor.Log("OK THE J KEY WAS PRESSED!");
|
||||||
List<Item> shoppingList = new List<Item>();
|
List<Item> shoppingList = new List<Item>();
|
||||||
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Aqua));
|
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Aqua));
|
||||||
if (t == null)
|
if (t == null)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("WTF?????");
|
CoreMonitor.Log("WTF?????");
|
||||||
|
@ -203,17 +94,21 @@ namespace StarAI
|
||||||
}
|
}
|
||||||
shoppingList.Add((Item)t);
|
shoppingList.Add((Item)t);
|
||||||
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shoppingList);
|
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shoppingList);
|
||||||
}catch(Exception err)
|
}
|
||||||
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log(Convert.ToString(err));
|
CoreMonitor.Log(Convert.ToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//K key for placing a tile.
|
||||||
|
#region
|
||||||
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
|
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("OK THE K KEY WAS PRESSED!");
|
CoreMonitor.Log("OK THE K KEY WAS PRESSED!");
|
||||||
|
|
||||||
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.randomColor());
|
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.randomColor());
|
||||||
if (t == null)
|
if (t == null)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("WTF?????");
|
CoreMonitor.Log("WTF?????");
|
||||||
|
@ -224,184 +119,72 @@ namespace StarAI
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CoreMonitor.Log(new Vector2(Game1.player.getTileX()*Game1.tileSize,Game1.player.getTileY()*Game1.tileSize).ToString());
|
CoreMonitor.Log(new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize).ToString());
|
||||||
|
|
||||||
int xPos = (int)(Game1.player.getTileX()) * Game1.tileSize;
|
int xPos = (int)(Game1.player.getTileX()) * Game1.tileSize;
|
||||||
int yPos = (int)(Game1.player.getTileY()) * Game1.tileSize;
|
int yPos = (int)(Game1.player.getTileY()) * Game1.tileSize;
|
||||||
Rectangle r = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
|
Rectangle r = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
|
||||||
Vector2 pos = new Vector2(r.X, r.Y);
|
Vector2 pos = new Vector2(r.X, r.Y);
|
||||||
bool ok = t.checkIfICanPlaceHere(t,pos,Game1.player.currentLocation);
|
bool ok = t.checkIfICanPlaceHere(t, pos, Game1.player.currentLocation);
|
||||||
if (ok == false) return;
|
if (ok == false) return;
|
||||||
t.placementAction(Game1.currentLocation, Game1.player.getTileX()*Game1.tileSize, Game1.player.getTileY()*Game1.tileSize);
|
t.placementAction(Game1.currentLocation, Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
|
||||||
t.setAdjacentTiles(true);
|
//t.setAdjacentTiles(true);
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log(Convert.ToString(err));
|
CoreMonitor.Log(Convert.ToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endregion
|
||||||
|
|
||||||
public static Vector2 parseCenterFromTile(int tileX, int tileY)
|
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.O)
|
||||||
{
|
|
||||||
int x = (tileX * Game1.tileSize) + Game1.tileSize / 2;
|
|
||||||
int y = (tileY * Game1.tileSize) + Game1.tileSize / 2;
|
|
||||||
return new Vector2(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void calculateMovement()
|
|
||||||
{
|
|
||||||
bool xTargetReached = false;
|
|
||||||
bool yTargetReached = false;
|
|
||||||
while (warpGoals.Count > 0)
|
|
||||||
{
|
{
|
||||||
Warp w = warpGoals[0];
|
|
||||||
if (Game1.player.getTileX() == w.X && Game1.player.getTileY() == w.Y)
|
foreach (var v in Game1.player.currentLocation.map.TileSheets)
|
||||||
{
|
{
|
||||||
warpGoals.Remove(w);
|
foreach (var q in Game1.player.currentLocation.map.Layers)
|
||||||
CoreMonitor.Log("LOOOP", LogLevel.Debug);
|
|
||||||
// return;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vector2 center = parseCenterFromTile(w.X, w.Y);
|
|
||||||
while (Game1.player.position.X > center.X && xTargetReached==false)
|
|
||||||
{
|
{
|
||||||
if (isWithinRange(Game1.player.position.X, center.X, 12) == true)
|
string[] s = q.ToString().Split(':');
|
||||||
|
string layer = s[1].Trim();
|
||||||
|
if (Game1.player.currentLocation.map.GetLayer(layer) == null)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
|
|
||||||
xTargetReached = true;
|
ModCore.CoreMonitor.Log("SHITTTTTT: " + layer, LogLevel.Error);
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
|
||||||
//break;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
//CoreMonitor.Log(Convert.ToString(Game1.player.position.X), LogLevel.Debug);
|
int tileIndex = Game1.player.currentLocation.getTileIndexAt((int)Game1.player.getTileX() / Game1.tileSize, (int)Game1.player.getTileY() / Game1.tileSize, layer);
|
||||||
//CoreMonitor.Log(Convert.ToString(center.X), LogLevel.Warn);
|
if (tileIndex == -1) continue;
|
||||||
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
|
//ModCore.CoreMonitor.Log("Position: " + (Game1.player.getTileLocation() / Game1.tileSize).ToString(), LogLevel.Warn);
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
//ModCore.CoreMonitor.Log("Layer: " + layer, LogLevel.Warn);
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
//ModCore.CoreMonitor.Log("Index: " + tileIndex.ToString(), LogLevel.Warn);
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
//ModCore.CoreMonitor.Log("Image Source: " + v.ImageSource, LogLevel.Warn);
|
||||||
}
|
|
||||||
while (Game1.player.position.X < center.X && xTargetReached==false)
|
if (layer == "Buildings")
|
||||||
{
|
|
||||||
if (isWithinRange(Game1.player.position.X, center.X, 6) == true)
|
|
||||||
{
|
{
|
||||||
xTargetReached = true;
|
TileExceptionNode tileException = new TileExceptionNode(v.ImageSource, tileIndex);
|
||||||
ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
|
foreach(var tile in PathFindingCore.Utilities.tileExceptionList)
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
{
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
if (tile.imageSource == tileException.imageSource && tile.index == tileException.index)
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
{
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
ModCore.CoreMonitor.Log("Tile exception already initialized!");
|
||||||
//break;
|
return; //tile is already initialized.
|
||||||
continue;
|
}
|
||||||
|
}
|
||||||
|
PathFindingCore.Utilities.tileExceptionList.Add(tileException);
|
||||||
|
tileException.serializeJson(Path.Combine(ModCore.CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
|
||||||
|
//StardustCore.ModCore.SerializationManager.
|
||||||
}
|
}
|
||||||
//CoreMonitor.Log(Convert.ToString(Game1.player.position.X), LogLevel.Debug);
|
|
||||||
//CoreMonitor.Log(Convert.ToString(center.X), LogLevel.Warn);
|
|
||||||
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
|
||||||
}
|
}
|
||||||
ModCore.CoreMonitor.Log("Run???");
|
|
||||||
while (Game1.player.position.Y < center.Y && yTargetReached==false)
|
|
||||||
{
|
|
||||||
ModCore.CoreMonitor.Log("banana");
|
|
||||||
if (isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
|
|
||||||
{
|
|
||||||
yTargetReached = true;
|
|
||||||
ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
|
||||||
//break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//CoreMonitor.Log(Convert.ToString(Game1.player.position.X), LogLevel.Debug);
|
|
||||||
//CoreMonitor.Log(Convert.ToString(center.X), LogLevel.Warn);
|
|
||||||
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.DOWN);
|
|
||||||
}
|
|
||||||
ModCore.CoreMonitor.Log("Or no???");
|
|
||||||
while (Game1.player.position.Y > center.Y&& yTargetReached==false)
|
|
||||||
{
|
|
||||||
ModCore.CoreMonitor.Log("potato");
|
|
||||||
if (isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
|
|
||||||
{
|
|
||||||
yTargetReached = true;
|
|
||||||
ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
|
||||||
//break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//CoreMonitor.Log(Convert.ToString(Game1.player.position.X), LogLevel.Debug);
|
|
||||||
//CoreMonitor.Log(Convert.ToString(center.X), LogLevel.Warn);
|
|
||||||
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
//InputSimulator.SimulateKeyUp(VirtualKeyCode.UP);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
while (Game1.player.getTileX() < w.X)
|
|
||||||
{
|
|
||||||
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game1.player.getTileX() == w.X)
|
|
||||||
{
|
|
||||||
warpGoals.Remove(w);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (xTargetReached == true && yTargetReached == true)
|
|
||||||
{
|
|
||||||
warpGoals.Remove(w);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
|
||||||
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
|
||||||
//return;
|
|
||||||
CoreMonitor.Log("Reached goal!", LogLevel.Error);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CoreMonitor.Log("UNCAUGHT EXCEPTION", LogLevel.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to calculate center of a tile with varience.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <param name="goal"></param>
|
|
||||||
/// <param name="tolerance"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool isWithinRange(float position,float goal, int tolerance)
|
|
||||||
{
|
|
||||||
if (position >= goal - tolerance && position <= goal + tolerance) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void GameEvents_SecondUpdateTick(object sender, EventArgs e)
|
private void GameEvents_SecondUpdateTick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Game1.player == null) return;
|
if (Game1.player == null) return;
|
||||||
if (Game1.hasLoadedGame == false) return;
|
if (Game1.hasLoadedGame == false) return;
|
||||||
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
|
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
|
||||||
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
|
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
|
||||||
if (warpGoals.Count == 0) return;
|
if (warpGoals.Count == 0) return;
|
||||||
if (fun.Status == TaskStatus.Running)
|
if (fun.Status == TaskStatus.Running)
|
||||||
|
@ -413,7 +196,7 @@ namespace StarAI
|
||||||
{
|
{
|
||||||
|
|
||||||
//CoreMonitor.Log("TASK IS Finished", LogLevel.Warn);
|
//CoreMonitor.Log("TASK IS Finished", LogLevel.Warn);
|
||||||
fun=new Task(new Action(calculateMovement));
|
fun = new Task(new Action(PathFindingCore.Utilities.calculateMovement));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,45 +206,25 @@ namespace StarAI
|
||||||
fun.Start();
|
fun.Start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e)
|
private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e)
|
||||||
{
|
{
|
||||||
CoreMonitor.Log("LOCATION CHANGED!");
|
CoreMonitor.Log("LOCATION CHANGED!");
|
||||||
CoreMonitor.Log(Game1.player.currentLocation.name);
|
CoreMonitor.Log(Game1.player.currentLocation.name);
|
||||||
foreach(var v in Game1.player.currentLocation.warps)
|
foreach (var v in Game1.player.currentLocation.warps)
|
||||||
{
|
{
|
||||||
string s ="X: " +Convert.ToString(v.X) + " Y: " + Convert.ToString(v.Y) + " TargetX: " + Convert.ToString(v.TargetX) + " TargetY: " + Convert.ToString(v.TargetY) + " TargetLocationName: " + Convert.ToString(v.TargetName);
|
string s = "X: " + Convert.ToString(v.X) + " Y: " + Convert.ToString(v.Y) + " TargetX: " + Convert.ToString(v.TargetX) + " TargetY: " + Convert.ToString(v.TargetY) + " TargetLocationName: " + Convert.ToString(v.TargetName);
|
||||||
CoreMonitor.Log(s);
|
CoreMonitor.Log(s);
|
||||||
//warpGoals.Add(v); Disabled for now
|
//warpGoals.Add(v); Disabled for now
|
||||||
}
|
}
|
||||||
//GameLocation loc=Game1.getLocationFromName("location name")
|
//GameLocation loc=Game1.getLocationFromName("location name")
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="s">This is the command's name</param>
|
|
||||||
/// <param name="sarray">This is the parameters that follow.</param>
|
|
||||||
public void hello(string s,string[] sarray)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log(s, LogLevel.Info);
|
|
||||||
|
|
||||||
foreach(var word in sarray)
|
|
||||||
{
|
|
||||||
CoreMonitor.Log(word, LogLevel.Info);
|
|
||||||
}
|
|
||||||
CoreMonitor.Log("FUDGE");
|
|
||||||
// Game1.player.tryToMoveInDirection(2, true, 0, false);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace StarAI.PathFindingCore
|
||||||
public static List<TileNode> queue=new List<TileNode>();
|
public static List<TileNode> queue=new List<TileNode>();
|
||||||
public static int totalPathCost;
|
public static int totalPathCost;
|
||||||
public static TileNode currentGoal;
|
public static TileNode currentGoal;
|
||||||
|
public static int delay;
|
||||||
|
|
||||||
public static List<TileNode> path=new List<TileNode>();
|
public static List<TileNode> path=new List<TileNode>();
|
||||||
public static int index = 0;
|
public static int index = 0;
|
||||||
|
@ -87,7 +88,7 @@ namespace StarAI.PathFindingCore
|
||||||
if (node.parent == null)
|
if (node.parent == null)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("I DONT UNDERSTAND!");
|
ModCore.CoreMonitor.Log("I DONT UNDERSTAND!");
|
||||||
System.Threading.Thread.Sleep(50);
|
System.Threading.Thread.Sleep(delay);
|
||||||
}
|
}
|
||||||
//ModCore.CoreMonitor.Log("ok checking adj:" + node.tileLocation.ToString());
|
//ModCore.CoreMonitor.Log("ok checking adj:" + node.tileLocation.ToString());
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ namespace StarAI.PathFindingCore
|
||||||
}
|
}
|
||||||
currentNode.parent.animationManager.enableAnimation();
|
currentNode.parent.animationManager.enableAnimation();
|
||||||
currentNode = currentNode.parent;
|
currentNode = currentNode.parent;
|
||||||
System.Threading.Thread.Sleep(200);
|
System.Threading.Thread.Sleep(delay);
|
||||||
if (currentNode.parent == null)
|
if (currentNode.parent == null)
|
||||||
{
|
{
|
||||||
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
|
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using StarAI.PathFindingCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StarAI.PathFindingCore
|
||||||
|
{
|
||||||
|
public class TileExceptionNode
|
||||||
|
{
|
||||||
|
public string imageSource;
|
||||||
|
public int index;
|
||||||
|
|
||||||
|
|
||||||
|
public TileExceptionNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileExceptionNode(string ImageSource, int TileIndex)
|
||||||
|
{
|
||||||
|
imageSource = ImageSource;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,39 +74,38 @@ namespace StarAI.PathFindingCore
|
||||||
cry = true;
|
cry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y))
|
if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y))
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("F!: " + t.thisLocation.name, LogLevel.Warn);
|
ModCore.CoreMonitor.Log("Object at this tile position!: " + t.thisLocation.name, LogLevel.Warn);
|
||||||
if (cry == true) this.thisLocation = null;
|
if (cry == true) this.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (t.thisLocation.isTileOccupied(pos / Game1.tileSize))
|
if (t.thisLocation.isTileOccupied(pos / Game1.tileSize))
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("K!!!!: " + t.thisLocation.name, LogLevel.Error);
|
ModCore.CoreMonitor.Log("Tile occupied!: " + t.thisLocation.name, LogLevel.Error);
|
||||||
if (cry == true) this.thisLocation = null;
|
if (cry == true) this.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.thisLocation.isTilePlaceable(pos) == false)
|
|
||||||
{
|
|
||||||
ModCore.CoreMonitor.Log("C!!!!: " + t.thisLocation.name, LogLevel.Error);
|
|
||||||
if (cry == true) this.thisLocation = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("J!!!!: " + t.thisLocation.name, LogLevel.Error);
|
ModCore.CoreMonitor.Log("Tile Not placeable at location. " + t.thisLocation.name, LogLevel.Error);
|
||||||
if (cry == true) this.thisLocation = null;
|
if (cry == true) this.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (t.thisLocation.isTilePassable(new xTile.Dimensions.Location((int)(pos.X/Game1.tileSize), (int)(pos.Y/Game1.tileSize)), Game1.viewport)==false)
|
if (t.thisLocation.isTilePassable(new xTile.Dimensions.Location((int)(pos.X/Game1.tileSize), (int)(pos.Y/Game1.tileSize)), Game1.viewport)==false)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("Y!!!!: " + t.thisLocation.name, LogLevel.Error);
|
ModCore.CoreMonitor.Log("Tile not passable check 2?????!!!!: " + t.thisLocation.name, LogLevel.Error);
|
||||||
if (cry == true) this.thisLocation = null;
|
if (cry == true) this.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cry == true) this.thisLocation = null;
|
if (cry == true) this.thisLocation = null;
|
||||||
|
@ -120,8 +119,8 @@ namespace StarAI.PathFindingCore
|
||||||
if (f == false) return;
|
if (f == false) return;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("Adding a child!");
|
// ModCore.CoreMonitor.Log("Adding a child!");
|
||||||
System.Threading.Thread.Sleep(50);
|
System.Threading.Thread.Sleep(PathFindingCore.PathFindingLogic.delay);
|
||||||
TileNode child = new TileNode(1, Vector2.Zero, t.texturePath,t.dataPath,StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Cyan));
|
TileNode child = new TileNode(1, Vector2.Zero, t.texturePath,t.dataPath,StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Cyan));
|
||||||
child.seenState = (int)stateEnum.NotVisited;
|
child.seenState = (int)stateEnum.NotVisited;
|
||||||
child.parent = t;
|
child.parent = t;
|
||||||
|
@ -164,6 +163,8 @@ namespace StarAI.PathFindingCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Unused????
|
||||||
public static void setAdjacentTiles(Vector2 position, GameLocation loc)
|
public static void setAdjacentTiles(Vector2 position, GameLocation loc)
|
||||||
{
|
{
|
||||||
Vector2 startPosition = position;
|
Vector2 startPosition = position;
|
||||||
|
@ -185,28 +186,28 @@ namespace StarAI.PathFindingCore
|
||||||
ModCore.CoreMonitor.Log("THIS IS MY LOCATION!!!: " +loc.name);
|
ModCore.CoreMonitor.Log("THIS IS MY LOCATION!!!: " +loc.name);
|
||||||
if (loc.isObjectAt((int)pos.X, (int)pos.Y))
|
if (loc.isObjectAt((int)pos.X, (int)pos.Y))
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("F!: " + loc.name, LogLevel.Warn);
|
// ModCore.CoreMonitor.Log("F!: " + loc.name, LogLevel.Warn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (loc.isTileOccupied(pos / Game1.tileSize))
|
if (loc.isTileOccupied(pos / Game1.tileSize))
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("K!!!!: " + loc.name, LogLevel.Error);
|
//ModCore.CoreMonitor.Log("K!!!!: " + loc.name, LogLevel.Error);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc.isTilePlaceable(pos) == false)
|
if (loc.isTilePlaceable(pos) == false)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("C!!!!: " + loc.name, LogLevel.Error);
|
//ModCore.CoreMonitor.Log("C!!!!: " + loc.name, LogLevel.Error);
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
if (loc.isTilePlaceable(pos / Game1.tileSize) == false)
|
if (loc.isTilePlaceable(pos / Game1.tileSize) == false)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("J!!!!: " + loc.name, LogLevel.Error);
|
// ModCore.CoreMonitor.Log("J!!!!: " + loc.name, LogLevel.Error);
|
||||||
continue;
|
// continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (loc.isTilePassable(new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize), Game1.viewport) == true && loc.isTileLocationOpen(new xTile.Dimensions.Location((int)(pos.X), (int)(pos.Y))) == true && loc.isObjectAt((int)(pos.X), (int)(pos.Y)) == false) ; //&& Game1.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)startPosition.X+x,(int)startPosition.Y+y)))
|
if (loc.isTilePassable(new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize), Game1.viewport) == true && loc.isTileLocationOpen(new xTile.Dimensions.Location((int)(pos.X), (int)(pos.Y)))) ; //&& Game1.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)startPosition.X+x,(int)startPosition.Y+y)))
|
||||||
{
|
{
|
||||||
//TileNode child = new TileNode(1, Vector2.Zero, this.texturePath, this.drawColor);
|
//TileNode child = new TileNode(1, Vector2.Zero, this.texturePath, this.drawColor);
|
||||||
//child.placementAction(Game1.currentLocation, xPos, yPos);
|
//child.placementAction(Game1.currentLocation, xPos, yPos);
|
||||||
|
@ -462,7 +463,7 @@ namespace StarAI.PathFindingCore
|
||||||
{
|
{
|
||||||
// Game1.showRedMessage("Why2?");
|
// Game1.showRedMessage("Why2?");
|
||||||
// this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero);
|
// this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero);
|
||||||
Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
||||||
this.flaggedForPickUp = true;
|
this.flaggedForPickUp = true;
|
||||||
this.thisLocation = null;
|
this.thisLocation = null;
|
||||||
this.locationsName = "";
|
this.locationsName = "";
|
||||||
|
@ -480,7 +481,7 @@ namespace StarAI.PathFindingCore
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero);
|
// this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero);
|
||||||
Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
||||||
// this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
// this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
||||||
// this.heldObject = null;
|
// this.heldObject = null;
|
||||||
Game1.playSound("coin");
|
Game1.playSound("coin");
|
||||||
|
@ -496,7 +497,7 @@ namespace StarAI.PathFindingCore
|
||||||
// Game1.showRedMessage("Why3?");
|
// Game1.showRedMessage("Why3?");
|
||||||
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
||||||
this.heldObject = null;
|
this.heldObject = null;
|
||||||
Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this,StardustCore.ModCore.SerializationManager);
|
||||||
Game1.playSound("coin");
|
Game1.playSound("coin");
|
||||||
this.thisLocation = null;
|
this.thisLocation = null;
|
||||||
this.locationsName = "";
|
this.locationsName = "";
|
||||||
|
@ -751,7 +752,7 @@ namespace StarAI.PathFindingCore
|
||||||
this.updateDrawPosition();
|
this.updateDrawPosition();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool f = Utilities.placementAction(this, location, x, y, StardustCore.ModCore.SerializationManager, who);
|
bool f = StardustCore.Utilities.placementAction(this, location, x, y, StardustCore.ModCore.SerializationManager, who);
|
||||||
this.thisLocation = Game1.player.currentLocation;
|
this.thisLocation = Game1.player.currentLocation;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -970,11 +971,11 @@ namespace StarAI.PathFindingCore
|
||||||
d.rotations = obj.rotations;
|
d.rotations = obj.rotations;
|
||||||
d.currentRotation = obj.currentRotation;
|
d.currentRotation = obj.currentRotation;
|
||||||
string s1 = Convert.ToString(obj.sourceRect);
|
string s1 = Convert.ToString(obj.sourceRect);
|
||||||
d.sourceRect = Utilities.parseRectFromJson(s1);
|
d.sourceRect = StardustCore.Utilities.parseRectFromJson(s1);
|
||||||
string s2 = Convert.ToString(obj.defaultSourceRect);
|
string s2 = Convert.ToString(obj.defaultSourceRect);
|
||||||
d.defaultSourceRect = Utilities.parseRectFromJson(s2);
|
d.defaultSourceRect = StardustCore.Utilities.parseRectFromJson(s2);
|
||||||
string s3 = Convert.ToString(obj.defaultBoundingBox);
|
string s3 = Convert.ToString(obj.defaultBoundingBox);
|
||||||
d.defaultBoundingBox = Utilities.parseRectFromJson(s3);
|
d.defaultBoundingBox = StardustCore.Utilities.parseRectFromJson(s3);
|
||||||
d.description = obj.description;
|
d.description = obj.description;
|
||||||
d.flipped = obj.flipped;
|
d.flipped = obj.flipped;
|
||||||
d.flaggedForPickUp = obj.flaggedForPickUp;
|
d.flaggedForPickUp = obj.flaggedForPickUp;
|
||||||
|
@ -1004,7 +1005,7 @@ namespace StarAI.PathFindingCore
|
||||||
d.heldObject = obj.heldObject;
|
d.heldObject = obj.heldObject;
|
||||||
d.minutesUntilReady = obj.minutesUntilReady;
|
d.minutesUntilReady = obj.minutesUntilReady;
|
||||||
string s4 = Convert.ToString(obj.boundingBox);
|
string s4 = Convert.ToString(obj.boundingBox);
|
||||||
d.boundingBox = Utilities.parseRectFromJson(s4);
|
d.boundingBox = StardustCore.Utilities.parseRectFromJson(s4);
|
||||||
d.scale = obj.scale;
|
d.scale = obj.scale;
|
||||||
d.lightSource = obj.lightSource;
|
d.lightSource = obj.lightSource;
|
||||||
d.shakeTimer = obj.shakeTimer;
|
d.shakeTimer = obj.shakeTimer;
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using StardewModdingAPI;
|
||||||
|
using StardewValley;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WindowsInput;
|
||||||
|
|
||||||
|
namespace StarAI.PathFindingCore
|
||||||
|
{
|
||||||
|
public class Utilities
|
||||||
|
{
|
||||||
|
|
||||||
|
public static List<TileExceptionNode> tileExceptionList = new List<TileExceptionNode>();
|
||||||
|
public static string folderForExceptionTiles="ExceptionTilesData";
|
||||||
|
|
||||||
|
public static Vector2 parseCenterFromTile(int tileX, int tileY)
|
||||||
|
{
|
||||||
|
int x = (tileX * Game1.tileSize) + Game1.tileSize / 2;
|
||||||
|
int y = (tileY * Game1.tileSize) + Game1.tileSize / 2;
|
||||||
|
return new Vector2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initializeTileExceptionList()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void calculateMovement()
|
||||||
|
{
|
||||||
|
bool xTargetReached = false;
|
||||||
|
bool yTargetReached = false;
|
||||||
|
while (ModCore.warpGoals.Count > 0)
|
||||||
|
{
|
||||||
|
Warp w = ModCore.warpGoals[0];
|
||||||
|
if (Game1.player.getTileX() == w.X && Game1.player.getTileY() == w.Y)
|
||||||
|
{
|
||||||
|
ModCore.warpGoals.Remove(w);
|
||||||
|
ModCore.CoreMonitor.Log("LOOOP", LogLevel.Debug);
|
||||||
|
// return;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector2 center = parseCenterFromTile(w.X, w.Y);
|
||||||
|
while (Game1.player.position.X > center.X && xTargetReached == false)
|
||||||
|
{
|
||||||
|
if (isWithinRange(Game1.player.position.X, center.X, 12) == true)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
|
||||||
|
xTargetReached = true;
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
||||||
|
//break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_A);
|
||||||
|
}
|
||||||
|
while (Game1.player.position.X < center.X && xTargetReached == false)
|
||||||
|
{
|
||||||
|
if (isWithinRange(Game1.player.position.X, center.X, 6) == true)
|
||||||
|
{
|
||||||
|
xTargetReached = true;
|
||||||
|
ModCore.CoreMonitor.Log("XXXXXXXtargetReached");
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_D);
|
||||||
|
}
|
||||||
|
ModCore.CoreMonitor.Log("Run???");
|
||||||
|
while (Game1.player.position.Y < center.Y && yTargetReached == false)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("banana");
|
||||||
|
if (isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
|
||||||
|
{
|
||||||
|
yTargetReached = true;
|
||||||
|
ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_S);
|
||||||
|
}
|
||||||
|
ModCore.CoreMonitor.Log("Or no???");
|
||||||
|
while (Game1.player.position.Y > center.Y && yTargetReached == false)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("potato");
|
||||||
|
if (isWithinRange(Game1.player.position.Y, center.Y, 6) == true)
|
||||||
|
{
|
||||||
|
yTargetReached = true;
|
||||||
|
ModCore.CoreMonitor.Log("YYYYYYYYYtargetReached");
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_W);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (xTargetReached == true && yTargetReached == true)
|
||||||
|
{
|
||||||
|
ModCore.warpGoals.Remove(w);
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_A);
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_D);
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_W);
|
||||||
|
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_S);
|
||||||
|
//return;
|
||||||
|
ModCore.CoreMonitor.Log("Reached goal!", LogLevel.Error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ModCore.CoreMonitor.Log("UNCAUGHT EXCEPTION", LogLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to calculate center of a tile with varience.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="goal"></param>
|
||||||
|
/// <param name="tolerance"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool isWithinRange(float position, float goal, int tolerance)
|
||||||
|
{
|
||||||
|
if (position >= goal - tolerance && position <= goal + tolerance) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,9 +56,12 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Commands.cs" />
|
||||||
<Compile Include="ModCore.cs" />
|
<Compile Include="ModCore.cs" />
|
||||||
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
||||||
|
<Compile Include="PathFindingCore\TileExceptionNode.cs" />
|
||||||
<Compile Include="PathFindingCore\TileNodeObject.cs" />
|
<Compile Include="PathFindingCore\TileNodeObject.cs" />
|
||||||
|
<Compile Include="PathFindingCore\Utilities.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue