Decompiled source of HitboxWireframeVisualizer v1.0.0

HitboxWireframeVisualizer.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOJP.HitboxWireframeVisualizer
{
	[BepInPlugin("REPOJP.HitboxWireframeVisualizer", "HitboxWireframeVisualizer", "1.0.0")]
	public sealed class HitboxWireframeVisualizerPlugin : BaseUnityPlugin
	{
		private enum Genre
		{
			Unknown,
			Player,
			RoomModule,
			Item,
			Enemy,
			Trace
		}

		private enum ShapeKind
		{
			Box,
			Sphere,
			Capsule,
			Ray
		}

		private struct RootInfo
		{
			public GameObject Root;

			public Genre Genre;

			public float DistanceSqr;
		}

		private struct SamplePoint
		{
			public Vector3 Position;

			public Color Color;
		}

		private struct Shape
		{
			public ShapeKind Kind;

			public GameObject OwnerRoot;

			public Genre Genre;

			public Vector3 Center;

			public Vector3 Size;

			public Quaternion Rotation;

			public float Radius;

			public float Height;

			public int CapsuleDirection;

			public Vector3 RayOrigin;

			public Vector3 RayDir;

			public float RayLength;

			public Color Color;

			public float DistanceSqr;

			public static Shape Box(GameObject root, Genre genre, Vector3 center, Vector3 size, Quaternion rot, Color color, float ds)
			{
				//IL_0023: 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)
				//IL_002c: 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_0035: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				Shape result = default(Shape);
				result.Kind = ShapeKind.Box;
				result.OwnerRoot = root;
				result.Genre = genre;
				result.Center = center;
				result.Size = size;
				result.Rotation = rot;
				result.Color = color;
				result.DistanceSqr = ds;
				return result;
			}

			public static Shape Sphere(GameObject root, Genre genre, Vector3 center, float radius, Color color, float ds)
			{
				//IL_0023: 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_0033: 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)
				Shape result = default(Shape);
				result.Kind = ShapeKind.Sphere;
				result.OwnerRoot = root;
				result.Genre = genre;
				result.Center = center;
				result.Radius = radius;
				result.Color = color;
				result.DistanceSqr = ds;
				return result;
			}

			public static Shape Capsule(GameObject root, Genre genre, Vector3 center, float radius, float height, int dir, Quaternion rot, Color color, float ds)
			{
				//IL_0023: 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_0045: 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_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)
				Shape result = default(Shape);
				result.Kind = ShapeKind.Capsule;
				result.OwnerRoot = root;
				result.Genre = genre;
				result.Center = center;
				result.Radius = radius;
				result.Height = height;
				result.CapsuleDirection = dir;
				result.Rotation = rot;
				result.Color = color;
				result.DistanceSqr = ds;
				return result;
			}

			public static Shape Ray(GameObject root, Genre genre, Vector3 origin, Vector3 dir, float length, Color color, float ds)
			{
				//IL_0023: 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)
				//IL_002c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				Shape result = default(Shape);
				result.Kind = ShapeKind.Ray;
				result.OwnerRoot = root;
				result.Genre = genre;
				result.RayOrigin = origin;
				result.RayDir = dir;
				result.RayLength = length;
				result.Color = color;
				result.DistanceSqr = ds;
				return result;
			}

			public Bounds GetApproxBounds()
			{
				//IL_000f: 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_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_0049: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: 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_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_0097: 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_016f: 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_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_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: 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_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: 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_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: 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_0151: 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_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: 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_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)
				if (Kind == ShapeKind.Box)
				{
					return new Bounds(Center, Size);
				}
				if (Kind == ShapeKind.Sphere)
				{
					return new Bounds(Center, Vector3.one * (Radius * 2f));
				}
				if (Kind == ShapeKind.Capsule)
				{
					float num = Mathf.Max(Height, Radius * 2f);
					return new Bounds(Center, Vector3.one * num);
				}
				if (Kind == ShapeKind.Ray)
				{
					Vector3 val = RayOrigin + ((Vector3)(ref RayDir)).normalized * Mathf.Max(0.02f, RayLength);
					Vector3 val2 = (RayOrigin + val) * 0.5f;
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(Mathf.Abs(val.x - RayOrigin.x), Mathf.Abs(val.y - RayOrigin.y), Mathf.Abs(val.z - RayOrigin.z));
					val3 += Vector3.one * 0.05f;
					return new Bounds(val2, val3);
				}
				return new Bounds(Center, Vector3.one * 0.1f);
			}

			public bool ContainsApprox(Vector3 p)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_009d: Unknown result type (might be due to invalid IL or missing references)
				if (Kind == ShapeKind.Box)
				{
					Bounds val = default(Bounds);
					((Bounds)(ref val))..ctor(Center, Size);
					return ((Bounds)(ref val)).Contains(p);
				}
				Vector3 val2;
				if (Kind == ShapeKind.Sphere)
				{
					val2 = p - Center;
					return ((Vector3)(ref val2)).sqrMagnitude <= Radius * Radius;
				}
				if (Kind == ShapeKind.Capsule)
				{
					float num = Mathf.Max(Radius, Height * 0.5f);
					val2 = p - Center;
					return ((Vector3)(ref val2)).sqrMagnitude <= num * num;
				}
				return false;
			}
		}

		private struct Candidate
		{
			public Collider Col;

			public float DistSqr;
		}

		private struct CachedColliderInfo
		{
			public GameObject Root;

			public Genre Genre;

			public int LastFrame;
		}

		private struct CachedRootRenderers
		{
			public GameObject Root;

			public Renderer[] Renderers;

			public int LastFrame;
		}

		private sealed class ModelTransparencyManager
		{
			private struct RendererState
			{
				public Renderer Renderer;

				public Material[] OriginalSharedMaterials;

				public bool OriginalEnabled;
			}

			private readonly Func<bool> _forceFallback;

			private readonly Func<bool> _useMpb;

			private readonly Func<GameObject, Renderer[]> _getRenderers;

			private readonly Dictionary<int, RendererState> _states = new Dictionary<int, RendererState>(1024);

			private readonly HashSet<int> _touchedThisFrame = new HashSet<int>();

			private Shader _fallbackShader;

			private readonly MaterialPropertyBlock _mpb = new MaterialPropertyBlock();

			private readonly Dictionary<int, float> _rootAlpha = new Dictionary<int, float>(256);

			public ModelTransparencyManager(Func<bool> forceFallback, Func<bool> useMpb, Func<GameObject, Renderer[]> getRenderers)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Expected O, but got Unknown
				_forceFallback = forceFallback;
				_useMpb = useMpb;
				_getRenderers = getRenderers;
				_fallbackShader = FindFallbackTransparentShader();
			}

			public void BeginFrame()
			{
				_touchedThisFrame.Clear();
			}

			public void EndFrame()
			{
				int[] array = _states.Keys.ToArray();
				foreach (int num in array)
				{
					if (!_touchedThisFrame.Contains(num))
					{
						RestoreRenderer(num);
					}
				}
			}

			public void SweepOrphans()
			{
				int[] array = _states.Keys.ToArray();
				foreach (int key in array)
				{
					if (_states.TryGetValue(key, out var value) && (Object)(object)value.Renderer == (Object)null)
					{
						_states.Remove(key);
					}
				}
			}

			public void RestoreAll()
			{
				int[] array = _states.Keys.ToArray();
				for (int i = 0; i < array.Length; i++)
				{
					RestoreRenderer(array[i]);
				}
				_states.Clear();
				_touchedThisFrame.Clear();
				_rootAlpha.Clear();
			}

			public void ApplyTransparent(GameObject root, float alpha01)
			{
				if ((Object)(object)root == (Object)null)
				{
					return;
				}
				int instanceID = ((Object)root).GetInstanceID();
				if (_rootAlpha.TryGetValue(instanceID, out var value) && Mathf.Abs(value - alpha01) < 0.001f)
				{
					Renderer[] array = _getRenderers(root);
					foreach (Renderer val in array)
					{
						if (!((Object)(object)val == (Object)null))
						{
							_touchedThisFrame.Add(((Object)val).GetInstanceID());
						}
					}
					return;
				}
				_rootAlpha[instanceID] = alpha01;
				Renderer[] array2 = _getRenderers(root);
				bool flag = _useMpb();
				foreach (Renderer val2 in array2)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						int instanceID2 = ((Object)val2).GetInstanceID();
						_touchedThisFrame.Add(instanceID2);
						if (!_states.ContainsKey(instanceID2))
						{
							CacheOriginal(val2);
						}
						if (flag)
						{
							ApplyTransparencyByMpb(val2, alpha01);
						}
						else
						{
							ApplyTransparencyByMaterials(val2, alpha01);
						}
					}
				}
			}

			private void CacheOriginal(Renderer r)
			{
				if ((Object)(object)r == (Object)null)
				{
					return;
				}
				int instanceID = ((Object)r).GetInstanceID();
				try
				{
					RendererState rendererState = default(RendererState);
					rendererState.Renderer = r;
					rendererState.OriginalSharedMaterials = r.sharedMaterials;
					rendererState.OriginalEnabled = r.enabled;
					RendererState value = rendererState;
					_states[instanceID] = value;
				}
				catch
				{
				}
			}

			private void RestoreRenderer(int id)
			{
				if (!_states.TryGetValue(id, out var value))
				{
					return;
				}
				if ((Object)(object)value.Renderer == (Object)null)
				{
					_states.Remove(id);
					return;
				}
				try
				{
					value.Renderer.SetPropertyBlock((MaterialPropertyBlock)null);
				}
				catch
				{
				}
				try
				{
					value.Renderer.sharedMaterials = value.OriginalSharedMaterials;
					value.Renderer.enabled = value.OriginalEnabled;
				}
				catch
				{
				}
				_states.Remove(id);
			}

			private void ApplyTransparencyByMpb(Renderer r, float alpha01)
			{
				//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_0047: 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_0086: Unknown result type (might be due to invalid IL or missing references)
				bool flag = false;
				try
				{
					Material sharedMaterial = r.sharedMaterial;
					if ((Object)(object)sharedMaterial != (Object)null)
					{
						if (sharedMaterial.HasProperty("_Color"))
						{
							Color color = sharedMaterial.GetColor("_Color");
							color.a = alpha01;
							_mpb.SetColor("_Color", color);
							flag = true;
						}
						else if (sharedMaterial.HasProperty("_BaseColor"))
						{
							Color color2 = sharedMaterial.GetColor("_BaseColor");
							color2.a = alpha01;
							_mpb.SetColor("_BaseColor", color2);
							flag = true;
						}
					}
				}
				catch
				{
				}
				if (flag)
				{
					try
					{
						r.SetPropertyBlock(_mpb);
					}
					catch
					{
					}
					_mpb.Clear();
				}
			}

			private void ApplyTransparencyByMaterials(Renderer r, float alpha01)
			{
				Material[] materials;
				try
				{
					materials = r.materials;
				}
				catch
				{
					return;
				}
				bool flag = _forceFallback();
				foreach (Material val in materials)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					bool flag2 = false;
					if (!flag)
					{
						flag2 = TrySetAlphaOnly(val, alpha01);
						if (flag2)
						{
							TrySetBlendTransparent(val);
						}
					}
					if (flag2)
					{
						continue;
					}
					if ((Object)(object)_fallbackShader == (Object)null)
					{
						_fallbackShader = FindFallbackTransparentShader();
					}
					if ((Object)(object)_fallbackShader != (Object)null)
					{
						try
						{
							val.shader = _fallbackShader;
						}
						catch
						{
						}
						TrySetAlphaOnly(val, alpha01);
						TrySetBlendTransparent(val);
					}
				}
				try
				{
					r.materials = materials;
				}
				catch
				{
				}
			}

			private bool TrySetAlphaOnly(Material m, float alpha01)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				if (m.HasProperty("_Color"))
				{
					Color color = m.GetColor("_Color");
					color.a = alpha01;
					m.SetColor("_Color", color);
					return true;
				}
				if (m.HasProperty("_BaseColor"))
				{
					Color color2 = m.GetColor("_BaseColor");
					color2.a = alpha01;
					m.SetColor("_BaseColor", color2);
					return true;
				}
				return false;
			}

			private void TrySetBlendTransparent(Material m)
			{
				try
				{
					if (m.HasProperty("_SrcBlend"))
					{
						m.SetInt("_SrcBlend", 5);
					}
					if (m.HasProperty("_DstBlend"))
					{
						m.SetInt("_DstBlend", 10);
					}
					if (m.HasProperty("_ZWrite"))
					{
						m.SetInt("_ZWrite", 0);
					}
					m.DisableKeyword("_ALPHATEST_ON");
					m.EnableKeyword("_ALPHABLEND_ON");
					m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
					m.renderQueue = 3000;
				}
				catch
				{
				}
				try
				{
					if (m.HasProperty("_Surface"))
					{
						m.SetFloat("_Surface", 1f);
					}
					if (m.HasProperty("_ZWriteControl"))
					{
						m.SetFloat("_ZWriteControl", 0f);
					}
					if (m.HasProperty("_ZWrite"))
					{
						m.SetFloat("_ZWrite", 0f);
					}
				}
				catch
				{
				}
			}

			private static Shader FindFallbackTransparentShader()
			{
				Shader val = Shader.Find("Universal Render Pipeline/Lit");
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
				val = Shader.Find("Standard");
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
				val = Shader.Find("Legacy Shaders/Transparent/Diffuse");
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
				return null;
			}
		}

		private enum TraceKind
		{
			Raycast,
			OverlapBox,
			OverlapSphere
		}

		private struct TraceItem
		{
			public TraceKind Kind;

			public float UntilTime;

			public Vector3 Center;

			public Vector3 Size;

			public Quaternion Rotation;

			public float Radius;

			public Vector3 RayOrigin;

			public Vector3 RayDir;

			public float RayLength;
		}

		private sealed class PhysicsTraceBuffer
		{
			[CompilerGenerated]
			private sealed class <GetActive>d__3 : IEnumerable<TraceItem>, IEnumerable, IEnumerator<TraceItem>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private TraceItem <>2__current;

				private int <>l__initialThreadId;

				private float now;

				public float <>3__now;

				public PhysicsTraceBuffer <>4__this;

				private int <i>5__1;

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

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

				[DebuggerHidden]
				public <GetActive>d__3(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

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

				private bool MoveNext()
				{
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -1;
						goto IL_007f;
					}
					<>1__state = -1;
					<i>5__1 = 0;
					goto IL_0090;
					IL_007f:
					<i>5__1++;
					goto IL_0090;
					IL_0090:
					if (<i>5__1 < <>4__this._buf.Length)
					{
						if (<>4__this._buf[<i>5__1].UntilTime > now)
						{
							<>2__current = <>4__this._buf[<i>5__1];
							<>1__state = 1;
							return true;
						}
						goto IL_007f;
					}
					return false;
				}

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

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

				[DebuggerHidden]
				IEnumerator<TraceItem> IEnumerable<TraceItem>.GetEnumerator()
				{
					<GetActive>d__3 <GetActive>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<GetActive>d__ = this;
					}
					else
					{
						<GetActive>d__ = new <GetActive>d__3(0)
						{
							<>4__this = <>4__this
						};
					}
					<GetActive>d__.now = <>3__now;
					return <GetActive>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<TraceItem>)this).GetEnumerator();
				}
			}

			private readonly TraceItem[] _buf = new TraceItem[256];

			private int _idx;

			public void Add(TraceItem it)
			{
				_buf[_idx] = it;
				_idx = (_idx + 1) % _buf.Length;
			}

			[IteratorStateMachine(typeof(<GetActive>d__3))]
			public IEnumerable<TraceItem> GetActive(float now)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <GetActive>d__3(-2)
				{
					<>4__this = this,
					<>3__now = now
				};
			}

			public int CountActive(float now)
			{
				int num = 0;
				for (int i = 0; i < _buf.Length; i++)
				{
					if (_buf[i].UntilTime > now)
					{
						num++;
					}
				}
				return num;
			}
		}

		private static class PhysicsPatches
		{
			public static void Raycast_Postfix(Vector3 origin, Vector3 direction, ref RaycastHit hitInfo, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction, bool __result)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: 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_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0093: Unknown result type (might be due to invalid IL or missing references)
				if (_traceBuffer != null)
				{
					float num = maxDistance;
					if (__result)
					{
						num = ((RaycastHit)(ref hitInfo)).distance;
					}
					_traceBuffer.Add(new TraceItem
					{
						Kind = TraceKind.Raycast,
						UntilTime = Time.unscaledTime + 0.1f,
						RayOrigin = origin,
						RayDir = direction,
						RayLength = Mathf.Max(0.02f, num),
						Center = origin + ((Vector3)(ref direction)).normalized * Mathf.Max(0.02f, num) * 0.5f
					});
				}
			}

			public static void OverlapBox_Prefix(Vector3 center, Vector3 halfExtents, Quaternion orientation, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (_traceBuffer != null)
				{
					_traceBuffer.Add(new TraceItem
					{
						Kind = TraceKind.OverlapBox,
						UntilTime = Time.unscaledTime + 0.1f,
						Center = center,
						Size = halfExtents * 2f,
						Rotation = orientation
					});
				}
			}

			public static void OverlapSphere_Prefix(Vector3 position, float radius, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				if (_traceBuffer != null)
				{
					_traceBuffer.Add(new TraceItem
					{
						Kind = TraceKind.OverlapSphere,
						UntilTime = Time.unscaledTime + 0.1f,
						Center = position,
						Radius = radius
					});
				}
			}
		}

		public const string PluginGuid = "REPOJP.HitboxWireframeVisualizer";

		public const string PluginName = "HitboxWireframeVisualizer";

		public const string PluginVersion = "1.0.0";

		private ConfigEntry<bool> CfgGenreEnemy;

		private ConfigEntry<bool> CfgGenrePlayer;

		private ConfigEntry<bool> CfgGenreRoomModule;

		private ConfigEntry<bool> CfgGenreItem;

		private ConfigEntry<int> CfgAlphaEnemyPct;

		private ConfigEntry<int> CfgAlphaPlayerPct;

		private ConfigEntry<int> CfgAlphaRoomModulePct;

		private ConfigEntry<int> CfgAlphaItemPct;

		private ConfigEntry<int> CfgMaxCollidersPerCollect;

		private ConfigEntry<bool> CfgEnemyPriority;

		private ConfigEntry<int> CfgCacheExpireFrames;

		private ConfigEntry<bool> CfgNearestFirst;

		private ConfigEntry<int> CfgOverlapBufferMax;

		private ConfigEntry<bool> CfgEnemyLayerNameFallback;

		private ConfigEntry<bool> CfgEnable;

		private ConfigEntry<bool> CfgShowUI;

		private ConfigEntry<float> CfgCollectorInterval;

		private ConfigEntry<float> CfgMaxDistance;

		private ConfigEntry<int> CfgMaxShapes;

		private ConfigEntry<int> CfgMaxTransparentRoots;

		private ConfigEntry<bool> CfgShowColliders;

		private ConfigEntry<bool> CfgShowHurtColliders;

		private ConfigEntry<bool> CfgShowPhysicsTrace;

		private ConfigEntry<bool> CfgShowMeshColliders;

		private ConfigEntry<bool> CfgMeshAsBoundsBox;

		private ConfigEntry<bool> CfgZTestAlways;

		private ConfigEntry<bool> CfgFillMode;

		private ConfigEntry<float> CfgWireAlpha;

		private ConfigEntry<float> CfgFillAlpha;

		private ConfigEntry<bool> CfgThickWireEnable;

		private ConfigEntry<float> CfgWireWidthWorld;

		private ConfigEntry<bool> CfgWireWidthDistanceScale;

		private ConfigEntry<int> CfgSphereSegments;

		private ConfigEntry<bool> CfgGridSampleEnable;

		private ConfigEntry<float> CfgGridPitch;

		private ConfigEntry<int> CfgGridMaxPoints;

		private ConfigEntry<bool> CfgTargetLockDefault;

		private ConfigEntry<float> CfgTargetRayDistance;

		private ConfigEntry<bool> CfgTransparencyEnable;

		private ConfigEntry<bool> CfgTransparencyForceFallbackShader;

		private ConfigEntry<bool> CfgTransparencyUsePropertyBlock;

		private ConfigEntry<string> CfgDefaultLayerColor;

		private ConfigEntry<string> CfgTriggerColor;

		private ConfigEntry<string> CfgLayerColorMap;

		private ConfigEntry<KeyCode> CfgKeyToggle;

		private ConfigEntry<KeyCode> CfgKeyTargetLock;

		private ConfigEntry<KeyCode> CfgKeyToggleZTest;

		private ConfigEntry<KeyCode> CfgKeyToggleFill;

		private ConfigEntry<KeyCode> CfgKeyToggleGrid;

		private ConfigEntry<KeyCode> CfgKeyToggleTrace;

		private ConfigEntry<KeyCode> CfgKeyFreeze;

		private ConfigEntry<KeyCode> CfgKeyExport;

		private float _nextCollectTime;

		private bool _frozen;

		private bool _targetLocked;

		private GameObject _lockedTargetRoot;

		private string _lockedTargetName;

		private Material _lineMat;

		private Material _fillMat;

		private readonly List<Shape> _shapes = new List<Shape>(2048);

		private readonly List<SamplePoint> _gridPoints = new List<SamplePoint>(2048);

		private readonly HashSet<int> _visibleRootIds = new HashSet<int>();

		private readonly Dictionary<int, RootInfo> _visibleRoots = new Dictionary<int, RootInfo>();

		private Color _defaultLayerColor;

		private Color _triggerColor;

		private readonly Dictionary<int, Color> _layerColors = new Dictionary<int, Color>();

		private ModelTransparencyManager _transparency;

		private Harmony _harmony;

		private static PhysicsTraceBuffer _traceBuffer;

		private GUIStyle _uiStyle;

		private GUIStyle _uiStyleSmall;

		private FieldInfo _hcFiBox;

		private FieldInfo _hcFiSphere;

		private FieldInfo _hcFiCollider;

		private FieldInfo _hcFiColliderIsBox;

		private string _configPath;

		private long _configLastWriteTicks;

		private float _nextConfigPollTime;

		private Collider[] _overlapBuf = (Collider[])(object)new Collider[4096];

		private readonly HashSet<int> _hurtUnique = new HashSet<int>();

		private readonly Dictionary<int, CachedColliderInfo> _colliderCache = new Dictionary<int, CachedColliderInfo>(8192);

		private readonly Dictionary<int, CachedRootRenderers> _rootRendererCache = new Dictionary<int, CachedRootRenderers>(1024);

		private readonly List<Candidate> _enemyCandidates = new List<Candidate>(1024);

		private readonly List<Candidate> _otherCandidates = new List<Candidate>(2048);

		private void Awake()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			BindConfig();
			_configPath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
			_configLastWriteTicks = TryGetLastWriteTicks(_configPath);
			ReloadColors();
			CreateMaterials();
			_transparency = new ModelTransparencyManager(() => CfgTransparencyForceFallbackShader.Value, () => CfgTransparencyUsePropertyBlock.Value, GetOrCacheRootRenderers);
			_traceBuffer = new PhysicsTraceBuffer();
			_harmony = new Harmony("REPOJP.HitboxWireframeVisualizer");
			TryPatchPhysics();
			CacheHurtColliderReflection();
			_targetLocked = CfgTargetLockDefault.Value;
			EnsureOverlapCapacity();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"HitboxWireframeVisualizer 1.0.0 loaded");
		}

		private void OnDestroy()
		{
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			try
			{
				_transparency?.RestoreAll();
			}
			catch
			{
			}
		}

		private void Update()
		{
			PollAndReloadConfig();
			HandleInput();
			if (!CfgEnable.Value)
			{
				_transparency.RestoreAll();
				return;
			}
			if (_frozen)
			{
				_transparency.SweepOrphans();
				return;
			}
			if (Time.unscaledTime < _nextCollectTime)
			{
				_transparency.SweepOrphans();
				return;
			}
			_nextCollectTime = Time.unscaledTime + Mathf.Max(0.02f, CfgCollectorInterval.Value);
			CollectAndBuild();
		}

		private void OnRenderObject()
		{
			if (!CfgEnable.Value)
			{
				return;
			}
			Camera current = Camera.current;
			if ((Object)(object)current == (Object)null)
			{
				return;
			}
			EnsureMaterials();
			if (!((Object)(object)_lineMat == (Object)null))
			{
				DrawWireframes(current);
				if (CfgFillMode.Value)
				{
					DrawFills();
				}
				if (CfgGridSampleEnable.Value)
				{
					DrawGridPoints();
				}
			}
		}

		private void OnGUI()
		{
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			if (CfgEnable.Value && CfgShowUI.Value)
			{
				EnsureUiStyles();
				int count = _shapes.Count;
				int count2 = _visibleRoots.Count;
				int num = _traceBuffer.CountActive(Time.unscaledTime);
				string text = (_frozen ? "Frozen" : "Live");
				string text2 = (_targetLocked ? "Locked" : "Free");
				string text3 = "Enemy:" + (CfgGenreEnemy.Value ? "On" : "Off") + "  Player:" + (CfgGenrePlayer.Value ? "On" : "Off") + "  Module:" + (CfgGenreRoomModule.Value ? "On" : "Off") + "  Item:" + (CfgGenreItem.Value ? "On" : "Off");
				string text4 = string.Format("Collect:{0:0.###}s  Dist:{1:0.#}m  MaxShapes:{2}  MaxCols:{3}  Nearest:{4}  Buf:{5}", CfgCollectorInterval.Value, CfgMaxDistance.Value, CfgMaxShapes.Value, CfgMaxCollidersPerCollect.Value, CfgNearestFirst.Value ? "On" : "Off", _overlapBuf.Length);
				GUILayout.BeginArea(new Rect(10f, 10f, 1200f, 360f));
				GUILayout.Label("HitboxWireframeVisualizer 1.0.0  Mode:" + text + "  Target:" + text2, _uiStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label(string.Format("Shapes:{0}  VisibleRoots:{1}  Trace:{2}({3})", count, count2, CfgShowPhysicsTrace.Value ? "On" : "Off", num), _uiStyleSmall, Array.Empty<GUILayoutOption>());
				GUILayout.Label(text3, _uiStyleSmall, Array.Empty<GUILayoutOption>());
				GUILayout.Label(text4, _uiStyleSmall, Array.Empty<GUILayoutOption>());
				if (_targetLocked)
				{
					GUILayout.Label("LockedRoot: " + _lockedTargetName, _uiStyleSmall, Array.Empty<GUILayoutOption>());
				}
				GUILayout.EndArea();
			}
		}

		private void EnsureUiStyles()
		{
			//IL_0026: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			if (_uiStyle == null || _uiStyleSmall == null)
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14
				};
				val.normal.textColor = Color.white;
				_uiStyle = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12
				};
				val2.normal.textColor = Color.white;
				_uiStyleSmall = val2;
			}
		}

		private void PollAndReloadConfig()
		{
			if (Time.unscaledTime < _nextConfigPollTime)
			{
				return;
			}
			_nextConfigPollTime = Time.unscaledTime + 0.5f;
			if (string.IsNullOrEmpty(_configPath))
			{
				return;
			}
			long num = TryGetLastWriteTicks(_configPath);
			if (num != 0 && num != _configLastWriteTicks)
			{
				_configLastWriteTicks = num;
				try
				{
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch
				{
					return;
				}
				ReloadColors();
				EnsureOverlapCapacity();
			}
		}

		private void EnsureOverlapCapacity()
		{
			int num = Mathf.Clamp(CfgOverlapBufferMax.Value, 4096, 65536);
			int num2 = Mathf.Clamp(Mathf.Max(4096, CfgMaxCollidersPerCollect.Value * 6), 4096, num);
			if (_overlapBuf == null || _overlapBuf.Length < num2)
			{
				_overlapBuf = (Collider[])(object)new Collider[num2];
			}
		}

		private static long TryGetLastWriteTicks(string path)
		{
			try
			{
				if (File.Exists(path))
				{
					return File.GetLastWriteTimeUtc(path).Ticks;
				}
			}
			catch
			{
			}
			return 0L;
		}

		private void CacheHurtColliderReflection()
		{
			_hcFiBox = AccessTools.Field(typeof(HurtCollider), "BoxCollider");
			_hcFiSphere = AccessTools.Field(typeof(HurtCollider), "SphereCollider");
			_hcFiCollider = AccessTools.Field(typeof(HurtCollider), "Collider");
			_hcFiColliderIsBox = AccessTools.Field(typeof(HurtCollider), "ColliderIsBox");
		}

		private void BindConfig()
		{
			CfgGenreEnemy = ((BaseUnityPlugin)this).Config.Bind<bool>("0.Genres", "ShowEnemy", true, "Show enemy hitboxes.敵関連表示");
			CfgGenrePlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("0.Genres", "ShowPlayer", false, "Show player-related hitboxes.プレイヤー関連表示");
			CfgGenreRoomModule = ((BaseUnityPlugin)this).Config.Bind<bool>("0.Genres", "ShowRoomModule", true, "Show room module-related hitboxes.部屋モジュール関連表示");
			CfgGenreItem = ((BaseUnityPlugin)this).Config.Bind<bool>("0.Genres", "ShowItem", false, "Show item/valuable/weapon-related hitboxes.アイテム関連表示");
			CfgAlphaEnemyPct = ((BaseUnityPlugin)this).Config.Bind<int>("1.TransparencyPct", "AlphaEnemyPct", 25, "Enemy model alpha percent (0-100).敵モデル透明度(0-100)");
			CfgAlphaPlayerPct = ((BaseUnityPlugin)this).Config.Bind<int>("1.TransparencyPct", "AlphaPlayerPct", 35, "Player model alpha percent (0-100).プレイヤーモデル透明度(0-100)");
			CfgAlphaRoomModulePct = ((BaseUnityPlugin)this).Config.Bind<int>("1.TransparencyPct", "AlphaRoomModulePct", 15, "Room module model alpha percent (0-100).部屋モジュール透明度(0-100)");
			CfgAlphaItemPct = ((BaseUnityPlugin)this).Config.Bind<int>("1.TransparencyPct", "AlphaItemPct", 25, "Item model alpha percent (0-100).アイテム透明度(0-100)");
			CfgMaxCollidersPerCollect = ((BaseUnityPlugin)this).Config.Bind<int>("2.Performance", "MaxCollidersPerCollect", 650, "Max colliders processed per collect.収集1回の処理Collider上限");
			CfgEnemyPriority = ((BaseUnityPlugin)this).Config.Bind<bool>("2.Performance", "EnemyPriority", true, "Process enemy colliders first.敵を優先処理");
			CfgCacheExpireFrames = ((BaseUnityPlugin)this).Config.Bind<int>("2.Performance", "CacheExpireFrames", 600, "Cache expiry frames.キャッシュ有効期限フレーム");
			CfgNearestFirst = ((BaseUnityPlugin)this).Config.Bind<bool>("2.Performance", "NearestFirst", true, "Process nearest colliders first.近距離を優先処理");
			CfgOverlapBufferMax = ((BaseUnityPlugin)this).Config.Bind<int>("2.Performance", "OverlapBufferMax", 32768, "Max overlap buffer size.Overlapバッファ最大サイズ");
			CfgEnemyLayerNameFallback = ((BaseUnityPlugin)this).Config.Bind<bool>("2.Performance", "EnemyLayerNameFallback", true, "Treat Layer name 'Enemy' as enemy.Layer名Enemyを敵扱い");
			CfgEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("3.General", "Enable", true, "Enable mod.有効化");
			CfgShowUI = ((BaseUnityPlugin)this).Config.Bind<bool>("3.General", "ShowUI", true, "Show UI overlay.簡易UI表示");
			CfgCollectorInterval = ((BaseUnityPlugin)this).Config.Bind<float>("3.General", "CollectorIntervalSeconds", 0.18f, "Collector interval (unscaled).収集間隔秒");
			CfgMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("3.General", "MaxDistanceMeters", 35f, "Max distance from camera for collection.カメラからの最大距離");
			CfgMaxShapes = ((BaseUnityPlugin)this).Config.Bind<int>("3.General", "MaxShapes", 110, "Max shapes drawn per frame.描画最大Shape数");
			CfgMaxTransparentRoots = ((BaseUnityPlugin)this).Config.Bind<int>("3.General", "MaxTransparentRoots", 16, "Max roots to apply model transparency.モデル透明化Root上限");
			CfgShowColliders = ((BaseUnityPlugin)this).Config.Bind<bool>("4.Targets", "ShowColliders", true, "Show colliders.通常Collider表示");
			CfgShowHurtColliders = ((BaseUnityPlugin)this).Config.Bind<bool>("4.Targets", "ShowHurtColliders", true, "Show HurtCollider shapes. HurtCollider判定形状表示");
			CfgShowPhysicsTrace = ((BaseUnityPlugin)this).Config.Bind<bool>("4.Targets", "ShowPhysicsTrace", false, "Show Physics trace (Harmony). Physicsトレース表示(Harmony)");
			CfgShowMeshColliders = ((BaseUnityPlugin)this).Config.Bind<bool>("5.Mesh", "ShowMeshColliders", false, "Show MeshCollider (heavy).MeshCollider表示(重い)");
			CfgMeshAsBoundsBox = ((BaseUnityPlugin)this).Config.Bind<bool>("5.Mesh", "MeshAsBoundsBox", true, "Draw MeshCollider as bounds box. MeshColliderをBounds箱で近似");
			CfgZTestAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("6.Render", "ZTestAlways", false, "Draw through walls.壁越し表示");
			CfgFillMode = ((BaseUnityPlugin)this).Config.Bind<bool>("6.Render", "FillMode", false, "Draw translucent fill.薄い面描画");
			CfgWireAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("6.Render", "WireAlpha", 1f, "Wire alpha.ワイヤー透明度");
			CfgFillAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("6.Render", "FillAlpha", 0.1f, "Fill alpha.面透明度");
			CfgThickWireEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("7.WireThickness", "ThickWireEnable", false, "Thick wire (heavy).太線表示(重い)");
			CfgWireWidthWorld = ((BaseUnityPlugin)this).Config.Bind<float>("7.WireThickness", "WireWidthWorld", 0.015f, "Wire width approx in world space.線幅近似(ワールド)");
			CfgWireWidthDistanceScale = ((BaseUnityPlugin)this).Config.Bind<bool>("7.WireThickness", "WireWidthDistanceScale", true, "Scale wire width by distance.距離で線幅スケール");
			CfgSphereSegments = ((BaseUnityPlugin)this).Config.Bind<int>("8.Segments", "SphereSegments", 14, "Sphere wire segments.球ワイヤー分割数");
			CfgGridSampleEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("9.Grid", "GridSampleEnable", false, "Grid sample points (heavy).グリッドサンプル点(重い)");
			CfgGridPitch = ((BaseUnityPlugin)this).Config.Bind<float>("9.Grid", "GridPitchMeters", 0.35f, "Grid pitch.グリッド間隔");
			CfgGridMaxPoints = ((BaseUnityPlugin)this).Config.Bind<int>("9.Grid", "GridMaxPoints", 300, "Max grid points.最大点数");
			CfgTargetLockDefault = ((BaseUnityPlugin)this).Config.Bind<bool>("10.Target", "TargetLockDefault", false, "Lock target by default.既定ロック");
			CfgTargetRayDistance = ((BaseUnityPlugin)this).Config.Bind<float>("10.Target", "TargetRayDistance", 60f, "Ray distance for target selection.ターゲット選択レイ距離");
			CfgTransparencyEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("11.Transparency", "EnableModelTransparency", true, "Make target models transparent.モデル透明化");
			CfgTransparencyUsePropertyBlock = ((BaseUnityPlugin)this).Config.Bind<bool>("11.Transparency", "UseMaterialPropertyBlock", true, "Use MPB to set alpha (fast).MPBでalpha設定(高速)");
			CfgTransparencyForceFallbackShader = ((BaseUnityPlugin)this).Config.Bind<bool>("11.Transparency", "ForceFallbackShader", false, "Force fallback transparent shader swap.透明シェーダ差替え強制");
			CfgDefaultLayerColor = ((BaseUnityPlugin)this).Config.Bind<string>("12.Colors", "DefaultLayerColor", "#AAAAAA", "Default layer color.既定Layer色(#RRGGBB)");
			CfgTriggerColor = ((BaseUnityPlugin)this).Config.Bind<string>("12.Colors", "TriggerColor", "#FF00FF", "Trigger color. Trigger色(#RRGGBB)");
			CfgLayerColorMap = ((BaseUnityPlugin)this).Config.Bind<string>("12.Colors", "LayerColorMap", "Player=#00A0FF;Enemy=#FF4040;Default=#B0B0B0;PhysGrabObjectHinge=#40FF40;Phys Grab Object=#FFFF40", "Layer color map by name: LayerName=#RRGGBB;... Layer色マップ");
			CfgKeyToggle = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleEnable", (KeyCode)282, "Toggle enable.有効切替");
			CfgKeyTargetLock = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleTargetLock", (KeyCode)285, "Toggle target lock.ターゲットロック切替");
			CfgKeyToggleZTest = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleZTestAlways", (KeyCode)286, "Toggle ZTest always.壁越し切替");
			CfgKeyToggleFill = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleFill", (KeyCode)287, "Toggle fill.面描画切替");
			CfgKeyToggleGrid = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleGrid", (KeyCode)288, "Toggle grid points.グリッド切替");
			CfgKeyToggleTrace = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "TogglePhysicsTrace", (KeyCode)289, "Toggle physics trace.物理トレース切替");
			CfgKeyFreeze = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ToggleFreeze", (KeyCode)290, "Freeze collect.収集凍結切替");
			CfgKeyExport = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("13.Keys", "ExportSelection", (KeyCode)291, "Export selection json.選択JSON出力");
		}

		private void ReloadColors()
		{
			//IL_0021: 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_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			_defaultLayerColor = ParseColorOrDefault(CfgDefaultLayerColor.Value, new Color(0.67f, 0.67f, 0.67f, 1f));
			_triggerColor = ParseColorOrDefault(CfgTriggerColor.Value, Color.magenta);
			_layerColors.Clear();
			string text = CfgLayerColorMap.Value ?? "";
			string[] array = text.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				string[] array3 = text2.Split(new char[1] { '=' }, StringSplitOptions.RemoveEmptyEntries);
				if (array3.Length == 2)
				{
					string text3 = array3[0].Trim();
					string text4 = array3[1].Trim();
					int num = LayerMask.NameToLayer(text3);
					if (num >= 0)
					{
						Color value = ParseColorOrDefault(text4, _defaultLayerColor);
						_layerColors[num] = value;
					}
				}
			}
		}

		private void CreateMaterials()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			Shader val = Shader.Find("Hidden/Internal-Colored");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Sprites/Default");
			}
			if (!((Object)(object)val == (Object)null))
			{
				_lineMat = new Material(val);
				((Object)_lineMat).hideFlags = (HideFlags)61;
				TrySetInt(_lineMat, "_SrcBlend", 5);
				TrySetInt(_lineMat, "_DstBlend", 10);
				TrySetInt(_lineMat, "_Cull", 0);
				TrySetInt(_lineMat, "_ZWrite", 0);
				_fillMat = new Material(val);
				((Object)_fillMat).hideFlags = (HideFlags)61;
				TrySetInt(_fillMat, "_SrcBlend", 5);
				TrySetInt(_fillMat, "_DstBlend", 10);
				TrySetInt(_fillMat, "_Cull", 2);
				TrySetInt(_fillMat, "_ZWrite", 0);
			}
		}

		private void EnsureMaterials()
		{
			if ((Object)(object)_lineMat == (Object)null || (Object)(object)_fillMat == (Object)null)
			{
				CreateMaterials();
			}
			if (!((Object)(object)_lineMat == (Object)null) && !((Object)(object)_fillMat == (Object)null))
			{
				TrySetInt(_lineMat, "_ZTest", CfgZTestAlways.Value ? 8 : 4);
				TrySetInt(_fillMat, "_ZTest", CfgZTestAlways.Value ? 8 : 4);
			}
		}

		private void HandleInput()
		{
			//IL_0007: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(CfgKeyToggle.Value))
			{
				CfgEnable.Value = !CfgEnable.Value;
				if (!CfgEnable.Value)
				{
					_transparency.RestoreAll();
				}
			}
			if (Input.GetKeyDown(CfgKeyTargetLock.Value))
			{
				_targetLocked = !_targetLocked;
				if (!_targetLocked)
				{
					_lockedTargetRoot = null;
					_lockedTargetName = null;
				}
			}
			if (Input.GetKeyDown(CfgKeyToggleZTest.Value))
			{
				CfgZTestAlways.Value = !CfgZTestAlways.Value;
			}
			if (Input.GetKeyDown(CfgKeyToggleFill.Value))
			{
				CfgFillMode.Value = !CfgFillMode.Value;
			}
			if (Input.GetKeyDown(CfgKeyToggleGrid.Value))
			{
				CfgGridSampleEnable.Value = !CfgGridSampleEnable.Value;
			}
			if (Input.GetKeyDown(CfgKeyToggleTrace.Value))
			{
				CfgShowPhysicsTrace.Value = !CfgShowPhysicsTrace.Value;
			}
			if (Input.GetKeyDown(CfgKeyFreeze.Value))
			{
				_frozen = !_frozen;
			}
			if (Input.GetKeyDown(CfgKeyExport.Value))
			{
				ExportSelectionJsonToClipboard();
			}
		}

		private void CollectAndBuild()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			Camera val = Camera.main;
			if ((Object)(object)val == (Object)null)
			{
				val = Camera.current;
			}
			if ((Object)(object)val == (Object)null)
			{
				_transparency.SweepOrphans();
				return;
			}
			UpdateTargetLock(val);
			_shapes.Clear();
			_gridPoints.Clear();
			_visibleRoots.Clear();
			_visibleRootIds.Clear();
			_hurtUnique.Clear();
			_enemyCandidates.Clear();
			_otherCandidates.Clear();
			Vector3 position = ((Component)val).transform.position;
			float num = Mathf.Max(1f, CfgMaxDistance.Value);
			if (_targetLocked && (Object)(object)_lockedTargetRoot != (Object)null)
			{
				if (CfgShowColliders.Value)
				{
					Collider[] componentsInChildren = _lockedTargetRoot.GetComponentsInChildren<Collider>(true);
					foreach (Collider val2 in componentsInChildren)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							AddSingleColliderShapeCached(position, val2);
						}
					}
				}
				if (CfgShowHurtColliders.Value)
				{
					HurtCollider[] componentsInChildren2 = _lockedTargetRoot.GetComponentsInChildren<HurtCollider>(true);
					foreach (HurtCollider val3 in componentsInChildren2)
					{
						if (!((Object)(object)val3 == (Object)null))
						{
							AddSingleHurtColliderShapeCached(position, val3);
						}
					}
				}
			}
			else
			{
				EnsureOverlapCapacity();
				int num2 = Physics.OverlapSphereNonAlloc(position, num, _overlapBuf, -1, (QueryTriggerInteraction)2);
				if (num2 == _overlapBuf.Length)
				{
					int num3 = Mathf.Clamp(CfgOverlapBufferMax.Value, 4096, 65536);
					int num4 = Mathf.Min(num3, _overlapBuf.Length * 2);
					if (num4 > _overlapBuf.Length)
					{
						_overlapBuf = (Collider[])(object)new Collider[num4];
						num2 = Physics.OverlapSphereNonAlloc(position, num, _overlapBuf, -1, (QueryTriggerInteraction)2);
					}
				}
				if (num2 <= 0)
				{
					_transparency.SweepOrphans();
					return;
				}
				for (int k = 0; k < num2; k++)
				{
					Collider val4 = _overlapBuf[k];
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					Bounds bounds = val4.bounds;
					Vector3 val5 = ((Bounds)(ref bounds)).center - position;
					float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
					bool flag = GetOrCacheColliderInfo(val4, Time.frameCount).Genre == Genre.Enemy;
					if (!flag && CfgEnemyLayerNameFallback.Value)
					{
						string text = LayerMask.LayerToName(((Component)val4).gameObject.layer);
						if (!string.IsNullOrEmpty(text) && string.Equals(text, "Enemy", StringComparison.OrdinalIgnoreCase))
						{
							flag = true;
						}
					}
					Candidate candidate = default(Candidate);
					candidate.Col = val4;
					candidate.DistSqr = sqrMagnitude;
					Candidate item = candidate;
					if (flag)
					{
						_enemyCandidates.Add(item);
					}
					else
					{
						_otherCandidates.Add(item);
					}
				}
				if (CfgNearestFirst.Value)
				{
					_enemyCandidates.Sort((Candidate a, Candidate b) => a.DistSqr.CompareTo(b.DistSqr));
					_otherCandidates.Sort((Candidate a, Candidate b) => a.DistSqr.CompareTo(b.DistSqr));
				}
				int num5 = Mathf.Max(1, CfgMaxCollidersPerCollect.Value);
				int num6 = 0;
				if (CfgEnemyPriority.Value && CfgGenreEnemy.Value && CfgShowColliders.Value)
				{
					for (int l = 0; l < _enemyCandidates.Count; l++)
					{
						if (num6 >= num5)
						{
							break;
						}
						AddSingleColliderShapeCached(position, _enemyCandidates[l].Col);
						num6++;
					}
				}
				if (CfgShowColliders.Value && num6 < num5)
				{
					if (!CfgEnemyPriority.Value)
					{
						for (int m = 0; m < _enemyCandidates.Count; m++)
						{
							if (num6 >= num5)
							{
								break;
							}
							AddSingleColliderShapeCached(position, _enemyCandidates[m].Col);
							num6++;
						}
					}
					for (int n = 0; n < _otherCandidates.Count; n++)
					{
						if (num6 >= num5)
						{
							break;
						}
						AddSingleColliderShapeCached(position, _otherCandidates[n].Col);
						num6++;
					}
				}
				if (CfgShowHurtColliders.Value)
				{
					int num7 = Mathf.Max(1, num5 / 3);
					int num8 = 0;
					if (CfgEnemyPriority.Value && CfgGenreEnemy.Value)
					{
						for (int num9 = 0; num9 < _enemyCandidates.Count; num9++)
						{
							if (num8 >= num7)
							{
								break;
							}
							Collider col = _enemyCandidates[num9].Col;
							if ((Object)(object)col == (Object)null)
							{
								continue;
							}
							HurtCollider componentInParent = ((Component)col).GetComponentInParent<HurtCollider>();
							if (!((Object)(object)componentInParent == (Object)null))
							{
								int instanceID = ((Object)componentInParent).GetInstanceID();
								if (_hurtUnique.Add(instanceID))
								{
									AddSingleHurtColliderShapeCached(position, componentInParent);
									num8++;
								}
							}
						}
					}
					int num10 = 0;
					for (int num11 = 0; num11 < _otherCandidates.Count; num11++)
					{
						if (num10 >= num7)
						{
							break;
						}
						Collider col2 = _otherCandidates[num11].Col;
						if ((Object)(object)col2 == (Object)null)
						{
							continue;
						}
						HurtCollider componentInParent2 = ((Component)col2).GetComponentInParent<HurtCollider>();
						if (!((Object)(object)componentInParent2 == (Object)null))
						{
							int instanceID2 = ((Object)componentInParent2).GetInstanceID();
							if (_hurtUnique.Add(instanceID2))
							{
								AddSingleHurtColliderShapeCached(position, componentInParent2);
								num10++;
							}
						}
					}
				}
			}
			if (CfgShowPhysicsTrace.Value)
			{
				AddTraceShapes(position, num);
			}
			if (_shapes.Count > CfgMaxShapes.Value)
			{
				_shapes.Sort((Shape a, Shape b) => a.DistanceSqr.CompareTo(b.DistanceSqr));
				_shapes.RemoveRange(CfgMaxShapes.Value, _shapes.Count - CfgMaxShapes.Value);
			}
			for (int num12 = 0; num12 < _shapes.Count; num12++)
			{
				Shape shape = _shapes[num12];
				if (!((Object)(object)shape.OwnerRoot == (Object)null))
				{
					int instanceID3 = ((Object)shape.OwnerRoot).GetInstanceID();
					if (_visibleRootIds.Add(instanceID3))
					{
						_visibleRoots[instanceID3] = new RootInfo
						{
							Root = shape.OwnerRoot,
							Genre = shape.Genre,
							DistanceSqr = shape.DistanceSqr
						};
					}
				}
			}
			if (CfgTransparencyEnable.Value)
			{
				_transparency.BeginFrame();
				foreach (RootInfo item2 in _visibleRoots.Values.OrderBy((RootInfo x) => x.DistanceSqr).Take(Mathf.Max(0, CfgMaxTransparentRoots.Value)))
				{
					float alpha = Alpha01ForGenre(item2.Genre);
					_transparency.ApplyTransparent(item2.Root, alpha);
				}
				_transparency.EndFrame();
			}
			else
			{
				_transparency.RestoreAll();
			}
			if (CfgGridSampleEnable.Value)
			{
				BuildGridSamples(val);
			}
			SweepCaches();
			_transparency.SweepOrphans();
		}

		private void UpdateTargetLock(Camera cam)
		{
			//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_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!_targetLocked)
			{
				return;
			}
			if ((Object)(object)_lockedTargetRoot != (Object)null && !Object.op_Implicit((Object)(object)_lockedTargetRoot))
			{
				_lockedTargetRoot = null;
				_lockedTargetName = null;
			}
			if ((Object)(object)_lockedTargetRoot != (Object)null)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)cam).transform.position, ((Component)cam).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, Mathf.Max(1f, CfgTargetRayDistance.Value), -1, (QueryTriggerInteraction)2))
			{
				GameObject val3 = ResolveOwnerRoot(((RaycastHit)(ref val2)).collider);
				if ((Object)(object)val3 != (Object)null)
				{
					_lockedTargetRoot = val3;
					_lockedTargetName = ((Object)val3).name;
				}
			}
		}

		private void AddSingleColliderShapeCached(Vector3 camPos, Collider c)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0087: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0167: 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)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null || !c.enabled || (c is MeshCollider && !CfgShowMeshColliders.Value))
			{
				return;
			}
			CachedColliderInfo orCacheColliderInfo = GetOrCacheColliderInfo(c, Time.frameCount);
			if (!IsGenreEnabled(orCacheColliderInfo.Genre))
			{
				return;
			}
			Bounds bounds = c.bounds;
			Vector3 val = ((Bounds)(ref bounds)).center - camPos;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			Color color = ResolveWireColor(c);
			BoxCollider val2 = (BoxCollider)(object)((c is BoxCollider) ? c : null);
			if (val2 != null)
			{
				Vector3 center = ((Component)val2).transform.TransformPoint(val2.center);
				Vector3 size = Vector3.Scale(val2.size, ((Component)val2).transform.lossyScale);
				Quaternion rotation = ((Component)val2).transform.rotation;
				_shapes.Add(Shape.Box(orCacheColliderInfo.Root, orCacheColliderInfo.Genre, center, size, rotation, color, sqrMagnitude));
				return;
			}
			SphereCollider val3 = (SphereCollider)(object)((c is SphereCollider) ? c : null);
			if (val3 != null)
			{
				Vector3 center2 = ((Component)val3).transform.TransformPoint(val3.center);
				float radius = val3.radius * MaxAbs(((Component)val3).transform.lossyScale);
				_shapes.Add(Shape.Sphere(orCacheColliderInfo.Root, orCacheColliderInfo.Genre, center2, radius, color, sqrMagnitude));
				return;
			}
			CapsuleCollider val4 = (CapsuleCollider)(object)((c is CapsuleCollider) ? c : null);
			if (val4 != null)
			{
				Vector3 center3 = ((Component)val4).transform.TransformPoint(val4.center);
				float num = MaxAbs(new Vector3(((Component)val4).transform.lossyScale.x, ((Component)val4).transform.lossyScale.z, ((Component)val4).transform.lossyScale.x));
				float num2 = Mathf.Abs(((Component)val4).transform.lossyScale.y);
				float radius2 = val4.radius * num;
				float height = val4.height * num2;
				_shapes.Add(Shape.Capsule(orCacheColliderInfo.Root, orCacheColliderInfo.Genre, center3, radius2, height, val4.direction, ((Component)val4).transform.rotation, color, sqrMagnitude));
			}
			else
			{
				MeshCollider val5 = (MeshCollider)(object)((c is MeshCollider) ? c : null);
				if (val5 != null)
				{
					Bounds bounds2 = ((Collider)val5).bounds;
					_shapes.Add(Shape.Box(orCacheColliderInfo.Root, orCacheColliderInfo.Genre, ((Bounds)(ref bounds2)).center, ((Bounds)(ref bounds2)).size, Quaternion.identity, color, sqrMagnitude));
				}
				else
				{
					Bounds bounds3 = c.bounds;
					_shapes.Add(Shape.Box(orCacheColliderInfo.Root, orCacheColliderInfo.Genre, ((Bounds)(ref bounds3)).center, ((Bounds)(ref bounds3)).size, Quaternion.identity, color, sqrMagnitude));
				}
			}
		}

		private void AddSingleHurtColliderShapeCached(Vector3 camPos, HurtCollider hc)
		{
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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)
			//IL_0119: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00ad: 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_00bd: 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)
			if ((Object)(object)hc == (Object)null || !((Behaviour)hc).isActiveAndEnabled || _hcFiCollider == null || _hcFiColliderIsBox == null)
			{
				return;
			}
			object? value = _hcFiCollider.GetValue(hc);
			Collider val = (Collider)((value is Collider) ? value : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject root = ResolveOwnerRoot(((Component)hc).gameObject);
			Genre genre = ResolveGenre(root);
			if (!IsGenreEnabled(genre))
			{
				return;
			}
			Bounds bounds = val.bounds;
			Vector3 val2 = ((Bounds)(ref bounds)).center - camPos;
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			Color triggerColor = _triggerColor;
			bool flag = false;
			try
			{
				flag = (bool)_hcFiColliderIsBox.GetValue(hc);
			}
			catch
			{
			}
			if (flag)
			{
				object? obj2 = _hcFiBox?.GetValue(hc);
				BoxCollider val3 = (BoxCollider)((obj2 is BoxCollider) ? obj2 : null);
				if ((Object)(object)val3 == (Object)null)
				{
					Bounds bounds2 = val.bounds;
					_shapes.Add(Shape.Box(root, genre, ((Bounds)(ref bounds2)).center, ((Bounds)(ref bounds2)).size, Quaternion.identity, triggerColor, sqrMagnitude));
					return;
				}
				Vector3 center = ((Component)val3).transform.TransformPoint(val3.center);
				Vector3 size = Vector3.Scale(val3.size, ((Component)val3).transform.lossyScale);
				Quaternion rotation = ((Component)val3).transform.rotation;
				_shapes.Add(Shape.Box(root, genre, center, size, rotation, triggerColor, sqrMagnitude));
			}
			else
			{
				object? obj3 = _hcFiSphere?.GetValue(hc);
				SphereCollider val4 = (SphereCollider)((obj3 is SphereCollider) ? obj3 : null);
				if ((Object)(object)val4 == (Object)null)
				{
					Bounds bounds3 = val.bounds;
					_shapes.Add(Shape.Box(root, genre, ((Bounds)(ref bounds3)).center, ((Bounds)(ref bounds3)).size, Quaternion.identity, triggerColor, sqrMagnitude));
				}
				else
				{
					Vector3 center2 = ((Component)val4).transform.TransformPoint(val4.center);
					float radius = val4.radius * MaxAbs(((Component)val4).transform.lossyScale);
					_shapes.Add(Shape.Sphere(root, genre, center2, radius, triggerColor, sqrMagnitude));
				}
			}
		}

		private CachedColliderInfo GetOrCacheColliderInfo(Collider c, int frame)
		{
			int instanceID = ((Object)c).GetInstanceID();
			if (_colliderCache.TryGetValue(instanceID, out var value))
			{
				if ((Object)(object)value.Root == (Object)null || !Object.op_Implicit((Object)(object)value.Root))
				{
					_colliderCache.Remove(instanceID);
				}
				else
				{
					if (value.Genre != 0)
					{
						value.LastFrame = frame;
						_colliderCache[instanceID] = value;
						return value;
					}
					_colliderCache.Remove(instanceID);
				}
			}
			GameObject root = ResolveOwnerRoot(c);
			Genre genre = ResolveGenre(root);
			if (genre != Genre.Enemy && CfgEnemyLayerNameFallback.Value)
			{
				string text = LayerMask.LayerToName(((Component)c).gameObject.layer);
				if (!string.IsNullOrEmpty(text) && string.Equals(text, "Enemy", StringComparison.OrdinalIgnoreCase))
				{
					genre = Genre.Enemy;
				}
			}
			CachedColliderInfo cachedColliderInfo = default(CachedColliderInfo);
			cachedColliderInfo.Root = root;
			cachedColliderInfo.Genre = genre;
			cachedColliderInfo.LastFrame = frame;
			CachedColliderInfo cachedColliderInfo2 = cachedColliderInfo;
			_colliderCache[instanceID] = cachedColliderInfo2;
			return cachedColliderInfo2;
		}

		private Renderer[] GetOrCacheRootRenderers(GameObject root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return Array.Empty<Renderer>();
			}
			int instanceID = ((Object)root).GetInstanceID();
			int frameCount = Time.frameCount;
			if (_rootRendererCache.TryGetValue(instanceID, out var value))
			{
				if ((Object)(object)value.Root != (Object)null && Object.op_Implicit((Object)(object)value.Root))
				{
					value.LastFrame = frameCount;
					_rootRendererCache[instanceID] = value;
					return value.Renderers ?? Array.Empty<Renderer>();
				}
				_rootRendererCache.Remove(instanceID);
			}
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			CachedRootRenderers cachedRootRenderers = default(CachedRootRenderers);
			cachedRootRenderers.Root = root;
			cachedRootRenderers.Renderers = componentsInChildren;
			cachedRootRenderers.LastFrame = frameCount;
			CachedRootRenderers value2 = cachedRootRenderers;
			_rootRendererCache[instanceID] = value2;
			return componentsInChildren ?? Array.Empty<Renderer>();
		}

		private void SweepCaches()
		{
			int num = Mathf.Max(60, CfgCacheExpireFrames.Value);
			int frameCount = Time.frameCount;
			if (_colliderCache.Count > 0)
			{
				int[] array = _colliderCache.Keys.ToArray();
				foreach (int key in array)
				{
					if (_colliderCache.TryGetValue(key, out var value) && ((Object)(object)value.Root == (Object)null || !Object.op_Implicit((Object)(object)value.Root) || frameCount - value.LastFrame > num))
					{
						_colliderCache.Remove(key);
					}
				}
			}
			if (_rootRendererCache.Count <= 0)
			{
				return;
			}
			int[] array2 = _rootRendererCache.Keys.ToArray();
			foreach (int key2 in array2)
			{
				if (_rootRendererCache.TryGetValue(key2, out var value2) && ((Object)(object)value2.Root == (Object)null || !Object.op_Implicit((Object)(object)value2.Root) || frameCount - value2.LastFrame > num))
				{
					_rootRendererCache.Remove(key2);
				}
			}
		}

		private void AddTraceShapes(Vector3 camPos, float maxDist)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0051: 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_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_0082: 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_00be: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			float num = maxDist * maxDist;
			float unscaledTime = Time.unscaledTime;
			foreach (TraceItem item in _traceBuffer.GetActive(unscaledTime))
			{
				Vector3 val = item.Center - camPos;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (!(sqrMagnitude > num))
				{
					Color white = Color.white;
					if (item.Kind == TraceKind.Raycast)
					{
						_shapes.Add(Shape.Ray(null, Genre.Trace, item.RayOrigin, item.RayDir, item.RayLength, white, sqrMagnitude));
					}
					else if (item.Kind == TraceKind.OverlapBox)
					{
						_shapes.Add(Shape.Box(null, Genre.Trace, item.Center, item.Size, item.Rotation, white, sqrMagnitude));
					}
					else if (item.Kind == TraceKind.OverlapSphere)
					{
						_shapes.Add(Shape.Sphere(null, Genre.Trace, item.Center, item.Radius, white, sqrMagnitude));
					}
				}
			}
		}

		private void BuildGridSamples(Camera cam)
		{
			//IL_0175: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			Shape? shape = null;
			if (_targetLocked && (Object)(object)_lockedTargetRoot != (Object)null)
			{
				for (int i = 0; i < _shapes.Count; i++)
				{
					Shape value = _shapes[i];
					if ((Object)(object)value.OwnerRoot == (Object)(object)_lockedTargetRoot && (value.Kind == ShapeKind.Box || value.Kind == ShapeKind.Sphere || value.Kind == ShapeKind.Capsule))
					{
						shape = value;
						break;
					}
				}
			}
			if (!shape.HasValue && _shapes.Count > 0)
			{
				_shapes.Sort((Shape a, Shape b) => a.DistanceSqr.CompareTo(b.DistanceSqr));
				for (int j = 0; j < _shapes.Count; j++)
				{
					Shape value2 = _shapes[j];
					if (value2.Kind == ShapeKind.Box || value2.Kind == ShapeKind.Sphere || value2.Kind == ShapeKind.Capsule)
					{
						shape = value2;
						break;
					}
				}
			}
			if (!shape.HasValue)
			{
				return;
			}
			Bounds approxBounds = shape.Value.GetApproxBounds();
			float num = Mathf.Max(0.05f, CfgGridPitch.Value);
			int num2 = Mathf.Max(1, CfgGridMaxPoints.Value);
			Vector3 min = ((Bounds)(ref approxBounds)).min;
			Vector3 max = ((Bounds)(ref approxBounds)).max;
			int num3 = 0;
			Vector3 val = default(Vector3);
			for (float num4 = min.x; num4 <= max.x; num4 += num)
			{
				for (float num5 = min.y; num5 <= max.y; num5 += num)
				{
					for (float num6 = min.z; num6 <= max.z; num6 += num)
					{
						if (num3 >= num2)
						{
							return;
						}
						((Vector3)(ref val))..ctor(num4, num5, num6);
						if (shape.Value.ContainsApprox(val))
						{
							_gridPoints.Add(new SamplePoint
							{
								Position = val,
								Color = shape.Value.Color
							});
							num3++;
						}
					}
				}
			}
		}

		private void DrawWireframes(Camera cam)
		{
			//IL_003b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_012a: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(CfgWireWidthWorld.Value, 0.002f, 0.15f);
			bool value = CfgThickWireEnable.Value;
			_lineMat.SetPass(0);
			GL.PushMatrix();
			GL.MultMatrix(Matrix4x4.identity);
			GL.Begin(1);
			int sphereSeg = Mathf.Clamp(CfgSphereSegments.Value, 6, 64);
			for (int i = 0; i < _shapes.Count; i++)
			{
				Shape s = _shapes[i];
				Color color = s.Color;
				color.a = Mathf.Clamp01(CfgWireAlpha.Value);
				if (!value)
				{
					GL.Color(color);
					DrawShapeWireThin(s, sphereSeg);
					continue;
				}
				float num2 = num;
				if (CfgWireWidthDistanceScale.Value)
				{
					float num3 = Mathf.Sqrt(Mathf.Max(0f, s.DistanceSqr));
					num2 = num * Mathf.Clamp(num3 * 0.06f, 1f, 5f);
				}
				Vector3 off = ((Component)cam).transform.right * num2;
				Vector3 off2 = ((Component)cam).transform.up * num2;
				GL.Color(color);
				DrawShapeWireThick(s, sphereSeg, off, off2);
			}
			GL.End();
			GL.PopMatrix();
		}

		private void DrawFills()
		{
			//IL_0029: 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_0053: 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)
			if (!((Object)(object)_fillMat == (Object)null))
			{
				_fillMat.SetPass(0);
				GL.PushMatrix();
				GL.MultMatrix(Matrix4x4.identity);
				GL.Begin(4);
				for (int i = 0; i < _shapes.Count; i++)
				{
					Shape s = _shapes[i];
					Color color = s.Color;
					color.a = Mathf.Clamp01(CfgFillAlpha.Value);
					GL.Color(color);
					DrawShapeFillApprox(s);
				}
				GL.End();
				GL.PopMatrix();
			}
		}

		private void DrawGridPoints()
		{
			//IL_0014: 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_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_005c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_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_009e: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			_lineMat.SetPass(0);
			GL.PushMatrix();
			GL.MultMatrix(Matrix4x4.identity);
			GL.Begin(1);
			float num = 0.06f;
			for (int i = 0; i < _gridPoints.Count; i++)
			{
				SamplePoint samplePoint = _gridPoints[i];
				Color color = samplePoint.Color;
				color.a = 0.9f;
				Vector3 position = samplePoint.Position;
				GL.Color(color);
				GL.Vertex(position + new Vector3(0f - num, 0f, 0f));
				GL.Vertex(position + new Vector3(num, 0f, 0f));
				GL.Vertex(position + new Vector3(0f, 0f - num, 0f));
				GL.Vertex(position + new Vector3(0f, num, 0f));
				GL.Vertex(position + new Vector3(0f, 0f, 0f - num));
				GL.Vertex(position + new Vector3(0f, 0f, num));
			}
			GL.End();
			GL.PopMatrix();
		}

		private void DrawShapeWireThin(Shape s, int sphereSeg)
		{
			//IL_0024: 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_0030: 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_0055: 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_007d: 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)
			switch (s.Kind)
			{
			case ShapeKind.Box:
				DrawBoxWireThin(s.Center, s.Size, s.Rotation);
				break;
			case ShapeKind.Sphere:
				DrawSphereWireThin(s.Center, s.Radius, sphereSeg);
				break;
			case ShapeKind.Capsule:
				DrawCapsuleWireThin(s.Center, s.Radius, s.Height, s.CapsuleDirection, s.Rotation, sphereSeg);
				break;
			case ShapeKind.Ray:
				DrawRayWireThin(s.RayOrigin, s.RayDir, s.RayLength);
				break;
			}
		}

		private void DrawShapeWireThick(Shape s, int sphereSeg, Vector3 off1, Vector3 off2)
		{
			//IL_0027: 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_0039: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_007d: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			switch (s.Kind)
			{
			case ShapeKind.Box:
				DrawBoxWireThick(s.Center, s.Size, s.Rotation, off1, off2);
				break;
			case ShapeKind.Sphere:
				DrawSphereWireThick(s.Center, s.Radius, sphereSeg, off1, off2);
				break;
			case ShapeKind.Capsule:
				DrawCapsuleWireThick(s.Center, s.Radius, s.Height, s.CapsuleDirection, s.Rotation, sphereSeg, off1, off2);
				break;
			case ShapeKind.Ray:
				DrawRayWireThick(s.RayOrigin, s.RayDir, s.RayLength, off1, off2);
				break;
			}
		}

		private void DrawBoxWireThin(Vector3 center, Vector3 size, Quaternion rot)
		{
			//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_000c: 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_0017: 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_0025: 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_0031: 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_0043: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0088: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00b4: 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_00ba: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0110: 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_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_0124: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_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_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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = size * 0.5f;
			Vector3[] array = (Vector3[])(object)new Vector3[8]
			{
				rot * new Vector3(0f - val.x, 0f - val.y, 0f - val.z) + center,
				rot * new Vector3(val.x, 0f - val.y, 0f - val.z) + center,
				rot * new Vector3(val.x, 0f - val.y, val.z) + center,
				rot * new Vector3(0f - val.x, 0f - val.y, val.z) + center,
				rot * new Vector3(0f - val.x, val.y, 0f - val.z) + center,
				rot * new Vector3(val.x, val.y, 0f - val.z) + center,
				rot * new Vector3(val.x, val.y, val.z) + center,
				rot * new Vector3(0f - val.x, val.y, val.z) + center
			};
			int[,] array2 = new int[12, 2]
			{
				{ 0, 1 },
				{ 1, 2 },
				{ 2, 3 },
				{ 3, 0 },
				{ 4, 5 },
				{ 5, 6 },
				{ 6, 7 },
				{ 7, 4 },
				{ 0, 4 },
				{ 1, 5 },
				{ 2, 6 },
				{ 3, 7 }
			};
			for (int i = 0; i < 12; i++)
			{
				Vector3 val2 = array[array2[i, 0]];
				Vector3 val3 = array[array2[i, 1]];
				GL.Vertex(val2);
				GL.Vertex(val3);
			}
		}

		private void DrawBoxWireThick(Vector3 center, Vector3 size, Quaternion rot, Vector3 off1, Vector3 off2)
		{
			//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_000c: 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_0017: 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_0025: 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_0031: 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_0043: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid I