quantum-space-buddies/QSB/Audio/Patches/PlayerMovementAudioPatches.cs
2023-07-28 19:30:57 +01:00

32 lines
1.2 KiB
C#

using HarmonyLib;
using QSB.Audio.Messages;
using QSB.Messaging;
using QSB.Patches;
using QSB.Player;
namespace QSB.Audio.Patches;
public class PlayerMovementAudioPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerMovementAudio), nameof(PlayerMovementAudio.PlayFootstep))]
public static void PlayerMovementAudio_PlayFootstep(PlayerMovementAudio __instance)
{
var underwater = !PlayerState.IsCameraUnderwater() && __instance._fluidDetector.InFluidType(FluidVolume.Type.WATER);
var audioType = underwater ? AudioType.MovementShallowWaterFootstep : PlayerMovementAudio.GetFootstepAudioType(__instance._playerController.GetGroundSurface());
if (audioType != AudioType.None)
{
new PlayerMovementAudioFootstepMessage(audioType, __instance._footstepAudio.pitch, QSBPlayerManager.LocalPlayerId).Send();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerMovementAudio), nameof(PlayerMovementAudio.OnJump))]
public static void PlayerMovementAudio_OnJump(PlayerMovementAudio __instance)
{
new PlayerMovementAudioJumpMessage(__instance._jumpAudio.pitch, QSBPlayerManager.LocalPlayerId).Send();
}
}