Can cut weeds.
This commit is contained in:
parent
365808a504
commit
992ef687e7
|
@ -32,6 +32,9 @@ namespace StarAI
|
||||||
ModCore.CoreHelper.ConsoleCommands.Add("choptwigs", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
ModCore.CoreHelper.ConsoleCommands.Add("choptwigs", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
||||||
ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
||||||
ModCore.CoreHelper.ConsoleCommands.Add("breakstones", "Break small stones with pickaxe.", new Action<string, string[]>(Commands.breakAllStones));
|
ModCore.CoreHelper.ConsoleCommands.Add("breakstones", "Break small stones with pickaxe.", new Action<string, string[]>(Commands.breakAllStones));
|
||||||
|
|
||||||
|
ModCore.CoreHelper.ConsoleCommands.Add("cutweed", "Cut weeds with a tool.", new Action<string, string[]>(Commands.cutAllWeeds));
|
||||||
|
ModCore.CoreHelper.ConsoleCommands.Add("cutweeds", "Cut weeds with a tool", new Action<string, string[]>(Commands.cutAllWeeds));
|
||||||
// ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
// ModCore.CoreHelper.ConsoleCommands.Add("chopsticks", "Chop twigs.", new Action<string, string[]>(Commands.chopAllTwigs));
|
||||||
pathfind("Initialize Delay 0", new string[] {
|
pathfind("Initialize Delay 0", new string[] {
|
||||||
"setDelay",
|
"setDelay",
|
||||||
|
@ -72,6 +75,19 @@ namespace StarAI
|
||||||
DebrisLogic.getAllStonestoBreakRadius(Game1.player.currentLocation);
|
DebrisLogic.getAllStonestoBreakRadius(Game1.player.currentLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void cutAllWeeds(string s, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length == 1)
|
||||||
|
{
|
||||||
|
if (args[0] == "All" || args[0] == "all")
|
||||||
|
{
|
||||||
|
DebrisLogic.getAllWeedsToCut(Game1.player.currentLocation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DebrisLogic.getAllWeedsToCutRadius(Game1.player.currentLocation);
|
||||||
|
}
|
||||||
|
|
||||||
public static void runTasks(string s, string[] args)
|
public static void runTasks(string s, string[] args)
|
||||||
{
|
{
|
||||||
ExecutionCore.TaskList.runTaskList();
|
ExecutionCore.TaskList.runTaskList();
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
||||||
{
|
{
|
||||||
public static List<TileNode> sticksToChop = new List<TileNode>();
|
public static List<TileNode> sticksToChop = new List<TileNode>();
|
||||||
public static List<TileNode> stonesToBreak = new List<TileNode>();
|
public static List<TileNode> stonesToBreak = new List<TileNode>();
|
||||||
|
public static List<TileNode> weedsToCut = new List<TileNode>();
|
||||||
|
|
||||||
|
|
||||||
public static void getAllSticksToChop(GameLocation location)
|
public static void getAllSticksToChop(GameLocation location)
|
||||||
{
|
{
|
||||||
|
@ -502,5 +504,221 @@ namespace StarAI.PathFindingCore.DebrisLogic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void getAllWeedsToCut(GameLocation location)
|
||||||
|
{
|
||||||
|
object[] arr = new object[1];
|
||||||
|
arr[0] = location;
|
||||||
|
getAllWeedsToCut(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DO NOT USE THIS UNLESS YOU WANT LAG UP THE WAZOO. WILL ATTEMPT TO PATH TO ALL STICKS AT THE LOCATION AND CHOP THEM!
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
public static void getAllWeedsToCut(object obj)
|
||||||
|
{
|
||||||
|
int twingCount = 0;
|
||||||
|
object[] objArr = (object[])obj;
|
||||||
|
GameLocation location = (GameLocation)objArr[0];
|
||||||
|
foreach (var v in location.objects)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(v.Value.name);
|
||||||
|
|
||||||
|
if (v.Value.name == "Weeds")
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(v.Value.name, LogLevel.Warn);
|
||||||
|
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.placementAction(Game1.currentLocation, (int)v.Key.X * Game1.tileSize, (int)v.Key.Y * Game1.tileSize);
|
||||||
|
t.fakePlacementAction(Game1.currentLocation, (int)v.Key.X, (int)v.Key.Y);
|
||||||
|
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "CutWeeds"));
|
||||||
|
weedsToCut.Add(t);
|
||||||
|
twingCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ok = 0;
|
||||||
|
foreach (var v in weedsToCut)
|
||||||
|
{
|
||||||
|
|
||||||
|
object[] objList = new object[2];
|
||||||
|
objList[0] = v;
|
||||||
|
// ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj));
|
||||||
|
StardewValley.Tools.MeleeWeapon w = new StardewValley.Tools.MeleeWeapon();
|
||||||
|
ModCore.CoreMonitor.Log("Processing weed:" + ok.ToString() + " / " + twingCount.ToString());
|
||||||
|
ok++;
|
||||||
|
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(cutSingleWeed, objList, new ExecutionCore.TaskMetaData("Cut Single Weed", null, new ToolPrerequisite(true, w.GetType(), 1)));
|
||||||
|
if (task.taskMetaData.cost == Int32.MaxValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
Utilities.clearExceptionListWithNames(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ExecutionCore.TaskList.taskList.Add(task);
|
||||||
|
Utilities.clearExceptionListWithName("Child");
|
||||||
|
// waterSingleCrop(v);
|
||||||
|
}
|
||||||
|
weedsToCut.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void getAllWeedsToCutRadius(GameLocation location)
|
||||||
|
{
|
||||||
|
object[] arr = new object[1];
|
||||||
|
arr[0] = location;
|
||||||
|
getAllWeedsToCutRadius(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void getAllWeedsToCutRadius(object obj)
|
||||||
|
{
|
||||||
|
int radius = 1;
|
||||||
|
int twingCount = 0;
|
||||||
|
object[] objArr = (object[])obj;
|
||||||
|
GameLocation location = (GameLocation)objArr[0];
|
||||||
|
string targetName = "Weeds";
|
||||||
|
if (StardustCore.Utilities.doesLocationContainObject(location, targetName))
|
||||||
|
{
|
||||||
|
StardewValley.Object twig = StardustCore.Utilities.checkRadiusForObject(radius, targetName);
|
||||||
|
while (twig == null)
|
||||||
|
{
|
||||||
|
radius++;
|
||||||
|
twig = StardustCore.Utilities.checkRadiusForObject(radius, targetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (twig.name == targetName)
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log(twig.name, LogLevel.Warn);
|
||||||
|
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, (int)twig.tileLocation.X, (int)twig.tileLocation.Y);
|
||||||
|
Utilities.tileExceptionList.Add(new TileExceptionMetaData(t, "CutWeeds"));
|
||||||
|
weedsToCut.Add(t);
|
||||||
|
twingCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModCore.CoreMonitor.Log("Weeds is not found at location.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ok = 0;
|
||||||
|
foreach (var v in weedsToCut)
|
||||||
|
{
|
||||||
|
object[] objList = new object[2];
|
||||||
|
objList[0] = v;
|
||||||
|
// ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(waterSingleCrop), obj));
|
||||||
|
StardewValley.Tools.MeleeWeapon w = new StardewValley.Tools.MeleeWeapon();
|
||||||
|
ModCore.CoreMonitor.Log("Processing weeds:" + ok.ToString() + " / " + twingCount.ToString());
|
||||||
|
ok++;
|
||||||
|
ExecutionCore.CustomTask task = new ExecutionCore.CustomTask(cutSingleWeed, objList, new ExecutionCore.TaskMetaData("Cut Single Weed", new StaminaPrerequisite(true, 3), new ToolPrerequisite(true, w.GetType(), 1)));
|
||||||
|
objList[1] = task.taskMetaData.path;
|
||||||
|
task.objectParameterDataArray = objList;
|
||||||
|
|
||||||
|
if (task.taskMetaData.cost == Int32.MaxValue)
|
||||||
|
{
|
||||||
|
Utilities.clearExceptionListWithNames(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ExecutionCore.TaskList.taskList.Add(task);
|
||||||
|
Utilities.clearExceptionListWithName("Child");
|
||||||
|
}
|
||||||
|
weedsToCut.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void cutSingleWeed(TileNode v, List<TileNode> path)
|
||||||
|
{
|
||||||
|
object[] obj = new object[2];
|
||||||
|
obj[0] = v;
|
||||||
|
obj[1] = path;
|
||||||
|
cutSingleWeed(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void cutSingleWeed(object obj)
|
||||||
|
{
|
||||||
|
object[] objArray = (object[])obj;
|
||||||
|
|
||||||
|
TileNode v = (TileNode)objArray[0];
|
||||||
|
List<TileNode> correctPath = (List<TileNode>)objArray[1];
|
||||||
|
foreach (var goodTile in correctPath)
|
||||||
|
{
|
||||||
|
StardustCore.ModCore.SerializationManager.trackedObjectList.Add(goodTile);
|
||||||
|
goodTile.placementAction(goodTile.thisLocation, (int)goodTile.tileLocation.X * Game1.tileSize, (int)goodTile.tileLocation.Y * Game1.tileSize);
|
||||||
|
}
|
||||||
|
PathFindingLogic.calculateMovement(correctPath);
|
||||||
|
|
||||||
|
if (v.tileLocation.X < Game1.player.getTileX())
|
||||||
|
{
|
||||||
|
Game1.player.faceDirection(3);
|
||||||
|
}
|
||||||
|
else if (v.tileLocation.X > Game1.player.getTileX())
|
||||||
|
{
|
||||||
|
Game1.player.faceDirection(1);
|
||||||
|
}
|
||||||
|
else if (v.tileLocation.Y < Game1.player.getTileY())
|
||||||
|
{
|
||||||
|
Game1.player.faceDirection(0);
|
||||||
|
}
|
||||||
|
else if (v.tileLocation.Y > Game1.player.getTileY())
|
||||||
|
{
|
||||||
|
Game1.player.faceDirection(2);
|
||||||
|
}
|
||||||
|
foreach (var item in Game1.player.items)
|
||||||
|
{
|
||||||
|
if (item is StardewValley.Tools.MeleeWeapon)
|
||||||
|
{
|
||||||
|
Game1.player.CurrentToolIndex = Game1.player.getIndexOfInventoryItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StardewValley.Object twig = v.thisLocation.objects[v.tileLocation];
|
||||||
|
while ((twig.name == "Weeds"))
|
||||||
|
{
|
||||||
|
if (!v.thisLocation.isObjectAt((int)v.tileLocation.X * Game1.tileSize, (int)v.tileLocation.Y * Game1.tileSize)) break;
|
||||||
|
if (WindowsInput.InputSimulator.IsKeyDown(WindowsInput.VirtualKeyCode.VK_C) == false) WindowsInput.InputSimulator.SimulateKeyDown(WindowsInput.VirtualKeyCode.VK_C);
|
||||||
|
|
||||||
|
Vector2 center = new Vector2();
|
||||||
|
if (Game1.player.facingDirection == 2)
|
||||||
|
{
|
||||||
|
center = 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);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Game1.player.facingDirection == 0)
|
||||||
|
{
|
||||||
|
center = 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);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Game1.player.position = center;
|
||||||
|
//Game1.setMousePosition((int)v.tileLocation.X*Game1.tileSize/2,(int)v.tileLocation.Y*Game1.tileSize/2);
|
||||||
|
ModCore.CoreMonitor.Log("DOESNT Slice LIKE YOU THINK IT SHOULD");
|
||||||
|
ModCore.CoreMonitor.Log("player pos: " + Game1.player.position.ToString(), LogLevel.Warn);
|
||||||
|
ModCore.CoreMonitor.Log("TilePos: " + v.position.ToString(), LogLevel.Error);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
WindowsInput.InputSimulator.SimulateKeyUp(WindowsInput.VirtualKeyCode.VK_C);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue