Decompiled source of ModernCamera v2.0.0

ModernCamera.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ModernCamera.Behaviours;
using ModernCamera.Enums;
using ModernCamera.Hooks;
using ModernCamera.Structs;
using ModernCamera.Utils;
using ProjectM;
using ProjectM.Sequencer;
using ProjectM.UI;
using Silkworm.API;
using Silkworm.Core.KeyBinding;
using Silkworm.Core.Options;
using Silkworm.Utils;
using Unity.Entities;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VRising")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes the camera more like a mmo camera and removes the limits")]
[assembly: AssemblyFileVersion("1.5.6.0")]
[assembly: AssemblyInformationalVersion("1.5.6+14518f253fa428f7c3bca513503b9dfeb68960d7")]
[assembly: AssemblyProduct("ModernCamera")]
[assembly: AssemblyTitle("ModernCamera")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.6.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ModernCamera
{
	public class ModernCamera : MonoBehaviour
	{
		private static GameObject CrosshairPrefab;

		private static GameObject Crosshair;

		private static CanvasScaler CanvasScaler;

		private static bool ShouldGatherSystems = true;

		private static ZoomModifierSystem ZoomModifierSystem;

		private static PrefabCollectionSystem PrefabCollectionSystem;

		private static UIDataSystem UIDataSystem;

		private static Camera GameCamera;

		private static bool GameFocused;

		public static void Enabled(bool enabled)
		{
			Settings.Enabled = enabled;
			UpdateEnabled(enabled);
		}

		public static void ActionMode(bool enabled)
		{
			ModernCameraState.IsMouseLocked = enabled;
			ModernCameraState.IsActionMode = enabled;
		}

		private static void UpdateEnabled(bool enabled)
		{
			if (ZoomModifierSystem != null)
			{
				((ComponentSystemBase)ZoomModifierSystem).Enabled = !enabled;
			}
			if ((Object)(object)Crosshair != (Object)null)
			{
				Crosshair.active = enabled && Settings.AlwaysShowCrosshair && !ModernCameraState.InBuildMode;
			}
			if (!enabled)
			{
				Cursor.visible = true;
				ActionMode(enabled: false);
			}
		}

		private static void UpdateFieldOfView(float fov)
		{
			if ((Object)(object)GameCamera != (Object)null)
			{
				GameCamera.fieldOfView = fov;
			}
		}

		private static void ToggleUI()
		{
			ModernCameraState.IsUIHidden = !ModernCameraState.IsUIHidden;
			DisableUISettings.SetHideHUD(ModernCameraState.IsUIHidden, WorldUtils.ClientWorld);
		}

		private void Awake()
		{
			ModernCameraState.RegisterCameraBehaviour(new FirstPersonCameraBehaviour());
			ModernCameraState.RegisterCameraBehaviour(new ThirdPersonCameraBehaviour());
			Settings.AddEnabledListener(UpdateEnabled);
			Settings.AddFieldOfViewListener(UpdateFieldOfView);
		}

		private void Update()
		{
			if (!GameFocused || !Settings.Enabled)
			{
				return;
			}
			if ((Object)(object)CrosshairPrefab == (Object)null)
			{
				BuildCrosshair();
			}
			if (WorldUtils.ClientWorldExists)
			{
				if ((Object)(object)GameCamera == (Object)null)
				{
					GameObject val = GameObject.Find("Main_GameToolCamera(Clone)");
					if ((Object)(object)val != (Object)null)
					{
						GameCamera = val.GetComponent<Camera>();
						UpdateFieldOfView(Settings.FieldOfView);
					}
				}
				if (ShouldGatherSystems)
				{
					GatherSystems();
				}
				UpdateSystems();
				UpdateCrosshair();
			}
			else
			{
				ShouldGatherSystems = true;
				Cursor.visible = true;
			}
		}

		private void OnApplicationFocus(bool hasFocus)
		{
			GameFocused = hasFocus;
		}

		private void BuildCrosshair()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (CursorController._CursorDatas != null)
				{
					CursorData val = ((IEnumerable<CursorData>)CursorController._CursorDatas).First((CursorData x) => (int)x.CursorType == 0);
					if (val != null)
					{
						CrosshairPrefab = new GameObject("Crosshair");
						CrosshairPrefab.active = false;
						CrosshairPrefab.AddComponent<CanvasRenderer>();
						RectTransform val2 = CrosshairPrefab.AddComponent<RectTransform>();
						((Component)val2).transform.SetSiblingIndex(1);
						val2.pivot = new Vector2(0.5f, 0.5f);
						val2.anchorMin = new Vector2(0.5f, 0.5f);
						val2.anchorMax = new Vector2(0.5f, 0.5f);
						val2.sizeDelta = new Vector2(32f, 32f);
						((Transform)val2).localScale = new Vector3(1.2f, 1.2f, 1.2f);
						((Transform)val2).localPosition = new Vector3(0f, 0f, 0f);
						Image val3 = CrosshairPrefab.AddComponent<Image>();
						val3.sprite = Sprite.Create(val.Texture, new Rect(0f, 0f, (float)((Texture)val.Texture).width, (float)((Texture)val.Texture).height), new Vector2(0.5f, 0.5f), 100f);
						CrosshairPrefab.active = false;
					}
				}
			}
			catch (Exception ex)
			{
				LogUtils.LogDebugError((object)ex);
			}
		}

		private void GatherSystems()
		{
			ZoomModifierSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<ZoomModifierSystem>();
			if (ZoomModifierSystem != null)
			{
				((ComponentSystemBase)ZoomModifierSystem).Enabled = false;
			}
			PrefabCollectionSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<PrefabCollectionSystem>();
			UIDataSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<UIDataSystem>();
			ShouldGatherSystems = false;
		}

		private void UpdateSystems()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			if (UIDataSystem == null || PrefabCollectionSystem == null)
			{
				return;
			}
			try
			{
				if ((Object)(object)UIDataSystem.UI.BuffBarParent != (Object)null)
				{
					ModernCameraState.IsShapeshifted = false;
					ModernCameraState.ShapeshiftName = "";
					Enumerator<Data> enumerator = UIDataSystem.UI.BuffBarParent.BuffsSelectionGroup.Entries.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Data current = enumerator.Current;
						if (!PrefabCollectionSystem.PrefabGuidToNameDictionary.ContainsKey(current.PrefabGUID))
						{
							continue;
						}
						string text = PrefabCollectionSystem.PrefabGuidToNameDictionary[current.PrefabGUID];
						if (text != null)
						{
							ModernCameraState.IsShapeshifted = text.Contains("shapeshift", StringComparison.OrdinalIgnoreCase);
							if (ModernCameraState.IsShapeshifted)
							{
								ModernCameraState.ShapeshiftName = text.Trim();
								break;
							}
						}
					}
				}
				if (!((Object)(object)UIDataSystem.UI.AbilityBar != (Object)null))
				{
					return;
				}
				ModernCameraState.IsMounted = false;
				Enumerator<AbilityBarEntry> enumerator2 = UIDataSystem.UI.AbilityBar.Entries.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					AbilityBarEntry current2 = enumerator2.Current;
					if (!PrefabCollectionSystem.PrefabGuidToNameDictionary.ContainsKey(current2.AbilityId))
					{
						continue;
					}
					string text2 = PrefabCollectionSystem.PrefabGuidToNameDictionary[current2.AbilityId];
					if (text2 != null)
					{
						ModernCameraState.IsMounted = text2.Contains("mounted", StringComparison.OrdinalIgnoreCase);
						if (ModernCameraState.IsMounted)
						{
							break;
						}
					}
				}
			}
			catch (Exception ex)
			{
				LogUtils.LogDebugError((object)ex);
			}
		}

		private void UpdateCrosshair()
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				bool visible = true;
				bool flag = false;
				if ((Object)(object)Crosshair == (Object)null && (Object)(object)CrosshairPrefab != (Object)null)
				{
					GameObject val = GameObject.Find("HUDCanvas(Clone)/Canvas");
					if ((Object)(object)val == (Object)null)
					{
						return;
					}
					CanvasScaler = val.GetComponent<CanvasScaler>();
					Crosshair = Object.Instantiate<GameObject>(CrosshairPrefab, val.transform);
					Crosshair.active = true;
				}
				if (ModernCameraState.ValidGameplayInputState && (ModernCameraState.IsMouseLocked || ((InputState)(ref ModernCameraState.GameplayInputState)).IsInputPressed((ButtonInputAction)500)) && !ModernCameraState.IsMenuOpen)
				{
					if (ModernCameraState.IsActionMode || ModernCameraState.IsFirstPerson || Settings.CameraAimMode == CameraAimMode.Forward)
					{
						Mouse.SetCursorPosition(Screen.width / 2 + Settings.AimOffsetX, Screen.height / 2 - Settings.AimOffsetY);
					}
					flag = ModernCameraState.IsFirstPerson || (ModernCameraState.IsActionMode && Settings.ActionModeCrosshair);
					visible = false;
				}
				if ((Object)(object)Crosshair != (Object)null)
				{
					Crosshair.active = (flag || Settings.AlwaysShowCrosshair) && !ModernCameraState.InBuildMode;
					if (ModernCameraState.IsFirstPerson)
					{
						Crosshair.transform.localPosition = Vector3.zero;
					}
					else if ((Object)(object)CanvasScaler != (Object)null)
					{
						Crosshair.transform.localPosition = new Vector3((float)Settings.AimOffsetX * (CanvasScaler.referenceResolution.x / (float)Screen.width), (float)Settings.AimOffsetY * (CanvasScaler.referenceResolution.y / (float)Screen.height), 0f);
					}
				}
				Cursor.visible = visible;
			}
			catch (Exception ex)
			{
				LogUtils.LogDebugError((object)ex);
			}
		}
	}
	internal static class ModernCameraState
	{
		internal static bool IsUIHidden;

		internal static bool IsFirstPerson;

		internal static bool IsActionMode;

		internal static bool IsMouseLocked;

		internal static bool IsShapeshifted;

		internal static bool IsMounted;

		internal static bool InBuildMode;

		internal static string ShapeshiftName;

		internal static BehaviourType CurrentBehaviourType = BehaviourType.Default;

		internal static Dictionary<BehaviourType, CameraBehaviour> CameraBehaviours = new Dictionary<BehaviourType, CameraBehaviour>();

		internal static bool ValidGameplayInputState;

		internal static InputState GameplayInputState;

		private static int _menusOpen;

		internal static bool IsMenuOpen
		{
			get
			{
				return _menusOpen > 0;
			}
			set
			{
				_menusOpen = (value ? (_menusOpen + 1) : Mathf.Max(0, _menusOpen - 1));
			}
		}

		internal static CameraBehaviour CurrentCameraBehaviour
		{
			get
			{
				if (CameraBehaviours.ContainsKey(CurrentBehaviourType))
				{
					return CameraBehaviours[CurrentBehaviourType];
				}
				return null;
			}
		}

		internal static void RegisterCameraBehaviour(CameraBehaviour behaviour)
		{
			CameraBehaviours.Add(behaviour.BehaviourType, behaviour);
		}

		internal static void Reset()
		{
			IsUIHidden = false;
			IsFirstPerson = false;
			IsActionMode = false;
			IsMouseLocked = false;
			IsShapeshifted = false;
			IsMounted = false;
			InBuildMode = false;
			ShapeshiftName = "";
			ValidGameplayInputState = false;
			CurrentCameraBehaviour?.Deactivate();
			CurrentBehaviourType = BehaviourType.Default;
		}
	}
	[BepInProcess("VRising.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("VRising.ModernCamera", "ModernCamera", "1.5.6")]
	public class Plugin : BasePlugin
	{
		private static Harmony Harmony;

		public override void Load()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			LogUtils.Init(((BasePlugin)this).Log);
			Settings.Init();
			((BasePlugin)this).AddComponent<ModernCamera>();
			TopdownCameraSystem_Hook.CreateAndApply();
			Harmony = new Harmony("VRising.ModernCamera");
			Harmony.PatchAll();
			LogUtils.LogInfo((object)"Plugin VRising.ModernCamera v1.5.6 is loaded!");
		}

		public override bool Unload()
		{
			Harmony.UnpatchSelf();
			TopdownCameraSystem_Hook.Dispose();
			return true;
		}
	}
	internal static class Settings
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static OnChange<float> <>9__93_0;

			public static OnChange<float> <>9__93_1;

			public static OnChange<float> <>9__93_2;

			public static OnChange<float> <>9__93_3;

			public static KeyEvent <>9__94_0;

			public static KeyEvent <>9__94_1;

			internal void <SetupOptions>b__93_0(float value)
			{
				if (value + ZoomOffset > MaxZoom && value + ZoomOffset < MaxZoomOption.MaxValue)
				{
					((Option<float>)(object)MaxZoomOption).SetValue(value + ZoomOffset);
				}
				else if (value + ZoomOffset > MaxZoomOption.MaxValue)
				{
					((Option<float>)(object)MinZoomOption).SetValue(MaxZoomOption.MaxValue - ZoomOffset);
				}
			}

			internal void <SetupOptions>b__93_1(float value)
			{
				if (value - ZoomOffset < MinZoom && value - ZoomOffset > MinZoomOption.MinValue)
				{
					((Option<float>)(object)MinZoomOption).SetValue(value - ZoomOffset);
				}
				else if (value - ZoomOffset < MinZoomOption.MinValue)
				{
					((Option<float>)(object)MaxZoomOption).SetValue(MinZoomOption.MinValue + ZoomOffset);
				}
			}

			internal void <SetupOptions>b__93_2(float value)
			{
				if (value > ((Option<float>)(object)MaxPitchOption).Value && value < MaxPitchOption.MaxValue)
				{
					((Option<float>)(object)MaxPitchOption).SetValue(value);
				}
				else if (value > MaxPitchOption.MaxValue)
				{
					((Option<float>)(object)MinPitchOption).SetValue(MaxPitchOption.MaxValue);
				}
			}

			internal void <SetupOptions>b__93_3(float value)
			{
				if (value < ((Option<float>)(object)MinPitchOption).Value && value > MinPitchOption.MinValue)
				{
					((Option<float>)(object)MinPitchOption).SetValue(value);
				}
				else if (value < MinPitchOption.MinValue)
				{
					((Option<float>)(object)MaxPitchOption).SetValue(MinPitchOption.MinValue);
				}
			}

			internal void <SetupKeybinds>b__94_0()
			{
				((Option<bool>)(object)EnabledOption).SetValue(!Enabled);
			}

			internal void <SetupKeybinds>b__94_1()
			{
				if (Enabled && !ModernCameraState.IsFirstPerson)
				{
					ModernCameraState.IsMouseLocked = !ModernCameraState.IsMouseLocked;
					ModernCameraState.IsActionMode = !ModernCameraState.IsActionMode;
				}
			}
		}

		internal static float FirstPersonForwardOffset = 1.65f;

		internal static float MountedOffset = 1.6f;

		internal static float HeadHeightOffset = 1.05f;

		internal static float ShoulderRightOffset = 0.8f;

		internal static Dictionary<string, Vector2> FirstPersonShapeshiftOffsets = new Dictionary<string, Vector2>
		{
			{
				"AB_Shapeshift_Bat_Buff",
				new Vector2(0f, 2.5f)
			},
			{
				"AB_Shapeshift_Bear_Buff",
				new Vector2(0.25f, 5f)
			},
			{
				"AB_Shapeshift_Bear_Skin01_Buff",
				new Vector2(0.25f, 5f)
			},
			{
				"AB_Shapeshift_Human_Grandma_Skin01_Buff",
				new Vector2(-0.1f, 1.55f)
			},
			{
				"AB_Shapeshift_Human_Buff",
				new Vector2(0.5f, 1.4f)
			},
			{
				"AB_Shapeshift_Rat_Buff",
				new Vector2(-1.85f, 2f)
			},
			{
				"AB_Shapeshift_Toad_Buff",
				new Vector2(-0.6f, 4.2f)
			},
			{
				"AB_Shapeshift_Wolf_Buff",
				new Vector2(-0.25f, 4.3f)
			},
			{
				"AB_Shapeshift_Wolf_Skin01_Buff",
				new Vector2(-0.25f, 4.3f)
			}
		};

		private static float ZoomOffset = 2f;

		private static ToggleOption EnabledOption;

		private static SliderOption FieldOfViewOption;

		private static ToggleOption AlwaysShowCrosshairOption;

		private static ToggleOption ActionModeCrosshairOption;

		private static ToggleOption FirstPersonEnabledOption;

		private static ToggleOption DefaultBuildModeOption;

		private static DropdownOption CameraAimModeOption;

		private static SliderOption AimOffsetXOption;

		private static SliderOption AimOffsetYOption;

		private static ToggleOption LockCameraZoomOption;

		private static SliderOption LockCameraZoomDistanceOption;

		private static SliderOption MinZoomOption;

		private static SliderOption MaxZoomOption;

		private static ToggleOption LockCameraPitchOption;

		private static SliderOption LockCameraPitchAngleOption;

		private static SliderOption MinPitchOption;

		private static SliderOption MaxPitchOption;

		private static ToggleOption OverTheShoulderOption;

		private static SliderOption OverTheShoulderXOption;

		private static SliderOption OverTheShoulderYOption;

		private static Keybinding EnabledKeybind;

		private static Keybinding ActionModeKeybind;

		private static Keybinding HideUIKeybind;

		internal static bool Enabled
		{
			get
			{
				return ((Option<bool>)(object)EnabledOption).Value;
			}
			set
			{
				((Option<bool>)(object)EnabledOption).SetValue(value);
			}
		}

		internal static bool FirstPersonEnabled
		{
			get
			{
				return ((Option<bool>)(object)FirstPersonEnabledOption).Value;
			}
			set
			{
				((Option<bool>)(object)FirstPersonEnabledOption).SetValue(value);
			}
		}

		internal static bool DefaultBuildMode
		{
			get
			{
				return ((Option<bool>)(object)DefaultBuildModeOption).Value;
			}
			set
			{
				((Option<bool>)(object)DefaultBuildModeOption).SetValue(value);
			}
		}

		internal static bool AlwaysShowCrosshair
		{
			get
			{
				return ((Option<bool>)(object)AlwaysShowCrosshairOption).Value;
			}
			set
			{
				((Option<bool>)(object)AlwaysShowCrosshairOption).SetValue(value);
			}
		}

		internal static bool ActionModeCrosshair
		{
			get
			{
				return ((Option<bool>)(object)ActionModeCrosshairOption).Value;
			}
			set
			{
				((Option<bool>)(object)ActionModeCrosshairOption).SetValue(value);
			}
		}

		internal static float FieldOfView
		{
			get
			{
				return ((Option<float>)(object)FieldOfViewOption).Value;
			}
			set
			{
				((Option<float>)(object)FieldOfViewOption).SetValue(value);
			}
		}

		internal static int AimOffsetX
		{
			get
			{
				return (int)((float)Screen.width * (((Option<float>)(object)AimOffsetXOption).Value / 100f));
			}
			set
			{
				((Option<float>)(object)AimOffsetXOption).SetValue((float)Mathf.Clamp(value / Screen.width, -25, 25));
			}
		}

		internal static int AimOffsetY
		{
			get
			{
				return (int)((float)Screen.height * (((Option<float>)(object)AimOffsetYOption).Value / 100f));
			}
			set
			{
				((Option<float>)(object)AimOffsetYOption).SetValue((float)Mathf.Clamp(value / Screen.width, -25, 25));
			}
		}

		internal static CameraAimMode CameraAimMode
		{
			get
			{
				return CameraAimModeOption.GetEnumValue<CameraAimMode>();
			}
			set
			{
				((Option<int>)(object)CameraAimModeOption).SetValue((int)value);
			}
		}

		internal static bool LockZoom
		{
			get
			{
				return ((Option<bool>)(object)LockCameraZoomOption).Value;
			}
			set
			{
				((Option<bool>)(object)LockCameraZoomOption).SetValue(value);
			}
		}

		internal static float LockZoomDistance
		{
			get
			{
				return ((Option<float>)(object)LockCameraZoomDistanceOption).Value;
			}
			set
			{
				((Option<float>)(object)LockCameraZoomDistanceOption).SetValue(value);
			}
		}

		internal static float MinZoom
		{
			get
			{
				return ((Option<float>)(object)MinZoomOption).Value;
			}
			set
			{
				((Option<float>)(object)MinZoomOption).SetValue(value);
			}
		}

		internal static float MaxZoom
		{
			get
			{
				return ((Option<float>)(object)MaxZoomOption).Value;
			}
			set
			{
				((Option<float>)(object)MaxZoomOption).SetValue(value);
			}
		}

		internal static bool LockPitch
		{
			get
			{
				return ((Option<bool>)(object)LockCameraPitchOption).Value;
			}
			set
			{
				((Option<bool>)(object)LockCameraPitchOption).SetValue(value);
			}
		}

		internal static float LockPitchAngle
		{
			get
			{
				return ((Option<float>)(object)LockCameraPitchAngleOption).Value * ((float)Math.PI / 180f);
			}
			set
			{
				((Option<float>)(object)LockCameraPitchAngleOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
			}
		}

		internal static float MinPitch
		{
			get
			{
				return ((Option<float>)(object)MinPitchOption).Value * ((float)Math.PI / 180f);
			}
			set
			{
				((Option<float>)(object)MinPitchOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
			}
		}

		internal static float MaxPitch
		{
			get
			{
				return ((Option<float>)(object)MaxPitchOption).Value * ((float)Math.PI / 180f);
			}
			set
			{
				((Option<float>)(object)MaxPitchOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
			}
		}

		internal static bool OverTheShoulder
		{
			get
			{
				return ((Option<bool>)(object)OverTheShoulderOption).Value;
			}
			set
			{
				((Option<bool>)(object)OverTheShoulderOption).SetValue(value);
			}
		}

		internal static float OverTheShoulderX
		{
			get
			{
				return ((Option<float>)(object)OverTheShoulderXOption).Value;
			}
			set
			{
				((Option<float>)(object)OverTheShoulderXOption).SetValue(value);
			}
		}

		internal static float OverTheShoulderY
		{
			get
			{
				return ((Option<float>)(object)OverTheShoulderYOption).Value;
			}
			set
			{
				((Option<float>)(object)OverTheShoulderYOption).SetValue(value);
			}
		}

		internal static void Init()
		{
			SetupOptions();
			SetupKeybinds();
		}

		internal static void AddEnabledListener(OnChange<bool> action)
		{
			((Option<bool>)(object)EnabledOption).AddListener(action);
		}

		internal static void AddFieldOfViewListener(OnChange<float> action)
		{
			((Option<float>)(object)FieldOfViewOption).AddListener(action);
		}

		internal static void AddHideUIListener(KeyEvent action)
		{
			HideUIKeybind.AddKeyDownListener(action);
		}

		private static void SetupOptions()
		{
			OptionCategory val = OptionsManager.AddCategory("Modern Camera");
			EnabledOption = val.AddToggle("moderncamera.enabled", "Enabled", true);
			FirstPersonEnabledOption = val.AddToggle("moderncamera.firstperson", "Enable First Person", true);
			DefaultBuildModeOption = val.AddToggle("moderncamera.defaultbuildmode", "Use Default Build Mode Camera", true);
			AlwaysShowCrosshairOption = val.AddToggle("moderncamera.alwaysshowcrosshair", "Always show Crosshair", false);
			ActionModeCrosshairOption = val.AddToggle("moderncamera.actionmodecrosshair", "Show Crosshair in Action Mode", false);
			FieldOfViewOption = val.AddSlider("moderncamera.fieldofview", "Field of View", 50f, 90f, 60f, 0, 0f);
			val.AddDivider("Third Person Aiming");
			CameraAimModeOption = val.AddDropdown("moderncamera.aimmode", "Aim Mode", 0, Enum.GetNames(typeof(CameraAimMode)));
			AimOffsetXOption = val.AddSlider("moderncamera.aimoffsetx", "Screen X% Offset ", -25f, 25f, 0f, 0, 0f);
			AimOffsetYOption = val.AddSlider("moderncamera.aimoffsety", "Screen Y% Offset", -25f, 25f, 0f, 0, 0f);
			val.AddDivider("Third Person Zoom");
			MinZoomOption = val.AddSlider("moderncamera.minzoom", "Min Zoom", 1f, 18f, 2f, 0, 0f);
			MaxZoomOption = val.AddSlider("moderncamera.maxzoom", "Max Zoom", 3f, 20f, 18f, 0, 0f);
			LockCameraZoomOption = val.AddToggle("moderncamera.lockzoom", "Lock Camera Zoom", false);
			LockCameraZoomDistanceOption = val.AddSlider("moderncamera.lockzoomdistance", "Locked Camera Zoom Distance", 6f, 20f, 15f, 0, 0f);
			val.AddDivider("Third Person Pitch");
			MinPitchOption = val.AddSlider("moderncamera.minpitch", "Min Pitch", 0f, 90f, 9f, 0, 0f);
			MaxPitchOption = val.AddSlider("moderncamera.maxpitch", "Max Pitch", 0f, 90f, 90f, 0, 0f);
			LockCameraPitchOption = val.AddToggle("moderncamera.lockpitch", "Lock Camera Pitch", false);
			LockCameraPitchAngleOption = val.AddSlider("moderncamera.lockpitchangle", "Locked Camera Pitch Angle", 0f, 90f, 60f, 0, 0f);
			val.AddDivider("Over the Shoulder");
			OverTheShoulderOption = val.AddToggle("moderncamera.overtheshoulder", "Use Over the Shoulder Offset", false);
			OverTheShoulderXOption = val.AddSlider("moderncamera.overtheshoulderx", "X Offset", 0.5f, 4f, 1f, 0, 0f);
			OverTheShoulderYOption = val.AddSlider("moderncamera.overtheshouldery", "Y Offset", 1f, 8f, 1f, 0, 0f);
			((Option<float>)(object)MinZoomOption).AddListener((OnChange<float>)delegate(float value)
			{
				if (value + ZoomOffset > MaxZoom && value + ZoomOffset < MaxZoomOption.MaxValue)
				{
					((Option<float>)(object)MaxZoomOption).SetValue(value + ZoomOffset);
				}
				else if (value + ZoomOffset > MaxZoomOption.MaxValue)
				{
					((Option<float>)(object)MinZoomOption).SetValue(MaxZoomOption.MaxValue - ZoomOffset);
				}
			});
			((Option<float>)(object)MaxZoomOption).AddListener((OnChange<float>)delegate(float value)
			{
				if (value - ZoomOffset < MinZoom && value - ZoomOffset > MinZoomOption.MinValue)
				{
					((Option<float>)(object)MinZoomOption).SetValue(value - ZoomOffset);
				}
				else if (value - ZoomOffset < MinZoomOption.MinValue)
				{
					((Option<float>)(object)MaxZoomOption).SetValue(MinZoomOption.MinValue + ZoomOffset);
				}
			});
			((Option<float>)(object)MinPitchOption).AddListener((OnChange<float>)delegate(float value)
			{
				if (value > ((Option<float>)(object)MaxPitchOption).Value && value < MaxPitchOption.MaxValue)
				{
					((Option<float>)(object)MaxPitchOption).SetValue(value);
				}
				else if (value > MaxPitchOption.MaxValue)
				{
					((Option<float>)(object)MinPitchOption).SetValue(MaxPitchOption.MaxValue);
				}
			});
			((Option<float>)(object)MaxPitchOption).AddListener((OnChange<float>)delegate(float value)
			{
				if (value < ((Option<float>)(object)MinPitchOption).Value && value > MinPitchOption.MinValue)
				{
					((Option<float>)(object)MinPitchOption).SetValue(value);
				}
				else if (value < MinPitchOption.MinValue)
				{
					((Option<float>)(object)MaxPitchOption).SetValue(MinPitchOption.MinValue);
				}
			});
		}

		private static void SetupKeybinds()
		{
			//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_0046: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			KeybindingCategory val = KeybindingsManager.AddCategory("Modern Camera");
			EnabledKeybind = val.AddKeyBinding("moderncamera.enabled", "Enabled", (string)null);
			Keybinding enabledKeybind = EnabledKeybind;
			object obj = <>c.<>9__94_0;
			if (obj == null)
			{
				KeyEvent val2 = delegate
				{
					((Option<bool>)(object)EnabledOption).SetValue(!Enabled);
				};
				<>c.<>9__94_0 = val2;
				obj = (object)val2;
			}
			enabledKeybind.AddKeyDownListener((KeyEvent)obj);
			ActionModeKeybind = val.AddKeyBinding("moderncamera.actionmode", "Action Mode", (string)null);
			Keybinding actionModeKeybind = ActionModeKeybind;
			object obj2 = <>c.<>9__94_1;
			if (obj2 == null)
			{
				KeyEvent val3 = delegate
				{
					if (Enabled && !ModernCameraState.IsFirstPerson)
					{
						ModernCameraState.IsMouseLocked = !ModernCameraState.IsMouseLocked;
						ModernCameraState.IsActionMode = !ModernCameraState.IsActionMode;
					}
				};
				<>c.<>9__94_1 = val3;
				obj2 = (object)val3;
			}
			actionModeKeybind.AddKeyDownListener((KeyEvent)obj2);
			HideUIKeybind = val.AddKeyBinding("moderncamera.hideui", "Hide UI", (string)null);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "VRising.ModernCamera";

		public const string PLUGIN_NAME = "ModernCamera";

		public const string PLUGIN_VERSION = "1.5.6";
	}
}
namespace ModernCamera.Utils
{
	internal static class Mouse
	{
		[DllImport("user32.dll")]
		private static extern bool SetCursorPos(int X, int Y);

		[DllImport("user32.dll")]
		private static extern bool GetCursorPos(out POINT point);

		[DllImport("user32.dll")]
		private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

		internal static bool SetCursorPosition(POINT point)
		{
			return SetCursorPos(point.X, point.Y);
		}

		internal static bool SetCursorPosition(int x, int y)
		{
			POINT pOINT = Window.ClientToScreen(x, y);
			return SetCursorPos(pOINT.X, pOINT.Y);
		}

		internal static void CenterCursorPosition()
		{
			RECT clientRect = Window.GetClientRect();
			SetCursorPosition((clientRect.Right - clientRect.Left) / 2, (clientRect.Bottom - clientRect.Top) / 2);
		}

		internal static POINT GetCursorPosition()
		{
			GetCursorPos(out var point);
			return point;
		}

		internal static void Click(MouseEvent mouseEvent)
		{
			Click(mouseEvent, GetCursorPosition());
		}

		internal static void Click(MouseEvent mouseEvent, POINT point)
		{
			mouse_event((int)mouseEvent, point.X, point.Y, 0, 0);
		}

		internal static void Click(MouseEvent mouseEvent, int x, int y)
		{
			mouse_event((int)mouseEvent, x, y, 0, 0);
		}
	}
	internal static class Window
	{
		internal static IntPtr Handle;

		[DllImport("user32.dll", CharSet = CharSet.Auto)]
		private static extern IntPtr FindWindow(string strClassName, string strWindowName);

		[DllImport("user32.dll")]
		private static extern bool GetWindowRect(IntPtr hwnd, ref RECT rectangle);

		[DllImport("user32.dll")]
		private static extern bool GetClientRect(IntPtr hwnd, ref RECT rectangle);

		[DllImport("user32.dll")]
		private static extern bool ClientToScreen(IntPtr hwnd, ref POINT point);

		[DllImport("user32.dll")]
		private static extern bool ScreenToClient(IntPtr hwnd, ref POINT point);

		static Window()
		{
			Handle = GetWindow("VRising");
		}

		public static IntPtr GetWindow(string title)
		{
			return FindWindow(null, title);
		}

		public static RECT GetWindowRect()
		{
			RECT rectangle = default(RECT);
			GetWindowRect(Handle, ref rectangle);
			return rectangle;
		}

		public static RECT GetClientRect()
		{
			RECT rectangle = default(RECT);
			GetClientRect(Handle, ref rectangle);
			return rectangle;
		}

		public static POINT ClientToScreen(int x, int y)
		{
			POINT point = new POINT(x, y);
			ClientToScreen(Handle, ref point);
			return point;
		}

		public static POINT ClientToScreen(POINT point)
		{
			return ClientToScreen(point.X, point.Y);
		}

		public static POINT ScreenToClient(int x, int y)
		{
			POINT point = new POINT(x, y);
			ClientToScreen(Handle, ref point);
			return point;
		}

		public static POINT ScreenToClient(POINT point)
		{
			return ScreenToClient(point.X, point.Y);
		}
	}
}
namespace ModernCamera.Structs
{
	internal struct POINT
	{
		internal int X;

		internal int Y;

		internal POINT(int X, int Y)
		{
			this.X = X;
			this.Y = Y;
		}
	}
	internal struct RECT
	{
		internal int Left;

		internal int Top;

		internal int Right;

		internal int Bottom;

		internal RECT(int Left, int Top, int Right, int Bottom)
		{
			this.Left = Left;
			this.Top = Top;
			this.Right = Right;
			this.Bottom = Bottom;
		}
	}
}
namespace ModernCamera.Patches
{
	[HarmonyPatch]
	internal static class ActionWheelSystem_Patch
	{
		private static bool WheelVisible;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ActionWheelSystem), "OnUpdate")]
		private static void OnUpdate(ActionWheelSystem __instance)
		{
			if (!WheelVisible && (__instance._CurrentActiveWheel.IsVisible() || __instance._EmotesWheel.IsVisible()))
			{
				ModernCameraState.IsMenuOpen = true;
				WheelVisible = true;
			}
			else if (WheelVisible && !__instance._CurrentActiveWheel.IsVisible() && !__instance._EmotesWheel.IsVisible())
			{
				ModernCameraState.IsMenuOpen = false;
				WheelVisible = false;
			}
		}
	}
	[HarmonyPatch]
	internal class EscapeMenuView_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EscapeMenuView), "OnEnable")]
		private static void OnEnable()
		{
			ModernCameraState.IsMenuOpen = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EscapeMenuView), "OnDestroy")]
		private static void OnDestroy()
		{
			ModernCameraState.IsMenuOpen = false;
		}
	}
	[HarmonyPatch]
	internal static class GameplayInputSystem_Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameplayInputSystem), "HandleInput")]
		private unsafe static void HandleInputPrefix(ref InputState inputState)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			ModernCameraState.ValidGameplayInputState = true;
			ModernCameraState.GameplayInputState = inputState;
			if (Settings.Enabled && ModernCameraState.IsMouseLocked && !ModernCameraState.IsMenuOpen && !((InputState)(ref inputState)).IsInputPressed((ButtonInputAction)500))
			{
				ButtonInputAction val = (ButtonInputAction)500;
				inputState.InputsPressed.m_ListData->Add(ref val);
			}
		}
	}
	[HarmonyPatch]
	internal static class HUDElementComponent_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDElementComponent), "UpdateVisibility")]
		private static void UpdateVisibility(HUDElementComponent __instance)
		{
			if (!((Object)((Component)__instance).gameObject).name.Equals("InteractorEntry(Clone)"))
			{
				return;
			}
			foreach (CanvasGroup componentsInChild in ((Component)__instance).GetComponentsInChildren<CanvasGroup>())
			{
				componentsInChild.alpha = 1f;
			}
		}
	}
	[HarmonyPatch]
	internal static class HUDMenu_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDMenu), "OnEnable")]
		private static void OnEnable()
		{
			ModernCameraState.IsMenuOpen = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDMenu), "OnDisable")]
		private static void OnDisable()
		{
			ModernCameraState.IsMenuOpen = false;
		}
	}
	[HarmonyPatch]
	internal static class OptionsMenu_Base_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(OptionsMenu_Base), "Start")]
		private static void Start()
		{
			ModernCameraState.IsMenuOpen = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(OptionsMenu_Base), "OnDestroy")]
		private static void OnDestroy()
		{
			ModernCameraState.IsMenuOpen = false;
		}
	}
	[HarmonyPatch]
	internal static class TopdownCameraSystem_Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(TopdownCameraSystem), "OnUpdate")]
		private static void OnUpdatePrefix(TopdownCameraSystem __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Enabled)
			{
				__instance._ZoomModifierSystem._ZoomModifiers.Clear();
			}
		}
	}
	[HarmonyPatch]
	internal class UIEntryPoint_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIEntryPoint), "Awake")]
		private static void AwakePostfix()
		{
			ModernCameraState.Reset();
		}
	}
}
namespace ModernCamera.Hooks
{
	internal static class TopdownCameraSystem_Hook
	{
		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate void HandleInput(IntPtr _this, ref InputState inputState);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate void UpdateCameraInputs(IntPtr _this, ref TopdownCameraState cameraState, ref TopdownCamera cameraData);

		private static HandleInput? HandleInputOriginal;

		private static INativeDetour? HandleInputDetour;

		private static UpdateCameraInputs? UpdateCameraInputsOriginal;

		private static INativeDetour? UpdateCameraInputsDetour;

		private static bool DefaultZoomSettingsSaved;

		private static bool UsingDefaultZoomSettings;

		private static ZoomSettings DefaultZoomSettings;

		private static ZoomSettings DefaultStandardZoomSettings;

		private static ZoomSettings DefaultBuildModeZoomSettings;

		internal static void CreateAndApply()
		{
			if (HandleInputDetour == null)
			{
				HandleInputDetour = DetourUtils.Create<HandleInput>(typeof(TopdownCameraSystem), "HandleInput", (HandleInput)HandleInputHook, ref HandleInputOriginal);
			}
			if (UpdateCameraInputsDetour == null)
			{
				UpdateCameraInputsDetour = DetourUtils.Create<UpdateCameraInputs>(typeof(TopdownCameraSystem), "UpdateCameraInputs", "OriginalLambdaBody", (UpdateCameraInputs)UpdateCameraInputsHook, ref UpdateCameraInputsOriginal);
			}
		}

		internal static void Dispose()
		{
			((IDisposable)UpdateCameraInputsDetour)?.Dispose();
			((IDisposable)HandleInputDetour)?.Dispose();
		}

		private static void HandleInputHook(IntPtr _this, ref InputState inputState)
		{
			if (Settings.Enabled)
			{
				ModernCameraState.CurrentCameraBehaviour?.HandleInput(ref inputState);
			}
			HandleInputOriginal(_this, ref inputState);
		}

		private static void UpdateCameraInputsHook(IntPtr _this, ref TopdownCameraState cameraState, ref TopdownCamera cameraData)
		{
			//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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Enabled)
			{
				if (!DefaultZoomSettingsSaved)
				{
					DefaultZoomSettings = cameraState.ZoomSettings;
					DefaultStandardZoomSettings = cameraData.StandardZoomSettings;
					DefaultBuildModeZoomSettings = cameraData.BuildModeZoomSettings;
					DefaultZoomSettingsSaved = true;
				}
				UsingDefaultZoomSettings = false;
				cameraState.ZoomSettings.MaxZoom = Settings.MaxZoom;
				cameraState.ZoomSettings.MinZoom = 0f;
				foreach (CameraBehaviour value in ModernCameraState.CameraBehaviours.Values)
				{
					if (value.ShouldActivate(ref cameraState))
					{
						ModernCameraState.CurrentCameraBehaviour?.Deactivate();
						value.Activate(ref cameraState);
						break;
					}
				}
				if (!ModernCameraState.CurrentCameraBehaviour.Active)
				{
					ModernCameraState.CurrentCameraBehaviour.Activate(ref cameraState);
				}
				ModernCameraState.CurrentCameraBehaviour.UpdateCameraInputs(ref cameraState, ref cameraData);
				cameraData.StandardZoomSettings = cameraState.ZoomSettings;
			}
			else if (DefaultZoomSettingsSaved && !UsingDefaultZoomSettings)
			{
				cameraState.ZoomSettings = DefaultZoomSettings;
				cameraData.StandardZoomSettings = DefaultStandardZoomSettings;
				cameraData.BuildModeZoomSettings = DefaultBuildModeZoomSettings;
				UsingDefaultZoomSettings = true;
			}
			UpdateCameraInputsOriginal(_this, ref cameraState, ref cameraData);
		}
	}
}
namespace ModernCamera.Enums
{
	internal enum BehaviourType
	{
		Default,
		FirstPerson,
		ThirdPerson
	}
	internal enum CameraAimMode
	{
		Default,
		Forward
	}
	[Flags]
	internal enum MouseEvent
	{
		Absolute = 0x8000,
		LeftDown = 2,
		LeftUp = 4,
		MiddleDown = 0x20,
		MiddleUp = 0x40,
		Move = 1,
		RightDown = 8,
		RightUp = 0x10
	}
}
namespace ModernCamera.Behaviours
{
	internal abstract class CameraBehaviour
	{
		internal BehaviourType BehaviourType;

		internal float DefaultMaxPitch;

		internal float DefaultMinPitch;

		internal bool Active;

		protected static float TargetZoom = Settings.MaxZoom / 2f;

		protected static ZoomSettings BuildModeZoomSettings;

		protected static bool IsBuildSettingsSet;

		internal virtual void Activate(ref TopdownCameraState state)
		{
			Active = true;
		}

		internal virtual void Deactivate()
		{
			TargetZoom = Settings.MaxZoom / 2f;
			Active = false;
		}

		internal virtual bool ShouldActivate(ref TopdownCameraState state)
		{
			return false;
		}

		internal unsafe virtual void HandleInput(ref InputState inputState)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (inputState.InputsPressed.IsCreated && ModernCameraState.IsMouseLocked && !ModernCameraState.IsMenuOpen && !((InputState)(ref inputState)).IsInputPressed((ButtonInputAction)500))
			{
				ButtonInputAction val = (ButtonInputAction)500;
				inputState.InputsPressed.m_ListData->Add(ref val);
			}
			float analogValue = ((InputState)(ref inputState)).GetAnalogValue((AnalogInputAction)16);
			if (analogValue != 0f && (!ModernCameraState.InBuildMode || !Settings.DefaultBuildMode))
			{
				float num = Mathf.Lerp(0.25f, 1.5f, Mathf.Max(0f, TargetZoom - Settings.MinZoom) / Settings.MaxZoom);
				float num2 = ((((InputState)(ref inputState)).GetAnalogValue((AnalogInputAction)16) > 0f) ? num : (0f - num));
				if ((TargetZoom > Settings.MinZoom && TargetZoom + num2 < Settings.MinZoom) || (ModernCameraState.IsFirstPerson && num2 > 0f))
				{
					TargetZoom = Settings.MinZoom;
				}
				else
				{
					TargetZoom = Mathf.Clamp(TargetZoom + num2, Settings.FirstPersonEnabled ? 0f : Settings.MinZoom, Settings.MaxZoom);
				}
				((InputState)(ref inputState)).SetAnalogValue((AnalogInputAction)16, 0f);
			}
			if (TargetZoom > Settings.MaxZoom)
			{
				TargetZoom = Settings.MaxZoom;
			}
		}

		internal virtual void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			ModernCameraState.InBuildMode = state.InBuildMode;
			if (!IsBuildSettingsSet)
			{
				BuildModeZoomSettings = data.BuildModeZoomSettings;
				IsBuildSettingsSet = true;
			}
			state.ZoomSettings.MaxPitch = DefaultMaxPitch;
			state.ZoomSettings.MinPitch = DefaultMinPitch;
			if (!state.InBuildMode || !Settings.DefaultBuildMode)
			{
				data.BuildModeZoomSettings.MaxPitch = DefaultMaxPitch;
				data.BuildModeZoomSettings.MinPitch = DefaultMinPitch;
				state.LastTarget.Zoom = TargetZoom;
				state.Target.Zoom = TargetZoom;
			}
			if (state.InBuildMode && Settings.DefaultBuildMode)
			{
				data.BuildModeZoomSettings = BuildModeZoomSettings;
				state.LastTarget.Zoom = data.BuildModeZoomDistance;
				state.Target.Zoom = data.BuildModeZoomDistance;
			}
		}
	}
	internal class FirstPersonCameraBehaviour : CameraBehaviour
	{
		internal FirstPersonCameraBehaviour()
		{
			BehaviourType = BehaviourType.FirstPerson;
			DefaultMaxPitch = 1.57f;
			DefaultMinPitch = -1.57f;
		}

		internal override void Activate(ref TopdownCameraState state)
		{
			base.Activate(ref state);
			ModernCameraState.IsMouseLocked = true;
			ModernCameraState.IsFirstPerson = true;
			ModernCameraState.CurrentBehaviourType = BehaviourType;
			state.PitchPercent = 0.51f;
			CameraBehaviour.TargetZoom = 0f;
		}

		internal override void Deactivate()
		{
			base.Deactivate();
			if (!ModernCameraState.IsActionMode)
			{
				ModernCameraState.IsMouseLocked = false;
			}
			ModernCameraState.IsFirstPerson = false;
		}

		internal override bool ShouldActivate(ref TopdownCameraState state)
		{
			return Settings.FirstPersonEnabled && ModernCameraState.CurrentBehaviourType != BehaviourType && CameraBehaviour.TargetZoom < Settings.MinZoom;
		}

		internal override void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
		{
			//IL_0034: 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)
			base.UpdateCameraInputs(ref state, ref data);
			float z = Settings.FirstPersonForwardOffset;
			float num = Settings.HeadHeightOffset;
			if (Settings.FirstPersonShapeshiftOffsets.ContainsKey(ModernCameraState.ShapeshiftName))
			{
				z = Settings.FirstPersonShapeshiftOffsets[ModernCameraState.ShapeshiftName].y;
				num = Settings.FirstPersonShapeshiftOffsets[ModernCameraState.ShapeshiftName].x;
			}
			state.LastTarget.NormalizedLookAtOffset.z = z;
			state.LastTarget.NormalizedLookAtOffset.y = (ModernCameraState.IsMounted ? (num + Settings.MountedOffset) : num);
		}
	}
	internal class ThirdPersonCameraBehaviour : CameraBehaviour
	{
		private float LastPitchPercent = float.PositiveInfinity;

		internal ThirdPersonCameraBehaviour()
		{
			BehaviourType = BehaviourType.ThirdPerson;
		}

		internal override void Activate(ref TopdownCameraState state)
		{
			base.Activate(ref state);
			if (ModernCameraState.CurrentBehaviourType == BehaviourType)
			{
				CameraBehaviour.TargetZoom = Settings.MaxZoom / 2f;
			}
			else
			{
				CameraBehaviour.TargetZoom = Settings.MinZoom;
			}
			ModernCameraState.CurrentBehaviourType = BehaviourType;
			state.PitchPercent = ((LastPitchPercent == float.PositiveInfinity) ? 0.5f : LastPitchPercent);
		}

		internal override bool ShouldActivate(ref TopdownCameraState state)
		{
			return ModernCameraState.CurrentBehaviourType != BehaviourType && CameraBehaviour.TargetZoom > 0f;
		}

		internal override void HandleInput(ref InputState inputState)
		{
			base.HandleInput(ref inputState);
			if (Settings.LockZoom)
			{
				CameraBehaviour.TargetZoom = Settings.LockZoomDistance;
			}
		}

		internal override void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
		{
			DefaultMaxPitch = Settings.MaxPitch;
			DefaultMinPitch = Settings.MinPitch;
			base.UpdateCameraInputs(ref state, ref data);
			state.LastTarget.NormalizedLookAtOffset.y = (ModernCameraState.IsMounted ? (Settings.HeadHeightOffset + Settings.MountedOffset) : Settings.HeadHeightOffset);
			if (Settings.OverTheShoulder && !ModernCameraState.IsShapeshifted && !ModernCameraState.IsMounted)
			{
				float num = Mathf.Max(0f, state.Current.Zoom - state.ZoomSettings.MinZoom) / state.ZoomSettings.MaxZoom;
				state.LastTarget.NormalizedLookAtOffset.x = Mathf.Lerp(Settings.OverTheShoulderX, 0f, num);
				state.LastTarget.NormalizedLookAtOffset.y = Mathf.Lerp(Settings.OverTheShoulderY, 0f, num);
			}
			if (Settings.LockPitch && (!state.InBuildMode || !Settings.DefaultBuildMode))
			{
				state.ZoomSettings.MaxPitch = Settings.LockPitchAngle;
				state.ZoomSettings.MinPitch = Settings.LockPitchAngle;
				data.BuildModeZoomSettings.MaxPitch = Settings.LockPitchAngle;
				data.BuildModeZoomSettings.MinPitch = Settings.LockPitchAngle;
			}
			LastPitchPercent = state.PitchPercent;
		}
	}
}

Silkworm.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using HarmonyLib;
using Iced.Intel;
using Il2CppInterop.Common;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using Silkworm.API;
using Silkworm.Core.KeyBinding;
using Silkworm.Core.Options;
using Silkworm.Utils;
using StunShared.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using Unity.Entities;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("iZastic")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Custom VRising library inspired by Wetstone")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+11dacfdb9e3992a57ee53f042cdb69eba63dc56c")]
[assembly: AssemblyProduct("Silkworm")]
[assembly: AssemblyTitle("Silkworm")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 Silkworm
{
	[BepInPlugin("iZastic.Silkworm", "Silkworm", "2.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Logger;

		private static Harmony harmony;

		public override void Load()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			harmony = new Harmony("iZastic.Silkworm");
			harmony.PatchAll();
			OptionsManager.Load();
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("iZastic.Silkworm");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("2.0.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			logger.LogInfo(val);
		}

		public override bool Unload()
		{
			OptionsManager.FullSave();
			return true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "iZastic.Silkworm";

		public const string PLUGIN_NAME = "Silkworm";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace Silkworm.Utils
{
	public static class DetourUtils
	{
		public static INativeDetour Create<T>(Type type, string innerTypeName, string methodName, T to, out T original) where T : Delegate
		{
			return Create(GetInnerType(type, innerTypeName), methodName, to, out original);
		}

		public static INativeDetour Create<T>(Type type, string methodName, T to, out T original) where T : Delegate
		{
			return Create(type.GetMethod(methodName, AccessTools.all), to, out original);
		}

		private static INativeDetour Create<T>(MethodInfo method, T to, out T original) where T : Delegate
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			IntPtr intPtr = Il2CppMethodResolver.ResolveFromMethodInfo(method);
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(15, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Detouring ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(method.DeclaringType.FullName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(method.Name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(intPtr.ToString("X"));
			}
			logger.LogDebug(val);
			return INativeDetour.CreateAndApply<T>(intPtr, to, ref original);
		}

		private static Type GetInnerType(Type type, string innerTypeName)
		{
			return type.GetNestedTypes().First((Type x) => x.Name.Contains(innerTypeName));
		}
	}
	public static class FileUtils
	{
		private static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
		{
			WriteIndented = true,
			IncludeFields = true
		};

		public static bool Exists(string filename)
		{
			return File.Exists(Path.Join(Paths.ConfigPath, "Silkworm", filename));
		}

		public static void WriteJson(string filename, object? data)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			try
			{
				string contents = JsonSerializer.Serialize(data, jsonSerializerOptions);
				Directory.CreateDirectory(Path.Join(Paths.ConfigPath, "Silkworm"));
				File.WriteAllText(Path.Join(Paths.ConfigPath, "Silkworm", filename), contents);
			}
			catch
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error saving ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(filename);
				}
				logger.LogWarning(val);
			}
		}

		public static T? ReadJson<T>(string filename)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			try
			{
				string json = File.ReadAllText(Path.Join(Paths.ConfigPath, "Silkworm", filename));
				return JsonSerializer.Deserialize<T>(json, jsonSerializerOptions);
			}
			catch
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(14, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error reading ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(filename);
				}
				logger.LogWarning(val);
				return default(T);
			}
		}
	}
	public static class HashUtils
	{
		private const uint FNVOffset32 = 2166136261u;

		private const uint FNVPrime32 = 16777619u;

		private static ulong FNVPrime64 = 1099511628211uL;

		private static ulong FNVOffset64 = 14695981039346656037uL;

		public static uint Hash32(string value)
		{
			uint num = 2166136261u;
			foreach (char c in value)
			{
				num = 16777619 * (num ^ c);
			}
			return num;
		}

		public static ulong Hash64(string value)
		{
			ulong num = FNVOffset64;
			foreach (char c in value)
			{
				num = FNVPrime64 * (num ^ c);
			}
			return num;
		}
	}
	public static class Il2CppMethodResolver
	{
		private static ulong ExtractTargetAddress(in Instruction instruction)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			OpKind op0Kind = ((Instruction)(ref instruction)).Op0Kind;
			if (1 == 0)
			{
			}
			ulong result = (((int)op0Kind == 4) ? ((Instruction)(ref instruction)).FarBranch16 : (((int)op0Kind != 5) ? ((Instruction)(ref instruction)).NearBranchTarget : ((Instruction)(ref instruction)).FarBranch32));
			if (1 == 0)
			{
			}
			return result;
		}

		private unsafe static IntPtr ResolveMethodPointer(IntPtr methodPointer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Invalid comparison between Unknown and I4
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			UnmanagedMemoryStream unmanagedMemoryStream = new UnmanagedMemoryStream((byte*)(void*)methodPointer, 1024L, 1024L, FileAccess.Read);
			StreamCodeReader val = new StreamCodeReader((Stream)unmanagedMemoryStream);
			Decoder val2 = Decoder.Create((IntPtr.Size == 8) ? 64 : 32, (CodeReader)(object)val, (DecoderOptions)0);
			val2.IP = (ulong)methodPointer.ToInt64();
			Instruction instruction = default(Instruction);
			bool flag = default(bool);
			while ((int)((Instruction)(ref instruction)).Mnemonic != 1620)
			{
				val2.Decode(ref instruction);
				if ((int)((Instruction)(ref instruction)).Mnemonic != 308 && (int)((Instruction)(ref instruction)).Mnemonic != 7)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(48, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Encountered mnemonic ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Mnemonic>(((Instruction)(ref instruction)).Mnemonic);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Treating as normal method");
					}
					logger.LogDebug(val3);
					return methodPointer;
				}
				if ((int)((Instruction)(ref instruction)).Mnemonic == 7 && ((Instruction)(ref instruction)).Immediate32 != 16)
				{
					ManualLogSource logger2 = Plugin.Logger;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(56, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Encountered non-unboxing add ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(((Instruction)(ref instruction)).Immediate32);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Treating as normal method");
					}
					logger2.LogDebug(val3);
					return methodPointer;
				}
				if ((int)((Instruction)(ref instruction)).Mnemonic == 308)
				{
					return new IntPtr((long)ExtractTargetAddress(in instruction));
				}
			}
			return methodPointer;
		}

		public static IntPtr ResolveFromMethodInfo(INativeMethodInfoStruct methodInfo)
		{
			return ResolveMethodPointer(methodInfo.MethodPointer);
		}

		public unsafe static IntPtr ResolveFromMethodInfo(MethodInfo method)
		{
			FieldInfo il2CppMethodInfoPointerFieldForGeneratedMethod = Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod((MethodBase)method);
			if (il2CppMethodInfoPointerFieldForGeneratedMethod == null)
			{
				throw new Exception($"Couldn't obtain method info for {method}");
			}
			INativeMethodInfoStruct val = UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)(IntPtr)(il2CppMethodInfoPointerFieldForGeneratedMethod.GetValue(null) ?? ((object)IntPtr.Zero)));
			if (val == null)
			{
				throw new Exception($"Method info for {method} is invalid");
			}
			return ResolveFromMethodInfo(val);
		}
	}
	public static class LogUtils
	{
		private static ManualLogSource Log;

		static LogUtils()
		{
			Log = Logger.CreateLogSource("Silkworm");
		}

		public static void Init(ManualLogSource log)
		{
			Log = log;
		}

		public static bool IsLogLevel(LogLevel level)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Enum)Logger.ListenedLogLevels).HasFlag((Enum)(object)level);
		}

		public static void LogFatal(object data)
		{
			Log.LogFatal(data);
		}

		public static void LogError(object data)
		{
			Log.LogError(data);
		}

		public static void LogWarning(object data)
		{
			Log.LogWarning(data);
		}

		public static void LogMessage(object data)
		{
			Log.LogMessage(data);
		}

		public static void LogInfo(object data)
		{
			Log.LogInfo(data);
		}

		public static void LogDebug(object data)
		{
			Log.LogDebug(data);
		}

		public static void LogDebugFatal(object data)
		{
			if (IsLogLevel((LogLevel)32))
			{
				LogFatal(data);
			}
		}

		public static void LogDebugError(object data)
		{
			if (IsLogLevel((LogLevel)32))
			{
				LogDebug(data);
			}
		}

		public static void LogDebugWarning(object data)
		{
			if (IsLogLevel((LogLevel)32))
			{
				LogWarning(data);
			}
		}
	}
	public static class WorldUtils
	{
		private static readonly string _ClientWorldName = "Client_0";

		private static readonly string _ServerWorldName = "Server";

		private static World? _ClientWorld;

		private static World? _ServerWorld;

		public static bool ClientWorldExists => WorldExists(_ClientWorldName);

		public static bool ServerWorldExists => WorldExists(_ServerWorldName);

		public static World DefaultWorld => World.DefaultGameObjectInjectionWorld;

		public static World ClientWorld
		{
			get
			{
				if (_ClientWorld == null || !_ClientWorld.IsCreated)
				{
					_ClientWorld = FindWorld(_ClientWorldName) ?? throw new Exception("Client world does not exist yet");
				}
				return _ClientWorld;
			}
		}

		public static World ServerWorld
		{
			get
			{
				if (_ServerWorld == null || !_ServerWorld.IsCreated)
				{
					_ServerWorld = FindWorld(_ServerWorldName) ?? throw new Exception("Server world does not exist yet");
				}
				return _ServerWorld;
			}
		}

		public static bool WorldExists(string name)
		{
			Enumerator<World> enumerator = World.All.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return true;
				}
			}
			return false;
		}

		public static World? FindWorld(string name)
		{
			Enumerator<World> enumerator = World.All.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return current;
				}
			}
			return null;
		}
	}
}
namespace Silkworm.Hooks
{
	[HarmonyPatch]
	internal static class InputActionSystem_Hook
	{
		private static InputActionMap MC_InputActionMap;

		private static InputAction ActionModeInputAction;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(InputActionSystem), "OnCreate")]
		private static void OnCreate(InputActionSystem __instance)
		{
			__instance._LoadedInputActions.Disable();
			foreach (KeybindingCategory value in KeybindingsManager.Categories.Values)
			{
				InputActionSetupExtensions.AddActionMap(__instance._LoadedInputActions, value.InputActionMap);
			}
			__instance._LoadedInputActions.Enable();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InputActionSystem), "OnUpdate")]
		private static void OnUpdate()
		{
			foreach (KeybindingCategory value in KeybindingsManager.Categories.Values)
			{
				foreach (Keybinding value2 in value.KeybindingMap.Values)
				{
					if (value2.IsDown)
					{
						value2.OnKeyDown();
					}
					if (value2.IsPressed)
					{
						value2.OnKeyPressed();
					}
					if (value2.IsUp)
					{
						value2.OnKeyUp();
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class Localization_Hook
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Localization), "Get", new Type[]
		{
			typeof(AssetGuid),
			typeof(bool)
		})]
		private static bool Get(AssetGuid guid, ref string __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!LocalizationManager.HasKey(guid))
			{
				return true;
			}
			__result = LocalizationManager.GetKey(guid);
			return false;
		}
	}
	[HarmonyPatch]
	internal static class OptionsPanel_Interface_Hook
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(OptionsPanel_Interface), "Start")]
		private static void Start(OptionsPanel_Interface __instance)
		{
			//IL_0022: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			foreach (OptionCategory value in OptionsManager.Categories.Values)
			{
				__instance.AddHeader(value.LocalizationKey);
				foreach (string option4 in value.Options)
				{
					SliderOption option2;
					DropdownOption option3;
					string text;
					if (value.TryGetToggle(option4, out var option))
					{
						SettingsEntry_Checkbox val = UIHelper.InstantiatePrefabUnderAnchor<SettingsEntry_Checkbox>(__instance.CheckboxPrefab, __instance.ContentNode);
						val.Initialize(option.NameKey, option.DescKey, option.DefaultValue, option.Value, OnChange(option), false, false, false);
					}
					else if (value.TryGetSlider(option4, out option2))
					{
						SettingsEntry_Slider val2 = UIHelper.InstantiatePrefabUnderAnchor<SettingsEntry_Slider>(__instance.SliderPrefab, __instance.ContentNode);
						val2.Initialize(option2.NameKey, option2.DescKey, option2.MinValue, option2.MaxValue, option2.DefaultValue, option2.Value, option2.Decimals, option2.Decimals == 0, OnChange(option2), false, false, false, option2.StepValue, (Il2CppStructArray<float>)null);
					}
					else if (value.TryGetDropdown(option4, out option3))
					{
						SettingsEntry_Dropdown val3 = UIHelper.InstantiatePrefabUnderAnchor<SettingsEntry_Dropdown>(__instance.DropdownPrefab, __instance.ContentNode);
						val3.Initialize(option3.NameKey, option3.DescKey, option3.Values, option3.DefaultValue, option3.Value, OnChange(option3), false, false, false);
					}
					else if (value.TryGetDivider(option4, out text))
					{
						GameObject val4 = CreateDivider((Transform)(object)__instance.ContentNode, text);
					}
				}
			}
		}

		private static GameObject CreateDivider(Transform parent, string text)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0023: 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_0060: 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_008c: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			Il2CppArrayBase<TextMeshProUGUI> componentsInChildren = ((Component)parent).GetComponentsInChildren<TextMeshProUGUI>();
			GameObject val = new GameObject("Divider");
			RectTransform val2 = val.AddComponent<RectTransform>();
			((Transform)val2).SetParent(parent);
			((Transform)val2).localScale = Vector3.one;
			val2.sizeDelta = new Vector2(0f, 28f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.12f, 0.152f, 0.2f, 0.15f);
			LayoutElement val4 = val.AddComponent<LayoutElement>();
			val4.preferredHeight = 28f;
			GameObject val5 = new GameObject("Text");
			RectTransform val6 = val5.AddComponent<RectTransform>();
			((Transform)val6).SetParent(val.transform);
			((Transform)val6).localScale = Vector3.one;
			TextMeshProUGUI val7 = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val7).fontStyle = (FontStyles)32;
			((TMP_Text)val7).font = ((TMP_Text)componentsInChildren[0]).font;
			((TMP_Text)val7).fontSize = 20f;
			if (text != null)
			{
				((TMP_Text)val7).SetText(text, true);
			}
			return val;
		}

		private static Action<T> OnChange<T>(Option<T> option)
		{
			return Action<T>.op_Implicit((Action<T>)delegate(T value)
			{
				option.SetValue(value);
				OptionsManager.FullSave();
			});
		}
	}
	[HarmonyPatch]
	internal class Options_ControlsPanel_Hook
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Options_ControlsPanel), "Start")]
		private static void Start(Options_ControlsPanel __instance)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeybindingCategory value in KeybindingsManager.Categories.Values)
			{
				SettingsEntry_Label val = UIHelper.InstantiatePrefabUnderAnchor<SettingsEntry_Label>(__instance.HeaderPrefab, __instance.ContentNode);
				((SettingsEntryBase)val).HeaderText.Set(value.NameKey);
				foreach (Keybinding value2 in value.KeybindingMap.Values)
				{
				}
			}
		}
	}
}
namespace Silkworm.Core.Options
{
	public class DropdownOption : Option<int>
	{
		internal List<string> Values;

		public DropdownOption(string name, string description, int defaultValue, string[] values)
			: base(name, description, defaultValue)
		{
			Values = new List<string>();
			foreach (string text in values)
			{
				Values.Add(text);
			}
		}

		public T GetEnumValue<T>()
		{
			return (T)Enum.Parse(typeof(T), Values[Value]);
		}
	}
	public delegate void OnChange<T>(T value);
	public class Option<T>
	{
		internal readonly LocalizationKey NameKey;

		internal readonly Nullable_Unboxed<LocalizationKey> DescKey;

		public string Name { get; internal set; }

		public string Description { get; internal set; }

		public virtual T Value { get; internal set; }

		public T DefaultValue { get; internal set; }

		internal event OnChange<T> OnChange = delegate
		{
		};

		public Option(string name, string description, T defaultValue)
		{
			//IL_004f: 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_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)
			Name = name;
			Description = description;
			DefaultValue = defaultValue;
			Value = defaultValue;
			NameKey = LocalizationManager.CreateKey(name);
			DescKey = LocalizationManager.CreateNullableKey(description);
		}

		public virtual void SetValue(T value)
		{
			Value = value;
			this.OnChange(Value);
		}

		public void AddListener(OnChange<T> action)
		{
			OnChange += action;
		}
	}
	public class OptionCategory
	{
		public Dictionary<string, bool> Toggles = new Dictionary<string, bool>();

		public Dictionary<string, float> Sliders = new Dictionary<string, float>();

		public Dictionary<string, string> Dropdowns = new Dictionary<string, string>();

		internal readonly LocalizationKey LocalizationKey;

		internal List<string> Options = new List<string>();

		internal Dictionary<string, ToggleOption> ToggleOptions = new Dictionary<string, ToggleOption>();

		internal Dictionary<string, SliderOption> SliderOptions = new Dictionary<string, SliderOption>();

		internal Dictionary<string, DropdownOption> DropdownOptions = new Dictionary<string, DropdownOption>();

		internal Dictionary<string, string> Dividers = new Dictionary<string, string>();

		public string Name { get; internal set; }

		public OptionCategory(string name)
		{
			//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)
			Name = name;
			LocalizationKey = LocalizationManager.CreateKey(name);
		}

		public ToggleOption AddToggle(string name, string description, bool defaultValue)
		{
			ToggleOption toggleOption = new ToggleOption(name, description, defaultValue);
			if (Toggles.ContainsKey(name))
			{
				toggleOption.Value = Toggles[name];
			}
			ToggleOptions.Add(name, toggleOption);
			Options.Add(toggleOption.Name);
			return toggleOption;
		}

		public SliderOption AddSlider(string name, string description, float minValue, float maxValue, float defaultValue, int decimals = 0, float stepValue = 0f)
		{
			SliderOption sliderOption = new SliderOption(name, description, minValue, maxValue, defaultValue, decimals);
			if (Sliders.ContainsKey(name))
			{
				sliderOption.Value = Mathf.Clamp(Sliders[name], minValue, maxValue);
			}
			SliderOptions.Add(name, sliderOption);
			Options.Add(sliderOption.Name);
			return sliderOption;
		}

		public DropdownOption AddDropdown(string name, string description, int defaultValue, string[] values)
		{
			DropdownOption dropdownOption = new DropdownOption(name, description, defaultValue, values);
			if (Dropdowns.ContainsKey(name))
			{
				dropdownOption.Value = Mathf.Max(0, Array.IndexOf(values, Dropdowns[name]));
			}
			DropdownOptions.Add(name, dropdownOption);
			Options.Add(dropdownOption.Name);
			return dropdownOption;
		}

		public void AddDivider()
		{
			AddDivider(null);
		}

		public void AddDivider(string name)
		{
			string text = Guid.NewGuid().ToString();
			Dividers.Add(text, name);
			Options.Add(text);
		}

		public ToggleOption GetToggle(string id)
		{
			return ToggleOptions.GetValueOrDefault(id);
		}

		public SliderOption GetSlider(string id)
		{
			return SliderOptions.GetValueOrDefault(id);
		}

		public DropdownOption GetDropdown(string id)
		{
			return DropdownOptions.GetValueOrDefault(id);
		}

		public bool HasToggle(string id)
		{
			return ToggleOptions.ContainsKey(id);
		}

		public bool HasSlider(string id)
		{
			return SliderOptions.ContainsKey(id);
		}

		public bool HasDropdown(string id)
		{
			return DropdownOptions.ContainsKey(id);
		}

		public bool TryGetToggle(string id, out ToggleOption option)
		{
			if (!ToggleOptions.ContainsKey(id))
			{
				option = null;
				return false;
			}
			option = ToggleOptions[id];
			return true;
		}

		public bool TryGetSlider(string id, out SliderOption option)
		{
			if (!SliderOptions.ContainsKey(id))
			{
				option = null;
				return false;
			}
			option = SliderOptions[id];
			return true;
		}

		public bool TryGetDropdown(string id, out DropdownOption option)
		{
			if (!DropdownOptions.ContainsKey(id))
			{
				option = null;
				return false;
			}
			option = DropdownOptions[id];
			return true;
		}

		public bool TryGetDivider(string id, out string text)
		{
			if (!Dividers.ContainsKey(id))
			{
				text = null;
				return false;
			}
			text = Dividers[id];
			return true;
		}
	}
	public class SliderOption : Option<float>
	{
		public float MinValue { get; internal set; }

		public float MaxValue { get; internal set; }

		public override float Value
		{
			get
			{
				return Mathf.Clamp(base.Value, MinValue, MaxValue);
			}
			internal set
			{
				base.Value = value;
			}
		}

		public int Decimals { get; internal set; }

		public float StepValue { get; internal set; }

		public SliderOption(string text, string description, float minValue, float maxValue, float defaultvalue, int decimals = 0, float stepValue = 0f)
			: base(text, description, defaultvalue)
		{
			MinValue = minValue;
			MaxValue = maxValue;
			Value = Mathf.Clamp(Value, MinValue, MaxValue);
			Decimals = decimals;
			StepValue = stepValue;
		}

		public override void SetValue(float value)
		{
			base.SetValue(value);
			Value = Mathf.Clamp(Value, MinValue, MaxValue);
		}
	}
	public class ToggleOption : Option<bool>
	{
		public ToggleOption(string name, string description, bool defaultvalue)
			: base(name, description, defaultvalue)
		{
		}
	}
}
namespace Silkworm.Core.KeyBinding
{
	public delegate void KeyEvent();
	public class Keybinding
	{
		public struct Data
		{
			public string Name;

			public string PrimaryDefault;

			public string PrimaryOverride;

			public string SecondaryDefault;

			public string SecondaryOverride;
		}

		internal ButtonInputAction InputFlag;

		internal LocalizationKey NameKey;

		internal InputAction InputAction;

		public Guid Id => InputAction.id;

		public string Name
		{
			get
			{
				return InputAction.name;
			}
			internal set
			{
				InputActionSetupExtensions.Rename(InputAction, value);
			}
		}

		public string Primary => InputAction.bindings[0].effectivePath;

		public string Secondary => InputAction.bindings[1].effectivePath;

		public bool IsPressed => InputAction.IsPressed();

		public bool IsDown => InputAction.WasPressedThisFrame();

		public bool IsUp => InputAction.WasReleasedThisFrame();

		internal string DefaultPrimary { get; set; }

		internal string DefaultSecondary { get; set; }

		internal event KeyEvent KeyPressed = delegate
		{
		};

		internal event KeyEvent KeyDown = delegate
		{
		};

		internal event KeyEvent KeyUp = delegate
		{
		};

		internal Keybinding(InputAction inputAction, string defaultPrimary = null, string defaultSecondary = null)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			InputAction = inputAction;
			NameKey = LocalizationManager.CreateKey(InputAction.name);
			InputActionSetupExtensions.AddBinding(InputAction, (defaultPrimary == null) ? "" : defaultPrimary, (string)null, (string)null, (string)null);
			DefaultPrimary = ((defaultPrimary == null) ? "" : defaultPrimary);
			InputActionSetupExtensions.AddBinding(InputAction, (defaultSecondary == null) ? "" : defaultSecondary, (string)null, (string)null, (string)null);
			DefaultSecondary = ((defaultSecondary == null) ? "" : defaultSecondary);
			ulong num = HashUtils.Hash64(InputAction.actionMap.name + "." + InputAction.name);
			do
			{
				InputFlag = (ButtonInputAction)num;
			}
			while (Enum.IsDefined(typeof(ButtonInputAction), (object)(ButtonInputAction)(num--)));
		}

		public void AddKeyPressedListener(KeyEvent action)
		{
			KeyPressed += action;
		}

		public void AddKeyDownListener(KeyEvent action)
		{
			KeyDown += action;
		}

		public void AddKeyUpListener(KeyEvent action)
		{
			KeyUp += action;
		}

		public void Override(bool primary, string path)
		{
			InputActionRebindingExtensions.ApplyBindingOverride(InputAction, (!primary) ? 1 : 0, path);
		}

		internal void OnKeyPressed()
		{
			this.KeyPressed();
		}

		internal void OnKeyDown()
		{
			this.KeyDown();
		}

		internal void OnKeyUp()
		{
			this.KeyUp();
		}

		internal Data GetData()
		{
			Data result = default(Data);
			result.Name = Name;
			result.PrimaryDefault = DefaultPrimary;
			result.PrimaryOverride = (InputAction.bindings[0].hasOverrides ? Primary : null);
			result.SecondaryDefault = DefaultSecondary;
			result.SecondaryOverride = (InputAction.bindings[1].hasOverrides ? Secondary : null);
			return result;
		}
	}
	public class KeybindingCategory
	{
		public Dictionary<string, Keybinding.Data> Overrides = new Dictionary<string, Keybinding.Data>();

		internal LocalizationKey NameKey;

		internal InputActionMap InputActionMap;

		internal Dictionary<string, Keybinding> KeybindingMap = new Dictionary<string, Keybinding>();

		internal Dictionary<ButtonInputAction, string> KeybindingFlags = new Dictionary<ButtonInputAction, string>();

		public string Name { get; internal set; }

		public KeybindingCategory(string name)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0049: 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)
			Name = name;
			InputActionMap = new InputActionMap(Name);
			NameKey = LocalizationManager.CreateKey(Name);
		}

		public Keybinding AddKeyBinding(string name, string defaultPrimary = null, string defaultSecondary = null)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Keybinding keybinding = new Keybinding(InputActionSetupExtensions.AddAction(InputActionMap, name, (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null), defaultPrimary, defaultSecondary);
			if (Overrides.TryGetValue(name, out var value))
			{
				if (!string.IsNullOrEmpty(value.PrimaryOverride))
				{
					keybinding.Override(primary: true, value.PrimaryOverride);
				}
				if (!string.IsNullOrEmpty(value.SecondaryOverride))
				{
					keybinding.Override(primary: false, value.SecondaryOverride);
				}
			}
			KeybindingMap.Add(name, keybinding);
			KeybindingFlags.Add(keybinding.InputFlag, name);
			return keybinding;
		}

		public Keybinding GetKeybinding(string id)
		{
			return KeybindingMap.GetValueOrDefault(id);
		}

		public Keybinding GetKeybinding(ButtonInputAction flag)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			string valueOrDefault = KeybindingFlags.GetValueOrDefault(flag);
			return (valueOrDefault == null) ? null : GetKeybinding(valueOrDefault);
		}

		public bool HasKeybinding(string id)
		{
			return KeybindingMap.ContainsKey(id);
		}

		public bool HasKeybinding(ButtonInputAction flag)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			string valueOrDefault = KeybindingFlags.GetValueOrDefault(flag);
			return valueOrDefault != null && HasKeybinding(valueOrDefault);
		}
	}
}
namespace Silkworm.API
{
	public static class KeybindingsManager
	{
		internal static Dictionary<string, KeybindingCategory> Categories = new Dictionary<string, KeybindingCategory>();

		internal static string ActionsFilename = "actions.json";

		public static KeybindingCategory AddCategory(string name)
		{
			if (!Categories.ContainsKey(name))
			{
				KeybindingCategory value = new KeybindingCategory(name);
				Categories.Add(name, value);
			}
			return Categories[name];
		}

		public static Keybinding AddKeybinding(string category, string name, string defaultPrimary = null, string defaultSecondary = null)
		{
			return AddCategory(category).AddKeyBinding(name, defaultPrimary, defaultSecondary);
		}

		public static Keybinding GetKeybinding(string id)
		{
			foreach (KeybindingCategory value in Categories.Values)
			{
				if (value.HasKeybinding(id))
				{
					return value.GetKeybinding(id);
				}
			}
			return null;
		}

		public static Keybinding GetKeybinding(ButtonInputAction flag)
		{
			//IL_001e: 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)
			foreach (KeybindingCategory value in Categories.Values)
			{
				if (value.HasKeybinding(flag))
				{
					return value.GetKeybinding(flag);
				}
			}
			return null;
		}

		public static void Save()
		{
			FileUtils.WriteJson(ActionsFilename, Categories);
		}

		public static void FullSave()
		{
			List<string> list = new List<string>();
			foreach (KeybindingCategory value in Categories.Values)
			{
				value.Overrides.Clear();
				foreach (Keybinding value2 in value.KeybindingMap.Values)
				{
					value.Overrides.Add(value2.Name, value2.GetData());
				}
				if (value.Overrides.Count == 0)
				{
					list.Add(value.Name);
				}
			}
			foreach (string item in list)
			{
				Categories.Remove(item);
			}
			Save();
		}

		internal static void Load()
		{
			if (!FileUtils.Exists(ActionsFilename))
			{
				Save();
				return;
			}
			Dictionary<string, KeybindingCategory> dictionary = FileUtils.ReadJson<Dictionary<string, KeybindingCategory>>(ActionsFilename);
			if (dictionary != null)
			{
				Categories = dictionary;
			}
		}
	}
	public static class LocalizationManager
	{
		private static readonly Dictionary<AssetGuid, string> guids;

		static LocalizationManager()
		{
			guids = new Dictionary<AssetGuid, string>();
		}

		public static LocalizationKey CreateKey(string value)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			LocalizationKey result = default(LocalizationKey);
			((LocalizationKey)(ref result))..ctor(AssetGuid.FromGuid(Guid.NewGuid()));
			guids.Add(((LocalizationKey)(ref result)).GetGuid(), value);
			return result;
		}

		public static Nullable_Unboxed<LocalizationKey> CreateNullableKey(string value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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 new Nullable_Unboxed<LocalizationKey>(CreateKey(value));
		}

		internal static string GetKey(AssetGuid guid)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return guids[guid];
		}

		internal static string GetKey(LocalizationKey key)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetKey(((LocalizationKey)(ref key)).GetGuid());
		}

		internal static bool HasKey(AssetGuid guid)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return guids.ContainsKey(guid);
		}
	}
	public static class OptionsManager
	{
		internal static Dictionary<string, OptionCategory> Categories = new Dictionary<string, OptionCategory>();

		internal static string OptionsFilename = "options.json";

		public static OptionCategory AddCategory(string name)
		{
			if (!Categories.ContainsKey(name))
			{
				Categories.Add(name, new OptionCategory(name));
			}
			return Categories[name];
		}

		public static ToggleOption GetToggle(string id)
		{
			foreach (OptionCategory value in Categories.Values)
			{
				if (value.HasToggle(id))
				{
					return value.GetToggle(id);
				}
			}
			return null;
		}

		public static SliderOption GetSlider(string id)
		{
			foreach (OptionCategory value in Categories.Values)
			{
				if (value.HasSlider(id))
				{
					return value.GetSlider(id);
				}
			}
			return null;
		}

		public static DropdownOption GetDropdown(string id)
		{
			foreach (OptionCategory value in Categories.Values)
			{
				if (value.HasDropdown(id))
				{
					return value.GetDropdown(id);
				}
			}
			return null;
		}

		public static void Save()
		{
			FileUtils.WriteJson(OptionsFilename, Categories);
		}

		internal static void FullSave()
		{
			List<string> list = new List<string>();
			foreach (OptionCategory value in Categories.Values)
			{
				value.Toggles.Clear();
				value.Sliders.Clear();
				value.Dropdowns.Clear();
				foreach (ToggleOption value2 in value.ToggleOptions.Values)
				{
					value.Toggles.Add(value2.Name, value2.Value);
				}
				foreach (SliderOption value3 in value.SliderOptions.Values)
				{
					value.Sliders.Add(value3.Name, value3.Value);
				}
				foreach (DropdownOption value4 in value.DropdownOptions.Values)
				{
					value.Dropdowns.Add(value4.Name, value4.Values[value4.Value]);
				}
				if (value.Toggles.Count + value.Sliders.Count + value.Dropdowns.Count == 0)
				{
					list.Add(value.Name);
				}
			}
			foreach (string item in list)
			{
				Categories.Remove(item);
			}
			Save();
		}

		internal static void Load()
		{
			if (!FileUtils.Exists(OptionsFilename))
			{
				Save();
				return;
			}
			Dictionary<string, OptionCategory> dictionary = FileUtils.ReadJson<Dictionary<string, OptionCategory>>(OptionsFilename);
			if (dictionary != null)
			{
				Categories = dictionary;
			}
		}
	}
}