Decompiled source of HotZoneMainMenu v1.0.0

HotZoneMainMenu/ThemeReplacer.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ThemeReplacer.Patches;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ThemeReplacer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Theme Replacer")]
[assembly: AssemblyTitle("ThemeReplacer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ThemeReplacer
{
	[BepInPlugin("ro.wolftech.dogle.themereplacer", "Theme Replacer", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin Theme Replacer is loaded!");
			new Harmony("ro.wolftech.dogle.themereplacer").PatchAll(typeof(MenuPatch));
		}
	}
	public static class PluginInformation
	{
		public const string GUID = "ro.wolftech.dogle.themereplacer";

		public const string Name = "Theme Replacer";

		public const string Version = "1.0.0";
	}
}
namespace ThemeReplacer.Patches
{
	public static class MenuPatch
	{
		public static AudioClip LoadClip(string path)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			if (Environment.OSVersion.Platform == PlatformID.Unix)
			{
				path = "file://" + path;
			}
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)0);
			try
			{
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				if ((int)audioClip.result != 1)
				{
					Debug.LogError((object)("Error loading " + path + " (" + audioClip.error + ")"));
					return null;
				}
				return DownloadHandlerAudioClip.GetContent(audioClip);
			}
			finally
			{
				((IDisposable)audioClip)?.Dispose();
			}
		}

		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPrefix]
		public static void ReplaceTheme()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "menu.wav");
			Plugin.Logger.LogInfo((object)("Checking " + text + "..."));
			if (!File.Exists(text))
			{
				Plugin.Logger.LogInfo((object)"No replacement menu.wav exists (why do you even have the mod installed then lol)");
				return;
			}
			GameObject val = GameObject.Find("WKTheme");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Plugin.Logger.LogInfo((object)"WKTheme not found (????)");
				return;
			}
			AudioSource component = val.GetComponent<AudioSource>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Plugin.Logger.LogInfo((object)"WKTheme audio source not found (????)");
				return;
			}
			AudioClip val2 = LoadClip(text);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Plugin.Logger.LogError((object)"Replacement menu.wav couldn't load correctly");
				return;
			}
			component.Stop();
			component.clip = val2;
			component.Play();
			Plugin.Logger.LogInfo((object)"done! YAY!");
		}
	}
}