|  | @@ -3,6 +3,7 @@ using Harmony;
 | 
	
		
			
				|  |  |  using Illusion.Game;
 | 
	
		
			
				|  |  |  using System;
 | 
	
		
			
				|  |  |  using System.Collections;
 | 
	
		
			
				|  |  | +using System.IO;
 | 
	
		
			
				|  |  |  using System.Reflection;
 | 
	
		
			
				|  |  |  using UnityEngine;
 | 
	
		
			
				|  |  |  using UnityEngine.SceneManagement;
 | 
	
	
		
			
				|  | @@ -56,20 +57,10 @@ namespace ResourceRedirector
 | 
	
		
			
				|  |  |          public static FieldInfo f_typeObjects = typeof(Manager.Sound).GetField("typeObjects", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
	
		
			
				|  |  |          public static FieldInfo f_settingObjects = typeof(Manager.Sound).GetField("settingObjects", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
	
		
			
				|  |  |          public static PropertyInfo f_clip = typeof(LoadAudioBase).GetProperty("clip", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public static void BindPreHook(ref LoadSound script)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            if (script.audioSource == null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                int type = (int)script.type;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                Transform[] typeObjects = (Transform[])f_typeObjects.GetValue(Manager.Game.Instance);
 | 
	
		
			
				|  |  | -                GameObject[] settingObjects = (GameObject[])f_settingObjects.GetValue(Manager.Game.Instance);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                Manager.Sound.Instance.SetParent(typeObjects[type], script, settingObjects[type]);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              if (script.clip.name.StartsWith("bgm"))
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  string path;
 | 
	
	
		
			
				|  | @@ -78,29 +69,46 @@ namespace ResourceRedirector
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      case BGM.Title:
 | 
	
		
			
				|  |  |                      default:
 | 
	
		
			
				|  |  | -                        path = "file://" + BepInEx.Common.Utility.PluginsDirectory.Replace('\\', '/') + "/title.wav";
 | 
	
		
			
				|  |  | +                        path = $"{BepInEx.Common.Utility.PluginsDirectory}\\title.wav";
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                      case BGM.Custom:
 | 
	
		
			
				|  |  | -                        path = "file://" + BepInEx.Common.Utility.PluginsDirectory.Replace('\\', '/') + "/custom.wav";
 | 
	
		
			
				|  |  | +                        path = $"{BepInEx.Common.Utility.PluginsDirectory}\\custom.wav";
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                if (!File.Exists(path))
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  |                  
 | 
	
		
			
				|  |  | -                Console.WriteLine($"Loaded {path}");
 | 
	
		
			
				|  |  | -                WWW loadGachi = new WWW(path);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                AudioClip clip = loadGachi.GetAudioClip(false);
 | 
	
		
			
				|  |  | +                Console.WriteLine($"Loading {path}");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                //force single threaded loading instead of using a coroutine
 | 
	
		
			
				|  |  | -                while (!clip.isReadyToPlay) { }
 | 
	
		
			
				|  |  | +                path = $"file://{path.Replace('\\', '/')}";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                script.audioSource.clip = clip;
 | 
	
		
			
				|  |  | +                if (script.audioSource == null)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    int type = (int)script.type;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                f_clip.SetValue(script, clip, null);
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                loadGachi.Dispose();
 | 
	
		
			
				|  |  | +                    Transform[] typeObjects = (Transform[])f_typeObjects.GetValue(Manager.Game.Instance);
 | 
	
		
			
				|  |  | +                    GameObject[] settingObjects = (GameObject[])f_settingObjects.GetValue(Manager.Game.Instance);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    Manager.Sound.Instance.SetParent(typeObjects[type], script, settingObjects[type]);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                using (WWW loadGachi = new WWW(path))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    AudioClip clip = loadGachi.GetAudioClipCompressed(false, AudioType.WAV);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    //force single threaded loading instead of using a coroutine
 | 
	
		
			
				|  |  | +                    while (!clip.isReadyToPlay) { }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    script.audioSource.clip = clip;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    f_clip.SetValue(script, clip, null);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 |