Added command to include key to exclusion

master
shoaib11120 2022-01-19 12:44:52 +05:30
parent 6c8eddd08b
commit 469ed0a6a6
3 changed files with 155 additions and 131 deletions

View File

@ -77,6 +77,8 @@ namespace stardew_access.Game
} }
public void checkTile(Vector2 position) public void checkTile(Vector2 position)
{
try
{ {
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
@ -123,11 +125,11 @@ namespace stardew_access.Game
string? terrain = ReadTile.getTerrainFeatureAtTile(tr).ToLower(); string? terrain = ReadTile.getTerrainFeatureAtTile(tr).ToLower();
if (terrain != null) if (terrain != null)
{ {
if(tr.Get() is HoeDirt && !exclusions.Contains("crop")) if (tr.Get() is HoeDirt && !exclusions.Contains("crop"))
{ {
playSoundAt(position, terrain); playSoundAt(position, terrain);
} }
else if(tr.Get() is GiantCrop && !exclusions.Contains("giant crop")) else if (tr.Get() is GiantCrop && !exclusions.Contains("giant crop"))
{ {
playSoundAt(position, terrain); playSoundAt(position, terrain);
} }
@ -186,12 +188,17 @@ namespace stardew_access.Game
playSoundAt(position, ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y)); playSoundAt(position, ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y));
} }
} }
catch (Exception e)
{
MainClass.monitor.Log($"{e.Message}\n{e.StackTrace}\n{e.Source}", StardewModdingAPI.LogLevel.Error);
}
}
public void playSoundAt(Vector2 position, String? searchQuery) public void playSoundAt(Vector2 position, String? searchQuery)
{ {
if (searchQuery == null || !exclusions.Contains(searchQuery)) if (searchQuery == null || !exclusions.Contains(searchQuery))
{ {
MainClass.monitor.Log($"{searchQuery}:X={position.X} Y={position.Y}", StardewModdingAPI.LogLevel.Debug); MainClass.monitor.Log($"Object:{searchQuery}\tPosition: X={position.X} Y={position.Y}", StardewModdingAPI.LogLevel.Debug);
Game1.currentLocation.localSoundAt("sa_poi", position); Game1.currentLocation.localSoundAt("sa_poi", position);
} }
} }

View File

@ -104,6 +104,10 @@ namespace stardew_access.Game
public static string? getBuildingAtTile(int x, int y) public static string? getBuildingAtTile(int x, int y)
{ {
string? toReturn = null; string? toReturn = null;
// It throws error if it can't find the index, do something else to fix this
try
{
int? index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex; int? index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
/* Add More /* Add More
MainClass.monitor.Log(index.ToString(), LogLevel.Debug); MainClass.monitor.Log(index.ToString(), LogLevel.Debug);
@ -139,6 +143,8 @@ namespace stardew_access.Game
break; break;
} }
} }
}
catch (Exception) {}
return toReturn; return toReturn;
} }

View File

@ -222,35 +222,46 @@ namespace stardew_access
#endregion #endregion
#region Custom Commands #region Custom Commands
helper.ConsoleCommands.Add("read_tile", "Toggle read tile feature", (string arg1, string[] arg2) => helper.ConsoleCommands.Add("read_tile", "Toggle read tile feature", (string commmand, string[] args) =>
{ {
readTile = !readTile; readTile = !readTile;
monitor.Log("Read Tile is " + (readTile ? "on" : "off"), LogLevel.Info); monitor.Log("Read Tile is " + (readTile ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("snap_mouse", "Toggle snap mouse feature", (string arg1, string[] arg2) => helper.ConsoleCommands.Add("snap_mouse", "Toggle snap mouse feature", (string commmand, string[] args) =>
{ {
snapMouse = !snapMouse; snapMouse = !snapMouse;
monitor.Log("Snap Mouse is " + (snapMouse ? "on" : "off"), LogLevel.Info); monitor.Log("Snap Mouse is " + (snapMouse ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("radar", "Toggle radar feature", (string arg1, string[] arg2) => helper.ConsoleCommands.Add("radar", "Toggle radar feature", (string commmand, string[] args) =>
{ {
radar = !radar; radar = !radar;
monitor.Log("Radar " + (snapMouse ? "on" : "off"), LogLevel.Info); monitor.Log("Radar " + (snapMouse ? "on" : "off"), LogLevel.Info);
}); });
helper.ConsoleCommands.Add("r_in", "Include an object to radar", (string arg1, string[] arg2) => helper.ConsoleCommands.Add("r_in", "Include an object to radar", (string commmand, string[] args) =>
{ {
radar = !radar; string? keyToAdd = null;
monitor.Log("Radar " + (snapMouse ? "on" : "off"), LogLevel.Info); for (int i = 0; i < args.Count(); i++) { keyToAdd += " " + args[i]; }
if (keyToAdd != null)
{
keyToAdd = keyToAdd.Trim().ToLower();
radarFeature.exclusions.Add(keyToAdd);
monitor.Log($"Added {keyToAdd} key to exclusions.", LogLevel.Info);
}
else
{
monitor.Log("Unable to add the key to exclusions.", LogLevel.Info);
}
}); });
helper.ConsoleCommands.Add("ref_sr", "Refresh screen reader", (string arg1, string[] arg2) => helper.ConsoleCommands.Add("ref_sr", "Refresh screen reader", (string commmand, string[] args) =>
{ {
ScreenReader.initializeScreenReader(); ScreenReader.initializeScreenReader();