From 101d0f496caf7bdb6ba6e0cbc706b7cae44bc77d Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Mon, 21 Mar 2022 12:33:44 +0530 Subject: [PATCH] Removed duplicate code --- stardew-access/Features/ReadTile.cs | 83 +++-------------------------- 1 file changed, 6 insertions(+), 77 deletions(-) diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index 56446aa..acf3117 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -98,6 +98,12 @@ namespace stardew_access.Features return (tileDetail.name, tileDetail.category.ToString()); } + ///Returns the name of the object at tile + public static string? getNameAtTile(Vector2 tile) + { + return getNameWithCategoryAtTile(tile).name; + } + ///Returns the name of the object at tile alongwith it's category public static (string? name, CATEGORY? category) getNameWithCategoryAtTile(Vector2 tile) { @@ -197,83 +203,6 @@ namespace stardew_access.Features return (toReturn, category); } - ///Returns the name of the object at tile - public static string? getNameAtTile(Vector2 tile) - { - int x = (int)tile.X; - int y = (int)tile.Y; - string? toReturn = ""; - - bool isColliding = isCollidingAtTile(x, y); - Dictionary> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; - string? door = getDoorAtTile(x, y); - (CATEGORY? category, string? name) tileInfo = getTileInfo(x, y); - string? junimoBundle = getJunimoBundleAt(x, y); - string? resourceClump = getResourceClumpAtTile(x, y); - string? farmAnimal = getFarmAnimalAt(Game1.currentLocation, x, y); - - if (Game1.currentLocation.isCharacterAtTile(tile) != null) - { - NPC npc = Game1.currentLocation.isCharacterAtTile(tile); - toReturn = npc.displayName; - } - else if (farmAnimal != null) - { - toReturn = farmAnimal; - } - else if (Game1.currentLocation.isWaterTile(x, y) && isColliding) - { - toReturn = "Water"; - } - else if (Game1.currentLocation.isObjectAtTile(x, y)) - { - toReturn = getObjectAtTile(x, y).name; - } - else if (terrainFeature.ContainsKey(tile)) - { - string? terrain = getTerrainFeatureAtTile(terrainFeature[tile]).Item1; - if (terrain != null) - toReturn = terrain; - } - else if (Game1.currentLocation.getLargeTerrainFeatureAt(x, y) != null) - { - toReturn = getBushAtTile(x, y); - } - else if (resourceClump != null) - { - toReturn = resourceClump; - } - else if (door != null) - { - toReturn = door; - } - else if (isMineDownLadderAtTile(x, y)) - { - toReturn = "Ladder"; - } - else if (isMineUpLadderAtTile(x, y)) - { - toReturn = "Up Ladder"; - } - else if (isElevatorAtTile(x, y)) - { - toReturn = "Elevator"; - } - else if (tileInfo.name != null) - { - toReturn = tileInfo.name; - } - else if (junimoBundle != null) - { - toReturn = junimoBundle; - } - - if (toReturn == "") - return null; - - return toReturn; - } - public static string? getBushAtTile(int x, int y) { string? toReturn = null;