Decompiled source of V1LevelSpeak v1.1.1

UK_V1LevelSpeak.dll

Decompiled a day ago
using System.Collections;
using System.Collections.Generic;
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;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("UK_V1LevelSpeak")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CCobaltDev")]
[assembly: AssemblyProduct("UK_V1LevelSpeak")]
[assembly: AssemblyCopyright("Copyright © CCobaltDev 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cd72d91a-1663-40b7-af27-dc0f58ac7a3c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UK_V1LevelSpeak;

[BepInPlugin("ccobaltdev.v1levelspeak", "V1LevelSpeak", "1.1.1")]
public class V1LevelSpeak : BaseUnityPlugin
{
	[HarmonyPatch]
	public static class LevelNamePopup_Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LevelNamePopup), "ShowLayerText")]
		public static void patch_ShowLayerText(LevelNamePopup __instance)
		{
			AudioClip val = clips[GetCurrentLevel() + "-1"];
			if ((Object)(object)val != (Object)null)
			{
				AudioSource val2 = ((Component)Camera.main).gameObject.AddComponent<AudioSource>();
				val2.clip = val;
				val2.volume = 1f;
				val2.Play();
				Object.Destroy((Object)(object)val2, 10f);
				((MonoBehaviour)__instance).StartCoroutine(RunInABit(val2.clip.length));
			}
		}

		private static IEnumerator RunInABit(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			AudioClip val = clips[GetCurrentLevel() + "-2"];
			if ((Object)(object)val != (Object)null)
			{
				AudioSource obj = ((Component)Camera.main).gameObject.AddComponent<AudioSource>();
				obj.clip = val;
				obj.volume = 1f;
				obj.Play();
				Object.Destroy((Object)(object)obj, 10f);
			}
		}
	}

	private static ManualLogSource log;

	private static AssetBundle assets;

	private static Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>();

	private static readonly Dictionary<string, string> layerToNumber = new Dictionary<string, string>
	{
		{ "PRELUDE", "0" },
		{ "LIMBO", "1" },
		{ "LUST", "2" },
		{ "GLUTTONY", "3" },
		{ "GREED", "4" },
		{ "WRATH", "5" },
		{ "HERESY", "6" },
		{ "VIOLENCE", "7" },
		{ "FRAUD", "8" },
		{ "TREACHERY", "9" },
		{ "PRIME", "P" }
	};

	private static readonly Dictionary<string, string> numberToWord = new Dictionary<string, string>
	{
		{ "FIRST", "1" },
		{ "SECOND", "2" },
		{ "THIRD", "3" },
		{ "FOURTH", "4" },
		{ "FIFTH", "5" },
		{ "CLIMAX", "4" },
		{ "ENCORE", "E" },
		{ "ACT I CRESCENDO", "1" },
		{ "ACT I CLIMAX", "2" },
		{ "ACT II CRESCENDO", "1" },
		{ "ACT II CLIMAX", "2" },
		{ "ACT III CRESCENDO", "1" },
		{ "ACT III CLIMAX", "2" }
	};

	public void Awake()
	{
		Harmony.CreateAndPatchAll(typeof(LevelNamePopup_Patch), (string)null);
		assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "leveltitles"));
		AudioClip[] array = assets.LoadAllAssets<AudioClip>();
		foreach (AudioClip val in array)
		{
			clips.Add(((Object)val).name, val);
		}
		log = ((BaseUnityPlugin)this).Logger;
	}

	public static string GetCurrentLevel()
	{
		string[] array = MapInfoBase.Instance.layerName.Split(new char[1] { ' ' });
		string text = numberToWord[string.Join(" ", array.Skip(2))];
		if (array[0] == "PRELUDE" && array[2] == "CLIMAX")
		{
			text = "5";
		}
		return layerToNumber[array[0]] + "-" + text;
	}
}