using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using StarlancerMusic.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StarlancerMusic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StarlancerMusic")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("aeae5378-d9a5-44a1-b268-280a716b4299")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StarlancerMusic
{
[BepInPlugin("AudioKnight.StarlancerMusic", "Starlancer Music", "1.0.0")]
public class StarlancerMusicBase : BaseUnityPlugin
{
private const string modGUID = "AudioKnight.StarlancerMusic";
private const string modName = "Starlancer Music";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("AudioKnight.StarlancerMusic");
private static StarlancerMusicBase Instance;
public static AssetBundle StarlancerMusicBundle;
internal static ManualLogSource logger;
public static string sAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static ConfigEntry<bool> vanillaMusic;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = ((BaseUnityPlugin)this).Logger;
logger.LogInfo((object)"Starlancer Music Online.");
StarlancerMusicBundle = AssetBundle.LoadFromFile(Path.Combine(sAssemblyLocation, "starlancermusic"));
harmony.PatchAll(typeof(StarlancerMusicBase));
harmony.PatchAll(typeof(BoomboxItemPatch));
vanillaMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("VanillaMusic", "RemoveMusic", false, "Whether or not to remove vanilla boombox music");
if ((Object)(object)StarlancerMusicBundle == (Object)null)
{
logger.LogError((object)"Failed to load Starlancer Music.");
}
}
}
}
namespace StarlancerMusic.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("StarlancerMusic.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}
namespace StarlancerMusic.Patches
{
internal class BoomboxItemPatch
{
internal static AudioClip[] StarMusic = StarlancerMusicBase.StarlancerMusicBundle.LoadAllAssets<AudioClip>();
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
[HarmonyPostfix]
private static void LoadMusic()
{
BoomboxItem[] array = Resources.FindObjectsOfTypeAll<BoomboxItem>();
BoomboxItem[] array2 = array;
foreach (BoomboxItem val in array2)
{
if (StarlancerMusicBase.vanillaMusic.Value)
{
val.musicAudios = (AudioClip[])(object)new AudioClip[0];
}
val.musicAudios = CollectionExtensions.AddRangeToArray<AudioClip>(val.musicAudios, StarMusic);
}
}
}
}