Fixed a really dumb stack overflow error on pathfinding across the world. THANK YOU.
This commit is contained in:
parent
31ddb0e7f1
commit
ea2e7c134f
|
@ -0,0 +1,36 @@
|
||||||
|
using StardewValley;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StarAI.CheatCore
|
||||||
|
{
|
||||||
|
class DoorsToWarps
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void makeAllDoorsWarps()
|
||||||
|
{
|
||||||
|
foreach(var v in Game1.locations)
|
||||||
|
{
|
||||||
|
foreach(var door in v.doors)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (warp.TargetName == v.name && warp.TargetX==door.Key.X&& warp.TargetY==door.Key.Y+1)
|
||||||
|
{
|
||||||
|
Warp w = new Warp(door.Key.X, door.Key.Y, door.Value, warp.X, warp.Y - 1,false);
|
||||||
|
v.warps.Add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,7 +42,7 @@ namespace StarAI
|
||||||
PathFindingCore.Utilities.initializeTileExceptionList();
|
PathFindingCore.Utilities.initializeTileExceptionList();
|
||||||
ExecutionCore.TaskMetaDataHeuristics.initializeToolCostDictionary();
|
ExecutionCore.TaskMetaDataHeuristics.initializeToolCostDictionary();
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
|
//StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
|
||||||
|
|
||||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||||
|
@ -50,6 +50,7 @@ namespace StarAI
|
||||||
StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
|
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)));
|
StardustCore.ModCore.SerializationManager.acceptedTypes.Add("StarAI.PathFindingCore.TileNode", new StardustCore.Serialization.SerializerDataNode(new StardustCore.Serialization.SerializerDataNode.SerializingFunction(StarAI.PathFindingCore.TileNode.Serialize), new StardustCore.Serialization.SerializerDataNode.ParsingFunction(StarAI.PathFindingCore.TileNode.ParseIntoInventory), new StardustCore.Serialization.SerializerDataNode.WorldParsingFunction(StarAI.PathFindingCore.TileNode.SerializeFromWorld), new StardustCore.Serialization.SerializerDataNode.SerializingToContainerFunction(StarAI.PathFindingCore.TileNode.Serialize)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
||||||
|
@ -81,6 +82,7 @@ namespace StarAI
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
loadExceptionTiles();
|
loadExceptionTiles();
|
||||||
|
CheatCore.DoorsToWarps.makeAllDoorsWarps();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadExceptionTiles()
|
public void loadExceptionTiles()
|
||||||
|
@ -138,11 +140,8 @@ namespace StarAI
|
||||||
//K key for placing a tile.
|
//K key for placing a tile.
|
||||||
#region
|
#region
|
||||||
|
|
||||||
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.H)
|
|
||||||
{
|
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
|
||||||
CoreMonitor.Log(Game1.player.position.ToString());
|
|
||||||
}
|
|
||||||
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!");
|
||||||
|
|
||||||
|
@ -198,12 +197,12 @@ namespace StarAI
|
||||||
|
|
||||||
ModCore.CoreMonitor.Log("SHITTTTTT: " + layer, LogLevel.Error);
|
ModCore.CoreMonitor.Log("SHITTTTTT: " + layer, LogLevel.Error);
|
||||||
}
|
}
|
||||||
int tileIndex = Game1.player.currentLocation.getTileIndexAt((int)Game1.player.getTileX() / Game1.tileSize, (int)Game1.player.getTileY() / Game1.tileSize, layer);
|
int tileIndex = Game1.player.currentLocation.getTileIndexAt((int)Game1.player.getTileX(), (int)Game1.player.getTileY(), layer);
|
||||||
if (tileIndex == -1) continue;
|
if (tileIndex == -1) continue;
|
||||||
//ModCore.CoreMonitor.Log("Position: " + (Game1.player.getTileLocation() / Game1.tileSize).ToString(), LogLevel.Warn);
|
ModCore.CoreMonitor.Log("Position: " + (Game1.player.getTileLocation()).ToString(), LogLevel.Warn);
|
||||||
//ModCore.CoreMonitor.Log("Layer: " + layer, LogLevel.Warn);
|
ModCore.CoreMonitor.Log("Layer: " + layer, LogLevel.Warn);
|
||||||
//ModCore.CoreMonitor.Log("Index: " + tileIndex.ToString(), LogLevel.Warn);
|
ModCore.CoreMonitor.Log("Index: " + tileIndex.ToString(), LogLevel.Warn);
|
||||||
//ModCore.CoreMonitor.Log("Image Source: " + v.ImageSource, LogLevel.Warn);
|
ModCore.CoreMonitor.Log("Image Source: " + v.ImageSource, LogLevel.Warn);
|
||||||
|
|
||||||
if (layer == "Buildings")
|
if (layer == "Buildings")
|
||||||
{
|
{
|
||||||
|
@ -216,8 +215,8 @@ namespace StarAI
|
||||||
return; //tile is already initialized.
|
return; //tile is already initialized.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PathFindingCore.Utilities.ignoreCheckTiles.Add(tileException);
|
//PathFindingCore.Utilities.ignoreCheckTiles.Add(tileException);
|
||||||
tileException.serializeJson(Path.Combine(ModCore.CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
|
// tileException.serializeJson(Path.Combine(ModCore.CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
|
||||||
//StardustCore.ModCore.SerializationManager.
|
//StardustCore.ModCore.SerializationManager.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
public Warp warp;
|
public Warp warp;
|
||||||
public List<WarpGoal> childrenWarps;
|
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)
|
public WarpGoal(WarpGoal Parent, Warp CurrentWarp)
|
||||||
{
|
{
|
||||||
this.parentWarpGoal = Parent;
|
this.parentWarpGoal = Parent;
|
||||||
|
@ -26,6 +30,7 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
|
|
||||||
public static void getWarpChain(GameLocation location, string mapName)
|
public static void getWarpChain(GameLocation location, string mapName)
|
||||||
{
|
{
|
||||||
|
List<GameLocation> blerp = new List<GameLocation>();
|
||||||
GameLocation check = Game1.getLocationFromName(mapName);
|
GameLocation check = Game1.getLocationFromName(mapName);
|
||||||
if (check == null)
|
if (check == null)
|
||||||
{
|
{
|
||||||
|
@ -43,11 +48,16 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
TransitionLogic.transitionToAdjacentMap(location, mapName);
|
TransitionLogic.transitionToAdjacentMap(location, mapName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
exploredLocations.Add(Warp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//keep chaining children
|
//keep chaining children
|
||||||
|
//exploredLocations.Add(location);
|
||||||
|
checkedLocations.Add(location);
|
||||||
|
List<WarpGoal> warpChain = okBye(startinggoals, mapName, location,checkedLocations);
|
||||||
|
|
||||||
List<WarpGoal> warpChain = okBye(startinggoals, mapName);
|
checkedLocations.Clear();
|
||||||
|
exploredLocations.Clear();
|
||||||
if (warpChain == null)
|
if (warpChain == null)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
||||||
|
@ -177,6 +187,9 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
public static List<List<TileNode>> getWarpChainReturn(GameLocation location,string mapName)
|
public static List<List<TileNode>> getWarpChainReturn(GameLocation location,string mapName)
|
||||||
{
|
{
|
||||||
GameLocation check = Game1.getLocationFromName(mapName);
|
GameLocation check = Game1.getLocationFromName(mapName);
|
||||||
|
|
||||||
|
List<GameLocation> blerp = new List<GameLocation>();
|
||||||
|
if (check.isStructure) mapName = check.uniqueName;
|
||||||
if (check == null)
|
if (check == null)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("INVALID LOCATION");
|
ModCore.CoreMonitor.Log("INVALID LOCATION");
|
||||||
|
@ -188,6 +201,7 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
{
|
{
|
||||||
WarpGoal child = new WarpGoal(null, Warp);
|
WarpGoal child = new WarpGoal(null, Warp);
|
||||||
startinggoals.Add(child);
|
startinggoals.Add(child);
|
||||||
|
exploredLocations.Add(Warp);
|
||||||
/*
|
/*
|
||||||
if (Warp.TargetName == mapName)
|
if (Warp.TargetName == mapName)
|
||||||
{
|
{
|
||||||
|
@ -200,8 +214,11 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
}
|
}
|
||||||
|
|
||||||
//keep chaining children
|
//keep chaining children
|
||||||
|
// exploredLocations.Add(location);
|
||||||
List<WarpGoal> warpChain= okBye(startinggoals, mapName);
|
checkedLocations.Add(location);
|
||||||
|
List<WarpGoal> warpChain= okBye(startinggoals, mapName,location,checkedLocations);
|
||||||
|
checkedLocations.Clear();
|
||||||
|
exploredLocations.Clear();
|
||||||
if (warpChain == null)
|
if (warpChain == null)
|
||||||
{
|
{
|
||||||
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
ModCore.CoreMonitor.Log("NULL WARP CHAIN");
|
||||||
|
@ -396,43 +413,135 @@ namespace StarAI.PathFindingCore.MapTransitionLogic
|
||||||
//Do final location walk to stuff here.
|
//Do final location walk to stuff here.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<WarpGoal> okBye(List<WarpGoal> param,string targetMapName)
|
/*
|
||||||
|
public static List<WarpGoal> okByeGOODLOCATION(List<WarpGoal> param, string targetMapName, GameLocation lastCheckedLocation)
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
WarpGoal theOne= new WarpGoal(null,null);
|
List<GameLocation> placesToExplore = new List<GameLocation>();
|
||||||
List<WarpGoal> warpChain = new List<WarpGoal>();
|
List<GameLocation> placesIHaveBeen = new List<GameLocation>();
|
||||||
foreach (WarpGoal w in param)
|
|
||||||
|
foreach(var warpGoal in param)
|
||||||
{
|
{
|
||||||
GameLocation loc = Game1.getLocationFromName(w.warp.TargetName);
|
ModCore.CoreMonitor.Log(warpGoal.warp.TargetName);
|
||||||
foreach (var v in loc.warps)
|
placesToExplore.Add(Game1.getLocationFromName(warpGoal.warp.TargetName));
|
||||||
|
}
|
||||||
|
placesIHaveBeen.Add(lastCheckedLocation);
|
||||||
|
|
||||||
|
|
||||||
|
while (placesToExplore.Count != 0)
|
||||||
|
{
|
||||||
|
GameLocation currentCheckingLocation = placesToExplore.ElementAt(0);
|
||||||
|
while(checkedLocations.Contains(currentCheckingLocation))
|
||||||
{
|
{
|
||||||
WarpGoal ok = new WarpGoal(w, v);
|
placesToExplore.Remove(currentCheckingLocation);
|
||||||
w.childrenWarps.Add(ok);
|
currentCheckingLocation = placesToExplore.ElementAt(0);
|
||||||
if (v.TargetName == targetMapName)
|
ModCore.CoreMonitor.Log("REMOVING " + currentCheckingLocation.name, StardewModdingAPI.LogLevel.Warn);
|
||||||
|
|
||||||
|
}
|
||||||
|
foreach(var warp in currentCheckingLocation.warps)
|
||||||
|
{
|
||||||
|
bool addNewLocation = true;
|
||||||
|
foreach (var checkedPlace in placesIHaveBeen)
|
||||||
{
|
{
|
||||||
found = true;
|
|
||||||
theOne = ok;
|
if (checkedPlace.name == warp.TargetName)
|
||||||
break;
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == false)
|
placesIHaveBeen.Add(currentCheckingLocation);
|
||||||
{
|
placesToExplore.Remove(currentCheckingLocation);
|
||||||
return okBye(w.childrenWarps,targetMapName);
|
ModCore.CoreMonitor.Log("CHECKING LOCATION: " + currentCheckingLocation.name,StardewModdingAPI.LogLevel.Alert);
|
||||||
}
|
|
||||||
if (found == true)
|
|
||||||
{
|
|
||||||
while (theOne.parentWarpGoal != null)
|
|
||||||
{
|
|
||||||
warpChain.Add(theOne);
|
|
||||||
theOne = theOne.parentWarpGoal;
|
|
||||||
}
|
|
||||||
warpChain.Add(theOne);
|
|
||||||
}
|
|
||||||
return warpChain;
|
|
||||||
//recursively call this logic???
|
|
||||||
}
|
}
|
||||||
return new List<WarpGoal>();
|
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>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ namespace StarAI.PathFindingCore
|
||||||
|
|
||||||
if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y))
|
if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y))
|
||||||
{
|
{
|
||||||
|
// ModCore.CoreMonitor.Log("OBJECt??? " + t.thisLocation.name, LogLevel.Error);
|
||||||
//ModCore.CoreMonitor.Log("Object at this tile position!: " + t.thisLocation.objects[new Vector2(pos.X/Game1.tileSize,pos.Y/Game1.tileSize)].name, LogLevel.Warn);
|
//ModCore.CoreMonitor.Log("Object at this tile position!: " + t.thisLocation.objects[new Vector2(pos.X/Game1.tileSize,pos.Y/Game1.tileSize)].name, LogLevel.Warn);
|
||||||
if (cry == true) t.thisLocation = null;
|
if (cry == true) t.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,9 +96,18 @@ namespace StarAI.PathFindingCore
|
||||||
if (utilityCheck) {
|
if (utilityCheck) {
|
||||||
foreach (var v in Utilities.tileExceptionList)
|
foreach (var v in Utilities.tileExceptionList)
|
||||||
{
|
{
|
||||||
// ModCore.CoreMonitor.Log(v.actionType);
|
// ModCore.CoreMonitor.Log(v.actionType);
|
||||||
if (v.tile.position == pos) return false;
|
// ModCore.CoreMonitor.Log("UTILITY????: " + t.thisLocation.name, LogLevel.Error);
|
||||||
if (v.tile.tileLocation == pos / Game1.tileSize) return false;
|
if (v.tile.position == pos)
|
||||||
|
{
|
||||||
|
// ModCore.CoreMonitor.Log("DERP????: " + t.thisLocation.name, LogLevel.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (v.tile.tileLocation == pos / Game1.tileSize)
|
||||||
|
{
|
||||||
|
// ModCore.CoreMonitor.Log("BLURP " + t.thisLocation.name, LogLevel.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,30 +115,34 @@ namespace StarAI.PathFindingCore
|
||||||
if (terrainFeature)
|
if (terrainFeature)
|
||||||
{
|
{
|
||||||
TerrainFeature terrain = t.thisLocation.terrainFeatures[pos / Game1.tileSize];
|
TerrainFeature terrain = t.thisLocation.terrainFeatures[pos / Game1.tileSize];
|
||||||
if (terrain.isPassable()) return true;
|
// ModCore.CoreMonitor.Log("TERRAIN NOPE!: " + t.thisLocation.name, LogLevel.Error);
|
||||||
|
if (terrain.isPassable()) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.thisLocation.isTileOccupied(pos / Game1.tileSize))
|
if (t.thisLocation.isTileOccupied(pos / Game1.tileSize))
|
||||||
{
|
{
|
||||||
// ModCore.CoreMonitor.Log("Tile occupied!: " + t.thisLocation.name, LogLevel.Error);
|
// ModCore.CoreMonitor.Log("Tile occupied!: " + t.thisLocation.name, LogLevel.Error);
|
||||||
|
if (isTileExempt(t,pos)) return true;
|
||||||
if (cry == true) t.thisLocation = null;
|
if (cry == true) t.thisLocation = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
|
||||||
{
|
{
|
||||||
// ModCore.CoreMonitor.Log("Tile Not placeable at location. " + t.thisLocation.name, LogLevel.Error);
|
// ModCore.CoreMonitor.Log("Tile Not placeable at location. " + t.thisLocation.name, LogLevel.Error);
|
||||||
if (cry == true) t.thisLocation = null;
|
if (cry == true) t.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("Tile not passable check 2?????!!!!: " + t.thisLocation.name, LogLevel.Error);
|
//ModCore.CoreMonitor.Log("Tile not passable check 2?????!!!!: " + t.thisLocation.name, LogLevel.Error);
|
||||||
|
if (isTileExempt(t,pos)) return true;
|
||||||
if (cry == true) t.thisLocation = null;
|
if (cry == true) t.thisLocation = null;
|
||||||
return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,6 +150,44 @@ namespace StarAI.PathFindingCore
|
||||||
if (cry == true) t.thisLocation = null;
|
if (cry == true) t.thisLocation = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool isTileExempt(TileNode t,Vector2 pos)
|
||||||
|
{
|
||||||
|
foreach (var v in Game1.player.currentLocation.map.TileSheets)
|
||||||
|
{
|
||||||
|
foreach (var q in Game1.player.currentLocation.map.Layers)
|
||||||
|
{
|
||||||
|
string[] s = q.ToString().Split(':');
|
||||||
|
string layer = s[1].Trim();
|
||||||
|
int tileIndex = t.thisLocation.getTileIndexAt((int)pos.X/Game1.tileSize, (int)pos.Y / Game1.tileSize, layer);
|
||||||
|
if (tileIndex == -1) continue;
|
||||||
|
//ModCore.CoreMonitor.Log("Position: " + (Game1.player.getTileLocation() / Game1.tileSize).ToString(), LogLevel.Warn);
|
||||||
|
//ModCore.CoreMonitor.Log("Layer: " + layer, LogLevel.Warn);
|
||||||
|
//ModCore.CoreMonitor.Log("Index: " + tileIndex.ToString(), LogLevel.Warn);
|
||||||
|
//ModCore.CoreMonitor.Log("Image Source: " + v.ImageSource, LogLevel.Warn);
|
||||||
|
|
||||||
|
if (layer == "Buildings")
|
||||||
|
{
|
||||||
|
TileExceptionNode tileException = new TileExceptionNode(v.ImageSource, tileIndex);
|
||||||
|
foreach (var tile in PathFindingCore.Utilities.ignoreCheckTiles)
|
||||||
|
{
|
||||||
|
if (tile.imageSource == tileException.imageSource && tile.index == tileException.index)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("Tile exception already initialized!");
|
||||||
|
return true; //tile is already initialized.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PathFindingCore.Utilities.ignoreCheckTiles.Add(tileException);
|
||||||
|
//tileException.serializeJson(Path.Combine(ModCore.CoreHelper.DirectoryPath, PathFindingCore.Utilities.folderForExceptionTiles));
|
||||||
|
//StardustCore.ModCore.SerializationManager.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void setSingleTileAsChild(TileNode t,int x, int y,bool checkForUtility,bool placementAction=true)
|
public static void setSingleTileAsChild(TileNode t,int x, int y,bool checkForUtility,bool placementAction=true)
|
||||||
{
|
{
|
|
@ -34,7 +34,25 @@ namespace StarAI.PathFindingCore
|
||||||
|
|
||||||
public static void initializeTileExceptionList()
|
public static void initializeTileExceptionList()
|
||||||
{
|
{
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\spring_outdoorsTileSheet", 779));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\spring_outdoorsTileSheet", 780));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\spring_outdoorsTileSheet", 781));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\spring_outdoorsTileSheet", 782));
|
||||||
|
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\summer_outdoorsTileSheet", 779));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\summer_outdoorsTileSheet", 780));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\summer_outdoorsTileSheet", 781));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\summer_outdoorsTileSheet", 782));
|
||||||
|
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\fall_outdoorsTileSheet", 779));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\fall_outdoorsTileSheet", 780));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\fall_outdoorsTileSheet", 781));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\fall_outdoorsTileSheet", 782));
|
||||||
|
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\winter_outdoorsTileSheet", 779));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\winter_outdoorsTileSheet", 780));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\winter_outdoorsTileSheet", 781));
|
||||||
|
ignoreCheckTiles.Add(new TileExceptionNode("Maps\\winter_outdoorsTileSheet", 782));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="CheatCore\DoorsToWarps.cs" />
|
||||||
<Compile Include="Commands.cs" />
|
<Compile Include="Commands.cs" />
|
||||||
<Compile Include="ExecutionCore\CustomTask.cs" />
|
<Compile Include="ExecutionCore\CustomTask.cs" />
|
||||||
<Compile Include="ExecutionCore\TaskList.cs" />
|
<Compile Include="ExecutionCore\TaskList.cs" />
|
||||||
|
@ -76,10 +77,10 @@
|
||||||
<Compile Include="PathFindingCore\MapTransitionLogic\TransitionLogic.cs" />
|
<Compile Include="PathFindingCore\MapTransitionLogic\TransitionLogic.cs" />
|
||||||
<Compile Include="PathFindingCore\MapTransitionLogic\WarpGoal.cs" />
|
<Compile Include="PathFindingCore\MapTransitionLogic\WarpGoal.cs" />
|
||||||
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
|
||||||
<Compile Include="PathFindingCore\PlacementNode.cs" />
|
<Compile Include="PathFindingCore\TileNodes\PlacementNode.cs" />
|
||||||
<Compile Include="PathFindingCore\TileExceptionMetaData.cs" />
|
<Compile Include="PathFindingCore\TileNodes\TileExceptionMetaData.cs" />
|
||||||
<Compile Include="PathFindingCore\TileExceptionNode.cs" />
|
<Compile Include="PathFindingCore\TileNodes\TileExceptionNode.cs" />
|
||||||
<Compile Include="PathFindingCore\TileNodeObject.cs" />
|
<Compile Include="PathFindingCore\TileNodes\TileNodeObject.cs" />
|
||||||
<Compile Include="PathFindingCore\Utilities.cs" />
|
<Compile Include="PathFindingCore\Utilities.cs" />
|
||||||
<Compile Include="PathFindingCore\WaterLogic\WaterLogic.cs" />
|
<Compile Include="PathFindingCore\WaterLogic\WaterLogic.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
Loading…
Reference in New Issue