Decompiled source of MyFoothold v1.0.0

plugins/my.pahsiv.MyFoothold.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("my.pahsiv.MyFoothold")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dd8caf3d13b0423ae9398fedc04c63fcf3b95200")]
[assembly: AssemblyProduct("MyFoothold")]
[assembly: AssemblyTitle("my.pahsiv.MyFoothold")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Foothold
{
	[BepInPlugin("my.pahsiv.MyFoothold", "MyFoothold", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private struct CachedResult
		{
			public bool HasHit;

			public Vector3 HitPoint;

			public float Angle;

			public bool IsStandable;
		}

		internal enum StandableColor
		{
			White,
			Green
		}

		internal enum NonStandableColor
		{
			Red,
			Magenta
		}

		internal enum Mode
		{
			Toggle,
			FadeAway,
			Trigger
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass54_0
		{
			public Vector3 cameraPosition;

			internal int <SortWithYield>b__0(Vector3 a, Vector3 b)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = a - cameraPosition;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				val = b - cameraPosition;
				float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
				return sqrMagnitude.CompareTo(sqrMagnitude2);
			}
		}

		[CompilerGenerated]
		private sealed class <BackgroundPruneCoroutine>d__65 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

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

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

			[DebuggerHidden]
			public <BackgroundPruneCoroutine>d__65(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Plugin plugin = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_0029;
				case 1:
					<>1__state = -1;
					try
					{
						if (!((Object)(object)mainCamera == (Object)null) && (((Scene)(ref currentScene)).name.StartsWith("Level_") || ((Scene)(ref currentScene)).name.StartsWith("Airport")) && !isVisualizationRunning)
						{
							goto IL_00b0;
						}
					}
					catch (Exception ex)
					{
						Logger.LogError((object)("BackgroundPruneCoroutine failed during scene check: " + ex.Message));
						return false;
					}
					goto IL_0029;
				case 2:
					{
						<>1__state = -1;
						isPruning = false;
						if (plugin.configDebugMode.Value)
						{
							Logger.LogMessage((object)$"Background prune completed. Cache size: {plugin._positionCache.Count}");
						}
						goto IL_0029;
					}
					IL_00b0:
					isPruning = true;
					<>2__current = ((MonoBehaviour)plugin).StartCoroutine(plugin.PruneCacheCoroutine(((Component)mainCamera).transform.position));
					<>1__state = 2;
					return true;
					IL_0029:
					<>2__current = (object)new WaitForSeconds(5f);
					<>1__state = 1;
					return true;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <PruneCacheCoroutine>d__66 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float range;

			public Plugin <>4__this;

			public Vector3 cameraPos;

			private float <rangeSqr>5__2;

			private int <totalChecked>5__3;

			private int <totalRemoved>5__4;

			private Dictionary<Vector3Int, CachedResult>.KeyCollection.Enumerator <>7__wrap4;

			private List<Vector3Int>.Enumerator <>7__wrap5;

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

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

			[DebuggerHidden]
			public <PruneCacheCoroutine>d__66(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				switch (<>1__state)
				{
				case -3:
				case 1:
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
					break;
				case -4:
				case 2:
					try
					{
					}
					finally
					{
						<>m__Finally2();
					}
					break;
				}
				<>7__wrap4 = default(Dictionary<Vector3Int, CachedResult>.KeyCollection.Enumerator);
				<>7__wrap5 = default(List<Vector3Int>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//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_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				bool result;
				try
				{
					int num = <>1__state;
					Plugin plugin = <>4__this;
					switch (num)
					{
					default:
						result = false;
						goto end_IL_0000;
					case 0:
						<>1__state = -1;
						isPruning = true;
						<rangeSqr>5__2 = range * range;
						plugin._pruneBuffer.Clear();
						<totalChecked>5__3 = 0;
						<>7__wrap4 = plugin._positionCache.Keys.GetEnumerator();
						<>1__state = -3;
						goto IL_0140;
					case 1:
						<>1__state = -3;
						goto IL_0140;
					case 2:
						{
							<>1__state = -4;
							break;
						}
						IL_0140:
						while (true)
						{
							if (!<>7__wrap4.MoveNext())
							{
								<>m__Finally1();
								<>7__wrap4 = default(Dictionary<Vector3Int, CachedResult>.KeyCollection.Enumerator);
								<totalRemoved>5__4 = 0;
								<>7__wrap5 = plugin._pruneBuffer.GetEnumerator();
								<>1__state = -4;
								break;
							}
							Vector3Int current = <>7__wrap4.Current;
							if (cancelPrune)
							{
								if (plugin.configDebugMode.Value)
								{
									Logger.LogMessage((object)"PruneCacheCoroutine: Interrupted by scan request.");
								}
								isPruning = false;
								result = false;
								<>m__Finally1();
							}
							else
							{
								Vector3 val = new Vector3((float)((Vector3Int)(ref current)).x, (float)((Vector3Int)(ref current)).y, (float)((Vector3Int)(ref current)).z) * 0.5f - cameraPos;
								if (((Vector3)(ref val)).sqrMagnitude > <rangeSqr>5__2)
								{
									plugin._pruneBuffer.Add(current);
								}
								if (<totalChecked>5__3++ % MainYield != 0)
								{
									continue;
								}
								<>2__current = null;
								<>1__state = 1;
								result = true;
							}
							goto end_IL_0000;
						}
						break;
					}
					while (true)
					{
						if (<>7__wrap5.MoveNext())
						{
							Vector3Int current2 = <>7__wrap5.Current;
							if (cancelPrune)
							{
								if (plugin.configDebugMode.Value)
								{
									Logger.LogMessage((object)"PruneCacheCoroutine: Interrupted during removal.");
								}
								isPruning = false;
								result = false;
								<>m__Finally2();
								break;
							}
							plugin._positionCache.Remove(current2);
							if (<totalRemoved>5__4++ % MainYield == 0)
							{
								<>2__current = null;
								<>1__state = 2;
								result = true;
								break;
							}
							continue;
						}
						<>m__Finally2();
						<>7__wrap5 = default(List<Vector3Int>.Enumerator);
						if (plugin.configDebugMode.Value)
						{
							Logger.LogMessage((object)$"Background prune completed. Removed: {plugin._pruneBuffer.Count}. Cache size: {plugin._positionCache.Count}");
						}
						isPruning = false;
						result = false;
						break;
					}
					end_IL_0000:;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap4).Dispose();
			}

			private void <>m__Finally2()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap5).Dispose();
			}

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

		[CompilerGenerated]
		private sealed class <RenderVisualizationCoroutine>d__53 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			private int <totalCalls>5__2;

			private Camera <theCamera>5__3;

			private Vector3 <cameraPos>5__4;

			private float <x>5__5;

			private float <y>5__6;

			private float <z>5__7;

			private List<Vector3>.Enumerator <>7__wrap7;

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

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

			[DebuggerHidden]
			public <RenderVisualizationCoroutine>d__53(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				switch (<>1__state)
				{
				case -3:
				case 6:
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
					break;
				case -4:
				case 7:
					try
					{
					}
					finally
					{
						<>m__Finally2();
					}
					break;
				}
				<theCamera>5__3 = null;
				<>7__wrap7 = default(List<Vector3>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0338: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_038e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0393: Unknown result type (might be due to invalid IL or missing references)
				//IL_0423: Unknown result type (might be due to invalid IL or missing references)
				//IL_0428: Unknown result type (might be due to invalid IL or missing references)
				//IL_0300: 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_0142: 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_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0438: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_04de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_024e: 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_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: 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)
				try
				{
					int num = <>1__state;
					Plugin plugin = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (isPruning)
						{
							cancelPrune = true;
							goto IL_0071;
						}
						goto IL_007e;
					case 1:
						<>1__state = -1;
						goto IL_0071;
					case 2:
						<>1__state = -1;
						goto IL_028d;
					case 3:
						<>1__state = -1;
						goto IL_028d;
					case 4:
						<>1__state = -1;
						<>2__current = ((MonoBehaviour)plugin).StartCoroutine(plugin.SortWithYield(plugin.nonVisiblePositions, <cameraPos>5__4, MainYield));
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -1;
						<totalCalls>5__2 = 0;
						<>7__wrap7 = plugin.visiblePositions.GetEnumerator();
						<>1__state = -3;
						goto IL_03e3;
					case 6:
						<>1__state = -3;
						goto IL_03e3;
					case 7:
						<>1__state = -4;
						goto IL_0478;
					case 8:
						{
							<>1__state = -1;
							break;
						}
						IL_03e3:
						while (<>7__wrap7.MoveNext())
						{
							Vector3 current = <>7__wrap7.Current;
							if (pool_balls.Count <= 0)
							{
								break;
							}
							plugin.CheckAndPlaceBallAtWithCache(current);
							if (<totalCalls>5__2++ % PlaceYield == 0)
							{
								<>2__current = null;
								<>1__state = 6;
								return true;
							}
						}
						<>m__Finally1();
						<>7__wrap7 = default(List<Vector3>.Enumerator);
						<>7__wrap7 = plugin.nonVisiblePositions.GetEnumerator();
						<>1__state = -4;
						goto IL_0478;
						IL_02c2:
						if (<y>5__6 <= (float)yRange)
						{
							<z>5__7 = -zRange;
							goto IL_029f;
						}
						<x>5__5 += xFreq;
						goto IL_02e5;
						IL_0478:
						while (<>7__wrap7.MoveNext())
						{
							Vector3 current2 = <>7__wrap7.Current;
							if (pool_redBalls.Count <= 0)
							{
								break;
							}
							plugin.CheckAndPlaceBallAtWithCache(current2);
							if (<totalCalls>5__2++ % SlowPlaceYield == 0)
							{
								<>2__current = null;
								<>1__state = 7;
								return true;
							}
						}
						<>m__Finally2();
						<>7__wrap7 = default(List<Vector3>.Enumerator);
						if (plugin._positionCache.Count > MaxCacheSize)
						{
							if (plugin.configDebugMode.Value)
							{
								Logger.LogMessage((object)$"Cache size {plugin._positionCache.Count} exceeded threshold. Pruning now.");
							}
							<>2__current = ((MonoBehaviour)plugin).StartCoroutine(plugin.PruneCacheCoroutine(<cameraPos>5__4));
							<>1__state = 8;
							return true;
						}
						break;
						IL_028d:
						<z>5__7 += zFreq;
						goto IL_029f;
						IL_007e:
						plugin.ReturnBallsToPool();
						lastScanTime = Time.time;
						<totalCalls>5__2 = 0;
						plugin.visiblePositions.Clear();
						plugin.nonVisiblePositions.Clear();
						<theCamera>5__3 = Camera.main;
						<cameraPos>5__4 = ((Component)<theCamera>5__3).transform.position;
						<x>5__5 = -xRange;
						goto IL_02e5;
						IL_02e5:
						if (<x>5__5 <= (float)xRange)
						{
							<y>5__6 = -yRange;
							goto IL_02c2;
						}
						<>2__current = ((MonoBehaviour)plugin).StartCoroutine(plugin.SortWithYield(plugin.visiblePositions, <cameraPos>5__4, MainYield));
						<>1__state = 4;
						return true;
						IL_029f:
						if (<z>5__7 <= (float)zRange)
						{
							Vector3 val = default(Vector3);
							((Vector3)(ref val))..ctor(<cameraPos>5__4.x + <x>5__5, <cameraPos>5__4.y + <y>5__6, <cameraPos>5__4.z + <z>5__7);
							Vector3Int key = plugin.SnapToGrid(val);
							if (plugin._positionCache.TryGetValue(key, out var value))
							{
								if (value.HasHit && value.IsStandable && value.Angle > 30f)
								{
									plugin.PlaceBall(value.HitPoint, value.Angle);
								}
								plugin._cacheHitCount++;
								if (<totalCalls>5__2++ % PlaceYield == 0)
								{
									<>2__current = null;
									<>1__state = 2;
									return true;
								}
							}
							else
							{
								Vector3 val2 = <theCamera>5__3.WorldToViewportPoint(val);
								if (val2.x >= 0f && val2.x <= 1f && val2.y >= 0f && val2.y <= 1f && val2.z > 0f)
								{
									plugin.visiblePositions.Add(val);
								}
								else
								{
									plugin.nonVisiblePositions.Add(val);
								}
								if (<totalCalls>5__2++ % MainYield == 0)
								{
									<>2__current = null;
									<>1__state = 3;
									return true;
								}
							}
							goto IL_028d;
						}
						<y>5__6 += yFreq;
						goto IL_02c2;
						IL_0071:
						if (isPruning)
						{
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
						cancelPrune = false;
						goto IL_007e;
					}
					isVisualizationRunning = false;
					float num2 = ((plugin._cacheHitCount > 0) ? ((float)plugin._cacheHitCount / (float)(plugin._raycastCount + plugin._cacheHitCount) * 100f) : 0f);
					if (plugin.configDebugMode.Value)
					{
						Logger.LogMessage((object)"Raycast Statistics:");
						Logger.LogMessage((object)$"  Raycasts performed: {plugin._raycastCount}");
						Logger.LogMessage((object)$"  Cache hits: {plugin._cacheHitCount}");
						Logger.LogMessage((object)$"  Cache efficiency: {num2:F1}%");
						Logger.LogMessage((object)$"  Total cached entries: {plugin._positionCache.Count}");
					}
					plugin._raycastCount = 0;
					plugin._cacheHitCount = 0;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap7).Dispose();
			}

			private void <>m__Finally2()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap7).Dispose();
			}

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

		[CompilerGenerated]
		private sealed class <SortWithYield>d__54 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Vector3 cameraPosition;

			public List<Vector3> list;

			public int chunkSize;

			private int <n>5__2;

			private int <totalIterations>5__3;

			private Comparison<Vector3> <compare>5__4;

			private int <i>5__5;

			private List<Vector3> <chunk>5__6;

			private int <j>5__7;

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

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

			[DebuggerHidden]
			public <SortWithYield>d__54(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<compare>5__4 = null;
				<chunk>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_0112;
				}
				<>1__state = -1;
				<>c__DisplayClass54_0 CS$<>8__locals0 = new <>c__DisplayClass54_0
				{
					cameraPosition = cameraPosition
				};
				<n>5__2 = list.Count;
				<totalIterations>5__3 = 0;
				<compare>5__4 = delegate(Vector3 a, Vector3 b)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = a - CS$<>8__locals0.cameraPosition;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					val = b - CS$<>8__locals0.cameraPosition;
					float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
					return sqrMagnitude.CompareTo(sqrMagnitude2);
				};
				<i>5__5 = 0;
				goto IL_0152;
				IL_0152:
				if (<i>5__5 < <n>5__2)
				{
					int num2 = Mathf.Min(<i>5__5 + chunkSize, <n>5__2);
					<chunk>5__6 = list.GetRange(<i>5__5, num2 - <i>5__5);
					<chunk>5__6.Sort(<compare>5__4);
					<j>5__7 = 0;
					goto IL_0122;
				}
				return false;
				IL_0122:
				if (<j>5__7 < <chunk>5__6.Count)
				{
					list[<i>5__5 + <j>5__7] = <chunk>5__6[<j>5__7];
					<totalIterations>5__3++;
					if (<totalIterations>5__3 % MainYield == 0)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_0112;
				}
				<chunk>5__6 = null;
				<i>5__5 += chunkSize;
				goto IL_0152;
				IL_0112:
				<j>5__7++;
				goto IL_0122;
			}

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

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

		internal static ManualLogSource Logger;

		internal static Scene currentScene;

		internal static MainCamera mainCamera;

		internal static bool activated = false;

		internal static Material baseMaterial;

		internal static float alpha = 1f;

		private static readonly Queue<GameObject> balls = new Queue<GameObject>();

		private static readonly Queue<GameObject> redBalls = new Queue<GameObject>();

		private static readonly Queue<GameObject> pool_balls = new Queue<GameObject>();

		private static readonly Queue<GameObject> pool_redBalls = new Queue<GameObject>();

		private static float lastScanTime = 0f;

		private static float lastAlphaChangeTime = 0f;

		private ConfigEntry<KeyCode> configActivationKey;

		private ConfigEntry<bool> configDebugMode;

		private ConfigEntry<Mode> configMode;

		private ConfigEntry<StandableColor> configStandableBallColor;

		private ConfigEntry<NonStandableColor> configNonStandableBallColor;

		private Color LastStandableColor = Color.white;

		private Color LastNonStandableColor = Color.red;

		private static readonly int poolSize = 10000;

		private static bool isVisualizationRunning = false;

		private static bool isPruning = false;

		private static bool cancelPrune = false;

		private static readonly int MainYield = 8000;

		private static readonly int PlaceYield = 3000;

		private static readonly int SlowPlaceYield = 1000;

		private Coroutine _backgroundPruneCoroutine;

		private const float PruneIntervalSeconds = 5f;

		public static float xFreq = 0.5f;

		public static float yFreq = 1f;

		public static float zFreq = 0.5f;

		public static int xRange = 15;

		public static int yRange = 10;

		public static int zRange = 15;

		private static readonly int totalGridPoints = ((int)((float)(xRange - -xRange) / xFreq) + 1) * ((int)((float)(yRange - -yRange) / yFreq) + 1) * ((int)((float)(zRange - -zRange) / zFreq) + 1);

		private List<Vector3> visiblePositions = new List<Vector3>(totalGridPoints);

		private List<Vector3> nonVisiblePositions = new List<Vector3>(totalGridPoints);

		private static readonly int MaxCacheSize = totalGridPoints * 3;

		private Dictionary<Vector3Int, CachedResult> _positionCache = new Dictionary<Vector3Int, CachedResult>(totalGridPoints * 5);

		private const float SnapSize = 0.5f;

		private List<Vector3Int> _pruneBuffer = new List<Vector3Int>(totalGridPoints * 3);

		private int _raycastCount;

		private int _cacheHitCount;

		private Dictionary<Collider, CollisionModifier> _colliderModifierCache = new Dictionary<Collider, CollisionModifier>();

		private static readonly int TerrainLayerMask = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1));

		private void Awake()
		{
			//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_00cc: 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_00e8: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_012f: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			configStandableBallColor = ((BaseUnityPlugin)this).Config.Bind<StandableColor>("General", "Standable ground Color", StandableColor.Green, "Change the ball color of standable ground.");
			configNonStandableBallColor = ((BaseUnityPlugin)this).Config.Bind<NonStandableColor>("General", "Non-standable ground Color", NonStandableColor.Magenta, "Change the ball color of non-standable ground.");
			configActivationKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Activation Key", (KeyCode)102, (ConfigDescription)null);
			configMode = ((BaseUnityPlugin)this).Config.Bind<Mode>("General", "Activation Mode", Mode.Trigger, "Toggle: Press once to activate; press again to hide the indicator.\r\nFade Away: Activates every time the button is pressed. The indicator will fade away after 3 seconds. Credit to VicVoss on GitHub for the idea.\r\nTrigger: Activates every time the button is pressed. The indicator will remain visible.");
			configDebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Mode", false, "Show debug information");
			Material val = new Material(Shader.Find("Universal Render Pipeline/Lit"));
			val.SetFloat("_Surface", 1f);
			val.SetFloat("_Blend", 0f);
			val.SetInt("_IgnoreProjector", 1);
			val.SetInt("_ReceiveShadows", 0);
			val.SetInt("_ZWrite", 0);
			val.SetInt("_SrcBlend", 5);
			val.SetInt("_DstBlend", 10);
			val.DisableKeyword("_ALPHATEST_ON");
			val.EnableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
			val.renderQueue = 3500;
			baseMaterial = val;
			SceneManager.sceneLoaded += OnSceneLoaded;
			configStandableBallColor.SettingChanged += Color_SettingChanged;
			configNonStandableBallColor.SettingChanged += Color_SettingChanged;
			configMode.SettingChanged += ConfigMode_SettingChanged;
			Logger.LogMessage((object)"          Plugin MyFoothold 1.0.0 is loaded!");
		}

		private void ConfigMode_SettingChanged(object sender, EventArgs e)
		{
			//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_0058: Unknown result type (might be due to invalid IL or missing references)
			ReturnBallsToPool();
			if (configMode.Value == Mode.FadeAway)
			{
				return;
			}
			foreach (GameObject item in balls.Concat(redBalls))
			{
				Material material = item.GetComponent<Renderer>().material;
				Color color = material.GetColor("_BaseColor");
				color.a = alpha;
				material.SetColor("_BaseColor", color);
			}
		}

		private void Color_SettingChanged(object sender, EventArgs e)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_008f: 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_00a8: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!((Scene)(ref currentScene)).name.StartsWith("Level_") && !((Scene)(ref currentScene)).name.StartsWith("Airport"))
			{
				return;
			}
			ReturnBallsToPool();
			Color val = ((configStandableBallColor.Value != StandableColor.Green) ? Color.white : Color.green);
			Color val2 = ((configNonStandableBallColor.Value != NonStandableColor.Magenta) ? Color.red : Color.magenta);
			if (LastStandableColor != val)
			{
				pool_balls.Clear();
				for (int i = 0; i < poolSize; i++)
				{
					pool_balls.Enqueue(CreateBall(val));
				}
				LastStandableColor = val;
			}
			if (LastNonStandableColor != val2)
			{
				pool_redBalls.Clear();
				for (int j = 0; j < poolSize; j++)
				{
					pool_redBalls.Enqueue(CreateBall(val2));
				}
				LastNonStandableColor = val2;
			}
		}

		private void OnGUI()
		{
			//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)
			if (configDebugMode.Value)
			{
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				Vector3 position = ((Component)Camera.main).transform.position;
				GUILayout.Label("Camera: " + ((object)(Vector3)(ref position)).ToString(), Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("balls: " + balls.Count, Array.Empty<GUILayoutOption>());
				GUILayout.Label("redBalls: " + redBalls.Count, Array.Empty<GUILayoutOption>());
				GUILayout.Label("pool_balls: " + pool_balls.Count, Array.Empty<GUILayoutOption>());
				GUILayout.Label("pool_redBalls: " + pool_redBalls.Count, Array.Empty<GUILayoutOption>());
				GUILayout.Label("alpha: " + alpha, Array.Empty<GUILayoutOption>());
				GUILayout.Label("isVisualizationRunning: " + isVisualizationRunning, Array.Empty<GUILayoutOption>());
				GUILayout.Label("isPruning: " + isPruning, Array.Empty<GUILayoutOption>());
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
				GUILayout.Label("totalGridPoints: " + totalGridPoints, Array.Empty<GUILayoutOption>());
				GUILayout.Label("_positionCache: " + _positionCache.Count, Array.Empty<GUILayoutOption>());
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode _)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			currentScene = scene;
			balls.Clear();
			redBalls.Clear();
			pool_balls.Clear();
			pool_redBalls.Clear();
			if (((Scene)(ref currentScene)).name.StartsWith("Level_") || ((Scene)(ref currentScene)).name.StartsWith("Airport"))
			{
				Color val = ((configStandableBallColor.Value != StandableColor.Green) ? Color.white : Color.green);
				Color val2 = ((configNonStandableBallColor.Value != NonStandableColor.Magenta) ? Color.red : Color.magenta);
				LastStandableColor = val;
				LastNonStandableColor = val2;
				for (int i = 0; i < poolSize; i++)
				{
					pool_balls.Enqueue(CreateBall(val));
					pool_redBalls.Enqueue(CreateBall(val2));
				}
				if (_backgroundPruneCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_backgroundPruneCoroutine);
				}
				_backgroundPruneCoroutine = ((MonoBehaviour)this).StartCoroutine(BackgroundPruneCoroutine());
			}
			else if (_backgroundPruneCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_backgroundPruneCoroutine);
				_backgroundPruneCoroutine = null;
			}
		}

		private GameObject CreateBall(Color ballColor)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			val.SetActive(false);
			int num = LayerMask.NameToLayer("UI");
			val.layer = ((num != -1) ? num : LayerMask.NameToLayer("Default"));
			Renderer component = val.GetComponent<Renderer>();
			Material material = new Material(baseMaterial);
			component.material = material;
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
			val.GetComponent<Collider>().enabled = false;
			ballColor.a = 1f;
			component.material.SetColor("_BaseColor", ballColor);
			val.transform.localScale = Vector3.one / 5f;
			return val;
		}

		private void Update()
		{
			if (!((Scene)(ref currentScene)).name.StartsWith("Level_") && !((Scene)(ref currentScene)).name.StartsWith("Airport"))
			{
				return;
			}
			if ((Object)(object)mainCamera == (Object)null)
			{
				mainCamera = Object.FindFirstObjectByType<MainCamera>();
				return;
			}
			CheckHotkeys();
			if (configMode.Value == Mode.FadeAway)
			{
				SetBallAlphas();
			}
		}

		private void CheckHotkeys()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKeyDown(configActivationKey.Value) || isVisualizationRunning)
			{
				return;
			}
			if (configMode.Value == Mode.Trigger)
			{
				isVisualizationRunning = true;
				((MonoBehaviour)this).StartCoroutine(RenderVisualizationCoroutine());
				return;
			}
			if (configMode.Value == Mode.Toggle)
			{
				activated = !activated;
			}
			if (activated || configMode.Value == Mode.FadeAway)
			{
				isVisualizationRunning = true;
				((MonoBehaviour)this).StartCoroutine(RenderVisualizationCoroutine());
			}
			else
			{
				ReturnBallsToPool();
			}
		}

		private void ReturnBallsToPool()
		{
			foreach (GameObject item in balls.ToList())
			{
				item.SetActive(false);
				balls.Dequeue();
				pool_balls.Enqueue(item);
			}
			foreach (GameObject item2 in redBalls.ToList())
			{
				item2.SetActive(false);
				redBalls.Dequeue();
				pool_redBalls.Enqueue(item2);
			}
		}

		private void RenderVisualization()
		{
			//IL_0044: 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_0070: 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)
			ReturnBallsToPool();
			lastScanTime = Time.time;
			float num = 0.5f;
			float num2 = 1f;
			Vector3 position = default(Vector3);
			for (float num3 = -10f; num3 <= 10f; num3 += num)
			{
				for (float num4 = -10f; num4 <= 10f; num4 += num2)
				{
					for (float num5 = -10f; num5 <= 10f; num5 += num)
					{
						((Vector3)(ref position))..ctor(((Component)mainCamera).transform.position.x + num3, ((Component)mainCamera).transform.position.y + num4, ((Component)mainCamera).transform.position.z + num5);
						CheckAndPlaceBallAt(position);
					}
				}
			}
		}

		[IteratorStateMachine(typeof(<RenderVisualizationCoroutine>d__53))]
		private IEnumerator RenderVisualizationCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RenderVisualizationCoroutine>d__53(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<SortWithYield>d__54))]
		private IEnumerator SortWithYield(List<Vector3> list, Vector3 cameraPosition, int chunkSize)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SortWithYield>d__54(0)
			{
				list = list,
				cameraPosition = cameraPosition,
				chunkSize = chunkSize
			};
		}

		private CollisionModifier GetCachedModifier(Collider collider)
		{
			if (!_colliderModifierCache.TryGetValue(collider, out var value))
			{
				value = ((Component)collider).GetComponent<CollisionModifier>();
				_colliderModifierCache[collider] = value;
			}
			return value;
		}

		private static bool TryRaycastDown(Vector3 position, float distance, out RaycastHit hit)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Physics.Raycast(position, Vector3.down, ref hit, distance, TerrainLayerMask, (QueryTriggerInteraction)1);
		}

		private void CheckAndPlaceBallAt(Vector3 position)
		{
			//IL_0000: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!TryRaycastDown(position, 1f, out var hit))
			{
				return;
			}
			CollisionModifier cachedModifier = GetCachedModifier(((RaycastHit)(ref hit)).collider);
			if ((Object)(object)cachedModifier != (Object)null && !cachedModifier.standable)
			{
				return;
			}
			float num = Vector3.Angle(Vector3.up, ((RaycastHit)(ref hit)).normal);
			if (!(num <= 30f))
			{
				if (num < 50f && pool_balls.Count > 0)
				{
					GameObject val = pool_balls.Dequeue();
					val.transform.position = ((RaycastHit)(ref hit)).point;
					balls.Enqueue(val);
					val.SetActive(true);
				}
				else if (num >= 50f && pool_redBalls.Count > 0)
				{
					GameObject val2 = pool_redBalls.Dequeue();
					val2.transform.position = ((RaycastHit)(ref hit)).point;
					redBalls.Enqueue(val2);
					val2.SetActive(true);
				}
			}
		}

		private Vector3Int SnapToGrid(Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			return new Vector3Int(Mathf.RoundToInt(position.x / 0.5f), Mathf.RoundToInt(position.y / 0.5f), Mathf.RoundToInt(position.z / 0.5f));
		}

		private void CheckAndPlaceBallAtWithCache(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references)
			Vector3Int key = SnapToGrid(position);
			_raycastCount++;
			if (!TryRaycastDown(position, 1f, out var hit))
			{
				_positionCache[key] = new CachedResult
				{
					HasHit = false
				};
				return;
			}
			CollisionModifier cachedModifier = GetCachedModifier(((RaycastHit)(ref hit)).collider);
			bool flag = (Object)(object)cachedModifier == (Object)null || cachedModifier.standable;
			float num = Vector3.Angle(Vector3.up, ((RaycastHit)(ref hit)).normal);
			_positionCache[key] = new CachedResult
			{
				HasHit = true,
				HitPoint = ((RaycastHit)(ref hit)).point,
				Angle = num,
				IsStandable = flag
			};
			if (flag && !(num <= 30f))
			{
				PlaceBall(((RaycastHit)(ref hit)).point, num);
			}
		}

		private void PlaceBall(Vector3 hitPoint, float angle)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (angle < 50f && pool_balls.Count > 0)
			{
				GameObject val = pool_balls.Dequeue();
				val.transform.position = hitPoint;
				balls.Enqueue(val);
				val.SetActive(true);
			}
			else if (angle >= 50f && pool_redBalls.Count > 0)
			{
				GameObject val2 = pool_redBalls.Dequeue();
				val2.transform.position = hitPoint;
				redBalls.Enqueue(val2);
				val2.SetActive(true);
			}
		}

		private void PruneCache(Vector3 cameraPos, float range = 25f)
		{
			//IL_001f: 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_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			float num = range * range;
			List<Vector3Int> list = new List<Vector3Int>();
			foreach (Vector3Int key in _positionCache.Keys)
			{
				Vector3Int current = key;
				Vector3 val = new Vector3((float)((Vector3Int)(ref current)).x, (float)((Vector3Int)(ref current)).y, (float)((Vector3Int)(ref current)).z) * 0.5f - cameraPos;
				if (((Vector3)(ref val)).sqrMagnitude > num)
				{
					list.Add(current);
				}
			}
			foreach (Vector3Int item in list)
			{
				_positionCache.Remove(item);
			}
		}

		[IteratorStateMachine(typeof(<BackgroundPruneCoroutine>d__65))]
		private IEnumerator BackgroundPruneCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BackgroundPruneCoroutine>d__65(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<PruneCacheCoroutine>d__66))]
		private IEnumerator PruneCacheCoroutine(Vector3 cameraPos, float range = 25f)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PruneCacheCoroutine>d__66(0)
			{
				<>4__this = this,
				cameraPos = cameraPos,
				range = range
			};
		}

		private void SetBallAlphas()
		{
			//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_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (configMode.Value != Mode.FadeAway || (double)(Time.time - lastAlphaChangeTime) < 0.05)
			{
				return;
			}
			lastAlphaChangeTime = Time.time;
			alpha = Mathf.Lerp(1f, 0f, Mathf.Clamp01((Time.time - (lastScanTime + 3f)) / 3f));
			foreach (GameObject item in balls.Concat(redBalls))
			{
				Material material = item.GetComponent<Renderer>().material;
				Color color = material.GetColor("_BaseColor");
				color.a = alpha;
				material.SetColor("_BaseColor", color);
			}
			if (!(alpha <= 0f))
			{
				return;
			}
			if (balls.Count > 0)
			{
				foreach (GameObject item2 in balls.ToList())
				{
					item2.SetActive(false);
					balls.Dequeue();
					pool_balls.Enqueue(item2);
				}
			}
			if (redBalls.Count <= 0)
			{
				return;
			}
			foreach (GameObject item3 in redBalls.ToList())
			{
				item3.SetActive(false);
				redBalls.Dequeue();
				pool_redBalls.Enqueue(item3);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "my.pahsiv.MyFoothold";

		public const string PLUGIN_NAME = "MyFoothold";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}