Made reading floorings toggleable | Added names to tuples making it more readable

master
Mohammad Shoaib 2022-03-17 20:04:20 +05:30
parent 0de1cd419b
commit fcd2243cc5
4 changed files with 47 additions and 39 deletions

View File

@ -27,6 +27,13 @@ namespace stardew_access
MainClass.GetMonitor().Log("Snap Mouse is " + (MainClass.snapMouse ? "on" : "off"), LogLevel.Info);
});
helper.ConsoleCommands.Add("flooring", "Toggle flooring in read tile.", (string commmand, string[] args) =>
{
MainClass.readFlooring = !MainClass.readFlooring;
MainClass.GetMonitor().Log("Flooring is " + (MainClass.readFlooring ? "on" : "off"), LogLevel.Info);
});
helper.ConsoleCommands.Add("radar", "Toggle radar feature.", (string commmand, string[] args) =>
{
MainClass.radar = !MainClass.radar;

View File

@ -191,14 +191,14 @@ namespace stardew_access.Features
public (bool, string?, string) CheckTile(Vector2 position)
{
(string?, CATEGORY?) tileDetail = ReadTile.getNameWithCategoryAtTile(position);
if (tileDetail.Item1 == null)
(string? name, CATEGORY? category) tileDetail = ReadTile.getNameWithCategoryAtTile(position);
if (tileDetail.name == null)
return (false, null, CATEGORY.Others.ToString());
if (tileDetail.Item2 == null)
tileDetail.Item2 = CATEGORY.Others;
if (tileDetail.category == null)
tileDetail.category = CATEGORY.Others;
return (true, tileDetail.Item1, tileDetail.Item2.ToString());
return (true, tileDetail.name, tileDetail.category.ToString());
}
@ -208,9 +208,9 @@ namespace stardew_access.Features
{
if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y))
{
(string?, CATEGORY) objDetails = ReadTile.getObjectAtTile((int)position.X, (int)position.Y);
string? objectName = objDetails.Item1;
CATEGORY category = objDetails.Item2;
(string? name, CATEGORY category) objDetails = ReadTile.getObjectAtTile((int)position.X, (int)position.Y);
string? objectName = objDetails.name;
CATEGORY category = objDetails.category;
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)position.X, (int)position.Y);
if (objectName != null)
@ -232,13 +232,13 @@ namespace stardew_access.Features
}
else
{
(string?, CATEGORY?) tileDetail = ReadTile.getNameWithCategoryAtTile(position);
if (tileDetail.Item1 != null)
(string? name, CATEGORY? category) tileDetail = ReadTile.getNameWithCategoryAtTile(position);
if (tileDetail.name != null)
{
if (tileDetail.Item2 == null)
tileDetail.Item2 = CATEGORY.Others;
if (tileDetail.category == null)
tileDetail.category = CATEGORY.Others;
PlaySoundAt(position, tileDetail.Item1, tileDetail.Item2);
PlaySoundAt(position, tileDetail.name, tileDetail.category);
}
}
}

View File

@ -72,18 +72,18 @@ namespace stardew_access.Features
}
///<summary>Returns the name of the object at tile alongwith it's category's name</summary>
public static (string?, string?) getNameWithCategoryNameAtTile(Vector2 tile)
public static (string? name, string? categoryName) getNameWithCategoryNameAtTile(Vector2 tile)
{
(string?, CATEGORY?) tileDetail = getNameWithCategoryAtTile(tile);
(string? name, CATEGORY? category) tileDetail = getNameWithCategoryAtTile(tile);
if (tileDetail.Item2 == null)
tileDetail.Item2 = CATEGORY.Others;
if (tileDetail.category == null)
tileDetail.category = CATEGORY.Others;
return (tileDetail.Item1, tileDetail.Item2.ToString());
return (tileDetail.name, tileDetail.category.ToString());
}
///<summary>Returns the name of the object at tile alongwith it's category</summary>
public static (string?, CATEGORY?) getNameWithCategoryAtTile(Vector2 tile)
public static (string? name, CATEGORY? category) getNameWithCategoryAtTile(Vector2 tile)
{
int x = (int)tile.X;
int y = (int)tile.Y;
@ -93,7 +93,7 @@ namespace stardew_access.Features
bool isColliding = isCollidingAtTile(x, y);
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
string? door = getDoorAtTile(x, y);
(CATEGORY?, string?) tileInfo = getTileInfo(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);
@ -119,18 +119,18 @@ namespace stardew_access.Features
}
else if (Game1.currentLocation.isObjectAtTile(x, y))
{
(string?, CATEGORY?) obj = getObjectAtTile(x, y);
toReturn = obj.Item1;
category = obj.Item2;
(string? name, CATEGORY? category) obj = getObjectAtTile(x, y);
toReturn = obj.name;
category = obj.category;
}
else if (terrainFeature.ContainsKey(tile))
{
(string?, CATEGORY) tf = getTerrainFeatureAtTile(terrainFeature[tile]);
string? terrain = tf.Item1;
(string? name, CATEGORY category) tf = getTerrainFeatureAtTile(terrainFeature[tile]);
string? terrain = tf.name;
if (terrain != null)
{
toReturn = terrain;
category = tf.Item2;
category = tf.category;
}
}
@ -164,10 +164,10 @@ namespace stardew_access.Features
toReturn = "Elevator";
category = CATEGORY.Doors;
}
else if (tileInfo.Item2 != null)
else if (tileInfo.name != null)
{
toReturn = tileInfo.Item2;
category = tileInfo.Item1;
toReturn = tileInfo.name;
category = tileInfo.category;
}
else if (junimoBundle != null)
{
@ -191,7 +191,7 @@ namespace stardew_access.Features
bool isColliding = isCollidingAtTile(x, y);
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
string? door = getDoorAtTile(x, y);
(CATEGORY?, string?) tileInfo = getTileInfo(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);
@ -211,7 +211,7 @@ namespace stardew_access.Features
}
else if (Game1.currentLocation.isObjectAtTile(x, y))
{
toReturn = getObjectAtTile(x, y).Item1;
toReturn = getObjectAtTile(x, y).name;
}
else if (terrainFeature.ContainsKey(tile))
{
@ -243,9 +243,9 @@ namespace stardew_access.Features
{
toReturn = "Elevator";
}
else if (tileInfo.Item2 != null)
else if (tileInfo.name != null)
{
toReturn = tileInfo.Item2;
toReturn = tileInfo.name;
}
else if (junimoBundle != null)
{
@ -391,9 +391,9 @@ namespace stardew_access.Features
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns>Item1: This is the category of the tile. Default to Furnitures.
/// <br/>Item2: This is the name of the tile. Default to null if the tile tile has nothing on it.</returns>
public static (CATEGORY?, string?) getTileInfo(int x, int y)
/// <returns>category: This is the category of the tile. Default to Furnitures.
/// <br/>name: This is the name of the tile. Default to null if the tile tile has nothing on it.</returns>
public static (CATEGORY? category, string? name) getTileInfo(int x, int y)
{
int? index = null;
@ -449,7 +449,7 @@ namespace stardew_access.Features
return (null, null);
}
public static (string?, CATEGORY) getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain)
public static (string? name, CATEGORY category) getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain)
{
string? toReturn = null;
CATEGORY category = CATEGORY.Others;
@ -518,7 +518,7 @@ namespace stardew_access.Features
if (toReturn.Contains("feature"))
toReturn.Replace("feature", "");
}
else if (terrain.Get() is Flooring)
else if (terrain.Get() is Flooring && MainClass.readFlooring)
{
category = CATEGORY.Flooring;
Flooring flooring = (Flooring)terrain.Get();
@ -639,7 +639,7 @@ namespace stardew_access.Features
return seedName;
}
public static (string?, CATEGORY) getObjectAtTile(int x, int y)
public static (string? name, CATEGORY category) getObjectAtTile(int x, int y)
{
string? toReturn = null;

View File

@ -19,6 +19,7 @@ namespace stardew_access
public static bool radar = false;
public static bool radarDebug = false;
public static bool radarStereoSound = true;
public static bool readFlooring = false;
private static IMonitor monitor;
public static string hudMessageQueryKey = "";
private static Radar radarFeature;