quantum-space-buddies/QSB/Audio/Patches/PlayerMovementAudioPatches.cs

32 lines
1.2 KiB
C#
Raw Permalink Normal View History

2022-08-27 22:07:50 +00:00
using HarmonyLib;
using QSB.Audio.Messages;
using QSB.Messaging;
using QSB.Patches;
using QSB.Player;
namespace QSB.Audio.Patches;
2023-07-28 18:30:57 +00:00
public class PlayerMovementAudioPatches : QSBPatch
2022-08-27 22:07:50 +00:00
{
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();
}
}