Compare commits
	
		
			4 Commits
		
	
	
		
			8cca880b04
			...
			c3cec1a490
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c3cec1a490 | |||
| 
						 | 
					5fa9fd5eca | ||
| 
						 | 
					d17974e3f5 | ||
| 
						 | 
					b89a8f205d | 
@@ -24,6 +24,9 @@ namespace stardew_access
 | 
				
			|||||||
                soundEffects.Add("colliding", TYPE.Sound);
 | 
					                soundEffects.Add("colliding", TYPE.Sound);
 | 
				
			||||||
                soundEffects.Add("invalid-selection", TYPE.Sound);
 | 
					                soundEffects.Add("invalid-selection", TYPE.Sound);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
					                soundEffects.Add("bobber_target_up", TYPE.Sound);
 | 
				
			||||||
 | 
					                soundEffects.Add("bobber_target_down", TYPE.Sound);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                soundEffects.Add("npc_top", TYPE.Footstep);
 | 
					                soundEffects.Add("npc_top", TYPE.Footstep);
 | 
				
			||||||
                soundEffects.Add("npc_right", TYPE.Footstep);
 | 
					                soundEffects.Add("npc_right", TYPE.Footstep);
 | 
				
			||||||
                soundEffects.Add("npc_left", TYPE.Footstep);
 | 
					                soundEffects.Add("npc_left", TYPE.Footstep);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -275,6 +275,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(GrandpaStoryPatch), nameof(GrandpaStoryPatch.DrawPatch))
 | 
					                        postfix: new HarmonyMethod(typeof(GrandpaStoryPatch), nameof(GrandpaStoryPatch.DrawPatch))
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            harmony.Patch(
 | 
				
			||||||
 | 
					                        original: AccessTools.Method(typeof(BobberBar), nameof(BobberBar.update)),
 | 
				
			||||||
 | 
					                        postfix: new HarmonyMethod(typeof(FishingMiniGamePatch), nameof(FishingMiniGamePatch.BobberBarPatch))
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            harmony.Patch(
 | 
					            harmony.Patch(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,6 +89,9 @@ namespace stardew_access
 | 
				
			|||||||
        public Boolean DisableInventoryVerbosity {get; set;} = false; // If enabled, does not speaks 'not usable here' and 'donatable' in inventories
 | 
					        public Boolean DisableInventoryVerbosity {get; set;} = false; // If enabled, does not speaks 'not usable here' and 'donatable' in inventories
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int MaximumFishingDifficulty { get; set; } = 999; // TODO Add doc
 | 
				
			||||||
 | 
					        public int FixFishingMotionType { get; set; } = 999;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // TODO Add the exclusion and focus list too
 | 
					        // TODO Add the exclusion and focus list too
 | 
				
			||||||
        // public String ExclusionList { get; set; } = "test";
 | 
					        // public String ExclusionList { get; set; } = "test";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										77
									
								
								stardew-access/Patches/FishingMiniGamePatch.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								stardew-access/Patches/FishingMiniGamePatch.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
				
			|||||||
 | 
					using StardewValley;
 | 
				
			||||||
 | 
					using StardewValley.Menus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace stardew_access.Patches {
 | 
				
			||||||
 | 
					    internal class FishingMiniGamePatch {
 | 
				
			||||||
 | 
					        private static ICue? progressSound = null;
 | 
				
			||||||
 | 
					        private static long previousBobberTargetUpPlayedTime = 0;
 | 
				
			||||||
 | 
					        private static long previousBobberTargetDownPlayedTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        internal static void BobberBarPatch(BobberBar __instance, ref float ___difficulty, ref int ___motionType, float ___distanceFromCatching, float ___bobberPosition, float ___bobberBarPos, bool ___bobberInBar, int ___bobberBarHeight, bool ___fadeOut, bool ___fadeIn) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                if (___difficulty > MainClass.Config.MaximumFishingDifficulty) {
 | 
				
			||||||
 | 
					                    MainClass.DebugLog($"Fish difficulty set to {MainClass.Config.MaximumFishingDifficulty} from {___difficulty}");
 | 
				
			||||||
 | 
					                    ___difficulty = MainClass.Config.MaximumFishingDifficulty;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (___motionType != MainClass.Config.FixFishingMotionType &&
 | 
				
			||||||
 | 
					                        (MainClass.Config.FixFishingMotionType >= 0 && MainClass.Config.FixFishingMotionType <= 4)) {
 | 
				
			||||||
 | 
					                    MainClass.DebugLog($"Motion type set to {MainClass.Config.FixFishingMotionType} from {___motionType}");
 | 
				
			||||||
 | 
					                    ___motionType = MainClass.Config.FixFishingMotionType;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                handleProgressBarSound(___distanceFromCatching, ___fadeOut, ___fadeIn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                handleBobberTargetSound(___bobberPosition, ___bobberBarPos, ___bobberInBar, ___bobberBarHeight, ___fadeOut, ___fadeIn);
 | 
				
			||||||
 | 
					            } catch (System.Exception e) {
 | 
				
			||||||
 | 
					                MainClass.ErrorLog($"An error occured while patching bobber bar:\n{e.Message}\n{e.StackTrace}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void handleBobberTargetSound(float bobberPosition, float bobberBarPos, bool bobberInBar, int ___bobberBarHeight, bool ___fadeOut, bool ___fadeIn) {
 | 
				
			||||||
 | 
					            if (bobberInBar) return;
 | 
				
			||||||
 | 
					            if (___fadeIn) return;
 | 
				
			||||||
 | 
					            if (___fadeOut) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DateTimeOffset now = (DateTimeOffset)DateTime.UtcNow;
 | 
				
			||||||
 | 
					            long currentTimeInMilliseconds = now.ToUnixTimeMilliseconds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(bobberPosition < bobberBarPos && (currentTimeInMilliseconds - previousBobberTargetUpPlayedTime) >= 250) {
 | 
				
			||||||
 | 
					                previousBobberTargetUpPlayedTime = currentTimeInMilliseconds;
 | 
				
			||||||
 | 
					                int distanceFromBobber = (int)(bobberBarPos - bobberPosition + (___bobberBarHeight / 2));
 | 
				
			||||||
 | 
					                int calculatedPitch = distanceFromBobber * 4;
 | 
				
			||||||
 | 
					                MainClass.DebugLog(calculatedPitch.ToString());
 | 
				
			||||||
 | 
					                Game1.playSoundPitched("bobber_target_up", calculatedPitch);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(bobberPosition > bobberBarPos && (currentTimeInMilliseconds - previousBobberTargetDownPlayedTime) >= 250) {
 | 
				
			||||||
 | 
					                previousBobberTargetDownPlayedTime = currentTimeInMilliseconds;
 | 
				
			||||||
 | 
					                int distanceFromBobber = (int)(bobberPosition - bobberBarPos - (___bobberBarHeight / 2));
 | 
				
			||||||
 | 
					                int calculatedPitch = distanceFromBobber * 4;
 | 
				
			||||||
 | 
					                MainClass.DebugLog(calculatedPitch.ToString());
 | 
				
			||||||
 | 
					                Game1.playSoundPitched("bobber_target_down", calculatedPitch);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								stardew-access/assets/sounds/bobber_target_down.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								stardew-access/assets/sounds/bobber_target_down.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								stardew-access/assets/sounds/bobber_target_up.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								stardew-access/assets/sounds/bobber_target_up.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user