Fixed footstep sounds

master
shoaib11120 2022-01-14 10:53:15 +05:30
parent b19e9fda43
commit 4bce675697
3 changed files with 112 additions and 57 deletions

View File

@ -74,10 +74,7 @@ namespace stardew_access.Game
{
toSpeak = "Ladder";
}
else if (!Game1.currentLocation.isTilePassable(Game1.player.nextPosition(Game1.player.getDirection()), Game1.viewport))
{
toSpeak = "Colliding";
} else
else
{
try
{
@ -247,6 +244,9 @@ namespace stardew_access.Game
else if(stage >= 4)
toReturn = $"{toReturn} tree";
if (fruitTree.fruitsOnTree.Value > 0)
toReturn = $"Harvestable {toReturn}";
return toReturn;
}
@ -347,6 +347,48 @@ namespace stardew_access.Game
return "Ice crystal";
case 75:
return "Geode";
case 32:
case 34:
case 36:
case 38:
case 40:
case 42:
case 48:
case 50:
case 52:
case 54:
case 56:
case 58:
return "Coloured stone";
case 668:
case 670:
case 845:
case 846:
case 847:
return "Mine stone";
case 818:
return "Clay stone";
case 816:
case 817:
return "Fossil stone";
case 25:
return "Stone";
case 118:
case 120:
case 122:
case 124:
return "Barrel";
case 119:
case 121:
case 123:
case 125:
return "Item box";
}
if (Game1.inMine || Game1.currentLocation is Mine)
{
switch (index)
{
case 76:
return "Frozen geode";
case 77:
@ -393,42 +435,7 @@ namespace stardew_access.Game
case 290:
case 850:
return "Iron node";
case 32:
case 34:
case 36:
case 38:
case 40:
case 42:
case 48:
case 50:
case 52:
case 54:
case 56:
case 58:
return "Coloured stone";
case 668:
case 670:
case 845:
case 846:
case 847:
return "Mine stone";
case 818:
return "Clay stone";
case 816:
case 817:
return "Fossil stone";
case 25:
return "Stone";
case 118:
case 120:
case 122:
case 124:
return "Barrel";
case 119:
case 121:
case 123:
case 125:
return "Item box";
}
}
return toReturn;

View File

@ -172,11 +172,6 @@ namespace stardew_access
original: AccessTools.Method(typeof(LanguageSelectionMenu), nameof(LanguageSelectionMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.LanguageSelectionMenuPatch))
);
/*harmony.Patch(
original: AccessTools.Method(typeof(HUDMessage), nameof(HUDMessage.draw), new Type[] { typeof(SpriteBatch), typeof(int) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.HUDMessagePatch))
);*/
#endregion
#region Quest Patches
@ -214,6 +209,11 @@ namespace stardew_access
);
#endregion
harmony.Patch(
original: AccessTools.Method(typeof(Game1), nameof(Game1.playSound)),
prefix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.PlaySoundPatch))
);
#endregion
#region Custom Commands
@ -388,7 +388,7 @@ namespace stardew_access
MainClass.monitor.Log($"Unable to narrate hud messages:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
}
await Task.Delay(1000);
await Task.Delay(300);
isNarratingHudMessage = false;
}
}

View File

@ -1,6 +1,9 @@
using StardewModdingAPI;
using Microsoft.Xna.Framework;
using stardew_access.Game;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Menus;
using StardewValley.TerrainFeatures;
namespace stardew_access.Patches
{
@ -9,6 +12,51 @@ namespace stardew_access.Patches
private static string currentLetterText = " ";
private static string currentLevelUpTitle = " ";
internal static bool PlaySoundPatch(string cueName)
{
try
{
if (!Context.IsPlayerFree)
return true;
if(!Game1.player.isMoving())
return true;
if(cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep")
{
if(!Game1.currentLocation.isTilePassable(Game1.player.nextPosition(Game1.player.getDirection()), Game1.viewport))
{
return false;
}
#region Check for objects
Vector2 gt = CurrentPlayer.getNextTile();
if (Game1.currentLocation.isObjectAtTile((int)gt.X, (int)gt.Y))
{
if (!Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y).isPassable())
return false;
}
#endregion
#region Check for terrain features
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
if (terrainFeature.ContainsKey(gt))
{
if (!terrainFeature[gt].Get().isPassable())
return false;
}
#endregion
}
}
catch (Exception e)
{
MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
}
return true;
}
internal static void LanguageSelectionMenuPatch(LanguageSelectionMenu __instance)
{
try