Decompiled source of SelectiveHUDHider v1.0.1

plugins/NixiTsu-SelectiveHUDHider-1.0.1.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace SelectiveHider
{
	[BepInPlugin("com.yourname.SelectiveHider", "Selective HUD Hider", "1.0.0")]
	public class SelectiveHiderPlugin : BaseUnityPlugin
	{
		private static class TransparencyManager
		{
			private static Dictionary<GameObject, CanvasGroup> _canvasGroups = new Dictionary<GameObject, CanvasGroup>();

			private static Dictionary<GameObject, float> _originalAlphas = new Dictionary<GameObject, float>();

			private static ManualLogSource Logger => Logger.CreateLogSource("TransparencyManager");

			public static void SetTransparent(GameObject obj, bool transparent)
			{
				if ((Object)(object)obj == (Object)null || !Object.op_Implicit((Object)(object)obj))
				{
					return;
				}
				try
				{
					CanvasGroup value2;
					if (transparent)
					{
						if (!_canvasGroups.TryGetValue(obj, out var value) || (Object)(object)value == (Object)null)
						{
							value = obj.GetComponent<CanvasGroup>();
							if ((Object)(object)value == (Object)null)
							{
								value = obj.AddComponent<CanvasGroup>();
							}
							_canvasGroups[obj] = value;
						}
						if (!_originalAlphas.ContainsKey(obj))
						{
							_originalAlphas[obj] = value.alpha;
						}
						value.alpha = 0f;
						value.blocksRaycasts = false;
						value.interactable = false;
					}
					else if (_canvasGroups.TryGetValue(obj, out value2) && (Object)(object)value2 != (Object)null)
					{
						if (_originalAlphas.TryGetValue(obj, out var value3))
						{
							value2.alpha = value3;
						}
						else
						{
							value2.alpha = 1f;
						}
						value2.blocksRaycasts = true;
						value2.interactable = true;
					}
					else
					{
						CanvasGroup component = obj.GetComponent<CanvasGroup>();
						if ((Object)(object)component != (Object)null)
						{
							component.alpha = 1f;
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[TransparencyManager] Ошибка: " + ex.Message));
				}
			}

			public static void Cleanup()
			{
				foreach (KeyValuePair<GameObject, CanvasGroup> canvasGroup in _canvasGroups)
				{
					if ((Object)(object)canvasGroup.Key != (Object)null && (Object)(object)canvasGroup.Value != (Object)null)
					{
						if (_originalAlphas.TryGetValue(canvasGroup.Key, out var value))
						{
							canvasGroup.Value.alpha = value;
						}
						else
						{
							canvasGroup.Value.alpha = 1f;
						}
						canvasGroup.Value.blocksRaycasts = true;
						canvasGroup.Value.interactable = true;
					}
				}
				_canvasGroups.Clear();
				_originalAlphas.Clear();
			}
		}

		private static class CustomStaminaStats
		{
			private static bool _enabled = true;

			private static bool _showPercent = false;

			private static int _fontSize = 16;

			private static float _outlineThickness = 0.15f;

			private static Dictionary<STATUSTYPE, TextMeshProUGUI> _statusTexts = new Dictionary<STATUSTYPE, TextMeshProUGUI>();

			private static TextMeshProUGUI _staminaText;

			private static Canvas _canvas;

			private static Character _observedCharacter;

			private static StaminaBar _staminaBar;

			private static Dictionary<STATUSTYPE, BarAffliction> _cachedAfflictions = new Dictionary<STATUSTYPE, BarAffliction>();

			private static float _lastStaminaValue = -1f;

			private static Dictionary<STATUSTYPE, float> _lastStatusValues = new Dictionary<STATUSTYPE, float>();

			private static readonly Dictionary<STATUSTYPE, Color> StatusColors = new Dictionary<STATUSTYPE, Color>
			{
				{
					(STATUSTYPE)0,
					new Color(1f, 0.3f, 0f)
				},
				{
					(STATUSTYPE)1,
					new Color(0.9f, 0.6f, 0.1f)
				},
				{
					(STATUSTYPE)2,
					new Color(0.2f, 0.6f, 0.9f)
				},
				{
					(STATUSTYPE)3,
					new Color(0.6f, 0.1f, 0.6f)
				},
				{
					(STATUSTYPE)4,
					new Color(0.8805f, 0.2077f, 0.2579f)
				},
				{
					(STATUSTYPE)5,
					new Color(0.5f, 0.1f, 0.5f)
				},
				{
					(STATUSTYPE)6,
					new Color(1f, 0.4f, 0.8f)
				},
				{
					(STATUSTYPE)7,
					new Color(0.75f, 0.55f, 0.25f)
				},
				{
					(STATUSTYPE)8,
					new Color(1f, 0.3f, 0.1f)
				},
				{
					(STATUSTYPE)9,
					new Color(0.4f, 0.5f, 0f)
				},
				{
					(STATUSTYPE)10,
					new Color(0.6f, 0.35f, 0.4f)
				},
				{
					(STATUSTYPE)11,
					new Color(0.9f, 0.9f, 0.9f)
				}
			};

			private static TMP_FontAsset _gameFont;

			private static Material _textMaterial;

			private static string _fontBundlePath = null;

			private static bool _forceHidden = false;

			private static float _lastCleanupTime = 0f;

			private static readonly float CLEANUP_INTERVAL = 5f;

			private static ManualLogSource Logger => Logger.CreateLogSource("CustomStaminaStats");

			public static void SetFontBundlePath(string path)
			{
				_fontBundlePath = path;
				_gameFont = null;
				Logger.LogInfo((object)("[CustomStaminaStats] Путь к шрифту установлен: " + path));
			}

			public static void Initialize(bool enabled, bool showPercent, int fontSize, float outline)
			{
				_enabled = enabled;
				_showPercent = showPercent;
				_fontSize = fontSize;
				_outlineThickness = outline;
				FindGameTextStyle();
				CreateCanvas();
				Logger.LogInfo((object)"[CustomStaminaStats] Инициализирован");
			}

			public static void ResetCache()
			{
				try
				{
					Logger.LogInfo((object)"[CustomStaminaStats] Очистка кэша цифр...");
					foreach (KeyValuePair<STATUSTYPE, TextMeshProUGUI> item in _statusTexts.ToList())
					{
						if ((Object)(object)item.Value != (Object)null && (Object)(object)((Component)item.Value).gameObject != (Object)null)
						{
							((TMP_Text)item.Value).text = "";
						}
					}
					if ((Object)(object)_staminaText != (Object)null && (Object)(object)((Component)_staminaText).gameObject != (Object)null)
					{
						((TMP_Text)_staminaText).text = "";
					}
					_lastStaminaValue = -1f;
					_lastStatusValues.Clear();
					_observedCharacter = null;
					_staminaBar = null;
					_cachedAfflictions.Clear();
					_forceHidden = false;
					HideAllTexts();
					Logger.LogInfo((object)"[CustomStaminaStats] Кэш цифр очищен");
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка очистки кэша: " + ex.Message));
				}
			}

			private static void FindGameTextStyle()
			{
				if ((Object)(object)_gameFont != (Object)null)
				{
					return;
				}
				try
				{
					if (_fontBundlePath != null)
					{
						string text = Path.Combine(_fontBundlePath, "chewy_font");
						if (File.Exists(text))
						{
							AssetBundle val = AssetBundle.LoadFromFile(text);
							if ((Object)(object)val != (Object)null)
							{
								_gameFont = val.LoadAsset<TMP_FontAsset>("Chewy_Regular_SDF");
								val.Unload(false);
								if ((Object)(object)_gameFont != (Object)null)
								{
									Logger.LogInfo((object)"[CustomStaminaStats] Загружен кастомный шрифт Chewy");
									return;
								}
							}
						}
						Logger.LogWarning((object)"[CustomStaminaStats] Не удалось загрузить кастомный шрифт");
					}
					TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
					TextMeshProUGUI[] array2 = array;
					foreach (TextMeshProUGUI val2 in array2)
					{
						if (((Object)val2).name == "InteractNameText" || ((Object)val2).name == "InteractPromptText" || ((Object)val2).name == "ItemPromptMain")
						{
							_gameFont = ((TMP_Text)val2).font;
							_textMaterial = ((Graphic)val2).material;
							ManualLogSource logger = Logger;
							TMP_FontAsset gameFont = _gameFont;
							logger.LogInfo((object)("[CustomStaminaStats] Используем игровой шрифт: " + ((gameFont != null) ? ((Object)gameFont).name : null)));
							return;
						}
					}
					TMP_FontAsset[] array3 = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
					if (array3.Length != 0)
					{
						_gameFont = array3[0];
						Logger.LogInfo((object)("[CustomStaminaStats] Используем первый доступный шрифт: " + ((Object)_gameFont).name));
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка поиска шрифта: " + ex.Message));
				}
			}

			private static void SetupGameTextStyle(TextMeshProUGUI text, int fontSize, TextAlignmentOptions alignment)
			{
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Expected O, but got Unknown
				if ((Object)(object)text == (Object)null || (Object)(object)((Component)text).gameObject == (Object)null)
				{
					return;
				}
				((TMP_Text)text).fontSize = fontSize;
				((TMP_Text)text).alignment = alignment;
				((TMP_Text)text).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)text).overflowMode = (TextOverflowModes)0;
				((Graphic)text).color = Color.white;
				((Graphic)text).raycastTarget = false;
				((TMP_Text)text).fontStyle = (FontStyles)1;
				if ((Object)(object)_gameFont == (Object)null)
				{
					FindGameTextStyle();
				}
				((TMP_Text)text).font = _gameFont;
				bool flag = true;
				if ((Object)(object)((TMP_Text)text).fontMaterial != (Object)null && ((Object)((TMP_Text)text).fontMaterial).name.EndsWith("_IsolatedMaterial"))
				{
					flag = false;
				}
				else if ((Object)(object)((TMP_Text)text).fontMaterial != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((TMP_Text)text).fontMaterial);
				}
				if (flag && (Object)(object)((TMP_Text)text).font != (Object)null && (Object)(object)((TMP_Asset)((TMP_Text)text).font).material != (Object)null)
				{
					try
					{
						Material val = new Material(((TMP_Asset)((TMP_Text)text).font).material);
						((Object)val).name = ((Object)((Component)text).gameObject).name + "_IsolatedMaterial";
						((TMP_Text)text).fontMaterial = val;
					}
					catch (Exception ex)
					{
						Logger.LogError((object)("[CustomStaminaStats] Ошибка создания материала: " + ex.Message));
					}
				}
				((TMP_Text)text).outlineWidth = _outlineThickness;
				((TMP_Text)text).outlineColor = Color32.op_Implicit(Color.black);
				Shadow component = ((Component)text).gameObject.GetComponent<Shadow>();
				if ((Object)(object)component == (Object)null)
				{
					component = ((Component)text).gameObject.AddComponent<Shadow>();
					component.effectColor = new Color(0f, 0f, 0f, 0.95f);
					component.effectDistance = new Vector2(2f, -2f);
				}
			}

			private static void RemoveDestroyedReferences()
			{
				//IL_0062: 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_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: 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_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					List<STATUSTYPE> list = new List<STATUSTYPE>();
					foreach (KeyValuePair<STATUSTYPE, TextMeshProUGUI> statusText in _statusTexts)
					{
						if ((Object)(object)statusText.Value == (Object)null || (Object)(object)((Component)statusText.Value).gameObject == (Object)null || !Object.op_Implicit((Object)(object)((Component)statusText.Value).gameObject))
						{
							list.Add(statusText.Key);
						}
					}
					foreach (STATUSTYPE item in list)
					{
						_statusTexts.Remove(item);
						_lastStatusValues.Remove(item);
					}
					List<STATUSTYPE> list2 = new List<STATUSTYPE>();
					foreach (KeyValuePair<STATUSTYPE, BarAffliction> cachedAffliction in _cachedAfflictions)
					{
						if ((Object)(object)cachedAffliction.Value == (Object)null || (Object)(object)((Component)cachedAffliction.Value).gameObject == (Object)null || !Object.op_Implicit((Object)(object)((Component)cachedAffliction.Value).gameObject))
						{
							list2.Add(cachedAffliction.Key);
						}
					}
					foreach (STATUSTYPE item2 in list2)
					{
						_cachedAfflictions.Remove(item2);
					}
					if ((Object)(object)_staminaText != (Object)null && ((Object)(object)((Component)_staminaText).gameObject == (Object)null || !Object.op_Implicit((Object)(object)((Component)_staminaText).gameObject)))
					{
						_staminaText = null;
						_lastStaminaValue = -1f;
					}
					if ((Object)(object)_canvas != (Object)null && ((Object)(object)((Component)_canvas).gameObject == (Object)null || !Object.op_Implicit((Object)(object)((Component)_canvas).gameObject)))
					{
						_canvas = null;
					}
					if ((Object)(object)_observedCharacter != (Object)null && (Object)(object)((Component)_observedCharacter).gameObject == (Object)null)
					{
						_observedCharacter = null;
					}
					if ((Object)(object)_staminaBar != (Object)null && ((Object)(object)((Component)_staminaBar).gameObject == (Object)null || !Object.op_Implicit((Object)(object)((Component)_staminaBar).gameObject)))
					{
						_staminaBar = null;
					}
					Logger.LogInfo((object)$"[CustomStaminaStats] Очищено {list.Count} статусов и {list2.Count} аффликций");
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка в RemoveDestroyedReferences: " + ex.Message));
				}
			}

			private static void SetupTMPOutline(TextMeshProUGUI text, float outlineThickness)
			{
				//IL_00ab: 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_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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)
				if ((Object)(object)((TMP_Text)text).fontMaterial == (Object)null)
				{
					return;
				}
				try
				{
					((TMP_Text)text).fontMaterial.EnableKeyword("OUTLINE_ON");
					((TMP_Text)text).fontMaterial.SetFloat("_OutlineWidth", outlineThickness);
					((TMP_Text)text).fontMaterial.SetColor("_OutlineColor", Color.black);
					((TMP_Text)text).outlineWidth = outlineThickness;
					((TMP_Text)text).outlineColor = Color32.op_Implicit(Color.black);
					((TMP_Text)text).fontMaterial.renderQueue = 3000;
					((Graphic)text).SetMaterialDirty();
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка настройки outline: " + ex.Message));
					((TMP_Text)text).outlineWidth = outlineThickness;
					((TMP_Text)text).outlineColor = Color32.op_Implicit(Color.black);
				}
			}

			public static void UpdateAll()
			{
				if (Time.time - _lastCleanupTime >= CLEANUP_INTERVAL)
				{
					RemoveDestroyedReferences();
					_lastCleanupTime = Time.time;
				}
				if (!_enabled || (Object)(object)_canvas == (Object)null)
				{
					return;
				}
				try
				{
					if (_forceHidden)
					{
						if (((Component)_canvas).gameObject.activeSelf)
						{
							((Component)_canvas).gameObject.SetActive(false);
						}
						return;
					}
					if (!((Component)_canvas).gameObject.activeSelf)
					{
						((Component)_canvas).gameObject.SetActive(true);
					}
					if ((Object)(object)_observedCharacter == (Object)null || (Object)(object)_observedCharacter != (Object)(object)Character.observedCharacter)
					{
						_observedCharacter = Character.observedCharacter;
						if ((Object)(object)_observedCharacter == (Object)null)
						{
							HideAllTexts();
							return;
						}
					}
					if ((Object)(object)_staminaBar == (Object)null)
					{
						GUIManager instance = GUIManager.instance;
						if ((Object)(object)instance != (Object)null && (Object)(object)instance.bar != (Object)null)
						{
							_staminaBar = instance.bar;
							CacheAfflictions();
						}
					}
					UpdateStaminaText();
					UpdateStatusTexts();
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка обновления: " + ex.Message));
				}
			}

			private static void CacheAfflictions()
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				_cachedAfflictions.Clear();
				if ((Object)(object)_staminaBar == (Object)null || _staminaBar.afflictions == null)
				{
					return;
				}
				BarAffliction[] afflictions = _staminaBar.afflictions;
				foreach (BarAffliction val in afflictions)
				{
					if ((Object)(object)val != (Object)null)
					{
						_cachedAfflictions[val.afflictionType] = val;
					}
				}
			}

			private static void CreateCanvas()
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Expected O, but got Unknown
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_canvas != (Object)null))
				{
					GameObject val = new GameObject("CustomStaminaStatsCanvas");
					Object.DontDestroyOnLoad((Object)(object)val);
					_canvas = val.AddComponent<Canvas>();
					_canvas.renderMode = (RenderMode)0;
					_canvas.sortingOrder = 100;
					((Component)_canvas).gameObject.SetActive(false);
					CanvasScaler val2 = val.AddComponent<CanvasScaler>();
					val2.uiScaleMode = (ScaleMode)1;
					val2.referenceResolution = new Vector2(1920f, 1080f);
					val2.screenMatchMode = (ScreenMatchMode)1;
					val.AddComponent<GraphicRaycaster>();
					val.layer = LayerMask.NameToLayer("UI");
					Logger.LogInfo((object)"[CustomStaminaStats] Canvas создан");
				}
			}

			private static TextMeshProUGUI CreateTextElement(string name, Transform parent, Vector2 anchoredPosition, TextAlignmentOptions alignment = 514, int fontSize = -1)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				//IL_003f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				if (fontSize == -1)
				{
					fontSize = _fontSize;
				}
				GameObject val = new GameObject(name);
				val.transform.SetParent(parent, false);
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				RectTransform component = ((Component)val2).GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.5f, 0.5f);
				component.anchorMax = new Vector2(0.5f, 0.5f);
				component.pivot = new Vector2(0.5f, 0.5f);
				component.sizeDelta = new Vector2(80f, 30f);
				component.anchoredPosition = anchoredPosition;
				SetupGameTextStyle(val2, fontSize, alignment);
				return val2;
			}

			private static void UpdateStaminaText()
			{
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: 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)
				if ((Object)(object)_observedCharacter == (Object)null || (Object)(object)_staminaBar == (Object)null || (Object)(object)_staminaBar.staminaBar == (Object)null)
				{
					HideStaminaText();
					return;
				}
				try
				{
					if (_observedCharacter.data.fullyPassedOut || _observedCharacter.data.dead || !((Component)_staminaBar.staminaBar).gameObject.activeSelf)
					{
						HideStaminaText();
						return;
					}
					float num = _observedCharacter.data.currentStamina * 100f;
					float num2 = _observedCharacter.GetMaxStamina() * 100f;
					if ((Object)(object)_staminaText == (Object)null)
					{
						Vector2 anchoredPosition = default(Vector2);
						((Vector2)(ref anchoredPosition))..ctor(0f, 0f);
						_staminaText = CreateTextElement("CustomStaminaText", ((Component)_canvas).transform, anchoredPosition, (TextAlignmentOptions)514, _fontSize + 2);
					}
					if (Math.Abs(num - _lastStaminaValue) > 0.1f || ((TMP_Text)_staminaText).text == "")
					{
						_lastStaminaValue = num;
						((TMP_Text)_staminaText).text = (_showPercent ? $"{Math.Round(num, 0):F0}%" : $"{Math.Round(num, 0):F0}");
						float num3 = num / num2;
						if (num3 < 0.25f)
						{
							((Graphic)_staminaText).color = new Color(1f, 0.3f, 0.3f);
						}
						else if (num3 < 0.5f)
						{
							((Graphic)_staminaText).color = new Color(1f, 0.92f, 0.016f);
						}
						else
						{
							((Graphic)_staminaText).color = new Color(0.5f, 1f, 0.5f);
						}
					}
					PositionStaminaText();
					((Component)_staminaText).gameObject.SetActive(true);
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка обновления выносливости: " + ex.Message));
				}
			}

			private static void PositionStaminaText()
			{
				//IL_0062: 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_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_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: 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)
				if ((Object)(object)_staminaBar == (Object)null || (Object)(object)_staminaBar.staminaBar == (Object)null || (Object)(object)_staminaText == (Object)null)
				{
					return;
				}
				try
				{
					Transform transform = ((Component)_staminaBar.staminaBar).transform;
					RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if (!((Object)(object)val == (Object)null))
					{
						Rect rect = val.rect;
						Vector3 val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
						Vector2 val3 = RectTransformUtility.WorldToScreenPoint(_canvas.worldCamera, val2);
						val3.y -= 30f;
						Transform transform2 = ((Component)_canvas).transform;
						Vector2 anchoredPosition = default(Vector2);
						if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform2 is RectTransform) ? transform2 : null), val3, _canvas.worldCamera, ref anchoredPosition))
						{
							((TMP_Text)_staminaText).rectTransform.anchoredPosition = anchoredPosition;
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка позиционирования стамины: " + ex.Message));
				}
			}

			private static void UpdateStatusTexts()
			{
				//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_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: 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)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				//IL_0208: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_observedCharacter == (Object)null || (Object)(object)_staminaBar == (Object)null)
				{
					HideAllStatusTexts();
					return;
				}
				try
				{
					CharacterAfflictions afflictions = _observedCharacter.refs.afflictions;
					if ((Object)(object)afflictions == (Object)null)
					{
						return;
					}
					Vector2 anchoredPosition = default(Vector2);
					foreach (STATUSTYPE value5 in Enum.GetValues(typeof(STATUSTYPE)))
					{
						float num = afflictions.GetCurrentStatus(value5) * 100f;
						if (num > 0f)
						{
							BarAffliction value = null;
							if (!_cachedAfflictions.TryGetValue(value5, out value) || (Object)(object)value == (Object)null)
							{
								BarAffliction[] afflictions2 = _staminaBar.afflictions;
								foreach (BarAffliction val2 in afflictions2)
								{
									if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf && val2.afflictionType == value5)
									{
										value = val2;
										_cachedAfflictions[value5] = val2;
										break;
									}
								}
							}
							if ((Object)(object)value == (Object)null || !((Component)value).gameObject.activeSelf)
							{
								if (_statusTexts.ContainsKey(value5))
								{
									((Component)_statusTexts[value5]).gameObject.SetActive(false);
								}
								continue;
							}
							float value2 = 0f;
							_lastStatusValues.TryGetValue(value5, out value2);
							if (!_statusTexts.TryGetValue(value5, out var value3) || (Object)(object)value3 == (Object)null)
							{
								((Vector2)(ref anchoredPosition))..ctor(0f, -200f);
								value3 = CreateTextElement($"Custom{(object)value5}Text", ((Component)_canvas).transform, anchoredPosition, (TextAlignmentOptions)514);
								if (StatusColors.TryGetValue(value5, out var value4))
								{
									((Graphic)value3).color = value4;
								}
								_statusTexts[value5] = value3;
							}
							if (Math.Abs(num - value2) > 0.1f || ((TMP_Text)value3).text == "")
							{
								_lastStatusValues[value5] = num;
								((TMP_Text)value3).text = (_showPercent ? $"{Math.Round(num, 0):F0}%" : $"{Math.Round(num, 0):F0}");
							}
							((Component)value3).gameObject.SetActive(true);
							PositionStatusText(value5, value3, value);
						}
						else if (_statusTexts.ContainsKey(value5))
						{
							((Component)_statusTexts[value5]).gameObject.SetActive(false);
							_lastStatusValues[value5] = 0f;
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка обновления статусов: " + ex.Message));
				}
			}

			private static void PositionStatusText(STATUSTYPE statusType, TextMeshProUGUI text, BarAffliction affliction)
			{
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: 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_0088: 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)
				if ((Object)(object)affliction == (Object)null || (Object)(object)text == (Object)null)
				{
					return;
				}
				try
				{
					Transform transform = ((Component)affliction).transform;
					RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if (!((Object)(object)val == (Object)null))
					{
						Rect rect = val.rect;
						Vector3 val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
						Vector2 val3 = RectTransformUtility.WorldToScreenPoint(_canvas.worldCamera, val2);
						val3.y -= 25f;
						Transform transform2 = ((Component)_canvas).transform;
						Vector2 anchoredPosition = default(Vector2);
						if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform2 is RectTransform) ? transform2 : null), val3, _canvas.worldCamera, ref anchoredPosition))
						{
							((TMP_Text)text).rectTransform.anchoredPosition = anchoredPosition;
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)$"[CustomStaminaStats] Ошибка позиционирования статуса {statusType}: {ex.Message}");
				}
			}

			private static void HideAllTexts()
			{
				if ((Object)(object)_staminaText != (Object)null)
				{
					((Component)_staminaText).gameObject.SetActive(false);
				}
				foreach (TextMeshProUGUI value in _statusTexts.Values)
				{
					if ((Object)(object)value != (Object)null)
					{
						((Component)value).gameObject.SetActive(false);
					}
				}
			}

			private static void HideStaminaText()
			{
				if ((Object)(object)_staminaText != (Object)null)
				{
					((Component)_staminaText).gameObject.SetActive(false);
				}
			}

			private static void HideAllStatusTexts()
			{
				foreach (TextMeshProUGUI value in _statusTexts.Values)
				{
					if ((Object)(object)value != (Object)null)
					{
						((Component)value).gameObject.SetActive(false);
					}
				}
			}

			public static void Cleanup()
			{
				try
				{
					foreach (TextMeshProUGUI value in _statusTexts.Values)
					{
						if ((Object)(object)value != (Object)null)
						{
							if ((Object)(object)((Graphic)value).material != (Object)null)
							{
								Object.Destroy((Object)(object)((Graphic)value).material);
							}
							Object.Destroy((Object)(object)((Component)value).gameObject);
						}
					}
					_statusTexts.Clear();
					_lastStatusValues.Clear();
					if ((Object)(object)_staminaText != (Object)null)
					{
						if ((Object)(object)((Graphic)_staminaText).material != (Object)null)
						{
							Object.Destroy((Object)(object)((Graphic)_staminaText).material);
						}
						Object.Destroy((Object)(object)((Component)_staminaText).gameObject);
						_staminaText = null;
					}
					if ((Object)(object)_canvas != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)_canvas).gameObject);
						_canvas = null;
					}
					_observedCharacter = null;
					_staminaBar = null;
					_cachedAfflictions.Clear();
					_textMaterial = null;
					_lastStaminaValue = -1f;
					_forceHidden = false;
					Logger.LogInfo((object)"[CustomStaminaStats] Очищено");
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка очистки: " + ex.Message));
				}
			}

			public static void SetVisible(bool visible)
			{
				try
				{
					_forceHidden = !visible;
					if (!((Object)(object)_canvas != (Object)null))
					{
						return;
					}
					((Component)_canvas).gameObject.SetActive(visible);
					if (visible)
					{
						Canvas.ForceUpdateCanvases();
						UpdateAll();
						if ((Object)(object)_staminaText != (Object)null)
						{
							((Component)_staminaText).gameObject.SetActive(true);
						}
						{
							foreach (TextMeshProUGUI value in _statusTexts.Values)
							{
								if ((Object)(object)value != (Object)null)
								{
									((Component)value).gameObject.SetActive(true);
								}
							}
							return;
						}
					}
					HideAllTexts();
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("[CustomStaminaStats] Ошибка установки видимости: " + ex.Message));
				}
			}

			public static void UpdateSettings(bool enabled, bool showPercent, int fontSize, float outline)
			{
				_enabled = enabled;
				_showPercent = showPercent;
				_fontSize = fontSize;
				_outlineThickness = outline;
				UpdateAllTextsStyle();
			}

			private static void UpdateAllTextsStyle()
			{
				if ((Object)(object)_staminaText != (Object)null)
				{
					((TMP_Text)_staminaText).fontSize = _fontSize + 2;
					SetupTMPOutline(_staminaText, _outlineThickness);
				}
				foreach (TextMeshProUGUI value in _statusTexts.Values)
				{
					if ((Object)(object)value != (Object)null)
					{
						((TMP_Text)value).fontSize = _fontSize;
						SetupTMPOutline(value, _outlineThickness);
					}
				}
			}
		}

		public enum ToggleKey
		{
			[Description("F1")]
			F1,
			[Description("F2")]
			F2,
			[Description("F3")]
			F3,
			[Description("F4")]
			F4,
			[Description("F5")]
			F5,
			[Description("F6")]
			F6,
			[Description("F7")]
			F7,
			[Description("F8")]
			F8,
			[Description("F9")]
			F9,
			[Description("F10")]
			F10,
			[Description("F11")]
			F11,
			[Description("F12")]
			F12,
			[Description("Insert")]
			Insert,
			[Description("Delete")]
			Delete,
			[Description("Home")]
			Home,
			[Description("End")]
			End,
			[Description("Page Up")]
			PageUp,
			[Description("Page Down")]
			PageDown,
			[Description("` (BackQuote)")]
			BackQuote,
			[Description("/ (Slash)")]
			Slash,
			[Description("\\ (Backslash)")]
			Backslash,
			[Description("Alpha1 (1)")]
			Alpha1,
			[Description("Alpha2 (2)")]
			Alpha2,
			[Description("Alpha3 (3)")]
			Alpha3,
			[Description("Alpha4 (4)")]
			Alpha4,
			[Description("Alpha5 (5)")]
			Alpha5,
			[Description("Alpha6 (6)")]
			Alpha6,
			[Description("Alpha7 (7)")]
			Alpha7,
			[Description("Alpha8 (8)")]
			Alpha8,
			[Description("Alpha9 (9)")]
			Alpha9,
			[Description("Alpha0 (0)")]
			Alpha0,
			[Description("Minus (-)")]
			Minus,
			[Description("Equals (=)")]
			Equals,
			[Description("Backspace")]
			Backspace,
			[Description("Tab")]
			Tab,
			[Description("Caps Lock")]
			CapsLock,
			[Description("Left Shift")]
			LeftShift,
			[Description("Right Shift")]
			RightShift,
			[Description("Left Ctrl")]
			LeftControl,
			[Description("Right Ctrl")]
			RightControl,
			[Description("Left Alt")]
			LeftAlt,
			[Description("Right Alt")]
			RightAlt,
			[Description("Space")]
			Space,
			[Description("Enter")]
			Return,
			[Description("Escape")]
			Escape,
			[Description("Print Screen")]
			Print,
			[Description("Scroll Lock")]
			ScrollLock,
			[Description("Pause")]
			Pause,
			[Description("Num Lock")]
			Numlock,
			[Description("NumPad 0")]
			Keypad0,
			[Description("NumPad 1")]
			Keypad1,
			[Description("NumPad 2")]
			Keypad2,
			[Description("NumPad 3")]
			Keypad3,
			[Description("NumPad 4")]
			Keypad4,
			[Description("NumPad 5")]
			Keypad5,
			[Description("NumPad 6")]
			Keypad6,
			[Description("NumPad 7")]
			Keypad7,
			[Description("NumPad 8")]
			Keypad8,
			[Description("NumPad 9")]
			Keypad9,
			[Description("NumPad .")]
			KeypadPeriod,
			[Description("NumPad /")]
			KeypadDivide,
			[Description("NumPad *")]
			KeypadMultiply,
			[Description("NumPad -")]
			KeypadMinus,
			[Description("NumPad +")]
			KeypadPlus,
			[Description("NumPad Enter")]
			KeypadEnter,
			[Description("NumPad =")]
			KeypadEquals,
			[Description("Up Arrow")]
			UpArrow,
			[Description("Down Arrow")]
			DownArrow,
			[Description("Left Arrow")]
			LeftArrow,
			[Description("Right Arrow")]
			RightArrow
		}

		private static HashSet<string> _transparencyElements = new HashSet<string> { "MoraleBoost", "ConnectionLog", "Spectating" };

		private ConfigEntry<ToggleKey> _toggleKeyConfig;

		private ConfigEntry<float> _checkIntervalConfig;

		private ConfigEntry<bool> _letterboxConfig;

		private GameObject _cachedCanvasLetterbox;

		private ConfigEntry<bool> _barGroupConfig;

		private ConfigEntry<bool> _barGroupMushroomsConfig;

		private ConfigEntry<bool> _inventoryConfig;

		private ConfigEntry<bool> _promptsConfig;

		private ConfigEntry<bool> _useItemConfig;

		private ConfigEntry<bool> _useItemFriendTFConfig;

		private ConfigEntry<bool> _dayNightTextConfig;

		private ConfigEntry<bool> _reticlesConfig;

		private ConfigEntry<bool> _spectatingConfig;

		private ConfigEntry<bool> _heroConfig;

		private ConfigEntry<bool> _theFogRisesConfig;

		private ConfigEntry<bool> _theLavaRisesConfig;

		private ConfigEntry<bool> _endgameConfig;

		private ConfigEntry<bool> _connectionLogConfig;

		private ConfigEntry<bool> _ascentUIConfig;

		private ConfigEntry<bool> _timerHeightUIConfig;

		private ConfigEntry<bool> _customStaminaEnabled;

		private ConfigEntry<bool> _customStaminaShowPercent;

		private ConfigEntry<int> _customStaminaFontSize;

		private ConfigEntry<float> _customStaminaOutline;

		private ConfigEntry<bool> _canvasBetterPingDistanceConfig;

		private ConfigEntry<bool> _canvasPassedOutMarkersConfig;

		private HashSet<string> _managedElements = new HashSet<string>();

		private static Dictionary<string, GameObject> _cachedExtraCanvases = new Dictionary<string, GameObject>();

		private static Dictionary<string, bool> _extraCanvasOriginalStates = new Dictionary<string, bool>();

		private static HashSet<string> _currentlyHidden = new HashSet<string>();

		private static Dictionary<string, bool> _originalStates = new Dictionary<string, bool>();

		private static bool _isCleanModeActive = false;

		private static GameObject _cachedCanvasHUD;

		private static GameObject _cachedCanvasHero;

		private static float _nextCheckTime = 0f;

		private KeyCode _currentToggleKey;

		private float _currentCheckInterval;

		private bool _configsDirty = true;

		private static Harmony _harmony;

		private void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Мод " + ((BaseUnityPlugin)this).Info.Metadata.Name + " v1.0.0 загружен!"));
			InitializeConfig();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			CustomStaminaStats.SetFontBundlePath(directoryName);
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			SceneManager.sceneLoaded += OnSceneLoaded;
			((MonoBehaviour)this).InvokeRepeating("UpdateCustomStaminaStats", 0.5f, 0.0167f);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Сцена загружена: " + ((Scene)(ref scene)).name));
			_cachedCanvasHUD = null;
			_cachedCanvasHero = null;
			_cachedCanvasLetterbox = null;
			_cachedExtraCanvases.Clear();
			_originalStates.Clear();
			_currentlyHidden.Clear();
			_extraCanvasOriginalStates.Clear();
			ForceShowCustomStaminaOnGameScenes(scene);
			if (_isCleanModeActive)
			{
				_isCleanModeActive = false;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Сброшен чистый режим из-за смены сцены");
			}
			if (((Scene)(ref scene)).name == "Airport" || ((Scene)(ref scene)).name == "Title")
			{
				ClearCustomStaminaCache();
			}
		}

		private void ClearCustomStaminaCache()
		{
			try
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Очистка кэша CustomStaminaStats (сцена Airport)");
				CustomStaminaStats.ResetCache();
				if (_customStaminaEnabled.Value)
				{
					UpdateCustomStaminaSettings();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка очистки кэша CustomStaminaStats: " + ex.Message));
			}
		}

		private bool IsFogOrLavaElement(string elementName)
		{
			return elementName == "TheFogRises" || elementName == "TheLavaRises";
		}

		private void HandleAnimatedElements(bool hide)
		{
			try
			{
				if (_theFogRisesConfig.Value)
				{
					Transform val = FindInCanvasHUD("TheFogRises");
					if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(false);
						_currentlyHidden.Add("TheFogRises");
						((BaseUnityPlugin)this).Logger.LogInfo((object)"TheFogRises скрыт");
					}
				}
				if (_theLavaRisesConfig.Value)
				{
					Transform val2 = FindInCanvasHUD("TheLavaRises");
					if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf)
					{
						((Component)val2).gameObject.SetActive(false);
						_currentlyHidden.Add("TheLavaRises");
						((BaseUnityPlugin)this).Logger.LogInfo((object)"TheLavaRises скрыт");
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка обработки анимированных элементов: " + ex.Message));
			}
		}

		private void UpdateCustomStaminaStats()
		{
			try
			{
				if (_customStaminaEnabled.Value)
				{
					CustomStaminaStats.UpdateAll();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("UpdateCustomStaminaStats error: " + ex.Message));
				((MonoBehaviour)this).CancelInvoke("UpdateCustomStaminaStats");
			}
		}

		private void InitializeConfig()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Expected O, but got Unknown
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_toggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<ToggleKey>("General", "Toggle Key", ToggleKey.F1, new ConfigDescription("Клавиша для переключения Чистого режима.", (AcceptableValueBase)null, Array.Empty<object>()));
				_checkIntervalConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Check Interval", 1f, new ConfigDescription("Частота проверок в чистом режиме (в секундах).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
				_letterboxConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Letterbox", false, "Enable Canvas_Letterbox (black bars) in Clean Mode");
				_barGroupConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "BarGroup", true, "Hide health bars, hunger, thirst, etc.");
				_barGroupMushroomsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "BarGroup_Mushrooms", false, "Hide mushroom strips (if any)");
				_inventoryConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Inventory", true, "Hide inventory");
				_promptsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Prompts", true, "Hide hints (E - take, F - use, etc.)");
				_useItemConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "UseItem", true, "Hide the use of items");
				_useItemFriendTFConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "UseItemFriendTF", false, "Hide the use of items on friends");
				_dayNightTextConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "DayNightText", true, "Hide the day/night text");
				_reticlesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Reticles", true, "Hide sights in the center of the screen");
				_spectatingConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Spectating", true, "Hide the switching interface behind players at death");
				_heroConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Hero", true, "Hide the name interface at the beginning of the biome");
				_theFogRisesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "TheFogRises", true, "Hide the message about the rising fog");
				_theLavaRisesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "TheLavaRises", true, "Hide a message about rising lava");
				_endgameConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Endgame", true, "Hide the end-of-game interface");
				_connectionLogConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "ConnectionLog", true, "Hide the connection log of other players");
				_ascentUIConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "AscentUI", true, "Hide the interface of the ascension number");
				_timerHeightUIConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Main HUD", "Timer & Height UI", true, "Hide timer and height (mod PeakStats)");
				_customStaminaEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Stamina Stats", "Enabled", false, "Enable digital statuses and endurance values");
				_customStaminaShowPercent = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Stamina Stats", "ShowPercentage", false, "Show the percentage sign (%) after the values");
				_customStaminaFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Stamina Stats", "FontSize", 16, new ConfigDescription("Font Size", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 32), Array.Empty<object>()));
				_customStaminaOutline = ((BaseUnityPlugin)this).Config.Bind<float>("Custom Stamina Stats", "OutlineThickness", 0.15f, new ConfigDescription("The thickness of the text outline", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.5f), Array.Empty<object>()));
				_canvasBetterPingDistanceConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra Canvas", "Canvas_BetterPingDistance", false, "Hide distances from ping (mod BetterPingDistance)");
				_canvasPassedOutMarkersConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra Canvas", "Canvas_PassedOutMarkers", false, "Hide the markers of players who have lost consciousness (mod DownedAwareness)");
				CustomStaminaStats.Initialize(_customStaminaEnabled.Value, _customStaminaShowPercent.Value, _customStaminaFontSize.Value, _customStaminaOutline.Value);
				_barGroupConfig.SettingChanged += MarkConfigsDirty;
				_barGroupMushroomsConfig.SettingChanged += MarkConfigsDirty;
				_inventoryConfig.SettingChanged += MarkConfigsDirty;
				_promptsConfig.SettingChanged += MarkConfigsDirty;
				_useItemConfig.SettingChanged += MarkConfigsDirty;
				_useItemFriendTFConfig.SettingChanged += MarkConfigsDirty;
				_dayNightTextConfig.SettingChanged += MarkConfigsDirty;
				_reticlesConfig.SettingChanged += MarkConfigsDirty;
				_spectatingConfig.SettingChanged += MarkConfigsDirty;
				_heroConfig.SettingChanged += MarkConfigsDirty;
				_theFogRisesConfig.SettingChanged += MarkConfigsDirty;
				_theLavaRisesConfig.SettingChanged += MarkConfigsDirty;
				_endgameConfig.SettingChanged += MarkConfigsDirty;
				_connectionLogConfig.SettingChanged += MarkConfigsDirty;
				_ascentUIConfig.SettingChanged += MarkConfigsDirty;
				_timerHeightUIConfig.SettingChanged += MarkConfigsDirty;
				_customStaminaEnabled.SettingChanged += delegate
				{
					UpdateCustomStaminaSettings();
				};
				_customStaminaShowPercent.SettingChanged += delegate
				{
					UpdateCustomStaminaSettings();
				};
				_customStaminaFontSize.SettingChanged += delegate
				{
					UpdateCustomStaminaSettings();
				};
				_customStaminaOutline.SettingChanged += delegate
				{
					UpdateCustomStaminaSettings();
				};
				_letterboxConfig.SettingChanged += delegate
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Конфиг Letterbox изменен: {_letterboxConfig.Value}");
					if (_isCleanModeActive)
					{
						ManageCanvasLetterbox(_letterboxConfig.Value);
					}
				};
				_toggleKeyConfig.SettingChanged += delegate
				{
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					_currentToggleKey = (KeyCode)Enum.Parse(typeof(KeyCode), _toggleKeyConfig.Value.ToString());
				};
				_checkIntervalConfig.SettingChanged += delegate
				{
					_currentCheckInterval = _checkIntervalConfig.Value;
				};
				_canvasBetterPingDistanceConfig.SettingChanged += OnExtraCanvasConfigChanged;
				_canvasPassedOutMarkersConfig.SettingChanged += OnExtraCanvasConfigChanged;
				_currentToggleKey = (KeyCode)Enum.Parse(typeof(KeyCode), _toggleKeyConfig.Value.ToString());
				_currentCheckInterval = _checkIntervalConfig.Value;
				UpdateManagedElements();
				_configsDirty = false;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Конфигурация загружена! Custom Stamina Stats готов!");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Ошибка инициализации: {arg}");
			}
		}

		private void UpdateCustomStaminaSettings()
		{
			if (_customStaminaEnabled.Value)
			{
				CustomStaminaStats.ResetCache();
			}
			CustomStaminaStats.UpdateSettings(_customStaminaEnabled.Value, _customStaminaShowPercent.Value, _customStaminaFontSize.Value, _customStaminaOutline.Value);
		}

		private void MarkConfigsDirty(object sender = null, EventArgs e = null)
		{
			_configsDirty = true;
		}

		private void OnExtraCanvasConfigChanged(object sender, EventArgs e)
		{
			if (sender is ConfigEntry<bool> val)
			{
				string key = ((ConfigEntryBase)val).Definition.Key;
				bool value = val.Value;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Конфиг {key} изменен: {value}");
				if (!value && _isCleanModeActive)
				{
					RestoreExtraCanvas(key);
				}
			}
		}

		private void OnDestroy()
		{
			try
			{
				CustomStaminaStats.Cleanup();
				((MonoBehaviour)this).CancelInvoke("UpdateCustomStaminaStats");
				try
				{
					SceneManager.sceneLoaded -= OnSceneLoaded;
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Ошибка отписки от sceneLoaded: " + ex.Message));
				}
				if (_harmony != null)
				{
					_harmony.UnpatchSelf();
					_harmony = null;
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"SelectiveHiderPlugin выгружен");
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка в OnDestroy: " + ex2.Message));
			}
		}

		private void UpdateManagedElements()
		{
			_managedElements.Clear();
			if (_barGroupConfig.Value)
			{
				_managedElements.Add("BarGroup");
			}
			if (_barGroupMushroomsConfig.Value)
			{
				_managedElements.Add("BarGroup_Mushrooms");
			}
			if (_inventoryConfig.Value)
			{
				_managedElements.Add("Inventory");
			}
			if (_promptsConfig.Value)
			{
				_managedElements.Add("Prompts");
			}
			if (_useItemConfig.Value)
			{
				_managedElements.Add("UseItem");
			}
			if (_useItemFriendTFConfig.Value)
			{
				_managedElements.Add("UseItemFriendTF");
			}
			if (_dayNightTextConfig.Value)
			{
				_managedElements.Add("DayNightText");
			}
			if (_reticlesConfig.Value)
			{
				_managedElements.Add("Reticles");
			}
			if (_spectatingConfig.Value)
			{
				_managedElements.Add("Spectating");
			}
			if (_heroConfig.Value)
			{
				_managedElements.Add("Hero");
			}
			if (_theFogRisesConfig.Value)
			{
				_managedElements.Add("TheFogRises");
			}
			if (_theLavaRisesConfig.Value)
			{
				_managedElements.Add("TheLavaRises");
			}
			if (_endgameConfig.Value)
			{
				_managedElements.Add("Endgame");
			}
			if (_connectionLogConfig.Value)
			{
				_managedElements.Add("ConnectionLog");
			}
			if (_ascentUIConfig.Value)
			{
				_managedElements.Add("AscentUI");
			}
			if (_timerHeightUIConfig.Value)
			{
				_managedElements.Add("Timer & Height UI");
			}
		}

		private void Update()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (_configsDirty)
			{
				UpdateManagedElements();
				_configsDirty = false;
			}
			if (Input.GetKeyDown(_currentToggleKey))
			{
				ToggleHudMode();
			}
			if (_isCleanModeActive && Time.time >= _nextCheckTime)
			{
				EnforceCleanMode();
				_nextCheckTime = Time.time + _currentCheckInterval;
			}
		}

		private void ToggleHudMode()
		{
			try
			{
				_isCleanModeActive = !_isCleanModeActive;
				if (_isCleanModeActive)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"=== АКТИВАЦИЯ ЧИСТОГО РЕЖИМА ===");
					_cachedCanvasLetterbox = null;
					ApplyCleanMode();
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"=== ВЫХОД ИЗ ЧИСТОГО РЕЖИМА ===");
					ApplyNormalMode();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка переключения: " + ex.Message));
				_isCleanModeActive = false;
				ApplyNormalMode();
			}
		}

		private GameObject FindExtraCanvas(string canvasName)
		{
			if (_cachedExtraCanvases.TryGetValue(canvasName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			GameObject val = GameObject.Find(canvasName);
			if ((Object)(object)val != (Object)null)
			{
				_cachedExtraCanvases[canvasName] = val;
			}
			return val;
		}

		private void HideExtraCanvas(string canvasName, ConfigEntry<bool> config)
		{
			if (!config.Value)
			{
				return;
			}
			GameObject val = FindExtraCanvas(canvasName);
			if ((Object)(object)val != (Object)null && val.activeSelf)
			{
				if (!_extraCanvasOriginalStates.ContainsKey(canvasName))
				{
					_extraCanvasOriginalStates[canvasName] = val.activeSelf;
				}
				val.SetActive(false);
				_currentlyHidden.Add(canvasName);
			}
		}

		private void RestoreExtraCanvas(string canvasName)
		{
			GameObject val = FindExtraCanvas(canvasName);
			if ((Object)(object)val != (Object)null)
			{
				if (_extraCanvasOriginalStates.TryGetValue(canvasName, out var value))
				{
					val.SetActive(value);
				}
				else
				{
					val.SetActive(true);
				}
				_currentlyHidden.Remove(canvasName);
			}
		}

		private void RestoreAllExtraCanvases()
		{
			foreach (string item in _currentlyHidden.ToList())
			{
				if (item.StartsWith("Canvas_"))
				{
					RestoreExtraCanvas(item);
				}
			}
		}

		private void ApplyCleanMode()
		{
			try
			{
				_currentlyHidden.Clear();
				_originalStates.Clear();
				_extraCanvasOriginalStates.Clear();
				TransparencyManager.Cleanup();
				_cachedCanvasLetterbox = null;
				_cachedCanvasHUD = GameObject.Find("Canvas_HUD");
				if ((Object)(object)_cachedCanvasHUD == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Canvas_HUD не найден!");
					return;
				}
				foreach (string managedElement in _managedElements)
				{
					if (IsFogOrLavaElement(managedElement) || managedElement == "MoraleBoost")
					{
						continue;
					}
					Transform val = FindInCanvasHUD(managedElement);
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					if (_transparencyElements.Contains(managedElement))
					{
						if (managedElement != "Spectating" && managedElement != "ConnectionLog" && !_originalStates.ContainsKey(managedElement))
						{
							_originalStates[managedElement] = ((Component)val).gameObject.activeSelf;
						}
						TransparencyManager.SetTransparent(((Component)val).gameObject, transparent: true);
						_currentlyHidden.Add(managedElement + "_transparent");
						if (!_originalStates.ContainsKey(managedElement))
						{
							_originalStates[managedElement] = ((Component)val).gameObject.activeSelf;
						}
					}
					else
					{
						if (!_originalStates.ContainsKey(managedElement))
						{
							_originalStates[managedElement] = ((Component)val).gameObject.activeSelf;
						}
						if (((Component)val).gameObject.activeSelf)
						{
							((Component)val).gameObject.SetActive(false);
							_currentlyHidden.Add(managedElement);
						}
					}
				}
				HandleAnimatedElements(hide: true);
				if (_barGroupConfig.Value && _managedElements.Contains("BarGroup"))
				{
					Transform val2 = _cachedCanvasHUD.transform.Find("BarGroup");
					if ((Object)(object)val2 != (Object)null)
					{
						Transform val3 = val2.Find("Bar/MoraleBoost");
						if ((Object)(object)val3 != (Object)null)
						{
							TransparencyManager.SetTransparent(((Component)val3).gameObject, transparent: true);
							_currentlyHidden.Add("MoraleBoost_transparent");
						}
					}
				}
				if (_barGroupConfig.Value)
				{
					CustomStaminaStats.SetVisible(visible: false);
					_originalStates["CustomStaminaStats"] = true;
				}
				else
				{
					_originalStates["CustomStaminaStats"] = true;
				}
				HideExtraCanvas("Canvas_BetterPingDistance", _canvasBetterPingDistanceConfig);
				HideExtraCanvas("Canvas_PassedOutMarkers", _canvasPassedOutMarkersConfig);
				ManageCanvasHero(hide: true);
				ManageCanvasLetterbox(enableInCleanMode: true);
				Canvas.ForceUpdateCanvases();
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Чистый режим активирован. Скрыто элементов: {_currentlyHidden.Count}");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка ApplyCleanMode: " + ex.Message));
			}
		}

		private void ApplyNormalMode()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			try
			{
				_currentlyHidden.Remove("TheFogRises");
				_currentlyHidden.Remove("TheLavaRises");
				if ((Object)(object)_cachedCanvasHUD != (Object)null)
				{
					foreach (Transform item in _cachedCanvasHUD.transform)
					{
						Transform val = item;
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						string name = ((Object)val).name;
						bool value;
						if (_currentlyHidden.Contains(name + "_transparent"))
						{
							TransparencyManager.SetTransparent(((Component)val).gameObject, transparent: false);
							_currentlyHidden.Remove(name + "_transparent");
						}
						else if (_originalStates.TryGetValue(name, out value))
						{
							if (name == "Spectating" || name == "ConnectionLog")
							{
								_currentlyHidden.Remove(name);
							}
							else if (((Component)val).gameObject.activeSelf != value)
							{
								((Component)val).gameObject.SetActive(value);
							}
						}
					}
				}
				ManageCanvasHero(hide: false);
				if (_currentlyHidden.Contains("MoraleBoost_transparent"))
				{
					GameObject cachedCanvasHUD = _cachedCanvasHUD;
					Transform val2 = ((cachedCanvasHUD != null) ? cachedCanvasHUD.transform.Find("BarGroup") : null);
					Transform val3 = ((val2 != null) ? val2.Find("Bar/MoraleBoost") : null);
					if ((Object)(object)val3 != (Object)null)
					{
						TransparencyManager.SetTransparent(((Component)val3).gameObject, transparent: false);
					}
				}
				if (_heroConfig.Value && (Object)(object)_cachedCanvasHero != (Object)null)
				{
					TransparencyManager.SetTransparent(_cachedCanvasHero, transparent: false);
				}
				ManageCanvasLetterbox(enableInCleanMode: false);
				RestoreAllExtraCanvases();
				if (_customStaminaEnabled.Value)
				{
					bool flag = _barGroupConfig.Value && _originalStates.ContainsKey("CustomStaminaStats") && _originalStates["CustomStaminaStats"];
					if (!_barGroupConfig.Value || flag)
					{
						CustomStaminaStats.SetVisible(visible: true);
					}
					else
					{
						CustomStaminaStats.SetVisible(visible: false);
					}
				}
				else
				{
					CustomStaminaStats.SetVisible(visible: false);
				}
				_currentlyHidden.Clear();
				_originalStates.Clear();
				_extraCanvasOriginalStates.Clear();
				_cachedCanvasHUD = null;
				_cachedCanvasHero = null;
				_cachedCanvasLetterbox = null;
				_cachedExtraCanvases.Clear();
				TransparencyManager.Cleanup();
				Canvas.ForceUpdateCanvases();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Обычный режим восстановлен!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка ApplyNormalMode: " + ex.Message));
			}
		}

		[Obsolete]
		private GameObject GetCanvasLetterbox()
		{
			if ((Object)(object)_cachedCanvasLetterbox != (Object)null)
			{
				return _cachedCanvasLetterbox;
			}
			Canvas[] array = Object.FindObjectsOfType<Canvas>(true);
			Canvas[] array2 = array;
			foreach (Canvas val in array2)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name == "Canvas_Letterbox")
				{
					_cachedCanvasLetterbox = ((Component)val).gameObject;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Найден Canvas_Letterbox (активен: {_cachedCanvasLetterbox.activeSelf})");
					return _cachedCanvasLetterbox;
				}
			}
			GameObject[] array3 = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array4 = array3;
			foreach (GameObject val2 in array4)
			{
				if ((Object)(object)val2 != (Object)null && ((Object)val2).name == "Canvas_Letterbox")
				{
					_cachedCanvasLetterbox = val2;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Найден Canvas_Letterbox через общий поиск (активен: {_cachedCanvasLetterbox.activeSelf})");
					return _cachedCanvasLetterbox;
				}
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Canvas_Letterbox не найден!");
			return null;
		}

		private void ManageCanvasLetterbox(bool enableInCleanMode)
		{
			if (!_letterboxConfig.Value)
			{
				return;
			}
			GameObject canvasLetterbox = GetCanvasLetterbox();
			if ((Object)(object)canvasLetterbox == (Object)null)
			{
				return;
			}
			try
			{
				bool value;
				if (_isCleanModeActive)
				{
					if (enableInCleanMode)
					{
						if (!_originalStates.ContainsKey("Canvas_Letterbox"))
						{
							_originalStates["Canvas_Letterbox"] = canvasLetterbox.activeSelf;
							((BaseUnityPlugin)this).Logger.LogInfo((object)$"Запомнено исходное состояние Canvas_Letterbox: {canvasLetterbox.activeSelf}");
						}
						if (!canvasLetterbox.activeSelf)
						{
							canvasLetterbox.SetActive(true);
							_currentlyHidden.Add("Canvas_Letterbox");
							((BaseUnityPlugin)this).Logger.LogInfo((object)"Canvas_Letterbox активирован в чистом режиме");
						}
					}
				}
				else if (_originalStates.TryGetValue("Canvas_Letterbox", out value))
				{
					if (canvasLetterbox.activeSelf != value)
					{
						canvasLetterbox.SetActive(value);
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Canvas_Letterbox восстановлен в исходное состояние: {value}");
					}
					_currentlyHidden.Remove("Canvas_Letterbox");
				}
				else if (canvasLetterbox.activeSelf)
				{
					canvasLetterbox.SetActive(false);
					_currentlyHidden.Remove("Canvas_Letterbox");
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Canvas_Letterbox выключен (исходное состояние не найдено)");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка управления Canvas_Letterbox: " + ex.Message));
			}
		}

		private void ForceShowCustomStaminaOnGameScenes(Scene scene)
		{
			if (((Scene)(ref scene)).name.StartsWith("Level_") && _customStaminaEnabled.Value)
			{
				CustomStaminaStats.SetVisible(visible: true);
			}
		}

		private GameObject GetCanvasHero()
		{
			if ((Object)(object)_cachedCanvasHero == (Object)null)
			{
				_cachedCanvasHero = GameObject.Find("Canvas_Hero");
			}
			return _cachedCanvasHero;
		}

		private void ManageCanvasHero(bool hide)
		{
			if (!_heroConfig.Value)
			{
				return;
			}
			GameObject canvasHero = GetCanvasHero();
			if ((Object)(object)canvasHero == (Object)null)
			{
				return;
			}
			try
			{
				if (hide)
				{
					if (!_originalStates.ContainsKey("Canvas_Hero"))
					{
						_originalStates["Canvas_Hero"] = canvasHero.activeSelf;
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Запомнено состояние Canvas_Hero: {canvasHero.activeSelf}");
					}
					if (canvasHero.activeSelf)
					{
						canvasHero.SetActive(false);
						_currentlyHidden.Add("Canvas_Hero");
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Canvas_Hero скрыт");
					}
					return;
				}
				if (_originalStates.TryGetValue("Canvas_Hero", out var value))
				{
					if (canvasHero.activeSelf != value)
					{
						canvasHero.SetActive(value);
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Canvas_Hero восстановлен в состояние: {value}");
					}
				}
				else if (!canvasHero.activeSelf)
				{
					canvasHero.SetActive(true);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Canvas_Hero включен (состояние не найдено)");
				}
				_currentlyHidden.Remove("Canvas_Hero");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Ошибка управления Canvas_Hero: " + ex.Message));
			}
		}

		private Transform FindInCanvasHUD(string name, bool includeInactive = true)
		{
			if ((Object)(object)_cachedCanvasHUD == (Object)null)
			{
				return null;
			}
			Transform val = _cachedCanvasHUD.transform.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			if (includeInactive)
			{
				Transform[] componentsInChildren = _cachedCanvasHUD.GetComponentsInChildren<Transform>(true);
				Transform[] array = componentsInChildren;
				foreach (Transform val2 in array)
				{
					if ((Object)(object)val2 != (Object)null && ((Object)val2).name == name)
					{
						return val2;
					}
				}
			}
			return null;
		}

		private void EnforceCleanMode()
		{
			if (!_isCleanModeActive)
			{
				return;
			}
			try
			{
				if (_barGroupConfig.Value)
				{
					CustomStaminaStats.SetVisible(visible: false);
				}
				if ((Object)(object)_cachedCanvasHUD == (Object)null)
				{
					_cachedCanvasHUD = GameObject.Find("Canvas_HUD");
				}
				if ((Object)(object)_cachedCanvasHUD != (Object)null)
				{
					foreach (string managedElement in _managedElements)
					{
						if (IsFogOrLavaElement(managedElement) || managedElement == "MoraleBoost")
						{
							continue;
						}
						Transform val = FindInCanvasHUD(managedElement);
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						if (_transparencyElements.Contains(managedElement))
						{
							CanvasGroup component = ((Component)val).GetComponent<CanvasGroup>();
							if ((Object)(object)component == (Object)null || component.alpha > 0.01f)
							{
								TransparencyManager.SetTransparent(((Component)val).gameObject, transparent: true);
								if (!_currentlyHidden.Contains(managedElement + "_transparent"))
								{
									_currentlyHidden.Add(managedElement + "_transparent");
								}
								if (!_originalStates.ContainsKey(managedElement))
								{
									_originalStates[managedElement] = ((Component)val).gameObject.activeSelf;
								}
							}
						}
						else if (((Component)val).gameObject.activeSelf)
						{
							if (!_originalStates.ContainsKey(managedElement))
							{
								_originalStates[managedElement] = true;
							}
							((Component)val).gameObject.SetActive(false);
							if (!_currentlyHidden.Contains(managedElement))
							{
								_currentlyHidden.Add(managedElement);
							}
						}
					}
				}
				if (_theFogRisesConfig.Value)
				{
					Transform val2 = FindInCanvasHUD("TheFogRises");
					if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf)
					{
						((Component)val2).gameObject.SetActive(false);
						if (!_currentlyHidden.Contains("TheFogRises"))
						{
							_currentlyHidden.Add("TheFogRises");
						}
					}
				}
				if (_theLavaRisesConfig.Value)
				{
					Transform val3 = FindInCanvasHUD("TheLavaRises");
					if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeSelf)
					{
						((Component)val3).gameObject.SetActive(false);
						if (!_currentlyHidden.Contains("TheLavaRises"))
						{
							_currentlyHidden.Add("TheLavaRises");
						}
					}
				}
				if (_heroConfig.Value)
				{
					GameObject canvasHero = GetCanvasHero();
					if ((Object)(object)canvasHero != (Object)null && canvasHero.activeSelf)
					{
						canvasHero.SetActive(false);
						_currentlyHidden.Add("Canvas_Hero");
					}
				}
				if (_letterboxConfig.Value)
				{
					GameObject canvasLetterbox = GetCanvasLetterbox();
					if ((Object)(object)canvasLetterbox != (Object)null)
					{
						if (!_originalStates.ContainsKey("Canvas_Letterbox"))
						{
							_originalStates["Canvas_Letterbox"] = canvasLetterbox.activeSelf;
						}
						if (!canvasLetterbox.activeSelf)
						{
							canvasLetterbox.SetActive(true);
							_currentlyHidden.Add("Canvas_Letterbox");
						}
					}
				}
				if (_canvasBetterPingDistanceConfig.Value)
				{
					GameObject val4 = FindExtraCanvas("Canvas_BetterPingDistance");
					if ((Object)(object)val4 != (Object)null && val4.activeSelf)
					{
						val4.SetActive(false);
						_currentlyHidden.Add("Canvas_BetterPingDistance");
					}
				}
				if (_canvasPassedOutMarkersConfig.Value)
				{
					GameObject val5 = FindExtraCanvas("Canvas_PassedOutMarkers");
					if ((Object)(object)val5 != (Object)null && val5.activeSelf)
					{
						val5.SetActive(false);
						_currentlyHidden.Add("Canvas_PassedOutMarkers");
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Ошибка EnforceCleanMode: " + ex.Message));
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}