Added progress sound when catching a fish
parent
871c0b47cb
commit
b89a8f205d
|
@ -274,6 +274,12 @@ namespace stardew_access
|
||||||
original: AccessTools.Method(typeof(GrandpaStory), nameof(GrandpaStory.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(GrandpaStory), nameof(GrandpaStory.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(MiniGamesPatches), nameof(MiniGamesPatches.GrandpaStoryPatch))
|
postfix: new HarmonyMethod(typeof(MiniGamesPatches), nameof(MiniGamesPatches.GrandpaStoryPatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
harmony.Patch(
|
||||||
|
original: AccessTools.Method(typeof(BobberBar), nameof(BobberBar.update)),
|
||||||
|
postfix: new HarmonyMethod(typeof(FishingMiniGamePatch), nameof(FishingMiniGamePatch.BobberBarPatch))
|
||||||
|
);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
using StardewValley;
|
||||||
|
using StardewValley.Menus;
|
||||||
|
|
||||||
|
namespace stardew_access.Patches {
|
||||||
|
internal class FishingMiniGamePatch {
|
||||||
|
private static ICue? progressSound = null;
|
||||||
|
|
||||||
|
internal static void BobberBarPatch(BobberBar __instance, float ___distanceFromCatching, float ___bobberPosition, float ___bobberBarPos, bool ___bobberInBar, bool ___fadeOut, bool ___fadeIn) {
|
||||||
|
try {
|
||||||
|
handleProgressBarSound(___distanceFromCatching, ___fadeOut, ___fadeIn);
|
||||||
|
// MainClass.DebugLog($"dist: {___distanceFromCatching}\tbobPos: {___bobberPosition}\tbobbarpos{___bobberBarPos}");
|
||||||
|
} catch (System.Exception e) {
|
||||||
|
MainClass.ErrorLog($"An error occured while patching bobber bar:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleProgressBarSound(float ___distanceFromCatching, bool ___fadeOut, bool ___fadeIn) {
|
||||||
|
if(Game1.soundBank == null) return;
|
||||||
|
|
||||||
|
if (progressSound == null) {
|
||||||
|
progressSound = Game1.soundBank.GetCue("SinWave");
|
||||||
|
}
|
||||||
|
|
||||||
|
progressSound.SetVariable("Pitch", 2400f * ___distanceFromCatching);
|
||||||
|
// progressSound.SetVariable("Volume", 300f);
|
||||||
|
|
||||||
|
if (___fadeIn && !progressSound.IsPlaying) {
|
||||||
|
// Start playing the sound on menu open
|
||||||
|
progressSound.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(___fadeOut && progressSound.IsPlaying) {
|
||||||
|
// Stop playing the sound on menu close
|
||||||
|
progressSound.Stop(Microsoft.Xna.Framework.Audio.AudioStopOptions.Immediate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue