Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BelowZero's What The Dock Fixes #279

Merged
merged 6 commits into from
Oct 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix CustomSoundPatcher for BZ stable
  • Loading branch information
Metious committed Sep 14, 2022
commit 0ac17600aae5da80fa6ed4cd28283bb69579ec98
20 changes: 17 additions & 3 deletions SMLHelper/Patchers/CustomSoundPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,12 @@ public static bool SoundQueue_Update_Prefix(SoundQueue __instance)
{
var instanceCurrent = __instance._current ?? default;
if (string.IsNullOrEmpty(instanceCurrent.sound) || !PlayedChannels.TryGetValue(instanceCurrent.sound, out var channel)) return true;
#if BELOWZERO
if (SoundQueue.GetPlaybackState(__instance.eventInstance) is not PLAYBACK_STATE.STARTING or PLAYBACK_STATE.PLAYING) return true;
#else
if (!SoundQueue.GetIsStartingOrPlaying(__instance.eventInstance)) return true;

#endif

ATTRIBUTES_3D attributes = Player.main.transform.To3DAttributes();
channel.set3DAttributes(ref attributes.position, ref attributes.velocity);
channel.getPosition(out var position, TIMEUNIT.MS);
Expand All @@ -412,15 +416,25 @@ public static bool SoundQueue_Update_Prefix(SoundQueue __instance)
return false;
}

[HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetIsStartingOrPlaying))]
[HarmonyPrefix]
public static bool SoundQueue_GetIsStartingOrPlaying_Prefix( ref bool __result)
#if BELOWZERO
[HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetPlaybackState))]
public static bool SoundQueue_GetIsStartingOrPlaying_Prefix(ref PLAYBACK_STATE __result)
#else
[HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetIsStartingOrPlaying))]
public static bool SoundQueue_GetIsStartingOrPlaying_Prefix(ref bool __result)
#endif
{
var instanceCurrent = PDASounds.queue?._current ?? default;
if (string.IsNullOrEmpty(instanceCurrent.sound) || !PlayedChannels.TryGetValue(instanceCurrent.sound, out var channel)) return true;

#if BELOWZERO
channel.isPlaying(out var isPlaying);
__result = isPlaying ? PLAYBACK_STATE.PLAYING : PLAYBACK_STATE.STOPPED;
#else
var result = channel.isPlaying(out __result);
__result = __result && result == RESULT.OK;
#endif
return false;
}

Expand Down