From 16def31766a3f139bdcc93fe791cb6212a995d56 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Sun, 13 Feb 2022 17:14:41 +0530 Subject: [PATCH] Fixed door name narration --- stardew-access/Features/Radar.cs | 2 +- stardew-access/Features/ReadTile.cs | 18 +++++++++++------- stardew-access/ModEntry.cs | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/stardew-access/Features/Radar.cs b/stardew-access/Features/Radar.cs index 7bbcdf8..a3089a9 100644 --- a/stardew-access/Features/Radar.cs +++ b/stardew-access/Features/Radar.cs @@ -296,7 +296,7 @@ namespace stardew_access.Game PlaySoundAt(position, "ladder", CATEGORY.Buildings); } // Check for doors - else if (ReadTile.isDoorAtTile((int)position.X, (int)position.Y).Item1) + else if (ReadTile.getDoorAtTile((int)position.X, (int)position.Y) != null) { PlaySoundAt(position, "door", CATEGORY.Buildings); } diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index 35715a6..5be8094 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -79,7 +79,7 @@ namespace stardew_access.Game bool isColliding = isCollidingAtTile(x, y); Dictionary> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; - (bool, string?) door = isDoorAtTile(x, y); + string? door = getDoorAtTile(x, y); (CATEGORY?, string?) tileInfo = getTileInfo(x, y); string? junimoBundle = getJunimoBundleAt(x, y); string? resourceClump = getResourceClumpAtTile(x, y); @@ -116,9 +116,9 @@ namespace stardew_access.Game { toReturn = resourceClump; } - else if (door.Item1) + else if (door != null) { - toReturn = (door.Item2 == null) ? "door" : door.Item2; + toReturn = door; } else if (isMineDownLadderAtTile(x, y)) { @@ -230,6 +230,8 @@ namespace stardew_access.Game return true; } + + return false; } @@ -712,7 +714,7 @@ namespace stardew_access.Game return false; } - public static (bool, string?) isDoorAtTile(int x, int y) + public static string? getDoorAtTile(int x, int y) { Point tilePoint = new Point(x, y); StardewValley.Network.NetPointDictionary doorList = Game1.currentLocation.doors; @@ -724,11 +726,14 @@ namespace stardew_access.Game string? doorName; doorList.TryGetValue(tilePoint, out doorName); - return (true, doorName); + if (doorName != null) + return $"{doorName} door"; + else + return "door"; } } - return (false, null); + return null; } public static string? getResourceClumpAtTile(int x, int y) @@ -782,6 +787,5 @@ namespace stardew_access.Game } return null; } - } } diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 045777b..ea0224f 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -29,7 +29,8 @@ namespace stardew_access public static IScreenReader GetScreenReader() { - screenReader = new ScreenReaderController().Initialize(); + if (screenReader == null) + screenReader = new ScreenReaderController().Initialize(); return screenReader; }