Decompiled source of DisableEffect v1.0.0

DisableEffect.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DisableEffect
{
	internal sealed class Inst
	{
		public Entry E;

		public bool Indicator;

		public bool Enemy;

		public bool ProjPart;
	}
	internal sealed class HiddenRenderer
	{
		public Renderer R;

		public Inst I;

		public HiddenRenderer(Renderer r, Inst i)
		{
			R = r;
			I = i;
		}
	}
	internal sealed class HiddenBehaviour
	{
		public Behaviour B;

		public Inst I;

		public HiddenBehaviour(Behaviour b, Inst i)
		{
			B = b;
			I = i;
		}
	}
	internal sealed class Binding
	{
		private string _text;

		private Key _key;

		private bool _ok;

		public bool Pressed(Keyboard kb, string text)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			if (text != _text)
			{
				_text = text;
				_ok = Enum.TryParse<Key>(text, ignoreCase: true, out _key) && (int)_key > 0;
				if (!_ok)
				{
					Plugin.Logger.LogWarning((object)("Disable effect: '" + text + "' is not a key name (use e.g. F8, F9, Backquote)"));
				}
			}
			if (_ok)
			{
				return ((ButtonControl)kb[_key]).wasPressedThisFrame;
			}
			return false;
		}
	}
	internal static class Controller
	{
		public static readonly string[] Categories = new string[9] { "Blood Magic", "Chaos Magic", "Unholy Magic", "Illusion Magic", "Frost Magic", "Storm Magic", "Barriers & Shields", "Weapons & melee", "Other effects" };

		internal static readonly Dictionary<string, Entry> Entries = new Dictionary<string, Entry>();

		private static readonly Entry[] Buckets = new Entry[6];

		private static readonly Dictionary<int, Inst> ByInstance = new Dictionary<int, Inst>();

		private static readonly List<HiddenRenderer> HiddenRenderers = new List<HiddenRenderer>();

		private static readonly List<HiddenBehaviour> HiddenEffects = new List<HiddenBehaviour>();

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

		private static readonly HashSet<string> RuleMine = new HashSet<string>();

		private static bool _inited;

		private static bool _applied;

		private static bool _greeted;

		private static bool _rulesDirty;

		private static bool _savePending;

		private static int _warnings;

		private static int _logged;

		private static int _order = 2000;

		private static float _nextScan;

		private static float _lastAction;

		private static float _nextSave;

		private static string _settingsKey;

		private static string[] _keepWords = new string[0];

		private static string[] _keepShaders = new string[0];

		private static string[] _enemyWords = new string[0];

		private static string[] _skip = new string[0];

		private static Key[] _actionKeys = (Key[])(object)new Key[0];

		private static readonly Binding ToggleBinding = new Binding();

		private static readonly Binding MenuBinding = new Binding();

		private static bool _listening;

		private static ConfigEntry<string> _listenTarget;

		private static string _listenLabel;

		private static int _listenFrame;

		private static float _listenUntil;

		private static string _message;

		private static float _messageUntil;

		private static GUIStyle _toastStyle;

		private static readonly string[] BarrierWords = new string[2] { "Shield", "Barrier" };

		private static readonly string[] ProjectileWords = new string[2] { "Projectile", "Missile" };

		private static readonly string[] MeleeWords = new string[2] { "Melee", "Weapon" };

		private static readonly HashSet<string> Failed = new HashSet<string>();

		private static readonly Regex WordSplit = new Regex("[^A-Za-z0-9]+|(?<=[a-z0-9])(?=[A-Z])", RegexOptions.Compiled);

		private static readonly Regex TrailingNumber = new Regex("[\\s_\\-]*\\(?\\d+\\)?$", RegexOptions.Compiled);

		private static readonly string[] GenericNames = new string[29]
		{
			"root", "container", "effects", "vfx", "fx", "spawned", "instances", "holder", "manager", "world",
			"scene", "global", "dynamic", "pooled", "parent", "particles", "objects", "gameobject", "game", "main",
			"level", "gameplay", "client", "clientworld", "default", "temp", "tmp", "dontdestroyonload", "cameraparent"
		};

		private static string RulesPath => Path.Combine(Paths.ConfigPath, "local.disableeffect.rules.txt");

		internal static bool Listening => _listening;

		private static bool PartOnly => string.Equals(Plugin.ProjectileMode.Value, "PartOnly", StringComparison.OrdinalIgnoreCase);

		internal static string Message
		{
			get
			{
				if (_message == null || !(Time.unscaledTime < _messageUntil))
				{
					return null;
				}
				return _message;
			}
		}

		internal static void Init()
		{
			if (_inited)
			{
				return;
			}
			_inited = true;
			foreach (Entry spell in SpellDb.Spells)
			{
				Entries[spell.Id] = spell;
			}
			for (int i = 0; i < Buckets.Length; i++)
			{
				Entry entry = new Entry
				{
					Id = "school:" + SpellDb.SchoolWords[i].ToLowerInvariant(),
					Name = "Other " + SpellDb.Schools[i].Replace(" Magic", "") + " effects (not matched to a spell)",
					Category = i,
					School = i,
					IsSpell = true,
					Order = 1000 + i
				};
				Buckets[i] = entry;
				Entries[entry.Id] = entry;
			}
			LoadRules();
		}

		internal static void Fail(string where, Exception e)
		{
			if (Failed.Add(where))
			{
				string[] array = (e.StackTrace ?? "").Split('\n');
				int num = Math.Min(array.Length, 6);
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < num; i++)
				{
					stringBuilder.Append(" | ").Append(array[i].Trim());
				}
				Plugin.Logger.LogWarning((object)("Disable effect: '" + where + "' failed: " + e.GetType().Name + ": " + e.Message + stringBuilder));
			}
		}

		internal static void Tick()
		{
			try
			{
				TickCore();
			}
			catch (Exception e)
			{
				Fail("update", e);
			}
		}

		private static void TickCore()
		{
			Init();
			float unscaledTime = Time.unscaledTime;
			PollKeys();
			if (_savePending && unscaledTime >= _nextSave)
			{
				_savePending = false;
				SaveRules();
			}
			if (_rulesDirty)
			{
				ReleaseUnhidden();
				_rulesDirty = false;
			}
			bool isOpen = Ui.IsOpen;
			if (!Plugin.Enabled.Value && !isOpen)
			{
				if (_applied)
				{
					RestoreAll();
					_applied = false;
				}
				return;
			}
			_applied = Plugin.Enabled.Value;
			if (!(unscaledTime < _nextScan))
			{
				_nextScan = unscaledTime + Math.Max(0.05f, Plugin.ScanInterval.Value);
				Sweep(unscaledTime, isOpen);
			}
		}

		private static void PollKeys()
		{
			if (!_greeted)
			{
				_greeted = true;
				Say(Plugin.MenuKey.Value + " opens the effects menu, " + Plugin.ToggleKey.Value + " turns hiding on/off", 6f);
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				if (_listening)
				{
					ListenForNewKey(current);
				}
				else if (MenuBinding.Pressed(current, Plugin.MenuKey.Value))
				{
					ToggleMenu();
				}
				else if (ToggleBinding.Pressed(current, Plugin.ToggleKey.Value))
				{
					ToggleEnabled();
				}
				else if (Ui.IsOpen)
				{
					Ui.HandleKeys(current);
				}
				else
				{
					LearnInput(current);
				}
			}
		}

		internal static void ToggleMenu()
		{
			if (!Plugin.EnableMenu.Value)
			{
				Say("The menu is switched off in the config (General / EnableMenu)", 4f);
			}
			else
			{
				Ui.SetOpen(!Ui.IsOpen);
			}
		}

		internal static void ToggleEnabled()
		{
			Plugin.Enabled.Value = !Plugin.Enabled.Value;
			_rulesDirty = true;
			Plugin.Logger.LogInfo((object)("Disable effect: " + (Plugin.Enabled.Value ? "ON" : "OFF")));
			Say("Disable effect: " + (Plugin.Enabled.Value ? "ON" : "OFF"), 2f);
		}

		internal static void Flip(ConfigEntry<bool> option)
		{
			option.Value = !option.Value;
			_rulesDirty = true;
		}

		private static void LearnInput(Keyboard kb)
		{
			//IL_0041: 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)
			bool flag = false;
			Mouse current = Mouse.current;
			if (current != null && (current.leftButton.wasPressedThisFrame || current.rightButton.wasPressedThisFrame || current.middleButton.wasPressedThisFrame))
			{
				flag = true;
			}
			Key[] actionKeys = _actionKeys;
			foreach (Key val in actionKeys)
			{
				try
				{
					if (((ButtonControl)kb[val]).wasPressedThisFrame)
					{
						flag = true;
					}
				}
				catch (Exception)
				{
				}
			}
			if (flag)
			{
				_lastAction = Time.unscaledTime;
			}
		}

		internal static void StartListening(ConfigEntry<string> target, string label)
		{
			_listening = true;
			_listenTarget = target;
			_listenLabel = label;
			_listenFrame = Time.frameCount;
			_listenUntil = Time.unscaledTime + 10f;
			Say("Press the new " + label + " (Esc cancels)", 10f);
		}

		private static void ListenForNewKey(Keyboard kb)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008b: Invalid comparison between Unknown and I4
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount == _listenFrame)
			{
				return;
			}
			if (Time.unscaledTime > _listenUntil || ((ButtonControl)kb.escapeKey).wasPressedThisFrame)
			{
				_listening = false;
				Say("Key not changed", 2f);
				return;
			}
			string b = ((_listenTarget == Plugin.ToggleKey) ? Plugin.MenuKey.Value : Plugin.ToggleKey.Value);
			foreach (Key value in Enum.GetValues(typeof(Key)))
			{
				if ((int)value != 0 && (int)value != 111)
				{
					bool wasPressedThisFrame;
					try
					{
						wasPressedThisFrame = ((ButtonControl)kb[value]).wasPressedThisFrame;
					}
					catch (Exception)
					{
						continue;
					}
					if (wasPressedThisFrame && !string.Equals(((object)value/*cast due to .constrained prefix*/).ToString(), b, StringComparison.OrdinalIgnoreCase))
					{
						_listenTarget.Value = ((object)value/*cast due to .constrained prefix*/).ToString();
						_listening = false;
						Say(_listenLabel + " is now " + ((object)value/*cast due to .constrained prefix*/).ToString(), 3f);
						break;
					}
				}
			}
		}

		internal static List<Entry> EntriesOf(int cat)
		{
			List<Entry> list = new List<Entry>();
			if (cat >= 0 && cat < 6)
			{
				foreach (Entry spell in SpellDb.Spells)
				{
					if (spell.School == cat)
					{
						list.Add(spell);
					}
				}
				list.Add(Buckets[cat]);
				return list;
			}
			if (cat == 6)
			{
				foreach (Entry spell2 in SpellDb.Spells)
				{
					if (spell2.Barrier)
					{
						list.Add(spell2);
					}
				}
			}
			List<Entry> list2 = new List<Entry>();
			foreach (Entry value in Entries.Values)
			{
				if (!value.IsSpell && value.Category == cat)
				{
					list2.Add(value);
				}
			}
			list2.Sort((Entry a, Entry b) => a.Order.CompareTo(b.Order));
			if (list2.Count > 300)
			{
				list2.RemoveRange(300, list2.Count - 300);
			}
			list.AddRange(list2);
			return list;
		}

		internal static bool IsLocked(Entry e)
		{
			if (e.Who == Who.Enemy)
			{
				return true;
			}
			if (e.Who == Who.Indicator && Plugin.KeepIndicators.Value)
			{
				return true;
			}
			if (e.Projectile && Plugin.KeepProjectiles.Value && !PartOnly)
			{
				return true;
			}
			if (Plugin.KeepBarriers.Value && (e.Barrier || (!e.IsSpell && e.Category == 6)))
			{
				return true;
			}
			return false;
		}

		internal static string TagsOf(Entry e)
		{
			List<string> list = new List<string>();
			if (e.Projectile)
			{
				list.Add((!Plugin.KeepProjectiles.Value) ? "projectile" : (PartOnly ? "projectile (its projectile part stays visible)" : "projectile - kept visible"));
			}
			if (e.Barrier || (!e.IsSpell && e.Category == 6))
			{
				list.Add(Plugin.KeepBarriers.Value ? "barrier - kept visible" : "barrier");
			}
			if (e.Who == Who.Enemy)
			{
				list.Add("enemy - kept visible");
			}
			if (e.Who == Who.Indicator)
			{
				list.Add(Plugin.KeepIndicators.Value ? "indicator - kept visible" : "indicator");
			}
			if (e.IsSpell && e.Mine)
			{
				list.Add("cast by you");
			}
			if (!e.IsSpell && e.Kind.Length > 0 && list.Count == 0)
			{
				list.Add(e.Kind);
			}
			return string.Join(", ", list.ToArray());
		}

		internal static void Counts(int cat, out int hidden, out int total)
		{
			hidden = 0;
			total = 0;
			foreach (Entry item in EntriesOf(cat))
			{
				total++;
				if (item.Hide && !IsLocked(item))
				{
					hidden++;
				}
			}
		}

		internal static void ToggleEntry(Entry e)
		{
			if (IsLocked(e))
			{
				Say(e.Name + " stays visible (see the options at the top)", 3f);
				return;
			}
			e.Hide = !e.Hide;
			e.Decided = true;
			Changed();
		}

		internal static void SetCategoryHidden(int cat, bool hide)
		{
			foreach (Entry item in EntriesOf(cat))
			{
				if (!IsLocked(item) && item.Hide != hide)
				{
					item.Hide = hide;
					item.Decided = true;
				}
			}
			Say(hide ? ("Hid everything allowed in " + Categories[cat]) : ("Showing everything in " + Categories[cat]), 2.5f);
			Changed();
		}

		private static void Changed()
		{
			_rulesDirty = true;
			_savePending = true;
			_nextSave = Time.unscaledTime + 0.5f;
		}

		internal static void Say(string text, float seconds)
		{
			if (Plugin.ShowMessages.Value)
			{
				_message = text;
				_messageUntil = Time.unscaledTime + seconds;
			}
		}

		private static void LoadRules()
		{
			try
			{
				if (!File.Exists(RulesPath))
				{
					return;
				}
				string[] array = File.ReadAllLines(RulesPath);
				foreach (string text in array)
				{
					int num = text.IndexOf('\t');
					if (num <= 0)
					{
						continue;
					}
					string text2 = text.Substring(0, num);
					string text3 = text.Substring(num + 1);
					if (text3.Length != 0)
					{
						switch (text2)
						{
						case "mine":
							RuleMine.Add(text3);
							break;
						case "hide":
						case "show":
							RuleHide[text3] = text2 == "hide";
							break;
						}
					}
				}
				foreach (KeyValuePair<string, bool> item in RuleHide)
				{
					if (!Entries.TryGetValue(item.Key, out var value))
					{
						if (!item.Key.StartsWith("kind:"))
						{
							continue;
						}
						value = NewDynamic(item.Key.Substring(5), "", "(not seen yet this session)", 8);
					}
					value.Hide = item.Value;
					value.Decided = true;
				}
				foreach (string item2 in RuleMine)
				{
					if (Entries.TryGetValue(item2, out var value2))
					{
						value2.Mine = true;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Disable effect: could not read rules: " + ex.Message));
			}
		}

		private static void SaveRules()
		{
			try
			{
				List<string> list = new List<string>();
				foreach (Entry value in Entries.Values)
				{
					if (value.Decided)
					{
						list.Add((value.Hide ? "hide" : "show") + "\t" + value.Id);
					}
					if (value.Mine)
					{
						list.Add("mine\t" + value.Id);
					}
				}
				File.WriteAllLines(RulesPath, list.ToArray());
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("Disable effect: could not save rules: " + ex.Message));
			}
		}

		private static Entry NewDynamic(string key, string kind, string sample, int category)
		{
			string text = "kind:" + key;
			if (Entries.TryGetValue(text, out var value))
			{
				return value;
			}
			value = new Entry
			{
				Id = text,
				Name = key,
				Kind = kind,
				Sample = sample,
				Category = category,
				Order = _order++
			};
			Entries[text] = value;
			return value;
		}

		private static void RefreshSettings()
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			string text = Plugin.KeepPatterns.Value + "|" + Plugin.KeepShaders.Value + "|" + Plugin.EnemyPatterns.Value + "|" + Plugin.ExcludePatterns.Value + "|" + Plugin.ActionKeys.Value + "|" + Plugin.KeyDepth.Value;
			if (text == _settingsKey)
			{
				return;
			}
			_settingsKey = text;
			_keepWords = SplitList(Plugin.KeepPatterns.Value);
			_keepShaders = SplitList(Plugin.KeepShaders.Value);
			_enemyWords = SplitList(Plugin.EnemyPatterns.Value);
			_skip = SplitList(Plugin.ExcludePatterns.Value);
			List<Key> list = new List<Key>();
			string[] array = SplitList(Plugin.ActionKeys.Value);
			foreach (string text2 in array)
			{
				if (Enum.TryParse<Key>(text2, ignoreCase: true, out Key result) && (int)result != 0)
				{
					list.Add(result);
				}
				else
				{
					Plugin.Logger.LogWarning((object)("Disable effect: ActionKeys has an unknown key '" + text2 + "'"));
				}
			}
			_actionKeys = list.ToArray();
			ByInstance.Clear();
		}

		private static void Sweep(float now, bool uiOpen)
		{
			RefreshSettings();
			bool actionRecent = !uiOpen && now - _lastAction <= Math.Max(0.1f, Plugin.ActionWindow.Value);
			foreach (Entry value in Entries.Values)
			{
				value.Live = 0;
			}
			if (ByInstance.Count > 20000)
			{
				ByInstance.Clear();
			}
			foreach (ParticleSystem item in Object.FindObjectsOfType<ParticleSystem>())
			{
				ParticleSystemRenderer component = ((Component)item).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				Inst inst = InstFor((Component)(object)item, "particle", (Renderer)(object)component, null, actionRecent);
				if (inst != null)
				{
					inst.E.Live++;
					inst.E.LastSeen = now;
					if (((Renderer)component).enabled && ShouldHide(inst))
					{
						((Renderer)component).enabled = false;
						HiddenRenderers.Add(new HiddenRenderer((Renderer)(object)component, inst));
					}
				}
			}
			foreach (VisualEffect item2 in Object.FindObjectsOfType<VisualEffect>())
			{
				Inst inst2 = InstFor((Component)(object)item2, "vfx", null, item2, actionRecent);
				if (inst2 != null)
				{
					inst2.E.Live++;
					inst2.E.LastSeen = now;
					if (((Behaviour)item2).enabled && ShouldHide(inst2))
					{
						((Behaviour)item2).enabled = false;
						HiddenEffects.Add(new HiddenBehaviour((Behaviour)(object)item2, inst2));
					}
				}
			}
			Prune();
		}

		private static Inst InstFor(Component c, string kind, Renderer r, VisualEffect fx, bool actionRecent)
		{
			int instanceID = ((Object)c).GetInstanceID();
			if (ByInstance.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			string shader = (((Object)(object)r != (Object)null) ? ShaderName(r) : "");
			string matInfo = (((Object)(object)r != (Object)null) ? MaterialInfo(r) : (((Object)(object)fx != (Object)null) ? AssetName(fx) : ""));
			value = Classify(c, kind, shader, matInfo, actionRecent);
			ByInstance[instanceID] = value;
			return value;
		}

		private static Inst Classify(Component c, string kind, string shader, string matInfo, bool actionRecent)
		{
			string text = PathOf(c.transform);
			if (Matches(text, _skip))
			{
				return null;
			}
			string text2 = KeyOf(c.transform);
			Inst inst = new Inst();
			string text3 = "";
			string text4 = "";
			string text5;
			if ((Object)(object)c.GetComponentInParent<HitCircleParticleComponent>() != (Object)null)
			{
				inst.Indicator = true;
				text3 = "HitCircleParticleComponent";
			}
			else if (shader.Length > 0 && (text5 = FirstContained(shader, _keepShaders)) != null)
			{
				inst.Indicator = true;
				text3 = "shader " + text5;
			}
			else if ((text5 = FirstWordMatch(text2, _keepWords)) != null)
			{
				inst.Indicator = true;
				text3 = "word " + text5;
			}
			if (HasNpcTag(c.transform))
			{
				inst.Enemy = true;
				text4 = "NPC-tagged object";
			}
			else if ((text5 = FirstWordMatch(text2, _enemyWords)) != null)
			{
				inst.Enemy = true;
				text4 = "word " + text5;
			}
			Entry entry = SpellDb.Match(SpellDb.Normalize(text2));
			if (entry == null)
			{
				int num = SchoolOf(text2);
				entry = ((FirstWordMatch(text2, BarrierWords) != null) ? NewDynamic(text2, kind, text, 6) : ((FirstWordMatch(text2, MeleeWords) != null) ? NewDynamic(text2, kind, text, 7) : ((num < 0) ? NewDynamic(text2, kind, text, 8) : Buckets[num])));
			}
			if (entry.Kind.Length == 0)
			{
				entry.Kind = kind;
			}
			if (entry.Sample.Length == 0)
			{
				entry.Sample = text;
			}
			if (entry.IsSpell && FirstWordMatch(text2, ProjectileWords) != null)
			{
				inst.ProjPart = true;
			}
			if (!entry.IsSpell)
			{
				if (inst.Enemy)
				{
					entry.Who = Who.Enemy;
					entry.Why = text4;
				}
				else if (inst.Indicator && entry.Who == Who.Unknown)
				{
					entry.Who = Who.Indicator;
					entry.Why = text3;
				}
			}
			if (entry.IsSpell && actionRecent && !inst.Enemy && !inst.Indicator && !entry.Mine)
			{
				entry.Mine = true;
				RuleMine.Add(entry.Id);
				_savePending = true;
				_nextSave = Time.unscaledTime + 0.5f;
			}
			inst.E = entry;
			if (Plugin.LogDiscoveries.Value && _logged < 1000)
			{
				_logged++;
				Plugin.Logger.LogInfo((object)("effect [" + kind + "] -> " + entry.Name + (entry.IsSpell ? (" (" + Categories[entry.School] + ")") : (" [" + Categories[entry.Category] + "]")) + (inst.Indicator ? (" INDICATOR(" + text3 + ")") : "") + (inst.Enemy ? (" ENEMY(" + text4 + ")") : "") + (inst.ProjPart ? " PROJECTILE-PART" : "") + " key=" + text2 + " path=" + text + " | " + matInfo + " {" + ComponentNames(c) + "}"));
			}
			return inst;
		}

		private static bool ShouldHide(Inst i)
		{
			if (!Plugin.Enabled.Value)
			{
				return false;
			}
			Entry e = i.E;
			if (!e.Hide)
			{
				return false;
			}
			if (i.Enemy)
			{
				return false;
			}
			if (i.Indicator && Plugin.KeepIndicators.Value)
			{
				return false;
			}
			if (i.ProjPart && Plugin.KeepProjectiles.Value)
			{
				return false;
			}
			if (IsLocked(e))
			{
				return false;
			}
			if (e.IsSpell && Plugin.OnlyHideSpellsYouCast.Value && !e.Mine)
			{
				return false;
			}
			return true;
		}

		private static void ReleaseUnhidden()
		{
			for (int num = HiddenRenderers.Count - 1; num >= 0; num--)
			{
				HiddenRenderer hiddenRenderer = HiddenRenderers[num];
				if (!ShouldHide(hiddenRenderer.I))
				{
					try
					{
						if ((Object)(object)hiddenRenderer.R != (Object)null && !((Il2CppObjectBase)hiddenRenderer.R).WasCollected)
						{
							hiddenRenderer.R.enabled = true;
						}
					}
					catch (Exception)
					{
					}
					HiddenRenderers.RemoveAt(num);
				}
			}
			for (int num2 = HiddenEffects.Count - 1; num2 >= 0; num2--)
			{
				HiddenBehaviour hiddenBehaviour = HiddenEffects[num2];
				if (!ShouldHide(hiddenBehaviour.I))
				{
					try
					{
						if ((Object)(object)hiddenBehaviour.B != (Object)null && !((Il2CppObjectBase)hiddenBehaviour.B).WasCollected)
						{
							hiddenBehaviour.B.enabled = true;
						}
					}
					catch (Exception)
					{
					}
					HiddenEffects.RemoveAt(num2);
				}
			}
		}

		private static void RestoreAll()
		{
			foreach (HiddenRenderer hiddenRenderer in HiddenRenderers)
			{
				try
				{
					if ((Object)(object)hiddenRenderer.R != (Object)null && !((Il2CppObjectBase)hiddenRenderer.R).WasCollected)
					{
						hiddenRenderer.R.enabled = true;
					}
				}
				catch (Exception)
				{
				}
			}
			foreach (HiddenBehaviour hiddenEffect in HiddenEffects)
			{
				try
				{
					if ((Object)(object)hiddenEffect.B != (Object)null && !((Il2CppObjectBase)hiddenEffect.B).WasCollected)
					{
						hiddenEffect.B.enabled = true;
					}
				}
				catch (Exception)
				{
				}
			}
			HiddenRenderers.Clear();
			HiddenEffects.Clear();
		}

		private static void Prune()
		{
			if (HiddenRenderers.Count + HiddenEffects.Count >= 2000)
			{
				HiddenRenderers.RemoveAll((HiddenRenderer h) => IsDead((Object)(object)h.R));
				HiddenEffects.RemoveAll((HiddenBehaviour h) => IsDead((Object)(object)h.B));
			}
		}

		private static bool IsDead(Object o)
		{
			try
			{
				return o == (Object)null || ((Il2CppObjectBase)o).WasCollected;
			}
			catch (Exception)
			{
				return true;
			}
		}

		internal static void OnGui()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Ui.IsOpen)
				{
					Ui.Draw();
				}
				else if (Message != null)
				{
					if (_toastStyle == null)
					{
						_toastStyle = new GUIStyle();
						_toastStyle.fontSize = 20;
						_toastStyle.alignment = (TextAnchor)4;
						_toastStyle.normal.textColor = Color.white;
					}
					float num = 700f;
					float num2 = 42f;
					Rect val = new Rect(((float)Screen.width - num) / 2f, 60f, num, num2);
					GUI.Box(val, "");
					GUI.Label(val, Message, _toastStyle);
				}
			}
			catch (Exception e)
			{
				Fail("draw", e);
			}
		}

		private static string KeyOf(Transform t)
		{
			List<string> list = new List<string>();
			int num = 0;
			Transform val = t;
			while ((Object)(object)val != (Object)null && num < 10)
			{
				list.Insert(0, CleanName(((Object)val).name));
				val = val.parent;
				num++;
			}
			int value = Plugin.KeyDepth.Value;
			List<string> list2 = new List<string>();
			foreach (string item in list)
			{
				if (item.Length != 0 && !IsGeneric(item))
				{
					list2.Add(item);
					if (value > 0 && list2.Count >= value)
					{
						break;
					}
				}
			}
			if (list2.Count == 0 && list.Count > 0)
			{
				list2.Add((list[list.Count - 1].Length > 0) ? list[list.Count - 1] : "(unnamed)");
			}
			if (list2.Count != 0)
			{
				return string.Join(" / ", list2.ToArray());
			}
			return "(unnamed)";
		}

		private static string CleanName(string n)
		{
			n = n.Replace("(Clone)", "").Trim();
			n = TrailingNumber.Replace(n, "");
			return n.Trim(' ', '_', '-');
		}

		private static bool IsGeneric(string n)
		{
			string text = n.ToLowerInvariant();
			if (text.Contains("pool"))
			{
				return true;
			}
			string[] genericNames = GenericNames;
			foreach (string text2 in genericNames)
			{
				if (text == text2)
				{
					return true;
				}
			}
			return false;
		}

		private static bool HasNpcTag(Transform t)
		{
			int num = 0;
			Transform val = t;
			while ((Object)(object)val != (Object)null && num < 10)
			{
				try
				{
					if (((Component)val).CompareTag("NPC"))
					{
						return true;
					}
				}
				catch (Exception)
				{
					return false;
				}
				val = val.parent;
				num++;
			}
			return false;
		}

		private static int SchoolOf(string key)
		{
			string[] array = WordSplit.Split(key);
			for (int i = 0; i < SpellDb.SchoolWords.Length; i++)
			{
				bool flag = false;
				string[] array2 = array;
				for (int j = 0; j < array2.Length; j++)
				{
					if (string.Equals(array2[j], SpellDb.SchoolWords[i], StringComparison.OrdinalIgnoreCase))
					{
						flag = true;
					}
				}
				if (!flag)
				{
					continue;
				}
				if (i == 0)
				{
					bool flag2 = false;
					array2 = array;
					foreach (string a in array2)
					{
						string[] notSchoolBlood = SpellDb.NotSchoolBlood;
						foreach (string b in notSchoolBlood)
						{
							if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase))
							{
								flag2 = true;
							}
						}
					}
					if (flag2)
					{
						continue;
					}
				}
				return i;
			}
			return -1;
		}

		private static string PathOf(Transform t)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			Transform val = t;
			while ((Object)(object)val != (Object)null && num < 10)
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Insert(0, '/');
				}
				stringBuilder.Insert(0, ((Object)val).name);
				val = val.parent;
				num++;
			}
			return stringBuilder.ToString().Replace("(Clone)", "");
		}

		private static bool Matches(string path, string[] patterns)
		{
			foreach (string value in patterns)
			{
				if (path.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static string FirstContained(string text, string[] patterns)
		{
			foreach (string text2 in patterns)
			{
				if (text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return text2;
				}
			}
			return null;
		}

		private static string FirstWordMatch(string text, string[] patterns)
		{
			string[] array = WordSplit.Split(text);
			foreach (string text2 in array)
			{
				if (text2.Length == 0)
				{
					continue;
				}
				foreach (string text3 in patterns)
				{
					if (text2.StartsWith(text3, StringComparison.OrdinalIgnoreCase))
					{
						return text3;
					}
				}
			}
			return null;
		}

		private static string ShaderName(Renderer r)
		{
			try
			{
				Material sharedMaterial = r.sharedMaterial;
				return ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null) ? ((Object)sharedMaterial.shader).name : "";
			}
			catch (Exception)
			{
				return "";
			}
		}

		private static string MaterialInfo(Renderer r)
		{
			try
			{
				Material sharedMaterial = r.sharedMaterial;
				if ((Object)(object)sharedMaterial == (Object)null)
				{
					return "";
				}
				string text = ((Object)sharedMaterial).name;
				if ((Object)(object)sharedMaterial.shader != (Object)null)
				{
					text = text + " | " + ((Object)sharedMaterial.shader).name;
				}
				Texture mainTexture = sharedMaterial.mainTexture;
				if ((Object)(object)mainTexture != (Object)null)
				{
					text = text + " | " + ((Object)mainTexture).name;
				}
				return text;
			}
			catch (Exception)
			{
				return "";
			}
		}

		private static string AssetName(VisualEffect fx)
		{
			try
			{
				VisualEffectAsset visualEffectAsset = fx.visualEffectAsset;
				return ((Object)(object)visualEffectAsset == (Object)null) ? "" : ((Object)visualEffectAsset).name;
			}
			catch (Exception)
			{
				return "";
			}
		}

		private static string ComponentNames(Component c)
		{
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				foreach (Component component in c.gameObject.GetComponents<Component>())
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(',');
					}
					stringBuilder.Append(((object)component).GetType().Name);
				}
				return stringBuilder.ToString();
			}
			catch (Exception)
			{
				return "?";
			}
		}

		private static string[] SplitList(string text)
		{
			List<string> list = new List<string>();
			if (!string.IsNullOrWhiteSpace(text))
			{
				string[] array = text.Split(',');
				for (int i = 0; i < array.Length; i++)
				{
					string text2 = array[i].Trim();
					if (text2.Length > 0)
					{
						list.Add(text2);
					}
				}
			}
			return list.ToArray();
		}
	}
	internal static class Icons
	{
		private const int Size = 64;

		private static readonly Dictionary<string, Texture2D> Cache = new Dictionary<string, Texture2D>();

		internal static Texture2D For(Entry e)
		{
			if (!e.IsSpell || !e.Id.StartsWith("spell:", StringComparison.Ordinal))
			{
				return null;
			}
			string key = SpellDb.Normalize(e.Id);
			if (Cache.TryGetValue(key, out var value))
			{
				return value;
			}
			value = Load(key);
			Cache[key] = value;
			return value;
		}

		private static Texture2D Load(string key)
		{
			//IL_00dd: 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_0079: Expected O, but got Unknown
			try
			{
				using Stream stream = typeof(Icons).Assembly.GetManifestResourceStream("DisableEffect.Icons." + key + ".rgba");
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[16384];
				int i;
				int num;
				for (i = 0; i < array.Length; i += num)
				{
					num = stream.Read(array, i, array.Length - i);
					if (num <= 0)
					{
						break;
					}
				}
				if (i != array.Length)
				{
					return null;
				}
				Texture2D val = new Texture2D(64, 64, (TextureFormat)4, 1, false);
				((Object)val).hideFlags = (HideFlags)61;
				try
				{
					val.LoadRawTextureData(Il2CppStructArray<byte>.op_Implicit(array));
				}
				catch (Exception)
				{
					for (int j = 0; j < 64; j++)
					{
						for (int k = 0; k < 64; k++)
						{
							int num2 = (j * 64 + k) * 4;
							val.SetPixel(k, j, new Color((float)(int)array[num2] / 255f, (float)(int)array[num2 + 1] / 255f, (float)(int)array[num2 + 2] / 255f, (float)(int)array[num2 + 3] / 255f));
						}
					}
				}
				val.Apply();
				return val;
			}
			catch (Exception e)
			{
				Controller.Fail("icon " + key, e);
				return null;
			}
		}
	}
	internal enum Who
	{
		Unknown,
		Enemy,
		Indicator
	}
	internal sealed class Entry
	{
		public string Id;

		public string Name;

		public int Category;

		public int School = -1;

		public bool IsSpell;

		public bool Projectile;

		public bool Barrier;

		public Who Who;

		public string Why = "";

		public string Sample = "";

		public string Kind = "";

		public bool Hide;

		public bool Decided;

		public bool Mine;

		public int Live;

		public float LastSeen = -1f;

		public int Order;

		public string[] Aliases = new string[0];
	}
	internal static class Cat
	{
		public const int Barriers = 6;

		public const int Weapons = 7;

		public const int Other = 8;
	}
	internal static class SpellDb
	{
		public static readonly string[] Schools = new string[6] { "Blood Magic", "Chaos Magic", "Unholy Magic", "Illusion Magic", "Frost Magic", "Storm Magic" };

		public static readonly string[] SchoolWords = new string[6] { "Blood", "Chaos", "Unholy", "Illusion", "Frost", "Storm" };

		public static readonly string[] NotSchoolBlood = new string[11]
		{
			"Scholar", "Warrior", "Rogue", "Brute", "Creature", "Worker", "Mutant", "Draculin", "Immortal", "Corruption",
			"Type"
		};

		public static readonly List<Entry> Spells = Build();

		private static List<Entry> Build()
		{
			List<Entry> list = new List<Entry>();
			S(list, 0, "Veil of Blood", "", "veilofblood,bloodveil");
			S(list, 0, "Blood Fountain", "", "bloodfountain");
			S(list, 0, "Sanguine Coil", "P", "sanguinecoil,bloodcoil");
			S(list, 0, "Carrion Swarm", "P", "carrionswarm");
			S(list, 0, "Shadowbolt", "P", "shadowbolt");
			S(list, 0, "Blood Rite", "", "bloodrite");
			S(list, 0, "Blood Rage", "", "bloodrage");
			S(list, 0, "Crimson Beam", "", "crimsonbeam");
			S(list, 0, "Heart Strike", "", "heartstrike");
			S(list, 0, "Blood Storm", "P", "bloodstorm");
			S(list, 1, "Veil of Chaos", "", "veilofchaos,chaosveil");
			S(list, 1, "Chaos Volley", "P", "chaosvolley,partchaosprojectile");
			S(list, 1, "Power Surge", "", "powersurge,chaossurge");
			S(list, 1, "Aftershock", "", "aftershock");
			S(list, 1, "Void", "", "chaosvoid,implosion");
			S(list, 1, "Chaos Barrier", "B", "chaosbarrier,chaosshield");
			S(list, 1, "Rain of Chaos", "", "rainofchaos");
			S(list, 1, "Merciless Charge", "", "mercilesscharge");
			S(list, 1, "Chaos Barrage", "P", "chaosbarrage");
			S(list, 1, "Voidquake Vortex", "", "voidquake");
			S(list, 2, "Veil of Bones", "", "veilofbones,bonesveil,unholyveil");
			S(list, 2, "Corrupted Skull", "P", "corruptedskull,unholyskull,partunholyprojectile");
			S(list, 2, "Ward of the Damned", "B", "wardofthedamned,unholyward");
			S(list, 2, "Bone Explosion", "", "boneexplosion,corpseexplosion");
			S(list, 2, "Death Knight", "", "deathknight");
			S(list, 2, "Soulburn", "", "soulburn");
			S(list, 2, "Unholy Chains", "P", "chainsofdeath,unholychains");
			S(list, 2, "Army Of The Dead", "", "armyofthedead");
			S(list, 2, "Volatile Arachnid", "", "unstablearachnid,volatilearachnid,arachnid");
			S(list, 2, "Summon Fallen Angel", "", "fallenangel");
			S(list, 3, "Veil of Illusion", "", "veilofillusion,illusionveil");
			S(list, 3, "Spectral Wolf", "P", "spectralwolf");
			S(list, 3, "Phantom Aegis", "", "phantomaegis");
			S(list, 3, "Wraith Spear", "P", "wraithspear");
			S(list, 3, "Mosquito (Spell)", "", "mosquito");
			S(list, 3, "Mist Trance", "", "misttrance");
			S(list, 3, "Curse", "P", "illusioncurse");
			S(list, 3, "Spectral Guardian", "", "spectralguardian");
			S(list, 3, "Wisp Dance", "P", "wispdance");
			S(list, 3, "Serpent's Kiss", "P", "serpentskiss,serpentkiss,illusionserpent");
			S(list, 4, "Veil of Frost", "", "veiloffrost,frostveil");
			S(list, 4, "Frost Bat", "P", "frostbat");
			S(list, 4, "Cold Snap", "", "coldsnap");
			S(list, 4, "Ice Nova", "", "icenova");
			S(list, 4, "Crystal Lance", "P", "crystallance,icebolt");
			S(list, 4, "Frost Barrier", "B", "frostbarrier,frostshield");
			S(list, 4, "Arctic Storm", "", "arcticstorm");
			S(list, 4, "Ice Block", "", "iceblock");
			S(list, 5, "Veil of Storm", "", "veilofstorm,stormveil");
			S(list, 5, "Cyclone", "P", "cyclone");
			S(list, 5, "Discharge", "", "discharge");
			S(list, 5, "Ball Lightning", "", "balllightning");
			S(list, 5, "Polarity Shift", "", "polarityshift,polarity");
			S(list, 5, "Lightning Curtain", "", "lightningcurtain,lightningwall");
			S(list, 5, "Lightning Tendrils", "P", "lightningtendrils");
			S(list, 5, "Raging Tempest", "", "ragingtempest");
			S(list, 5, "Lightning Typhoon", "", "lightningtyphoon");
			S(list, 5, "Eye Of The Storm", "", "eyeofthestorm");
			return list;
		}

		private static void S(List<Entry> l, int school, string name, string flags, string aliases)
		{
			l.Add(new Entry
			{
				Id = "spell:" + SchoolWords[school].ToLowerInvariant() + "/" + name,
				Name = name,
				Category = school,
				School = school,
				IsSpell = true,
				Projectile = (flags.IndexOf('P') >= 0),
				Barrier = (flags.IndexOf('B') >= 0),
				Aliases = aliases.Split(','),
				Order = l.Count
			});
		}

		public static string Normalize(string s)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			foreach (char c in s)
			{
				if (char.IsLetterOrDigit(c))
				{
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			return stringBuilder.ToString();
		}

		public static Entry Match(string normalizedKey)
		{
			Entry result = null;
			int num = 0;
			foreach (Entry spell in Spells)
			{
				string[] aliases = spell.Aliases;
				foreach (string text in aliases)
				{
					if (text.Length > num && normalizedKey.Contains(text))
					{
						result = spell;
						num = text.Length;
					}
				}
			}
			return result;
		}
	}
	[BepInPlugin("local.disableeffect", "Disable effect", "0.7.0")]
	[BepInProcess("VRising.exe")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Logger;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<string> ToggleKey;

		internal static ConfigEntry<string> MenuKey;

		internal static ConfigEntry<bool> ShowMessages;

		internal static ConfigEntry<bool> EnableMenu;

		internal static ConfigEntry<bool> KeepIndicators;

		internal static ConfigEntry<bool> KeepProjectiles;

		internal static ConfigEntry<bool> KeepBarriers;

		internal static ConfigEntry<string> ProjectileMode;

		internal static ConfigEntry<bool> OnlyHideSpellsYouCast;

		internal static ConfigEntry<string> KeepPatterns;

		internal static ConfigEntry<string> KeepShaders;

		internal static ConfigEntry<string> EnemyPatterns;

		internal static ConfigEntry<string> ExcludePatterns;

		internal static ConfigEntry<int> KeyDepth;

		internal static ConfigEntry<string> ActionKeys;

		internal static ConfigEntry<float> ActionWindow;

		internal static ConfigEntry<float> ScanInterval;

		internal static ConfigEntry<bool> LogDiscoveries;

		public override void Load()
		{
			Logger = ((BasePlugin)this).Log;
			Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch. When off, nothing is hidden (the menu still works). The toggle key flips this.");
			ToggleKey = ((BasePlugin)this).Config.Bind<string>("General", "ToggleKey", "F8", "Key that turns hiding on/off (a UnityEngine.InputSystem key name). Also changeable in the menu.");
			MenuKey = ((BasePlugin)this).Config.Bind<string>("General", "MenuKey", "F9", "Key that opens/closes the menu. Also changeable in the menu.");
			EnableMenu = ((BasePlugin)this).Config.Bind<bool>("General", "EnableMenu", true, "Allow the F9 window. Set to false to run without it (hiding still works with the saved choices and the toggle key).");
			ShowMessages = ((BasePlugin)this).Config.Bind<bool>("General", "ShowMessages", true, "Show short on-screen messages (toggled, key changed, ...).");
			KeepIndicators = ((BasePlugin)this).Config.Bind<bool>("Protect", "KeepIndicators", true, "Never hide circle / aim / telegraph indicators (yours and enemies').");
			KeepProjectiles = ((BasePlugin)this).Config.Bind<bool>("Protect", "KeepProjectiles", true, "Keep projectile skills visible (Shadowbolt, Sanguine Coil, Carrion Swarm, Chaos Volley, ... see the menu).");
			KeepBarriers = ((BasePlugin)this).Config.Bind<bool>("Protect", "KeepBarriers", true, "Keep barrier / shield skills visible (Chaos Barrier, Ward of the Damned, Frost Barrier, and generic shields).");
			ProjectileMode = ((BasePlugin)this).Config.Bind<string>("Protect", "ProjectileMode", "All", "All = a projectile skill's every effect stays visible. PartOnly = only its projectile part stays visible, so its cast / hit effects can be hidden.");
			OnlyHideSpellsYouCast = ((BasePlugin)this).Config.Bind<bool>("Protect", "OnlyHideSpellsYouCast", true, "A ticked spell is only hidden once you have cast it yourself (seen right after your cast key), so an enemy using a spell you never cast stays visible.");
			KeepPatterns = ((BasePlugin)this).Config.Bind<string>("Protect", "KeepPatterns", "Warning,Marker,Telegraph,Indicator", "Comma-separated WORDS in an effect's name that mark it as an indicator (matched at the start of each CamelCase / underscore word).");
			KeepShaders = ((BasePlugin)this).Config.Bind<string>("Protect", "KeepShaders", "AimPreview", "Comma-separated text; effects drawn with a shader whose name contains it are indicators (the game's aim previews use 'AimPreview').");
			EnemyPatterns = ((BasePlugin)this).Config.Bind<string>("Protect", "EnemyPatterns", "VBlood,Boss,Enemy,Npc", "Words that mark an effect as an enemy effect (also anything under an object tagged NPC). Enemy effects are never hidden.");
			ExcludePatterns = ((BasePlugin)this).Config.Bind<string>("Protect", "ExcludePatterns", "UI,Canvas,Menu,Loading,Cursor", "Comma-separated text. Effects whose path contains any of these are ignored completely.");
			KeyDepth = ((BasePlugin)this).Config.Bind<int>("Advanced", "KeyDepth", 1, "How an effect's name is built for the lists. 1 = top-most meaningful object name, 2 = the first two, 0 = the whole path.");
			ActionKeys = ((BasePlugin)this).Config.Bind<string>("Advanced", "ActionKeys", "Q,E,R,C,T,Space,LeftShift", "Keys that count as 'you just cast something' (any mouse button always counts). Used for OnlyHideSpellsYouCast.");
			ActionWindow = ((BasePlugin)this).Config.Bind<float>("Advanced", "ActionWindowSeconds", 0.9f, "How long after a cast key / click new effects are credited to you.");
			ScanInterval = ((BasePlugin)this).Config.Bind<float>("Advanced", "ScanIntervalSeconds", 0.2f, "How often effects are looked for (minimum 0.05). Lower hides new effects sooner but costs more CPU.");
			LogDiscoveries = ((BasePlugin)this).Config.Bind<bool>("Advanced", "LogDiscoveries", false, "Log each new effect (which spell it was filed under, protections, path, material, components) to the BepInEx log (max 1000).");
			ClassInjector.RegisterTypeInIl2Cpp<EffectSweeper>();
			((BasePlugin)this).AddComponent<EffectSweeper>();
			((BasePlugin)this).Log.LogInfo((object)("Disable effect loaded. Menu key: " + MenuKey.Value + ", toggle key: " + ToggleKey.Value));
		}
	}
	public class EffectSweeper : MonoBehaviour
	{
		public EffectSweeper(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Update()
		{
			Controller.Tick();
		}

		public void OnGUI()
		{
			Controller.OnGui();
		}
	}
	internal static class Ui
	{
		private sealed class L
		{
			public float sc;

			public float pad;

			public float titleH;

			public float topH;

			public float footH;

			public float leftW;

			public float rowH;

			public float bodyY;

			public float bodyH;

			public float rx;

			public float rw;

			public float listY;

			public float viewH;
		}

		private static bool _open;

		private static int _cat;

		private static int _sel;

		private static int _top;

		private static int _visible = 5;

		private static float _x;

		private static float _y;

		private static float _w;

		private static float _h;

		private static bool _placed;

		private static bool _dragging;

		private static bool _barDrag;

		private static float _dragDx;

		private static float _dragDy;

		private static float _barDy;

		private static Texture2D _texPanel;

		private static Texture2D _texTitle;

		private static Texture2D _texRow;

		private static Texture2D _texRowSel;

		private static Texture2D _texSide;

		private static Texture2D _texBorder;

		private static Texture2D _texThumb;

		private static GUIStyle _label;

		private static GUIStyle _small;

		private static GUIStyle _head;

		private static GUIStyle _title;

		private static GUIStyle _name;

		private static GUIStyle _tagsLeft;

		private static GUIStyle _letter;

		private static GUIStyle _btnPlain;

		private static GUIStyle _btnOn;

		private static GUIStyle _btnOff;

		private static GUIStyle _btnShown;

		private static GUIStyle _btnHidden;

		private static GUIStyle _btnLocked;

		private static GUIStyle _btnCat;

		private static GUIStyle _btnCatSel;

		public static bool IsOpen => _open;

		public static void SetOpen(bool open)
		{
			_open = open;
			_dragging = false;
			_barDrag = false;
			if (open)
			{
				_sel = 0;
				_top = 0;
			}
		}

		public static void HandleKeys(Keyboard kb)
		{
			List<Entry> list = Controller.EntriesOf(_cat);
			int num = Controller.Categories.Length;
			if (((ButtonControl)kb.upArrowKey).wasPressedThisFrame)
			{
				_sel = Math.Max(0, _sel - 1);
			}
			if (((ButtonControl)kb.downArrowKey).wasPressedThisFrame)
			{
				_sel = Math.Max(0, Math.Min(list.Count - 1, _sel + 1));
			}
			if (((ButtonControl)kb.pageUpKey).wasPressedThisFrame)
			{
				_cat = (_cat + num - 1) % num;
				_sel = 0;
				_top = 0;
			}
			if (((ButtonControl)kb.pageDownKey).wasPressedThisFrame)
			{
				_cat = (_cat + 1) % num;
				_sel = 0;
				_top = 0;
			}
			if ((((ButtonControl)kb.leftArrowKey).wasPressedThisFrame || ((ButtonControl)kb.rightArrowKey).wasPressedThisFrame) && _sel >= 0 && _sel < list.Count)
			{
				Controller.ToggleEntry(list[_sel]);
			}
			if (((ButtonControl)kb.homeKey).wasPressedThisFrame)
			{
				Controller.SetCategoryHidden(_cat, hide: false);
			}
			if (((ButtonControl)kb.endKey).wasPressedThisFrame)
			{
				Controller.SetCategoryHidden(_cat, hide: true);
			}
			if (((ButtonControl)kb.escapeKey).wasPressedThisFrame)
			{
				SetOpen(open: false);
			}
			if (_sel < _top)
			{
				_top = _sel;
			}
			else if (_sel >= _top + _visible)
			{
				_top = _sel - _visible + 1;
			}
		}

		private static void Guard(string where, Action step)
		{
			try
			{
				step();
			}
			catch (Exception e)
			{
				Controller.Fail("window " + where, e);
			}
		}

		public static void Draw()
		{
			if (!_open)
			{
				return;
			}
			Guard("styles", EnsureStyles);
			if ((Object)(object)_texPanel == (Object)null)
			{
				return;
			}
			L l = Layout();
			ApplySizes(l.sc);
			Guard("frame", delegate
			{
				DrawFrame(l);
			});
			if (_open)
			{
				Guard("options bar", delegate
				{
					DrawOptions(l);
				});
				Guard("pages", delegate
				{
					DrawPages(l);
				});
				Guard("list", delegate
				{
					DrawList(l);
				});
				Guard("footer", delegate
				{
					DrawFooter(l);
				});
			}
		}

		private static L Layout()
		{
			L l = new L();
			l.sc = Math.Max(0.8f, Math.Min(1.6f, (float)Screen.height / 1080f));
			l.pad = 10f * l.sc;
			l.titleH = 34f * l.sc;
			l.topH = 42f * l.sc;
			l.footH = 30f * l.sc;
			l.leftW = 230f * l.sc;
			l.rowH = 64f * l.sc;
			if (!_placed)
			{
				_w = Math.Min((float)Screen.width - 40f, 980f * l.sc);
				_h = Math.Min((float)Screen.height - 80f, 660f * l.sc);
				_x = ((float)Screen.width - _w) / 2f;
				_y = Math.Max(20f, ((float)Screen.height - _h) / 2f);
				_placed = true;
			}
			_w = Math.Min(_w, (float)Screen.width - 10f);
			_h = Math.Min(_h, (float)Screen.height - 10f);
			_x = Math.Max(0f, Math.Min(_x, (float)Screen.width - 120f));
			_y = Math.Max(0f, Math.Min(_y, (float)Screen.height - l.titleH));
			l.bodyY = _y + l.titleH + l.topH + 4f * l.sc;
			l.bodyH = _h - l.titleH - l.topH - l.footH - 8f * l.sc;
			l.rx = _x + l.pad + l.leftW + l.pad;
			l.rw = _w - l.leftW - 3f * l.pad;
			l.listY = l.bodyY + 34f * l.sc;
			l.viewH = l.bodyH - 34f * l.sc;
			return l;
		}

		private static void DrawFrame(L l)
		{
			//IL_0014: 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_0071: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(_x, _y, _w, _h), (Texture)(object)_texPanel);
			GUI.DrawTexture(new Rect(_x, _y, _w, l.titleH), (Texture)(object)_texTitle);
			GUI.Label(new Rect(_x + l.pad, _y, _w - l.titleH - l.pad, l.titleH), "Disable effect", _title);
			if (GUI.Button(new Rect(_x + _w - l.titleH, _y + 3f * l.sc, l.titleH - 3f * l.sc, l.titleH - 6f * l.sc), "X", _btnHidden))
			{
				SetOpen(open: false);
			}
			else
			{
				HandleDrag(new Rect(_x, _y, _w - l.titleH, l.titleH));
			}
		}

		private static void DrawOptions(L l)
		{
			float x = _x + l.pad;
			float y = _y + l.titleH + 7f * l.sc;
			float h = 28f * l.sc;
			float gap = 6f * l.sc;
			float sc = l.sc;
			Toggle(Toggle(Toggle(Toggle(Toggle(x, y, 185f * sc, h, "Hiding: " + (Plugin.Enabled.Value ? "ON" : "OFF") + "  (" + Plugin.ToggleKey.Value + ")", Plugin.Enabled.Value, gap, Controller.ToggleEnabled), y, 165f * sc, h, Plugin.KeepIndicators.Value ? "Indicators visible" : "Indicators may hide", Plugin.KeepIndicators.Value, gap, delegate
			{
				Controller.Flip(Plugin.KeepIndicators);
			}), y, 165f * sc, h, Plugin.KeepProjectiles.Value ? "Projectiles visible" : "Projectiles may hide", Plugin.KeepProjectiles.Value, gap, delegate
			{
				Controller.Flip(Plugin.KeepProjectiles);
			}), y, 150f * sc, h, Plugin.KeepBarriers.Value ? "Barriers visible" : "Barriers may hide", Plugin.KeepBarriers.Value, gap, delegate
			{
				Controller.Flip(Plugin.KeepBarriers);
			}), y, 185f * sc, h, Plugin.OnlyHideSpellsYouCast.Value ? "Only spells I cast" : "Any matching spell", Plugin.OnlyHideSpellsYouCast.Value, gap, delegate
			{
				Controller.Flip(Plugin.OnlyHideSpellsYouCast);
			});
		}

		private static void DrawPages(L l)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			float sc = l.sc;
			GUI.DrawTexture(new Rect(_x + l.pad, l.bodyY, l.leftW, l.bodyH), (Texture)(object)_texSide);
			float num = l.bodyY + 6f * sc;
			for (int i = 0; i < Controller.Categories.Length; i++)
			{
				Controller.Counts(i, out var hidden, out var total);
				string text = Controller.Categories[i] + "    " + hidden + "/" + total;
				if (GUI.Button(new Rect(_x + l.pad + 6f * sc, num, l.leftW - 12f * sc, 32f * sc), text, (i == _cat) ? _btnCatSel : _btnCat))
				{
					_cat = i;
					_sel = 0;
					_top = 0;
				}
				num += 36f * sc;
			}
			num += 6f * sc;
			GUI.Label(new Rect(_x + l.pad + 8f * sc, num, l.leftW - 16f * sc, 22f * sc), "Keys (click to change)", _small);
			num += 24f * sc;
			if (GUI.Button(new Rect(_x + l.pad + 6f * sc, num, l.leftW - 12f * sc, 28f * sc), Controller.Listening ? "Press a key..." : ("Hide on/off: " + Plugin.ToggleKey.Value), _btnPlain))
			{
				Controller.StartListening(Plugin.ToggleKey, "toggle key");
			}
			num += 32f * sc;
			if (GUI.Button(new Rect(_x + l.pad + 6f * sc, num, l.leftW - 12f * sc, 28f * sc), Controller.Listening ? "Press a key..." : ("Menu: " + Plugin.MenuKey.Value), _btnPlain))
			{
				Controller.StartListening(Plugin.MenuKey, "menu key");
			}
		}

		private static void DrawList(L l)
		{
			//IL_007d: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			float sc = l.sc;
			List<Entry> list = Controller.EntriesOf(_cat);
			int count = list.Count;
			Controller.Counts(_cat, out var hidden, out var total);
			GUI.Label(new Rect(l.rx, l.bodyY, l.rw - 250f * sc, 30f * sc), Controller.Categories[_cat] + "   -   " + hidden + " of " + total + " hidden", _head);
			if (GUI.Button(new Rect(l.rx + l.rw - 240f * sc, l.bodyY + 1f * sc, 116f * sc, 28f * sc), "Hide all", _btnHidden))
			{
				Controller.SetCategoryHidden(_cat, hide: true);
			}
			if (GUI.Button(new Rect(l.rx + l.rw - 118f * sc, l.bodyY + 1f * sc, 116f * sc, 28f * sc), "Show all", _btnShown))
			{
				Controller.SetCategoryHidden(_cat, hide: false);
			}
			Rect listRect = new Rect(l.rx, l.listY, l.rw, l.viewH);
			GUI.DrawTexture(listRect, (Texture)(object)_texSide);
			_visible = Math.Max(1, (int)(l.viewH / l.rowH));
			int maxTop = Math.Max(0, count - _visible);
			Guard("mouse wheel", delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Wheel(listRect);
			});
			_top = Math.Max(0, Math.Min(_top, maxTop));
			_sel = Math.Max(0, Math.Min(_sel, Math.Max(0, count - 1)));
			if (count == 0)
			{
				GUI.Label(new Rect(l.rx + 14f * sc, l.listY + 10f * sc, l.rw - 28f * sc, 60f * sc), "Nothing here yet. Cast a skill or swing your weapon, and effects appear in this list as they play.", _small);
				return;
			}
			float trackW = 22f * sc;
			float num = l.rw - trackW - 14f * sc;
			for (int num2 = 0; num2 < _visible && _top + num2 < count; num2++)
			{
				int index = _top + num2;
				DrawRow(new Rect(l.rx + 4f * sc, l.listY + 4f * sc + (float)num2 * l.rowH, num, l.rowH - 6f * sc), list[index], index, sc);
			}
			Guard("scrollbar", delegate
			{
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				DrawScrollbar(new Rect(l.rx + l.rw - trackW - 4f * sc, l.listY + 4f * sc, trackW, l.viewH - 8f * sc), count, maxTop, sc);
			});
		}

		private static void DrawRow(Rect row, Entry e, int index, float sc)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(row, (Texture)(object)((index == _sel) ? _texRowSel : _texRow));
			float num = 2f;
			GUI.DrawTexture(new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y, ((Rect)(ref row)).width, num), (Texture)(object)_texBorder);
			GUI.DrawTexture(new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y + ((Rect)(ref row)).height - num, ((Rect)(ref row)).width, num), (Texture)(object)_texBorder);
			GUI.DrawTexture(new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y, num, ((Rect)(ref row)).height), (Texture)(object)_texBorder);
			GUI.DrawTexture(new Rect(((Rect)(ref row)).x + ((Rect)(ref row)).width - num, ((Rect)(ref row)).y, num, ((Rect)(ref row)).height), (Texture)(object)_texBorder);
			float num2 = 52f * sc;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref row)).x + 10f * sc, ((Rect)(ref row)).y + (((Rect)(ref row)).height - num2) / 2f, num2, num2);
			Texture2D val2 = Icons.For(e);
			if ((Object)(object)val2 != (Object)null)
			{
				GUI.DrawTexture(val, (Texture)(object)val2);
			}
			else
			{
				GUI.DrawTexture(val, (Texture)(object)_texSide);
				GUI.Label(val, (e.Name.Length > 0) ? e.Name.Substring(0, 1).ToUpperInvariant() : "?", _letter);
			}
			float num3 = 132f * sc;
			float num4 = 40f * sc;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(((Rect)(ref row)).x + ((Rect)(ref row)).width - num3 - 12f * sc, ((Rect)(ref row)).y + (((Rect)(ref row)).height - num4) / 2f, num3, num4);
			float num5 = ((Rect)(ref val)).x + ((Rect)(ref val)).width + 14f * sc;
			float num6 = ((Rect)(ref val3)).x - num5 - 10f * sc;
			string s = e.Name + ((e.Live > 0) ? "   (playing)" : "");
			GUI.Label(new Rect(num5, ((Rect)(ref row)).y + 3f * sc, num6, ((Rect)(ref row)).height * 0.56f), Clip(s, (int)(num6 / (22f * sc * 0.52f))), _name);
			GUI.Label(new Rect(num5, ((Rect)(ref row)).y + ((Rect)(ref row)).height * 0.56f, num6, ((Rect)(ref row)).height * 0.38f), Clip(Controller.TagsOf(e), (int)(num6 / (12f * sc * 0.5f))), _tagsLeft);
			bool flag = Controller.IsLocked(e);
			bool flag2 = e.Hide && !flag;
			if (GUI.Button(val3, flag2 ? "HIDE" : "SHOW", flag ? _btnLocked : (flag2 ? _btnHidden : _btnShown)))
			{
				_sel = index;
				Controller.ToggleEntry(e);
			}
		}

		private static void DrawFooter(L l)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			string message = Controller.Message;
			GUI.Label(new Rect(_x + l.pad, _y + _h - l.footH, _w - 2f * l.pad, l.footH), (message != null) ? message : "SHOW (green) = the effect is visible, HIDE (red) = hidden, blue = always visible. Drag the title bar to move.", _small);
		}

		private static float Toggle(float x, float y, float w, float h, string text, bool on, float gap, Action click)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (GUI.Button(new Rect(x, y, w, h), text, on ? _btnOn : _btnOff))
			{
				click();
			}
			return x + w + gap;
		}

		private static void HandleDrag(Rect titleRect)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Event current = Event.current;
			if (current != null)
			{
				if ((int)current.type == 0 && ((Rect)(ref titleRect)).Contains(current.mousePosition))
				{
					_dragging = true;
					_dragDx = current.mousePosition.x - _x;
					_dragDy = current.mousePosition.y - _y;
					current.Use();
				}
				else if ((int)current.type == 3 && _dragging)
				{
					_x = current.mousePosition.x - _dragDx;
					_y = current.mousePosition.y - _dragDy;
					current.Use();
				}
				else if ((int)current.type == 1)
				{
					_dragging = false;
				}
			}
		}

		private static void Wheel(Rect area)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current != null && (int)current.type == 6 && ((Rect)(ref area)).Contains(current.mousePosition))
			{
				_top += ((current.delta.y > 0f) ? 2 : (-2));
				current.Use();
			}
		}

		private static void DrawScrollbar(Rect r, int count, int maxTop, float sc)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Invalid comparison between Unknown and I4
			//IL_0151: 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_023e: Invalid comparison between Unknown and I4
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			float num = 24f * sc;
			if (GUI.Button(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, num), "^", _btnPlain))
			{
				_top = Math.Max(0, _top - 1);
			}
			if (GUI.Button(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height - num, ((Rect)(ref r)).width, num), "v", _btnPlain))
			{
				_top = Math.Min(maxTop, _top + 1);
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + num + 2f * sc, ((Rect)(ref r)).width, ((Rect)(ref r)).height - 2f * num - 4f * sc);
			GUI.DrawTexture(val, (Texture)(object)_texRow);
			if (maxTop <= 0)
			{
				return;
			}
			float num2 = Math.Max(24f * sc, ((Rect)(ref val)).height * (float)_visible / (float)count);
			float num3 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - num2) * ((float)_top / (float)maxTop);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref val)).x, num3, ((Rect)(ref val)).width, num2);
			GUI.DrawTexture(val2, (Texture)(object)_texThumb);
			Event current = Event.current;
			if (current == null)
			{
				return;
			}
			if ((int)current.type == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
			{
				if (((Rect)(ref val2)).Contains(current.mousePosition))
				{
					_barDrag = true;
					_barDy = current.mousePosition.y - num3;
				}
				else
				{
					_top = ((current.mousePosition.y < num3) ? Math.Max(0, _top - _visible) : Math.Min(maxTop, _top + _visible));
				}
				current.Use();
			}
			else if ((int)current.type == 3 && _barDrag)
			{
				float val3 = (current.mousePosition.y - _barDy - ((Rect)(ref val)).y) / Math.Max(1f, ((Rect)(ref val)).height - num2);
				_top = (int)Math.Round(Math.Max(0f, Math.Min(1f, val3)) * (float)maxTop);
				current.Use();
			}
			else if ((int)current.type == 1)
			{
				_barDrag = false;
			}
		}

		private static string Clip(string s, int max)
		{
			if (max < 4)
			{
				max = 4;
			}
			if (s.Length > max)
			{
				return s.Substring(0, max - 1) + "~";
			}
			return s;
		}

		private static Texture2D Tex(float r, float g, float b, float a)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, 1, false);
			val.SetPixel(0, 0, new Color(r, g, b, a));
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private static GUIStyle Style(TextAnchor anchor, Color text, Texture2D bg, Texture2D hover, bool bold)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			GUIStyle val = new GUIStyle();
			val.alignment = anchor;
			val.normal.textColor = text;
			val.hover.textColor = text;
			val.active.textColor = text;
			if (bold)
			{
				val.fontStyle = (FontStyle)1;
			}
			if ((Object)(object)bg != (Object)null)
			{
				val.normal.background = bg;
				val.hover.background = (((Object)(object)hover != (Object)null) ? hover : bg);
				val.active.background = (((Object)(object)hover != (Object)null) ? hover : bg);
			}
			RectOffset val2 = new RectOffset();
			val2.left = 8;
			val2.right = 8;
			val2.top = 2;
			val2.bottom = 2;
			val.padding = val2;
			return val;
		}

		private static GUIStyle ButtonStyle(float r, float g, float b, bool bold)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Style((TextAnchor)4, Color.white, Tex(r, g, b, 1f), Tex(Math.Min(1f, r + 0.12f), Math.Min(1f, g + 0.12f), Math.Min(1f, b + 0.12f), 1f), bold);
		}

		private static void EnsureStyles()
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_texPanel != (Object)null))
			{
				Texture2D texPanel = Tex(0.09f, 0.09f, 0.1f, 0.97f);
				_texTitle = Tex(0.16f, 0.12f, 0.2f, 1f);
				_texRow = Tex(0.15f, 0.15f, 0.16f, 1f);
				_texRowSel = Tex(0.22f, 0.22f, 0.28f, 1f);
				_texSide = Tex(0.12f, 0.12f, 0.13f, 1f);
				_texBorder = Tex(0.33f, 0.24f, 0.48f, 1f);
				_texThumb = Tex(0.45f, 0.36f, 0.62f, 1f);
				Color text = default(Color);
				((Color)(ref text))..ctor(0.93f, 0.93f, 0.93f, 1f);
				_label = Style((TextAnchor)3, text, null, null, bold: false);
				_small = Style((TextAnchor)3, new Color(0.75f, 0.75f, 0.78f, 1f), null, null, bold: false);
				_head = Style((TextAnchor)3, new Color(1f, 0.82f, 0.4f, 1f), null, null, bold: false);
				_title = Style((TextAnchor)3, Color.white, null, null, bold: false);
				_name = Style((TextAnchor)3, Color.white, null, null, bold: true);
				_tagsLeft = Style((TextAnchor)3, new Color(0.65f, 0.75f, 0.92f, 1f), null, null, bold: false);
				_letter = Style((TextAnchor)4, new Color(0.8f, 0.8f, 0.85f, 1f), null, null, bold: true);
				_btnPlain = ButtonStyle(0.28f, 0.28f, 0.32f, bold: false);
				_btnOn = ButtonStyle(0.2f, 0.45f, 0.25f, bold: false);
				_btnOff = ButtonStyle(0.35f, 0.35f, 0.38f, bold: false);
				_btnShown = ButtonStyle(0.18f, 0.52f, 0.24f, bold: true);
				_btnHidden = ButtonStyle(0.85f, 0.12f, 0.12f, bold: true);
				_btnLocked = ButtonStyle(0.25f, 0.4f, 0.62f, bold: true);
				_btnCat = ButtonStyle(0.2f, 0.2f, 0.24f, bold: false);
				_btnCatSel = ButtonStyle(0.42f, 0.3f, 0.62f, bold: false);
				_texPanel = texPanel;
			}
		}

		private static void ApplySizes(float sc)
		{
			_label.fontSize = (int)(15f * sc);
			_small.fontSize = (int)(13f * sc);
			_head.fontSize = (int)(17f * sc);
			_title.fontSize = (int)(19f * sc);
			_name.fontSize = (int)(22f * sc);
			_tagsLeft.fontSize = (int)(12f * sc);
			_letter.fontSize = (int)(28f * sc);
			int fontSize = (int)(14f * sc);
			_btnPlain.fontSize = fontSize;
			_btnOn.fontSize = fontSize;
			_btnOff.fontSize = fontSize;
			_btnCat.fontSize = fontSize;
			_btnCatSel.fontSize = fontSize;
			int fontSize2 = (int)(17f * sc);
			_btnShown.fontSize = fontSize2;
			_btnHidden.fontSize = fontSize2;
			_btnLocked.fontSize = fontSize2;
		}
	}
}