Decompiled source of GamepadPlus v1.0.1

plugins/GamepadPlus.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public static class Players
{
	public class Data
	{
		public SplitPlayer Split;

		public Character Character;

		public PlayerCharacterStats Stats;

		public CharacterCamera Camera;

		public CharacterUI UI;

		public PlayerSystem System;

		public int ID;

		public string UID;

		public bool IsUsingGamepad => GameInput.IsUsingGamepad(ID);

		public Vector2 CameraMovementInput => new Vector2(GameInput.AxisValue(ID, (GameplayActions)2), GameInput.AxisValue(ID, (GameplayActions)3));

		public Vector2 PlayerMovementInput => new Vector2(GameInput.AxisValue(ID, (GameplayActions)0), GameInput.AxisValue(ID, (GameplayActions)1));

		public bool Pressed(string actionName)
		{
			return GameInput.Pressed(ID, actionName);
		}

		public bool Released(string actionName)
		{
			return GameInput.Released(ID, actionName);
		}

		public bool Held(string actionName)
		{
			return GameInput.Held(ID, actionName);
		}

		public float AxisValue(string axisName)
		{
			return GameInput.AxisValue(ID, axisName);
		}

		public bool Pressed(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Pressed(ID, gameplayAction);
		}

		public bool Released(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Released(ID, gameplayAction);
		}

		public bool Held(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Held(ID, gameplayAction);
		}

		public float AxisValue(GameplayActions gameplayAxis)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.AxisValue(ID, gameplayAxis);
		}

		public bool Pressed(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Pressed(ID, menuAction);
		}

		public bool Released(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Released(ID, menuAction);
		}

		public bool Held(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Held(ID, menuAction);
		}

		public float AxisValue(MenuActions menuAxis)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.AxisValue(ID, menuAxis);
		}
	}

	[HarmonyPatch(typeof(LocalCharacterControl), "RetrieveComponents")]
	public class LocalCharacterControl_RetrieveComponents
	{
		[HarmonyPostfix]
		public static void Postfix(LocalCharacterControl __instance, Character ___m_character)
		{
			Recache();
		}
	}

	[HarmonyPatch(typeof(RPCManager), "SendPlayerHasLeft")]
	public class RPCManager_SendPlayerHasLeft
	{
		[HarmonyPostfix]
		public static void Postfix(RPCManager __instance, string _playerUID)
		{
			Recache();
		}
	}

	public static List<Data> Local { get; private set; }

	public static Data GetFirst()
	{
		return UnityEngineExtensions.FirstOrDefault<Data>((IList<Data>)Local);
	}

	public static Data GetLocal(int playerID)
	{
		return Local.DefaultOnInvalid(playerID);
	}

	public static Data GetLocal(LocalCharacterControl localCharacterControl)
	{
		return GetLocal(GetPlayerID(localCharacterControl));
	}

	public static Data GetLocal(UIElement uiElement)
	{
		return GetLocal(GetPlayerID(uiElement));
	}

	public static Data GetLocal(Character character)
	{
		return GetLocal(GetPlayerID(character));
	}

	public static Data GetLocal(CharacterUI characterUI)
	{
		return GetLocal(GetPlayerID(characterUI));
	}

	public static Data GetLocal(CharacterCamera characterCamera)
	{
		return GetLocal(GetPlayerID(characterCamera));
	}

	public static bool TryGetFirst(out Data player)
	{
		return GetFirst().TryNonNull(out player);
	}

	public static bool TryGetLocal(int playerID, out Data player)
	{
		player = GetLocal(playerID);
		return player != null;
	}

	public static bool TryGetLocal(LocalCharacterControl localCharacterControl, out Data player)
	{
		return TryGetLocal(GetPlayerID(localCharacterControl), out player);
	}

	public static bool TryGetLocal(UIElement uiElement, out Data player)
	{
		return TryGetLocal(GetPlayerID(uiElement), out player);
	}

	public static bool TryGetLocal(Character character, out Data player)
	{
		return TryGetLocal(GetPlayerID(character), out player);
	}

	public static bool TryGetLocal(CharacterUI characterUI, out Data player)
	{
		return TryGetLocal(GetPlayerID(characterUI), out player);
	}

	public static bool TryGetLocal(CharacterCamera characterCamera, out Data player)
	{
		return TryGetLocal(GetPlayerID(characterCamera), out player);
	}

	private static void Recache()
	{
		Local.Clear();
		foreach (SplitPlayer localPlayer in SplitScreenManager.Instance.LocalPlayers)
		{
			Character assignedCharacter = localPlayer.AssignedCharacter;
			PlayerSystem ownerPlayerSys = assignedCharacter.OwnerPlayerSys;
			Local.Add(new Data
			{
				Split = localPlayer,
				Character = assignedCharacter,
				Stats = assignedCharacter.PlayerStats,
				Camera = assignedCharacter.CharacterCamera,
				UI = assignedCharacter.CharacterUI,
				System = ownerPlayerSys,
				ID = ownerPlayerSys.PlayerID,
				UID = ownerPlayerSys.UID
			});
		}
	}

	private static int GetPlayerID(LocalCharacterControl localCharacterControl)
	{
		return ((CharacterControl)localCharacterControl).Character.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(UIElement uiElement)
	{
		return uiElement.LocalCharacter.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(Character character)
	{
		return character.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(CharacterUI characterUI)
	{
		return characterUI.TargetCharacter.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(CharacterCamera characterCamera)
	{
		return characterCamera.TargetCharacter.OwnerPlayerSys.PlayerID;
	}

	public static void Initialize()
	{
		Local = new List<Data>();
		Harmony.CreateAndPatchAll(typeof(Players), (string)null);
	}
}
public static class GameInput
{
	public static float HOLD_DURATION = 1.25f;

	public static float HOLD_THRESHOLD = 0.4f;

	public static bool ForceCursorNavigation;

	private static Dictionary<string, KeyCode> _keyCodesByName;

	public static bool Pressed(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButtonDown(actionName);
	}

	public static bool Released(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButtonUp(actionName);
	}

	public static bool Held(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButton(actionName);
	}

	public static float AxisValue(int playerID, string axisnName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetAxis(axisnName);
	}

	public static bool IsUsingGamepad(int playerID)
	{
		return ControlsInput.IsLastActionGamepad(playerID);
	}

	public static KeyCode ToKeyCode(string text)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!text.IsNotEmpty() || !_keyCodesByName.ContainsKey(text))
		{
			return (KeyCode)0;
		}
		return _keyCodesByName[text];
	}

	public static string ToName(this GameplayActions action)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		return ControlsInput.GetGameplayActionName(action);
	}

	public static string ToName(this MenuActions action)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		return ControlsInput.GetMenuActionName(action);
	}

	public static bool Pressed(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Pressed(playerID, gameplayAction.ToName());
	}

	public static bool Released(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Released(playerID, gameplayAction.ToName());
	}

	public static bool Held(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Held(playerID, gameplayAction.ToName());
	}

	public static float AxisValue(int playerID, GameplayActions gameplayAxis)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return AxisValue(playerID, gameplayAxis.ToName());
	}

	public static bool Pressed(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Pressed(playerID, menuAction.ToName());
	}

	public static bool Released(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Released(playerID, menuAction.ToName());
	}

	public static bool Held(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Held(playerID, menuAction.ToName());
	}

	public static float AxisValue(int playerID, MenuActions menuAxis)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return AxisValue(playerID, menuAxis.ToName());
	}

	public static void Initialize()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		_keyCodesByName = new Dictionary<string, KeyCode>();
		foreach (KeyCode value2 in Enum.GetValues(typeof(KeyCode)))
		{
			KeyCode value = value2;
			string text = ((object)(KeyCode)(ref value)).ToString();
			if (!text.Contains("Joystick") && !_keyCodesByName.ContainsKey(text))
			{
				_keyCodesByName.Add(text, value);
			}
		}
		Harmony.CreateAndPatchAll(typeof(GameInput), (string)null);
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static bool CharacterUI_IsMenuFocused_Getter_Pre(ref bool __result)
	{
		if (!ForceCursorNavigation)
		{
			return true;
		}
		__result = true;
		return false;
	}
}
public static class Collections_IList
{
	public static bool IsValid<T>(this IList<T> t, int a)
	{
		if (a >= 0)
		{
			return a < t.Count;
		}
		return false;
	}

	public static T DefaultOnInvalid<T>(this IList<T> t, int a)
	{
		if (!t.IsValid(a))
		{
			return default(T);
		}
		return t[a];
	}

	public static T First<T>(this IList<T> t)
	{
		return t[0];
	}

	public static T FirstNonNull<T>(this IList<T> t) where T : class
	{
		for (int i = 0; i < t.Count; i++)
		{
			if (t[i] != null)
			{
				return t[i];
			}
		}
		return null;
	}

	public static T Last<T>(this IList<T> t)
	{
		return t[t.Count - 1];
	}

	public static T LastNonNull<T>(this IList<T> t) where T : class
	{
		for (int num = t.Count - 1; num >= 0; num--)
		{
			if (t[num] != null)
			{
				return t[num];
			}
		}
		return null;
	}

	public static void SetFirst<T>(this IList<T> t, T a)
	{
		t[0] = a;
	}

	public static void SetFirstNonNull<T>(this IList<T> t, T a) where T : class
	{
		for (int i = 0; i < t.Count; i++)
		{
			if (t[i] != null)
			{
				t[i] = a;
				break;
			}
		}
	}

	public static void SetLast<T>(this IList<T> t, T a)
	{
		t[t.Count - 1] = a;
	}

	public static void SetLastNonNull<T>(this IList<T> t, T a) where T : class
	{
		for (int num = t.Count - 1; num >= 0; num--)
		{
			if (t[num] != null)
			{
				t[num] = a;
				break;
			}
		}
	}

	public static void RemoveFirst<T>(this IList<T> t)
	{
		t.RemoveAt(0);
	}

	public static void RemoveFirstNonNull<T>(this IList<T> t)
	{
		for (int i = 0; i < t.Count; i++)
		{
			if (t[i] != null)
			{
				t.RemoveAt(i);
				break;
			}
		}
	}

	public static void RemoveLast<T>(this IList<T> t)
	{
		t.RemoveAt(t.Count - 1);
	}

	public static void RemoveLastNonNull<T>(this IList<T> t)
	{
		for (int num = t.Count - 1; num >= 0; num--)
		{
			if (t[num] != null)
			{
				t.RemoveAt(num);
				break;
			}
		}
	}

	public static bool TryGet<T>(this IList<T> t, int a, out T r)
	{
		if (a >= 0 && a < t.Count)
		{
			r = t[a];
			return true;
		}
		r = default(T);
		return false;
	}

	public static bool TryGetNonNull<T>(this IList<T> t, int a, out T r) where T : class
	{
		if (a >= 0 && a < t.Count && t[a] != null)
		{
			r = t[a];
			return true;
		}
		r = null;
		return false;
	}
}
public static class Tools
{
	public static bool TryNonNull<T>(this T t, out T r) where T : class
	{
		r = t;
		return r != null;
	}

	public static bool TryNonNull<T>(this T? t, out T r) where T : struct
	{
		if (t.HasValue)
		{
			r = t.Value;
			return true;
		}
		r = default(T);
		return false;
	}

	public static bool IsNotNullOrEmpty(this string t)
	{
		return !string.IsNullOrEmpty(t);
	}

	public static bool IsNotNullOrEmpty<T>(this IEnumerable<T> t)
	{
		return t?.IsNotEmpty() ?? false;
	}

	public static bool IsNotEmpty<T>(this IEnumerable<T> t)
	{
		using (IEnumerator<T> enumerator = t.GetEnumerator())
		{
			if (enumerator.MoveNext())
			{
				_ = enumerator.Current;
				return true;
			}
		}
		return false;
	}

	public static bool IsContainedIn<T>(this T t, ICollection<T> a)
	{
		return a.Contains(t);
	}
}
namespace GamepadPlus;

public class Gamepad : MonoBehaviour
{
	[HarmonyPatch(typeof(ControlsInput), "Sheathe")]
	public class ControlsInput_Sheathe
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result, ControlsInput __instance, ref int _playerID)
		{
			TryOverrideVanillaQuickslotInput(ref __result, _playerID);
		}
	}

	[HarmonyPatch(typeof(ControlsInput), "ToggleMap")]
	public class ControlsInput_ToggleMap
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result, ControlsInput __instance, ref int _playerID)
		{
			TryOverrideVanillaQuickslotInput(ref __result, _playerID);
		}
	}

	[HarmonyPatch(typeof(ControlsInput), "ToggleLights")]
	public class ControlsInput_ToggleLights
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result, ControlsInput __instance, ref int _playerID)
		{
			TryOverrideVanillaQuickslotInput(ref __result, _playerID);
		}
	}

	[HarmonyPatch(typeof(ControlsInput), "HandleBackpack")]
	public class ControlsInput_HandleBackpack
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result, ControlsInput __instance, ref int _playerID)
		{
			TryOverrideVanillaQuickslotInput(ref __result, _playerID);
		}
	}

	[HarmonyPatch(typeof(LocalCharacterControl), "UpdateQuickSlots")]
	public class LocalCharacterControl_UpdateQuickSlots
	{
		[HarmonyPostfix]
		public static void Postfix(LocalCharacterControl __instance, Character ___m_character)
		{
			TryHandleCustomQuickslotInput(___m_character);
		}
	}

	[HarmonyPatch(typeof(SplitScreenManager), "Awake")]
	public class SplitScreenManager_Awake
	{
		[HarmonyPostfix]
		public static void Postfix(SplitScreenManager __instance)
		{
			Object.DontDestroyOnLoad((Object)(object)__instance.m_charUIPrefab);
			SetupQuickslotPanels(__instance.m_charUIPrefab);
		}
	}

	[HarmonyPatch(typeof(CharacterQuickSlotManager), "Awake")]
	public class CharacterQuickSlotManager_Awake
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterQuickSlotManager __instance)
		{
			SetupQuickslots(((Component)__instance).transform.Find("QuickSlots"));
		}
	}

	[HarmonyPatch(typeof(Item), "PerformEquip")]
	public class Item_PerformEquip
	{
		[HarmonyPrefix]
		public static void Prefix(Item __instance, EquipmentSlot _slot)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.ReplaceSlot.Value)
			{
				return;
			}
			Character val = ((_slot != null) ? _slot.Character : null);
			if (!Object.op_Implicit((Object)(object)val) || !val.IsLocalPlayer || val.IsAI || !Object.op_Implicit((Object)(object)val.OwnerPlayerSys))
			{
				return;
			}
			Item equippedItem = (Item)(object)_slot.EquippedItem;
			if (__instance is Weapon && ((Equipment)(Weapon)__instance).TwoHanded)
			{
				EquipmentSlot[] equipmentSlots = val.Inventory.Equipment.EquipmentSlots;
				if (!equipmentSlots[5].EquippedItem.TryNonNull<Equipment>(out var r) || HasItemAssignedToAnyQuickslot(val, (Item)(object)r))
				{
					equippedItem = (Item)(object)equipmentSlots[6].EquippedItem;
				}
			}
			if ((Object)(object)equippedItem == (Object)null || HasItemAssignedToAnyQuickslot(val, equippedItem))
			{
				return;
			}
			QuickSlot[] quickSlots = _slot.Character.QuickSlotMngr.m_quickSlots;
			foreach (QuickSlot val2 in quickSlots)
			{
				if ((Object)(object)val2.ActiveItem == (Object)(object)__instance)
				{
					val2.SetQuickSlot(equippedItem, true);
					break;
				}
			}
		}
	}

	private static void TryOverrideVanillaQuickslotInput(ref bool input, int playerID)
	{
		input &= !ControlsInput.QuickSlotToggle1(playerID) && !ControlsInput.QuickSlotToggle2(playerID);
	}

	private static void TryHandleCustomQuickslotInput(Character character)
	{
		if ((Object)(object)character == (Object)null || (Object)(object)character.QuickSlotMngr == (Object)null || character.CharacterUI.IsMenuFocused)
		{
			return;
		}
		int playerID = character.OwnerPlayerSys.PlayerID;
		if (!ControlsInput.QuickSlotToggle1(playerID) && !ControlsInput.QuickSlotToggle2(playerID))
		{
			return;
		}
		int num = -1;
		if (GameInput.Pressed(playerID, (GameplayActions)9))
		{
			num = 8;
		}
		else if (GameInput.Pressed(playerID, (MenuActions)16))
		{
			num = 9;
		}
		else if (GameInput.Pressed(playerID, (GameplayActions)23))
		{
			num = 10;
		}
		else if (GameInput.Pressed(playerID, (GameplayActions)24))
		{
			num = 11;
		}
		if (num >= 0)
		{
			if (ControlsInput.QuickSlotToggle1(playerID))
			{
				num += 4;
			}
			character.QuickSlotMngr.QuickSlotInput(num);
		}
	}

	private static void SetupQuickslots(Transform quickslotsHolder)
	{
		Transform val = quickslotsHolder.Find("1");
		for (int i = quickslotsHolder.childCount; i < 16; i++)
		{
			Object.Instantiate<Transform>(val, quickslotsHolder);
		}
		QuickSlot[] componentsInChildren = ((Component)quickslotsHolder).GetComponentsInChildren<QuickSlot>();
		for (int j = 0; j < componentsInChildren.Length; j++)
		{
			((Object)componentsInChildren[j]).name = (j + 1).ToString();
			componentsInChildren[j].ItemQuickSlot = false;
		}
	}

	private static void SetupQuickslotPanels(CharacterUI ui)
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		Transform menuPanelsHolder = GetMenuPanelsHolder(ui);
		Transform gamePanelsHolder = GetGamePanelsHolder(ui);
		Component[] componentsInChildren = (Component[])(object)((Component)menuPanelsHolder.Find("LT/QuickSlots")).GetComponentsInChildren<EditorQuickSlotDisplayPlacer>();
		Component[] array = componentsInChildren;
		componentsInChildren = (Component[])(object)((Component)menuPanelsHolder.Find("RT/QuickSlots")).GetComponentsInChildren<EditorQuickSlotDisplayPlacer>();
		Component[] array2 = componentsInChildren;
		componentsInChildren = (Component[])(object)((Component)gamePanelsHolder.Find("LT/QuickSlots")).GetComponentsInChildren<EditorQuickSlotDisplayPlacer>();
		Component[] array3 = componentsInChildren;
		componentsInChildren = (Component[])(object)((Component)gamePanelsHolder.Find("RT/QuickSlots")).GetComponentsInChildren<EditorQuickSlotDisplayPlacer>();
		Component[] array4 = componentsInChildren;
		for (int i = 0; i < array.Length; i++)
		{
			array[i].transform.localPosition = array3[i].transform.localPosition;
		}
		for (int j = 0; j < array2.Length; j++)
		{
			array2[j].transform.localPosition = array4[j].transform.localPosition;
		}
		gamePanelsHolder.Find("imgLT").localPosition = new Vector3(-195f, 170f);
		gamePanelsHolder.Find("imgRT").localPosition = new Vector3(-155f, 170f);
		menuPanelsHolder.Find("LT").localPosition = new Vector3(-90f, 50f);
		menuPanelsHolder.Find("RT").localPosition = new Vector3(340f, -100f);
		menuPanelsHolder.Find("LT/imgLT").localPosition = new Vector3(-125f, 125f);
		menuPanelsHolder.Find("RT/imgRT").localPosition = new Vector3(-125f, 125f);
		((Component)menuPanelsHolder.Find("LeftDecoration")).gameObject.SetActive(false);
		((Component)menuPanelsHolder.Find("RightDecoration")).gameObject.SetActive(false);
		DuplicateQuickslotsInPanel(gamePanelsHolder.Find("LT"), 8, new Vector3(-200f, -50f));
		DuplicateQuickslotsInPanel(gamePanelsHolder.Find("RT"), 8, new Vector3(-200f, -50f));
		DuplicateQuickslotsInPanel(menuPanelsHolder.Find("LT"), 8, new Vector3(-200f, -50f));
		DuplicateQuickslotsInPanel(menuPanelsHolder.Find("RT"), 8, new Vector3(-200f, -50f));
	}

	private static void DuplicateQuickslotsInPanel(Transform panelHolder, int idOffset, Vector3 posOffset)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		Transform val = panelHolder.Find("QuickSlots");
		EditorQuickSlotDisplayPlacer[] componentsInChildren = ((Component)val).GetComponentsInChildren<EditorQuickSlotDisplayPlacer>();
		foreach (EditorQuickSlotDisplayPlacer val2 in componentsInChildren)
		{
			val2.IsTemplate = true;
			Transform val3 = Object.Instantiate<Transform>(((Component)val2).transform);
			val2.IsTemplate = false;
			val3.SetParent(val);
			val3.localScale = new Vector3(0.8f, 0.8f, 0.8f);
			val3.localPosition = ((Component)val2).transform.localPosition + posOffset;
			if (((Object)val3).name.Contains("_A"))
			{
				val3.localPosition += new Vector3(0f, 30f);
			}
			else if (((Object)val3).name.Contains("_B"))
			{
				val3.localPosition += new Vector3(-30f, 0f);
			}
			else if (((Object)val3).name.Contains("_X"))
			{
				val3.localPosition += new Vector3(30f, 0f);
			}
			else if (((Object)val3).name.Contains("_Y"))
			{
				val3.localPosition += new Vector3(0f, -30f);
			}
			EditorQuickSlotDisplayPlacer component = ((Component)val3).GetComponent<EditorQuickSlotDisplayPlacer>();
			component.RefSlotID += idOffset;
			component.IsTemplate = false;
			Transform obj = val3.Find("QuickSlotDisplay(Clone)/Panel/Input");
			if (obj != null)
			{
				GameObject gameObject = ((Component)obj).gameObject;
				if (gameObject != null)
				{
					gameObject.SetActive(false);
				}
			}
		}
	}

	private static Transform GetGamePanelsHolder(CharacterUI ui)
	{
		return ((Component)ui).transform.Find("Canvas/GameplayPanels/HUD/QuickSlot/Controller/LT-RT");
	}

	private static Transform GetMenuPanelsHolder(CharacterUI ui)
	{
		return ((Component)ui).transform.Find("Canvas/GameplayPanels/Menus/CharacterMenus/MainPanel/Content/MiddlePanel/QuickSlotPanel/PanelSwitcher/Controller/LT-RT");
	}

	private static bool HasItemAssignedToAnyQuickslot(Character character, Item item)
	{
		QuickSlot[] quickSlots = character.QuickSlotMngr.m_quickSlots;
		for (int i = 0; i < quickSlots.Length; i++)
		{
			if ((Object)(object)quickSlots[i].ActiveItem == (Object)(object)item)
			{
				return true;
			}
		}
		return false;
	}
}
[BepInPlugin("iggy.gamepadPlus", "gamepadPlus", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "iggy.gamepadPlus";

	public const string NAME = "gamepadPlus";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static Plugin Instance;

	public static ConfigEntry<bool> ReplaceSlot;

	internal void Awake()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		ReplaceSlot = ((BaseUnityPlugin)this).Config.Bind<bool>("Gamepad Plus Config", "Replace Slot", true, "When equipping an item, replace the slot with the currently equipped weapon.");
		((Component)this).gameObject.AddComponent<Gamepad>();
		GameInput.Initialize();
		Players.Initialize();
		new Harmony("iggy.gamepadPlus").PatchAll();
	}
}