Decompiled source of TechtonicaVR v2.0.0

BepInEx/plugins/techtonica_vr/techtonica_vr.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using PiUtils.Assets;
using PiUtils.Debug;
using PiUtils.Objects.Behaviours;
using PiUtils.Patches;
using PiUtils.Patches.Universal;
using PiUtils.UI;
using PiUtils.Util;
using PiVrLoader;
using PiVrLoader.Input;
using PiVrLoader.Input.Ui;
using PiVrLoader.UI;
using PiVrLoader.Util;
using PiVrLoader.VRCamera;
using Rewired;
using TTIK.Ik;
using TTIK.Ik.FingerTracking;
using TTIK.Network;
using TechtonicaVR.Assets;
using TechtonicaVR.Ik;
using TechtonicaVR.Input;
using TechtonicaVR.Input.Ui;
using TechtonicaVR.Input.Ui.Machine;
using TechtonicaVR.Patches.LoadingScreen;
using TechtonicaVR.Patches.MainGame.Player;
using TechtonicaVR.Patches.MainGame.UI;
using TechtonicaVR.Patches.MainMenu;
using TechtonicaVR.UI;
using TechtonicaVR.Util.Patch;
using TechtonicaVR.VRCamera;
using TechtonicaVR.VRCamera.Patch;
using TechtonicaVR.VrPlayer;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Valve.VR;
using Valve.VR.InteractionSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("techtonica_vr")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+1034b9a2bf3f026a1395ed059424823a1d926bca")]
[assembly: AssemblyProduct("Techtonica VR")]
[assembly: AssemblyTitle("techtonica_vr")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TechtonicaVR
{
	public class LoadingScreenPatch : MonoBehaviour
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<LoadingScreenPatch>();

		private IPatch[] patches = (IPatch[])(object)new IPatch[1] { (IPatch)new LoadingScreenCanvasPatch() };

		private float startTime = Time.time;

		public static LoadingScreenPatch Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject("LoadingScreenPatch").AddComponent<LoadingScreenPatch>();
		}

		private void Start()
		{
			Logger.LogDebug("Hello Loading Screen!");
		}

		private void Update()
		{
			patches = patches.Where((IPatch p) => !p.Apply()).ToArray();
			if (!patches.Any())
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public class MainGamePatch : MonoBehaviour
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<MainGamePatch>();

		private IPatch[] playerSpringPatches = (IPatch[])(object)new IPatch[7]
		{
			(IPatch)new LeftHandAttachPatch(),
			(IPatch)new RightHandAttachPatch(),
			(IPatch)new SetDefaultLayerPatch("Right Hand Attach", true),
			(IPatch)new SetDefaultLayerPatch("Left Hand Attach", true),
			(IPatch)new SetDefaultLayerPatch("Terrain Manipulator Black Hole", true),
			(IPatch)new SetDefaultLayerPatch("Terrain Manipulator Black Hole (Active)", true),
			(IPatch)new SetDefaultLayerPatch("Terrain Manipulator Black Hole (On Destroy)", true)
		};

		private IPatch[] patches = Array.Empty<IPatch>();

		private float startTime = Time.time;

		public static MainGamePatch Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject("MainGamePatch").AddComponent<MainGamePatch>();
		}

		private void Start()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			patches = playerSpringPatches.Concat(new <>z__ReadOnlyArray<IPatch>((IPatch[])(object)new IPatch[22]
			{
				(IPatch)new ExecuteAfterPatch((IPatch)new DisableByNamePatch("Astronaut_LP_ArmsTorso"), playerSpringPatches),
				(IPatch)new NotificationCanvasPatche(),
				(IPatch)new ToolbarUiPatch(),
				(IPatch)new PrimaryToolbarPatch(),
				(IPatch)new QuestTaskListPatch(),
				(IPatch)new SecondaryToolbarPatch(),
				(IPatch)new DialoguePopupPatch(),
				(IPatch)new DisableComponentPatch<OutlinePostProcess>(),
				(IPatch)new CursorCanvasPatch(),
				(IPatch)new InspectorCanvasPatch(),
				(IPatch)new CompassPatch(),
				(IPatch)new MapPatch(),
				(IPatch)new CraftingQueuePatch(),
				(IPatch)new PlayerArrowPatch(),
				(IPatch)new PlayerInventoryUIPatch(),
				(IPatch)new StorageInventoryUIPatch(),
				(IPatch)new IaCMenuPatch(),
				(IPatch)new SaveNotificationPatch(),
				(IPatch)new HudPatch(),
				(IPatch)new ProductionTerminalPatch(),
				(IPatch)new OmniseekerPatch(),
				(IPatch)new SystemLogUiPatch()
			})).ToArray();
			Logger.LogDebug("Hello World!");
		}

		private void Update()
		{
			patches = patches.Where((IPatch p) => !p.Apply()).ToArray();
			if (!patches.Any())
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public class MainMenuPatch : MonoBehaviour
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<MainMenuPatch>();

		private IPatch[] patches = (IPatch[])(object)new IPatch[3]
		{
			(IPatch)new CameraOriginPatch(),
			(IPatch)new SpaceBGCameraPatch(),
			(IPatch)new AtLeastOnePatch((IPatch[])(object)new IPatch[2]
			{
				(IPatch)new MenuCanvasPatch1080(),
				(IPatch)new MenuCanvasPatch1440()
			})
		};

		private float startTime = Time.time;

		public static MainMenuPatch Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject("MainMenuPatch").AddComponent<MainMenuPatch>();
		}

		private void Start()
		{
			Logger.LogDebug("Hello Main Menu!");
		}

		private void Update()
		{
			if (!patches.Where((IPatch p) => !p.Apply()).Any())
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public class ModConfig
	{
		private static ConfigEntry<bool> modEnabled;

		public static ConfigEntry<int> smoothTurnSpeed;

		public static ConfigEntry<float> snapTurnAngle;

		private static ConfigEntry<bool> vignetteEnabled;

		private static ConfigEntry<bool> vignetteOnTeleport;

		private static ConfigEntry<bool> vignetteOnSmoothLocomotion;

		private static ConfigEntry<bool> vignetteOnSmoothTurn;

		private static ConfigEntry<bool> vignetteOnSnapTurn;

		public static ConfigEntry<float> longPressTime;

		public static ConfigEntry<bool> displayBody;

		public static ConfigEntry<float> menuSpawnDistance;

		public static ConfigEntry<Vector3> menuScale;

		public static ConfigEntry<Vector3> inventoryAndCraftingMenuScaleOverride;

		public static ConfigEntry<float> menuDownwardOffset;

		public static ConfigEntry<float> menuScrollSpeed;

		public static ConfigEntry<float> menuScrollDeadzone;

		public static void Init(ConfigFile config)
		{
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			modEnabled = config.Bind<bool>("General", "Enabled", true, "Enable mod");
			smoothTurnSpeed = config.Bind<int>("Input", "Smooth Turn Speed", 90, "Speed of smooth turning");
			snapTurnAngle = config.Bind<float>("Comfort", "Snap Turn Angle", 30f, "Angle of snap turning");
			vignetteEnabled = config.Bind<bool>("Comfort", "Vignette Enabled", false, "Enable vignette");
			vignetteOnTeleport = config.Bind<bool>("Comfort", "Vignette On Teleport", true, "Enable vignette on teleport");
			vignetteOnSmoothLocomotion = config.Bind<bool>("Comfort", "Vignette On Smooth Locomotion", true, "Enable vignette on smooth locomotion");
			vignetteOnSmoothTurn = config.Bind<bool>("Comfort", "Vignette On Smooth Turn", true, "Enable vignette on smooth turn");
			vignetteOnSnapTurn = config.Bind<bool>("Comfort", "Vignette On Snap Turn", true, "Enable vignette on snap turn");
			longPressTime = config.Bind<float>("Buttons", "Long Press Time", 1f, "Time to hold button for long press");
			displayBody = config.Bind<bool>("Graphics", "Display Body", true, "Display player body. If disabled, only hands are visible. Does not affect other players");
			menuSpawnDistance = config.Bind<float>("UI", "Menu Spawn Distance", 0.8f, "Distance from head to spawn Menus");
			menuScale = config.Bind<Vector3>("UI", "Menu Scale", new Vector3(0.001f, 0.001f, 0.001f), "Scale of Menus");
			inventoryAndCraftingMenuScaleOverride = config.Bind<Vector3>("UI", "Inventory and Crafting Menu Scale Override", new Vector3(0.001f, 0.0005f, 0.001f), "Scale of Inventory and Crafting Menu. Set to 0 to use Menu Scale");
			menuDownwardOffset = config.Bind<float>("UI", "Menu Downward Offset", 0.2f, "Offset of Menus from head. Needed, as menus sometimes spawn too high.");
			menuScrollSpeed = config.Bind<float>("UI", "Menu Scroll Speed", 0.125f, "Speed of scrolling in menus");
			menuScrollDeadzone = config.Bind<float>("UI", "Menu Scroll Deadzone", 0.35f, "Deadzone of scrolling in menus");
		}

		public static bool ModEnabled()
		{
			return modEnabled.Value;
		}

		public static bool VignetteEnabled()
		{
			return vignetteEnabled.Value;
		}

		public static bool VignetteOnTeleport()
		{
			if (VignetteEnabled())
			{
				return vignetteOnTeleport.Value;
			}
			return false;
		}

		public static bool VignetteOnSmoothLocomotion()
		{
			if (VignetteEnabled())
			{
				return vignetteOnSmoothLocomotion.Value;
			}
			return false;
		}

		public static bool VignetteOnSmoothTurn()
		{
			if (VignetteEnabled())
			{
				return vignetteOnSmoothTurn.Value;
			}
			return false;
		}

		public static bool VignetteOnSnapTurn()
		{
			if (VignetteEnabled())
			{
				return vignetteOnSnapTurn.Value;
			}
			return false;
		}
	}
	[BepInPlugin("de.xenira.techtonicavr", "Techtonica VR", "2.0.0")]
	[BepInProcess("Techtonica.exe")]
	[BepInDependency("de.xenira.ttik", "0.2.2")]
	[BepInDependency("de.xenira.pi_utils", "0.4.0")]
	[BepInDependency("de.xenira.pi_vr_loader", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TechtonicaVR : BaseUnityPlugin
	{
		public class VRLoader : MonoBehaviour
		{
		}

		private static PluginLogger Logger;

		public static VRLoader staticVrLoader;

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Logger = PluginLogger.GetLogger<TechtonicaVR>();
			Logger.LogInfo("Loading plugin techtonica_vr version 2.0.0...");
			License.LogLicense(Logger, "xenira", "techtonica_vr", "2.0.0");
			AssetLoader.assetLoader = new AssetLoader(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assets"));
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			if (!ModConfig.ModEnabled())
			{
				Logger.LogInfo("Mod is disabled, skipping...");
				return;
			}
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			if ((Object)(object)staticVrLoader == (Object)null)
			{
				staticVrLoader = new GameObject("VRLoader").AddComponent<VRLoader>();
				Object.DontDestroyOnLoad((Object)(object)staticVrLoader);
			}
			string? directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			PiVrLoader.CopyVrConfig(Path.Combine(directoryName, "vr_config", "StreamingAssets"), "StreamingAssets", true);
			PiVrLoader.CopyVrConfig(Path.Combine(directoryName, "vr_config", "UnitySubsystems"), "UnitySubsystems", true);
			ApplicationManifestHelper.UpdateManifest(Path.Combine(Paths.ManagedPath, "..", "StreamingAssets", "techtonicaVR.vrmanifest"), "steam.app.1457320", "https://steamcdn-a.akamaihd.net/steam/apps/1457320/header.jpg", "Techtonica VR", "Techtonica VR mod 2.0.0 by Xenira", 1457320, true);
			TechCameraManager.Create();
			((MonoBehaviour)this).StartCoroutine(AssetLoader.Load());
			IkSetup.SetupIk();
			Logger.LogInfo("Plugin techtonica_vr is loaded!");
			TechInputMapper.MapActions();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			Logger.LogDebug("Scene " + ((Scene)(ref scene)).name + " loaded!");
			if (((Scene)(ref scene)).name == "Main Menu")
			{
				Logger.LogInfo("Scene is MainMenu, creating MainMenuPatch...");
				MainMenuPatch.Create();
			}
			else if (((Scene)(ref scene)).name == "Loading")
			{
				Logger.LogInfo("Scene is LoadingScreen, creating LoadingScreenPatch...");
				LoadingScreenPatch.Create();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "techtonica_vr";

		public const string PLUGIN_NAME = "Techtonica VR";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace TechtonicaVR.Util.Patch
{
	public class Transpile
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<Transpile>();

		public static MethodInfo getTransformMethod = typeof(Component).GetMethod("get_transform");

		public static MethodInfo getForwardMethod = typeof(Transform).GetMethod("get_forward");

		public static MethodInfo getTransformPatchMethod = typeof(Transpile).GetMethod("patchedGetTransform");

		public static MethodInfo getForwardPatchMethod = typeof(Transpile).GetMethod("PatchedGetForward");

		public static IEnumerable<CodeInstruction> reassemblePatch<T>(IEnumerable<CodeInstruction> instructions, int expectedPatchCount = 12)
		{
			int patchCnt = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, getTransformMethod))
				{
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)getTransformPatchMethod);
					patchCnt++;
				}
				else if (CodeInstructionExtensions.Calls(instruction, getForwardMethod))
				{
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)getForwardPatchMethod);
					patchCnt++;
				}
				else
				{
					yield return instruction;
				}
			}
			if (patchCnt != expectedPatchCount)
			{
				Logger.LogError($"[{typeof(T)}]: Patch count mismatch: {patchCnt} != {expectedPatchCount}");
			}
		}

		public static Transform patchedGetTransform()
		{
			return SteamVRInputMapper.rightHandObject.transform;
		}

		public static Vector3 PatchedGetForward()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return -SteamVRInputMapper.rightHandObject.transform.up;
		}
	}
}
namespace TechtonicaVR.UI
{
	public class RecipePickerMenuWrapper : Menu
	{
		private RecipePickerUI menu;

		public RecipePickerMenuWrapper(RecipePickerUI menu)
		{
			this.menu = menu;
		}

		public bool isOpen()
		{
			return ((Behaviour)menu.myCanvas).enabled;
		}
	}
	public class UIMenuWrapper : Menu
	{
		private UIMenu menu;

		public UIMenuWrapper(UIMenu menu)
		{
			this.menu = menu;
		}

		public bool isOpen()
		{
			if (menu.isOpen)
			{
				return !((Behaviour)UIManager.instance.recipePickerUI.myCanvas).enabled;
			}
			return false;
		}
	}
	public class WorldPositionedCanvas : MonoBehaviour
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<WorldPositionedCanvas>();

		public Menu menu;

		public PlayerInventoryUI playerInventoryUI;

		public Vector3 target;

		public Vector3 camOrigin;

		public Vector3 scale;

		private void Start()
		{
			if (menu == null)
			{
				Logger.LogError("WorldPositionedCanvas: menu is null");
				Object.Destroy((Object)(object)this);
			}
		}

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			bool flag = menu.isOpen();
			if (!(target == Vector3.zero) && flag)
			{
				Camera mainCamera = VRCameraManager.mainCamera;
				if (flag)
				{
					MathyStuff.PositionCanvasInWorld(((Component)this).gameObject, mainCamera, target, camOrigin);
				}
				if ((Object)(object)playerInventoryUI != (Object)null && playerInventoryUI.isOpen)
				{
					MathyStuff.PositionCanvasInWorld(((Component)((Component)playerInventoryUI).gameObject.transform.GetChild(0)).gameObject, mainCamera, target, camOrigin);
				}
			}
		}
	}
}
namespace TechtonicaVR.UI.Patch
{
	[Harmony]
	public class HologramPreviewManagerPatch
	{
		[HarmonyPatch(typeof(HologramPreviewManager), "Update")]
		[HarmonyPrefix]
		public static bool UpdatePrefix(HologramPreviewManager __instance)
		{
			UIManager instance = UIManager.instance;
			if (instance == null)
			{
				return true;
			}
			return !instance.anyMenuOpen;
		}
	}
	[Harmony]
	public class InventoryGridUIPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void shiftCountPrefix(SlotsSetup __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			__instance._shiftCount = (__instance.rotateSlots ? FHG_Utils.FloorToInt(FHG_Utils.Abs(__instance.scrollContent.anchoredPosition.y / __instance.spacing.y)) : 0);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(BaseResourceGridUI), "ResetToTop")]
		public static bool ResetToTopPrefix(BaseResourceGridUI __instance)
		{
			__instance.slotsSetup.ResetScrollToTop();
			return false;
		}
	}
	[HarmonyPatch]
	public class UIMenuPatch
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<UIMenuPatch>();

		private static GameObject worldAnchor;

		private static Vector3 lastCamOrigin = Vector3.zero;

		private static Vector3 lastPosition = Vector3.zero;

		[HarmonyPatch(typeof(UIMenu), "Start")]
		[HarmonyPostfix]
		public static void StartPostfix(UIMenu __instance)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug("Attaching world position behaviour to: " + ((Object)__instance).name);
			GameObject val = findTlc(((Component)__instance).gameObject);
			foreach (GameObject item in GameObjectFinder.FindChildObjectsByName("BG Blur", ((Component)((Component)__instance).transform.root).gameObject))
			{
				destroyBlur(item);
			}
			Canvas componentInParent = val.GetComponentInParent<Canvas>();
			componentInParent.renderMode = (RenderMode)2;
			((Component)componentInParent).gameObject.layer = 0;
			((Component)componentInParent).transform.SetParent(getWorldAnchor().transform);
			((Component)componentInParent).transform.localPosition = Vector3.zero;
			((Component)componentInParent).transform.localRotation = Quaternion.identity;
			if (__instance is InventoryAndCraftingUI)
			{
				((Component)componentInParent).transform.localScale = ModConfig.inventoryAndCraftingMenuScaleOverride.Value;
			}
			else
			{
				((Behaviour)((Component)componentInParent).GetComponent<CanvasScaler>()).enabled = false;
				((Component)componentInParent).transform.localScale = ModConfig.menuScale.Value;
			}
			AsyncGameObject.TimeoutFrames((Action)delegate
			{
				addInteractableUi(__instance);
			}, 1);
			disableButtonPrompts(__instance);
		}

		private static void addInteractableUi(UIMenu instance)
		{
			if (instance is GeneratorUI)
			{
				((InteractableUi)new PowerGeneratorInteractableUi(GameObjectFinder.FindChildObjectByName("Content Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is SmelterUI)
			{
				((InteractableUi)new SmelterInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is DrillUI)
			{
				((InteractableUi)new DrillInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is ThresherUI)
			{
				((InteractableUi)new ThresherInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is AssemblerUI)
			{
				GameObject gameObject = GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject);
				GameObject gameObject2 = GameObjectFinder.FindChildObjectByName("visible sidebar area", ((Component)instance).gameObject);
				((InteractableUi)new AssemblerInteractableUi(gameObject)).menu = (Menu)(object)new UIMenuWrapper(instance);
				((InteractableUi)new AssemblerRecipeSelectInteractableUi(gameObject2)).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is FilterInserterUI)
			{
				((InteractableUi)new FilterInserterInteractableUi(GameObjectFinder.FindChildObjectByName("Filter Options Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is PlanterUI)
			{
				((InteractableUi)new PlanterInteractableUi(GameObjectFinder.FindChildObjectByName("Content Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is ResourceGateUI)
			{
				((InteractableUi)new ResourceGateInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is ProductionTerminalMenu)
			{
				((InteractableUi)new ProductionTerminalInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is TransitDepotUI)
			{
				((InteractableUi)new TransitDepotInteractableUi(GameObjectFinder.FindChildObjectByName("Transit Depot Container ", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is TechTreeUI)
			{
				GameObject gameObject3 = GameObjectFinder.FindChildObjectByName("Main Tech Tree Container", ((Component)instance).gameObject);
				((InteractableUi)new TechTreeInteractableUi((TechTreeUI)(object)((instance is TechTreeUI) ? instance : null), gameObject3)).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is RepairableElevatorUI)
			{
				((InteractableUi)new RepairableElevatorInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
			else if (instance is BlastSmelterUI)
			{
				((InteractableUi)new BlastSmelterInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)instance).gameObject))).menu = (Menu)(object)new UIMenuWrapper(instance);
			}
		}

		private static void disableButtonPrompts(UIMenu __instance)
		{
			MKBInventoryButtonPrompts[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<MKBInventoryButtonPrompts>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.SetActive(false);
			}
			ControllerInventoryButtonPrompts[] componentsInChildren2 = ((Component)__instance).gameObject.GetComponentsInChildren<ControllerInventoryButtonPrompts>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Component)componentsInChildren2[i]).gameObject.SetActive(false);
			}
			foreach (GameObject item in GameObjectFinder.FindChildObjectsByName("MKB Inventory Button Prompts", ((Component)__instance).gameObject))
			{
				item.gameObject.SetActive(false);
			}
			foreach (GameObject item2 in GameObjectFinder.FindChildObjectsByName("Controller Button Prompts", ((Component)__instance).gameObject))
			{
				item2.gameObject.SetActive(false);
			}
			foreach (GameObject item3 in GameObjectFinder.FindChildObjectsByName("Inventory Button Prompts", ((Component)__instance).gameObject))
			{
				item3.gameObject.SetActive(false);
			}
		}

		private static GameObject findTlc(GameObject gameObject)
		{
			return GameObjectFinder.FindChildObjectByName("Top Level Container", gameObject) ?? GameObjectFinder.FindParentObjectByName("Top Level Container", gameObject) ?? gameObject;
		}

		[HarmonyPatch(typeof(UIMenu), "OnOpen")]
		[HarmonyPostfix]
		public static void OnOpenPostfix(UIMenu __instance)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			Logger.LogInfo("UIMenu.OnOpenPostfix: " + ((Object)__instance).name);
			if (!UIManager._instance.carouselUI.isOpen || !(lastPosition != Vector3.zero))
			{
				lastPosition = ((Component)VRCameraManager.mainCamera).transform.position + ((Component)VRCameraManager.mainCamera).transform.forward * ModConfig.menuSpawnDistance.Value + Vector3.down * ModConfig.menuDownwardOffset.Value;
				lastCamOrigin = ((Component)VRCameraManager.mainCamera).transform.position;
				setWorldAnchor(lastPosition, lastCamOrigin);
			}
		}

		[HarmonyPatch(typeof(UIMenu), "OnClose")]
		[HarmonyPostfix]
		public static void OnClosePostfix(UIMenu __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo("UIMenu.OnClosePostfix: " + ((Object)__instance).name);
			if (!UIManager._instance.carouselUI.isOpen)
			{
				lastPosition = Vector3.zero;
				lastCamOrigin = Vector3.zero;
				getWorldAnchor().transform.position = Vector3.zero;
			}
		}

		[HarmonyPatch(typeof(FHG_Utils), "ToggleAlpha")]
		[HarmonyPrefix]
		public static bool ToggleAlphaPrefix(CanvasGroup me, bool isOn)
		{
			return (Object)(object)me != (Object)null;
		}

		[HarmonyPatch(typeof(PlayerInventoryUI), "Start")]
		[HarmonyPostfix]
		public static void PlayerInventoryUIStartPostfix(PlayerInventoryUI __instance)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug("Attaching world position behaviour to: " + ((Object)__instance).name);
			Canvas myCanvas = __instance.myCanvas;
			((Component)myCanvas).gameObject.layer = 0;
			myCanvas.renderMode = (RenderMode)2;
			((Component)myCanvas).transform.SetParent(getWorldAnchor().transform, true);
			((Component)myCanvas).transform.localPosition = Vector3.zero;
			((Component)myCanvas).transform.localRotation = Quaternion.identity;
			((Component)myCanvas).transform.localScale = ModConfig.menuScale.Value;
		}

		[HarmonyPatch(typeof(RecipePickerUI), "Start")]
		[HarmonyPostfix]
		public static void RecipePickerUIStartPostfix(RecipePickerUI __instance)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug("Attaching world position behaviour to: " + ((Object)__instance).name);
			foreach (GameObject item in GameObjectFinder.FindChildObjectsByName("BG Blur", ((Component)((Component)__instance).transform.root).gameObject))
			{
				destroyBlur(item);
			}
			Canvas componentInParent = ((Component)__instance).GetComponentInParent<Canvas>();
			((Component)componentInParent).gameObject.layer = 0;
			componentInParent.renderMode = (RenderMode)2;
			((Component)componentInParent).transform.SetParent(getWorldAnchor().transform, true);
			((Component)componentInParent).transform.localPosition = Vector3.zero;
			((Component)componentInParent).transform.localScale = ModConfig.menuScale.Value;
			AsyncGameObject.TimeoutFrames((Action)delegate
			{
				((InteractableUi)new RecipePickerInteractableUi(GameObjectFinder.FindChildObjectByName("Container", ((Component)__instance).gameObject))).menu = (Menu)(object)new RecipePickerMenuWrapper(__instance);
			}, 10);
		}

		private static void destroyBlur(GameObject blur)
		{
			if (!((Object)(object)blur == (Object)null))
			{
				DisableWhenNoMenuOpen component = blur.GetComponent<DisableWhenNoMenuOpen>();
				if ((Object)(object)component != (Object)null)
				{
					Logger.LogDebug($"Deregistering component disabler: {component.targetBehaviour}");
					UIManager._instance.DeregisterComponentDisabler(component.targetBehaviour);
				}
				Object.Destroy((Object)(object)blur);
			}
		}

		private static GameObject getWorldAnchor()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)worldAnchor == (Object)null)
			{
				worldAnchor = new GameObject("UI World Anchor");
				Object.DontDestroyOnLoad((Object)(object)worldAnchor);
				worldAnchor.AddComponent<Gizmo>();
			}
			return worldAnchor;
		}

		private static void setWorldAnchor(Vector3 position, Vector3 camOrigin)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = getWorldAnchor();
			val.transform.position = position;
			val.transform.LookAt(2f * val.transform.position - camOrigin);
		}
	}
}
namespace TechtonicaVR.VrPlayer
{
	public class LightController
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<LightController>();

		private Headlamp[] headlamps;

		private GameObject backpackLight;

		private Interactable headlampInteractable;

		private Interactable backpackInteractable;

		public LightController(Headlamp[] headlamps)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			TechInputMapper.Use.ButtonReleased += new ButtonEventHandler(OnUseButtonReleased);
			this.headlamps = headlamps.Where((Headlamp h) => ((Behaviour)h).enabled).ToArray();
			headlampInteractable = AddHeadlampInteractable();
		}

		public void SetBackpackLight(GameObject light)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug("Setting backpack light...");
			backpackLight = light;
			GameObject val = new GameObject("BackpackLightInteractable");
			val.transform.SetParent(light.transform.parent, false);
			val.transform.localPosition = new Vector3(0.1837f, 0.9103f, 0.4041f);
			val.transform.localRotation = Quaternion.Euler(337.1403f, 3.5846f, 277.2928f);
			backpackInteractable = val.AddComponent<Interactable>();
			backpackInteractable.interactionTransform = TechCameraManager.rightHandObject.transform;
			backpackInteractable.OnEnter += delegate
			{
				SteamVRInputMapper.PlayVibration((SteamVR_Input_Sources)2, 0.3f, (float?)null, (float?)null);
			};
			Headlamp[] array = headlamps;
			if (array != null)
			{
				Enumeration.ForEach<Headlamp>((IEnumerable<Headlamp>)array, (Action<Headlamp>)delegate(Headlamp lamp)
				{
					lamp.TurnOff();
				});
			}
		}

		private void OnUseButtonReleased(object sender, SteamVR_Input_Sources source)
		{
			Interactable obj = headlampInteractable;
			if (obj != null && obj.isHovered)
			{
				ToggleHeadlamps();
				return;
			}
			Interactable obj2 = backpackInteractable;
			if (obj2 != null && obj2.isHovered)
			{
				ToggleBackpackLight();
			}
		}

		public void ToggleHeadlamps(bool group = true)
		{
			Logger.LogDebug("Toggling headlamp...");
			Headlamp[] array = headlamps;
			if (array != null)
			{
				Enumeration.ForEach<Headlamp>((IEnumerable<Headlamp>)array, (Action<Headlamp>)delegate(Headlamp lamp)
				{
					lamp.ToggleLight();
				});
			}
		}

		public void ToggleBackpackLight(bool group = true)
		{
			Logger.LogDebug("Toggling backpack light...");
			GameObject obj = backpackLight;
			if (obj != null)
			{
				obj.SetActive(!backpackLight.activeSelf);
			}
		}

		private Interactable AddHeadlampInteractable()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogDebug("Adding headlamp interactable...");
			if (headlamps == null)
			{
				Logger.LogDebug("No headlamp found");
				return null;
			}
			Headlamp val = headlamps.FirstOrDefault();
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogDebug("First headlamp not found");
				return null;
			}
			GameObject val2 = new GameObject("HeadlampInteractable");
			val2.transform.SetParent(((Component)val).transform.parent, false);
			val2.transform.localPosition = new Vector3(-0.0324f, 0.1657f, -0.0179f);
			val2.transform.localRotation = Quaternion.Euler(336.0304f, 355.1733f, 353.0185f);
			Interactable obj = val2.gameObject.AddComponent<Interactable>();
			obj.interactionTransform = TechCameraManager.rightHandObject.transform;
			obj.OnEnter += delegate
			{
				SteamVRInputMapper.PlayVibration((SteamVR_Input_Sources)2, 0.3f, (float?)null, (float?)null);
			};
			return obj;
		}
	}
	public class MainGamePlayer : MonoBehaviour
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<MainGamePlayer>();

		public static MainGamePlayer instance;

		public LightController lightController;

		private void Start()
		{
			if ((Object)(object)instance != (Object)null)
			{
				Logger.LogWarning("MainGamePlayer already exists! Destroying old instance!");
				Object.Destroy((Object)(object)instance);
			}
			instance = this;
			Logger.LogDebug("Setting up light controller...");
			Headlamp[] array = Object.FindObjectsOfType<Headlamp>();
			Enumeration.ForEach<Headlamp>((IEnumerable<Headlamp>)array, (Action<Headlamp>)delegate(Headlamp h)
			{
				((Component)h).transform.SetParent(((Component)VRCameraManager.mainCamera).transform, false);
			});
			lightController = new LightController(array);
		}
	}
}
namespace TechtonicaVR.Patches.MainMenu
{
	public class CameraOriginPatch : GameObjectPatch
	{
		public CameraOriginPatch()
			: base("Main Camera (origin)")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			gameObject.transform.position = new Vector3(-1614f, 23f, -2312f);
			return true;
		}
	}
	public class MenuCanvasPatch1080 : GameObjectPatch
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<MenuCanvasPatch1080>();

		public MenuCanvasPatch1080()
			: base("Canvas 1080")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_003c: 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)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Main Camera (origin)");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			gameObject.transform.parent = val.transform;
			gameObject.transform.localPosition = new Vector3(5.5982f, 0.7818f, 5.9599f);
			gameObject.transform.rotation = Quaternion.Euler(0f, 40.4374f, 0f);
			gameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
			gameObject.GetComponent<Canvas>().renderMode = (RenderMode)2;
			Logger.LogWarning("MenuCanvasPatch1080 applied");
			return true;
		}
	}
	public class MenuCanvasPatch1440 : GameObjectPatch
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<MenuCanvasPatch1440>();

		public MenuCanvasPatch1440()
			: base("Canvas 1440")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_003c: 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)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Main Camera (origin)");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			gameObject.transform.parent = val.transform;
			gameObject.transform.localPosition = new Vector3(5.5982f, 0.7818f, 5.9599f);
			gameObject.transform.rotation = Quaternion.Euler(0f, 40.4374f, 0f);
			gameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
			gameObject.GetComponent<Canvas>().renderMode = (RenderMode)2;
			Logger.LogWarning("MenuCanvasPatch1440 applied");
			return true;
		}
	}
	public class SpaceBGCameraPatch : GameObjectPatch
	{
		public SpaceBGCameraPatch()
			: base("Space BG Camera")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			GameObject val = GameObject.Find("Main Camera (origin)");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			gameObject.AddComponent<SteamVR_TrackedObject>();
			((Behaviour)gameObject.GetComponent<PostProcessLayer>()).enabled = false;
			Object.Destroy((Object)(object)gameObject.GetComponent("SpaceGraphicsToolkit.SgtCamera"));
			gameObject.transform.parent = val.transform;
			return true;
		}
	}
}
namespace TechtonicaVR.Patches.MainGame.UI
{
	internal class CompassPatch : GameComponentPatch<CompassUI>
	{
		protected override bool Apply(CompassUI component)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Transform child = ((Component)component).gameObject.transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas obj = ((Component)child).gameObject.AddComponent<HandTrackedCanvas>();
			obj.hand = SteamVRInputMapper.rightHandObject.transform;
			obj.showDirection = Vector3.right;
			obj.offset = new Vector3(0.08f, -0.03f, -0.1f);
			obj.showDistance = 0.3f;
			obj.rectTransform = ((Component)child.GetChild(0)).GetComponent<RectTransform>();
			child.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			for (int i = 0; i < child.childCount; i++)
			{
				child.GetChild(i).localPosition = Vector3.zero;
			}
			return true;
		}
	}
	internal class CraftingQueuePatch : GameComponentPatch<CraftingQueueGrid>
	{
		protected override bool Apply(CraftingQueueGrid component)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)component).gameObject.transform.parent;
			if ((Object)(object)parent == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas obj = ((Component)parent).gameObject.AddComponent<HandTrackedCanvas>();
			obj.hand = SteamVRInputMapper.leftHandObject.transform;
			obj.showDirection = -Vector3.right;
			obj.offset = new Vector3(-0.08f, 0.06f, -0.1f);
			obj.showDistance = 0.3f;
			obj.noTransform = true;
			obj.tlcLocalPosition = new Vector3(-17.7141f, 17.7794f, 0f);
			parent.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			for (int i = 0; i < parent.childCount; i++)
			{
				parent.GetChild(i).localPosition = Vector3.zero;
			}
			return true;
		}
	}
	public class CursorCanvasPatch : GameObjectPatch
	{
		public CursorCanvasPatch()
			: base("Cursor Canvas")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			TargetRaycastPatch.cursorTlc = gameObject.transform.GetChild(0);
			return true;
		}
	}
	internal class DialoguePopupPatch : GameComponentPatch<DialogueEntryPopupUI>
	{
		protected override bool Apply(DialogueEntryPopupUI component)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)component).gameObject.transform;
			if ((Object)(object)transform == (Object)null)
			{
				return false;
			}
			((Component)transform).transform.position = new Vector3(transform.position.x, 16f, transform.position.z);
			return true;
		}
	}
	public class HudPatch : GameComponentPatch<HUD>
	{
		protected override bool Apply(HUD component)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObjectFinder.FindChildObjectByName("Button Mappings Canvas", ((Component)component).gameObject);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = GameObjectFinder.FindChildObjectByName("Encumbered Warning", ((Component)component).gameObject);
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			val.SetActive(false);
			val2.transform.localPosition = new Vector3(-200f, 250f, -500f);
			return true;
		}
	}
	public class IaCMenuPatch : GameObjectPatch
	{
		public IaCMenuPatch()
			: base("Inventory and Crafting Menus")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			GameObject val = GameObjectFinder.FindChildObjectByName("Inventory Canvas", gameObject);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if ((Object)(object)GameObjectFinder.FindChildObjectByName("Crafting Canvas", gameObject) == (Object)null)
			{
				return false;
			}
			InventoryAndCraftingUI iac = Object.FindObjectOfType<InventoryAndCraftingUI>();
			if ((Object)(object)iac == (Object)null)
			{
				return false;
			}
			GameObject val2 = GameObjectFinder.FindChildObjectByName("All Button Mappings", ((Component)iac).gameObject);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.SetActive(false);
			}
			GameObject val3 = new GameObject("Inventory UI Anchor");
			val3.transform.parent = ((Component)iac).transform;
			val3.transform.localPosition = new Vector3(-616f, -600f, 0f);
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = new Vector3(1.1f, 2.35f, 1f);
			InventoryInteractableUi inventoryInteractableUi = new InventoryInteractableUi(((Component)val.GetComponentInChildren<InventoryGridUI>()).gameObject);
			((InteractableUi)inventoryInteractableUi).transform = val3.transform;
			((InteractableUi)inventoryInteractableUi).menu = (Menu)(object)new UIMenuWrapper((UIMenu)(object)iac);
			((InteractableUi)inventoryInteractableUi).OnEnterEvent = (UiEnterEvent)Delegate.Combine((Delegate?)(object)((InteractableUi)inventoryInteractableUi).OnEnterEvent, (Delegate?)(UiEnterEvent)delegate
			{
				iac.inventoryHasFocus = true;
				iac.Refresh();
			});
			GameObject val4 = new GameObject("Crafting UI Anchor");
			val4.transform.parent = ((Component)iac).transform;
			val4.transform.localPosition = new Vector3(1065f, 1270f, 0f);
			val4.transform.localRotation = Quaternion.identity;
			val4.transform.localScale = new Vector3(1.1f, 2.35f, 1f);
			CraftingInteractableUi craftingInteractableUi = new CraftingInteractableUi(((Component)gameObject.GetComponentInChildren<RecipePageUI>()).gameObject);
			((InteractableUi)craftingInteractableUi).transform = val4.transform;
			((InteractableUi)craftingInteractableUi).menu = (Menu)(object)new UIMenuWrapper((UIMenu)(object)iac);
			((InteractableUi)craftingInteractableUi).OnEnterEvent = (UiEnterEvent)Delegate.Combine((Delegate?)(object)((InteractableUi)craftingInteractableUi).OnEnterEvent, (Delegate?)(UiEnterEvent)delegate
			{
				iac.inventoryHasFocus = false;
				iac.Refresh();
			});
			return true;
		}
	}
	internal class InspectorCanvasPatch : GameComponentPatch<InspectorUI>
	{
		protected override bool Apply(InspectorUI gameObject)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			Transform child = ((Component)gameObject).transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			Transform child2 = ((Component)child).transform.GetChild(0);
			if ((Object)(object)child2 == (Object)null)
			{
				return false;
			}
			((Component)child2).transform.localPosition = new Vector3(23.8832f, -21.9059f, 0f);
			Transform child3 = ((Component)((Component)child).gameObject.transform.GetChild(1)).transform.GetChild(0);
			if ((Object)(object)child3 == (Object)null)
			{
				return false;
			}
			((Component)child3).transform.localPosition = new Vector3(211.4383f, -22.6601f, 0f);
			TargetRaycastPatch.inspectorTlc = child;
			return true;
		}
	}
	internal class MapPatch : GameComponentPatch<MapHUD>
	{
		protected override bool Apply(MapHUD component)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			Transform child = ((Component)component).transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas obj = ((Component)child).gameObject.AddComponent<HandTrackedCanvas>();
			obj.hand = SteamVRInputMapper.rightHandObject.transform;
			obj.showDirection = Vector3.right;
			obj.offset = new Vector3(0.08f, -0.03f, -0.1f);
			obj.showDistance = 0.2f;
			obj.rectTransform = ((Component)child.GetChild(0)).GetComponent<RectTransform>();
			obj.transformOverride = new Vector3(100f, 200f, 0f);
			child.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			for (int i = 0; i < child.childCount; i++)
			{
				child.GetChild(i).localPosition = Vector3.zero;
			}
			return true;
		}
	}
	internal class NotificationCanvasPatche : GameComponentPatch<NotificationUI>
	{
		protected override bool Apply(NotificationUI component)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Transform child = ((Component)component).gameObject.transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas obj = ((Component)child).gameObject.AddComponent<HandTrackedCanvas>();
			obj.hand = SteamVRInputMapper.leftHandObject.transform;
			obj.showDirection = Vector3.right;
			obj.offset = new Vector3(0.08f, -0.03f, -0.1f);
			obj.showDistance = 0.2f;
			obj.rectTransform = ((Component)child.GetChild(0)).GetComponent<RectTransform>();
			child.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			for (int i = 0; i < child.childCount; i++)
			{
				child.GetChild(i).localPosition = Vector3.zero;
			}
			return true;
		}
	}
	internal class OmniseekerPatch : GameComponentPatch<OmniseekerUI>
	{
		protected override bool Apply(OmniseekerUI component)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)component).transform;
			if ((Object)(object)transform == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas obj = ((Component)transform).gameObject.AddComponent<HandTrackedCanvas>();
			Scanner componentInChildren = SteamVRInputMapper.rightHandObject.GetComponentInChildren<Scanner>();
			obj.hand = ((componentInChildren != null) ? ((Component)componentInChildren).transform : null);
			Vector3 val = Vector3.forward + Vector3.left;
			obj.showDirection = ((Vector3)(ref val)).normalized;
			obj.offset = new Vector3(0.08f, -0.03f, -0.1f);
			obj.showDistance = 0.3f;
			obj.rectTransform = ((Component)transform.GetChild(0)).GetComponent<RectTransform>();
			obj.transformOverride = new Vector3(100f, 450f, 550f);
			transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			return true;
		}
	}
	public class PlayerArrowPatch : GameObjectPatch
	{
		public PlayerArrowPatch()
			: base("Player Arrow")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			gameObject.transform.parent = ((Component)VRCameraManager.mainCamera).transform;
			gameObject.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			return true;
		}
	}
	public class PlayerInventoryUIPatch : GameComponentPatch<PlayerInventoryUI>
	{
		protected override bool Apply(PlayerInventoryUI component)
		{
			InventoryGridUI componentInChildren = ((Component)component).gameObject.GetComponentInChildren<InventoryGridUI>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			new InventoryInteractableUi(((Component)componentInChildren).gameObject);
			return true;
		}
	}
	public class ProductionTerminalPatch : GameComponentPatch<ProductionTerminalMenu>
	{
		protected override bool Apply(ProductionTerminalMenu component)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			Transform child = ((Component)component).transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			ProductionTerminalCelebration componentInChildren = ((Component)child).GetComponentInChildren<ProductionTerminalCelebration>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			GameObject val = GameObjectFinder.FindChildObjectByName("VFX_AnimatedScaled_Text", ((Component)componentInChildren).gameObject);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Transform[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren<Transform>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = 0;
			}
			Transform transform = val.transform;
			transform.localPosition += new Vector3(0f, 0f, -250f);
			child.localPosition = Vector3.zero;
			return true;
		}
	}
	internal class QuestTaskListPatch : GameComponentPatch<QuestUI>
	{
		protected override bool Apply(QuestUI component)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			Transform child = ((Component)component).gameObject.transform.GetChild(0);
			if ((Object)(object)child == (Object)null)
			{
				return false;
			}
			HandTrackedCanvas val = ((Component)child).gameObject.AddComponent<HandTrackedCanvas>();
			val.hand = SteamVRInputMapper.leftHandObject.transform;
			val.showDirection = Vector3.right;
			val.offset = new Vector3(0.08f, -0.03f, -0.1f);
			val.showDistance = 0.2f;
			val.rectTransform = ((Component)child.GetChild(0)).GetComponent<RectTransform>();
			child.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
			child.GetChild(0).localPosition = Vector3.zero;
			DebugLine obj = ((Component)child).gameObject.AddComponent<DebugLine>();
			obj.start = val.hand;
			obj.end = child;
			return true;
		}
	}
	public class SaveNotificationPatch : GameComponentPatch<SaveNotification>
	{
		protected override bool Apply(SaveNotification component)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)((Component)component).transform.GetChild(0)).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return false;
			}
			GameObject gameObject2 = ((Component)gameObject.transform.GetChild(0)).gameObject;
			if ((Object)(object)gameObject2 == (Object)null)
			{
				return false;
			}
			gameObject2.transform.localPosition = new Vector3(200f, -200f, -500f);
			return true;
		}
	}
	public class StorageInventoryUIPatch : GameObjectPatch
	{
		public StorageInventoryUIPatch()
			: base("Storage Menu")
		{
		}

		protected override bool Apply(GameObject component)
		{
			InventoryGridUI componentInChildren = component.GetComponentInChildren<InventoryGridUI>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			new InventoryInteractableUi(((Component)((Component)componentInChildren).gameObject.transform.parent).gameObject, UIManager.instance.inventoryAndStorageMenu);
			return true;
		}
	}
	public class SystemLogUiPatch : GameComponentPatch<SystemLogUI>
	{
		protected override bool Apply(SystemLogUI component)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObjectFinder.FindChildObjectByName("System Log", ((Component)component).gameObject);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			val.transform.localPosition = new Vector3(0f, 500f, 0f);
			return true;
		}
	}
	internal class ToolbarUiPatch : GameComponentPatch<ToolbarUI>
	{
		protected override bool Apply(ToolbarUI component)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			HandTrackedCanvas obj = ((Component)component).gameObject.AddComponent<HandTrackedCanvas>();
			obj.hand = SteamVRInputMapper.leftHandObject.transform;
			obj.showDirection = -Vector3.right;
			obj.offset = new Vector3(-0.08f, 0.06f, -0.1f);
			obj.showDistance = 0.3f;
			obj.noTransform = true;
			((Component)component).transform.parent.localScale = new Vector3(-0.1f, 0.1f, 0.05f);
			for (int i = 0; i < ((Component)component).transform.childCount; i++)
			{
				((Component)component).transform.GetChild(i).localPosition = Vector3.zero;
			}
			return true;
		}
	}
	internal class PrimaryToolbarPatch : GameObjectPatch
	{
		public PrimaryToolbarPatch()
			: base("Primary Toolbar")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			new ToolbarInteractableUi(gameObject);
			return true;
		}
	}
	internal class SecondaryToolbarPatch : GameObjectPatch
	{
		public SecondaryToolbarPatch()
			: base("Secondary Toolbar")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			new ToolbarInteractableUi(gameObject);
			return true;
		}
	}
}
namespace TechtonicaVR.Patches.MainGame.Player
{
	public class RightHandAttachPatch : GameObjectPatch
	{
		public RightHandAttachPatch()
			: base("Right Hand Attach")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)SteamVRInputMapper.rightHandObject == (Object)null)
			{
				return false;
			}
			gameObject.transform.parent = SteamVRInputMapper.rightHandObject.transform;
			gameObject.transform.localPosition = new Vector3(0.0016f, 0.0749f, -0.0961f);
			gameObject.transform.localRotation = Quaternion.Euler(345.2184f, 358.572f, 280.9678f);
			return true;
		}
	}
	public class LeftHandAttachPatch : GameObjectPatch
	{
		public LeftHandAttachPatch()
			: base("Left Hand Attach")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)SteamVRInputMapper.leftHandObject == (Object)null)
			{
				return false;
			}
			gameObject.transform.parent = SteamVRInputMapper.leftHandObject.transform;
			gameObject.transform.localPosition = new Vector3(0.0571f, 0.0371f, -0.0295f);
			gameObject.transform.localRotation = Quaternion.Euler(28.9023f, 352.767f, 77.4064f);
			return true;
		}
	}
}
namespace TechtonicaVR.Patches.LoadingScreen
{
	public class LoadingScreenCanvasPatch : GameObjectPatch
	{
		public LoadingScreenCanvasPatch()
			: base("Black backdrop")
		{
		}

		protected override bool Apply(GameObject gameObject)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			gameObject = ((Component)gameObject.transform.parent).gameObject;
			gameObject.transform.position = new Vector3(0f, 0f, 0f);
			gameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
			gameObject.GetComponent<Canvas>().renderMode = (RenderMode)2;
			VRCameraManager.mainCamera.farClipPlane = 20f;
			return true;
		}
	}
}
namespace TechtonicaVR.Input
{
	[HarmonyPatch]
	internal class InputPatches
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<InputPatches>();

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ControlDefines), "UpdateCurrentController")]
		private static bool GetUseController()
		{
			FlowManager.instance.useController = true;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool GetIsUsingMouse(ref bool __result)
		{
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InputHandler), "SetVibration")]
		private static bool SetVibration(float leftIntensity, float rightIntensity)
		{
			SteamVR_Actions._default.Haptic.Execute(0f, Time.deltaTime, 1f / 60f, leftIntensity, (SteamVR_Input_Sources)1);
			SteamVR_Actions._default.Haptic.Execute(0f, Time.deltaTime, 1f / 60f, rightIntensity, (SteamVR_Input_Sources)2);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetAxis2D", new Type[]
		{
			typeof(int),
			typeof(int)
		})]
		private static bool GetAxis2D(ref Vector2 __result, int xAxisActionId, int yAxisActionId)
		{
			return handleAxisInput(ref __result, xAxisActionId, yAxisActionId);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetAxis2DRaw", new Type[]
		{
			typeof(int),
			typeof(int)
		})]
		private static bool GetAxis2DRaw(ref Vector2 __result, int xAxisActionId, int yAxisActionId)
		{
			return handleAxisInput(ref __result, xAxisActionId, yAxisActionId);
		}

		private static bool handleAxisInput(ref Vector2 __result, int xAxisActionId, int yAxisActionId)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			//IL_0049: 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)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (xAxisActionId == 0 && yAxisActionId == 1)
			{
				__result = SteamVRInputMapper.MoveAxes;
				if (ModConfig.VignetteOnSmoothLocomotion())
				{
					Vignette instance = Vignette.instance;
					if (instance != null)
					{
						Vector2 moveAxes = SteamVRInputMapper.MoveAxes;
						instance.Show(((Vector2)(ref moveAxes)).magnitude);
					}
				}
				return false;
			}
			if (xAxisActionId == 61 && yAxisActionId == 62)
			{
				__result = TechInputMapper.UIAxesPrimary;
				return false;
			}
			if (xAxisActionId == 57 && yAxisActionId == 58)
			{
				__result = TechInputMapper.UIAxesSecondary;
				return false;
			}
			if (xAxisActionId == 93 && yAxisActionId == 94)
			{
				__result = TechInputMapper.UIAxesSecondary;
				return false;
			}
			Logger.LogDebug($"Unknown Rewired axis action IDs: {xAxisActionId}, {yAxisActionId}. Using default Rewired input.");
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerFirstPersonController), "Move")]
		private static void Move(PlayerFirstPersonController __instance)
		{
			if ((__instance.m_IsGrounded || __instance.hoverPackActive) && !InputHandler.instance.playerInputBlocked && (!InputHandler.instance.playerInputBlockedOverride || !((Object)(object)VRCameraManager.mainCamera != (Object)null)))
			{
				Turn(__instance);
			}
		}

		private static void Turn(PlayerFirstPersonController __instance)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)VRCameraManager.mainCamera == (Object)null)
			{
				return;
			}
			if (TechInputMapper.snapTurnLeft.IsReleased())
			{
				ExecuteSnapTurn(__instance, -1f);
				return;
			}
			if (TechInputMapper.snapTurnRight.IsReleased())
			{
				ExecuteSnapTurn(__instance, 1f);
				return;
			}
			float num = SteamVRInputMapper.TurnAxis * Time.deltaTime * (float)ModConfig.smoothTurnSpeed.Value;
			if (ModConfig.VignetteOnSmoothTurn())
			{
				Vignette instance = Vignette.instance;
				if (instance != null)
				{
					instance.Show(Mathf.Abs(SteamVRInputMapper.TurnAxis));
				}
			}
			((Component)__instance).gameObject.transform.RotateAround(((Component)VRCameraManager.mainCamera).transform.position, Vector3.up, num);
		}

		private static void ExecuteSnapTurn(PlayerFirstPersonController __instance, float direction)
		{
			if (ModConfig.VignetteOnSnapTurn())
			{
				Vignette.instance.OneShot((Action)delegate
				{
					SnapTurn.Turn(((Component)__instance).gameObject, direction * ModConfig.snapTurnAngle.Value);
				}, 1f);
			}
			else
			{
				SnapTurn.Turn(((Component)__instance).gameObject, direction * ModConfig.snapTurnAngle.Value);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonDown", new Type[] { typeof(int) })]
		private static bool GetButtonDown(ref bool __result, int actionId)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsPressed();
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButtonDown", new Type[] { typeof(int) })]
		private static void GetButtonDown(int actionId, ref bool __result, bool __runOriginal)
		{
			if (__runOriginal & __result)
			{
				Logger.LogDebug($"Unknown Rewired button down action ID: {actionId}. Using default Rewired input.");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonUp", new Type[] { typeof(int) })]
		private static bool GetButtonUp(ref bool __result, int actionId)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsReleased();
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButtonUp", new Type[] { typeof(int) })]
		private static void GetButtonUp(int actionId, ref bool __result, bool __runOriginal)
		{
			if (__runOriginal & __result)
			{
				Logger.LogDebug($"Unknown Rewired button up action ID: {actionId}. Using default Rewired input.");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonTimedPress", new Type[]
		{
			typeof(int),
			typeof(float)
		})]
		private static bool GetButtonTimedPress(ref bool __result, int actionId, float time)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsTimedPress(time);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonLongPressDown", new Type[] { typeof(int) })]
		private static bool GetButtonLongPressDown(ref bool __result, int actionId)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsTimedPressDown(ModConfig.longPressTime.Value);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonTimedPressDown", new Type[]
		{
			typeof(int),
			typeof(float)
		})]
		private static bool GetButtonTimedPressDown(ref bool __result, int actionId, float time)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsTimedPressDown(time);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonTimedPressUp", new Type[]
		{
			typeof(int),
			typeof(float)
		})]
		private static bool GetButtonTimedPressUp(ref bool __result, int actionId, float time)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsTimedPressUp(time);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButtonTimedPressUp", new Type[]
		{
			typeof(int),
			typeof(float),
			typeof(float)
		})]
		private static bool GetButtonTimedPressUp(ref bool __result, int actionId, float time, float expireIn)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsTimedPressUp(time, expireIn);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetButton", new Type[] { typeof(int) })]
		private static bool GetButton(ref bool __result, int actionId)
		{
			Button val = MapButtonState(actionId);
			if (val != null)
			{
				__result = val.IsDown();
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButton", new Type[] { typeof(int) })]
		private static void GetButton(int actionId, ref bool __result, bool __runOriginal)
		{
			if (__runOriginal & __result)
			{
				Logger.LogDebug($"Unknown Rewired button action ID: {actionId}. Using default Rewired input.");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool AnyKeyPressed(ref bool __result)
		{
			if (InputHandler.instance.uiInputBlocked)
			{
				__result = false;
				return false;
			}
			GetAnyButtonDown(ref __result);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetAnyButton")]
		private static bool GetAnyButton(ref bool __result)
		{
			__result = AllButtons().Any((Button state) => state.IsDown());
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetAnyButtonDown")]
		private static bool GetAnyButtonDown(ref bool __result)
		{
			__result = AllButtons().Any((Button state) => state.IsPressed());
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "GetAnyButtonUp")]
		private static bool GetAnyButtonUp(ref bool __result)
		{
			__result = AllButtons().Any((Button state) => state.IsReleased());
			return false;
		}

		private static Button MapButtonState(int actionId)
		{
			switch (actionId)
			{
			case 4:
				return TechInputMapper.Jump;
			case 69:
				return TechInputMapper.Use;
			case 5:
			case 137:
				return TechInputMapper.Interact;
			case 16:
				return TechInputMapper.Sprint;
			case 42:
				return TechInputMapper.rotateLeft;
			case 38:
				return TechInputMapper.rotateRight;
			case 45:
				return TechInputMapper.Inventory;
			case 43:
				return TechInputMapper.toggleErase;
			case 114:
				return TechInputMapper.cycleHotbarLeft;
			case 65:
				return TechInputMapper.UIPageLeft;
			case 66:
				return TechInputMapper.UIPageRight;
			case 143:
				return TechInputMapper.UIPageLeftSecondary;
			case 144:
				return TechInputMapper.UIPageRightSecondary;
			case 59:
				return TechInputMapper.UISubmit;
			case 60:
				return TechInputMapper.UICancel;
			case 129:
				return TechInputMapper.HotbarEdit;
			case 107:
			case 131:
				return TechInputMapper.HotbarSwapItem;
			case 132:
				return TechInputMapper.HotbarExitEdit;
			case 130:
				return TechInputMapper.HotbarClear;
			case 63:
				return TechInputMapper.UIShortcut1;
			case 64:
				return TechInputMapper.UIShortcut2;
			case 95:
				return TechInputMapper.SonarZoomIn;
			case 96:
				return TechInputMapper.SonarZoomOut;
			case 83:
				return TechInputMapper.craft;
			case 84:
				return TechInputMapper.craftFive;
			case 85:
				return TechInputMapper.craftAll;
			case 87:
				return TechInputMapper.transfer;
			case 90:
				return TechInputMapper.transferHalf;
			case 91:
				return TechInputMapper.transferAll;
			case 92:
				return TechInputMapper.takeAll;
			case 113:
				return TechInputMapper.cycleHotbarRight;
			case 136:
				return TechInputMapper.TechTree;
			case 9:
				return TechInputMapper.PauseMenu;
			case 109:
				return TechInputMapper.Variant;
			default:
				return null;
			}
		}

		private static Button[] AllButtons()
		{
			return (Button[])(object)new Button[32]
			{
				TechInputMapper.Jump,
				TechInputMapper.Interact,
				TechInputMapper.Sprint,
				TechInputMapper.Inventory,
				TechInputMapper.TechTree,
				TechInputMapper.cycleHotbarLeft,
				TechInputMapper.takeAll,
				TechInputMapper.cycleHotbarRight,
				TechInputMapper.rotateLeft,
				TechInputMapper.rotateRight,
				TechInputMapper.UIPageLeft,
				TechInputMapper.UIPageRight,
				TechInputMapper.UIPageLeftSecondary,
				TechInputMapper.UIPageRightSecondary,
				TechInputMapper.UISubmit,
				TechInputMapper.UICancel,
				TechInputMapper.craft,
				TechInputMapper.craftFive,
				TechInputMapper.craftAll,
				TechInputMapper.transfer,
				TechInputMapper.transferHalf,
				TechInputMapper.transferAll,
				TechInputMapper.HotbarEdit,
				TechInputMapper.HotbarSwapItem,
				TechInputMapper.HotbarExitEdit,
				TechInputMapper.HotbarClear,
				TechInputMapper.UIShortcut1,
				TechInputMapper.UIShortcut2,
				TechInputMapper.SonarZoomIn,
				TechInputMapper.SonarZoomOut,
				TechInputMapper.PauseMenu,
				TechInputMapper.Variant
			};
		}
	}
	public static class TechInputMapper
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UpdateHandler <0>__HandleSteamVRMenuJoystickPrimary;

			public static UpdateHandler <1>__HandleSteamVRMenuJoystickSecondary;

			public static ChangeHandler <2>__UpdateLeftSkeleton;

			public static ChangeHandler <3>__UpdateRightSkeleton;
		}

		private static PluginLogger Logger = new PluginLogger(typeof(SteamVRInputMapper));

		public static Button Sprint = new Button(SteamVR_Actions.default_Sprint, (long?)null);

		public static Button Jump = new Button(SteamVR_Actions._default.Jump, (long?)null);

		public static Button Interact = new Button(SteamVR_Actions._default.Interact, (long?)SteamVRInputMapper.DefaultState);

		public static Button Use = new Button(SteamVR_Actions._default.Use, (long?)SteamVRInputMapper.DefaultState);

		public static Button TechTree = new Button(SteamVR_Actions._default.TechTree, (long?)null);

		public static Button Inventory = new Button(SteamVR_Actions._default.Inventory, (long?)null);

		public static Button takeAll = new Button(SteamVR_Actions._default.TakeAll, (long?)null);

		public static Button craft = new Button(SteamVR_Actions._default.Craft, (long?)null);

		public static Button craftFive = new Button(SteamVR_Actions._default.CraftFive, (long?)null);

		public static Button craftAll = new Button(SteamVR_Actions._default.CraftAll, (long?)null);

		public static Button transfer = new Button(SteamVR_Actions._default.Transfer, (long?)null);

		public static Button transferHalf = new Button(SteamVR_Actions._default.TransferHalf, (long?)null);

		public static Button transferAll = new Button(SteamVR_Actions._default.TransferAll, (long?)null);

		public static Button UIPageLeft = new Button(SteamVR_Actions._default.UIPageLeft, (long?)SteamVRInputMapper.DefaultState);

		public static Button UIPageRight = new Button(SteamVR_Actions._default.UIPageRight, (long?)SteamVRInputMapper.DefaultState);

		public static Button UIPageLeftSecondary = new Button(SteamVR_Actions._default.UIPageLeftSecondary, (long?)null);

		public static Button UIPageRightSecondary = new Button(SteamVR_Actions._default.UIPageRightSecondary, (long?)null);

		public static Button UISubmit = new Button(SteamVR_Actions._default.UISubmit, (long?)null);

		public static Button UICancel = new Button(SteamVR_Actions._default.UICancel, (long?)null);

		public static Button HotbarEdit = new Button(SteamVR_Actions._default.ToggleHotbarEdit, (long?)null);

		public static Button HotbarSwapItem = new Button(SteamVR_Actions._default.HotbarSwap, (long?)null);

		public static Button HotbarExitEdit = new Button(SteamVR_Actions._default.ExitHotbarEdit, (long?)null);

		public static Button HotbarClear = new Button(SteamVR_Actions._default.ClearHotbar, (long?)null);

		public static Button SonarZoomIn = new Button(SteamVR_Actions._default.SonarZoomIn, (long?)null);

		public static Button SonarZoomOut = new Button(SteamVR_Actions._default.SonarZoomOut, (long?)null);

		public static Button PauseMenu = new Button(SteamVR_Actions._default.PauseMenu, (long?)null);

		public static Button cycleHotbarLeft = new Button(SteamVR_Actions._default.CycleHotbarLeft, (long?)null);

		public static Button cycleHotbarRight = new Button(SteamVR_Actions._default.CycleHotbarRight, (long?)null);

		public static Button rotateLeft = new Button(SteamVR_Actions._default.RotateBuildingLeft, (long?)null);

		public static Button rotateRight = new Button(SteamVR_Actions._default.RotoateBuildingRight, (long?)null);

		public static Button toggleErase = new Button(SteamVR_Actions._default.ToggleErase, (long?)null);

		public static Button snapTurnLeft = new Button(SteamVR_Actions._default.SnapTurnLeft, (long?)null);

		public static Button snapTurnRight = new Button(SteamVR_Actions._default.SnapTurnRight, (long?)null);

		public static Button teleport = new Button(SteamVR_Actions._default.Teleport, (long?)null);

		public static Button Variant = new Button(SteamVR_Actions._default.Variant, (long?)null);

		public static Button UIClick = new Button(SteamVR_Actions.UI.Click, (long?)SteamVRInputMapper.UiState);

		public static Button UIShortcut1 = new Button(SteamVR_Actions._default.UIShortcut1, (long?)null);

		public static Button UIShortcut2 = new Button(SteamVR_Actions._default.UIShortcut2, (long?)null);

		public static Button Grab = new Button(SteamVR_Actions._default.GrabGrip, (long?)null);

		public static Vector2 UIAxesPrimary { get; private set; }

		public static Vector2 UIAxesSecondary { get; private set; }

		public static void MapActions()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			Logger.LogInfo("Mapping SteamVR actions...");
			((SteamVR_Action)UIClick.action).actionSet.Activate((SteamVR_Input_Sources)0, 0, false);
			SteamVR_Action_Vector2 menuJoystickPrimary = SteamVR_Actions._default.MenuJoystickPrimary;
			object obj = <>O.<0>__HandleSteamVRMenuJoystickPrimary;
			if (obj == null)
			{
				UpdateHandler val = HandleSteamVRMenuJoystickPrimary;
				<>O.<0>__HandleSteamVRMenuJoystickPrimary = val;
				obj = (object)val;
			}
			menuJoystickPrimary.AddOnUpdateListener((UpdateHandler)obj, (SteamVR_Input_Sources)0);
			SteamVR_Action_Vector2 menuJoystickSecondary = SteamVR_Actions._default.MenuJoystickSecondary;
			object obj2 = <>O.<1>__HandleSteamVRMenuJoystickSecondary;
			if (obj2 == null)
			{
				UpdateHandler val2 = HandleSteamVRMenuJoystickSecondary;
				<>O.<1>__HandleSteamVRMenuJoystickSecondary = val2;
				obj2 = (object)val2;
			}
			menuJoystickSecondary.AddOnUpdateListener((UpdateHandler)obj2, (SteamVR_Input_Sources)0);
			SteamVR_Action_Skeleton skeletonLeftHand = SteamVR_Actions._default.SkeletonLeftHand;
			object obj3 = <>O.<2>__UpdateLeftSkeleton;
			if (obj3 == null)
			{
				ChangeHandler val3 = UpdateLeftSkeleton;
				<>O.<2>__UpdateLeftSkeleton = val3;
				obj3 = (object)val3;
			}
			skeletonLeftHand.AddOnChangeListener((ChangeHandler)obj3);
			SteamVR_Action_Skeleton skeletonRightHand = SteamVR_Actions._default.SkeletonRightHand;
			object obj4 = <>O.<3>__UpdateRightSkeleton;
			if (obj4 == null)
			{
				ChangeHandler val4 = UpdateRightSkeleton;
				<>O.<3>__UpdateRightSkeleton = val4;
				obj4 = (object)val4;
			}
			skeletonRightHand.AddOnChangeListener((ChangeHandler)obj4);
		}

		private static void UpdateLeftSkeleton(SteamVR_Action_Skeleton skeleton)
		{
			UpdateSkeleton((HandType)0, skeleton);
		}

		private static void UpdateRightSkeleton(SteamVR_Action_Skeleton skeleton)
		{
			UpdateSkeleton((HandType)1, skeleton);
		}

		private static void UpdateSkeleton(HandType left, SteamVR_Action_Skeleton skeleton)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)NetworkIkPlayer.localInstance == (Object)null))
			{
				float[] fingerCurls = skeleton.GetFingerCurls(false);
				for (int i = 0; i < fingerCurls.Length; i++)
				{
					NetworkIkPlayer.localInstance.UpdateFingerCurl(left, (FingerType)i, fingerCurls[i]);
				}
			}
		}

		public static void UnmapActions()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			Logger.LogInfo("Unmapping SteamVR actions...");
			SteamVR_Action_Vector2 menuJoystickPrimary = SteamVR_Actions._default.MenuJoystickPrimary;
			object obj = <>O.<0>__HandleSteamVRMenuJoystickPrimary;
			if (obj == null)
			{
				UpdateHandler val = HandleSteamVRMenuJoystickPrimary;
				<>O.<0>__HandleSteamVRMenuJoystickPrimary = val;
				obj = (object)val;
			}
			menuJoystickPrimary.RemoveOnUpdateListener((UpdateHandler)obj, (SteamVR_Input_Sources)0);
			SteamVR_Action_Vector2 menuJoystickSecondary = SteamVR_Actions._default.MenuJoystickSecondary;
			object obj2 = <>O.<1>__HandleSteamVRMenuJoystickSecondary;
			if (obj2 == null)
			{
				UpdateHandler val2 = HandleSteamVRMenuJoystickSecondary;
				<>O.<1>__HandleSteamVRMenuJoystickSecondary = val2;
				obj2 = (object)val2;
			}
			menuJoystickSecondary.RemoveOnUpdateListener((UpdateHandler)obj2, (SteamVR_Input_Sources)0);
			SteamVR_Action_Skeleton skeletonLeftHand = SteamVR_Actions._default.SkeletonLeftHand;
			object obj3 = <>O.<2>__UpdateLeftSkeleton;
			if (obj3 == null)
			{
				ChangeHandler val3 = UpdateLeftSkeleton;
				<>O.<2>__UpdateLeftSkeleton = val3;
				obj3 = (object)val3;
			}
			skeletonLeftHand.RemoveOnChangeListener((ChangeHandler)obj3);
			SteamVR_Action_Skeleton skeletonRightHand = SteamVR_Actions._default.SkeletonRightHand;
			object obj4 = <>O.<3>__UpdateRightSkeleton;
			if (obj4 == null)
			{
				ChangeHandler val4 = UpdateRightSkeleton;
				<>O.<3>__UpdateRightSkeleton = val4;
				obj4 = (object)val4;
			}
			skeletonRightHand.RemoveOnChangeListener((ChangeHandler)obj4);
		}

		private static void HandleSteamVRMenuJoystickPrimary(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			UIAxesPrimary = axis;
		}

		private static void HandleSteamVRMenuJoystickSecondary(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			UIAxesSecondary = axis;
		}
	}
}
namespace TechtonicaVR.Input.Ui
{
	public class CraftingInteractableUi : InteractableUi
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<CraftingInteractableUi>();

		private RecipePageUI recipePage;

		private Transform tabsTransform;

		public CraftingInteractableUi(GameObject gameObject)
			: base(gameObject)
		{
			tabsTransform = GameObjectFinder.FindChildObjectByName("Tabs", gameObject).transform;
			recipePage = gameObject.GetComponent<RecipePageUI>();
			base.getInteractables = () => getTabs().Concat(getRecipes()).ToList();
		}

		private IEnumerable<Interactable> getTabs()
		{
			for (int i = 0; i < tabsTransform.childCount; i++)
			{
				GameObject tab = ((Component)tabsTransform.GetChild(i)).gameObject;
				yield return new InteractableBuilder((InteractableUi)(object)this, ((InteractableUi)this).getRect(tab.GetComponent<RectTransform>()), tab).withClick((InteractableClickEvent)delegate
				{
					onTabClick(tab);
				}, (Func<bool>)null).withHoverEnter((InteractableHoverEnterEvent)delegate
				{
					onTabHoverEnter(tab);
				}).withHoverExit((InteractableHoverExitEvent)delegate
				{
					onTabHoverExit(tab);
				})
					.build();
			}
		}

		protected void onTabHoverEnter(GameObject tab)
		{
			MouseInteraction component = tab.GetComponent<MouseInteraction>();
			if (!((Object)(object)component == (Object)null))
			{
				component.mouseEnterCallback();
			}
		}

		protected void onTabHoverExit(GameObject tab)
		{
			MouseInteraction component = tab.GetComponent<MouseInteraction>();
			if (!((Object)(object)component == (Object)null))
			{
				component.mouseExitCallback();
			}
		}

		private void onTabClick(GameObject tab)
		{
			MouseInteraction component = tab.GetComponent<MouseInteraction>();
			if (!((Object)(object)component == (Object)null))
			{
				component.mouseLeftClickCallback();
				((InteractableUi)this).rebuildInteractables();
			}
		}

		private IEnumerable<Interactable> getRecipes()
		{
			RecipeSlotUI[] componentsInChildren = ((Component)recipePage).gameObject.GetComponentsInChildren<RecipeSlotUI>();
			foreach (RecipeSlotUI recipe in componentsInChildren)
			{
				yield return new InteractableBuilder((InteractableUi)(object)this, ((InteractableUi)this).getRect(((Component)recipe).GetComponent<RectTransform>()), ((Component)recipe).gameObject).withClick((InteractableClickEvent)delegate
				{
					onRecipeClick(recipe);
				}, (Func<bool>)null).withHoverEnter((InteractableHoverEnterEvent)delegate
				{
					onRecipeHoverEnter(recipe);
				}).withHoverExit((InteractableHoverExitEvent)delegate
				{
					onRecipeHoverExit(recipe);
				})
					.build();
			}
		}

		protected void onRecipeHoverEnter(RecipeSlotUI slot)
		{
			((MouseInteraction)slot).mouseEnterCallback();
		}

		protected void onRecipeHoverExit(RecipeSlotUI slot)
		{
			((MouseInteraction)slot).mouseExitCallback();
		}

		private void onRecipeClick(RecipeSlotUI slot)
		{
			((MouseInteraction)slot).mouseLeftClickCallback();
		}
	}
	public class InventoryInteractableUi : InteractableUi
	{
		private static PluginLogger Logger = PluginLogger.GetLogger<InventoryInteractableUi>();

		protected ResourceInfo draggedResourceInfo;

		private InventoryNavigator chestUi;

		private int draggedResourceCount;

		public InventoryInteractableUi(GameObject gameObject, InventoryNavigator chestUi = null)
			: base(gameObject)
		{
			this.chestUi = chestUi;
			init();
		}

		protected virtual void init()
		{
			InventoryGridUI inv = ((Component)base.transform).gameObject.GetComponentInChildren<InventoryGridUI>() ?? ((Component)base.transform).gameObject.GetComponentInParent<InventoryGridUI>();
			base.getInteractables = () => inv.ui.slots.Select(getInteractable).Concat(((Component)base.transform).gameObject.GetComponentsInChildren<Button>().Select(getButtonInteractable)).ToList();
		}

		protected Interactable getInteractable(InventoryResourceSlotUI slot, int index)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00a7: Expected O, but got Unknown
			//IL_00a7: Expected O, but got Unknown
			//IL_00a7: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00c4: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			RectTransform rectTransform = ((Component)slot).GetComponent<RectTransform>();
			Rect rect = ((InteractableUi)this).getRect(rectTransform);
			return new InteractableBuilder((InteractableUi)(object)this, rect, ((Component)rectTransform).gameObject).withRecalculate((Func<Rect>)(() => ((InteractableUi)this).getRect(rectTransform))).withClick((InteractableClickEvent)delegate
			{
				onClick(slot);
			}, (Func<bool>)(() => isClickable())).withDrag((InteractableGetObjectCallback)(() => draggedResourceInfo ?? slot.resourceType), (InteractableDragEvent)delegate
			{
				onDrag(slot);
			}, (InteractableDropEvent)delegate(InteractableUi ui, Interactable _source, Interactable target)
			{
				onDrop(ui, target, slot);
			}, (InteractableCancelDragEvent)delegate
			{
				onCancelDrag(slot);
			})
				.withDrop(new InteractableAcceptsDropEvent(onAcceptsDrop), (InteractableReceiveDropEvent)delegate(InteractableUi _ui, object source)
				{
					onReceiveDrop(source, slot);
				})
				.withHoverEnter((InteractableHoverEnterEvent)delegate
				{
					onHoverEnter(slot);
				})
				.withHoverExit((InteractableHoverExitEvent)delegate
				{
					onHoverExit(slot);
				})
				.build();
		}

		protected Interactable getButtonInteractable(Button button, int index)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			RectTransform rectTransform = ((Component)button).GetComponent<RectTransform>();
			Rect rect = ((InteractableUi)this).getRect(rectTransform);
			return new InteractableBuilder((InteractableUi)(object)this, rect, ((Component)rectTransform).gameObject).withRecalculate((Func<Rect>)(() => ((InteractableUi)this).getRect(rectTransform))).withClick((InteractableClickEvent)delegate
			{
				onButtonClick(button);
			}, (Func<bool>)null).withHoverEnter((InteractableHoverEnterEvent)delegate
			{
				onButtonHoverEnter(button);
			})
				.withHoverExit((InteractableHoverExitEvent)delegate
				{
					onButtonHoverExit(button);
				})
				.build();
		}

		protected void onHoverEnter(InventoryResourceSlotUI slot)
		{
			((MouseInteraction)slot).mouseEnterCallback?.Invoke();
		}

		protected void onButtonHoverEnter(Button button)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			((Selectable)button).OnPointerEnter(new PointerEventData(EventSystem.current));
		}

		protected void onHoverExit(InventoryResourceSlotUI slot)
		{
			((MouseInteraction)slot).mouseExitCallback?.Invoke();
		}

		protected void onButtonHoverExit(Button button)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			((Selectable)button).OnPointerExit(new PointerEventData(EventSystem.current));
		}

		private void onClick(InventoryResourceSlotUI slot)
		{
			if (isSettingLimit())
			{
				((MouseInteraction)slot).mouseLeftClickCallback?.Invoke();
			}
		}

		private bool isClickable()
		{
			return isSettingLimit();
		}

		private void onButtonClick(Button button)
		{
			ButtonClickedEvent obj = button.onClick;
			if (obj != null)
			{
				((UnityEvent)obj).Invoke();
			}
		}

		protected void onDrag(InventoryResourceSlotUI slot)
		{
			PluginLogger logger = Logger;
			ResourceInfo resourceType = slot.resourceType;
			logger.LogDebug("Dragged toolbar slot " + ((resourceType != null) ? ((Object)resourceType).name : null));
			draggedResourceInfo = slot.resourceType;
			draggedResourceCount = slot.resourceQuantity;
			((MouseInteraction)slot).mouseLeftClickCallback();
		}

		protected void onDrop(InteractableUi ui, Interactable target, InventoryResourceSlotUI sourceSlot)
		{
			PluginLogger logger = Logger;
			ResourceInfo resourceType = sourceSlot.resourceType;
			logger.LogDebug("Dropped inventory slot " + ((resourceType != null) ? ((Object)resourceType).name : null));
			ResourceInfo val = draggedResourceInfo;
			draggedResourceInfo = null;
			if (target == null)
			{
				((MouseInteraction)sourceSlot).mouseLeftClickCallback();
			}
			else if (ui is InventoryInteractableUi)
			{
				InventoryResourceSlotUI component = target.gameObject.GetComponent<InventoryResourceSlotUI>();
				if ((Object)(object)component == (Object)null)
				{
					Logger.LogDebug("Target " + ((Object)target.gameObject).name + " is not a ToolbarSlotUI");
					return;
				}
				((MouseInteraction)component).mouseLeftClickCallback();
				MouseCursorBuffer.instance.TryCancel();
			}
			else if (ui is ToolbarInteractableUi)
			{
				target.receiveDrop(target.ui, (object)val);
				((MouseInteraction)sourceSlot).mouseLeftClickCallback();
			}
			else
			{
				onCancelDrag(sourceSlot);
			}
		}

		protected void onCancelDrag(InventoryResourceSlotUI slot)
		{
			((MouseInteraction)slot).mouseLeftClickCallback();
			draggedResourceInfo = null;
		}

		protected void onAcceptsDrop(AcceptDropEventArgs args)
		{
			if (args.source.ui is InventoryInteractableUi)
			{
				Interactable source = args.source;
				object obj = ((source != null) ? source.GetObjectCallback.Invoke() : null);
				if (!((Object)((obj is ResourceInfo) ? obj : null) == (Object)null))
				{
					args.accept = args.accept || true;
				}
			}
		}

		protected void onReceiveDrop(object sourceObject, InventoryResourceSlotUI slot)
		{
			if ((Object)((sourceObject is ResourceInfo) ? sourceObject : null) == (Object)null)
			{
				Logger.LogError($"Received drop of {sourceObject} which is not a ResourceInfo");
			}
		}

		private bool isSettingLimit()
		{
			if ((Object)(object)chestUi == (Object)null)
			{
				return false;
			}
			return chestUi.settingLimit;
		}
	}
	public class TechTreeInteractableUi : InteractableUi
	{
		private TechTreeUI techTreeUi;

		public TechTreeInteractableUi(TechTreeUI ui, GameObject gameObject)
			: base(gameObject)
		{
			TechTreeInteractableUi @object = this;
			techTreeUi = ui;
			base.getInteractables = () => gameObject.GetComponentsInChildren<TechTreeCategoryButton>().Select(@object.getCategoryButtonInteractable).Concat(from interactable in gameObject.GetComponentsInChildren<TechTreeNode>().Select(@object.getTechTreeNodeInteractable)
				where interactable != null
				select interactable)
				.ToList();
		}

		private Interactable getTechTreeNodeInteractable(TechTreeNode node)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			if (node.myUnlock.category != techTreeUi.gridUI.curCategory)
			{
				return null;
			}
			RectTransform component = ((Component)node).GetComponent<RectTransform>();
			return new InteractableBuilder((InteractableUi)(object)this, ((InteractableUi)this).getRect(component), ((Component)node).gameObject).withClick((InteractableClickEvent)delegate
			{
				((MouseInteraction)node).mouseLeftClickCallback?.Invoke();
			}, (Func<bool>)null).withMouseDown((Action)delegate
			{
				((MouseInteraction)node).mouseDownCallback?.Invoke();
			}).withMouseUp((Action)delegate
			{
				((MouseInteraction)node).mouseUpCallback?.Invoke();
			})
				.withHoverEnter((InteractableHoverEnterEvent)delegate
				{
					((MouseInteraction)node).mouseEnterCallback?.Invoke();
				})
				.withHoverExit((InteractableHoverExitEvent)delegate
				{
					((MouseInteraction)node).mouseE