Decompiled source of MaxwellBoombox v1.0.0

BepInEx/plugins/MaxwellBoombox.dll

Decompiled 8 months 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 HarmonyLib;
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("MaxwellBoombox")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes the boombox into Maxwell the cat.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6b475e219840981e634dce245becbe44e58aa1cc")]
[assembly: AssemblyProduct("MaxwellBoombox")]
[assembly: AssemblyTitle("MaxwellBoombox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 MaxwellBoombox
{
	[BepInPlugin("MaxwellBoombox", "MaxwellBoombox", "1.0.0")]
	public class MaxwellBoombox : BaseUnityPlugin
	{
		public static GameObject maxwellObject;

		private void Awake()
		{
			LoadMaxwellBundle();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaxwellBoombox is loaded!");
		}

		private void LoadMaxwellBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			directoryName = Path.Combine(directoryName, "Bundles", "maxwell");
			AssetBundle val = AssetBundle.LoadFromFile(directoryName);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Failed to load Maxwell bundle!");
				return;
			}
			maxwellObject = val.LoadAsset<GameObject>("Assets/Prefabs/maxwell.prefab");
			if ((Object)(object)maxwellObject == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Failed to load Maxwell object!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded the Maxwell object!");
			}
		}
	}
	public class MaxwellManager : MonoBehaviour
	{
		private int maxStates = 4;

		private int curState = -1;

		private Animator animator = null;

		private void Awake()
		{
			animator = ((Component)this).GetComponentInChildren<Animator>();
		}

		public void Toggle(bool on)
		{
			if (on)
			{
				curState = (curState + 1) % maxStates;
				animator.SetInteger("anim", curState);
			}
			else
			{
				animator.SetInteger("anim", -1);
			}
		}
	}
	[HarmonyPatch]
	public static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(BoomboxItem), "Start")]
		public static void MakeMaxwell(BoomboxItem __instance)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Object.Destroy((Object)(object)((Component)__instance).gameObject.GetComponent<MeshRenderer>());
			GameObject val = Object.Instantiate<GameObject>(MaxwellBoombox.maxwellObject, ((Component)__instance).transform);
			val.transform.localScale = new Vector3(45.3511f, 44.8757f, 70.3447f);
			val.transform.localPosition = new Vector3(-8.5f, 0f, 0f);
			val.transform.localEulerAngles = Vector3.zero;
			((Component)__instance).gameObject.AddComponent<MaxwellManager>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BoomboxItem), "StartMusic")]
		public static void OnBoomboxToggle(bool startMusic, BoomboxItem __instance)
		{
			((Component)__instance).gameObject.GetComponent<MaxwellManager>().Toggle(startMusic);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MaxwellBoombox";

		public const string PLUGIN_NAME = "MaxwellBoombox";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}