Added exception for warp points when checking if a tile is on map

master
Mohammad Shoaib Khan 2022-11-07 20:51:00 +05:30
parent fe03dfb46e
commit 771ebb07e4
No known key found for this signature in database
GPG Key ID: 3EE32C9DFF520699
4 changed files with 20 additions and 2 deletions

View File

@ -166,7 +166,7 @@ namespace stardew_access.Features
{
Vector2 dir = new Vector2(item.X + dirX[i], item.Y + dirY[i]);
if (!searched.Contains(dir) && Game1.currentLocation.isTileOnMap(dir))
if (!searched.Contains(dir) && (TileInfo.isWarpPointAtTile((int)dir.X, (int)dir.Y) || Game1.currentLocation.isTileOnMap(dir)))
{
toSearch.Enqueue(dir);
searched.Add(dir);

View File

@ -279,6 +279,9 @@ namespace stardew_access.Features
{
Rectangle rect = new Rectangle(x * 64 + 1, y * 64 + 1, 62, 62);
// Check whether the position is a warp point, if so then return false, sometimes warp points are 1 tile off the map for example in coops and barns
if (isWarpPointAtTile(x, y)) return false;
if (Game1.currentLocation.isCollidingPosition(rect, Game1.viewport, true, 0, glider: false, Game1.player, pathfinding: true))
{
return true;
@ -290,6 +293,18 @@ namespace stardew_access.Features
return false;
}
public static Boolean isWarpPointAtTile(int x, int y)
{
if (Game1.currentLocation == null) return false;
foreach (Warp warpPoint in Game1.currentLocation.warps)
{
if (warpPoint.X == x && warpPoint.Y == y) return true;
}
return false;
}
public static string? getFarmAnimalAt(GameLocation? location, int x, int y)
{
if (location == null)

View File

@ -278,6 +278,9 @@ namespace stardew_access.Features
private static bool isPositionOnMap(Vector2 position)
{
// Check whether the position is a warp point, if so then return true, sometimes warp points are 1 tile off the map for example in coops and barns
if (TileInfo.isWarpPointAtTile((int)(position.X / Game1.tileSize), (int)(position.Y / Game1.tileSize))) return true;
//position does not take viewport into account since the entire map needs to be checked.
Map map = Game1.currentLocation.map;
if (position.X < 0 || position.X > map.Layers[0].DisplayWidth) return false;

View File

@ -1,7 +1,7 @@
{
"Name": "Stardew Access",
"Author": "Mohammad Shoaib",
"Version": "1.3.3",
"Version": "1.3.4",
"Description": "An accessibility mod with screen reader support!",
"UniqueID": "shoaib.stardewaccess",
"EntryDll": "stardew-access.dll",