DigitalzombieTLD hace 2 años
padre
commit
308ea3ef66

+ 1 - 1
AudioMain.cs

@@ -22,7 +22,7 @@ namespace AudioMgr
             ClassInjector.RegisterTypeInIl2Cpp<Queue>();
             ClassInjector.RegisterTypeInIl2Cpp<Queue>();
             ClassInjector.RegisterTypeInIl2Cpp<Stream>();
             ClassInjector.RegisterTypeInIl2Cpp<Stream>();
             RadioMaster.Initialize();
             RadioMaster.Initialize();
-            AudioMgr.Settings.OnLoad();
+            Settings.OnLoad();
             //bundle = AssetBundle.LoadFromFile(Application.dataPath + "/../Mods/sillysounds.unity3d");
             //bundle = AssetBundle.LoadFromFile(Application.dataPath + "/../Mods/sillysounds.unity3d");
         }
         }
 
 

+ 19 - 9
Components/Shot.cs

@@ -13,7 +13,7 @@ namespace AudioMgr
         {
         {
         }
         }
 
 
-        private AudioSource _audioSource;
+        public AudioSource _audioSource;
         private Setting _activeSetting;
         private Setting _activeSetting;
 
 
         private bool _isEnabled = false;
         private bool _isEnabled = false;
@@ -63,6 +63,15 @@ namespace AudioMgr
             VolumeMaster.onVolumeChange -= ResetVolume;
             VolumeMaster.onVolumeChange -= ResetVolume;
         }
         }
 
 
+        [HideFromIl2Cpp]
+        public void ResetVolume()
+        {
+            if (_audioSource)
+            {
+                _audioSource.volume = VolumeMaster.GetVolume(_sourceType);
+            }
+        }
+
         [HideFromIl2Cpp]
         [HideFromIl2Cpp]
         public void SetVolume(float newVolume)
         public void SetVolume(float newVolume)
         {          
         {          
@@ -96,6 +105,14 @@ namespace AudioMgr
             MelonCoroutines.Start(PlayRoutine(audioClip));
             MelonCoroutines.Start(PlayRoutine(audioClip));
         }
         }
 
 
+        [HideFromIl2Cpp]
+        public void Play()
+        {
+            Stop();
+            _playState = PlayState.Playing;
+            _audioSource.Play();
+        }
+
         private IEnumerator PlayRoutine(Clip audioClip)
         private IEnumerator PlayRoutine(Clip audioClip)
         {
         {
             double _startTime = AudioSettings.dspTime + 0.6;
             double _startTime = AudioSettings.dspTime + 0.6;
@@ -119,14 +136,7 @@ namespace AudioMgr
             _audioSource.Stop();
             _audioSource.Stop();
         }
         }
 
 
-        [HideFromIl2Cpp]
-        public void ResetVolume()
-        {
-            if (_audioSource)
-            {
-                _audioSource.volume = VolumeMaster.GetVolume(_sourceType);
-            }
-        }
+        
 
 
         [HideFromIl2Cpp]
         [HideFromIl2Cpp]
         public void PlayOneshot(Clip audioClip)
         public void PlayOneshot(Clip audioClip)

+ 7 - 1
Harmony/AudioSimplePatches.cs

@@ -14,12 +14,18 @@ namespace AudioMgr
             if (AudioMain._debug)
             if (AudioMain._debug)
                 MelonLogger.Msg("Play simple started " + __instance.m_Event.Name + " on " + __instance.gameObject.name);
                 MelonLogger.Msg("Play simple started " + __instance.m_Event.Name + " on " + __instance.gameObject.name);
 
 
+            if (__instance.m_Event ==  null || __instance.gameObject == null)
+            {
+                return true;
+            }
+
+            
             if (Settings.options.disableWaterfall && __instance.m_Event.Name.Contains("Waterfall"))
             if (Settings.options.disableWaterfall && __instance.m_Event.Name.Contains("Waterfall"))
             {
             {
+              
                 return false;
                 return false;
             }
             }
 
 
-
             if (PatchMaster.PatchAction(__instance.name, __instance.gameObject))
             if (PatchMaster.PatchAction(__instance.name, __instance.gameObject))
             {
             {
                 return false;
                 return false;

+ 13 - 2
Harmony/PlaySoundPatches.cs

@@ -38,6 +38,11 @@ namespace AudioMgr
             if (AudioMain._debug)
             if (AudioMain._debug)
                 MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
                 MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
 
 
+            if(go == null)
+            {
+                return true;
+            }
+
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             {
             {
                 return false;
                 return false;
@@ -55,11 +60,17 @@ namespace AudioMgr
             if (AudioMain._debug)
             if (AudioMain._debug)
                 MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
                 MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
 
 
-            if(Settings.options.disableWaterfall && soundEvent.Name.Contains("Waterfall"))
+
+
+            if (go == null || soundEvent == null)
             {
             {
-                return false;
+                return true;
             }
             }
 
 
+            if (Settings.options.disableWaterfall && soundEvent.Name.Contains("Waterfall"))
+            {
+                return false;
+            }
 
 
             if (PatchMaster.PatchAction(soundEvent.Name, go))
             if (PatchMaster.PatchAction(soundEvent.Name, go))
             {
             {

+ 16 - 7
Harmony/RTPCPatches.cs

@@ -14,35 +14,44 @@ namespace AudioMgr
             if (AudioMain._debug)
             if (AudioMain._debug)
                 MelonLogger.Msg("RTPC " + GameParameterIDs.GetString(rtpcID) + "; " + rtpcValue);
                 MelonLogger.Msg("RTPC " + GameParameterIDs.GetString(rtpcID) + "; " + rtpcValue);
 
 
+
+            if (go == null)
+            {
+                return;
+            }
+
+   
             // Aurora music patch
             // Aurora music patch
-            if(Settings.options.enableAuroraTweaks && GameParameterIDs.GetString(rtpcID) == "AURORASTRENGTH") 
+            if (Settings.options.enableAuroraTweaks && GameParameterIDs.GetString(rtpcID) == "AURORASTRENGTH") 
             {
             {
-                if(rtpcValue > Settings.options.auroraVolume) 
+                if (rtpcValue > Settings.options.auroraVolume) 
                 {
                 {
-                    rtpcValue = Settings.options.auroraVolume;
+                    rtpcValue = Settings.options.auroraVolume;                 
                 }
                 }
             }
             }
-
+      
             // Wind audioc patch
             // Wind audioc patch
             if (Settings.options.enableWindTweaks && GameManager.GetWeatherComponent().IsIndoorScene() && (GameParameterIDs.GetString(rtpcID) == "WINDINTENSITYBLEND"))
             if (Settings.options.enableWindTweaks && GameManager.GetWeatherComponent().IsIndoorScene() && (GameParameterIDs.GetString(rtpcID) == "WINDINTENSITYBLEND"))
-            {             
+            {            
                 if (rtpcValue > Settings.options.windVolume)
                 if (rtpcValue > Settings.options.windVolume)
                 {
                 {
+               
                     rtpcValue = Settings.options.windVolume;
                     rtpcValue = Settings.options.windVolume;
                 }
                 }
             }
             }
-                       
 
 
             if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
             if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
             {
             {
+        
                 VolumeMaster.SetMasterVolume(rtpcValue / 100);
                 VolumeMaster.SetMasterVolume(rtpcValue / 100);
 
 
             }
             }
             else if (VolumeIDs.GetRtpcIDList().ContainsKey(rtpcID)) // Set sfx/voice/ambient/bgm
             else if (VolumeIDs.GetRtpcIDList().ContainsKey(rtpcID)) // Set sfx/voice/ambient/bgm
             {
             {
+            
                 VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue / 100);
                 VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue / 100);
             }
             }
-
+          
             rtpcValue = PatchMaster.ParameterAction(GameParameterIDs.GetString(rtpcID), rtpcValue);           
             rtpcValue = PatchMaster.ParameterAction(GameParameterIDs.GetString(rtpcID), rtpcValue);           
         }
         }
     }
     }

+ 3 - 3
Properties/AssemblyInfo.cs

@@ -4,7 +4,7 @@ using AudioMgr;
 
 
 [assembly: AssemblyTitle("AudioManager")]
 [assembly: AssemblyTitle("AudioManager")]
 [assembly: AssemblyCopyright("Digitalzombie")]
 [assembly: AssemblyCopyright("Digitalzombie")]
-[assembly: AssemblyVersion("1.3.3")]
-[assembly: AssemblyFileVersion("1.3.3")]
-[assembly: MelonInfo(typeof(AudioMain), "AudioManager", "1.3.3", "Digitalzombie", null)]
+[assembly: AssemblyVersion("1.3.8")]
+[assembly: AssemblyFileVersion("1.3.8")]
+[assembly: MelonInfo(typeof(AudioMain), "AudioManager", "1.3.8", "Digitalzombie", null)]
 [assembly: MelonGame("Hinterland", "TheLongDark")]
 [assembly: MelonGame("Hinterland", "TheLongDark")]

+ 4 - 0
README.md

@@ -2,6 +2,10 @@
 # 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.3.8!
+- Mod compatibility fix
+- Stuff
+
 ### New: v1.3.3!
 ### New: v1.3.3!
 - Custom music on the radio when the aurora is active ... or not:
 - Custom music on the radio when the aurora is active ... or not:
 Put your mp3 and/or ogg files into the \Mods\AuroraRadio folder and check out the modsettings
 Put your mp3 and/or ogg files into the \Mods\AuroraRadio folder and check out the modsettings