using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ExtraMusicforDroneBoomBox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ExtraMusicforDroneBoomBox")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1095bd70-163c-4b94-8a92-55e04b96b739")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.ZeroTails.ExtraMusicforDroneBoomBox", "Extra Music for DroneBoomBox", "1.0.7")]
public class MusicInjector : BaseUnityPlugin
{
private string modDirectoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Extra Music for DroneBoomBox loaded!");
string text = FindMusicFolder();
if (text == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"No folder containing 'XiaohaiMod-DroneBoomBox' found in the plugin path.");
return;
}
string text2 = Path.Combine(text, "Music");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Music folder resolved to: " + text2));
if (Directory.Exists(modDirectoryPath))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Mod directory found at: " + modDirectoryPath));
if (!Directory.Exists(text2))
{
Directory.CreateDirectory(text2);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Music folder created at: " + text2));
}
CopyAudioFiles(modDirectoryPath, text2);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Audio files successfully copied to the Music folder.");
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)("Mod directory not found at: " + modDirectoryPath + ". Please ensure the audio files are in the same directory as the .dll."));
}
}
private string FindMusicFolder()
{
DirectoryInfo directoryInfo = new DirectoryInfo(Paths.PluginPath);
return directoryInfo.GetDirectories().FirstOrDefault((DirectoryInfo dir) => dir.Name.Contains("XiaohaiMod-DroneBoomBox"))?.FullName;
}
private void CopyAudioFiles(string sourceDir, string destDir)
{
DirectoryInfo directoryInfo = new DirectoryInfo(sourceDir);
FileInfo[] array = directoryInfo.GetFiles("*.mp3").Concat(directoryInfo.GetFiles("*.ogg")).Concat(directoryInfo.GetFiles("*.wav"))
.ToArray();
FileInfo[] array2 = array;
foreach (FileInfo fileInfo in array2)
{
string text = Path.Combine(destDir, fileInfo.Name);
fileInfo.CopyTo(text, overwrite: true);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Copied " + fileInfo.Name + " to " + text));
}
}
}