Decompiled source of RebindBuildBar v1.0.4

RebindBuildBar.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using xiaoye97;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("RebindBuildBar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RebindBuildBar")]
[assembly: AssemblyTitle("RebindBuildBar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RebindBuildBar;

[HarmonyPatch]
public static class Patches
{
	public delegate bool RefAction<T1, in T2, in T3>(ref T1 arg1, T2 arg2, T3 arg3);

	public static UIBuildMenu buildMenu;

	public static ConfigFile customBarBind = new ConfigFile(Paths.ConfigPath + "/RebindBuildBar/CustomBarBind.cfg", true);

	private static Vector2 pickerPos = new Vector2(-300f, 238f);

	public static Color textColor = new Color(0.3821f, 0.8455f, 1f, 0.7843f);

	public static Color lockedTextColor = new Color(0.8f, 0f, 0f, 0.5f);

	public static Color normalColor = new Color(0.588f, 0.588f, 0.588f, 0.7f);

	public static Color disabledColor = new Color(0.2f, 0.15f, 0.15f, 0.7f);

	private static string _lockedText;

	public static string lockedText
	{
		get
		{
			if (string.IsNullOrEmpty(_lockedText))
			{
				_lockedText = Localization.Translate("LockedTipText");
				if (_lockedText.Length < 10)
				{
					int count = (10 - _lockedText.Length) / 2;
					_lockedText += new string(' ', count);
				}
			}
			return _lockedText;
		}
	}

	[HarmonyPatch(typeof(UIBuildMenu), "_OnCreate")]
	[HarmonyPostfix]
	public static void InitResetButton(UIBuildMenu __instance)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		buildMenu = __instance;
		GameObject val = RebindBuildBarPlugin.resources.bundle.LoadAsset<GameObject>("Assets/RebindBuildBar/UI/buildmenu-button.prefab");
		GameObject val2 = Object.Instantiate<GameObject>(val, __instance.childGroup.transform, false);
		((RectTransform)val2.transform).anchoredPosition = new Vector2(-300f, 5f);
		UIButton component = val2.GetComponent<UIButton>();
		component.onClick += delegate
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			bool heldCtrl = CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue;
			string text = Localization.Translate(heldCtrl ? "ResetBuildMenuQuestion1" : "ResetBuildMenuQuestion2");
			UIMessageBox.Show(Localization.Translate("ResetBuildMenuQuestionTitle"), text, Localization.Translate("否"), Localization.Translate("是"), 2, (Response)null, (Response)delegate
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				ResetBuildBarItems(heldCtrl);
				buildMenu.SetCurrentCategory(buildMenu.currentCategory);
				VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			});
		};
		__instance.randRemindTips = Array.Empty<UIRandomTip>();
	}

	public static void ResetBuildBarItems(bool heldCtrl)
	{
		UIBuildMenu.staticLoaded = false;
		if (heldCtrl)
		{
			UIBuildMenu.StaticLoad();
			LDBTool.SetBuildBar();
			ResetConfigFile();
			customBarBind.Save();
		}
		else
		{
			ReloadOneCategory(buildMenu.currentCategory);
			ResetConfigFile();
			customBarBind.Save();
		}
	}

	public static void ReloadOneCategory(int category)
	{
		ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
		foreach (ItemProto val in dataArray)
		{
			int buildIndex = val.BuildIndex;
			if (buildIndex > 0)
			{
				int num = buildIndex / 100;
				int num2 = buildIndex % 100;
				if (num == category && num <= 15 && num2 <= 12)
				{
					UIBuildMenu.protos[num, num2] = val;
				}
			}
		}
		foreach (KeyValuePair<int, Dictionary<int, int>> item in LDBTool.BuildBarDict)
		{
			foreach (KeyValuePair<int, int> item2 in item.Value)
			{
				ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(item2.Value);
				if (val2 != null && item.Key == category)
				{
					UIBuildMenu.protos[item.Key, item2.Key] = val2;
				}
			}
		}
		UIBuildMenu.staticLoaded = true;
	}

	[HarmonyPatch(typeof(UIBuildMenu), "SetCurrentCategory")]
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> ShowLockedIcons(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
		}).Advance(-2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null)
		})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)4)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<UIBuildMenu, int>>((Action<UIBuildMenu, int>)ButtonLogic) });
		return val.InstructionEnumeration();
	}

	[HarmonyPatch(typeof(UIBuildMenu), "_OnUpdate")]
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> ShowLockedIconsUpdate(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Expected O, but got Unknown
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Expected O, but got Unknown
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Expected O, but got Unknown
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Expected O, but got Unknown
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Expected O, but got Unknown
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Expected O, but got Unknown
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Expected O, but got Unknown
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Expected O, but got Unknown
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Expected O, but got Unknown
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
		{
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Proto), "ID"), (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null)
		}).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
		{
			new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null)
		}).Advance(1)
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_2, (object)null)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<bool, int, UIBuildMenu, bool>>((Func<bool, int, UIBuildMenu, bool>)delegate(bool result, int index, UIBuildMenu that)
			{
				if (result)
				{
					return true;
				}
				if (!GameMain.history.TechUnlocked(1001) || index == 9)
				{
					return false;
				}
				that.isAnyCategoryUnlocked = true;
				return true;
			}) });
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null)
		}).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
		{
			new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameHistoryData), "ItemUnlocked", (Type[])null, (Type[])null), (string)null)
		});
		CodeMatcher val2 = val.Clone();
		val2.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
		{
			new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(UIButton), "highlighted"), (string)null)
		}).Advance(1);
		Label label = (Label)val2.Operand;
		val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Pop, (object)null)
		}).SetInstruction(new CodeInstruction(OpCodes.Br, (object)label));
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
		{
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Component), "get_gameObject", (Type[])null, (Type[])null), (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null)
		}).Advance(5).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null)
		})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)9)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<UIBuildMenu, int>>((Action<UIBuildMenu, int>)ButtonLogic) });
		return val.InstructionEnumeration();
	}

	private static void ButtonLogic(UIBuildMenu menu, int i)
	{
		if (UIBuildMenu.protos[menu.currentCategory, i] != null && (UIBuildMenu.protos[menu.currentCategory, i].IsEntity || UIBuildMenu.protos[menu.currentCategory, i].BuildMode == 4))
		{
			int iD = ((Proto)UIBuildMenu.protos[menu.currentCategory, i]).ID;
			if (GameMain.history.ItemUnlocked(iD))
			{
				EnableButton(menu, i, iD);
			}
			else if (menu.currentCategory == 9)
			{
				DisableButton(menu, i);
			}
			else
			{
				GhostButton(menu, i, iD);
			}
		}
		else if (menu.currentCategory == 9)
		{
			DisableButton(menu, i);
		}
		else
		{
			GhostButton(menu, i, 0);
		}
	}

	private static void GhostButton(UIBuildMenu menu, int i, int itemId)
	{
		//IL_00b1: 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)
		if ((Object)(object)menu.childButtons[i] == (Object)null)
		{
			return;
		}
		if (itemId == 0)
		{
			((Behaviour)menu.childIcons[i]).enabled = false;
			menu.childButtons[i].tips.itemId = 0;
		}
		else
		{
			((Behaviour)menu.childIcons[i]).enabled = true;
			menu.childButtons[i].tips.itemId = itemId;
			menu.childButtons[i].tips.corner = 8;
			menu.childButtons[i].tips.delay = 0.2f;
			menu.childNumTexts[i].text = lockedText;
			((Graphic)menu.childNumTexts[i]).color = lockedTextColor;
			if ((Object)(object)menu.childIcons[i].sprite == (Object)null && UIBuildMenu.protos[menu.currentCategory, i] != null)
			{
				menu.childIcons[i].sprite = UIBuildMenu.protos[menu.currentCategory, i].iconSprite;
			}
			((Graphic)menu.childIcons[i]).color = disabledColor;
		}
		((Component)menu.childButtons[i]).gameObject.SetActive(true);
		((Selectable)menu.childButtons[i].button).interactable = true;
	}

	private static void DisableButton(UIBuildMenu menu, int i)
	{
		if (!((Object)(object)menu.childButtons[i] == (Object)null))
		{
			menu.childNumTexts[i].text = "";
			menu.childButtons[i].tips.itemId = 0;
			((Selectable)menu.childButtons[i].button).interactable = false;
			((Component)menu.childButtons[i].button).gameObject.SetActive(false);
		}
	}

	private static void EnableButton(UIBuildMenu menu, int i, int itemId)
	{
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)menu.childButtons[i] == (Object)null))
		{
			StorageComponent package = menu.player.package;
			((Behaviour)menu.childIcons[i]).enabled = true;
			menu.childButtons[i].tips.itemId = itemId;
			menu.childButtons[i].tips.corner = 8;
			menu.childButtons[i].tips.delay = 0.2f;
			((Component)menu.childButtons[i].button).gameObject.SetActive(true);
			int num = package.GetItemCount(itemId);
			bool flag = menu.player.inhandItemId == itemId;
			if (flag)
			{
				num += menu.player.inhandItemCount;
			}
			StringBuilderUtility.WriteKMG(menu.strb, 5, (long)num, false);
			menu.childNumTexts[i].text = ((num > 0) ? menu.strb.ToString().Trim() : "");
			((Graphic)menu.childNumTexts[i]).color = textColor;
			((Selectable)menu.childButtons[i].button).interactable = true;
			if ((Object)(object)menu.childIcons[i].sprite == (Object)null && UIBuildMenu.protos[menu.currentCategory, i] != null)
			{
				menu.childIcons[i].sprite = UIBuildMenu.protos[menu.currentCategory, i].iconSprite;
			}
			((Graphic)menu.childIcons[i]).color = normalColor;
			((Graphic)menu.childTips[i]).color = menu.tipTextColor;
			menu.childButtons[i].highlighted = flag;
		}
	}

	[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
	[HarmonyPriority(200)]
	[HarmonyPostfix]
	public static void LoadBar()
	{
		for (int i = 0; i < UIBuildMenu.protos.GetLength(0); i++)
		{
			for (int j = 0; j < UIBuildMenu.protos.GetLength(1); j++)
			{
				if (i == 0 || j == 0 || i > 8 || j > 10)
				{
					continue;
				}
				int num = i * 100 + j;
				ItemProto val = UIBuildMenu.protos[i, j];
				if (val != null && ((Proto)val).ID != 0)
				{
					ConfigEntry<int> val2 = customBarBind.Bind<int>("BuildBarBinds", num.ToString(), ((Proto)val).ID, "Item: " + Localization.Translate(((Proto)val).Name));
					if (val2.Value == 0)
					{
						UIBuildMenu.protos[i, j] = null;
					}
					else if (val2.Value > 0 && ((ProtoSet<ItemProto>)(object)LDB.items).Exist(val2.Value) && val2.Value != ((Proto)val).ID)
					{
						UIBuildMenu.protos[i, j] = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val2.Value);
					}
				}
				else
				{
					ConfigEntry<int> val3 = customBarBind.Bind<int>("BuildBarBinds", num.ToString(), 0, "Unused");
					if (val3.Value > 0 && ((ProtoSet<ItemProto>)(object)LDB.items).Exist(val3.Value))
					{
						UIBuildMenu.protos[i, j] = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val3.Value);
					}
				}
			}
		}
	}

	private static void ResetConfigFile()
	{
		for (int i = 0; i < UIBuildMenu.protos.GetLength(0); i++)
		{
			for (int j = 0; j < UIBuildMenu.protos.GetLength(1); j++)
			{
				if (i != 0 && j != 0 && i <= 8 && j <= 10)
				{
					int num = i * 100 + j;
					ItemProto val = UIBuildMenu.protos[i, j];
					if (val != null && ((Proto)val).ID != 0)
					{
						ConfigEntry<int> val2 = customBarBind.Bind<int>("BuildBarBinds", num.ToString(), ((Proto)val).ID, "Item: " + Localization.Translate(((Proto)val).Name));
						val2.Value = ((Proto)val).ID;
						UIBuildMenu.protos[i, j] = val;
					}
					else
					{
						ConfigEntry<int> val3 = customBarBind.Bind<int>("BuildBarBinds", num.ToString(), 0, "Unused");
						val3.Value = 0;
						UIBuildMenu.protos[i, j] = null;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(UIBuildMenu), "OnChildButtonClick")]
	[HarmonyPrefix]
	public static bool OnChildClick(UIBuildMenu __instance, int index)
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		if (!CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue)
		{
			return true;
		}
		if (buildMenu.currentCategory < 1 || buildMenu.currentCategory >= 9)
		{
			return true;
		}
		int buildIndex = buildMenu.currentCategory * 100 + index;
		UIItemPickerExtension.Popup(pickerPos, (Action<ItemProto>)delegate(ItemProto proto)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (proto != null && ((Proto)proto).ID != 0)
			{
				ConfigEntry<int> val = customBarBind.Bind<int>("BuildBarBinds", buildIndex.ToString(), ((Proto)proto).ID, "Item: " + Localization.Translate(((Proto)proto).Name));
				val.Value = ((Proto)proto).ID;
				UIBuildMenu.protos[buildMenu.currentCategory, index] = proto;
				buildMenu.SetCurrentCategory(buildMenu.currentCategory);
				VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			}
		}, true, (Func<ItemProto, bool>)((ItemProto proto) => proto.ModelIndex != 0 && proto.CanBuild));
		UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
		return false;
	}

	public static void Update()
	{
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)buildMenu == (Object)null || !buildMenu.childGroup.gameObject.activeSelf || buildMenu.currentCategory < 1 || buildMenu.currentCategory >= 9)
		{
			return;
		}
		if (CustomKeyBindSystem.GetKeyBind("ClearBuildBar").keyValue)
		{
			for (int j = 1; j <= 10; j++)
			{
				if (buildMenu.childButtons[j].isPointerEnter)
				{
					int num = buildMenu.currentCategory * 100 + j;
					ConfigEntry<int> val = customBarBind.Bind<int>("BuildBarBinds", num.ToString(), 0, "Cleared by player");
					val.Value = 0;
					UIBuildMenu.protos[buildMenu.currentCategory, j] = null;
					buildMenu.SetCurrentCategory(buildMenu.currentCategory);
					VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
					return;
				}
			}
		}
		if (!CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue)
		{
			return;
		}
		for (int i = 1; i <= 10; i++)
		{
			if (!Input.GetKeyDown((KeyCode)(282 + (i - 1))) || !VFInput.inScreen || VFInput.inputing)
			{
				continue;
			}
			int buildIndex = buildMenu.currentCategory * 100 + i;
			UIItemPickerExtension.Popup(pickerPos, (Action<ItemProto>)delegate(ItemProto proto)
			{
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				if (proto != null && ((Proto)proto).ID != 0)
				{
					ConfigEntry<int> val2 = customBarBind.Bind<int>("BuildBarBinds", buildIndex.ToString(), ((Proto)proto).ID, "Item: " + Localization.Translate(((Proto)proto).Name));
					val2.Value = ((Proto)proto).ID;
					UIBuildMenu.protos[buildMenu.currentCategory, i] = proto;
					buildMenu.SetCurrentCategory(buildMenu.currentCategory);
					VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
				}
			}, true, (Func<ItemProto, bool>)((ItemProto proto) => proto.ModelIndex != 0 && proto.CanBuild));
			UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
			break;
		}
	}
}
[BepInPlugin("org.kremnev8.plugin.RebindBuildBar", "Rebind Build Bar", "1.0.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "CustomKeyBindSystem", "PickerExtensionsSystem", "LocalizationModule" })]
public class RebindBuildBarPlugin : BaseUnityPlugin
{
	public const string MODNAME = "RebindBuildBar";

	public const string MODGUID = "org.kremnev8.plugin.RebindBuildBar";

	public const string MOD_DISP_NAME = "Rebind Build Bar";

	public const string VERSION = "1.0.4";

	public static ManualLogSource logger;

	public static ResourceData resources;

	private void Awake()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Expected O, but got Unknown
		logger = ((BaseUnityPlugin)this).Logger;
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		resources = new ResourceData("RebindBuildBar", "RebindBuildBar", directoryName);
		resources.LoadAssetBundle("rebindbarbundle");
		LocalizationModule.RegisterTranslation("ResetBuildMenuTipTitle", "Reset Build Bar item binding");
		LocalizationModule.RegisterTranslation("ResetBuildMenuTip", "Pressing this button will reset Build Bar items in current category to their defaults. Holding ctrl (Rebindable) resets all items in all categories.");
		LocalizationModule.RegisterTranslation("ResetBuildMenuQuestionTitle", "Are you sure?");
		LocalizationModule.RegisterTranslation("ResetBuildMenuQuestion1", "This action will reset all Build Bar items in build bar to their defaults");
		LocalizationModule.RegisterTranslation("ResetBuildMenuQuestion2", "This action will reset Build Bar items in current category to their defaults");
		LocalizationModule.RegisterTranslation("KEYReassignBuildBar", "Reassign Build Bar item");
		LocalizationModule.RegisterTranslation("KEYClearBuildBar", "Clear Build Bar item");
		LocalizationModule.RegisterTranslation("LockedTipText", "Locked");
		BuiltinKey val = default(BuiltinKey);
		val.id = 150;
		val.key = new CombineKey(0, (byte)2, (ECombineKeyAction)0, false);
		val.conflictGroup = 2050;
		val.name = "ReassignBuildBar";
		val.canOverride = true;
		CustomKeyBindSystem.RegisterKeyBind<HoldKeyBind>(val);
		val = default(BuiltinKey);
		val.id = 151;
		val.key = new CombineKey(325, (byte)0, (ECombineKeyAction)0, false);
		val.conflictGroup = 4098;
		val.name = "ClearBuildBar";
		val.canOverride = true;
		CustomKeyBindSystem.RegisterKeyBind<ReleaseKeyBind>(val);
		Harmony val2 = new Harmony("org.kremnev8.plugin.RebindBuildBar");
		val2.PatchAll(typeof(Patches));
		logger.LogInfo((object)"Rebind Build Bar mod is loaded successfully!");
	}

	private void Update()
	{
		Patches.Update();
	}
}