Readded `lessInfo` to many tiles related functions and other code cleanup (making argument ordering consist.

master
Katie Durden 2023-04-04 15:09:49 -07:00
parent 91643e184f
commit ad0cb687b7
7 changed files with 694 additions and 673 deletions

View File

@ -205,8 +205,9 @@ namespace stardew_access.Features
/// <param name="beach">The Beach to search.</param> /// <param name="beach">The Beach to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetBeachInfo(Beach beach, int x, int y) private static (string? name, CATEGORY? category) GetBeachInfo(Beach beach, int x, int y, bool lessInfo = false)
{ {
if (MainClass.ModHelper == null) if (MainClass.ModHelper == null)
{ {
@ -237,25 +238,35 @@ namespace stardew_access.Features
/// <param name="boatTunnel">The BoatTunnel to search.</param> /// <param name="boatTunnel">The BoatTunnel to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetBoatTunnelInfo(BoatTunnel boatTunnel, int x, int y) private static (string? name, CATEGORY? category) GetBoatTunnelInfo(BoatTunnel boatTunnel, int x, int y, bool lessInfo = false)
{ {
if (boatTunnel is null) // Check if the player has received the specified mail or not
{ bool HasMail(string mail) => Game1.MasterPlayer.hasOrWillReceiveMail(mail);
throw new ArgumentNullException(nameof(boatTunnel));
}
if (x == 4 && y == 9) // If the position matches one of the interactable elements in the boat tunnel
if ((x, y) == (4, 9) || (x, y) == (6, 8) || (x, y) == (8, 9))
{ {
return ((!Game1.MasterPlayer.hasOrWillReceiveMail("willyBoatFixed") ? "Repair " : "") + "Ticket Machine", CATEGORY.Interactables); string mail = (x, y) switch
}
else if (x == 6 && y == 8)
{ {
return ((!Game1.MasterPlayer.hasOrWillReceiveMail("willyBoatHull") ? "Repair " : "") + "Boat Hull", (!Game1.MasterPlayer.hasOrWillReceiveMail("willyBoatHull") ? CATEGORY.Interactables : CATEGORY.Decor)); (4, 9) => "willyBoatFixed",
} (6, 8) => "willyBoatHull",
else if (x == 8 && y == 9) (8, 9) => "willyBoatAnchor",
_ => throw new InvalidOperationException("Unexpected (x, y) values"),
};
string itemName = (x, y) switch
{ {
return ((!Game1.MasterPlayer.hasOrWillReceiveMail("willyBoatAnchor") ? "Repair " : "") + "Boat Anchor", (!Game1.MasterPlayer.hasOrWillReceiveMail("willyBoatAnchor") ? CATEGORY.Interactables : CATEGORY.Decor)); (4, 9) => "Ticket Machine",
(6, 8) => "Boat Hull",
(8, 9) => "Boat Anchor",
_ => throw new InvalidOperationException("Unexpected (x, y) values"),
};
CATEGORY category = (x, y) == (4, 9) ? CATEGORY.Interactables : (!HasMail(mail) ? CATEGORY.Interactables : CATEGORY.Decor);
return ((!HasMail(mail) ? "Repair " : "") + itemName, category);
} }
return (null, null); return (null, null);
@ -267,8 +278,9 @@ namespace stardew_access.Features
/// <param name="communityCenter">The CommunityCenter to search.</param> /// <param name="communityCenter">The CommunityCenter to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetCommunityCenterInfo(CommunityCenter communityCenter, int x, int y) private static (string? name, CATEGORY? category) GetCommunityCenterInfo(CommunityCenter communityCenter, int x, int y, bool lessInfo = false)
{ {
if (communityCenter.missedRewardsChestVisible.Value && x == 22 && y == 10) if (communityCenter.missedRewardsChestVisible.Value && x == 22 && y == 10)
{ {
@ -284,8 +296,9 @@ namespace stardew_access.Features
/// <param name="building">The Building instance.</param> /// <param name="building">The Building instance.</param>
/// <param name="x">The x-coordinate of the position.</param> /// <param name="x">The x-coordinate of the position.</param>
/// <param name="y">The y-coordinate of the position.</param> /// <param name="y">The y-coordinate of the position.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the door or building found, or (null, null) if no door or building is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the door or building found, or (null, null) if no door or building is found.</returns>
private static (string? name, CATEGORY? category) GetBuildingInfo(Building building, int x, int y) private static (string? name, CATEGORY? category) GetBuildingInfo(Building building, int x, int y, bool lessInfo = false)
{ {
string name = building.buildingType.Value; string name = building.buildingType.Value;
int buildingTileX = building.tileX.Value; int buildingTileX = building.tileX.Value;
@ -341,8 +354,9 @@ namespace stardew_access.Features
/// <param name="farm">The Farm to search.</param> /// <param name="farm">The Farm to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetFarmInfo(Farm farm, int x, int y) private static (string? name, CATEGORY? category) GetFarmInfo(Farm farm, int x, int y, bool lessInfo = false)
{ {
var mainMailboxPos = farm.GetMainMailboxPosition(); var mainMailboxPos = farm.GetMainMailboxPosition();
Building building = farm.getBuildingAt(new Vector2(x, y)); Building building = farm.getBuildingAt(new Vector2(x, y));
@ -353,7 +367,7 @@ namespace stardew_access.Features
} }
else if (building is not null) // Check if there is a building at the current position else if (building is not null) // Check if there is a building at the current position
{ {
return GetBuildingInfo(building, x, y); return GetBuildingInfo(building, x, y, lessInfo);
} }
return (null, null); return (null, null);
@ -365,8 +379,9 @@ namespace stardew_access.Features
/// <param name="farmHouse">The FarmHouse to search.</param> /// <param name="farmHouse">The FarmHouse to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetFarmHouseInfo(FarmHouse farmHouse, int x, int y) private static (string? name, CATEGORY? category) GetFarmHouseInfo(FarmHouse farmHouse, int x, int y, bool lessInfo = false)
{ {
if (farmHouse.upgradeLevel >= 1) if (farmHouse.upgradeLevel >= 1)
{ {
@ -396,8 +411,9 @@ namespace stardew_access.Features
/// <param name="forest">The Forest to search.</param> /// <param name="forest">The Forest to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetForestInfo(Forest forest, int x, int y) private static (string? name, CATEGORY? category) GetForestInfo(Forest forest, int x, int y, bool lessInfo = false)
{ {
if (forest.travelingMerchantDay && x == 27 && y == 11) if (forest.travelingMerchantDay && x == 27 && y == 11)
{ {
@ -421,8 +437,9 @@ namespace stardew_access.Features
/// <param name="islandFarmHouse">The IslandFarmHouse to search.</param> /// <param name="islandFarmHouse">The IslandFarmHouse to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetIslandFarmHouseInfo(IslandFarmHouse islandFarmHouse, int x, int y) private static (string? name, CATEGORY? category) GetIslandFarmHouseInfo(IslandFarmHouse islandFarmHouse, int x, int y, bool lessInfo = false)
{ {
int fridgeX = islandFarmHouse.fridgePosition.X; int fridgeX = islandFarmHouse.fridgePosition.X;
int fridgeY = islandFarmHouse.fridgePosition.Y; int fridgeY = islandFarmHouse.fridgePosition.Y;
@ -448,8 +465,9 @@ namespace stardew_access.Features
/// <param name="islandNorth">The IslandNorth to search.</param> /// <param name="islandNorth">The IslandNorth to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetIslandNorthInfo(IslandNorth islandNorth, int x, int y) private static (string? name, CATEGORY? category) GetIslandNorthInfo(IslandNorth islandNorth, int x, int y, bool lessInfo = false)
{ {
// Check if the trader is activated and the coordinates match the trader's location // Check if the trader is activated and the coordinates match the trader's location
if (islandNorth.traderActivated.Value && x == 36 && y == 71) if (islandNorth.traderActivated.Value && x == 36 && y == 71)
@ -467,8 +485,9 @@ namespace stardew_access.Features
/// <param name="islandWest">The IslandWest to search.</param> /// <param name="islandWest">The IslandWest to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetIslandWestInfo(IslandWest islandWest, int x, int y) private static (string? name, CATEGORY? category) GetIslandWestInfo(IslandWest islandWest, int x, int y, bool lessInfo = false)
{ {
// Check if the coordinates match the shipping bin's location // Check if the coordinates match the shipping bin's location
if ((islandWest.shippingBinPosition.X == x || (islandWest.shippingBinPosition.X + 1) == x) && islandWest.shippingBinPosition.Y == y) if ((islandWest.shippingBinPosition.X == x || (islandWest.shippingBinPosition.X + 1) == x) && islandWest.shippingBinPosition.Y == y)
@ -486,8 +505,11 @@ namespace stardew_access.Features
/// <param name="dungeon">The VolcanoDungeon to search.</param> /// <param name="dungeon">The VolcanoDungeon to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name of the tile and the CATEGORY, or (null, null) if no relevant tile is found.</returns> /// <returns>A tuple containing the name of the tile and the CATEGORY, or (null, null) if no relevant tile is found.</returns>
private static (string? name, CATEGORY? category) GetVolcanoDungeonInfo(VolcanoDungeon dungeon, int x, int y) private static (string? name, CATEGORY? category) GetVolcanoDungeonInfo(VolcanoDungeon dungeon, int x, int y, bool lessInfo = false)
{
if (!lessInfo)
{ {
if (dungeon.IsCooledLava(x, y)) if (dungeon.IsCooledLava(x, y))
{ {
@ -497,6 +519,7 @@ namespace stardew_access.Features
{ {
return ("Lava", CATEGORY.WaterTiles); return ("Lava", CATEGORY.WaterTiles);
} }
}
return (null, null); return (null, null);
} }
@ -507,8 +530,9 @@ namespace stardew_access.Features
/// <param name="islandLocation">The named IslandLocation to search.</param> /// <param name="islandLocation">The named IslandLocation to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetNamedIslandLocationInfo(IslandLocation islandLocation, int x, int y) private static (string? name, CATEGORY? category) GetNamedIslandLocationInfo(IslandLocation islandLocation, int x, int y, bool lessInfo = false)
{ {
object locationType = islandLocation is not null and IslandLocation ? islandLocation.Name ?? "Undefined Island Location" : islandLocation!.GetType(); object locationType = islandLocation is not null and IslandLocation ? islandLocation.Name ?? "Undefined Island Location" : islandLocation!.GetType();
@ -585,8 +609,9 @@ namespace stardew_access.Features
/// <param name="islandLocation">The IslandLocation to search.</param> /// <param name="islandLocation">The IslandLocation to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetIslandLocationInfo(IslandLocation islandLocation, int x, int y) private static (string? name, CATEGORY? category) GetIslandLocationInfo(IslandLocation islandLocation, int x, int y, bool lessInfo = false)
{ {
var nutTracker = Game1.player.team.collectedNutTracker; var nutTracker = Game1.player.team.collectedNutTracker;
string? parrot = GetParrotPerchAtTile(islandLocation, x, y); string? parrot = GetParrotPerchAtTile(islandLocation, x, y);
@ -605,10 +630,10 @@ namespace stardew_access.Features
return islandLocation switch return islandLocation switch
{ {
IslandNorth islandNorth => GetIslandNorthInfo(islandNorth, x, y), IslandNorth islandNorth => GetIslandNorthInfo(islandNorth, x, y, lessInfo),
IslandWest islandWest => GetIslandWestInfo(islandWest, x, y), IslandWest islandWest => GetIslandWestInfo(islandWest, x, y, lessInfo),
VolcanoDungeon dungeon => GetVolcanoDungeonInfo(dungeon, x, y), VolcanoDungeon dungeon => GetVolcanoDungeonInfo(dungeon, x, y, lessInfo),
_ => GetNamedIslandLocationInfo(islandLocation, x, y) _ => GetNamedIslandLocationInfo(islandLocation, x, y, lessInfo)
}; };
} }
@ -618,8 +643,9 @@ namespace stardew_access.Features
/// <param name="libraryMuseum">The LibraryMuseum containing the tile.</param> /// <param name="libraryMuseum">The LibraryMuseum containing the tile.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>The value of the "Action" property as a string, or null if the property is not found.</returns> /// <returns>The value of the "Action" property as a string, or null if the property is not found.</returns>
private static string? GetTileActionPropertyValue(LibraryMuseum libraryMuseum, int x, int y) private static string? GetTileActionPropertyValue(LibraryMuseum libraryMuseum, int x, int y, bool lessInfo = false)
{ {
xTile.Tiles.Tile tile = libraryMuseum.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location(x * 64, y * 64), Game1.viewport.Size); xTile.Tiles.Tile tile = libraryMuseum.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location(x * 64, y * 64), Game1.viewport.Size);
return tile.Properties.TryGetValue("Action", out xTile.ObjectModel.PropertyValue? value) ? value.ToString() : null; return tile.Properties.TryGetValue("Action", out xTile.ObjectModel.PropertyValue? value) ? value.ToString() : null;
@ -631,8 +657,9 @@ namespace stardew_access.Features
/// <param name="libraryMuseum">The LibraryMuseum to search.</param> /// <param name="libraryMuseum">The LibraryMuseum to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetLibraryMuseumInfo(LibraryMuseum libraryMuseum, int x, int y) private static (string? name, CATEGORY? category) GetLibraryMuseumInfo(LibraryMuseum libraryMuseum, int x, int y, bool lessInfo = false)
{ {
if (libraryMuseum.museumPieces.TryGetValue(new Vector2(x, y), out int museumPiece)) if (libraryMuseum.museumPieces.TryGetValue(new Vector2(x, y), out int museumPiece))
{ {
@ -644,7 +671,7 @@ namespace stardew_access.Features
string? action = libraryMuseum.doesTileHaveProperty(x, y, "Action", "Buildings"); string? action = libraryMuseum.doesTileHaveProperty(x, y, "Action", "Buildings");
if (action != null && action.Contains("Notes")) if (action != null && action.Contains("Notes"))
{ {
string? actionPropertyValue = GetTileActionPropertyValue(libraryMuseum, x, y); string? actionPropertyValue = GetTileActionPropertyValue(libraryMuseum, x, y, lessInfo);
if (actionPropertyValue != null) if (actionPropertyValue != null)
{ {
@ -667,8 +694,9 @@ namespace stardew_access.Features
/// <param name="town">The Town to search.</param> /// <param name="town">The Town to search.</param>
/// <param name="x">The x-coordinate to search.</param> /// <param name="x">The x-coordinate to search.</param>
/// <param name="y">The y-coordinate to search.</param> /// <param name="y">The y-coordinate to search.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns> /// <returns>A tuple containing the name and CATEGORY of the object found, or (null, null) if no relevant object is found.</returns>
private static (string? name, CATEGORY? category) GetTownInfo(Town town, int x, int y) private static (string? name, CATEGORY? category) GetTownInfo(Town town, int x, int y, bool lessInfo = false)
{ {
if (SpecialOrder.IsSpecialOrdersBoardUnlocked() && x == 62 && y == 93) if (SpecialOrder.IsSpecialOrdersBoardUnlocked() && x == 62 && y == 93)
{ {
@ -684,14 +712,15 @@ namespace stardew_access.Features
/// <param name="currentLocation">The current GameLocation instance.</param> /// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x coordinate of the tile.</param> /// <param name="x">The x coordinate of the tile.</param>
/// <param name="y">The y coordinate of the tile.</param> /// <param name="y">The y coordinate of the tile.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple of (string? name, CATEGORY? category) for the feeding bench, or null if not applicable.</returns> /// <returns>A tuple of (string? name, CATEGORY? category) for the feeding bench, or null if not applicable.</returns>
private static (string? name, CATEGORY? category)? GetFeedingBenchInfo(GameLocation currentLocation, int x, int y) private static (string? name, CATEGORY? category)? GetFeedingBenchInfo(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
string locationName = currentLocation.Name; string locationName = currentLocation.Name;
if (FeedingBenchBounds.TryGetValue(locationName, out var bounds) && x >= bounds.minX && x <= bounds.maxX && y == bounds.y) if (FeedingBenchBounds.TryGetValue(locationName, out var bounds) && x >= bounds.minX && x <= bounds.maxX && y == bounds.y)
{ {
(string? name, CATEGORY category) = TileInfo.getObjectAtTile(x, y, currentLocation, true); (string? name, CATEGORY category) = TileInfo.getObjectAtTile(currentLocation, x, y, true);
return (name?.Contains("hay", StringComparison.OrdinalIgnoreCase) == true ? "Feeding Bench" : "Empty Feeding Bench", category); return (name?.Contains("hay", StringComparison.OrdinalIgnoreCase) == true ? "Feeding Bench" : "Empty Feeding Bench", category);
} }
@ -704,8 +733,9 @@ namespace stardew_access.Features
/// <param name="currentLocation">The current GameLocation instance.</param> /// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x coordinate of the tile.</param> /// <param name="x">The x coordinate of the tile.</param>
/// <param name="y">The y coordinate of the tile.</param> /// <param name="y">The y coordinate of the tile.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns>A tuple of (string? name, CATEGORY? category) for the object in the location, or null if not applicable.</returns> /// <returns>A tuple of (string? name, CATEGORY? category) for the object in the location, or null if not applicable.</returns>
private static (string? name, CATEGORY? category) GetLocationByNameInfo(GameLocation currentLocation, int x, int y) private static (string? name, CATEGORY? category) GetLocationByNameInfo(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
object locationType = currentLocation is not null and GameLocation ? currentLocation.Name ?? "Undefined GameLocation" : currentLocation!.GetType(); string locationName = currentLocation.Name ?? ""; object locationType = currentLocation is not null and GameLocation ? currentLocation.Name ?? "Undefined GameLocation" : currentLocation!.GetType(); string locationName = currentLocation.Name ?? "";
if (locationName.Contains("coop", StringComparison.OrdinalIgnoreCase) || locationName.Contains("barn", StringComparison.OrdinalIgnoreCase)) if (locationName.Contains("coop", StringComparison.OrdinalIgnoreCase) || locationName.Contains("barn", StringComparison.OrdinalIgnoreCase))
@ -734,12 +764,12 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Retrieves the dynamic tile information for the given coordinates in the specified location. /// Retrieves the dynamic tile information for the given coordinates in the specified location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="lessInfo">An optional boolean to return less detailed information. Defaults to false.</param> /// <param name="lessInfo">An optional boolean to return less detailed information. Defaults to false.</param>
/// <returns>A tuple containing the name and CATEGORY of the dynamic tile, or null values if not found.</returns> /// <returns>A tuple containing the name and CATEGORY of the dynamic tile, or null values if not found.</returns>
public static (string? name, CATEGORY? category) GetDynamicTileAt(int x, int y, GameLocation currentLocation, bool lessInfo = false) public static (string? name, CATEGORY? category) GetDynamicTileAt(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
// Check for panning spots // Check for panning spots
if (currentLocation.orePanPoint.Value != Point.Zero && currentLocation.orePanPoint.Value == new Point(x, y)) if (currentLocation.orePanPoint.Value != Point.Zero && currentLocation.orePanPoint.Value == new Point(x, y))
@ -765,17 +795,17 @@ namespace stardew_access.Features
// Retrieve dynamic tile information based on the current location type // Retrieve dynamic tile information based on the current location type
return currentLocation switch return currentLocation switch
{ {
Beach beach => GetBeachInfo(beach, x, y), Beach beach => GetBeachInfo(beach, x, y, lessInfo),
BoatTunnel boatTunnel => GetBoatTunnelInfo(boatTunnel, x, y), BoatTunnel boatTunnel => GetBoatTunnelInfo(boatTunnel, x, y, lessInfo),
CommunityCenter communityCenter => GetCommunityCenterInfo(communityCenter, x, y), CommunityCenter communityCenter => GetCommunityCenterInfo(communityCenter, x, y, lessInfo),
Farm farm => GetFarmInfo(farm, x, y), Farm farm => GetFarmInfo(farm, x, y, lessInfo),
FarmHouse farmHouse => GetFarmHouseInfo(farmHouse, x, y), FarmHouse farmHouse => GetFarmHouseInfo(farmHouse, x, y, lessInfo),
Forest forest => GetForestInfo(forest, x, y), Forest forest => GetForestInfo(forest, x, y, lessInfo),
IslandFarmHouse islandFarmHouse => GetIslandFarmHouseInfo(islandFarmHouse, x, y), IslandFarmHouse islandFarmHouse => GetIslandFarmHouseInfo(islandFarmHouse, x, y, lessInfo),
IslandLocation islandLocation => GetIslandLocationInfo(islandLocation, x, y), IslandLocation islandLocation => GetIslandLocationInfo(islandLocation, x, y, lessInfo),
LibraryMuseum libraryMuseum => GetLibraryMuseumInfo(libraryMuseum, x, y), LibraryMuseum libraryMuseum => GetLibraryMuseumInfo(libraryMuseum, x, y, lessInfo),
Town town => GetTownInfo(town, x, y), Town town => GetTownInfo(town, x, y, lessInfo),
_ => GetLocationByNameInfo(currentLocation, x, y) _ => GetLocationByNameInfo(currentLocation, x, y, lessInfo)
}; };
} }
} }

View File

@ -178,7 +178,7 @@ namespace stardew_access.Features
{ {
Vector2 dir = new(item.X + dirX[i], item.Y + dirY[i]); Vector2 dir = new(item.X + dirX[i], item.Y + dirY[i]);
if (!searched.Contains(dir) && (TileInfo.isWarpPointAtTile((int)dir.X, (int)dir.Y, currentLocation) || currentLocation.isTileOnMap(dir))) if (!searched.Contains(dir) && (TileInfo.isWarpPointAtTile(currentLocation, (int)dir.X, (int)dir.Y) || currentLocation.isTileOnMap(dir)))
{ {
toSearch.Enqueue(dir); toSearch.Enqueue(dir);
searched.Add(dir); searched.Add(dir);
@ -231,7 +231,7 @@ namespace stardew_access.Features
{ {
if (currentLocation.isObjectAtTile((int)position.X, (int)position.Y)) if (currentLocation.isObjectAtTile((int)position.X, (int)position.Y))
{ {
(string? name, CATEGORY category) objDetails = TileInfo.getObjectAtTile((int)position.X, (int)position.Y, currentLocation); (string? name, CATEGORY category) objDetails = TileInfo.getObjectAtTile(currentLocation, (int)position.X, (int)position.Y);
string? objectName = objDetails.name; string? objectName = objDetails.name;
CATEGORY category = objDetails.category; CATEGORY category = objDetails.category;
StardewValley.Object obj = currentLocation.getObjectAtTile((int)position.X, (int)position.Y); StardewValley.Object obj = currentLocation.getObjectAtTile((int)position.X, (int)position.Y);

View File

@ -90,7 +90,7 @@ namespace stardew_access.Features
} }
var currentLocation = Game1.currentLocation; var currentLocation = Game1.currentLocation;
bool isColliding = TileInfo.IsCollidingAtTile(x, y, currentLocation); bool isColliding = TileInfo.IsCollidingAtTile(currentLocation, x, y);
(string? name, string? category) info = TileInfo.getNameWithCategoryNameAtTile(tile, currentLocation); (string? name, string? category) info = TileInfo.getNameWithCategoryNameAtTile(tile, currentLocation);

View File

@ -71,7 +71,7 @@ namespace stardew_access.Features
return (staticTile.name, staticTile.category); return (staticTile.name, staticTile.category);
} }
(string? name, CATEGORY? category) dynamicTile = DynamicTiles.GetDynamicTileAt(x, y, currentLocation, lessInfo); (string? name, CATEGORY? category) dynamicTile = DynamicTiles.GetDynamicTileAt(currentLocation, x, y, lessInfo);
if (dynamicTile.name != null) if (dynamicTile.name != null)
{ {
return (dynamicTile.name, dynamicTile.category); return (dynamicTile.name, dynamicTile.category);
@ -79,16 +79,16 @@ namespace stardew_access.Features
if (currentLocation.isObjectAtTile(x, y)) if (currentLocation.isObjectAtTile(x, y))
{ {
(string? name, CATEGORY? category) obj = getObjectAtTile(x, y, currentLocation, lessInfo); (string? name, CATEGORY? category) obj = getObjectAtTile(currentLocation, x, y, lessInfo);
return (obj.name, obj.category); return (obj.name, obj.category);
} }
if (currentLocation.isWaterTile(x, y) && !lessInfo && IsCollidingAtTile(x, y, currentLocation)) if (currentLocation.isWaterTile(x, y) && !lessInfo && IsCollidingAtTile(currentLocation, x, y))
{ {
return ("Water", CATEGORY.WaterTiles); return ("Water", CATEGORY.WaterTiles);
} }
string? resourceClump = getResourceClumpAtTile(x, y, currentLocation, lessInfo); string? resourceClump = getResourceClumpAtTile(currentLocation, x, y, lessInfo);
if (resourceClump != null) if (resourceClump != null)
{ {
return (resourceClump, CATEGORY.ResourceClumps); return (resourceClump, CATEGORY.ResourceClumps);
@ -103,20 +103,20 @@ namespace stardew_access.Features
} }
} }
string? bush = GetBushAtTile(x, y, currentLocation, lessInfo); string? bush = GetBushAtTile(currentLocation, x, y, lessInfo);
if (bush != null) if (bush != null)
{ {
return (bush, CATEGORY.Bush); return (bush, CATEGORY.Bush);
} }
string? door = getDoorAtTile(x, y, currentLocation); string? door = getDoorAtTile(currentLocation, x, y);
string? warp = getWarpPointAtTile(x, y, currentLocation); string? warp = getWarpPointAtTile(currentLocation, x, y);
if (warp != null || door != null) if (warp != null || door != null)
{ {
return (warp ?? door, CATEGORY.Doors); return (warp ?? door, CATEGORY.Doors);
} }
string? junimoBundle = GetJunimoBundleAt(x, y, currentLocation); string? junimoBundle = GetJunimoBundleAt(currentLocation, x, y);
if (junimoBundle != null) if (junimoBundle != null)
{ {
return (junimoBundle, CATEGORY.JunimoBundle); return (junimoBundle, CATEGORY.JunimoBundle);
@ -150,12 +150,12 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Gets the bush at the specified tile coordinates in the provided GameLocation. /// Gets the bush at the specified tile coordinates in the provided GameLocation.
/// </summary> /// </summary>
/// <param name="currentLocation">The GameLocation instance to search for bushes.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="currentLocation">The GameLocation instance to search for bushes.</param>
/// <param name="lessInfo">Whether to return less information about the bush.</param> /// <param name="lessInfo">Whether to return less information about the bush.</param>
/// <returns>A string describing the bush if one is found at the specified coordinates, otherwise null.</returns> /// <returns>A string describing the bush if one is found at the specified coordinates, otherwise null.</returns>
public static string? GetBushAtTile(int x, int y, GameLocation currentLocation, bool lessInfo = false) public static string? GetBushAtTile(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
Bush? bush = (Bush)currentLocation.getLargeTerrainFeatureAt(x, y); Bush? bush = (Bush)currentLocation.getLargeTerrainFeatureAt(x, y);
@ -201,11 +201,11 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Determines if there is a Junimo bundle at the specified tile coordinates in the provided GameLocation. /// Determines if there is a Junimo bundle at the specified tile coordinates in the provided GameLocation.
/// </summary> /// </summary>
/// <param name="currentLocation">The GameLocation instance to search for Junimo bundles.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="currentLocation">The GameLocation instance to search for Junimo bundles.</param>
/// <returns>The name of the Junimo bundle if one is found at the specified coordinates, otherwise null.</returns> /// <returns>The name of the Junimo bundle if one is found at the specified coordinates, otherwise null.</returns>
public static string? GetJunimoBundleAt(int x, int y, GameLocation currentLocation) public static string? GetJunimoBundleAt(GameLocation currentLocation, int x, int y)
{ {
if (currentLocation is CommunityCenter communityCenter) if (currentLocation is CommunityCenter communityCenter)
{ {
@ -246,25 +246,25 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Determines if there is a collision at the specified tile coordinates in the provided GameLocation. /// Determines if there is a collision at the specified tile coordinates in the provided GameLocation.
/// </summary> /// </summary>
/// <param name="currentLocation">The GameLocation instance to search for collisions.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="currentLocation">The GameLocation instance to search for collisions.</param>
/// <returns>True if a collision is detected at the specified tile coordinates, otherwise False.</returns> /// <returns>True if a collision is detected at the specified tile coordinates, otherwise False.</returns>
public static bool IsCollidingAtTile(int x, int y, GameLocation currentLocation) public static bool IsCollidingAtTile(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
// This function highly optimized over readability because `currentLocation.isCollidingPosition` takes ~30ms on the Farm map, more on larger maps I.E. Forest. // This function highly optimized over readability because `currentLocation.isCollidingPosition` takes ~30ms on the Farm map, more on larger maps I.E. Forest.
// Return the result of the logical comparison directly, inlining operations // Return the result of the logical comparison directly, inlining operations
// Check if the tile is NOT a warp point and if it collides with an object or terrain feature // Check if the tile is NOT a warp point and if it collides with an object or terrain feature
// OR if the tile has stumps in a Woods location // OR if the tile has stumps in a Woods location
return !isWarpPointAtTile(x, y, currentLocation) && return !isWarpPointAtTile(currentLocation, x, y) &&
(currentLocation.isCollidingPosition(new Rectangle(x * 64 + 1, y * 64 + 1, 62, 62), Game1.viewport, true, 0, glider: false, Game1.player, pathfinding: true) || (currentLocation.isCollidingPosition(new Rectangle(x * 64 + 1, y * 64 + 1, 62, 62), Game1.viewport, true, 0, glider: false, Game1.player, pathfinding: true) ||
(currentLocation is Woods woods && getStumpsInWoods(x, y, woods) is not null)); (currentLocation is Woods woods && getStumpsInWoods(woods, x, y, lessInfo) is not null));
} }
/// <summary> /// <summary>
/// Returns the Warp object at the specified tile coordinates or null if not found. /// Returns the Warp object at the specified tile coordinates or null if not found.
/// </summary> /// </summary>
private static Warp? GetWarpAtTile(int x, int y, GameLocation currentLocation) private static Warp? GetWarpAtTile(GameLocation currentLocation, int x, int y)
{ {
if (currentLocation is null) return null; if (currentLocation is null) return null;
@ -281,13 +281,13 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Returns the name of the warp point at the specified tile coordinates, or null if not found. /// Returns the name of the warp point at the specified tile coordinates, or null if not found.
/// </summary> /// </summary>
public static string? getWarpPointAtTile(int x, int y, GameLocation currentLocation) public static string? getWarpPointAtTile(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
Warp? warpPoint = GetWarpAtTile(x, y, currentLocation); Warp? warpPoint = GetWarpAtTile(currentLocation, x, y);
if (warpPoint != null) if (warpPoint != null)
{ {
return $"{warpPoint.TargetName} Entrance"; return lessInfo ? warpPoint.TargetName : $"{warpPoint.TargetName} Entrance";
} }
return null; return null;
@ -296,9 +296,9 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Returns true if there's a warp point at the specified tile coordinates, or false otherwise. /// Returns true if there's a warp point at the specified tile coordinates, or false otherwise.
/// </summary> /// </summary>
public static bool isWarpPointAtTile(int x, int y, GameLocation currentLocation) public static bool isWarpPointAtTile(GameLocation currentLocation, int x, int y)
{ {
return GetWarpAtTile(x, y, currentLocation) != null; return GetWarpAtTile(currentLocation, x, y) != null;
} }
/// <summary> /// <summary>
@ -311,7 +311,7 @@ namespace stardew_access.Features
/// A string containing the farm animal's name, type, and age if a farm animal is found at the specified tile; /// A string containing the farm animal's name, type, and age if a farm animal is found at the specified tile;
/// null if no farm animal is found or if the location is not a Farm or an AnimalHouse. /// null if no farm animal is found or if the location is not a Farm or an AnimalHouse.
/// </returns> /// </returns>
public static string? getFarmAnimalAt(GameLocation? location, int x, int y) public static string? getFarmAnimalAt(GameLocation location, int x, int y)
{ {
// Return null if the location is null or not a Farm or AnimalHouse // Return null if the location is null or not a Farm or AnimalHouse
if (location is null || !(location is Farm || location is AnimalHouse)) if (location is null || !(location is Farm || location is AnimalHouse))
@ -563,12 +563,12 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Retrieves the name and category of an object at a specific tile in the game location. /// Retrieves the name and category of an object at a specific tile in the game location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current game location.</param>
/// <param name="x">The X coordinate of the tile.</param> /// <param name="x">The X coordinate of the tile.</param>
/// <param name="y">The Y coordinate of the tile.</param> /// <param name="y">The Y coordinate of the tile.</param>
/// <param name="currentLocation">The current game location.</param>
/// <param name="lessInfo">An optional parameter to display less information, set to false by default.</param> /// <param name="lessInfo">An optional parameter to display less information, set to false by default.</param>
/// <returns>A tuple containing the object's name and category.</returns> /// <returns>A tuple containing the object's name and category.</returns>
public static (string? name, CATEGORY category) getObjectAtTile(int x, int y, GameLocation currentLocation, bool lessInfo = false) public static (string? name, CATEGORY category) getObjectAtTile(GameLocation currentLocation, int x, int y, bool lessInfo = false)
{ {
(string? name, CATEGORY category) toReturn = (null, CATEGORY.Others); (string? name, CATEGORY category) toReturn = (null, CATEGORY.Others);
@ -783,12 +783,12 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Check if a tile with the specified index exists at the given coordinates in the specified location. /// Check if a tile with the specified index exists at the given coordinates in the specified location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current game location.</param>
/// <param name="x">The X coordinate of the tile.</param> /// <param name="x">The X coordinate of the tile.</param>
/// <param name="y">The Y coordinate of the tile.</param> /// <param name="y">The Y coordinate of the tile.</param>
/// <param name="currentLocation">The current game location.</param>
/// <param name="targetTileIndex">The target tile index to check for.</param> /// <param name="targetTileIndex">The target tile index to check for.</param>
/// <returns>True if a tile with the specified index exists at the given coordinates, false otherwise.</returns> /// <returns>True if a tile with the specified index exists at the given coordinates, false otherwise.</returns>
private static bool CheckTileIndex(int x, int y, GameLocation currentLocation, int targetTileIndex) private static bool CheckTileIndex(GameLocation currentLocation, int x, int y, int targetTileIndex)
{ {
var tile = currentLocation.Map.GetLayer("Buildings").Tiles[x, y]; var tile = currentLocation.Map.GetLayer("Buildings").Tiles[x, y];
return tile != null && tile.TileIndex == targetTileIndex; return tile != null && tile.TileIndex == targetTileIndex;
@ -797,70 +797,67 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Determines if a mine down ladder is present at the specified tile location. /// Determines if a mine down ladder is present at the specified tile location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <returns>True if a mine down ladder is found at the specified tile, otherwise false.</returns> /// <returns>True if a mine down ladder is found at the specified tile, otherwise false.</returns>
public static bool isMineDownLadderAtTile(int x, int y, GameLocation currentLocation) public static bool isMineDownLadderAtTile(GameLocation currentLocation, int x, int y)
{ {
return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave" return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave"
? CheckTileIndex(x, y, currentLocation, 173) ? CheckTileIndex(currentLocation, x, y, 173)
: false; : false;
} }
/// <summary> /// <summary>
/// Determines if a mine shaft is present at the specified tile location. /// Determines if a mine shaft is present at the specified tile location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <returns>True if a mine shaft is found at the specified tile, otherwise false.</returns> /// <returns>True if a mine shaft is found at the specified tile, otherwise false.</returns>
public static bool isShaftAtTile(int x, int y, GameLocation currentLocation) public static bool isShaftAtTile(GameLocation currentLocation, int x, int y)
{ {
return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave" return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave"
? CheckTileIndex(x, y, currentLocation, 174) ? CheckTileIndex(currentLocation, x, y, 174)
: false; : false;
} }
/// <summary> /// <summary>
/// Determines if a mine up ladder is present at the specified tile location. /// Determines if a mine up ladder is present at the specified tile location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <returns>True if a mine up ladder is found at the specified tile, otherwise false.</returns> /// <returns>True if a mine up ladder is found at the specified tile, otherwise false.</returns>
public static bool isMineUpLadderAtTile(int x, int y, GameLocation currentLocation) public static bool isMineUpLadderAtTile(GameLocation currentLocation, int x, int y)
{ {
return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave" return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave"
? CheckTileIndex(x, y, currentLocation, 115) ? CheckTileIndex(currentLocation, x, y, 115)
: false; : false;
} }
/// <summary> /// <summary>
/// Determines if an elevator is present at the specified tile location. /// Determines if an elevator is present at the specified tile location.
/// </summary> /// </summary>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <param name="x">The x-coordinate of the tile.</param> /// <param name="x">The x-coordinate of the tile.</param>
/// <param name="y">The y-coordinate of the tile.</param> /// <param name="y">The y-coordinate of the tile.</param>
/// <param name="currentLocation">The current GameLocation instance.</param>
/// <returns>True if an elevator is found at the specified tile, otherwise false.</returns> /// <returns>True if an elevator is found at the specified tile, otherwise false.</returns>
public static bool isElevatorAtTile(int x, int y, GameLocation currentLocation) public static bool isElevatorAtTile(GameLocation currentLocation, int x, int y)
{ {
return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave" return currentLocation is Mine or MineShaft || currentLocation.Name == "SkullCave"
? CheckTileIndex(x, y, currentLocation, 112) ? CheckTileIndex(currentLocation, x, y, 112)
: false; : false;
} }
/// <summary> /// <summary>
/// Gets the door information at the specified tile coordinates in the given location. /// Gets the door information at the specified tile coordinates in the given location.
/// </summary> /// </summary>
/// <param name="currentLocation">The GameLocation where the door might be found.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="currentLocation">The GameLocation where the door might be found.</param> /// <returns>A string containing the door information if a door is found at the specified tile; null if no door is found.</returns>
/// <returns> public static string? getDoorAtTile(GameLocation currentLocation, int x, int y)
/// A string containing the door information if a door is found at the specified tile;
/// null if no door is found.
/// </returns>
public static string? getDoorAtTile(int x, int y, GameLocation currentLocation)
{ {
// Create a Point object from the given tile coordinates // Create a Point object from the given tile coordinates
Point tilePoint = new(x, y); Point tilePoint = new(x, y);
@ -882,19 +879,16 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Gets the resource clump information at the specified tile coordinates in the given location. /// Gets the resource clump information at the specified tile coordinates in the given location.
/// </summary> /// </summary>
/// <param name="currentLocation">The GameLocation where the resource clump might be found.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="currentLocation">The GameLocation where the resource clump might be found.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param> /// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the resource clump's origin. Default is false.</param>
/// <returns> /// <returns>A string containing the resource clump information if a resource clump is found at the specified tile; null if no resource clump is found.</returns>
/// A string containing the resource clump information if a resource clump is found at the specified tile; public static string? getResourceClumpAtTile(GameLocation currentLocation, int x, int y, bool lessInfo = false)
/// null if no resource clump is found.
/// </returns>
public static string? getResourceClumpAtTile(int x, int y, GameLocation currentLocation, bool lessInfo = false)
{ {
// Check if the current location is Woods and handle stumps in woods separately // Check if the current location is Woods and handle stumps in woods separately
if (currentLocation is Woods woods) if (currentLocation is Woods woods)
return getStumpsInWoods(x, y, woods, lessInfo); return getStumpsInWoods(woods, x, y, lessInfo);
// Iterate through resource clumps in the location using a for loop for performance reasons // Iterate through resource clumps in the location using a for loop for performance reasons
for (int i = 0, count = currentLocation.resourceClumps.Count; i < count; i++) for (int i = 0, count = currentLocation.resourceClumps.Count; i < count; i++)
@ -916,15 +910,12 @@ namespace stardew_access.Features
/// <summary> /// <summary>
/// Gets the stump information at the specified tile coordinates in the given Woods location. /// Gets the stump information at the specified tile coordinates in the given Woods location.
/// </summary> /// </summary>
/// <param name="woods">The Woods location where the stump might be found.</param>
/// <param name="x">The x-coordinate of the tile to check.</param> /// <param name="x">The x-coordinate of the tile to check.</param>
/// <param name="y">The y-coordinate of the tile to check.</param> /// <param name="y">The y-coordinate of the tile to check.</param>
/// <param name="woods">The Woods location where the stump might be found.</param>
/// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the stump's origin. Default is false.</param> /// <param name="lessInfo">Optional. If true, returns information only if the tile coordinates match the stump's origin. Default is false.</param>
/// <returns> /// <returns>A string containing the stump information if a stump is found at the specified tile; null if no stump is found.</returns>
/// A string containing the stump information if a stump is found at the specified tile; public static string? getStumpsInWoods(Woods woods, int x, int y, bool lessInfo = false)
/// null if no stump is found.
/// </returns>
public static string? getStumpsInWoods(int x, int y, Woods woods, bool lessInfo = false)
{ {
// Iterate through stumps in the Woods location // Iterate through stumps in the Woods location
foreach (var stump in woods.stumps) foreach (var stump in woods.stumps)

View File

@ -184,7 +184,7 @@ namespace stardew_access.Features
if (name == null) if (name == null)
{ {
// Report if a tile is empty or blocked if there is nothing on it // Report if a tile is empty or blocked if there is nothing on it
if (TileInfo.IsCollidingAtTile((int)tile.X, (int)tile.Y, Game1.currentLocation)) if (TileInfo.IsCollidingAtTile(Game1.currentLocation, (int)tile.X, (int)tile.Y))
{ {
name = "blocked"; name = "blocked";
} }
@ -280,7 +280,7 @@ namespace stardew_access.Features
{ {
var currentLocation = Game1.currentLocation; var currentLocation = Game1.currentLocation;
// 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 // 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), currentLocation)) return true; if (TileInfo.isWarpPointAtTile(currentLocation, (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. //position does not take viewport into account since the entire map needs to be checked.
Map map = currentLocation.map; Map map = currentLocation.map;

View File

@ -34,7 +34,7 @@ namespace stardew_access.Patches
if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep")
{ {
Vector2 nextTile = CurrentPlayer.FacingTile; Vector2 nextTile = CurrentPlayer.FacingTile;
if (TileInfo.IsCollidingAtTile((int)nextTile.X, (int)nextTile.Y, Game1.currentLocation)) if (TileInfo.IsCollidingAtTile(Game1.currentLocation, (int)nextTile.X, (int)nextTile.Y))
{ {
if (prevTile != nextTile) if (prevTile != nextTile)
{ {