Added animal narration | Bug fix in location narration
parent
29cd44f31f
commit
e916e27427
|
@ -99,6 +99,12 @@ namespace stardew_access.Game
|
|||
playSoundAt(position, npc.displayName, typeof(NPC));
|
||||
}
|
||||
}
|
||||
// Check for animals
|
||||
else if (ReadTile.getFarmAnimalAt(Game1.currentLocation, (int)position.X, (int)position.Y) != null && !exclusions.Contains("animals"))
|
||||
{
|
||||
string name = ReadTile.getFarmAnimalAt(Game1.currentLocation, (int)position.X, (int)position.Y, onlyName: true);
|
||||
playSoundAt(position, name, typeof(FarmAnimal));
|
||||
}
|
||||
// Check for water
|
||||
else if (Game1.currentLocation.isWaterTile((int)position.X, (int)position.Y) && !exclusions.Contains("water"))
|
||||
{
|
||||
|
@ -247,6 +253,8 @@ namespace stardew_access.Game
|
|||
|
||||
if(soundType == typeof(Farmer)) // Villagers and farmers
|
||||
soundName = $"npc{soundName}";
|
||||
if (soundType == typeof(FarmAnimal)) // Farm Animals
|
||||
soundName = $"npc{soundName}";
|
||||
else if(soundType == typeof(NPC)) // Other npcs, also includes enemies
|
||||
soundName = $"obj{soundName}";
|
||||
else if(soundType == typeof(WaterTiles)) // Water tiles
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Locations;
|
||||
using StardewValley.Objects;
|
||||
using StardewValley.TerrainFeatures;
|
||||
|
||||
namespace stardew_access.Game
|
||||
|
@ -44,6 +45,10 @@ namespace stardew_access.Game
|
|||
NPC npc = Game1.currentLocation.isCharacterAtTile(gt);
|
||||
toSpeak = npc.displayName;
|
||||
}
|
||||
else if(getFarmAnimalAt(Game1.currentLocation, x, y) != null)
|
||||
{
|
||||
toSpeak = getFarmAnimalAt(Game1.currentLocation, x, y);
|
||||
}
|
||||
else if (Game1.currentLocation.isWaterTile(x, y))
|
||||
{
|
||||
toSpeak = "Water";
|
||||
|
@ -99,6 +104,45 @@ namespace stardew_access.Game
|
|||
isReadingTile = false;
|
||||
}
|
||||
|
||||
public static string? getFarmAnimalAt(GameLocation? location, int x, int y, bool onlyName = false)
|
||||
{
|
||||
if (location == null)
|
||||
return null;
|
||||
|
||||
if (location is not Farm && location is not AnimalHouse)
|
||||
return null;
|
||||
|
||||
List<FarmAnimal>? farmAnimals = null;
|
||||
|
||||
if(location is Farm)
|
||||
farmAnimals = (location as Farm).getAllFarmAnimals();
|
||||
else if(location is AnimalHouse)
|
||||
farmAnimals = (location as AnimalHouse).animals.Values.ToList();
|
||||
|
||||
if (farmAnimals == null || farmAnimals.Count <= 0)
|
||||
return null;
|
||||
|
||||
for(int i = 0; i < farmAnimals.Count; i++)
|
||||
{
|
||||
int fx = farmAnimals[i].getTileX();
|
||||
int fy = farmAnimals[i].getTileY();
|
||||
|
||||
if (fx.Equals(x) && fy.Equals(y))
|
||||
{
|
||||
string name = farmAnimals[i].displayName;
|
||||
int age = farmAnimals[i].age.Value;
|
||||
string type = farmAnimals[i].displayType;
|
||||
|
||||
if (onlyName)
|
||||
return name;
|
||||
|
||||
return $"{name}, {type}, age {age}";
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string? getBuildingAtTile(int x, int y)
|
||||
{
|
||||
string? toReturn = null;
|
||||
|
@ -106,7 +150,10 @@ namespace stardew_access.Game
|
|||
// It throws error if it can't find the index, do something else to fix this
|
||||
try
|
||||
{
|
||||
int? index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
|
||||
int? index = null;
|
||||
|
||||
if (Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y]!=null)
|
||||
index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
|
||||
/* Add More
|
||||
MainClass.monitor.Log(index.ToString(), LogLevel.Debug);
|
||||
*/
|
||||
|
@ -465,6 +512,13 @@ namespace stardew_access.Game
|
|||
}
|
||||
}
|
||||
|
||||
if(obj is Chest)
|
||||
{
|
||||
Chest chest = (Chest)obj;
|
||||
toReturn = chest.Type;
|
||||
toReturn = chest.DisplayName;
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace stardew_access.Game
|
|||
return;
|
||||
|
||||
previousLocation = currentLocation;
|
||||
ScreenReader.say($"{currentLocation.NameOrUniqueName} Entered",true);
|
||||
ScreenReader.say($"{currentLocation.Name} Entered",true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue