From 20e07d79cc4fd2044fcb1db5f1718ce7df9b9ba2 Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Wed, 26 Jan 2022 13:57:48 +0530 Subject: [PATCH] Added up ladder and mine elevator --- stardew-access/Features/Radar.cs | 13 +++++-- stardew-access/Features/ReadTile.cs | 56 +++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/stardew-access/Features/Radar.cs b/stardew-access/Features/Radar.cs index f310be4..8c82d57 100644 --- a/stardew-access/Features/Radar.cs +++ b/stardew-access/Features/Radar.cs @@ -69,6 +69,7 @@ namespace stardew_access.Game exclusions.Add("weed"); exclusions.Add("twig"); exclusions.Add("coloured stone"); + exclusions.Add("ice crystal"); exclusions.Add("clay stone"); exclusions.Add("fossil stone"); exclusions.Add("crop"); @@ -77,7 +78,7 @@ namespace stardew_access.Game exclusions.Add("water"); exclusions.Add("grass"); - /* Not excluded + /* Not excluded Categories * * * exclusions.Add("farmer"); @@ -291,7 +292,15 @@ namespace stardew_access.Game } } // Check for Mine ladders - else if (ReadTile.isMineLadderAtTile((int)position.X, (int)position.Y)) + else if (ReadTile.isMineDownLadderAtTile((int)position.X, (int)position.Y)) + { + PlaySoundAt(position, "ladder", CATEGORY.Buildings); + } + else if (ReadTile.isMineUpLadderAtTile((int)position.X, (int)position.Y)) + { + PlaySoundAt(position, "ladder", CATEGORY.Buildings); + } + else if (ReadTile.isElevatorAtTile((int)position.X, (int)position.Y)) { PlaySoundAt(position, "ladder", CATEGORY.Buildings); } diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index 00820f4..83fc47c 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -75,10 +75,18 @@ namespace stardew_access.Game { toSpeak = "Door"; } - else if (isMineLadderAtTile(x, y)) + else if (isMineDownLadderAtTile(x, y)) { toSpeak = "Ladder"; } + else if (isMineUpLadderAtTile(x, y)) + { + toSpeak = "Up Ladder"; + } + else if (isElevatorAtTile(x, y)) + { + toSpeak = "Elevator"; + } else if (getBuildingAtTile(x, y) != null) { toSpeak = getBuildingAtTile(x, y); @@ -203,6 +211,7 @@ namespace stardew_access.Game /* Add More MainClass.monitor.Log(index.ToString(), LogLevel.Debug); */ + if (index != null) { switch (index) @@ -240,6 +249,7 @@ namespace stardew_access.Game break; } } + } return toReturn; @@ -572,11 +582,11 @@ namespace stardew_access.Game return toReturn; } - public static bool isMineLadderAtTile(int x, int y) + public static bool isMineDownLadderAtTile(int x, int y) { try { - if (Game1.inMine || Game1.currentLocation is Mine) + if (Game1.currentLocation is Mine or MineShaft) { int? index = null; @@ -592,6 +602,46 @@ namespace stardew_access.Game return false; } + public static bool isMineUpLadderAtTile(int x, int y) + { + try + { + if (Game1.currentLocation is Mine or MineShaft) + { + int? index = null; + + if (Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y] != null) + index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex; + + if (index == 115) + return true; + } + } + catch (Exception) { } + + return false; + } + + public static bool isElevatorAtTile(int x, int y) + { + try + { + if (Game1.currentLocation is Mine or MineShaft) + { + int? index = null; + + if (Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y] != null) + index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex; + + if (index == 112) + return true; + } + } + catch (Exception) { } + + return false; + } + public static bool isDoorAtTile(int x, int y) { Point tilePoint = new Point(x, y);