using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HarmonyLib.Tools;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LCNeedyStreamerOverloadSoundPackMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Add 26 songs from Needy Streamer Overload to the Boombox!")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("LCNeedyStreamerOverloadSoundPackMod")]
[assembly: AssemblyTitle("LCNeedyStreamerOverloadSoundPackMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LCNeedyStreamerOverloadSoundPackMod
{
[BepInPlugin("LCNeedyStreamerOverloadSoundPackMod", "LCNeedyStreamerOverloadSoundPackMod", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public class Configs
{
public static ConfigEntry<bool> configAddOrOverwrite;
public Configs(ConfigFile cfg)
{
configAddOrOverwrite = cfg.Bind<bool>("Boombox Options", "Add Or Overwrite", true, "Choose whether the Needy Streamer Overload / Needy Girl Overdose music is added to the total list of Boombox songs (true), or is the only music used by the Boombox (false).");
}
}
internal static ManualLogSource Logger;
public static AssetBundle NSOAssetBundle;
public static bool addedMusic;
public static Configs MyConfig { get; internal set; }
private void Awake()
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin LCNeedyStreamerOverloadSoundPackMod is loaded!");
NSOAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "nsoassetbundle"));
if ((Object)(object)NSOAssetBundle == (Object)null)
{
Logger.LogError((object)"Failed to load NSO AssetBundle");
return;
}
Logger.LogDebug((object)"Loaded NSO AssetBundle");
new Harmony("LCNeedyStreamerOverloadSoundPackMod").PatchAll();
HarmonyFileLog.Enabled = false;
MyConfig = new Configs(((BaseUnityPlugin)this).Config);
if (Configs.configAddOrOverwrite.Value)
{
Logger.LogInfo((object)"Config [Add Or Overwrite] is set to TRUE. NSO/NGO songs will be added to the total list of songs.");
}
else
{
Logger.LogInfo((object)"Config [Add Or Overwrite] is set to FALSE. NSO/NGO songs will try to be the only songs in the playlist.");
}
}
public static void AddSongsToBoombox(BoomboxItem __instance)
{
if (!((Object)(object)NSOAssetBundle == (Object)null))
{
if (Configs.configAddOrOverwrite.Value)
{
List<AudioClip> list = __instance.musicAudios.ToList();
list.AddRange(NSOAssetBundle.LoadAllAssets<AudioClip>());
__instance.musicAudios = list.ToArray();
}
else
{
__instance.musicAudios = NSOAssetBundle.LoadAllAssets<AudioClip>();
}
addedMusic = true;
}
}
}
[HarmonyPatch(typeof(StartOfRound), "Start")]
public class NewStartOfRound
{
[HarmonyPrefix]
public static void Prefix(StartOfRound __instance)
{
if (Plugin.addedMusic)
{
return;
}
foreach (Item items in __instance.allItemsList.itemsList)
{
if (((Object)items).name == "Boombox")
{
BoomboxItem component = items.spawnPrefab.GetComponent<BoomboxItem>();
if ((Object)(object)component != (Object)null)
{
Plugin.AddSongsToBoombox(component);
break;
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LCNeedyStreamerOverloadSoundPackMod";
public const string PLUGIN_NAME = "LCNeedyStreamerOverloadSoundPackMod";
public const string PLUGIN_VERSION = "1.0.2";
}
}