Added ability to add entries specific to a certain farm type.
The entries with 'farm' name will be applied to all farm types and if we want to add an entry specific to a farm type, like to beach farm layout, we can use 'farm_beach' name for this.master
parent
016eb87f7d
commit
434921a668
|
@ -77,18 +77,17 @@ namespace stardew_access.Features
|
||||||
return getStaticTileInfoAtWithCategory(x, y).name;
|
return getStaticTileInfoAtWithCategory(x, y).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public (string? name, CATEGORY category) getStaticTileInfoAtWithCategory(int x, int y)
|
public (string? name, CATEGORY category) getStaticTileInfoAtWithCategory(int x, int y) {
|
||||||
{
|
|
||||||
List<JObject> allData = new List<JObject>();
|
List<JObject> allData = new List<JObject>();
|
||||||
|
|
||||||
if (customTilesData != null) allData.Add(customTilesData);
|
if (customTilesData != null) allData.Add(customTilesData);
|
||||||
if (staticTilesData != null) allData.Add(staticTilesData);
|
if (staticTilesData != null) allData.Add(staticTilesData);
|
||||||
|
|
||||||
foreach (JObject data in allData)
|
foreach (JObject data in allData) {
|
||||||
{
|
|
||||||
foreach (KeyValuePair<string, JToken?> location in data)
|
foreach (KeyValuePair<string, JToken?> location in data)
|
||||||
{
|
{
|
||||||
if (location.Key.Contains("||") && MainClass.ModHelper != null)
|
string locationName = location.Key;
|
||||||
|
if (locationName.Contains("||") && MainClass.ModHelper != null)
|
||||||
{
|
{
|
||||||
// Mod Specific Tiles
|
// Mod Specific Tiles
|
||||||
// We can add tiles that only get detected when the specified mod is loaded.
|
// We can add tiles that only get detected when the specified mod is loaded.
|
||||||
|
@ -109,20 +108,28 @@ namespace stardew_access.Features
|
||||||
// .
|
// .
|
||||||
// .
|
// .
|
||||||
// }
|
// }
|
||||||
string uniqueModID = location.Key.Substring(location.Key.LastIndexOf("||") + 2);
|
string uniqueModID = locationName.Substring(locationName.LastIndexOf("||") + 2);
|
||||||
string locationName = location.Key.Remove(location.Key.LastIndexOf("||"));
|
locationName = locationName.Remove(locationName.LastIndexOf("||"));
|
||||||
bool isLoaded = MainClass.ModHelper.ModRegistry.IsLoaded(uniqueModID);
|
bool isLoaded = MainClass.ModHelper.ModRegistry.IsLoaded(uniqueModID);
|
||||||
|
|
||||||
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
if (!isLoaded) continue; // Skip if the specified mod is not loaded
|
||||||
if (!Game1.currentLocation.Name.ToLower().Equals(locationName.ToLower())) continue;
|
|
||||||
}
|
}
|
||||||
else if (!Game1.currentLocation.Name.ToLower().Equals(location.Key.ToLower())) continue;
|
|
||||||
|
|
||||||
if (location.Value != null)
|
if (locationName.Contains("_") && locationName.ToLower().StartsWith("farm_"))
|
||||||
|
{
|
||||||
|
string farmType = locationName.Substring(locationName.LastIndexOf("_") + 1);
|
||||||
|
int farmTypeIndex = getFarmTypeIndex(farmType);
|
||||||
|
locationName = locationName.Remove(locationName.LastIndexOf("_"));
|
||||||
|
|
||||||
|
if (farmTypeIndex != Game1.whichFarm) continue; // Skip if current farm type does not matches
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Game1.currentLocation.Name.ToLower().Equals(locationName.ToLower())) continue;
|
||||||
|
if (location.Value == null) continue;
|
||||||
|
|
||||||
foreach (var tile in ((JObject)location.Value))
|
foreach (var tile in ((JObject)location.Value))
|
||||||
{
|
{
|
||||||
if (tile.Value == null)
|
if (tile.Value == null) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
JToken? tileXArray = tile.Value["x"];
|
JToken? tileXArray = tile.Value["x"];
|
||||||
JToken? tileYArray = tile.Value["y"];
|
JToken? tileYArray = tile.Value["y"];
|
||||||
|
@ -136,21 +143,21 @@ namespace stardew_access.Features
|
||||||
|
|
||||||
foreach (var item in tileXArray)
|
foreach (var item in tileXArray)
|
||||||
{
|
{
|
||||||
if (short.Parse(item.ToString()) == x)
|
if (short.Parse(item.ToString()) != x)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
isXPresent = true;
|
isXPresent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in tileYArray)
|
foreach (var item in tileYArray)
|
||||||
{
|
{
|
||||||
if (short.Parse(item.ToString()) == y)
|
if (short.Parse(item.ToString()) != y)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
isYPresent = true;
|
isYPresent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (isXPresent && isYPresent)
|
if (isXPresent && isYPresent)
|
||||||
{
|
{
|
||||||
|
@ -173,5 +180,20 @@ namespace stardew_access.Features
|
||||||
}
|
}
|
||||||
return (null, CATEGORY.Others);
|
return (null, CATEGORY.Others);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getFarmTypeIndex(string farmType)
|
||||||
|
{
|
||||||
|
return farmType.ToLower() switch
|
||||||
|
{
|
||||||
|
"default" => 0,
|
||||||
|
"riverlands" => 1,
|
||||||
|
"forest" => 2,
|
||||||
|
"mountains" => 3,
|
||||||
|
"combat" => 4,
|
||||||
|
"fourcorners" => 5,
|
||||||
|
"beach" => 6,
|
||||||
|
_ => 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue