Decompiled source of REPO Accessibility v1.0.0

RepoAccessibility.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepoAccessibility")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoAccessibility")]
[assembly: AssemblyTitle("RepoAccessibility")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Codex.RepoDeafMode
{
	[BepInPlugin("codex.repoaccessibility.signals", "Deaf Mode Signals", "1.0.0")]
	public sealed class RepoDeafModePlugin : BaseUnityPlugin
	{
		private sealed class Signal
		{
			public Vector3 Position;

			public float Expires;

			public Color Color;

			public string Label;
		}

		private readonly List<Signal> _signals = new List<Signal>();

		private readonly HashSet<int> _playing = new HashSet<int>();

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<KeyCode> _toggleKey;

		private ConfigEntry<float> _maxDistance;

		private float _nextScan;

		private GUIStyle _style;

		private Texture2D _pixel;

		private void Awake()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Signals", "Enabled", true, "Show visual cues when nearby positional sounds begin.");
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Signals", "ToggleKey", (KeyCode)288, "Toggle Deaf Mode Signals while in game.");
			_maxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Signals", "MaxDistance", 60f, "Maximum distance for sound cues.");
			_pixel = new Texture2D(1, 1, (TextureFormat)4, false);
			_pixel.SetPixel(0, 0, Color.white);
			_pixel.Apply();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Deaf Mode Signals loaded. Press F7 to toggle.");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_enabled.Value = !_enabled.Value;
			}
			if (!_enabled.Value)
			{
				_signals.Clear();
				_playing.Clear();
				return;
			}
			if (Time.unscaledTime >= _nextScan)
			{
				_nextScan = Time.unscaledTime + 0.35f;
				Scan();
			}
			for (int num = _signals.Count - 1; num >= 0; num--)
			{
				if (_signals[num].Expires <= Time.unscaledTime)
				{
					_signals.RemoveAt(num);
				}
			}
		}

		private void Scan()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			AudioSource[] array = Object.FindObjectsOfType<AudioSource>();
			HashSet<int> hashSet = new HashSet<int>();
			PlayerAvatar val = SemiFunc.PlayerGetLocal();
			Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero));
			foreach (AudioSource val3 in array)
			{
				if ((Object)(object)val3 == (Object)null || !val3.isPlaying || !((Component)val3).gameObject.activeInHierarchy || val3.spatialBlend < 0.25f || val3.volume < 0.08f)
				{
					continue;
				}
				int instanceID = ((Object)val3).GetInstanceID();
				hashSet.Add(instanceID);
				if (_playing.Contains(instanceID))
				{
					continue;
				}
				float num = Vector3.Distance(val2, ((Component)val3).transform.position);
				if (!(num < 1.5f) && !(num > _maxDistance.Value))
				{
					Color color;
					string label = Classify(val3, out color);
					_signals.Add(new Signal
					{
						Position = ((Component)val3).transform.position,
						Expires = Time.unscaledTime + 3f,
						Color = color,
						Label = label
					});
					if (_signals.Count > 24)
					{
						_signals.RemoveAt(0);
					}
				}
			}
			_playing.Clear();
			foreach (int item in hashSet)
			{
				_playing.Add(item);
			}
		}

		private static string Classify(AudioSource source, out Color color)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			string text = (((Object)((Component)source).gameObject).name + " " + (((Object)(object)source.clip != (Object)null) ? ((Object)source.clip).name : "")).ToLowerInvariant();
			Transform parent = ((Component)source).transform.parent;
			int num = 0;
			while ((Object)(object)parent != (Object)null && num++ < 4)
			{
				text = text + " " + ((Object)parent).name.ToLowerInvariant();
				parent = parent.parent;
			}
			if (Has(text, "enemy", "monster", "attack", "chase", "scream", "head", "tumble"))
			{
				color = new Color(1f, 0.27f, 0.25f, 1f);
				return "THREAT";
			}
			if (Has(text, "player", "footstep", "voice", "jump", "land", "talk"))
			{
				color = new Color(0.3f, 0.72f, 1f, 1f);
				return "PLAYER";
			}
			if (Has(text, "valuable", "loot", "item", "grab", "pickup"))
			{
				color = new Color(0.32f, 1f, 0.63f, 1f);
				return "LOOT";
			}
			color = new Color(1f, 0.78f, 0.28f, 1f);
			return "SOUND";
		}

		private static bool Has(string text, params string[] hints)
		{
			for (int i = 0; i < hints.Length; i++)
			{
				if (text.Contains(hints[i]))
				{
					return true;
				}
			}
			return false;
		}

		private void OnGUI()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: 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)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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)
			//IL_0184: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!_enabled.Value || (Object)(object)Camera.main == (Object)null)
			{
				return;
			}
			if (_style == null)
			{
				_style = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
			}
			Vector2 val2 = default(Vector2);
			Vector2 val3 = default(Vector2);
			for (int i = 0; i < _signals.Count; i++)
			{
				Signal signal = _signals[i];
				Vector3 val = Camera.main.WorldToScreenPoint(signal.Position);
				((Vector2)(ref val2))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
				((Vector2)(ref val3))..ctor(val.x, (float)Screen.height - val.y);
				Vector2 val4 = val3 - val2;
				if (val.z <= 0f)
				{
					val4 = -val4;
				}
				if (!(val.z > 0f) || !(val3.x > 24f) || !(val3.x < (float)(Screen.width - 24)) || !(val3.y > 24f) || !(val3.y < (float)(Screen.height - 24)))
				{
					if (((Vector2)(ref val4)).sqrMagnitude < 1f)
					{
						val4 = Vector2.up;
					}
					((Vector2)(ref val4)).Normalize();
					float num = Mathf.Min(((float)Screen.width * 0.5f - 30f) / Mathf.Max(0.001f, Mathf.Abs(val4.x)), ((float)Screen.height * 0.5f - 30f) / Mathf.Max(0.001f, Mathf.Abs(val4.y)));
					val3 = val2 + val4 * num;
				}
				Color color = signal.Color;
				color.a = Mathf.Clamp01((signal.Expires - Time.unscaledTime) / 3f);
				DrawLine(val2, val3, new Color(color.r, color.g, color.b, color.a * 0.35f), 2f);
				DrawCircle(val3, 12f + Mathf.Sin(Time.unscaledTime * 8f + (float)i) * 3f, color, 2f);
				GUI.color = color;
				GUI.Label(new Rect(Mathf.Clamp(val3.x + 12f, 4f, (float)(Screen.width - 86)), Mathf.Clamp(val3.y - 12f, 4f, (float)(Screen.height - 24)), 82f, 22f), signal.Label, _style);
				GUI.color = Color.white;
			}
		}

		private void DrawCircle(Vector2 center, float radius, Color color, float width)
		{
			//IL_0000: 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_0011: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 start = center + new Vector2(radius, 0f);
			for (int i = 1; i <= 20; i++)
			{
				float num = MathF.PI * 2f * (float)i / 20f;
				Vector2 val = center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius;
				DrawLine(start, val, color, width);
				start = val;
			}
		}

		private void DrawLine(Vector2 start, Vector2 end, Color color, float width)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			Matrix4x4 matrix = GUI.matrix;
			GUI.color = color;
			Vector2 val = end - start;
			GUIUtility.ScaleAroundPivot(new Vector2(((Vector2)(ref val)).magnitude, width), start);
			GUIUtility.RotateAroundPivot(Mathf.Atan2(val.y, val.x) * 57.29578f, start);
			GUI.DrawTexture(new Rect(start.x, start.y, 1f, 1f), (Texture)(object)_pixel);
			GUI.matrix = matrix;
			GUI.color = color2;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_pixel != (Object)null)
			{
				Object.Destroy((Object)(object)_pixel);
			}
		}
	}
}
namespace Codex.FocusZoom
{
	[BepInPlugin("codex.repoaccessibility.zoom", "Focus Zoom", "1.0.0")]
	public sealed class FocusZoomPlugin : BaseUnityPlugin
	{
		private ConfigEntry<KeyCode> _zoomKey;

		private ConfigEntry<float> _zoomFieldOfView;

		private ConfigEntry<float> _smoothness;

		private Camera _camera;

		private float _originalFieldOfView;

		private bool _isZooming;

		private void Awake()
		{
			_zoomKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Zoom", "HoldKey", (KeyCode)99, "Hold this key for a closer view.");
			_zoomFieldOfView = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "FieldOfView", 38f, "Field of view while zooming. Lower values zoom in more.");
			_smoothness = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "Smoothness", 10f, "How quickly the view transitions in and out.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Focus Zoom loaded. Hold C to zoom; settings are configurable.");
		}

		private void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			if ((Object)(object)_camera != (Object)(object)main)
			{
				RestoreCamera();
				_camera = main;
			}
			bool key = Input.GetKey(_zoomKey.Value);
			if (key && !_isZooming)
			{
				_originalFieldOfView = _camera.fieldOfView;
				_isZooming = true;
			}
			if (_isZooming)
			{
				float num = (key ? Mathf.Clamp(_zoomFieldOfView.Value, 20f, 100f) : _originalFieldOfView);
				float num2 = 1f - Mathf.Exp((0f - Mathf.Clamp(_smoothness.Value, 1f, 30f)) * Time.unscaledDeltaTime);
				_camera.fieldOfView = Mathf.Lerp(_camera.fieldOfView, num, num2);
				if (!key && Mathf.Abs(_camera.fieldOfView - _originalFieldOfView) < 0.15f)
				{
					_camera.fieldOfView = _originalFieldOfView;
					_isZooming = false;
				}
			}
		}

		private void RestoreCamera()
		{
			if ((Object)(object)_camera != (Object)null && _isZooming)
			{
				_camera.fieldOfView = _originalFieldOfView;
			}
			_isZooming = false;
		}

		private void OnDestroy()
		{
			RestoreCamera();
		}
	}
}
namespace Codex.CameraComfort
{
	[BepInPlugin("codex.repoaccessibility.comfort", "Camera Comfort", "1.0.0")]
	public sealed class CameraComfortPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(CameraShake), "Update")]
		private static class CameraShakePatch
		{
			private struct State
			{
				public float Rotation;

				public float Position;
			}

			private static void Prefix(CameraShake __instance, out State __state)
			{
				__state = new State
				{
					Rotation = __instance.RotationMultiplier,
					Position = __instance.PositionMultiplier
				};
				CameraComfortPlugin instance = Instance;
				if (!((Object)(object)instance == (Object)null) && instance._enabled.Value)
				{
					float num = 1f - Mathf.Clamp01(instance._shakeReduction.Value);
					__instance.RotationMultiplier *= num;
					__instance.PositionMultiplier *= num;
				}
			}

			private static void Postfix(CameraShake __instance, State __state)
			{
				__instance.RotationMultiplier = __state.Rotation;
				__instance.PositionMultiplier = __state.Position;
			}
		}

		private static CameraComfortPlugin Instance;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<KeyCode> _menuKey;

		private ConfigEntry<float> _fovOffset;

		private ConfigEntry<float> _shakeReduction;

		private readonly Harmony _harmony = new Harmony("codex.repoaccessibility.comfort");

		private Camera _camera;

		private float _baseFov;

		private float _lastAppliedFov;

		private bool _hasFov;

		private bool _menuOpen;

		private CursorLockMode _oldCursorLock;

		private bool _oldCursorVisible;

		private Rect _menuRect;

		private GUIStyle _titleStyle;

		private GUIStyle _labelStyle;

		private GUIStyle _smallStyle;

		private Texture2D _pixel;

		private const int WindowId = 26102610;

		private void Awake()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Comfort", "Enabled", true, "Enable FOV and camera-shake comfort adjustments.");
			_menuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Comfort", "SettingsKey", (KeyCode)290, "Open or close Camera Comfort settings.");
			_fovOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Comfort", "FovOffset", 0f, new ConfigDescription("Adjust the game's current field of view. Zero keeps the game value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-20f, 30f), Array.Empty<object>()));
			_shakeReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Comfort", "ShakeReduction", 0.5f, new ConfigDescription("Reduce camera shake strength from 0 (none) to 1 (maximum).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			_menuRect = new Rect(Mathf.Max(12f, (float)(Screen.width - 420) * 0.5f), Mathf.Max(12f, (float)(Screen.height - 300) * 0.5f), 420f, 300f);
			_pixel = new Texture2D(1, 1, (TextureFormat)4, false);
			_pixel.SetPixel(0, 0, Color.white);
			_pixel.Apply();
			_harmony.PatchAll(typeof(CameraComfortPlugin));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Camera Comfort loaded. Press F9 to open settings.");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_menuKey.Value))
			{
				SetMenuOpen(!_menuOpen);
			}
			if (_menuOpen && Input.GetKeyDown((KeyCode)27))
			{
				SetMenuOpen(open: false);
			}
		}

		private void LateUpdate()
		{
			if (_menuOpen)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			if (!_enabled.Value)
			{
				RestoreFov();
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				RestoreFov();
				return;
			}
			if ((Object)(object)main != (Object)(object)_camera)
			{
				RestoreFov();
				_camera = main;
				_baseFov = main.fieldOfView;
				_hasFov = true;
			}
			else if (_hasFov && Mathf.Abs(main.fieldOfView - _lastAppliedFov) > 0.1f)
			{
				_baseFov = main.fieldOfView;
			}
			_lastAppliedFov = Mathf.Clamp(_baseFov + _fovOffset.Value, 50f, 120f);
			main.fieldOfView = _lastAppliedFov;
		}

		private void RestoreFov()
		{
			if ((Object)(object)_camera != (Object)null && _hasFov)
			{
				_camera.fieldOfView = _baseFov;
			}
			_camera = null;
			_hasFov = false;
		}

		private void SetMenuOpen(bool open)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_menuOpen != open)
			{
				_menuOpen = open;
				if (open)
				{
					_oldCursorLock = Cursor.lockState;
					_oldCursorVisible = Cursor.visible;
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					((Rect)(ref _menuRect)).x = Mathf.Clamp(((Rect)(ref _menuRect)).x, 8f, Mathf.Max(8f, (float)Screen.width - ((Rect)(ref _menuRect)).width - 8f));
					((Rect)(ref _menuRect)).y = Mathf.Clamp(((Rect)(ref _menuRect)).y, 8f, Mathf.Max(8f, (float)Screen.height - ((Rect)(ref _menuRect)).height - 8f));
				}
				else
				{
					Cursor.lockState = _oldCursorLock;
					Cursor.visible = _oldCursorVisible;
				}
			}
		}

		private void OnGUI()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (_menuOpen)
			{
				int depth = GUI.depth;
				GUI.depth = 1;
				EnsureStyles();
				_menuRect = GUI.Window(26102610, _menuRect, new WindowFunction(DrawMenu), GUIContent.none);
				GUI.depth = depth;
			}
		}

		private void DrawMenu(int id)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			DrawRect(new Rect(0f, 0f, ((Rect)(ref _menuRect)).width, ((Rect)(ref _menuRect)).height), new Color(0.025f, 0.04f, 0.055f, 0.97f));
			DrawRect(new Rect(0f, 0f, ((Rect)(ref _menuRect)).width, 4f), new Color(0.34f, 0.93f, 0.77f, 1f));
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Space(13f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(17f);
			GUILayout.Label("CAMERA COMFORT", _titleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("×", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(34f),
				GUILayout.Height(30f)
			}))
			{
				SetMenuOpen(open: false);
			}
			GUILayout.Space(10f);
			GUILayout.EndHorizontal();
			GUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(18f);
			GUILayout.Label("PERSONAL VIEW SETTINGS", _smallStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(18f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(20f);
			GUILayout.Label("Enable comfort adjustments", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(245f) });
			_enabled.Value = GUILayout.Toggle(_enabled.Value, "On", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
			GUILayout.EndHorizontal();
			GUILayout.Space(18f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(20f);
			GUILayout.Label("FOV offset", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) });
			_fovOffset.Value = Mathf.Round(GUILayout.HorizontalSlider(_fovOffset.Value, -20f, 30f, Array.Empty<GUILayoutOption>()) * 2f) / 2f;
			GUILayout.Label(((_fovOffset.Value >= 0f) ? "+" : "") + _fovOffset.Value.ToString("0.0"), _smallStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) });
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(20f);
			GUILayout.Label("Camera shake reduction", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(175f) });
			_shakeReduction.Value = Mathf.Round(GUILayout.HorizontalSlider(_shakeReduction.Value, 0f, 1f, Array.Empty<GUILayoutOption>()) * 100f) / 100f;
			GUILayout.Label(Mathf.RoundToInt(_shakeReduction.Value * 100f) + "%", _smallStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) });
			GUILayout.EndHorizontal();
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Space(18f);
			GUILayout.Label("F9  SETTINGS     ·     ESC  CLOSE", _smallStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(12f);
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _menuRect)).width, 52f));
		}

		private void EnsureStyles()
		{
			//IL_0014: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (_titleStyle == null)
			{
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_titleStyle.normal.textColor = new Color(0.34f, 0.93f, 0.77f, 1f);
				_labelStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_labelStyle.normal.textColor = Color.white;
				_smallStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 11,
					alignment = (TextAnchor)3
				};
				_smallStyle.normal.textColor = new Color(0.67f, 0.77f, 0.82f, 1f);
			}
		}

		private void DrawRect(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_pixel);
			GUI.color = color2;
		}

		private void OnDestroy()
		{
			if (_menuOpen)
			{
				SetMenuOpen(open: false);
			}
			RestoreFov();
			_harmony.UnpatchSelf();
			if ((Object)(object)_pixel != (Object)null)
			{
				Object.Destroy((Object)(object)_pixel);
			}
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}
	}
}