Decompiled source of ControllerOverhaul v0.1.2

ControllerOverhaul.dll

Decompiled 6 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
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 ConfigurationManager;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ControllerOverhaul")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ControllerOverhaul")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b7ceab7c-e2b2-4e84-8c49-7e83ee55b69d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace ControllerOverhaul;

[BepInPlugin("mtsukn.ControllerOverhaul", "ControllerOverhaul", "0.1.2")]
[BepInProcess("Valheim.exe")]
public class Main : BaseUnityPlugin
{
	public enum JoyRemoveToolOptions
	{
		[Description("Deselect build piece")]
		DeselectBuildPiece,
		[Description("Unequip tool")]
		UnequipTool,
		[Description("Deselect build piece, and then unequip tool")]
		DeselectThenUnequip
	}

	[HarmonyPatch(typeof(ConfigurationManager), "Update")]
	public static class ConfigUpdate
	{
		public static bool configOpen;

		private static bool Prefix(ConfigurationManager __instance)
		{
			if (configOpen && !__instance.DisplayingWindow)
			{
				configOpen = false;
				resetGamepad(ZInput.instance, clearButtons: true);
			}
			else if (!configOpen && __instance.DisplayingWindow)
			{
				configOpen = true;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(ZInput), "UpdateGamepadInputLayout")]
	public static class CustomGamepadInput
	{
		private static bool Prefix(ZInput __instance, bool clearButtons)
		{
			resetGamepad(__instance, clearButtons);
			return false;
		}
	}

	[HarmonyPatch(typeof(ZInput), "ClearGamepadButtons")]
	public static class ButtonDef_Patch
	{
		private static bool Prefix(ZInput __instance)
		{
			foreach (ButtonDef item in from button in __instance.m_buttons.Values.ToList()
				where button.Name.Contains("Joy")
				select button)
			{
				__instance.UnsubscribeButton(item);
				item.ButtonAction.Disable();
				__instance.m_buttons.Remove(item.Name);
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(HotkeyBar), "Update")]
	public static class HotkeyBar_Patch
	{
		public static int l_selected = -1;

		public static Vector2Int[] storedSelection = (Vector2Int[])(object)new Vector2Int[8];

		public static bool returnSelection = false;

		private static bool Prefix(HotkeyBar __instance)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected I4, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return true;
			}
			if (((Character)localPlayer).TakeInput() && !Hud.IsPieceSelectionVisible())
			{
				if (DisableHotbarInBuildMode.Value && ((Character)localPlayer).InPlaceMode())
				{
					if (isRemoveToolDown())
					{
						int num = (int)localPlayer.m_buildPieces.GetSelectedCategory();
						foreach (ItemData equippedItem in ((Humanoid)localPlayer).m_inventory.GetEquippedItems())
						{
							string name = equippedItem.m_shared.m_name;
							if ((JoyRemoveToolFunction.Value.Equals(JoyRemoveToolOptions.DeselectBuildPiece) || JoyRemoveToolFunction.Value.Equals(JoyRemoveToolOptions.DeselectThenUnequip)) && (Object)(object)localPlayer.GetSelectedPiece() != (Object)null && localPlayer.GetSelectedPiece().m_canRotate && !localPlayer.GetSelectedPiece().m_repairPiece)
							{
								switch (name)
								{
								case "$item_hammer":
									((Vector2Int)(ref storedSelection[num])).Set(((Vector2Int)(ref localPlayer.m_buildPieces.m_selectedPiece[num])).x, ((Vector2Int)(ref localPlayer.m_buildPieces.m_selectedPiece[num])).y);
									localPlayer.m_buildPieces.m_selectedPiece[localPlayer.m_buildPieces.GetSelectedCategory()] = new Vector2Int(0, 0);
									returnSelection = true;
									localPlayer.SetupPlacementGhost();
									continue;
								default:
									if (!(name == "$item_feaster"))
									{
										continue;
									}
									break;
								case "$item_hoe":
								case "$item_cultivator":
									break;
								}
								((Vector2Int)(ref storedSelection[num])).Set(((Vector2Int)(ref localPlayer.m_buildPieces.m_selectedPiece[num])).x, ((Vector2Int)(ref localPlayer.m_buildPieces.m_selectedPiece[num])).y);
								localPlayer.m_buildPieces.m_selectedPiece[localPlayer.m_buildPieces.GetSelectedCategory()] = new Vector2Int(-1, -1);
								returnSelection = true;
								localPlayer.SetupPlacementGhost();
							}
							else
							{
								if (!JoyRemoveToolFunction.Value.Equals(JoyRemoveToolOptions.UnequipTool) && !JoyRemoveToolFunction.Value.Equals(JoyRemoveToolOptions.DeselectThenUnequip))
								{
									continue;
								}
								switch (name)
								{
								default:
									if (!(name == "$item_feaster"))
									{
										continue;
									}
									break;
								case "$item_hammer":
								case "$item_hoe":
								case "$item_cultivator":
									break;
								}
								if (ZInput.GetButton("JoySecondaryAttack"))
								{
									Player_Patch.heavyPressedInMenu = true;
								}
								((Humanoid)localPlayer).UnequipItem(equippedItem, true);
								localPlayer.SetupPlacementGhost();
							}
						}
					}
					if ((Object)(object)localPlayer.GetSelectedPiece() != (Object)null && localPlayer.GetSelectedPiece().m_canRotate && !localPlayer.GetSelectedPiece().m_repairPiece)
					{
						return false;
					}
				}
				else if (isRemoveToolDown() && RemoveToolReEquip.Value && !((Character)localPlayer).InPlaceMode() && ((Humanoid)localPlayer).m_hiddenLeftItem == null && ((Humanoid)localPlayer).m_hiddenRightItem == null && ((Humanoid)localPlayer).m_leftItem == null && ((Humanoid)localPlayer).m_rightItem == null)
				{
					ItemData itemAt = ((Humanoid)localPlayer).m_inventory.GetItemAt(__instance.m_selected, 0);
					if (itemAt != null)
					{
						string name2 = itemAt.m_shared.m_name;
						switch (name2)
						{
						default:
							if (!(name2 == "$item_feaster"))
							{
								break;
							}
							goto case "$item_hammer";
						case "$item_hammer":
						case "$item_hoe":
						case "$item_cultivator":
							((Humanoid)localPlayer).EquipItem(itemAt, true);
							break;
						}
					}
				}
			}
			if (SimpleHotbar.Value)
			{
				ItemData itemAt2 = ((Humanoid)localPlayer).m_inventory.GetItemAt(__instance.m_selected, 0);
				if (itemAt2 != null && l_selected != __instance.m_selected && fastSwap(itemAt2) && !((Humanoid)localPlayer).IsItemEquiped(itemAt2))
				{
					if (((Character)localPlayer).InAttack() || ((Character)localPlayer).InDodge() || ((Character)localPlayer).IsSwimming())
					{
						return true;
					}
					((Humanoid)localPlayer).EquipItem(itemAt2, true);
					l_selected = __instance.m_selected;
				}
				else
				{
					l_selected = __instance.m_selected;
				}
			}
			return true;
		}

		public static bool fastSwap(ItemData item)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			if ((int)item.m_shared.m_itemType == 19 || (int)item.m_shared.m_itemType == 3 || (int)item.m_shared.m_itemType == 14 || (int)item.m_shared.m_itemType == 22 || (int)item.m_shared.m_itemType == 4 || (int)item.m_shared.m_itemType == 5 || (int)item.m_shared.m_itemType == 15)
			{
				return true;
			}
			return false;
		}

		public static bool isRemoveToolDown()
		{
			return ZInput.GetButtonDown("JoyRemoveTool") || (JoyRemoveTool.Value == "" && ZInput.GetButtonDown("JoySecondaryAttack"));
		}
	}

	[HarmonyPatch(typeof(Player), "Update")]
	public static class Player_Patch
	{
		private static float rotationTimer;

		public static bool heavyPressedInMenu;

		public static bool removeToolPressInMenu;

		private static bool Prefix(Player __instance)
		{
			if ((InventoryGui.IsVisible() || ((Object)(object)__instance != (Object)null && ((Character)__instance).InPlaceMode()) || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || Console.IsVisible() || TextInput.IsVisible() || StoreGui.IsVisible() || Minimap.IsOpen() || PlayerCustomizaton.IsBarberGuiVisible() || Menu.IsVisible()) && ZInput.GetButton("JoySecondaryAttack"))
			{
				heavyPressedInMenu = true;
			}
			else if (!ZInput.GetButton("JoySecondaryAttack"))
			{
				heavyPressedInMenu = false;
			}
			if (ZInput.GamepadActive && ((Character)__instance).InPlaceMode() && !InventoryGui.IsVisible() && !Menu.IsVisible() && !Hud.IsPieceSelectionVisible() && !Minimap.IsOpen() && !Console.IsVisible() && !Chat.instance.HasFocus() && ButtonRotate.Value)
			{
				bool flag = false;
				if (ZInput.GetButton("JoyRotateRight"))
				{
					flag = true;
					if (rotationTimer == 0f || rotationTimer > 0.2f)
					{
						__instance.m_placeRotation++;
					}
				}
				if (ZInput.GetButton("JoyRotateLeft"))
				{
					flag = true;
					if (rotationTimer == 0f || rotationTimer > 0.2f)
					{
						__instance.m_placeRotation--;
					}
				}
				if (rotationTimer > 0.2f)
				{
					rotationTimer = 0.12f;
				}
				if (flag)
				{
					rotationTimer += Time.deltaTime;
				}
				else
				{
					rotationTimer = 0f;
				}
			}
			if (ZInput.GetButtonDown("JoyAutoPickup") && ToggleAutopickupMenu.Value && Menu.IsVisible())
			{
				Player.m_enableAutoPickup = !Player.m_enableAutoPickup;
				((Character)__instance).Message((MessageType)1, "$hud_autopickup:" + (Player.m_enableAutoPickup ? "$hud_on" : "$hud_off"), 0, (Sprite)null);
			}
			if (ZInput.GetButtonDown("JoyCopy") && CopyBind.Value && ((Character)__instance).InPlaceMode())
			{
				Copy_Patch.disableCopy = false;
				__instance.CopyPiece();
				__instance.m_blockRemove = true;
				Copy_Patch.disableCopy = true;
			}
			if (ZInput.GetButtonDown("JoyRemove"))
			{
				__instance.m_removePressedTime = Time.time;
			}
			if (EnableSitInBuildMode.Value && (Object)(object)__instance != (Object)null && ((Character)__instance).InPlaceMode() && !ZInput.GetButton("JoyAltKeys") && ZInput.GetButtonDown("JoySit"))
			{
				if (((Character)__instance).InEmote() && ((Character)__instance).IsSitting())
				{
					((Character)__instance).StopEmote();
				}
				else
				{
					__instance.StartEmote("sit", false);
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Hud), "TogglePieceSelection")]
	public static class BuildMenu_Patch
	{
		private static bool Prefix(Hud __instance)
		{
			//IL_0065: 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)
			if (DisableHotbarInBuildMode.Value && !__instance.m_pieceSelectionWindow.activeSelf)
			{
				try
				{
					if (!JoyRemoveToolFunction.Value.Equals(JoyRemoveToolOptions.UnequipTool) && HotkeyBar_Patch.returnSelection)
					{
						Player.m_localPlayer.SetSelectedPiece(HotkeyBar_Patch.storedSelection[Player.m_localPlayer.m_buildPieces.GetSelectedCategory()]);
						HotkeyBar_Patch.returnSelection = false;
					}
				}
				catch (Exception ex)
				{
					logger.LogInfo((object)ex);
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "Message")]
	public static class Autopickup_Patch
	{
		private static bool Prefix(Player __instance, string msg)
		{
			if (msg.Contains("hud_autopickup") && ((DisablePickupToggleInBuildMode.Value && ((Character)__instance).InPlaceMode()) || (ToggleAutopickupMenu.Value && !Menu.IsVisible())))
			{
				Player.m_enableAutoPickup = !Player.m_enableAutoPickup;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "StartGuardianPower")]
	public static class GuardianPower_Patch
	{
		private static bool Prefix(Player __instance)
		{
			if ((Object)(object)__instance != (Object)null && DisableGPInBuildMode.Value && ((Character)__instance).InPlaceMode())
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "CopyPiece")]
	public static class Copy_Patch
	{
		public static bool disableCopy = true;

		private static bool Prefix()
		{
			if (disableCopy && CopyBind.Value)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	public static class PlayerController_Patch
	{
		public static bool inPlayerControllerFixedUpdate;

		public static bool doGuiPatch;

		private static bool Prefix(PlayerController __instance)
		{
			inPlayerControllerFixedUpdate = true;
			if (BlockStopsRun.Value && ZInput.GetButtonDown("JoyBlock") && __instance.m_run)
			{
				__instance.m_run = false;
			}
			return true;
		}

		private static void Postfix()
		{
			inPlayerControllerFixedUpdate = false;
			doGuiPatch = false;
		}
	}

	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	public static class TakeInput_Patch
	{
		private static bool Prefix(ref bool __result, bool look = false)
		{
			if (MoveInGui.Value && PlayerController_Patch.inPlayerControllerFixedUpdate && (InventoryGui.IsVisible() || Hud.IsPieceSelectionVisible()))
			{
				PlayerController_Patch.doGuiPatch = true;
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "SetControls")]
	public static class SetControls_Patch
	{
		private static bool Prefix(Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge)
		{
			if (PlayerController_Patch.doGuiPatch)
			{
				attack = false;
				attackHold = false;
				secondaryAttack = false;
				secondaryAttackHold = false;
				block = false;
				blockHold = false;
				jump = false;
				crouch = false;
				dodge = false;
			}
			if (Player_Patch.heavyPressedInMenu)
			{
				secondaryAttack = false;
				secondaryAttackHold = false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(InventoryGrid), "UpdateGamepad")]
	public static class InventoryGrid_Patch
	{
		private static bool Prefix(InventoryGrid __instance)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			if (!InventoryGui.IsVisible() || !MoveInGui.Value)
			{
				return true;
			}
			if (!__instance.m_uiGroup.IsActive || Console.IsVisible())
			{
				return false;
			}
			if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyRStickLeft"))
			{
				__instance.m_selected.x = Mathf.Max(0, __instance.m_selected.x - 1);
			}
			if (ZInput.GetButtonDown("JoyDPadRight") || ZInput.GetButtonDown("JoyRStickRight"))
			{
				__instance.m_selected.x = Mathf.Min(__instance.m_width - 1, __instance.m_selected.x + 1);
			}
			if (ZInput.GetButtonDown("JoyDPadUp") || ZInput.GetButtonDown("JoyRStickUp"))
			{
				if (__instance.m_selected.y - 1 < 0)
				{
					if (!__instance.jumpToNextContainer)
					{
						return false;
					}
					__instance.OnMoveToUpperInventoryGrid?.Invoke(__instance.m_selected);
				}
				else
				{
					__instance.m_selected.y = Mathf.Max(0, __instance.m_selected.y - 1);
					__instance.jumpToNextContainer = false;
				}
			}
			if (!ZInput.GetButton("JoyDPadUp") && !ZInput.GetButton("JoyRStickUp") && __instance.m_selected.y - 1 <= 0)
			{
				__instance.jumpToNextContainer = true;
			}
			if (ZInput.GetButtonDown("JoyDPadDown") || ZInput.GetButtonDown("JoyRStickDown"))
			{
				if (__instance.m_selected.y + 1 > __instance.m_height - 1)
				{
					if (!__instance.jumpToNextContainer)
					{
						return false;
					}
					__instance.OnMoveToLowerInventoryGrid?.Invoke(__instance.m_selected);
				}
				else
				{
					__instance.m_selected.y = Mathf.Min(__instance.m_width - 1, __instance.m_selected.y + 1);
					__instance.jumpToNextContainer = false;
				}
			}
			if (!ZInput.GetButton("JoyDPadDown") && !ZInput.GetButton("JoyRStickDown") && __instance.m_selected.y + 1 >= __instance.m_height - 1)
			{
				__instance.jumpToNextContainer = true;
			}
			if (ZInput.GetButtonDown("JoyButtonA"))
			{
				Modifier arg = (Modifier)0;
				if (ZInput.GetButton("JoyLTrigger"))
				{
					arg = (Modifier)1;
				}
				if (ZInput.GetButton("JoyRTrigger"))
				{
					arg = (Modifier)3;
				}
				ItemData gamepadSelectedItem = __instance.GetGamepadSelectedItem();
				__instance.m_onSelected(__instance, gamepadSelectedItem, __instance.m_selected, arg);
			}
			if (ZInput.GetButtonDown("JoyButtonX"))
			{
				ItemData gamepadSelectedItem2 = __instance.GetGamepadSelectedItem();
				if (ZInput.GetButton("JoyLTrigger"))
				{
					__instance.m_onSelected(__instance, gamepadSelectedItem2, __instance.m_selected, (Modifier)2);
					return false;
				}
				__instance.m_onRightClick(__instance, gamepadSelectedItem2, __instance.m_selected);
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(Player), "UpdateBuildGuiInput")]
	public static class UpdateBuildGuiInput_Patch
	{
		private static bool Prefix(Player __instance)
		{
			if (!Hud.IsPieceSelectionVisible() || !MoveInGui.Value)
			{
				return true;
			}
			if (ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive())
			{
				__instance.UpdateBuildGuiInputAlternative1();
				return false;
			}
			if (!Hud.IsPieceSelectionVisible())
			{
				if (Hud.instance.IsQuickPieceSelectEnabled())
				{
					if (!Hud.IsPieceSelectionVisible() && ZInput.GetButtonDown("BuildMenu") && !PlayerController.HasInputDelay && !Hud.InRadial())
					{
						Hud.instance.TogglePieceSelection();
					}
				}
				else if (ZInput.GetButtonDown("BuildMenu") && !PlayerController.HasInputDelay && !Hud.InRadial())
				{
					Hud.instance.TogglePieceSelection();
				}
				if (ZInput.GetButtonDown("JoyUse") && !PlayerController.HasInputDelay && !Hud.InRadial())
				{
					Hud.instance.TogglePieceSelection();
					return false;
				}
			}
			else if (Hud.IsPieceSelectionVisible())
			{
				if (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("JoyButtonB") || ZInput.GetButtonDown("BuildMenu"))
				{
					Hud.HidePieceSelection();
				}
				if (ZInput.GetButtonDown("JoyUse") || (SelectBuildPieceWithConfirm.Value && ZInput.GetButtonDown("JoyButtonA")))
				{
					Hud.HidePieceSelection();
					__instance.PlayButtonSound();
				}
				__instance.m_scrollCurrAmount = (__instance.m_scrollCurrAmount += ZInput.GetMouseScrollWheel());
				if (ZInput.GetButtonDown("JoyTabLeft") || ZInput.GetButtonDown("TabLeft") || __instance.m_scrollCurrAmount > __instance.m_scrollAmountThreshold)
				{
					__instance.m_scrollCurrAmount = 0f;
					__instance.m_buildPieces.PrevCategory();
					__instance.UpdateAvailablePiecesList();
				}
				if (ZInput.GetButtonDown("JoyTabRight") || ZInput.GetButtonDown("TabRight") || __instance.m_scrollCurrAmount < 0f - __instance.m_scrollAmountThreshold)
				{
					__instance.m_scrollCurrAmount = 0f;
					__instance.m_buildPieces.NextCategory();
					__instance.UpdateAvailablePiecesList();
				}
				if (ZInput.GetButtonDown("JoyRStickLeft") || ZInput.GetButtonDown("JoyDPadLeft"))
				{
					__instance.m_buildPieces.LeftPiece();
					__instance.SetupPlacementGhost();
				}
				if (ZInput.GetButtonDown("JoyRStickRight") || ZInput.GetButtonDown("JoyDPadRight"))
				{
					__instance.m_buildPieces.RightPiece();
					__instance.SetupPlacementGhost();
				}
				if (ZInput.GetButtonDown("JoyRStickUp") || ZInput.GetButtonDown("JoyDPadUp"))
				{
					__instance.m_buildPieces.UpPiece();
					__instance.SetupPlacementGhost();
				}
				if (ZInput.GetButtonDown("JoyRStickDown") || ZInput.GetButtonDown("JoyDPadDown"))
				{
					__instance.m_buildPieces.DownPiece();
					__instance.SetupPlacementGhost();
				}
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "UpdateRecipeGamepadInput")]
	public static class RecipeGamepad_Patch
	{
		private static bool Prefix(InventoryGui __instance)
		{
			if (!InventoryGui.IsVisible() || !MoveInGui.Value)
			{
				return true;
			}
			if (__instance.m_availableRecipes.Count > 0)
			{
				if (ZInput.GetButtonDown("JoyRStickDown") || ZInput.GetButtonDown("JoyDPadDown"))
				{
					__instance.SetRecipe(Mathf.Min(__instance.m_availableRecipes.Count - 1, __instance.GetSelectedRecipeIndex(false) + 1), true);
				}
				if (ZInput.GetButtonDown("JoyRStickUp") || ZInput.GetButtonDown("JoyDPadUp"))
				{
					__instance.SetRecipe(Mathf.Max(0, __instance.GetSelectedRecipeIndex(false) - 1), true);
				}
			}
			return false;
		}
	}

	private const string pluginGUID = "mtsukn.ControllerOverhaul";

	private const string pluginName = "ControllerOverhaul";

	private const string pluginVersion = "0.1.2";

	private readonly Harmony HarmonyInstance = new Harmony("mtsukn.ControllerOverhaul");

	public static ManualLogSource logger = Logger.CreateLogSource("ControllerOverhaul");

	public static ConfigEntry<string> JoyBuildMenu { get; private set; }

	public static ConfigEntry<string> JoyUse { get; private set; }

	public static ConfigEntry<string> JoyHide { get; private set; }

	public static ConfigEntry<string> JoyJump { get; private set; }

	public static ConfigEntry<string> JoyDodge { get; private set; }

	public static ConfigEntry<string> JoySit { get; private set; }

	public static ConfigEntry<string> JoyGP { get; private set; }

	public static ConfigEntry<string> JoyInventory { get; private set; }

	public static ConfigEntry<string> JoyRun { get; private set; }

	public static ConfigEntry<string> JoyCrouch { get; private set; }

	public static ConfigEntry<string> JoyHotbarUse { get; private set; }

	public static ConfigEntry<string> JoyCamZoomIn { get; private set; }

	public static ConfigEntry<string> JoyCamZoomOut { get; private set; }

	public static ConfigEntry<string> JoyMiniMapZoomIn { get; private set; }

	public static ConfigEntry<string> JoyMiniMapZoomOut { get; private set; }

	public static ConfigEntry<string> JoyHotbarLeft { get; private set; }

	public static ConfigEntry<string> JoyHotbarRight { get; private set; }

	public static ConfigEntry<string> JoyAutoPickup { get; private set; }

	public static ConfigEntry<string> JoyBlock { get; private set; }

	public static ConfigEntry<string> JoyAttack { get; private set; }

	public static ConfigEntry<string> JoySecondaryAttack { get; private set; }

	public static ConfigEntry<string> JoyRadial { get; private set; }

	public static ConfigEntry<string> JoyRadialInteract { get; private set; }

	public static ConfigEntry<string> JoyRadialSecondaryInteract { get; private set; }

	public static ConfigEntry<string> JoyRadialBack { get; private set; }

	public static ConfigEntry<string> JoyRadialClose { get; private set; }

	public static ConfigEntry<string> JoyAltPlace { get; private set; }

	public static ConfigEntry<string> JoyRotate { get; private set; }

	public static ConfigEntry<string> JoyPlace { get; private set; }

	public static ConfigEntry<string> JoyRemove { get; private set; }

	public static ConfigEntry<string> JoyRotateRight { get; private set; }

	public static ConfigEntry<string> JoyRotateLeft { get; private set; }

	public static ConfigEntry<string> JoyCopy { get; private set; }

	public static ConfigEntry<string> JoyTabLeft { get; private set; }

	public static ConfigEntry<string> JoyTabRight { get; private set; }

	public static ConfigEntry<string> JoyNextSnap { get; private set; }

	public static ConfigEntry<string> JoyPrevSnap { get; private set; }

	public static ConfigEntry<string> JoyAltKeys { get; private set; }

	public static ConfigEntry<string> JoyScrollChatUp { get; private set; }

	public static ConfigEntry<string> JoyScrollChatDown { get; private set; }

	public static ConfigEntry<string> JoyMap { get; private set; }

	public static ConfigEntry<string> JoyChat { get; private set; }

	public static ConfigEntry<string> JoyMenu { get; private set; }

	public static ConfigEntry<string> JoyRemoveTool { get; private set; }

	public static ConfigEntry<bool> MoveInGui { get; private set; }

	public static ConfigEntry<bool> SimpleHotbar { get; private set; }

	public static ConfigEntry<bool> ButtonRotate { get; private set; }

	public static ConfigEntry<bool> DisableHotbarInBuildMode { get; private set; }

	public static ConfigEntry<bool> EnableSitInBuildMode { get; private set; }

	public static ConfigEntry<bool> DisablePickupToggleInBuildMode { get; private set; }

	public static ConfigEntry<bool> DisableGPInBuildMode { get; private set; }

	public static ConfigEntry<bool> ToggleAutopickupMenu { get; private set; }

	public static ConfigEntry<bool> CopyBind { get; private set; }

	public static ConfigEntry<bool> SelectBuildPieceWithConfirm { get; private set; }

	public static ConfigEntry<bool> BlockStopsRun { get; private set; }

	public static ConfigEntry<bool> RemoveToolReEquip { get; private set; }

	public static ConfigEntry<JoyRemoveToolOptions> JoyRemoveToolFunction { get; private set; }

	public void Awake()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Expected O, but got Unknown
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Expected O, but got Unknown
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Expected O, but got Unknown
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Expected O, but got Unknown
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Expected O, but got Unknown
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Expected O, but got Unknown
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Expected O, but got Unknown
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Expected O, but got Unknown
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Expected O, but got Unknown
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dc: Expected O, but got Unknown
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Expected O, but got Unknown
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Expected O, but got Unknown
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ab: Expected O, but got Unknown
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Expected O, but got Unknown
		//IL_0527: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Expected O, but got Unknown
		//IL_056c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Expected O, but got Unknown
		//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bb: Expected O, but got Unknown
		//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0601: Expected O, but got Unknown
		//IL_0639: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Expected O, but got Unknown
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0688: Expected O, but got Unknown
		//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Expected O, but got Unknown
		//IL_0708: Unknown result type (might be due to invalid IL or missing references)
		//IL_0712: Expected O, but got Unknown
		//IL_074d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0757: Expected O, but got Unknown
		//IL_0792: Unknown result type (might be due to invalid IL or missing references)
		//IL_079c: Expected O, but got Unknown
		//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07dd: Expected O, but got Unknown
		//IL_0818: Unknown result type (might be due to invalid IL or missing references)
		//IL_0822: Expected O, but got Unknown
		//IL_085d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0867: Expected O, but got Unknown
		//IL_089e: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a8: Expected O, but got Unknown
		//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ed: Expected O, but got Unknown
		//IL_0928: Unknown result type (might be due to invalid IL or missing references)
		//IL_0932: Expected O, but got Unknown
		//IL_0969: Unknown result type (might be due to invalid IL or missing references)
		//IL_0973: Expected O, but got Unknown
		//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b4: Expected O, but got Unknown
		//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f5: Expected O, but got Unknown
		//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3a: Expected O, but got Unknown
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7b: Expected O, but got Unknown
		//IL_0ab2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abc: Expected O, but got Unknown
		//IL_0af3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afd: Expected O, but got Unknown
		//IL_0b39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b43: Expected O, but got Unknown
		//IL_0b7f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b89: Expected O, but got Unknown
		//IL_0bc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcf: Expected O, but got Unknown
		//IL_0c0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c14: Expected O, but got Unknown
		//IL_0c4f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c59: Expected O, but got Unknown
		//IL_0c94: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c9e: Expected O, but got Unknown
		//IL_0cd9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ce3: Expected O, but got Unknown
		//IL_0d1a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d24: Expected O, but got Unknown
		//IL_0d5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d69: Expected O, but got Unknown
		//IL_0da4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dae: Expected O, but got Unknown
		//IL_0de9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df3: Expected O, but got Unknown
		//IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e38: Expected O, but got Unknown
		//IL_0e73: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e7d: Expected O, but got Unknown
		//IL_0eb8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ec2: Expected O, but got Unknown
		//IL_0efd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f07: Expected O, but got Unknown
		//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f4c: Expected O, but got Unknown
		logger.LogInfo((object)"Working new");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		HarmonyInstance.PatchAll(executingAssembly);
		JoyJump = ((BaseUnityPlugin)this).Config.Bind<string>("Movement", "JoyJump", "<Gamepad>/buttonSouth", new ConfigDescription("Jump.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		JoyRun = ((BaseUnityPlugin)this).Config.Bind<string>("Movement", "JoyRun", "<Gamepad>/leftStickPress", new ConfigDescription("Run. Toggle run can be found in the in-game settings.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		BlockStopsRun = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "Block Stops Auto Run", true, new ConfigDescription("Blocking while running with auto run enabled will stop running.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoySit = ((BaseUnityPlugin)this).Config.Bind<string>("Movement", "JoySit", "<Gamepad>/dpad/down", new ConfigDescription("Sit.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyCrouch = ((BaseUnityPlugin)this).Config.Bind<string>("Movement", "JoyCrouch", "<Gamepad>/rightStickPress", new ConfigDescription("Crouch.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		JoyDodge = ((BaseUnityPlugin)this).Config.Bind<string>("Combat", "JoyDodge", "<Gamepad>/buttonSouth", new ConfigDescription("(Alternate) Dodge.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		JoyBlock = ((BaseUnityPlugin)this).Config.Bind<string>("Combat", "JoyBlock", "<Gamepad>/leftTrigger", new ConfigDescription("Block.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyAttack = ((BaseUnityPlugin)this).Config.Bind<string>("Combat", "JoyAttack", "<Gamepad>/rightTrigger", new ConfigDescription("Attack.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoySecondaryAttack = ((BaseUnityPlugin)this).Config.Bind<string>("Combat", "JoySecondaryAttack", "<Gamepad>/buttonEast", new ConfigDescription("Heavy attack.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		MoveInGui = ((BaseUnityPlugin)this).Config.Bind<bool>("User Interface", "Enable Movement in GUI", false, new ConfigDescription("Enables character movement in GUI and delegates GUI navigation to the right stick and DPad. This feature is a bit buggy due to Unity shenanigans but the DPad retains normal functionality in all menus.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 8
			}
		}));
		JoyInventory = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyInventory", "<Gamepad>/buttonNorth", new ConfigDescription("Open or close your inventory.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 7
			}
		}));
		JoyTabLeft = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyTabLeft", "<Gamepad>/leftShoulder", new ConfigDescription("Tab left.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 6
			}
		}));
		JoyTabRight = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyTabRight", "<Gamepad>/rightShoulder", new ConfigDescription("Tab right.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		JoyUse = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyUse", "<Gamepad>/buttonWest", new ConfigDescription("Use objects and items from inventory.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		JoyHide = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyHide", "<Gamepad>/dpad/right", new ConfigDescription("Hide/show items.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyGP = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyGP", "<Gamepad>/dpad/left", new ConfigDescription("Use your forsaken power.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyAltKeys = ((BaseUnityPlugin)this).Config.Bind<string>("User Interface", "JoyAltKeys", "<Gamepad>/leftTrigger", new ConfigDescription("While held, enables alternate bind functionality. Any binds with (Alternate) in their description are only activated while this button is held.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		SimpleHotbar = ((BaseUnityPlugin)this).Config.Bind<bool>("Simple Hotbar", "Simple Hotbar", false, new ConfigDescription("(Non Vanilla) If enabled, hotbar will function similar to other games. Switching slots will automatically equip weapons and skip swapping animations and allow swapping while running. Consumables and armor are not used automatically. This slightly alters game balancing, enable in multiplayer instances at your own risk.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		JoyHotbarLeft = ((BaseUnityPlugin)this).Config.Bind<string>("Simple Hotbar", "JoyHotbarLeft", "<Gamepad>/leftShoulder", new ConfigDescription("Moves hotbar selection left.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyHotbarRight = ((BaseUnityPlugin)this).Config.Bind<string>("Simple Hotbar", "JoyHotbarRight", "<Gamepad>/rightShoulder", new ConfigDescription("Moves hotbar selection right.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyHotbarUse = ((BaseUnityPlugin)this).Config.Bind<string>("Simple Hotbar", "JoyHotbarUse", "<Gamepad>/dpad/up", new ConfigDescription("Use the current selected item.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		JoyBuildMenu = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyBuildMenu", "<Gamepad>/buttonWest", new ConfigDescription("Open and close the build selection menu.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 10
			}
		}));
		SelectBuildPieceWithConfirm = ((BaseUnityPlugin)this).Config.Bind<bool>("Building", "Select Build Pieces With Confirm", true, new ConfigDescription("Pressing <Gamepad>/buttonSouth in the build selection menu selects the current piece and closes the menu. May cause bind conflicts, use at your own risk.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 9
			}
		}));
		JoyPlace = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyPlace", "<Gamepad>/rightTrigger", new ConfigDescription("Place a build piece.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 8
			}
		}));
		JoyRemove = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyRemove", "<Gamepad>/leftTrigger", new ConfigDescription("Remove a build piece.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 7
			}
		}));
		JoyRotate = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyRotate", "<Gamepad>/leftTrigger", new ConfigDescription("Hold to enable build piece rotation with the right stick. If you have Separate Rotate Buttons enabled, this bind will not function.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 6
			}
		}));
		JoyNextSnap = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyNextSnap", "<Gamepad>/dpad/right", new ConfigDescription("Next snap.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		JoyPrevSnap = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyPrevSnap", "<Gamepad>/dpad/left", new ConfigDescription("Previous snap.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		CopyBind = ((BaseUnityPlugin)this).Config.Bind<bool>("Building", "Copy Button", true, new ConfigDescription("Copy objects using JoyCopy. If disabled, copying objects in build mode is performed via JoyAltKeys+JoyRemove.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyCopy = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyCopy", "<Gamepad>/rightStickPress", new ConfigDescription("Copy the build piece you're looking at. If you have Copy Button disabled, copy will be performed via JoyAltKeys+JoyRemove", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyAltPlace = ((BaseUnityPlugin)this).Config.Bind<string>("Building", "JoyAltPlace", "<Gamepad>/dpad/down", new ConfigDescription("Disable build snapping.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		ButtonRotate = ((BaseUnityPlugin)this).Config.Bind<bool>("Button Rotate", "Separate Rotate Buttons", true, new ConfigDescription("If enabled, JoyRotateRight and JoyRotateLeft will be used to rotate build pieces. If disabled, JoyRotate+RStickRight and JoyRotate+RStickLeft will be used.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyRotateRight = ((BaseUnityPlugin)this).Config.Bind<string>("Button Rotate", "JoyRotateRight", "<Gamepad>/rightShoulder", new ConfigDescription("Rotate your selected piece to the right. If you have Separate Rotate Buttons disabled, this bind will not function.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyRotateLeft = ((BaseUnityPlugin)this).Config.Bind<string>("Button Rotate", "JoyRotateLeft", "<Gamepad>/leftShoulder", new ConfigDescription("Rotate your selected piece to the left. If you have Separate Rotate Buttons disabled, this bind will not function.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		DisableHotbarInBuildMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Building Tweaks", "Disable Hotbar While Building", true, new ConfigDescription("Disables the hotbar while a rotatable build piece is selected. Enable this if you want your hotbar and rotate binds on the same buttons. Additionally, if enabled, JoySecondaryAttack will remove any selected building piece and return control to your hotbar.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 7
			}
		}));
		JoyRemoveToolFunction = ((BaseUnityPlugin)this).Config.Bind<JoyRemoveToolOptions>("Building Tweaks", "Remove Tool Function", JoyRemoveToolOptions.DeselectThenUnequip, new ConfigDescription("If Disable Hotbar While Building is enabled, this settings will control how the build tool removal functionality behaves. You can either have it de-select the build piece, you can have it un-equip the tool entirely, or you can do both sequentially.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 6
			}
		}));
		RemoveToolReEquip = ((BaseUnityPlugin)this).Config.Bind<bool>("Building Tweaks", "Tool ReEquip", false, new ConfigDescription("JoySecondaryAttack will re-equip any tool if you're unnarmed and it's selected in your hotbar.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		JoyRemoveTool = ((BaseUnityPlugin)this).Config.Bind<string>("Building Tweaks", "JoyRemoveTool", "", new ConfigDescription("To be used with Disable Hotbar While Building and Tool ReEquip for equipping and unequipping tools. This is here if you want to use a separate bind other than the default JoySecondaryAttack.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		DisablePickupToggleInBuildMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Building Tweaks", "Disable Auto Pickup Toggle While Building", true, new ConfigDescription("Disables auto pickup toggle in build mode, freeing up bind options.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		DisableGPInBuildMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Building Tweaks", "Disable Forsaken Power While Building", true, new ConfigDescription("Disables forsaken power in build mode, freeing up bind options.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		EnableSitInBuildMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Building Tweaks", "Enable Sitting While Building", false, new ConfigDescription("Enables sitting in build mode. May cause bind conflicts, use at your own risk.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		JoyCamZoomIn = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyCamZoomIn", "<Gamepad>/dpad/up", new ConfigDescription("(Alternate) Zoom in.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 11
			}
		}));
		JoyCamZoomOut = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyCamZoomOut", "<Gamepad>/dpad/down", new ConfigDescription("(Alternate) Zoom out.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 10
			}
		}));
		JoyMiniMapZoomIn = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyMiniMapZoomIn", "<Gamepad>/dpad/right", new ConfigDescription("(Alternate) Zoom in minimap.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 9
			}
		}));
		JoyMiniMapZoomOut = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyMiniMapZoomOut", "<Gamepad>/dpad/left", new ConfigDescription("(Alternate) Zoom out minimap.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 8
			}
		}));
		JoyScrollChatUp = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyScrollChatUp", "<Gamepad>/rightStick/up", new ConfigDescription("Scroll chat up.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 7
			}
		}));
		JoyScrollChatDown = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyScrollChatDown", "<Gamepad>/rightStick/down", new ConfigDescription("Scroll chat down.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 6
			}
		}));
		JoyAutoPickup = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyAutoPickup", "<Gamepad>/select", new ConfigDescription("(Alternate) Toggle auto pickup.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		ToggleAutopickupMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra", "Toggle Auto Pickup From Menu", true, new ConfigDescription("Auto pickup is only toggleable from the menu.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		JoyMap = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyMap", "<Gamepad>/select", new ConfigDescription("Open and close map.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyChat = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyChat", "<Gamepad>/select", new ConfigDescription("(Alternate) Open and close chat.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyMenu = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "JoyMenu", "<Gamepad>/start", new ConfigDescription("Open and close menu.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
		JoyRadial = ((BaseUnityPlugin)this).Config.Bind<string>("Radial (unused)", "JoyRadial", "<Gamepad>/leftShoulder", new ConfigDescription("Unused functionality for a radial selection menu. This won't interfere with other binds.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 5
			}
		}));
		JoyRadialInteract = ((BaseUnityPlugin)this).Config.Bind<string>("Radial (unused)", "JoyRadialInteract", "<Gamepad>/rightTrigger", new ConfigDescription("Unused functionality for a radial selection menu. This won't interfere with other binds.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 4
			}
		}));
		JoyRadialSecondaryInteract = ((BaseUnityPlugin)this).Config.Bind<string>("Radial (unused)", "JoyRadialSecondaryInteract", "<Gamepad>/rightShoulder", new ConfigDescription("Unused functionality for a radial selection menu. This won't interfere with other binds.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 3
			}
		}));
		JoyRadialBack = ((BaseUnityPlugin)this).Config.Bind<string>("Radial (unused)", "JoyRadialBack", "<Gamepad>/leftTrigger", new ConfigDescription("Unused functionality for a radial selection menu. This won't interfere with other binds.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		JoyRadialClose = ((BaseUnityPlugin)this).Config.Bind<string>("Radial (unused)", "JoyRadialClose", "<Gamepad>/buttonEast", new ConfigDescription("Unused functionality for a radial selection menu. This won't interfere with other binds.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1
			}
		}));
	}

	public static void resetGamepad(ZInput __instance, bool clearButtons)
	{
		if (clearButtons)
		{
			__instance.ClearGamepadButtons();
		}
		__instance.AddButton("JoyBuildMenu", JoyBuildMenu.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyUse", JoyUse.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyHide", JoyHide.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyJump", JoyJump.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyDodge", JoyDodge.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoySit", JoySit.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyGP", JoyGP.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyInventory", JoyInventory.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRun", JoyRun.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyCrouch", JoyCrouch.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyHotbarUse", JoyHotbarUse.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyCamZoomIn", JoyCamZoomIn.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyCamZoomOut", JoyCamZoomOut.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyMiniMapZoomIn", JoyMiniMapZoomIn.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyMiniMapZoomOut", JoyMiniMapZoomOut.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyHotbarLeft", JoyHotbarLeft.Value, false, true, false, 0.3f, 0.1f);
		__instance.AddButton("JoyHotbarRight", JoyHotbarRight.Value, false, true, false, 0.3f, 0.1f);
		__instance.AddButton("JoyAutoPickup", JoyAutoPickup.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyBlock", JoyBlock.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyAttack", JoyAttack.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoySecondaryAttack", JoySecondaryAttack.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRadial", JoyRadial.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRadialInteract", JoyRadialInteract.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRadialSecondaryInteract", JoyRadialSecondaryInteract.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRadialBack", JoyRadialBack.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRadialClose", JoyRadialClose.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyAltPlace", JoyAltPlace.Value, false, true, false, 0f, 0f);
		if (ButtonRotate.Value)
		{
			__instance.AddButton("JoyRotateRight", JoyRotateRight.Value, false, true, false, 0f, 0f);
			__instance.AddButton("JoyRotateLeft", JoyRotateLeft.Value, false, true, false, 0f, 0f);
		}
		else
		{
			__instance.AddButton("JoyRotate", JoyRotate.Value, false, true, false, 0f, 0f);
		}
		__instance.AddButton("JoyPlace", JoyPlace.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyRemove", JoyRemove.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyCopy", JoyCopy.Value, false, false, false, 0f, 0f);
		__instance.AddButton("JoyTabLeft", JoyTabLeft.Value, false, false, false, 0f, 0f);
		__instance.AddButton("JoyTabRight", JoyTabRight.Value, false, false, false, 0f, 0f);
		__instance.AddButton("JoyNextSnap", JoyNextSnap.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyPrevSnap", JoyPrevSnap.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyAltKeys", JoyAltKeys.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyScrollChatUp", JoyScrollChatUp.Value, false, true, false, 0.5f, 0.05f);
		__instance.AddButton("JoyScrollChatDown", JoyScrollChatDown.Value, false, true, false, 0.5f, 0.05f);
		if (JoyRemoveTool.Value != null)
		{
			__instance.AddButton("JoyRemoveTool", JoyRemoveTool.Value, false, true, false, 0f, 0f);
		}
		__instance.AddButton("JoyButtonA", ZInput.s_gamepadInputPathMap[(GamepadInput)5], false, false, false, 0f, 0f);
		__instance.AddButton("JoyButtonB", ZInput.s_gamepadInputPathMap[(GamepadInput)6], false, false, false, 0f, 0f);
		__instance.AddButton("JoyButtonX", ZInput.s_gamepadInputPathMap[(GamepadInput)7], false, false, false, 0f, 0f);
		__instance.AddButton("JoyButtonY", ZInput.s_gamepadInputPathMap[(GamepadInput)8], false, false, false, 0f, 0f);
		__instance.AddButton("JoyBack", ZInput.s_gamepadInputPathMap[(GamepadInput)19], false, false, false, 0f, 0f);
		__instance.AddButton("JoyStart", ZInput.s_gamepadInputPathMap[(GamepadInput)20], false, true, false, 0f, 0f);
		__instance.AddButton("JoyLStick", ZInput.s_gamepadInputPathMap[(GamepadInput)11], false, false, false, 0f, 0f);
		__instance.AddButton("JoyRStick", ZInput.s_gamepadInputPathMap[(GamepadInput)14], false, false, false, 0f, 0f);
		__instance.AddButton("JoyLStickLeft", ZInput.s_gamepadInputPathMap[(GamepadInput)28], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyLStickRight", ZInput.s_gamepadInputPathMap[(GamepadInput)29], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyLStickUp", ZInput.s_gamepadInputPathMap[(GamepadInput)26], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyLStickDown", ZInput.s_gamepadInputPathMap[(GamepadInput)27], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyRStickLeft", ZInput.s_gamepadInputPathMap[(GamepadInput)24], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyRStickRight", ZInput.s_gamepadInputPathMap[(GamepadInput)25], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyRStickUp", ZInput.s_gamepadInputPathMap[(GamepadInput)22], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyRStickDown", ZInput.s_gamepadInputPathMap[(GamepadInput)23], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyDPadLeft", ZInput.s_gamepadInputPathMap[(GamepadInput)1], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyDPadRight", ZInput.s_gamepadInputPathMap[(GamepadInput)2], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyDPadUp", ZInput.s_gamepadInputPathMap[(GamepadInput)4], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyDPadDown", ZInput.s_gamepadInputPathMap[(GamepadInput)3], false, false, false, 0.3f, 0.1f);
		__instance.AddButton("JoyLBumper", ZInput.s_gamepadInputPathMap[(GamepadInput)15], false, false, false, 0f, 0f);
		__instance.AddButton("JoyRBumper", ZInput.s_gamepadInputPathMap[(GamepadInput)16], false, false, false, 0f, 0f);
		__instance.AddButton("JoyLTrigger", ZInput.s_gamepadInputPathMap[(GamepadInput)17], false, false, false, 0f, 0f);
		__instance.AddButton("JoyRTrigger", ZInput.s_gamepadInputPathMap[(GamepadInput)18], false, false, false, 0f, 0f);
		__instance.AddButton("JoyMap", JoyMap.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyChat", JoyChat.Value, true, true, false, 0f, 0f);
		__instance.AddButton("JoyMenu", JoyMenu.Value, false, true, false, 0f, 0f);
		__instance.AddButton("JoyToggleHUD", JoyMenu.Value, true, true, false, 0f, 0f);
	}
}