DigitalzombieTLD 2 年之前
父节点
当前提交
308ea3ef66
共有 7 个文件被更改,包括 63 次插入23 次删除
  1. 1 1
      AudioMain.cs
  2. 19 9
      Components/Shot.cs
  3. 7 1
      Harmony/AudioSimplePatches.cs
  4. 13 2
      Harmony/PlaySoundPatches.cs
  5. 16 7
      Harmony/RTPCPatches.cs
  6. 3 3
      Properties/AssemblyInfo.cs
  7. 4 0
      README.md

+ 1 - 1
AudioMain.cs

@@ -22,7 +22,7 @@ namespace AudioMgr
             ClassInjector.RegisterTypeInIl2Cpp<Queue>();
             ClassInjector.RegisterTypeInIl2Cpp<Stream>();
             RadioMaster.Initialize();
-            AudioMgr.Settings.OnLoad();
+            Settings.OnLoad();
             //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 bool _isEnabled = false;
@@ -63,6 +63,15 @@ namespace AudioMgr
             VolumeMaster.onVolumeChange -= ResetVolume;
         }
 
+        [HideFromIl2Cpp]
+        public void ResetVolume()
+        {
+            if (_audioSource)
+            {
+                _audioSource.volume = VolumeMaster.GetVolume(_sourceType);
+            }
+        }
+
         [HideFromIl2Cpp]
         public void SetVolume(float newVolume)
         {          
@@ -96,6 +105,14 @@ namespace AudioMgr
             MelonCoroutines.Start(PlayRoutine(audioClip));
         }
 
+        [HideFromIl2Cpp]
+        public void Play()
+        {
+            Stop();
+            _playState = PlayState.Playing;
+            _audioSource.Play();
+        }
+
         private IEnumerator PlayRoutine(Clip audioClip)
         {
             double _startTime = AudioSettings.dspTime + 0.6;
@@ -119,14 +136,7 @@ namespace AudioMgr
             _audioSource.Stop();
         }
 
-        [HideFromIl2Cpp]
-        public void ResetVolume()
-        {
-            if (_audioSource)
-            {
-                _audioSource.volume = VolumeMaster.GetVolume(_sourceType);
-            }
-        }
+        
 
         [HideFromIl2Cpp]
         public void PlayOneshot(Clip audioClip)

+ 7 - 1
Harmony/AudioSimplePatches.cs

@@ -14,12 +14,18 @@ namespace AudioMgr
             if (AudioMain._debug)
                 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"))
             {
+              
                 return false;
             }
 
-
             if (PatchMaster.PatchAction(__instance.name, __instance.gameObject))
             {
                 return false;

+ 13 - 2
Harmony/PlaySoundPatches.cs

@@ -38,6 +38,11 @@ namespace AudioMgr
             if (AudioMain._debug)
                 MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
 
+            if(go == null)
+            {
+                return true;
+            }
+
             if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
             {
                 return false;
@@ -55,11 +60,17 @@ namespace AudioMgr
             if (AudioMain._debug)
                 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))
             {

+ 16 - 7
Harmony/RTPCPatches.cs

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

+ 3 - 3
Properties/AssemblyInfo.cs

@@ -4,7 +4,7 @@ using AudioMgr;
 
 [assembly: AssemblyTitle("AudioManager")]
 [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")]

+ 4 - 0
README.md

@@ -2,6 +2,10 @@
 # AudioManager
 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!
 - 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