Decompiled source of Rebindable Keys v0.1.0

RebindableKeys.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2Cpp;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using rebindableKeys;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(RebindableKeys), "Rebindable Keys", "1.0.0", "Friendly Fish", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RebindableKeys")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RebindableKeys")]
[assembly: AssemblyTitle("RebindableKeys")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace rebindableKeys
{
	public class RebindableKeys : MelonMod
	{
		public const string LIFT_KEYBIND_ACTION_NAME = "_LiftTool";

		public static InputAction liftAction;

		public override void OnUpdate()
		{
			if (Object.op_Implicit((Object)(object)GameManager.Instance) && Object.op_Implicit((Object)(object)ToolController.Instance) && !GameManager.Instance.IsStarted && liftAction != null && liftAction.WasPerformedThisFrame())
			{
				ToolController.Instance.LiftTool();
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
			if (sceneName != "Jinko")
			{
				KeybindPreferences val = Object.FindFirstObjectByType<KeybindPreferences>();
				InputActionAsset inputActionAsset = val.inputActionAsset;
				InputActionMap val2 = inputActionAsset.FindActionMap("Player", false);
				liftAction = val2.FindAction("_LiftTool", false);
				if (liftAction == null)
				{
					inputActionAsset.Disable();
					liftAction = InputActionSetupExtensions.AddAction(val2, "_LiftTool", (InputActionType)1, (string)null, (string)null, (string)null, (string)null, (string)null);
					InputActionSetupExtensions.AddBinding(liftAction, "<Keyboard>/Tab", (string)null, (string)null, (string)null);
					inputActionAsset.Enable();
				}
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
				((Object)val3).name = "Lift";
				KeybindPreferences liftKeybindPreferences = val3.GetComponent<KeybindPreferences>();
				liftKeybindPreferences.actionName = "_LiftTool";
				GameObject gameObject = ((Component)FindInActiveObjectByName("Lift Keybind").transform.GetChild(0)).gameObject;
				MelonLogger.Msg(((Object)gameObject).name);
				RectTransform component = gameObject.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(240f, component.sizeDelta.y);
				component.anchoredPosition = new Vector2(-241f, component.anchoredPosition.y);
				GameObject val4 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
				RectTransform component2 = val4.GetComponent<RectTransform>();
				component2.sizeDelta = new Vector2(221f, component.sizeDelta.y);
				component2.anchoredPosition = new Vector2(0f, component2.anchoredPosition.y);
				Color color = default(Color);
				ColorUtility.TryParseHtmlString("#D9BB86", ref color);
				((Graphic)val4.GetComponent<Image>()).color = color;
				Button component3 = val4.GetComponent<Button>();
				AudioSource uiClickSound = GameObject.Find("UI Click Sound").GetComponent<AudioSource>();
				((UnityEvent)component3.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					uiClickSound.Play();
				}));
				((UnityEvent)component3.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					liftKeybindPreferences.StartRebinding();
				}));
				liftKeybindPreferences.keybindText = ((Component)val4.transform.GetChild(0)).GetComponent<Text>();
			}
		}

		private GameObject FindInActiveObjectByName(string name)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = ((IEnumerable<Transform>)Resources.FindObjectsOfTypeAll<Transform>()).ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				if ((int)((Object)array[i]).hideFlags == 0 && ((Object)array[i]).name == name)
				{
					return ((Component)array[i]).gameObject;
				}
			}
			return null;
		}
	}
}