mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 00:39:53 +00:00
Sync marshmallow roasting related sounds
This commit is contained in:
parent
4008225e5e
commit
d2387de39a
16
QSB/Audio/Messages/PlayerAudioControllerOneShotMessage.cs
Normal file
16
QSB/Audio/Messages/PlayerAudioControllerOneShotMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.Audio.Messages;
|
||||
|
||||
|
||||
public class PlayerAudioControllerOneShotMessage : QSBMessage<(AudioType audioType, uint userID)>
|
||||
{
|
||||
public PlayerAudioControllerOneShotMessage(AudioType audioType, uint userID) : base((audioType, userID)) { }
|
||||
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote() =>
|
||||
QSBPlayerManager.GetPlayer(Data.userID)?.AudioController?.PlayOneShot(Data.audioType);
|
||||
}
|
36
QSB/Audio/Patches/PlayerAudioControllerPatches.cs
Normal file
36
QSB/Audio/Patches/PlayerAudioControllerPatches.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Audio.Messages;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
|
||||
namespace QSB.Audio.Patches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class PlayerAudioControllerPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
private static void PlayOneShot(AudioType audioType) =>
|
||||
new PlayerAudioControllerOneShotMessage(audioType, QSBPlayerManager.LocalPlayerId).Send();
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayMarshmallowCatchFire))]
|
||||
public static void PlayerAudioController_PlayMarshmallowCatchFire() => PlayOneShot(AudioType.ToolMarshmallowIgnite);
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayMarshmallowBlowOut))]
|
||||
public static void PlayerAudioController_PlayMarshmallowBlowOut() => PlayOneShot(AudioType.ToolMarshmallowBlowOut);
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayMarshmallowEat))]
|
||||
public static void PlayerAudioController_PlayMarshmallowEat() => PlayOneShot(AudioType.ToolMarshmallowEat);
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayMarshmallowEatBurnt))]
|
||||
public static void PlayerAudioController_PlayMarshmallowEatBurnt() => PlayOneShot(AudioType.ToolMarshmallowEatBurnt);
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayMarshmallowReplace))]
|
||||
public static void PlayerAudioController_PlayMarshmallowReplace() => PlayOneShot(AudioType.ToolMarshmallowReplace);
|
||||
}
|
@ -22,14 +22,11 @@ public class QSBPlayerAudioController : MonoBehaviour
|
||||
=> _oneShotExternalSource?.PlayOneShot(AudioType.ToolFlashlightOff);
|
||||
|
||||
public void PlayWearSuit()
|
||||
=> _oneShotExternalSource?.PlayOneShot(AudioType.PlayerSuitWearSuit);
|
||||
=> PlayOneShot(AudioType.PlayerSuitWearSuit);
|
||||
|
||||
public void PlayRemoveSuit()
|
||||
=> _oneShotExternalSource?.PlayOneShot(AudioType.PlayerSuitRemoveSuit);
|
||||
=> PlayOneShot(AudioType.PlayerSuitRemoveSuit);
|
||||
|
||||
public void PlayWearHelmet()
|
||||
=> _oneShotExternalSource?.PlayOneShot(AudioType.PlayerSuitWearHelmet);
|
||||
|
||||
public void PlayRemoveHelmet()
|
||||
=> _oneShotExternalSource?.PlayOneShot(AudioType.PlayerSuitRemoveHelmet);
|
||||
public void PlayOneShot(AudioType audioType)
|
||||
=> _oneShotExternalSource?.PlayOneShot(audioType, 1f);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user