Skip to content

Commit

Permalink
fix music patches for ship
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Feb 9, 2024
1 parent c8333e9 commit 7eeef34
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions QSB/ShipSync/Patches/ShipAudioPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,53 @@ public static bool ShipThrusterAudio_Update(ShipThrusterAudio __instance)
}

[HarmonyPrefix]
[HarmonyPatch(typeof(TravelMusicController), nameof(TravelMusicController.Update))]
public static bool TravelMusicController_Update(TravelMusicController __instance)
[HarmonyPatch(typeof(GlobalMusicController), nameof(GlobalMusicController.UpdateTravelMusic))]
public static bool GlobalMusicController_UpdateTravelMusic(GlobalMusicController __instance)
{
// only this line is changed
__instance._isTraveling = PlayerState.IsInsideShip()
&& ShipManager.Instance.CurrentFlyer != uint.MaxValue
&& Locator.GetPlayerRulesetDetector().AllowTravelMusic();
bool flag = PlayerState.IsInsideShip()
&& ShipManager.Instance.CurrentFlyer != uint.MaxValue
&& Locator.GetPlayerRulesetDetector().AllowTravelMusic()
&& !PlayerState.IsHullBreached()
&& !__instance._playingFinalEndTimes;

if (__instance._isTraveling && !__instance._wasTraveling)

bool flag2 = __instance._travelSource.isPlaying && !__instance._travelSource.IsFadingOut();
if (flag && !flag2)
{
__instance._audioSource.FadeIn(5f, false, false, 1f);
__instance._travelSource.FadeIn(5f, false, false, 1f);
return false;
}
else if (!__instance._isTraveling && __instance._wasTraveling)
if (!flag && flag2)
{
__instance._audioSource.FadeOut(5f, OWAudioSource.FadeOutCompleteAction.PAUSE, 0f);
__instance._travelSource.FadeOut(5f, OWAudioSource.FadeOutCompleteAction.PAUSE, 0f);
}

__instance._wasTraveling = __instance._isTraveling;

return false;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(GlobalMusicController), nameof(GlobalMusicController.UpdateBrambleMusic))]
public static bool GlobalMusicController_UpdateBrambleMusic(GlobalMusicController __instance)

Check failure on line 73 in QSB/ShipSync/Patches/ShipAudioPatches.cs

View workflow job for this annotation

GitHub Actions / build

'ShipAudioPatches.GlobalMusicController_UpdateBrambleMusic(GlobalMusicController)': not all code paths return a value

Check failure on line 73 in QSB/ShipSync/Patches/ShipAudioPatches.cs

View workflow job for this annotation

GitHub Actions / build

'ShipAudioPatches.GlobalMusicController_UpdateBrambleMusic(GlobalMusicController)': not all code paths return a value
{
bool flag = Locator.GetPlayerSectorDetector().InBrambleDimension()
&& !Locator.GetPlayerSectorDetector().InVesselDimension()
&& PlayerState.IsInsideShip()
&& ShipManager.Instance.CurrentFlyer != uint.MaxValue
&& !PlayerState.IsHullBreached()
&& !__instance._playingFinalEndTimes;

bool flag2 = __instance._darkBrambleSource.isPlaying && !__instance._darkBrambleSource.IsFadingOut();

if (flag && !flag2)
{
__instance._darkBrambleSource.FadeIn(5f, false, false, 1f);
return false;
}

if (!flag && flag2)
{
__instance._darkBrambleSource.FadeOut(5f, OWAudioSource.FadeOutCompleteAction.STOP, 0f);
}
}
}

0 comments on commit 7eeef34

Please sign in to comment.