diff --git a/stardew-access/Features/StaticTiles.cs b/stardew-access/Features/StaticTiles.cs new file mode 100644 index 0000000..e8d90ab --- /dev/null +++ b/stardew-access/Features/StaticTiles.cs @@ -0,0 +1,64 @@ +using Newtonsoft.Json.Linq; +using StardewValley; + +namespace stardew_access.Features +{ + public class StaticTiles + { + private JObject? data; + + public StaticTiles() + { + using (StreamReader file = new StreamReader("static-tiles.json")) + { + string json = file.ReadToEnd(); + data = JObject.Parse(json); + + } + } + + public bool isAvailable(string locationName) + { + if (data != null) + { + foreach (var location in data) + { + if (locationName.ToLower().Equals(location.Key)) + return true; + } + } + + return false; + } + + public string? getStaticTileAt(int x, int y) + { + if (data == null) + return null; + + foreach (var location in data) + { + if (!Game1.currentLocation.Name.ToLower().Equals(location.Key)) + continue; + + if (location.Value != null) + foreach (var tile in ((JObject)location.Value)) + { + if (tile.Value == null) + continue; + + JToken? tileX = tile.Value["x"]; + JToken? tileY = tile.Value["y"]; + + if (tileX == null || tileY == null) + continue; + + if (short.Parse(tileX.ToString()) == x && short.Parse(tileY.ToString()) == y) + return tile.Key; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/stardew-access/Features/TileInfo.cs b/stardew-access/Features/TileInfo.cs index 3863cfc..d21b465 100644 --- a/stardew-access/Features/TileInfo.cs +++ b/stardew-access/Features/TileInfo.cs @@ -47,6 +47,7 @@ namespace stardew_access.Features string? resourceClump = getResourceClumpAtTile(x, y); string? farmAnimal = getFarmAnimalAt(Game1.currentLocation, x, y); string? parrot = getParrotPerchAtTile(x, y); + string? staticTile = MainClass.STiles.getStaticTileAt(x, y); if (Game1.currentLocation.isCharacterAtTile(tile) != null) { @@ -62,6 +63,11 @@ namespace stardew_access.Features toReturn = farmAnimal; category = CATEGORY.FarmAnimals; } + else if (staticTile != null) + { + toReturn = staticTile; + category = CATEGORY.Others; + } else if (Game1.currentLocation is VolcanoDungeon && ((VolcanoDungeon)Game1.currentLocation).IsCooledLava(x, y)) { toReturn = "Cooled lava"; @@ -893,5 +899,6 @@ namespace stardew_access.Features return null; } + } } \ No newline at end of file diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 1dc8136..2fb2634 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -7,6 +7,7 @@ using stardew_access.Patches; using stardew_access.ScreenReader; using Microsoft.Xna.Framework; using StardewValley.Menus; +using Newtonsoft.Json.Linq; namespace stardew_access { @@ -17,16 +18,30 @@ namespace stardew_access private Harmony? harmony; private static IMonitor? monitor; private static Radar? radarFeature; + private static StaticTiles? sTiles; private static IScreenReader? screenReader; private static IModHelper? modHelper; internal static ModConfig Config { get => config; set => config = value; } public static IModHelper? ModHelper { get => modHelper; } + public static StaticTiles STiles + { + get + { + if (sTiles == null) + sTiles = new StaticTiles(); + + return sTiles; + } + set => sTiles = value; + } public static Radar RadarFeature { get { - if (radarFeature == null) { radarFeature = new Radar(); } + if (radarFeature == null) + radarFeature = new Radar(); + return radarFeature; } set => radarFeature = value; diff --git a/stardew-access/static-tiles.json b/stardew-access/static-tiles.json new file mode 100644 index 0000000..cffffe6 --- /dev/null +++ b/stardew-access/static-tiles.json @@ -0,0 +1,23 @@ +{ + "busstop": + { + "Ticket Machine": + { + "x":7, + "y":11, + "type":"interactable" + }, + "Minecart": + { + "x":4, + "y":3, + "type":"interactable" + }, + "Minecart": + { + "x":5, + "y":3, + "type":"interactable" + } + } +} \ No newline at end of file