Decompiled source of EyesColorCustom v1.0.0

EyesColorCustom.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 REPOJP.EyesColorCustom
{
	[BepInPlugin("REPOJP.EyesColorCustom", "EyesColorCustom", "1.0.0")]
	public sealed class EyesColorCustomPlugin : BaseUnityPlugin
	{
		private enum EyeColorPreset
		{
			Off,
			Red,
			Green,
			Love,
			CeilingEye,
			Inverted
		}

		private enum HudAnimState
		{
			Hidden,
			In,
			Hold,
			Out
		}

		[HarmonyPatch]
		private static class ExpressionInputSuppressPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(SemiFunc), "InputDown")]
			private static bool SemiFunc_InputDown_Prefix(InputKey key, ref bool __result)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				if (!IsExpressionKey(key))
				{
					return true;
				}
				if (ShouldSuppressExpressionInputs())
				{
					__result = false;
					return false;
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(SemiFunc), "InputHold")]
			private static bool SemiFunc_InputHold_Prefix(InputKey key, ref bool __result)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				if (!IsExpressionKey(key))
				{
					return true;
				}
				if (ShouldSuppressExpressionInputs())
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		[CompilerGenerated]
		private sealed class <ApplyLoop>d__48 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EyesColorCustomPlugin <>4__this;

			private float <interval>5__1;

			private float <blink>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ApplyLoop>d__48(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<>4__this._enabled.Value)
				{
					<>4__this.EnsureLocalCache();
					if ((Object)(object)<>4__this._cachedAvatar != (Object)null && (Object)(object)<>4__this._cachedHealth != (Object)null)
					{
						<>4__this.ApplyEye();
						<>4__this.ApplyPupil();
					}
				}
				<interval>5__1 = Mathf.Clamp(<>4__this._applyIntervalSeconds.Value, 0.05f, 2f);
				if (<>4__this._enabled.Value && <>4__this._eyeBlinkList.Count >= 2)
				{
					<blink>5__2 = Mathf.Clamp(<>4__this._blinkIntervalSeconds.Value, 0.05f, 5f);
					<interval>5__1 = Mathf.Min(<interval>5__1, <blink>5__2 * 0.5f);
					<interval>5__1 = Mathf.Clamp(<interval>5__1, 0.05f, 2f);
				}
				<>2__current = (object)new WaitForSeconds(<interval>5__1);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <RegisterCommandsLoop>d__83 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EyesColorCustomPlugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RegisterCommandsLoop>d__83(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)DebugCommandHandler.instance != (Object)null)
				{
					<>4__this.RegisterCommands();
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public const string PluginGuid = "REPOJP.EyesColorCustom";

		public const string PluginName = "EyesColorCustom";

		public const string PluginVersion = "1.0.0";

		private static EyesColorCustomPlugin Instance;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<EyeColorPreset> _defaultEyeColor;

		private ConfigEntry<float> _defaultPupilMultiplier;

		private ConfigEntry<float> _applyIntervalSeconds;

		private ConfigEntry<float> _blinkIntervalSeconds;

		private ConfigEntry<KeyboardShortcut> _uiToggleKey;

		private ConfigEntry<float> _hudHoldSeconds;

		private ConfigEntry<float> _hudFadeInSeconds;

		private ConfigEntry<float> _hudFadeOutSeconds;

		private bool _eyeUseDefault = true;

		private EyeColorPreset _eyeSingle = EyeColorPreset.Off;

		private readonly List<EyeColorPreset> _eyeBlinkList = new List<EyeColorPreset>();

		private bool _pupilUseDefault = true;

		private float _pupilMultiplier;

		private PlayerAvatar _cachedAvatar;

		private PlayerHealth _cachedHealth;

		private bool _lastAppliedEyeOverride;

		private EyeColorPreset _lastAppliedEyePreset;

		private bool _lastAppliedPupilOverride;

		private bool _uiVisible;

		private Rect _uiRect = new Rect(40f, 40f, 560f, 470f);

		private Vector2 _uiScroll;

		private HudAnimState _hudState = HudAnimState.Hidden;

		private float _hudStateStartUnscaled;

		private float _hudX;

		private float _hudY;

		private float _hudAlpha;

		private Texture2D _whiteTex;

		private bool _guiInited;

		private GUIStyle _hudTitleStyle;

		private GUIStyle _hudTextStyle;

		private GUIStyle _hudSmallStyle;

		private GUIStyle _hudMonoStyle;

		private Harmony _harmony;

		private bool _pendingReapplyAfterScene;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			Instance = this;
			BindConfig();
			ApplyConfigToRuntime();
			_harmony = new Harmony("REPOJP.EyesColorCustom");
			_harmony.PatchAll(typeof(ExpressionInputSuppressPatches));
			((MonoBehaviour)this).StartCoroutine(ApplyLoop());
			((MonoBehaviour)this).StartCoroutine(RegisterCommandsLoop());
			_defaultEyeColor.SettingChanged += delegate
			{
				ApplyConfigToRuntime();
			};
			_defaultPupilMultiplier.SettingChanged += delegate
			{
				ApplyConfigToRuntime();
			};
			SceneManager.sceneLoaded += OnSceneLoaded;
			SceneManager.activeSceneChanged += OnActiveSceneChanged;
		}

		private void OnDestroy()
		{
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			try
			{
				SceneManager.sceneLoaded -= OnSceneLoaded;
				SceneManager.activeSceneChanged -= OnActiveSceneChanged;
			}
			catch
			{
			}
			if ((Object)(object)_whiteTex != (Object)null)
			{
				Object.Destroy((Object)(object)_whiteTex);
				_whiteTex = null;
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			_pendingReapplyAfterScene = true;
			_cachedAvatar = null;
			_cachedHealth = null;
		}

		private void OnActiveSceneChanged(Scene from, Scene to)
		{
			_pendingReapplyAfterScene = true;
			_cachedAvatar = null;
			_cachedHealth = null;
		}

		private void BindConfig()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0118: 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_0165: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("0_General", "Enabled", true, "Enable plugin. プラグイン有効化");
			_defaultEyeColor = ((BaseUnityPlugin)this).Config.Bind<EyeColorPreset>("1_Defaults", "DefaultEyeColor", EyeColorPreset.Off, "Default eye color preset. デフォルト目色プリセット");
			_defaultPupilMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1_Defaults", "DefaultPupilMultiplier", 1f, new ConfigDescription("Default pupil size multiplier. デフォルト瞳孔倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 3f), Array.Empty<object>()));
			_applyIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("2_Runtime", "ApplyIntervalSeconds", 0.2f, new ConfigDescription("Apply loop interval seconds. 適用ループ間隔秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>()));
			_blinkIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("2_Runtime", "BlinkIntervalSeconds", 0.2f, new ConfigDescription("Blink interval seconds for multi-color selection. 複数色選択の点滅間隔秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 5f), Array.Empty<object>()));
			_uiToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("3_UI", "UiToggleKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Toggle settings UI. 設定UI表示切替");
			_hudHoldSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("3_UI", "HudHoldSeconds", 5f, new ConfigDescription("HUD hold seconds before fade out. フェードアウトまでのHUD保持秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			_hudFadeInSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("3_UI", "HudFadeInSeconds", 0.18f, new ConfigDescription("HUD fade in seconds. HUDフェードイン秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			_hudFadeOutSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("3_UI", "HudFadeOutSeconds", 0.22f, new ConfigDescription("HUD fade out seconds. HUDフェードアウト秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
		}

		private void ApplyConfigToRuntime()
		{
			_eyeUseDefault = true;
			_eyeBlinkList.Clear();
			_eyeSingle = _defaultEyeColor.Value;
			_pupilUseDefault = true;
			_pupilMultiplier = ClampPupil(_defaultPupilMultiplier.Value);
			_pendingReapplyAfterScene = true;
			BumpHud();
		}

		private void Update()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!_enabled.Value)
			{
				return;
			}
			KeyboardShortcut value = _uiToggleKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				_uiVisible = !_uiVisible;
				BumpHud();
			}
			if (!SemiFunc.NoTextInputsActive())
			{
				return;
			}
			bool flag = IsCtrlPressed();
			bool flag2 = IsShiftPressed();
			if (flag && flag2)
			{
				return;
			}
			if (flag)
			{
				List<int> digitsDownThisFrame = GetDigitsDownThisFrame();
				if (digitsDownThisFrame.Count > 0)
				{
					if (digitsDownThisFrame.Contains(0))
					{
						SetEyeDefault();
						return;
					}
					List<EyeColorPreset> list = MapEyePresetsFromDigits(digitsDownThisFrame);
					if (list.Count > 0)
					{
						_eyeUseDefault = false;
						if (list.Count >= 2)
						{
							_eyeBlinkList.Clear();
							_eyeBlinkList.AddRange(list);
							_eyeSingle = EyeColorPreset.Off;
						}
						else
						{
							_eyeBlinkList.Clear();
							_eyeSingle = list[0];
						}
						BumpHud();
						return;
					}
				}
				if (Input.GetKeyDown((KeyCode)280))
				{
					CycleEyeColor(1);
				}
				else if (Input.GetKeyDown((KeyCode)281))
				{
					CycleEyeColor(-1);
				}
				else if (Input.GetKeyDown((KeyCode)8))
				{
					SetEyeDefault();
				}
			}
			else
			{
				if (!flag2)
				{
					return;
				}
				List<int> digitsDownThisFrame2 = GetDigitsDownThisFrame();
				if (digitsDownThisFrame2.Count > 0)
				{
					if (digitsDownThisFrame2.Contains(0))
					{
						SetPupilDefault();
						return;
					}
					int num = digitsDownThisFrame2.Where((int d) => d >= 4 && d <= 9).DefaultIfEmpty(-1).Max();
					if (num >= 4)
					{
						SetPupilFromDigit(num);
						BumpHud();
						return;
					}
				}
				if (Input.GetKeyDown((KeyCode)280))
				{
					CyclePupil(1);
				}
				else if (Input.GetKeyDown((KeyCode)281))
				{
					CyclePupil(-1);
				}
				else if (Input.GetKeyDown((KeyCode)8))
				{
					SetPupilDefault();
				}
			}
		}

		[IteratorStateMachine(typeof(<ApplyLoop>d__48))]
		private IEnumerator ApplyLoop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyLoop>d__48(0)
			{
				<>4__this = this
			};
		}

		private void EnsureLocalCache()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				_cachedAvatar = null;
				_cachedHealth = null;
				return;
			}
			PlayerHealth playerHealth = instance.playerHealth;
			if (!Object.op_Implicit((Object)(object)playerHealth))
			{
				_cachedAvatar = null;
				_cachedHealth = null;
				return;
			}
			if ((Object)(object)_cachedAvatar != (Object)(object)instance || (Object)(object)_cachedHealth != (Object)(object)playerHealth)
			{
				_cachedAvatar = instance;
				_cachedHealth = playerHealth;
				_lastAppliedEyeOverride = false;
				_lastAppliedPupilOverride = false;
				_pendingReapplyAfterScene = true;
			}
			if (_pendingReapplyAfterScene)
			{
				ApplyEye();
				ApplyPupil();
				_pendingReapplyAfterScene = false;
				BumpHud();
			}
		}

		private void ApplyEye()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00cf: 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)
			float num = Mathf.Clamp(_blinkIntervalSeconds.Value, 0.05f, 5f);
			EyeColorPreset desiredEyePreset = GetDesiredEyePreset(num);
			bool flag = desiredEyePreset != EyeColorPreset.Off;
			float num2 = Mathf.Clamp(_applyIntervalSeconds.Value, 0.05f, 2f);
			float num3 = Mathf.Max(0.25f, num2 * 4f);
			if (_eyeBlinkList.Count >= 2)
			{
				num3 = Mathf.Max(num3, num * 2.5f);
			}
			if (flag)
			{
				EyeOverrideState val = MapPresetToState(desiredEyePreset);
				_cachedHealth.EyeMaterialOverride(val, num3, 9999);
				_lastAppliedEyeOverride = true;
				_lastAppliedEyePreset = desiredEyePreset;
			}
			else if (_lastAppliedEyeOverride)
			{
				EyeOverrideState val2 = MapPresetToState(_lastAppliedEyePreset);
				_cachedHealth.EyeMaterialOverride(val2, 0.06f, 9999);
				_lastAppliedEyeOverride = false;
			}
		}

		private void ApplyPupil()
		{
			float num = (_pupilUseDefault ? ClampPupil(_defaultPupilMultiplier.Value) : ClampPupil(_pupilMultiplier));
			bool flag = Math.Abs(num - 1f) > 0.0001f;
			float num2 = Mathf.Clamp(_applyIntervalSeconds.Value, 0.05f, 2f);
			float num3 = Mathf.Max(0.25f, num2 * 4f);
			if (flag)
			{
				_cachedAvatar.OverridePupilSize(num, 9999, 5f, 0.5f, 5f, 0.5f, num3);
				_lastAppliedPupilOverride = true;
			}
			else if (_lastAppliedPupilOverride)
			{
				_cachedAvatar.OverridePupilSize(1f, 9999, 5f, 0.5f, 5f, 0.5f, 0.06f);
				_lastAppliedPupilOverride = false;
			}
		}

		private EyeColorPreset GetDesiredEyePreset(float blinkInterval)
		{
			if (_eyeBlinkList.Count >= 2)
			{
				float num = Mathf.Clamp(blinkInterval, 0.05f, 5f);
				int num2 = (int)(Time.unscaledTime / num) % _eyeBlinkList.Count;
				if (num2 < 0)
				{
					num2 = 0;
				}
				return _eyeBlinkList[num2];
			}
			if (_eyeBlinkList.Count == 1)
			{
				return _eyeBlinkList[0];
			}
			if (_eyeUseDefault)
			{
				return _defaultEyeColor.Value;
			}
			return _eyeSingle;
		}

		private static List<EyeColorPreset> MapEyePresetsFromDigits(List<int> digits)
		{
			List<(int, EyeColorPreset)> list = new List<(int, EyeColorPreset)>();
			foreach (int digit in digits)
			{
				if (TryMapEyeColorDigit(digit, out var preset))
				{
					list.Add((digit, preset));
				}
			}
			list = list.OrderBy<(int, EyeColorPreset), int>(((int digit, EyeColorPreset preset) x) => x.digit).ToList();
			List<EyeColorPreset> list2 = new List<EyeColorPreset>();
			foreach (var item in list)
			{
				if (!list2.Contains(item.Item2))
				{
					list2.Add(item.Item2);
				}
			}
			return list2;
		}

		private void SetEyeDefault()
		{
			_eyeUseDefault = true;
			_eyeBlinkList.Clear();
			_eyeSingle = _defaultEyeColor.Value;
			BumpHud();
		}

		private void CycleEyeColor(int dir)
		{
			EyeColorPreset[] array = new EyeColorPreset[6]
			{
				EyeColorPreset.Off,
				EyeColorPreset.Red,
				EyeColorPreset.Green,
				EyeColorPreset.Love,
				EyeColorPreset.CeilingEye,
				EyeColorPreset.Inverted
			};
			EyeColorPreset desiredEyePreset = GetDesiredEyePreset(_blinkIntervalSeconds.Value);
			int num = Array.IndexOf(array, desiredEyePreset);
			if (num < 0)
			{
				num = 0;
			}
			num = (num + dir) % array.Length;
			if (num < 0)
			{
				num += array.Length;
			}
			_eyeUseDefault = false;
			_eyeBlinkList.Clear();
			_eyeSingle = array[num];
			BumpHud();
		}

		private void SetPupilDefault()
		{
			_pupilUseDefault = true;
			_pupilMultiplier = ClampPupil(_defaultPupilMultiplier.Value);
			BumpHud();
		}

		private void SetPupilFromDigit(int digit)
		{
			float num = 0.25f;
			float num2 = 3f;
			float num3 = Mathf.InverseLerp(4f, 9f, (float)digit);
			float v = Mathf.Lerp(num, num2, num3);
			_pupilUseDefault = false;
			_pupilMultiplier = ClampPupil(v);
		}

		private void CyclePupil(int dir)
		{
			int num = DigitFromPupil(_pupilUseDefault ? ClampPupil(_defaultPupilMultiplier.Value) : ClampPupil(_pupilMultiplier));
			int num2 = num + dir;
			if (num2 < 4)
			{
				num2 = 9;
			}
			if (num2 > 9)
			{
				num2 = 4;
			}
			SetPupilFromDigit(num2);
			BumpHud();
		}

		private static int DigitFromPupil(float mult)
		{
			float num = 0.25f;
			float num2 = 3f;
			float num3 = Mathf.InverseLerp(num, num2, mult);
			int num4 = Mathf.RoundToInt(Mathf.Lerp(4f, 9f, num3));
			if (num4 < 4)
			{
				num4 = 4;
			}
			if (num4 > 9)
			{
				num4 = 9;
			}
			return num4;
		}

		private void BumpHud()
		{
			float unscaledTime = Time.unscaledTime;
			if (_hudState == HudAnimState.In || _hudState == HudAnimState.Hold)
			{
				_hudState = HudAnimState.Hold;
				_hudStateStartUnscaled = unscaledTime;
			}
			else
			{
				_hudState = HudAnimState.In;
				_hudStateStartUnscaled = unscaledTime;
			}
		}

		private static bool IsCtrlPressed()
		{
			return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
		}

		private static bool IsShiftPressed()
		{
			return Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
		}

		private static List<int> GetDigitsDownThisFrame()
		{
			List<int> list = new List<int>();
			if (Input.GetKeyDown((KeyCode)52) || Input.GetKeyDown((KeyCode)260))
			{
				list.Add(4);
			}
			if (Input.GetKeyDown((KeyCode)53) || Input.GetKeyDown((KeyCode)261))
			{
				list.Add(5);
			}
			if (Input.GetKeyDown((KeyCode)54) || Input.GetKeyDown((KeyCode)262))
			{
				list.Add(6);
			}
			if (Input.GetKeyDown((KeyCode)55) || Input.GetKeyDown((KeyCode)263))
			{
				list.Add(7);
			}
			if (Input.GetKeyDown((KeyCode)56) || Input.GetKeyDown((KeyCode)264))
			{
				list.Add(8);
			}
			if (Input.GetKeyDown((KeyCode)57) || Input.GetKeyDown((KeyCode)265))
			{
				list.Add(9);
			}
			if (Input.GetKeyDown((KeyCode)48) || Input.GetKeyDown((KeyCode)256))
			{
				list.Add(0);
			}
			return list.Distinct().ToList();
		}

		private static bool TryMapEyeColorDigit(int digit, out EyeColorPreset preset)
		{
			switch (digit)
			{
			case 4:
				preset = EyeColorPreset.Off;
				return true;
			case 5:
				preset = EyeColorPreset.Red;
				return true;
			case 6:
				preset = EyeColorPreset.Green;
				return true;
			case 7:
				preset = EyeColorPreset.Love;
				return true;
			case 8:
				preset = EyeColorPreset.CeilingEye;
				return true;
			case 9:
				preset = EyeColorPreset.Inverted;
				return true;
			default:
				preset = EyeColorPreset.Off;
				return false;
			}
		}

		private static EyeOverrideState MapPresetToState(EyeColorPreset preset)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			return (EyeOverrideState)(preset switch
			{
				EyeColorPreset.Red => 1, 
				EyeColorPreset.Green => 2, 
				EyeColorPreset.Love => 3, 
				EyeColorPreset.CeilingEye => 4, 
				EyeColorPreset.Inverted => 5, 
				_ => 1, 
			});
		}

		private static float ClampPupil(float v)
		{
			if (v < 0.25f)
			{
				return 0.25f;
			}
			if (v > 3f)
			{
				return 3f;
			}
			return v;
		}

		private void EnsureGui()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00b5: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			if ((Object)(object)_whiteTex == (Object)null)
			{
				_whiteTex = new Texture2D(1, 1, (TextureFormat)4, false);
				_whiteTex.SetPixel(0, 0, Color.white);
				_whiteTex.Apply(false, true);
				((Object)_whiteTex).hideFlags = (HideFlags)61;
			}
			if (!_guiInited)
			{
				_hudTitleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)0
				};
				_hudTextStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					alignment = (TextAnchor)0
				};
				_hudSmallStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					alignment = (TextAnchor)0
				};
				_hudMonoStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					alignment = (TextAnchor)0
				};
				_guiInited = true;
			}
		}

		private void UpdateHudAnim(float w, float h, float margin)
		{
			float unscaledTime = Time.unscaledTime;
			float num = Mathf.Clamp(_hudFadeInSeconds.Value, 0f, 2f);
			float num2 = Mathf.Clamp(_hudFadeOutSeconds.Value, 0f, 2f);
			float num3 = Mathf.Clamp(_hudHoldSeconds.Value, 0f, 10f);
			float num4 = ((float)Screen.width - w) * 0.5f;
			float num5 = (float)Screen.height - margin - h;
			float num6 = (float)Screen.height + h + 30f;
			float num7 = (float)Screen.width - margin - w;
			float num8 = (float)Screen.height - margin - h + 55f;
			if (_hudState == HudAnimState.Hidden)
			{
				_hudAlpha = 0f;
			}
			else if (_hudState == HudAnimState.In)
			{
				float num9 = ((num <= 0.0001f) ? 1f : Mathf.Clamp01((unscaledTime - _hudStateStartUnscaled) / num));
				float num10 = EaseOutCubic(num9);
				_hudAlpha = Mathf.Lerp(0f, 1f, num10);
				_hudX = num4;
				_hudY = Mathf.Lerp(num6, num5, num10);
				if (num9 >= 1f)
				{
					_hudState = HudAnimState.Hold;
					_hudStateStartUnscaled = unscaledTime;
				}
			}
			else if (_hudState == HudAnimState.Hold)
			{
				_hudAlpha = 1f;
				_hudX = num4;
				_hudY = num5;
				if (unscaledTime - _hudStateStartUnscaled >= num3)
				{
					_hudState = HudAnimState.Out;
					_hudStateStartUnscaled = unscaledTime;
				}
			}
			else if (_hudState == HudAnimState.Out)
			{
				float num11 = ((num2 <= 0.0001f) ? 1f : Mathf.Clamp01((unscaledTime - _hudStateStartUnscaled) / num2));
				float num12 = EaseInCubic(num11);
				_hudAlpha = Mathf.Lerp(1f, 0f, num12);
				_hudX = Mathf.Lerp(num4, num7, num12);
				_hudY = Mathf.Lerp(num5, num8, num12);
				if (num11 >= 1f)
				{
					_hudState = HudAnimState.Hidden;
					_hudAlpha = 0f;
				}
			}
		}

		private static float EaseOutCubic(float t)
		{
			float num = 1f - t;
			return 1f - num * num * num;
		}

		private static float EaseInCubic(float t)
		{
			return t * t * t;
		}

		private void OnGUI()
		{
			//IL_0036: 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_0051: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value)
			{
				EnsureGui();
				DrawHudAnimated();
				if (_uiVisible)
				{
					_uiRect = GUI.Window(985231, _uiRect, new WindowFunction(DrawUiWindow), "EyesColorCustom");
				}
			}
		}

		private void DrawHudAnimated()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			float num = 620f;
			float num2 = 132f;
			float margin = 18f;
			UpdateHudAnim(num, num2, margin);
			if (_hudState != 0 && !(_hudAlpha <= 0.001f))
			{
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(_hudX, _hudY, num, num2);
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, _hudAlpha);
				DrawRect(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 6f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), new Color(0f, 0f, 0f, 0.35f * _hudAlpha));
				DrawRect(r, new Color(0.05f, 0.05f, 0.06f, 0.78f * _hudAlpha));
				DrawBorder(r, 1.5f, new Color(1f, 1f, 1f, 0.2f * _hudAlpha));
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref r)).x + 14f, ((Rect)(ref r)).y + 12f, ((Rect)(ref r)).width - 28f, ((Rect)(ref r)).height - 24f);
				EyeColorPreset desiredEyePreset = GetDesiredEyePreset(_blinkIntervalSeconds.Value);
				List<EyeColorPreset> list = BuildEyeShowList();
				float mult = (_pupilUseDefault ? ClampPupil(_defaultPupilMultiplier.Value) : ClampPupil(_pupilMultiplier));
				GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 20f), "Eye / Pupil", _hudTitleStyle);
				GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 26f, 70f, 20f), "Eye", _hudTextStyle);
				Color presetUiColor = GetPresetUiColor(desiredEyePreset);
				DrawColorSwatch(new Rect(((Rect)(ref val)).x + 44f, ((Rect)(ref val)).y + 26f, 22f, 22f), presetUiColor, active: true, 0, showIndex: true);
				GUI.Label(new Rect(((Rect)(ref val)).x + 76f, ((Rect)(ref val)).y + 26f, ((Rect)(ref val)).width - 76f, 20f), BuildEyeStatusText(), _hudTextStyle);
				DrawEyeChipRow(((Rect)(ref val)).x, ((Rect)(ref val)).y + 52f, list, desiredEyePreset);
				string text = "Blink " + Mathf.Clamp(_blinkIntervalSeconds.Value, 0.05f, 5f).ToString("0.00", CultureInfo.InvariantCulture) + "s";
				GUI.Label(new Rect(((Rect)(ref val)).x + 430f, ((Rect)(ref val)).y + 26f, 200f, 20f), text, _hudSmallStyle);
				GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 90f, 70f, 20f), "Pupil", _hudTextStyle);
				string text2 = (_pupilUseDefault ? "Default " : string.Empty) + mult.ToString("0.00", CultureInfo.InvariantCulture);
				GUI.Label(new Rect(((Rect)(ref val)).x + 76f, ((Rect)(ref val)).y + 90f, 180f, 20f), text2, _hudTextStyle);
				DrawPupilBar(new Rect(((Rect)(ref val)).x + 250f, ((Rect)(ref val)).y + 94f, 350f, 14f), mult);
				GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 112f, ((Rect)(ref val)).width, 18f), "Ctrl+4-9 Eye  Ctrl+0 Default  Shift+4-9 Pupil  Shift+0 Default  F6 UI", _hudSmallStyle);
				GUI.color = color;
			}
		}

		private List<EyeColorPreset> BuildEyeShowList()
		{
			if (_eyeBlinkList.Count >= 2)
			{
				return new List<EyeColorPreset>(_eyeBlinkList);
			}
			if (_eyeBlinkList.Count == 1)
			{
				return new List<EyeColorPreset> { _eyeBlinkList[0] };
			}
			if (_eyeUseDefault)
			{
				if (_defaultEyeColor.Value != 0)
				{
					return new List<EyeColorPreset> { _defaultEyeColor.Value };
				}
				return new List<EyeColorPreset>();
			}
			if (_eyeSingle != 0)
			{
				return new List<EyeColorPreset> { _eyeSingle };
			}
			return new List<EyeColorPreset>();
		}

		private void DrawEyeChipRow(float x, float y, List<EyeColorPreset> list, EyeColorPreset active)
		{
			//IL_0025: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (list == null || list.Count == 0)
			{
				DrawRect(new Rect(x, y, 240f, 28f), new Color(1f, 1f, 1f, 0.06f * _hudAlpha));
				DrawBorder(new Rect(x, y, 240f, 28f), 1f, new Color(1f, 1f, 1f, 0.12f * _hudAlpha));
				GUI.Label(new Rect(x + 8f, y + 5f, 240f, 20f), "OFF", _hudMonoStyle);
				return;
			}
			float num = 44f;
			float num2 = 28f;
			float num3 = 8f;
			if (list.Count >= 2)
			{
				GUI.Label(new Rect(x, y - 18f, 220f, 18f), "Selected Colors", _hudSmallStyle);
			}
			Rect r = default(Rect);
			for (int i = 0; i < list.Count; i++)
			{
				EyeColorPreset eyeColorPreset = list[i];
				Color presetUiColor = GetPresetUiColor(eyeColorPreset);
				((Rect)(ref r))..ctor(x + (num + num3) * (float)i, y, num, num2);
				bool active2 = eyeColorPreset == active;
				bool showIndex = list.Count >= 2;
				DrawColorSwatch(r, presetUiColor, active2, i + 1, showIndex);
			}
		}

		private void DrawPupilBar(Rect r, float mult)
		{
			//IL_001e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.25f;
			float num2 = 3f;
			float num3 = Mathf.InverseLerp(num, num2, mult);
			num3 = Mathf.Clamp01(num3);
			DrawRect(r, new Color(1f, 1f, 1f, 0.06f * _hudAlpha));
			DrawBorder(r, 1f, new Color(1f, 1f, 1f, 0.14f * _hudAlpha));
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, (((Rect)(ref r)).width - 4f) * num3, ((Rect)(ref r)).height - 4f);
			DrawRect(r2, new Color(0.3f, 0.85f, 0.6f, 0.7f * _hudAlpha));
			GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y - 2f, 60f, 20f), "0.25", _hudSmallStyle);
			GUI.Label(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 60f, ((Rect)(ref r)).y - 2f, 60f, 20f), "3.00", _hudSmallStyle);
		}

		private void DrawColorSwatch(Rect r, Color c, bool active, int index, bool showIndex)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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)
			DrawRect(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), new Color(0f, 0f, 0f, 0.3f * _hudAlpha));
			Color c2 = c;
			c2.a *= _hudAlpha;
			DrawRect(r, c2);
			if (active)
			{
				float num = 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 10f);
				DrawBorder(r, 2f, new Color(1f, 1f, 1f, (0.65f + 0.25f * num) * _hudAlpha));
			}
			else
			{
				DrawBorder(r, 1.5f, new Color(1f, 1f, 1f, 0.18f * _hudAlpha));
			}
			if (showIndex)
			{
				GUI.Label(new Rect(((Rect)(ref r)).x + 6f, ((Rect)(ref r)).y + 5f, ((Rect)(ref r)).width - 12f, ((Rect)(ref r)).height - 10f), index.ToString(CultureInfo.InvariantCulture), _hudMonoStyle);
			}
			string presetShortNameFromColor = GetPresetShortNameFromColor(c);
			GUI.Label(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 16f, ((Rect)(ref r)).y + 5f, 16f, ((Rect)(ref r)).height - 10f), presetShortNameFromColor, _hudMonoStyle);
		}

		private static string GetPresetShortNameFromColor(Color c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0047: 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_0073: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (c.r > 0.85f && c.g > 0.8f && c.b < 0.35f)
			{
				return "C";
			}
			if (c.r < 0.2f && c.g < 0.2f && c.b < 0.2f)
			{
				return "I";
			}
			if (c.r > 0.8f && c.g < 0.4f && c.b < 0.4f)
			{
				return "R";
			}
			if (c.g > 0.8f && c.r < 0.4f && c.b < 0.4f)
			{
				return "G";
			}
			if (c.r > 0.8f && c.b > 0.8f && c.g < 0.6f)
			{
				return "L";
			}
			return "-";
		}

		private static Color GetPresetUiColor(EyeColorPreset p)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(p switch
			{
				EyeColorPreset.Red => new Color(1f, 0.22f, 0.22f, 1f), 
				EyeColorPreset.Green => new Color(0.22f, 1f, 0.35f, 1f), 
				EyeColorPreset.Love => new Color(1f, 0.25f, 0.95f, 1f), 
				EyeColorPreset.CeilingEye => new Color(1f, 0.9f, 0.2f, 1f), 
				EyeColorPreset.Inverted => new Color(0.05f, 0.05f, 0.05f, 1f), 
				_ => new Color(0.55f, 0.55f, 0.55f, 1f), 
			});
		}

		private void DrawRect(Rect r, Color c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)(_whiteTex ?? Texture2D.whiteTexture));
			GUI.color = color;
		}

		private void DrawBorder(Rect r, float thickness, Color c)
		{
			//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)
			//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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			DrawRect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, thickness), c);
			DrawRect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - thickness, ((Rect)(ref r)).width, thickness), c);
			DrawRect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, thickness, ((Rect)(ref r)).height), c);
			DrawRect(new Rect(((Rect)(ref r)).xMax - thickness, ((Rect)(ref r)).y, thickness, ((Rect)(ref r)).height), c);
		}

		private string BuildEyeStatusText()
		{
			if (_eyeUseDefault)
			{
				return "Default " + _defaultEyeColor.Value;
			}
			if (_eyeBlinkList.Count >= 2)
			{
				return "Blink " + string.Join(",", _eyeBlinkList.Select((EyeColorPreset x) => x.ToString()).ToArray());
			}
			if (_eyeSingle == EyeColorPreset.Off)
			{
				return "OFF";
			}
			return _eyeSingle.ToString();
		}

		private void DrawUiWindow(int id)
		{
			//IL_000e: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			_uiScroll = GUILayout.BeginScrollView(_uiScroll, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(540f),
				GUILayout.Height(395f)
			});
			GUILayout.Label("Status", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Eye  " + BuildEyeStatusText(), Array.Empty<GUILayoutOption>());
			float num = (_pupilUseDefault ? ClampPupil(_defaultPupilMultiplier.Value) : ClampPupil(_pupilMultiplier));
			GUILayout.Label("Pupil " + (_pupilUseDefault ? "Default " : string.Empty) + num.ToString("0.00", CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Blink Interval Seconds", Array.Empty<GUILayoutOption>());
			float num2 = GUILayout.HorizontalSlider(_blinkIntervalSeconds.Value, 0.05f, 5f, Array.Empty<GUILayoutOption>());
			if (Math.Abs(num2 - _blinkIntervalSeconds.Value) > 0.0001f)
			{
				_blinkIntervalSeconds.Value = num2;
				((BaseUnityPlugin)this).Config.Save();
				BumpHud();
			}
			GUILayout.EndScrollView();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				_uiVisible = false;
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 22f));
		}

		[IteratorStateMachine(typeof(<RegisterCommandsLoop>d__83))]
		private IEnumerator RegisterCommandsLoop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RegisterCommandsLoop>d__83(0)
			{
				<>4__this = this
			};
		}

		private void RegisterCommands()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			DebugCommandHandler instance = DebugCommandHandler.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.Register(new ChatCommand("eyeui", "Toggle settings UI. 設定UI切替", (Action<bool, string[]>)delegate
				{
					_uiVisible = !_uiVisible;
					BumpHud();
					Debug.Log((object)("[EyesColorCustom] UI " + (_uiVisible ? "On" : "Off")));
				}, (Func<bool, string, string[], List<string>>)null, (Func<bool>)(() => true), false));
			}
		}

		internal static bool ShouldSuppressExpressionInputs()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return false;
			}
			if (!Instance._enabled.Value)
			{
				return false;
			}
			if (!SemiFunc.NoTextInputsActive())
			{
				return true;
			}
			if (IsCtrlPressed() || IsShiftPressed())
			{
				return true;
			}
			return false;
		}

		private static bool IsExpressionKey(InputKey key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			return (int)key == 26 || (int)key == 27 || (int)key == 28 || (int)key == 29 || (int)key == 30 || (int)key == 31;
		}
	}
}