Decompiled source of Showitemcoverage v0.4.0

plugins/Showitemcoverage.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Peak;
using Peak.Afflictions;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RangeOverlay
{
	internal static class ModConfig
	{
		internal static ConfigEntry<KeyboardShortcut> ToggleKey;

		internal static ConfigEntry<float> SwitchDelaySeconds;

		internal static ConfigEntry<int> Resolution;

		internal static ConfigEntry<bool> EnableBellTower;

		internal static ConfigEntry<bool> BellTowerUnlit;

		internal static ConfigEntry<string> BellTowerColor;

		internal static ConfigEntry<bool> EnableCampfire;

		internal static ConfigEntry<string> CampfireColor;

		internal static ConfigEntry<bool> EnableCandle;

		internal static ConfigEntry<string> CandleColor;

		internal static ConfigEntry<bool> OwnCandle;

		internal static ConfigEntry<bool> AllyCandle;

		internal static ConfigEntry<bool> GroundCandle;

		internal static ConfigEntry<bool> EnableLantern;

		internal static ConfigEntry<string> LanternColor;

		internal static ConfigEntry<bool> OwnLantern;

		internal static ConfigEntry<bool> AllyLantern;

		internal static ConfigEntry<bool> GroundLantern;

		internal static ConfigEntry<bool> EnableFaerieLantern;

		internal static ConfigEntry<string> FaerieLanternColor;

		internal static ConfigEntry<bool> OwnFaerieLantern;

		internal static ConfigEntry<bool> AllyFaerieLantern;

		internal static ConfigEntry<bool> GroundFaerieLantern;

		internal static ConfigEntry<bool> EnableBugle;

		internal static ConfigEntry<string> BugleColor;

		internal static ConfigEntry<bool> OwnBugle;

		internal static ConfigEntry<bool> AllyBugle;

		internal static ConfigEntry<bool> GroundBugle;

		internal static ConfigEntry<bool> EnableMassSuperJump;

		internal static ConfigEntry<string> MassSuperJumpColor;

		internal static ConfigEntry<bool> OwnMassSuperJump;

		internal static ConfigEntry<bool> AllyMassSuperJump;

		internal static ConfigEntry<bool> GroundMassSuperJump;

		internal static ConfigEntry<bool> EnableStamAmulet;

		internal static ConfigEntry<string> StamAmuletColor;

		internal static ConfigEntry<bool> OwnStamAmulet;

		internal static ConfigEntry<bool> AllyStamAmulet;

		internal static ConfigEntry<bool> GroundStamAmulet;

		internal static void Init(ConfigFile config)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			ToggleKey = config.Bind<KeyboardShortcut>("通用", "切换显示快捷键 Toggle Key", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "按一下切换全部范围球的可视度,默认不绑定。 Toggle visibility of all spheres, unbound by default.");
			SwitchDelaySeconds = config.Bind<float>("通用", "道具切换延迟秒数 Item Switch Delay", 1f, new ConfigDescription("切换手持道具后等待多少秒才显示新道具的范围球,避免快速切换时频繁闪烁。 Seconds to wait after switching held items before showing the new sphere.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			Resolution = config.Bind<int>("通用", "球体精细度 Sphere Resolution", 2, new ConfigDescription("球体网格精细度,1=低,2=中,3=高;越高越圆滑,性能开销略增。 Sphere mesh resolution, 1=Low, 2=Medium, 3=High.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			EnableBellTower = config.Bind<bool>("钟塔(鬼火)", "显示 Enable", true, "显示雾沼地图钟塔(鬼火)的幽暗保护范围。 Show bell tower (GhostFire) range.");
			BellTowerUnlit = config.Bind<bool>("钟塔(鬼火)", "显示未开启的 Show Unlit", false, "开启后未点亮的钟塔也显示范围球,默认只显示已点亮、真正生效的。 Also show unlit bell towers.");
			BellTowerColor = config.Bind<string>("钟塔(鬼火)", "颜色 Color", "115,217,255,45", "钟塔范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			EnableCampfire = config.Bind<bool>("营火", "显示 Enable", false, "显示营火的幽暗保护范围,默认关闭。 Show campfire range, off by default.");
			CampfireColor = config.Bind<string>("营火", "颜色 Color", "255,140,60,45", "营火范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			EnableCandle = config.Bind<bool>("蜡烛", "显示 Enable", true, "显示蜡烛点燃后形成的安全范围。 Show candle range.");
			CandleColor = config.Bind<string>("蜡烛", "颜色 Color", "255,191,77,45", "蜡烛范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnCandle = config.Bind<bool>("蜡烛", "自己手中的 Own", true, "显示自己手中(含口袋)的蜡烛范围。 Show candles you hold.");
			AllyCandle = config.Bind<bool>("蜡烛", "队友手中的 Ally", false, "显示队友手中(含口袋)的蜡烛范围。 Show candles held by teammates.");
			GroundCandle = config.Bind<bool>("蜡烛", "地上的 Ground", false, "显示掉在地上或场景中的蜡烛范围。 Show candles on the ground.");
			EnableLantern = config.Bind<bool>("提灯", "显示 Enable", false, "显示普通提灯的幽暗保护范围,默认关闭。 Show lantern range, off by default.");
			LanternColor = config.Bind<string>("提灯", "颜色 Color", "255,220,150,45", "普通提灯范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnLantern = config.Bind<bool>("提灯", "自己手中的 Own", true, "显示自己手中(含口袋)的提灯范围。 Show lanterns you hold.");
			AllyLantern = config.Bind<bool>("提灯", "队友手中的 Ally", false, "显示队友手中(含口袋)的提灯范围。 Show lanterns held by teammates.");
			GroundLantern = config.Bind<bool>("提灯", "地上的 Ground", false, "显示掉在地上或场景中的提灯范围。 Show lanterns on the ground.");
			EnableFaerieLantern = config.Bind<bool>("仙子提灯", "显示 Enable", false, "显示仙子提灯的幽暗保护范围,默认关闭。 Show faerie lantern range, off by default.");
			FaerieLanternColor = config.Bind<string>("仙子提灯", "颜色 Color", "180,255,220,45", "仙子提灯范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnFaerieLantern = config.Bind<bool>("仙子提灯", "自己手中的 Own", true, "显示自己手中(含口袋)的仙子提灯范围。 Show faerie lanterns you hold.");
			AllyFaerieLantern = config.Bind<bool>("仙子提灯", "队友手中的 Ally", false, "显示队友手中(含口袋)的仙子提灯范围。 Show faerie lanterns held by teammates.");
			GroundFaerieLantern = config.Bind<bool>("仙子提灯", "地上的 Ground", false, "显示掉在地上或场景中的仙子提灯范围。 Show faerie lanterns on the ground.");
			EnableBugle = config.Bind<bool>("友谊喇叭", "显示 Enable", true, "显示友谊喇叭吹响时的作用范围。 Show bugle range.");
			BugleColor = config.Bind<string>("友谊喇叭", "颜色 Color", "140,255,140,45", "友谊喇叭范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnBugle = config.Bind<bool>("友谊喇叭", "自己手中的 Own", true, "显示自己手中(含口袋)的友谊喇叭范围。 Show bugles you hold.");
			AllyBugle = config.Bind<bool>("友谊喇叭", "队友手中的 Ally", false, "显示队友手中(含口袋)的友谊喇叭范围。 Show bugles held by teammates.");
			GroundBugle = config.Bind<bool>("友谊喇叭", "地上的 Ground", false, "显示掉在地上或场景中的友谊喇叭范围。 Show bugles on the ground.");
			EnableMassSuperJump = config.Bind<bool>("超级跳护符", "显示 Enable", true, "显示超级跳护符(对附近队友施加低重力与超级跳)的影响范围。 Show super jump amulet range.");
			MassSuperJumpColor = config.Bind<string>("超级跳护符", "颜色 Color", "217,153,255,45", "超级跳护符范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnMassSuperJump = config.Bind<bool>("超级跳护符", "自己手中的 Own", true, "显示自己手中(含口袋)的超级跳护符范围。 Show super jump amulets you hold.");
			AllyMassSuperJump = config.Bind<bool>("超级跳护符", "队友手中的 Ally", false, "显示队友手中(含口袋)的超级跳护符范围。 Show super jump amulets held by teammates.");
			GroundMassSuperJump = config.Bind<bool>("超级跳护符", "地上的 Ground", false, "显示掉在地上或场景中的超级跳护符范围。 Show super jump amulets on the ground.");
			EnableStamAmulet = config.Bind<bool>("无限体力护符(童军的野心)", "显示 Enable", true, "显示无限体力护符(游戏内名「童军的野心」)辐射给附近队友的范围,仅手持时显示预览。 Show infinite stamina amulet (Scout's Ambition) range, preview while held.");
			StamAmuletColor = config.Bind<string>("无限体力护符(童军的野心)", "颜色 Color", "255,242,115,45", "无限体力护符范围球的颜色,格式 R,G,B,A,取值 0-255(A 为透明度)。 Color, format R,G,B,A in 0-255.");
			OwnStamAmulet = config.Bind<bool>("无限体力护符(童军的野心)", "自己手中的 Own", true, "显示自己手持的无限体力护符范围。 Show infinite stamina amulets you hold.");
			AllyStamAmulet = config.Bind<bool>("无限体力护符(童军的野心)", "队友手中的 Ally", false, "显示队友手持的无限体力护符范围。 Show infinite stamina amulets held by teammates.");
			GroundStamAmulet = config.Bind<bool>("无限体力护符(童军的野心)", "地上的 Ground", false, "显示掉在地上或场景中的无限体力护符范围。 Show infinite stamina amulets on the ground.");
		}

		internal static bool OwnEnabled(RangeKind kind)
		{
			return kind switch
			{
				RangeKind.Candle => OwnCandle.Value, 
				RangeKind.Lantern => OwnLantern.Value, 
				RangeKind.FaerieLantern => OwnFaerieLantern.Value, 
				RangeKind.Bugle => OwnBugle.Value, 
				RangeKind.MassSuperJump => OwnMassSuperJump.Value, 
				RangeKind.StamAmulet => OwnStamAmulet.Value, 
				_ => false, 
			};
		}

		internal static bool AllyEnabled(RangeKind kind)
		{
			return kind switch
			{
				RangeKind.Candle => AllyCandle.Value, 
				RangeKind.Lantern => AllyLantern.Value, 
				RangeKind.FaerieLantern => AllyFaerieLantern.Value, 
				RangeKind.Bugle => AllyBugle.Value, 
				RangeKind.MassSuperJump => AllyMassSuperJump.Value, 
				RangeKind.StamAmulet => AllyStamAmulet.Value, 
				_ => false, 
			};
		}

		internal static bool GroundEnabled(RangeKind kind)
		{
			return kind switch
			{
				RangeKind.Candle => GroundCandle.Value, 
				RangeKind.Lantern => GroundLantern.Value, 
				RangeKind.FaerieLantern => GroundFaerieLantern.Value, 
				RangeKind.Bugle => GroundBugle.Value, 
				RangeKind.MassSuperJump => GroundMassSuperJump.Value, 
				RangeKind.StamAmulet => GroundStamAmulet.Value, 
				_ => false, 
			};
		}

		internal static Color ParseColor(string value)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			Color result = default(Color);
			((Color)(ref result))..ctor(1f, 1f, 1f, 0.18f);
			if (string.IsNullOrWhiteSpace(value))
			{
				return result;
			}
			string[] array = value.Split(new char[1] { ',' });
			if (array.Length < 3)
			{
				return result;
			}
			if (!float.TryParse(array[0].Trim(), out var result2) || !float.TryParse(array[1].Trim(), out var result3) || !float.TryParse(array[2].Trim(), out var result4))
			{
				return result;
			}
			float result5 = 45f;
			if (array.Length >= 4)
			{
				float.TryParse(array[3].Trim(), out result5);
			}
			return new Color(result2 / 255f, result3 / 255f, result4 / 255f, result5 / 255f);
		}
	}
	[BepInPlugin("peak.rangeoverlay", "范围透视圈", "0.3.0")]
	[BepInProcess("PEAK.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		private GameObject _host;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			PluginInfo.Init(((BaseUnityPlugin)this).Logger);
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			_host = new GameObject("RangeOverlay_Host");
			((Object)_host).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)_host);
			_host.AddComponent<RangeOverlayHost>();
			ManualLogSource log = PluginInfo.Log;
			KeyboardShortcut value = ModConfig.ToggleKey.Value;
			object obj;
			if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
			{
				value = ModConfig.ToggleKey.Value;
				obj = ((object)((KeyboardShortcut)(ref value)).MainKey/*cast due to .constrained prefix*/).ToString();
			}
			else
			{
				obj = "未绑定";
			}
			log.LogInfo((object)("范围透视圈 v0.3.0 已加载(切换快捷键:" + (string?)obj + ")"));
		}

		private void OnDestroy()
		{
			if ((Object)(object)_host != (Object)null)
			{
				Object.Destroy((Object)(object)_host);
				_host = null;
			}
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "peak.rangeoverlay";

		public const string Name = "范围透视圈";

		public const string Version = "0.3.0";

		internal static ManualLogSource Log { get; private set; }

		internal static void Init(ManualLogSource log)
		{
			Log = log;
		}
	}
	internal enum RangeKind
	{
		BellTower,
		Campfire,
		Candle,
		Lantern,
		FaerieLantern,
		Bugle,
		MassSuperJump,
		StamAmulet
	}
	internal enum RangeSource
	{
		Ground,
		OwnHeld,
		AllyHeld,
		Environment
	}
	internal struct RangeEntry
	{
		public RangeKind Kind;

		public RangeSource Source;

		public Vector3 Center;

		public float Radius;
	}
	internal sealed class RangeOverlayHost : MonoBehaviour
	{
		private RangeSpherePool _pool;

		private readonly RangeScanner _scanner = new RangeScanner();

		private readonly List<RangeEntry> _frame = new List<RangeEntry>();

		private bool _globalVisible = true;

		private Item _lastLocalItem;

		private float _itemShownAt;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("RangeOverlay_Root");
			((Object)val).hideFlags = (HideFlags)61;
			val.transform.SetParent(((Component)this).transform, false);
			_pool = new RangeSpherePool(val.transform);
		}

		private void Update()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			HandleToggleKey();
			int num;
			int num2;
			if (_globalVisible)
			{
				num = (((Object)(object)Character.localCharacter != (Object)null) ? 1 : 0);
				if (num != 0)
				{
					num2 = (UpdateHeldItemDelay() ? 1 : 0);
					goto IL_0028;
				}
			}
			else
			{
				num = 0;
			}
			num2 = 0;
			goto IL_0028;
			IL_0028:
			bool flag = (byte)num2 != 0;
			_pool.BeginFrame(ModConfig.Resolution.Value);
			if (num != 0)
			{
				_frame.Clear();
				_frame.AddRange(_scanner.Scan());
				for (int i = 0; i < _frame.Count; i++)
				{
					RangeEntry rangeEntry = _frame[i];
					if (IsSourceEnabled(rangeEntry.Kind, rangeEntry.Source) && (rangeEntry.Source != RangeSource.OwnHeld || flag))
					{
						Color color = ColorFor(rangeEntry.Kind);
						Vector3 center = rangeEntry.Center;
						_pool.Place(center, rangeEntry.Radius, color);
					}
				}
			}
			_pool.EndFrame();
		}

		private bool UpdateHeldItemDelay()
		{
			Item val = null;
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.data != (Object)null)
			{
				val = localCharacter.data.currentItem;
			}
			if ((Object)(object)val != (Object)(object)_lastLocalItem)
			{
				_lastLocalItem = val;
				float value = ModConfig.SwitchDelaySeconds.Value;
				_itemShownAt = Time.unscaledTime + value;
				return value <= 0f;
			}
			return Time.unscaledTime >= _itemShownAt;
		}

		private static bool IsSourceEnabled(RangeKind kind, RangeSource source)
		{
			return source switch
			{
				RangeSource.Environment => true, 
				RangeSource.OwnHeld => ModConfig.OwnEnabled(kind), 
				RangeSource.AllyHeld => ModConfig.AllyEnabled(kind), 
				RangeSource.Ground => ModConfig.GroundEnabled(kind), 
				_ => false, 
			};
		}

		private static Color ColorFor(RangeKind kind)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0075: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(kind switch
			{
				RangeKind.BellTower => ModConfig.ParseColor(ModConfig.BellTowerColor.Value), 
				RangeKind.Campfire => ModConfig.ParseColor(ModConfig.CampfireColor.Value), 
				RangeKind.Candle => ModConfig.ParseColor(ModConfig.CandleColor.Value), 
				RangeKind.Lantern => ModConfig.ParseColor(ModConfig.LanternColor.Value), 
				RangeKind.FaerieLantern => ModConfig.ParseColor(ModConfig.FaerieLanternColor.Value), 
				RangeKind.Bugle => ModConfig.ParseColor(ModConfig.BugleColor.Value), 
				RangeKind.MassSuperJump => ModConfig.ParseColor(ModConfig.MassSuperJumpColor.Value), 
				RangeKind.StamAmulet => ModConfig.ParseColor(ModConfig.StamAmuletColor.Value), 
				_ => Color.white, 
			});
		}

		private void HandleToggleKey()
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = ModConfig.ToggleKey.Value;
			if ((int)((KeyboardShortcut)(ref value)).MainKey != 0 && ((KeyboardShortcut)(ref value)).IsDown())
			{
				_globalVisible = !_globalVisible;
				PluginInfo.Log.LogInfo((object)(_globalVisible ? "范围显示:开" : "范围显示:关"));
			}
		}

		private void OnDestroy()
		{
			if (_pool != null)
			{
				_pool.Dispose();
				_pool = null;
			}
		}
	}
	internal sealed class RangeScanner
	{
		private readonly List<RangeEntry> _results = new List<RangeEntry>();

		internal List<RangeEntry> Scan()
		{
			_results.Clear();
			ScanSafeZones();
			ScanItemInstances();
			ScanStamAmulets();
			return _results;
		}

		private void ScanSafeZones()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			List<GloomSafeZone> aLL_GLOOM_SAFE_ZONES = GloomSafeZone.ALL_GLOOM_SAFE_ZONES;
			if (aLL_GLOOM_SAFE_ZONES == null)
			{
				return;
			}
			for (int i = 0; i < aLL_GLOOM_SAFE_ZONES.Count; i++)
			{
				GloomSafeZone val = aLL_GLOOM_SAFE_ZONES[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				float statusProtectionRadius = val.statusProtectionRadius;
				if (!(statusProtectionRadius <= 0.01f))
				{
					RangeKind kind = ClassifyZone(val);
					Item componentInParent = ((Component)val).GetComponentInParent<Item>();
					RangeSource source;
					if (!((Object)(object)componentInParent != (Object)null) || !IsItemHeld(componentInParent))
					{
						source = ((!((Object)(object)componentInParent != (Object)null)) ? RangeSource.Environment : RangeSource.Ground);
					}
					else
					{
						Character holderCharacter = componentInParent.holderCharacter;
						source = (((Object)(object)holderCharacter != (Object)null && holderCharacter.IsLocal) ? RangeSource.OwnHeld : RangeSource.AllyHeld);
					}
					if (IsZoneEnabled(kind, val, source))
					{
						_results.Add(new RangeEntry
						{
							Kind = kind,
							Source = source,
							Center = ((Component)val).transform.position,
							Radius = statusProtectionRadius
						});
					}
				}
			}
		}

		private static bool IsItemHeld(Item item)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			if ((Object)(object)item.holderCharacter != (Object)null)
			{
				return true;
			}
			if ((int)item.itemState != 1)
			{
				return (int)item.itemState == 2;
			}
			return true;
		}

		private static bool IsZoneEnabled(RangeKind kind, GloomSafeZone zone, RangeSource source)
		{
			switch (kind)
			{
			case RangeKind.BellTower:
				if (!ModConfig.EnableBellTower.Value)
				{
					return false;
				}
				if (!zone.isLit && !ModConfig.BellTowerUnlit.Value)
				{
					return false;
				}
				return true;
			case RangeKind.Campfire:
				if (ModConfig.EnableCampfire.Value)
				{
					return zone.isLit;
				}
				return false;
			default:
				if (source == RangeSource.Environment || !zone.isLit)
				{
					return false;
				}
				return IsItemKindEnabled(kind);
			}
		}

		private static bool IsItemKindEnabled(RangeKind kind)
		{
			return kind switch
			{
				RangeKind.Candle => ModConfig.EnableCandle.Value, 
				RangeKind.Lantern => ModConfig.EnableLantern.Value, 
				RangeKind.FaerieLantern => ModConfig.EnableFaerieLantern.Value, 
				RangeKind.Bugle => ModConfig.EnableBugle.Value, 
				RangeKind.MassSuperJump => ModConfig.EnableMassSuperJump.Value, 
				RangeKind.StamAmulet => ModConfig.EnableStamAmulet.Value, 
				_ => false, 
			};
		}

		private static RangeKind ClassifyZone(GloomSafeZone zone)
		{
			if (zone is GhostFire)
			{
				return RangeKind.BellTower;
			}
			if ((Object)(object)((Component)zone).GetComponentInParent<Campfire>() != (Object)null)
			{
				return RangeKind.Campfire;
			}
			Lantern componentInParent = ((Component)zone).GetComponentInParent<Lantern>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				if (!IsFaerie(((Component)componentInParent).gameObject))
				{
					return RangeKind.Lantern;
				}
				return RangeKind.FaerieLantern;
			}
			if ((Object)(object)((Component)zone).GetComponentInParent<Candle>() != (Object)null || zone.isCandle)
			{
				return RangeKind.Candle;
			}
			return RangeKind.BellTower;
		}

		internal static bool IsFaerie(GameObject go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			string name = ((Object)go).name;
			if (name != null)
			{
				return name.IndexOf("Faerie", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}

		private void ScanItemInstances()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			List<Item> aLL_ITEMS = Item.ALL_ITEMS;
			if (aLL_ITEMS == null)
			{
				return;
			}
			for (int i = 0; i < aLL_ITEMS.Count; i++)
			{
				Item val = aLL_ITEMS[i];
				if (!((Object)(object)val == (Object)null))
				{
					RangeSource source;
					if (IsItemHeld(val))
					{
						Character holderCharacter = val.holderCharacter;
						source = (((Object)(object)holderCharacter != (Object)null && holderCharacter.IsLocal) ? RangeSource.OwnHeld : RangeSource.AllyHeld);
					}
					else
					{
						source = RangeSource.Ground;
					}
					AddItemRanges(val.transform.position, val.transform, source);
				}
			}
		}

		private static float ReadAfflictionRadius(Transform root, string afflictionTypeName)
		{
			MonoBehaviour[] componentsInChildren = ((Component)root).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)null || !(val is ItemActionBase))
				{
					continue;
				}
				FieldInfo field = ((object)val).GetType().GetField("affliction");
				object obj = ((field != null) ? field.GetValue(val) : null);
				if (obj != null && !(obj.GetType().Name != afflictionTypeName))
				{
					FieldInfo field2 = obj.GetType().GetField("radius");
					if (field2 != null && field2.GetValue(obj) is float num && num > 0.01f)
					{
						return num;
					}
				}
			}
			return 0f;
		}

		private void AddItemRanges(Vector3 center, Transform transform, RangeSource source)
		{
			//IL_0001: 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)
			AddBugle(center, transform, source);
			AddMassSuperJump(center, transform, source);
		}

		private void ScanStamAmulets()
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.EnableStamAmulet.Value)
			{
				return;
			}
			List<Character> allCharacters = Character.AllCharacters;
			if (allCharacters == null)
			{
				return;
			}
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null)
				{
					continue;
				}
				Item currentItem = val.data.currentItem;
				if ((Object)(object)currentItem == (Object)null)
				{
					continue;
				}
				float num = ReadAfflictionRadius(currentItem.transform, "Affliction_RadiateInfiniteStam");
				string name = ((Object)((Component)currentItem).gameObject).name;
				if (num > 0.01f || (name != null && name.IndexOf("InfiniteStamina", StringComparison.OrdinalIgnoreCase) >= 0))
				{
					float num2 = ReadActiveRadiateRadius(val);
					float num3 = ((num2 > 0.01f) ? num2 : num);
					if (!(num3 <= 0.01f))
					{
						RangeSource source = (val.IsLocal ? RangeSource.OwnHeld : RangeSource.AllyHeld);
						Add(RangeKind.StamAmulet, source, val.Center, num3);
					}
				}
			}
		}

		private static float ReadActiveRadiateRadius(Character character)
		{
			if (character.refs == null || (Object)(object)character.refs.afflictions == (Object)null)
			{
				return 0f;
			}
			Affliction val = default(Affliction);
			if (!character.refs.afflictions.HasAfflictionType((AfflictionType)24, ref val))
			{
				return 0f;
			}
			Affliction_RadiateInfiniteStam val2 = (Affliction_RadiateInfiniteStam)(object)((val is Affliction_RadiateInfiniteStam) ? val : null);
			if (val2 != null && val2.radius > 0.01f)
			{
				return val2.radius;
			}
			return 0f;
		}

		private void AddBugle(Vector3 center, Transform transform, RangeSource source)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.EnableBugle.Value)
			{
				return;
			}
			MagicBugle component = ((Component)transform).GetComponent<MagicBugle>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.massAffliction == (Object)null))
			{
				float radius = component.massAffliction.radius;
				if (!(radius <= 0.01f))
				{
					Add(RangeKind.Bugle, source, center, radius);
				}
			}
		}

		private void AddMassSuperJump(Vector3 center, Transform transform, RangeSource source)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (ModConfig.EnableMassSuperJump.Value)
			{
				float num = ReadAfflictionRadius(transform, "Affliction_MassSuperJump");
				if (!(num <= 0.01f))
				{
					Add(RangeKind.MassSuperJump, source, center, num);
				}
			}
		}

		private void Add(RangeKind kind, RangeSource source, Vector3 center, float radius)
		{
			//IL_0020: 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)
			_results.Add(new RangeEntry
			{
				Kind = kind,
				Source = source,
				Center = center,
				Radius = radius
			});
		}
	}
	internal sealed class RangeSpherePool
	{
		private readonly Transform _root;

		private readonly Material _material;

		private readonly List<RangeSphere> _all = new List<RangeSphere>();

		private int _activeCount;

		private int _lastResolution = -1;

		internal RangeSpherePool(Transform root)
		{
			_root = root;
			_material = SphereMeshFactory.CreateMaterial();
		}

		internal void BeginFrame(int resolution)
		{
			if (_lastResolution != resolution)
			{
				Mesh mesh = SphereMeshFactory.GetMesh(resolution);
				for (int i = 0; i < _all.Count; i++)
				{
					_all[i].SetMesh(mesh);
				}
				_lastResolution = resolution;
			}
			_activeCount = 0;
		}

		internal void Place(Vector3 center, float radius, Color color)
		{
			//IL_0044: 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)
			if (!(radius <= 0.01f))
			{
				RangeSphere rangeSphere;
				if (_activeCount < _all.Count)
				{
					rangeSphere = _all[_activeCount];
				}
				else
				{
					rangeSphere = Create();
					_all.Add(rangeSphere);
				}
				rangeSphere.Show(center, radius, color);
				_activeCount++;
			}
		}

		internal void EndFrame()
		{
			for (int i = _activeCount; i < _all.Count; i++)
			{
				_all[i].Hide();
			}
		}

		internal void Dispose()
		{
			for (int i = 0; i < _all.Count; i++)
			{
				if ((Object)(object)_all[i] != (Object)null && (Object)(object)((Component)_all[i]).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_all[i]).gameObject);
				}
			}
			_all.Clear();
			_activeCount = 0;
			if ((Object)(object)_material != (Object)null)
			{
				Object.Destroy((Object)(object)_material);
			}
			SphereMeshFactory.Clear();
		}

		private RangeSphere Create()
		{
			//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_0012: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("RangeSphere")
			{
				hideFlags = (HideFlags)61
			};
			val.transform.SetParent(_root, false);
			MeshFilter val2 = val.AddComponent<MeshFilter>();
			MeshRenderer val3 = val.AddComponent<MeshRenderer>();
			((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val3).receiveShadows = false;
			((Renderer)val3).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)val3).reflectionProbeUsage = (ReflectionProbeUsage)0;
			((Renderer)val3).material = _material;
			val2.sharedMesh = SphereMeshFactory.GetMesh((_lastResolution < 1) ? 2 : _lastResolution);
			RangeSphere rangeSphere = val.AddComponent<RangeSphere>();
			rangeSphere.Bind(val3);
			rangeSphere.Hide();
			return rangeSphere;
		}
	}
	internal sealed class RangeSphere : MonoBehaviour
	{
		private MeshRenderer _renderer;

		private MaterialPropertyBlock _block;

		internal void Bind(MeshRenderer renderer)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			_renderer = renderer;
			_block = new MaterialPropertyBlock();
		}

		internal void SetMesh(Mesh mesh)
		{
			MeshFilter component = ((Component)this).GetComponent<MeshFilter>();
			if ((Object)(object)component != (Object)null)
			{
				component.sharedMesh = mesh;
			}
		}

		internal void Show(Vector3 center, float radius, Color color)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (!((Object)(object)_renderer == (Object)null))
			{
				if (!((Component)this).gameObject.activeSelf)
				{
					((Component)this).gameObject.SetActive(true);
				}
				((Component)this).transform.position = center;
				((Component)this).transform.localScale = new Vector3(radius, radius, radius);
				((Renderer)_renderer).GetPropertyBlock(_block);
				_block.SetColor("_Color", color);
				_block.SetColor("_BaseColor", color);
				((Renderer)_renderer).SetPropertyBlock(_block);
			}
		}

		internal void Hide()
		{
			if (((Component)this).gameObject.activeSelf)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	internal static class SphereMeshFactory
	{
		private static readonly Dictionary<int, Mesh> _cache = new Dictionary<int, Mesh>();

		private static Shader _shader;

		internal static Mesh GetMesh(int resolution)
		{
			resolution = Mathf.Clamp(resolution, 1, 3);
			if (_cache.TryGetValue(resolution, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			int lon = 32;
			int lat = 16;
			switch (resolution)
			{
			case 1:
				lon = 16;
				lat = 8;
				break;
			case 3:
				lon = 48;
				lat = 24;
				break;
			}
			Mesh val = Build(lon, lat);
			((Object)val).name = "RangeSphere_" + resolution;
			_cache[resolution] = val;
			return val;
		}

		internal static void Clear()
		{
			_cache.Clear();
		}

		private static Mesh Build(int lon, int lat)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_014d: Expected O, but got Unknown
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<int> list4 = new List<int>();
			Vector3 item = default(Vector3);
			for (int i = 0; i <= lat; i++)
			{
				float num = (float)i / (float)lat;
				float num2 = (float)Math.PI * num;
				float num3 = Mathf.Sin(num2);
				float num4 = Mathf.Cos(num2);
				for (int j = 0; j <= lon; j++)
				{
					float num5 = (float)j / (float)lon;
					float num6 = (float)Math.PI * 2f * num5;
					((Vector3)(ref item))..ctor(num3 * Mathf.Cos(num6), num4, num3 * Mathf.Sin(num6));
					list.Add(item);
					list2.Add(item);
					list3.Add(new Vector2(num5, 1f - num));
				}
			}
			int num7 = lon + 1;
			for (int k = 0; k < lat; k++)
			{
				for (int l = 0; l < lon; l++)
				{
					int num8 = k * num7 + l;
					int item2 = num8 + 1;
					int num9 = num8 + num7;
					int item3 = num9 + 1;
					list4.Add(num8);
					list4.Add(num9);
					list4.Add(item2);
					list4.Add(item2);
					list4.Add(num9);
					list4.Add(item3);
				}
			}
			Mesh val = new Mesh();
			val.SetVertices(list);
			val.SetNormals(list2);
			val.SetUVs(0, list3);
			val.SetTriangles(list4, 0);
			val.RecalculateBounds();
			return val;
		}

		internal static Material CreateMaterial()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(ResolveShader());
			((Object)val).hideFlags = (HideFlags)61;
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", Color.white);
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", Color.white);
			}
			if (val.HasProperty("_Mode"))
			{
				val.SetFloat("_Mode", 3f);
			}
			val.SetOverrideTag("RenderType", "Transparent");
			if (val.HasProperty("_SrcBlend"))
			{
				val.SetInt("_SrcBlend", 5);
			}
			if (val.HasProperty("_DstBlend"))
			{
				val.SetInt("_DstBlend", 10);
			}
			val.SetInt("_ZWrite", 0);
			val.DisableKeyword("_ALPHATEST_ON");
			val.EnableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val.SetInt("_Cull", 0);
			val.renderQueue = 3000;
			return val;
		}

		private static Shader ResolveShader()
		{
			if ((Object)(object)_shader != (Object)null)
			{
				return _shader;
			}
			string[] array = new string[6] { "Sprites/Default", "Universal Render Pipeline/Unlit", "Universal Render Pipeline/Simple Lit", "Unlit/Transparent", "Legacy Shaders/Transparent/Diffuse", "Standard" };
			for (int i = 0; i < array.Length; i++)
			{
				Shader val = Shader.Find(array[i]);
				if ((Object)(object)val != (Object)null)
				{
					_shader = val;
					return _shader;
				}
			}
			_shader = Shader.Find("Standard");
			return _shader;
		}
	}
}