DigitalzombieTLD před 2 roky
rodič
revize
010dfd3691

+ 29 - 11
AudioMain.cs

@@ -4,18 +4,25 @@ using Il2Cpp;
 using UnityEngine;
 using UnityEngine;
 using UnityEngine.Rendering;
 using UnityEngine.Rendering;
 
 
+
 namespace AudioMgr
 namespace AudioMgr
 {
 {
     public class AudioMain : MelonMod
     public class AudioMain : MelonMod
 	{
 	{
         bool initialized = false;
         bool initialized = false;
-        ClipManager myClipManager;
+        ClipManager myClipManager, myClipManager2;
         Shot myPlayerShot;
         Shot myPlayerShot;
+        string rootPath = Application.dataPath + "/../Mods/";
+        //AssetBundle bundle;
+        public static bool _debug = false;
 
 
         public override void OnInitializeMelon() 
         public override void OnInitializeMelon() 
 		{
 		{
             ClassInjector.RegisterTypeInIl2Cpp<Shot>();
             ClassInjector.RegisterTypeInIl2Cpp<Shot>();
             ClassInjector.RegisterTypeInIl2Cpp<Queue>();
             ClassInjector.RegisterTypeInIl2Cpp<Queue>();
+
+            AudioMgr.Settings.OnLoad();
+            //bundle = AssetBundle.LoadFromFile(Application.dataPath + "/../Mods/sillysounds.unity3d");
         }
         }
 
 
         public override void OnSceneWasLoaded(int buildIndex, string sceneName)
         public override void OnSceneWasLoaded(int buildIndex, string sceneName)
@@ -23,10 +30,17 @@ namespace AudioMgr
             if (sceneName.Contains("Boot"))
             if (sceneName.Contains("Boot"))
             {
             {
                 AudioMaster.CreateMasterParent();
                 AudioMaster.CreateMasterParent();
-                myClipManager = new ClipManager();
+                
+                //myClipManager = new ClipManager();
+                //myClipManager2 = new ClipManager();
+
+                //myClipManager.LoadClipFromFile("start", "start.mp3", ClipManager.LoadType.Decompressed);
+                //myClipManager.LoadClipFromFile("shutdown", "shutdown.mp3", ClipManager.LoadType.Decompressed);
+                //myClipManager.LoadClipFromFile("waterfall", "waterfall.ogg", ClipManager.LoadType.Decompressed);
+
+                //myClipManager2.LoadAllClipsFromBundle(bundle);
+
 
 
-                myClipManager.LoadClipFromFile("start", "start.mp3", ClipManager.LoadType.Decompressed);
-                myClipManager.LoadClipFromFile("shutdown", "shutdown.mp3", ClipManager.LoadType.Decompressed);
             }
             }
 
 
             if (sceneName.Contains("Menu"))
             if (sceneName.Contains("Menu"))
@@ -34,11 +48,11 @@ namespace AudioMgr
                 initialized = true;
                 initialized = true;
                
                
 
 
-                myPlayerShot = AudioMaster.CreatePlayerShot(AudioMaster.SourceType.Ambience);
+               //myPlayerShot = AudioMaster.CreatePlayerShot(AudioMaster.SourceType.SFX);
 
 
 
 
-                PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODOPEN1", myClipManager, "start", AudioMaster.SourceType.SFX);
-                PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODCLOSE1", myClipManager, "shutdown", AudioMaster.SourceType.SFX);
+                //PatchMaster.AddReplacePatch("PLAY_CROWCAWSDISTANT", myClipManager, "start", AudioMaster.SourceType.SFX);
+                //PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODCLOSE1", myClipManager, "shutdown", AudioMaster.SourceType.SFX);
 
 
               
               
             }
             }
@@ -54,7 +68,7 @@ namespace AudioMgr
 
 
         public override void OnUpdate()
         public override void OnUpdate()
         {
         {
-            /*
+            
             if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Keypad0))
             if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Keypad0))
             {
             {
                 // myPlayerShot.PlayOneshot(myClipManager.GetClip("waterfall"));
                 // myPlayerShot.PlayOneshot(myClipManager.GetClip("waterfall"));
@@ -63,8 +77,12 @@ namespace AudioMgr
                 PatchMaster.AddParameterPatch("WINDACTUALSPEED", 0f, PatchMaster.ParameterType.Limitter); 
                 PatchMaster.AddParameterPatch("WINDACTUALSPEED", 0f, PatchMaster.ParameterType.Limitter); 
                 PatchMaster.AddParameterPatch("AMBIENTVOLUME", 0f, PatchMaster.ParameterType.Limitter);
                 PatchMaster.AddParameterPatch("AMBIENTVOLUME", 0f, PatchMaster.ParameterType.Limitter);
                 PatchMaster.AddParameterPatch("GLOBALVOLUME", 0f, PatchMaster.ParameterType.Limitter);
                 PatchMaster.AddParameterPatch("GLOBALVOLUME", 0f, PatchMaster.ParameterType.Limitter);
-            }          
-            */
+            }
+            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L))
+            {
+                //myPlayerShot.PlayOneshot(myClipManager2.GetClip("woo"));
+            }
+
+            }
         }
         }
-    }
 }
 }

+ 3 - 0
AudioManager.csproj

@@ -72,6 +72,9 @@
         <Reference Include="Il2CppSystem.Core" />
         <Reference Include="Il2CppSystem.Core" />
         <Reference Include="Il2CppSystem.Data" />
         <Reference Include="Il2CppSystem.Data" />
         <Reference Include="Il2CppSystem" />
         <Reference Include="Il2CppSystem" />
+        <Reference Include="ModSettings">
+          <HintPath>..\..\..\..\Games\Steam\steamapps\common\TheLongDark\Mods\ModSettings.dll</HintPath>
+        </Reference>
         <Reference Include="UnityEngine.AnimationModule" />
         <Reference Include="UnityEngine.AnimationModule" />
         <Reference Include="UnityEngine.AssetBundleModule" />
         <Reference Include="UnityEngine.AssetBundleModule" />
         <Reference Include="UnityEngine.AudioModule" />
         <Reference Include="UnityEngine.AudioModule" />

+ 60 - 0
AudioManagerSettings.cs

@@ -0,0 +1,60 @@
+using UnityEngine;
+using ModSettings;
+using MelonLoader;
+
+namespace AudioMgr
+{
+    internal class AudioManagerSettings : JsonModSettings
+    {     
+		[Section("Aurora Audio")]
+
+        [Name("Limit Volume")]
+        [Description("Limit Volume to Value below")]
+        public bool enableAuroraTweaks = false;
+
+        [Name("Music")]
+		[Description("Left: Silent / Right: Maximum Volume")]
+		[Slider(0, 100)]
+		public int auroraVolume = 0;
+
+        [Section("Wind Audio Indoor (clattering)")]
+
+        [Name("Limit Volume")]
+        [Description("Limit Volume to Value below")]
+        public bool enableWindTweaks = false;
+
+        [Name("Indoor Wind Audio")]
+        [Description("Left: Silent / Right: Maximum Volume")]
+        [Slider(0, 100)]
+        public int windVolume = 0;
+
+        [Section("Waterfalls")]
+
+        [Name("Silent Waterfalls")]
+        [Description("Disable waterfall audio")]
+        public bool disableWaterfall = true;
+
+        [Section("Flares")]
+
+        [Name("Silent Flares")]
+        [Description("Disable flare audio")]
+        public bool disableFlare = true;
+
+        protected override void OnConfirm()
+        {
+            base.OnConfirm();
+         
+        }
+    }
+
+    internal static class Settings
+    {
+        public static AudioManagerSettings options;
+
+        public static void OnLoad()
+        {
+            options = new AudioManagerSettings();
+            options.AddToModSettings("AudioManager");           
+        }
+    }
+}

+ 6 - 3
Harmony/3DSoundPatches.cs

@@ -9,7 +9,8 @@ namespace AudioMgr
     {
     {
         public static bool Prefix(ref GameAudioManager __instance, ref string soundID, ref GameObject go)
         public static bool Prefix(ref GameAudioManager __instance, ref string soundID, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play3D string " + soundID + " on " + go.name);
+            if(AudioMain._debug)
+            MelonLogger.Msg("Play3D string " + soundID + " on " + go.name);
 
 
             if (PatchMaster.PatchAction(soundID, go))
             if (PatchMaster.PatchAction(soundID, go))
             {
             {
@@ -25,7 +26,8 @@ namespace AudioMgr
     {
     {
         public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
         public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play3D uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play3D uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
 
 
 
 
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
@@ -42,7 +44,8 @@ namespace AudioMgr
     {
     {
         public static void Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
         public static void Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play3D event " + soundEvent.Name + " on " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play3D event " + soundEvent.Name + " on " + go.name);
         }
         }
     }
     }
 }
 }

+ 18 - 0
Harmony/AKEnginePatches.cs

@@ -0,0 +1,18 @@
+using Il2Cpp;
+using MelonLoader;
+using UnityEngine;
+
+namespace AudioMgr
+{
+    [HarmonyLib.HarmonyPatch(typeof(AkSoundEngine), "SetGameObjectOutputBusVolume", new Type[] {typeof(GameObject), typeof(GameObject), typeof(float) })]
+    public class BusVolumePatch
+    {
+        public static void Prefix(ref AkSoundEngine __instance, ref GameObject in_emitterObjID, ref GameObject in_listenerObjID, ref float in_fControlValue)
+        {
+            if (AudioMain._debug)
+                MelonLogger.Msg("AK emitter: " + in_emitterObjID.name + "; value: " + in_fControlValue);
+        }
+    }
+
+   
+}

+ 2 - 1
Harmony/AmbientEmitter.cs

@@ -11,7 +11,8 @@ namespace AudioMgr
     {
     {
         public static void Postfix(ref AmbientEmitter __instance)
         public static void Postfix(ref AmbientEmitter __instance)
         {
         {
-            //MelonLogger.Msg("Ambient emitter Start: " + __instance + " on gameobject " + __instance.gameObject.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Ambient emitter Start: " + __instance + " on gameobject " + __instance.gameObject.name);
         }
         }
     }
     }
 
 

+ 8 - 1
Harmony/AudioSimplePatches.cs

@@ -11,7 +11,14 @@ namespace AudioMgr
     {    
     {    
         public static bool Prefix(ref PlayAudioSimple __instance)
         public static bool Prefix(ref PlayAudioSimple __instance)
         {
         {
-            //MelonLogger.Msg("Play simple started " + __instance.m_Event.Name + " on " + __instance.gameObject.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play simple started " + __instance.m_Event.Name + " on " + __instance.gameObject.name);
+
+            if (Settings.options.disableWaterfall && __instance.m_Event.Name.Contains("Waterfall"))
+            {
+                return false;
+            }
+
 
 
             if (PatchMaster.PatchAction(__instance.name, __instance.gameObject))
             if (PatchMaster.PatchAction(__instance.name, __instance.gameObject))
             {
             {

+ 20 - 3
Harmony/PlaySoundPatches.cs

@@ -10,7 +10,16 @@ namespace AudioMgr
     {
     {
         public static bool Prefix(ref GameAudioManager __instance, ref string soundID, ref GameObject go)
         public static bool Prefix(ref GameAudioManager __instance, ref string soundID, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play string " + soundID + " on " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play string " + soundID + " on " + go.name);
+
+            if (Settings.options.disableFlare)
+            {
+                if (soundID.Contains("FlareLoop") || soundID.Contains("FLARELIGHT"))
+                {
+                    return false;
+                }
+            }
 
 
             if (PatchMaster.PatchAction(soundID, go))
             if (PatchMaster.PatchAction(soundID, go))
             {
             {
@@ -26,7 +35,8 @@ namespace AudioMgr
     {
     {
         public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
         public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
 
 
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             {
             {
@@ -42,7 +52,14 @@ namespace AudioMgr
     {
     {
         public static bool Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
         public static bool Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
         {
         {
-            //MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
+
+            if(Settings.options.disableWaterfall && soundEvent.Name.Contains("Waterfall"))
+            {
+                return false;
+            }
+
 
 
             if (PatchMaster.PatchAction(soundEvent.Name, go))
             if (PatchMaster.PatchAction(soundEvent.Name, go))
             {
             {

+ 4 - 3
Harmony/PlaySoundPositionalPatches.cs

@@ -9,8 +9,8 @@ namespace AudioMgr
     {
     {
         public static void Prefix(ref GameAudioManager __instance, string soundID, GameObject go, AkCallbackManager.EventCallback eventCallback, GameAudioManager.PlayOptions playOptions)
         public static void Prefix(ref GameAudioManager __instance, string soundID, GameObject go, AkCallbackManager.EventCallback eventCallback, GameAudioManager.PlayOptions playOptions)
         {
         {
-            // MelonLogger.Msg("Play positional string " + soundID + "; " + go.name);
-
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play positional string " + soundID + "; " + go.name);
 
 
         }
         }
     }
     }
@@ -20,7 +20,8 @@ namespace AudioMgr
     {
     {
         public static void Prefix(ref GameAudioManager __instance, Il2CppAK.Wwise.Event soundEvent, GameObject go, AkCallbackManager.EventCallback eventCallback, GameAudioManager.PlayOptions playOptions)
         public static void Prefix(ref GameAudioManager __instance, Il2CppAK.Wwise.Event soundEvent, GameObject go, AkCallbackManager.EventCallback eventCallback, GameAudioManager.PlayOptions playOptions)
         {
         {
-            //MelonLogger.Msg("Play positional event " + EventIDs.GetEventString(soundEvent.PlayingId) + "; " + go.name);
+            if (AudioMain._debug)
+                MelonLogger.Msg("Play positional event " + EventIDs.GetEventString(soundEvent.PlayingId) + "; " + go.name);
         }
         }
     }
     }
 }
 }

+ 21 - 1
Harmony/RTPCPatches.cs

@@ -11,7 +11,27 @@ namespace AudioMgr
         public static void Prefix(GameAudioManager __instance, ref uint rtpcID, ref float rtpcValue, ref GameObject go)
         public static void Prefix(GameAudioManager __instance, ref uint rtpcID, ref float rtpcValue, ref GameObject go)
         {
         {
             // GAME_PARAMETERS
             // GAME_PARAMETERS
-            //MelonLogger.Msg("RTPC " + GameParameterIDs.GetString(rtpcID) + "; " + rtpcValue);
+            if (AudioMain._debug)
+                MelonLogger.Msg("RTPC " + GameParameterIDs.GetString(rtpcID) + "; " + rtpcValue);
+
+            // Aurora music patch
+            if(Settings.options.enableAuroraTweaks && GameParameterIDs.GetString(rtpcID) == "AURORASTRENGTH") 
+            {
+                if(rtpcValue > Settings.options.auroraVolume) 
+                {
+                    rtpcValue = Settings.options.auroraVolume;
+                }
+            }
+
+            // Wind audioc patch
+            if (Settings.options.enableWindTweaks && GameManager.GetWeatherComponent().IsIndoorScene() && (GameParameterIDs.GetString(rtpcID) == "WINDINTENSITYBLEND"))
+            {             
+                if (rtpcValue > Settings.options.windVolume)
+                {
+                    rtpcValue = Settings.options.windVolume;
+                }
+            }
+                       
 
 
             if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
             if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
             {
             {

+ 1 - 1
Harmony/VolumePatches.cs

@@ -19,5 +19,5 @@ namespace AudioMgr
                 VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue/100);
                 VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue/100);
             }           
             }           
         }
         }
-    } */   
+    }    */
 }
 }

+ 1 - 1
Master/SettingMaster.cs

@@ -40,7 +40,7 @@ namespace AudioMgr
             _defaultSetting[AudioMaster.SourceType.SFX].spread = 0.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].spread = 0.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].panStereo = 0.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].panStereo = 0.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].dopplerLevel = 0f;
             _defaultSetting[AudioMaster.SourceType.SFX].dopplerLevel = 0f;
-            _defaultSetting[AudioMaster.SourceType.SFX].maxDistance = 18.0f;
+            _defaultSetting[AudioMaster.SourceType.SFX].maxDistance = 18f; // 18.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].minDistance = 1.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].minDistance = 1.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].pitch = 1.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].pitch = 1.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].spatialBlend = 1.0f;
             _defaultSetting[AudioMaster.SourceType.SFX].spatialBlend = 1.0f;

+ 3 - 3
Properties/AssemblyInfo.cs

@@ -3,7 +3,7 @@ using System.Reflection;
 
 
 [assembly: AssemblyTitle("AudioManager")]
 [assembly: AssemblyTitle("AudioManager")]
 [assembly: AssemblyCopyright("Digitalzombie")]
 [assembly: AssemblyCopyright("Digitalzombie")]
-[assembly: AssemblyVersion("0.8.0")]
-[assembly: AssemblyFileVersion("0.8.0")]
-[assembly: MelonInfo(typeof(AudioMgr.AudioMain), "AudioManager", "0.8.0", "Digitalzombie", null)]
+[assembly: AssemblyVersion("1.0.0")]
+[assembly: AssemblyFileVersion("1.0.0")]
+[assembly: MelonInfo(typeof(AudioMgr.AudioMain), "AudioManager", "1.0.0", "Digitalzombie", null)]
 [assembly: MelonGame("Hinterland", "TheLongDark")]
 [assembly: MelonGame("Hinterland", "TheLongDark")]

+ 7 - 0
README.md

@@ -2,6 +2,13 @@
 # AudioManager
 # AudioManager
 Audio helper mod for The Long Dark. Uses Unitys native audio engine to enable easier usage of custom audio in mods.
 Audio helper mod for The Long Dark. Uses Unitys native audio engine to enable easier usage of custom audio in mods.
 
 
+### New: v1.0! Now includes features for players:
+- Disable flare audio (no more hisssssss)
+- Disable waterfall audio (ears stop bleeding)
+- Adjust wind effect volume (eg. like clattering) when indoors  (keep your sanity at the farmhouse)
+- Adjust aurora music volume (if you don't feel creepy today)
+
+
 #### Current features v0.8
 #### Current features v0.8
 - Loading of single audio files (ogg, wav, mp3) on runtime
 - Loading of single audio files (ogg, wav, mp3) on runtime
 - Loading of all audio files inside a directory
 - Loading of all audio files inside a directory