mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[MuteSFX] Initial CVRMG release
This commit is contained in:
parent
aac93fbed7
commit
d9c8a31667
9 changed files with 171 additions and 0 deletions
49
MuteSFX/AudioModuleManager.cs
Normal file
49
MuteSFX/AudioModuleManager.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using ABI_RC.Core.AudioEffects;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.MuteSFX;
|
||||
|
||||
public static class AudioModuleManager
|
||||
{
|
||||
public const string sfx_mute = "MuteSFX_sfx_mute";
|
||||
public const string sfx_unmute = "MuteSFX_sfx_unmute";
|
||||
|
||||
public static void SetupDefaultAudioClips()
|
||||
{
|
||||
string path = Application.streamingAssetsPath + "/Cohtml/UIResources/GameUI/mods/MuteSFX/audio/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
MuteSFX.Logger.Msg("Created MuteSFX/audio directory!");
|
||||
}
|
||||
|
||||
string[] clipNames = { "sfx_mute.wav", "sfx_unmute.wav" };
|
||||
foreach (string clipName in clipNames)
|
||||
{
|
||||
string clipPath = Path.Combine(path, clipName);
|
||||
if (!File.Exists(clipPath))
|
||||
{
|
||||
byte[] clipData = null;
|
||||
string resourceName = "MuteSFX.SFX." + clipName;
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
|
||||
{
|
||||
clipData = new byte[stream.Length];
|
||||
stream.Read(clipData, 0, clipData.Length);
|
||||
}
|
||||
|
||||
using (FileStream fileStream = new FileStream(clipPath, FileMode.CreateNew))
|
||||
{
|
||||
fileStream.Write(clipData, 0, clipData.Length);
|
||||
}
|
||||
|
||||
MuteSFX.Logger.Msg("Placed missing sfx in audio folder: " + clipName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayAudioModule(string module)
|
||||
{
|
||||
InterfaceAudio.PlayModule(module);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue