Decompiled source of AbilityPresets v1.0.0

AbilityPresets.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AbilityPresets")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows the user to set ability presets that they can access instantly by pressing buttons")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AbilityPresets")]
[assembly: AssemblyTitle("AbilityPresets")]
[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 AbilityPresets
{
	[BepInPlugin("com.PizzaMan730.AbilityPresets", "AbilityPresets", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigFile config;

		private ConfigEntry<int> Preset1_1;

		private ConfigEntry<int> Preset1_2;

		private ConfigEntry<int> Preset1_3;

		private ConfigEntry<int> Preset2_1;

		private ConfigEntry<int> Preset2_2;

		private ConfigEntry<int> Preset2_3;

		private ConfigEntry<int> Preset3_1;

		private ConfigEntry<int> Preset3_2;

		private ConfigEntry<int> Preset3_3;

		private ConfigEntry<int> Preset4_1;

		private ConfigEntry<int> Preset4_2;

		private ConfigEntry<int> Preset4_3;

		private ConfigEntry<int> Preset5_1;

		private ConfigEntry<int> Preset5_2;

		private ConfigEntry<int> Preset5_3;

		private ConfigEntry<int> Preset6_1;

		private ConfigEntry<int> Preset6_2;

		private ConfigEntry<int> Preset6_3;

		private ConfigEntry<int> Preset7_1;

		private ConfigEntry<int> Preset7_2;

		private ConfigEntry<int> Preset7_3;

		private ConfigEntry<int> Preset8_1;

		private ConfigEntry<int> Preset8_2;

		private ConfigEntry<int> Preset8_3;

		private ConfigEntry<int> Preset9_1;

		private ConfigEntry<int> Preset9_2;

		private ConfigEntry<int> Preset9_3;

		private ConfigEntry<int> Preset0_1;

		private ConfigEntry<int> Preset0_2;

		private ConfigEntry<int> Preset0_3;

		private void Awake()
		{
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AbilityPresets has loaded!");
			config = ((BaseUnityPlugin)this).Config;
			Preset1_1 = config.Bind<int>("Preset 1", "Slot 1", 0, "");
			Preset1_2 = config.Bind<int>("Preset 1", "Slot 2", 0, "");
			Preset1_3 = config.Bind<int>("Preset 1", "Slot 3", 0, "");
			Preset2_1 = config.Bind<int>("Preset 2", "Slot 1", 0, "");
			Preset2_2 = config.Bind<int>("Preset 2", "Slot 2", 0, "");
			Preset2_3 = config.Bind<int>("Preset 2", "Slot 3", 0, "");
			Preset3_1 = config.Bind<int>("Preset 3", "Slot 1", 0, "");
			Preset3_2 = config.Bind<int>("Preset 3", "Slot 2", 0, "");
			Preset3_3 = config.Bind<int>("Preset 3", "Slot 3", 0, "");
			Preset4_1 = config.Bind<int>("Preset 4", "Slot 1", 0, "");
			Preset4_2 = config.Bind<int>("Preset 4", "Slot 2", 0, "");
			Preset4_3 = config.Bind<int>("Preset 4", "Slot 3", 0, "");
			Preset5_1 = config.Bind<int>("Preset 5", "Slot 1", 0, "");
			Preset5_2 = config.Bind<int>("Preset 5", "Slot 2", 0, "");
			Preset5_3 = config.Bind<int>("Preset 5", "Slot 3", 0, "");
			Preset6_1 = config.Bind<int>("Preset 6", "Slot 1", 0, "");
			Preset6_2 = config.Bind<int>("Preset 6", "Slot 2", 0, "");
			Preset6_3 = config.Bind<int>("Preset 6", "Slot 3", 0, "");
			Preset7_1 = config.Bind<int>("Preset 7", "Slot 1", 0, "");
			Preset7_2 = config.Bind<int>("Preset 7", "Slot 2", 0, "");
			Preset7_3 = config.Bind<int>("Preset 7", "Slot 3", 0, "");
			Preset8_1 = config.Bind<int>("Preset 8", "Slot 1", 0, "");
			Preset8_2 = config.Bind<int>("Preset 8", "Slot 2", 0, "");
			Preset8_3 = config.Bind<int>("Preset 8", "Slot 3", 0, "");
			Preset9_1 = config.Bind<int>("Preset 9", "Slot 1", 0, "");
			Preset9_2 = config.Bind<int>("Preset 9", "Slot 2", 0, "");
			Preset9_3 = config.Bind<int>("Preset 9", "Slot 3", 0, "");
			Preset0_1 = config.Bind<int>("Preset 0", "Slot 1", 0, "");
			Preset0_2 = config.Bind<int>("Preset 0", "Slot 2", 0, "");
			Preset0_3 = config.Bind<int>("Preset 0", "Slot 3", 0, "");
			Harmony val = new Harmony("com.PizzaMan730.AbilityPresets");
		}

		private void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Expected O, but got Unknown
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name == "ChSelect_online"))
			{
				activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "CharacterSelect"))
				{
					return;
				}
			}
			bool isPressed = ((ButtonControl)Keyboard.current[(Key)55]).isPressed;
			if (((ButtonControl)Keyboard.current[(Key)41]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset1_1, Preset1_2, Preset1_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset1_1.Value, Preset1_2.Value, Preset1_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)42]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset2_1, Preset2_2, Preset2_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset2_1.Value, Preset2_2.Value, Preset2_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)43]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset3_1, Preset3_2, Preset3_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset3_1.Value, Preset3_2.Value, Preset3_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)44]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset4_1, Preset4_2, Preset4_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset4_1.Value, Preset4_2.Value, Preset4_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)45]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset5_1, Preset5_2, Preset5_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset5_1.Value, Preset5_2.Value, Preset5_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)46]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset6_1, Preset6_2, Preset6_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset6_1.Value, Preset6_2.Value, Preset6_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)47]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset7_1, Preset7_2, Preset7_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset7_1.Value, Preset7_2.Value, Preset7_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)48]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset8_1, Preset8_2, Preset8_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset8_1.Value, Preset8_2.Value, Preset8_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)49]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset9_1, Preset9_2, Preset9_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset9_1.Value, Preset9_2.Value, Preset9_3.Value);
				}
			}
			if (((ButtonControl)Keyboard.current[(Key)50]).wasPressedThisFrame)
			{
				if (isPressed)
				{
					Debug.Log((object)"Saving preset");
					SavePreset(Preset0_1, Preset0_2, Preset0_3);
				}
				else
				{
					Debug.Log((object)"Loading preset");
					LoadPreset(Preset0_1.Value, Preset0_2.Value, Preset0_3.Value);
				}
			}
			if ((Object)(object)GameObject.Find("PresetText") == (Object)null)
			{
				Canvas component = GameObject.Find("Canvas").GetComponent<Canvas>();
				GameObject val = new GameObject("PresetText", new Type[2]
				{
					typeof(RectTransform),
					typeof(TextMeshProUGUI)
				});
				val.transform.SetParent(((Component)component).transform);
				TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>();
				((Graphic)component2).raycastTarget = false;
				((TMP_Text)component2).text = "Press a number key to load that preset\nHold control while pressing to save";
				((Graphic)component2).color = Color.black;
				((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
				((TMP_Text)component2).font = LocalizedText.localizationTable.GetFont(Settings.Get().Language, false);
				((TMP_Text)component2).fontSize = 20f;
				RectTransform component3 = val.GetComponent<RectTransform>();
				Rect rect = ((Component)component).GetComponent<RectTransform>().rect;
				float height = ((Rect)(ref rect)).height;
				float width = ((Rect)(ref rect)).width;
				component3.anchoredPosition = new Vector2((0f - width) / 2f + 600f, (0f - height) / 2f + 100f);
				component3.sizeDelta = new Vector2(width, 100f);
				val.SetActive(true);
			}
		}

		private void SavePreset(ConfigEntry<int> Preset1, ConfigEntry<int> Preset2, ConfigEntry<int> Preset3)
		{
			Transform val = GameObject.Find("Rectangle1").transform.FindChild("SELECT_COLOR");
			Preset1.Value = ((Component)val.FindChild("ability_TOP")).GetComponent<SelectAbility>().SelectedIndex;
			Preset2.Value = ((Component)val.FindChild("ability_MID")).GetComponent<SelectAbility>().SelectedIndex;
			Preset3.Value = ((Component)val.FindChild("ability_BOT")).GetComponent<SelectAbility>().SelectedIndex;
		}

		private void LoadPreset(int Preset1, int Preset2, int Preset3)
		{
			Debug.Log((object)"Test");
			Transform val = GameObject.Find("Rectangle1").transform.FindChild("SELECT_COLOR");
			Debug.Log((object)"Test1");
			((SelectableMonoBehaviour)((Component)val.FindChild("ability_TOP")).GetComponent<SelectAbility>()).Select(Preset1);
			((SelectableMonoBehaviour)((Component)val.FindChild("ability_MID")).GetComponent<SelectAbility>()).Select(Preset2);
			((SelectableMonoBehaviour)((Component)val.FindChild("ability_BOT")).GetComponent<SelectAbility>()).Select(Preset3);
		}
	}
	public enum Abilities
	{
		random,
		dash,
		grenade,
		bow,
		engine,
		blink,
		gust,
		grow,
		rock,
		missile,
		spike,
		time,
		smoke,
		platform,
		revive,
		roll,
		shrink,
		blackhole,
		invisibility,
		meteor,
		macho,
		push,
		tesla,
		mine,
		teleport,
		drill,
		hookshot,
		beam
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AbilityPresets";

		public const string PLUGIN_NAME = "AbilityPresets";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}