Decompiled source of Mine Explosion Visualizer v1.0.0

MineExplosionVisualizer.dll

Decompiled 2 months 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using GTFO.API.Utilities;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Player;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MineExplosionVisualizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MineExplosionVisualizer")]
[assembly: AssemblyTitle("MineExplosionVisualizer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MineExplosionVisualizer;

[BepInPlugin("mineexplosionvisualizer.HazardousMonkey", "MineExplosionVisualizer", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MineExplosionVisualizerPlugin : BasePlugin
{
	public static ConfigEntry<string> VisualizerColor;

	public static ConfigEntry<float> VisualizerOpacity;

	public static ConfigEntry<float> BeamLength;

	public static ConfigEntry<float> BeamWidth;

	public static ConfigEntry<float> BeamHeight;

	public static ConfigEntry<bool> SolidFill;

	public static ConfigEntry<bool> ShowDistMinIndicator;

	public static ConfigEntry<bool> VisualizerEnabled;

	public static ConfigEntry<KeyCode> ToggleKey;

	public static MineExplosionVisualizerPlugin Instance { get; private set; }

	public override void Load()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Expected O, but got Unknown
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Expected O, but got Unknown
		Instance = this;
		VisualizerColor = ((BasePlugin)this).Config.Bind<string>("Appearance", "Color", "#ffffff", "Color of the lines/cell (#rrggbb)");
		VisualizerOpacity = ((BasePlugin)this).Config.Bind<float>("Appearance", "Opacity", 0.002f, new ConfigDescription("Opacity of both the lines/cell. I'd recommend starting with a very near-zero number", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		SolidFill = ((BasePlugin)this).Config.Bind<bool>("Appearance", "SolidFill", true, "The visual is drawn as a solid filled shape instead of a wireframe outline.");
		ShowDistMinIndicator = ((BasePlugin)this).Config.Bind<bool>("Appearance", "ShowDistMinIndicator", false, "Draws the full-damage boundary indicator at the point where max damage ends and falloff begins.");
		VisualizerEnabled = ((BasePlugin)this).Config.Bind<bool>("Detection", "Enabled to start?", true, "For when you don't want to see this extra information by default");
		ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("Detection", "ToggleKey", (KeyCode)98, "Key for hot-toggling all functionality.");
		BeamLength = ((BasePlugin)this).Config.Bind<float>("Detection", "BeamLengthPadding", 2.5f, new ConfigDescription("Distance in meters beyond the end of the beam within which the explosion visualizer will still activate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
		BeamWidth = ((BasePlugin)this).Config.Bind<float>("Detection", "BeamWidthPadding", 5f, new ConfigDescription("Distance in meters beyond the width of the beam within which the explosion visualizer will still activate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 20f), Array.Empty<object>()));
		BeamHeight = ((BasePlugin)this).Config.Bind<float>("Detection", "BeamHeightPadding", 5f, new ConfigDescription("Distance in meters beyond the height of the beam within which the explosion visualizer will still activate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 20f), Array.Empty<object>()));
		ClassInjector.RegisterTypeInIl2Cpp<MineVisualizerUpdater>();
		new Harmony("mineexplosionvisualizer.HazardousMonkey").PatchAll();
		LiveEdit.CreateListener(Paths.ConfigPath, Path.GetFileName(((BasePlugin)this).Config.ConfigFilePath), false).FileChanged += (LiveEditEventHandler)delegate
		{
			((BasePlugin)this).Config.Reload();
			MineVisualizerManager.MarkConfigDirty();
		};
		MineVisualizerManager.RefreshConfig();
		((BasePlugin)this).Log.LogInfo((object)"[MineExplosionVisualizer] Loaded successfully.");
	}
}
public static class MineVisualizerManager
{
	private readonly struct MineEntry
	{
		public readonly Transform AlignTransform;

		public readonly MineDeployerInstance_Detonate_Explosive Detonate;

		public readonly Vector3 NormalizedLocalDir;

		public MineEntry(Transform align, MineDeployerInstance_Detonate_Explosive det)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			AlignTransform = align;
			Detonate = det;
			? normalizedLocalDir;
			if (!((Object)(object)det != (Object)null))
			{
				normalizedLocalDir = new Vector3(0f, 0f, -1f);
			}
			else
			{
				Vector3 explosionDirection = det.m_explosionDirection;
				normalizedLocalDir = ((Vector3)(ref explosionDirection)).normalized;
			}
			NormalizedLocalDir = (Vector3)normalizedLocalDir;
		}
	}

	private static readonly Dictionary<MineDeployerInstance_Detect_Laser, MineEntry> _mines = new Dictionary<MineDeployerInstance_Detect_Laser, MineEntry>();

	private static readonly List<MineDeployerInstance_Detect_Laser> _mineKeys = new List<MineDeployerInstance_Detect_Laser>();

	private static readonly List<(MineDeployerInstance_Detect_Laser Laser, MineDeployerInstance_Detonate_Explosive Detonate, Vector3 NormalizedLocalDir)> _visibleMines = new List<(MineDeployerInstance_Detect_Laser, MineDeployerInstance_Detonate_Explosive, Vector3)>();

	private static readonly List<MineDeployerInstance_Detect_Laser> _dead = new List<MineDeployerInstance_Detect_Laser>();

	public static Color VisColor = new Color(1f, 0.27f, 0f, 0.75f);

	public static float CfgBeamLength = 2.5f;

	public static float CfgBeamWidth = 5f;

	public static float CfgBeamHeight = 5f;

	public static bool CfgSolidFill = false;

	public static bool CfgShowDistMinIndicator = false;

	public static bool Enabled = true;

	public static KeyCode CfgToggleKey = (KeyCode)98;

	private static volatile bool _configDirty = false;

	public static IReadOnlyList<(MineDeployerInstance_Detect_Laser Laser, MineDeployerInstance_Detonate_Explosive Detonate, Vector3 NormalizedLocalDir)> VisibleMines => _visibleMines;

	public static void MarkConfigDirty()
	{
		_configDirty = true;
	}

	public static bool ConsumeConfigDirty()
	{
		if (!_configDirty)
		{
			return false;
		}
		_configDirty = false;
		return true;
	}

	public static void RegisterMine(MineDeployerInstance_Detect_Laser laser, Transform alignTf, MineDeployerInstance_Detonate_Explosive detonate)
	{
		if (!((Object)(object)laser == (Object)null) && !(((Il2CppObjectBase)laser).Pointer == IntPtr.Zero))
		{
			if (!_mines.ContainsKey(laser))
			{
				_mineKeys.Add(laser);
			}
			_mines[laser] = new MineEntry(alignTf, detonate);
		}
	}

	public static void UnregisterMine(MineDeployerInstance_Detect_Laser laser)
	{
		if (!((Object)(object)laser == (Object)null))
		{
			_mines.Remove(laser);
			RemoveKeySwapBack(laser);
		}
	}

	private static void RemoveKeySwapBack(MineDeployerInstance_Detect_Laser key)
	{
		int num = _mineKeys.IndexOf(key);
		if (num >= 0)
		{
			int index = _mineKeys.Count - 1;
			_mineKeys[num] = _mineKeys[index];
			_mineKeys.RemoveAt(index);
		}
	}

	public static bool TryGetEntry(MineDeployerInstance_Detect_Laser laser, out Transform alignTf, out MineDeployerInstance_Detonate_Explosive detonate)
	{
		if (_mines.TryGetValue(laser, out var value))
		{
			alignTf = value.AlignTransform;
			detonate = value.Detonate;
			return true;
		}
		alignTf = null;
		detonate = null;
		return false;
	}

	public static void Tick(Vector3 playerPos)
	{
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		_dead.Clear();
		foreach (MineDeployerInstance_Detect_Laser mineKey in _mineKeys)
		{
			if ((Object)(object)mineKey == (Object)null || ((Il2CppObjectBase)mineKey).Pointer == IntPtr.Zero)
			{
				_dead.Add(mineKey);
			}
		}
		foreach (MineDeployerInstance_Detect_Laser item in _dead)
		{
			_mines.Remove(item);
			RemoveKeySwapBack(item);
		}
		_visibleMines.Clear();
		foreach (MineDeployerInstance_Detect_Laser mineKey2 in _mineKeys)
		{
			if (_mines.TryGetValue(mineKey2, out var value))
			{
				Transform alignTransform = value.AlignTransform;
				if (!((Object)(object)alignTransform == (Object)null) && !(((Il2CppObjectBase)alignTransform).Pointer == IntPtr.Zero) && IsPlayerInBeam(alignTransform, mineKey2.m_maxLineDistance, playerPos))
				{
					_visibleMines.Add((mineKey2, value.Detonate, value.NormalizedLocalDir));
				}
			}
		}
	}

	public static void Cleanup()
	{
		_mines.Clear();
		_mineKeys.Clear();
		_visibleMines.Clear();
		_dead.Clear();
		MineVisualizerUpdater.ResetCaches();
	}

	public static void ClearVisible()
	{
		_visibleMines.Clear();
	}

	public static void RefreshConfig()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		Color val = ParseHexColor(MineExplosionVisualizerPlugin.VisualizerColor.Value, new Color(1f, 0.27f, 0f));
		float value = MineExplosionVisualizerPlugin.VisualizerOpacity.Value;
		VisColor = new Color(val.r, val.g, val.b, value);
		CfgBeamLength = MineExplosionVisualizerPlugin.BeamLength.Value;
		CfgBeamWidth = MineExplosionVisualizerPlugin.BeamWidth.Value;
		CfgBeamHeight = MineExplosionVisualizerPlugin.BeamHeight.Value;
		CfgSolidFill = MineExplosionVisualizerPlugin.SolidFill.Value;
		CfgShowDistMinIndicator = MineExplosionVisualizerPlugin.ShowDistMinIndicator.Value;
		CfgToggleKey = MineExplosionVisualizerPlugin.ToggleKey.Value;
		Enabled = MineExplosionVisualizerPlugin.VisualizerEnabled.Value;
		Debug.Log(Object.op_Implicit($"[MineExplosionVisualizer] Config refreshed → color={VisColor} beamLen={CfgBeamLength} beamW={CfgBeamWidth} beamH={CfgBeamHeight} solid={CfgSolidFill} distMinIndicator={CfgShowDistMinIndicator} toggleKey={CfgToggleKey} enabled={Enabled}"));
	}

	private static bool IsPlayerInBeam(Transform alignTf, float maxDist, Vector3 playerPos)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_005a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)alignTf == (Object)null || ((Il2CppObjectBase)alignTf).Pointer == IntPtr.Zero)
		{
			return false;
		}
		Vector3 position = alignTf.position;
		Vector3 forward = alignTf.forward;
		float num = Vector3.Dot(playerPos - position, forward);
		if (num < 0f || num > maxDist + CfgBeamLength)
		{
			return false;
		}
		Vector3 val = position + forward * num;
		Vector3 val2 = playerPos - val;
		float num2 = Mathf.Sqrt(val2.x * val2.x + val2.z * val2.z);
		float num3 = Mathf.Abs(val2.y);
		if (num2 < CfgBeamWidth)
		{
			return num3 < CfgBeamHeight;
		}
		return false;
	}

	private static Color ParseHexColor(string hex, Color fallback)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (hex != null && hex.Length == 7 && hex[0] == '#')
			{
				int num = HexPair(hex, 1);
				int num2 = HexPair(hex, 3);
				int num3 = HexPair(hex, 5);
				if (num >= 0 && num2 >= 0 && num3 >= 0)
				{
					return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f);
				}
			}
		}
		catch
		{
		}
		Debug.LogWarning(Object.op_Implicit("[MineExplosionVisualizer] Could not parse color '" + hex + "' — using fallback."));
		return fallback;
	}

	private static int HexPair(string s, int i)
	{
		int num = HexNibble(s[i]);
		int num2 = HexNibble(s[i + 1]);
		if (num < 0 || num2 < 0)
		{
			return -1;
		}
		return (num << 4) | num2;
	}

	private static int HexNibble(char c)
	{
		if (c >= '0' && c <= '9')
		{
			return c - 48;
		}
		if (c >= 'a' && c <= 'f')
		{
			return c - 97 + 10;
		}
		if (c >= 'A' && c <= 'F')
		{
			return c - 65 + 10;
		}
		return -1;
	}
}
public class MineVisualizerUpdater : MonoBehaviour
{
	private readonly struct CapsuleGeometry
	{
		public readonly Vector3 PointA;

		public readonly Vector3 PointB;

		public readonly Vector3 Dir;

		public readonly Vector3 Right;

		public readonly Vector3 Up;

		public readonly float Radius;

		public readonly float DistMin;

		public readonly float DistMax;

		public readonly bool Valid;

		public CapsuleGeometry(MineDeployerInstance_Detect_Laser laser, MineDeployerInstance_Detonate_Explosive detonate, Vector3 normalizedLocalDir)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			if ((Object)(object)detonate == (Object)null || ((Il2CppObjectBase)detonate).Pointer == IntPtr.Zero)
			{
				val = (Up = Vector3.zero);
				val = (Right = val);
				val = (Dir = val);
				val = (PointA = (PointB = val));
				Radius = (DistMin = (DistMax = 0f));
				Valid = false;
				return;
			}
			float num = Mathf.Min(0.5f, laser.DetectionRange * 0.5f);
			Dir = ((Component)detonate).transform.TransformDirection(normalizedLocalDir);
			PointA = ((Component)detonate).transform.position + Dir * num;
			Radius = detonate.m_radius;
			DistMin = detonate.m_distanceMin;
			DistMax = detonate.m_distanceMax;
			if (Radius <= 0f)
			{
				Radius = 2f;
			}
			if (DistMax <= 0f)
			{
				DistMax = 6f;
			}
			PointB = PointA + Dir * DistMax;
			Right = Vector3.Cross(Dir, Vector3.up);
			Vector3 right = ((((Vector3)(ref Right)).sqrMagnitude < 0.0001f) ? Vector3.Cross(Dir, Vector3.forward) : Right);
			((Vector3)(ref right)).Normalize();
			Right = right;
			val = Vector3.Cross(Right, Dir);
			Up = ((Vector3)(ref val)).normalized;
			Valid = true;
		}
	}

	private const int CircleSegments = 32;

	private const int HemiSegments = 16;

	private static readonly float[] _ringCos = new float[33];

	private static readonly float[] _ringSin = new float[33];

	private static readonly float[] _hemiCos = new float[17];

	private static readonly float[] _hemiSin = new float[17];

	private static bool _lutReady = false;

	private const float RimAmbient = 0.15f;

	private static Material _glMat;

	private static bool _matReady = false;

	private static readonly List<CapsuleGeometry> _frameGeo = new List<CapsuleGeometry>();

	private static GameObject _host;

	private static Camera _mainCam;

	private static PlayerAgent _localPlayer;

	private static void EnsureLUT()
	{
		if (!_lutReady)
		{
			float num = (float)Math.PI / 16f;
			for (int i = 0; i <= 32; i++)
			{
				_ringCos[i] = Mathf.Cos((float)i * num);
				_ringSin[i] = Mathf.Sin((float)i * num);
			}
			float num2 = (float)Math.PI / 16f;
			for (int j = 0; j <= 16; j++)
			{
				_hemiCos[j] = Mathf.Cos((float)j * num2);
				_hemiSin[j] = Mathf.Sin((float)j * num2);
			}
			_lutReady = true;
		}
	}

	public MineVisualizerUpdater(IntPtr ptr)
		: base(ptr)
	{
	}

	public static void EnsureCreated()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		if (!((Object)(object)_host != (Object)null) || !(((Il2CppObjectBase)_host).Pointer != IntPtr.Zero))
		{
			_host = new GameObject("MineVisualizerHost");
			Object.DontDestroyOnLoad((Object)(object)_host);
			((Il2CppObjectBase)_host.AddComponent(Il2CppType.Of<MineVisualizerUpdater>())).Cast<MineVisualizerUpdater>();
			Debug.Log(Object.op_Implicit("[MineExplosionVisualizer] MineVisualizerUpdater host created."));
		}
	}

	public static void ResetCaches()
	{
		_localPlayer = null;
		_mainCam = null;
	}

	private static void EnsureMaterial()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		if (!_matReady)
		{
			_glMat = new Material(Shader.Find("Hidden/Internal-Colored"));
			((Object)_glMat).hideFlags = (HideFlags)61;
			_glMat.SetInt("_SrcBlend", 5);
			_glMat.SetInt("_DstBlend", 10);
			_glMat.SetInt("_Cull", 0);
			_glMat.SetInt("_ZWrite", 0);
			_glMat.SetInt("_ZTest", 8);
			_matReady = true;
		}
	}

	private void Update()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		if (MineVisualizerManager.ConsumeConfigDirty())
		{
			MineVisualizerManager.RefreshConfig();
		}
		if ((int)FocusStateManager.CurrentState == 4 && Input.GetKeyDown(MineVisualizerManager.CfgToggleKey))
		{
			MineVisualizerManager.Enabled = !MineVisualizerManager.Enabled;
			Debug.Log(Object.op_Implicit("[MineExplosionVisualizer] Visualizer " + (MineVisualizerManager.Enabled ? "ENABLED" : "DISABLED") + "."));
		}
		if (!MineVisualizerManager.Enabled)
		{
			MineVisualizerManager.ClearVisible();
			return;
		}
		if ((Object)(object)_localPlayer == (Object)null || ((Il2CppObjectBase)_localPlayer).Pointer == IntPtr.Zero)
		{
			_localPlayer = PlayerManager.GetLocalPlayerAgent();
		}
		if ((Object)(object)_localPlayer == (Object)null || ((Il2CppObjectBase)_localPlayer).Pointer == IntPtr.Zero)
		{
			MineVisualizerManager.Tick(Vector3.zero);
		}
		else
		{
			MineVisualizerManager.Tick(((Component)_localPlayer).transform.position + Vector3.up * 1.4f);
		}
	}

	private void OnRenderObject()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_mainCam == (Object)null)
		{
			_mainCam = Camera.main;
		}
		if ((Object)(object)Camera.current != (Object)(object)_mainCam || MineVisualizerManager.VisibleMines.Count == 0)
		{
			return;
		}
		EnsureMaterial();
		EnsureLUT();
		bool cfgSolidFill = MineVisualizerManager.CfgSolidFill;
		Vector3 forward = ((Component)Camera.current).transform.forward;
		Color visColor = MineVisualizerManager.VisColor;
		_frameGeo.Clear();
		foreach (var (val, val2, normalizedLocalDir) in MineVisualizerManager.VisibleMines)
		{
			if (!((Object)(object)val == (Object)null) && !(((Il2CppObjectBase)val).Pointer == IntPtr.Zero) && !((Object)(object)val2 == (Object)null) && !(((Il2CppObjectBase)val2).Pointer == IntPtr.Zero))
			{
				CapsuleGeometry item = new CapsuleGeometry(val, val2, normalizedLocalDir);
				if (item.Valid)
				{
					_frameGeo.Add(item);
				}
			}
		}
		if (_frameGeo.Count == 0)
		{
			return;
		}
		_glMat.SetPass(0);
		GL.PushMatrix();
		if (cfgSolidFill)
		{
			GL.Begin(4);
			GL.Color(visColor);
			foreach (CapsuleGeometry item2 in _frameGeo)
			{
				CapsuleGeometry geo = item2;
				DrawExplosionCapsuleSolid(in geo, visColor, forward);
			}
			GL.End();
		}
		GL.Begin(1);
		GL.Color(visColor);
		foreach (CapsuleGeometry item3 in _frameGeo)
		{
			CapsuleGeometry geo2 = item3;
			DrawExplosionCapsule(in geo2);
		}
		GL.End();
		GL.PopMatrix();
	}

	private static void DrawExplosionCapsule(in CapsuleGeometry geo)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		Vector3 pointA = geo.PointA;
		Vector3 pointB = geo.PointB;
		Vector3 dir = geo.Dir;
		Vector3 right = geo.Right;
		Vector3 up = geo.Up;
		float radius = geo.Radius;
		float distMin = geo.DistMin;
		float distMax = geo.DistMax;
		DrawRing(pointA, right, up, radius);
		DrawRing(pointB, right, up, radius);
		for (int i = 0; i < 4; i++)
		{
			int num = i * 8;
			Vector3 val = (right * _ringCos[num] + up * _ringSin[num]) * radius;
			GL.Vertex(pointA + val);
			GL.Vertex(pointB + val);
		}
		DrawHemisphere(pointA, right, up, -dir, radius);
		DrawHemisphere(pointB, right, up, dir, radius);
		if (distMin > 0.01f && distMin < distMax && MineVisualizerManager.CfgShowDistMinIndicator)
		{
			Vector3 val2 = pointA + dir * distMin;
			DrawRing(val2, right, up, radius);
			GL.Vertex(val2 + right * radius);
			GL.Vertex(val2 - right * radius);
			GL.Vertex(val2 + up * radius);
			GL.Vertex(val2 - up * radius);
		}
	}

	private static void DrawRing(Vector3 center, Vector3 right, Vector3 up, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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)
		//IL_0012: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = center + right * radius;
		for (int i = 1; i <= 32; i++)
		{
			Vector3 val2 = center + (right * _ringCos[i] + up * _ringSin[i]) * radius;
			GL.Vertex(val);
			GL.Vertex(val2);
			val = val2;
		}
	}

	private static void DrawHemisphere(Vector3 center, Vector3 right, Vector3 up, Vector3 pole, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: 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_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		DrawHalfArc(center, right, pole, radius);
		DrawHalfArc(center, up, pole, radius);
	}

	private static void DrawHalfArc(Vector3 center, Vector3 side, Vector3 pole, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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)
		//IL_0012: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = center + side * radius;
		for (int i = 1; i <= 16; i++)
		{
			Vector3 val2 = center + (side * _hemiCos[i] + pole * _hemiSin[i]) * radius;
			GL.Vertex(val);
			GL.Vertex(val2);
			val = val2;
		}
	}

	private static void DrawExplosionCapsuleSolid(in CapsuleGeometry geo, Color baseColor, Vector3 viewDir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		DrawCylinderSolid(geo.PointA, geo.PointB, geo.Right, geo.Up, geo.Radius, baseColor, viewDir);
		DrawCapSolid(geo.PointA, geo.Right, geo.Up, -geo.Dir, geo.Radius, baseColor, viewDir);
		DrawCapSolid(geo.PointB, geo.Right, geo.Up, geo.Dir, geo.Radius, baseColor, viewDir);
		if (geo.DistMin > 0.01f && geo.DistMin < geo.DistMax && MineVisualizerManager.CfgShowDistMinIndicator)
		{
			DrawDiscSolid(geo.PointA + geo.Dir * geo.DistMin, geo.Right, geo.Up, geo.Radius, geo.Dir, baseColor, viewDir);
		}
	}

	private static void DrawCylinderSolid(Vector3 pointA, Vector3 pointB, Vector3 right, Vector3 up, float radius, Color baseColor, Vector3 viewDir)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_0025: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: 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)
		Vector3 val = right * _ringCos[0] + up * _ringSin[0];
		float num = 1f - Mathf.Abs(Vector3.Dot(val, viewDir));
		float num2 = 0.15f + 0.85f * num;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(baseColor.r * num2, baseColor.g * num2, baseColor.b * num2, baseColor.a);
		Color val4 = default(Color);
		for (int i = 0; i < 32; i++)
		{
			Vector3 val3 = right * _ringCos[i + 1] + up * _ringSin[i + 1];
			float num3 = 1f - Mathf.Abs(Vector3.Dot(val3, viewDir));
			float num4 = 0.15f + 0.85f * num3;
			((Color)(ref val4))..ctor(baseColor.r * num4, baseColor.g * num4, baseColor.b * num4, baseColor.a);
			Vector3 val5 = pointA + val * radius;
			Vector3 val6 = pointA + val3 * radius;
			Vector3 val7 = pointB + val * radius;
			Vector3 val8 = pointB + val3 * radius;
			GL.Color(val2);
			GL.Vertex(val5);
			GL.Color(val2);
			GL.Vertex(val7);
			GL.Color(val4);
			GL.Vertex(val8);
			GL.Color(val2);
			GL.Vertex(val5);
			GL.Color(val4);
			GL.Vertex(val8);
			GL.Color(val4);
			GL.Vertex(val6);
			val = val3;
			val2 = val4;
		}
	}

	private static void DrawCapSolid(Vector3 center, Vector3 right, Vector3 up, Vector3 poleDir, float radius, Color baseColor, Vector3 viewDir)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = center + poleDir * radius;
		float num = 1f - Mathf.Abs(Vector3.Dot(poleDir, viewDir));
		float num2 = 0.15f + 0.85f * num;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(baseColor.r * num2, baseColor.g * num2, baseColor.b * num2, baseColor.a);
		Vector3 val3 = right * _ringCos[0] + up * _ringSin[0];
		float num3 = 1f - Mathf.Abs(Vector3.Dot(val3, viewDir));
		float num4 = 0.15f + 0.85f * num3;
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(baseColor.r * num4, baseColor.g * num4, baseColor.b * num4, baseColor.a);
		for (int i = 0; i < 32; i++)
		{
			Vector3 val5 = right * _ringCos[i + 1] + up * _ringSin[i + 1];
			float num5 = 1f - Mathf.Abs(Vector3.Dot(val5, viewDir));
			float num6 = 0.15f + 0.85f * num5;
			Color val6 = new Color(baseColor.r * num6, baseColor.g * num6, baseColor.b * num6, baseColor.a);
			GL.Color(val2);
			GL.Vertex(val);
			GL.Color(val4);
			GL.Vertex(center + val3 * radius);
			GL.Color(val6);
			GL.Vertex(center + val5 * radius);
			val3 = val5;
			val4 = val6;
		}
	}

	private static void DrawDiscSolid(Vector3 center, Vector3 right, Vector3 up, float radius, Vector3 axisNormal, Color baseColor, Vector3 viewDir)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		float num = 1f - Mathf.Abs(Vector3.Dot(axisNormal, viewDir));
		float num2 = 0.15f + 0.85f * num;
		GL.Color(new Color(baseColor.r * num2, baseColor.g * num2, baseColor.b * num2, baseColor.a));
		for (int i = 0; i < 32; i++)
		{
			Vector3 val = center + (right * _ringCos[i] + up * _ringSin[i]) * radius;
			Vector3 val2 = center + (right * _ringCos[i + 1] + up * _ringSin[i + 1]) * radius;
			GL.Vertex(center);
			GL.Vertex(val);
			GL.Vertex(val2);
			GL.Vertex(center);
			GL.Vertex(val2);
			GL.Vertex(val);
		}
	}
}
[HarmonyPatch(typeof(MineDeployerInstance_Detect_Laser), "Setup")]
public static class Patch_LaserSetup
{
	public static void Postfix(MineDeployerInstance_Detect_Laser __instance)
	{
		try
		{
			MineVisualizerUpdater.EnsureCreated();
			Transform val = FindChildByName(((Component)__instance).transform, "lineAlign");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning(Object.op_Implicit("[MineExplosionVisualizer] Could not find 'lineAlign' child — beam-intersection check will be skipped for this mine."));
			}
			MineDeployerInstance_Detonate_Explosive component = ((Component)__instance).gameObject.GetComponent<MineDeployerInstance_Detonate_Explosive>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning(Object.op_Implicit("[MineExplosionVisualizer] Could not find MineDeployerInstance_Detonate_Explosive on mine GO."));
			}
			MineVisualizerManager.RegisterMine(__instance, val, component);
		}
		catch (Exception ex)
		{
			Debug.LogWarning(Object.op_Implicit("[MineExplosionVisualizer] Patch_LaserSetup failed: " + ex.Message));
		}
	}

	private static Transform FindChildByName(Transform parent, string name)
	{
		for (int i = 0; i < parent.childCount; i++)
		{
			Transform child = parent.GetChild(i);
			if (((Object)child).name == name)
			{
				return child;
			}
			Transform val = FindChildByName(child, name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}
}
[HarmonyPatch(typeof(MineDeployerInstance_Detonate_Explosive), "TriggerDetonate")]
public static class Patch_MineTriggered
{
	public static void Postfix(MineDeployerInstance_Detonate_Explosive __instance)
	{
		try
		{
			MineDeployerInstance_Detect_Laser component = ((Component)__instance).gameObject.GetComponent<MineDeployerInstance_Detect_Laser>();
			if ((Object)(object)component != (Object)null)
			{
				MineVisualizerManager.UnregisterMine(component);
			}
		}
		catch
		{
		}
	}
}
[HarmonyPatch(typeof(GameStateManager), "ChangeState")]
public static class Patch_GameStateChanged
{
	public static void Postfix(eGameStateName nextState)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Invalid comparison between Unknown and I4
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Invalid comparison between Unknown and I4
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		try
		{
			if ((int)nextState == 11 || (int)nextState == 15 || (int)nextState == 14 || (int)nextState == 16 || (int)nextState == 5 || (int)nextState == 6)
			{
				MineVisualizerManager.Cleanup();
			}
		}
		catch
		{
		}
	}
}