Added static tiles to tile info

master
Mohammad Shoaib 2022-04-23 17:54:19 +05:30
parent 4590f64736
commit 5148139825
4 changed files with 110 additions and 1 deletions

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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"
}
}
}