Decompiled source of LCNeedyStreamerOverloadSoundPackMod v1.0.1

LCNeedyStreamerOverloadSoundPackMod.dll

Decompiled 3 months ago
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.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("LCNeedyStreamerOverloadSoundPackMod")]
[assembly: AssemblyTitle("LCNeedyStreamerOverloadSoundPackMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.1")]
	public class Plugin : BaseUnityPlugin
	{
		public class Config
		{
			public static ConfigEntry<bool> configAddOrOverwrite;

			public Config(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).");
			}
		}

		public static Plugin instance;

		internal static ManualLogSource Logger;

		public static AssetBundle NSOAssetBundle;

		public static AudioClip[] NSOSoundTrack;

		public static string sAssemblyLocation;

		public static bool AddSongs = true;

		public static Config MyConfig { get; internal set; }

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin LCNeedyStreamerOverloadSoundPackMod is loaded!");
			Harmony val = new Harmony("LCNeedyStreamerOverloadSoundPackMod");
			val.PatchAll();
			HarmonyFileLog.Enabled = false;
			MyConfig = new Config(((BaseUnityPlugin)this).Config);
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			NSOAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "nsoassetbundle"));
			if ((Object)(object)NSOAssetBundle == (Object)null)
			{
				Logger.LogError((object)"Failed to load NSO AssetBundle");
				AddSongs = false;
				return;
			}
			Logger.LogInfo((object)"Loaded NSO AssetBundle");
			LoadSongs();
			if (Config.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 LoadSongs()
		{
			NSOSoundTrack = NSOAssetBundle.LoadAllAssets<AudioClip>();
		}

		public static void SetBoomboxOnStart(BoomboxItem __instance)
		{
			if (AddSongs)
			{
				if (Config.configAddOrOverwrite.Value)
				{
					List<AudioClip> list = __instance.musicAudios.ToList();
					list.AddRange(NSOSoundTrack);
					__instance.musicAudios = list.ToArray();
				}
				else if (!Config.configAddOrOverwrite.Value)
				{
					__instance.musicAudios = NSOSoundTrack;
				}
				__instance.musicRandomizer = new Random(GetRandomSeed());
			}
		}

		public static int GetRandomSeed()
		{
			int num = Random.Range(0, 10);
			int num2 = Random.Range(0, 10);
			int num3 = Random.Range(0, 10);
			int num4 = Random.Range(0, 10);
			int num5 = Random.Range(0, 10);
			string s = num.ToString() + num2 + num3 + num4 + num5;
			return int.Parse(s);
		}
	}
	[HarmonyPatch(typeof(BoomboxItem), "Start")]
	public class NewBoomboxStart
	{
		[HarmonyPostfix]
		public static void Postfix(BoomboxItem __instance)
		{
			Plugin.SetBoomboxOnStart(__instance);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LCNeedyStreamerOverloadSoundPackMod";

		public const string PLUGIN_NAME = "LCNeedyStreamerOverloadSoundPackMod";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}