using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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: AssemblyCompany("Foothold")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.6.0+82c8d80f0e9f930555cf4b78778c1f32b02fd899")]
[assembly: AssemblyProduct("Foothold?")]
[assembly: AssemblyTitle("Foothold")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.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("Foothold", "Foothold?", "1.6.0")]
public class Plugin : BaseUnityPlugin
{
internal enum StandableColor
{
White,
Green
}
internal enum NonStandableColor
{
Red,
Magenta
}
internal enum Mode
{
Toggle,
FadeAway,
Trigger,
Continuous
}
private class PositionKey
{
private static readonly Queue<PositionKey> pool;
private static int poolSize;
public static int totalAllocations;
public static int totalInUse;
private bool isInUse = false;
public Vector3 position;
public bool standable;
public Matrix4x4 matrix;
public bool ballVisible = false;
public (int, int) ballMatrixIndex = (-1, -1);
public static int PoolCount => pool.Count;
static PositionKey()
{
pool = new Queue<PositionKey>();
poolSize = 40000;
totalAllocations = 0;
totalInUse = 0;
for (int i = 0; i < poolSize; i++)
{
pool.Enqueue(new PositionKey());
totalAllocations++;
}
}
private PositionKey()
{
}
public static PositionKey GetNew(float x, float y, float z, bool standable, GameObject ballObject = null)
{
//IL_005a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (pool.Count <= 0)
{
for (int i = 0; i < poolSize / 5; i++)
{
pool.Enqueue(new PositionKey());
totalAllocations++;
}
}
PositionKey positionKey = pool.Dequeue();
positionKey.position = new Vector3(x, y, z);
positionKey.matrix = Matrix4x4.TRS(positionKey.position, Quaternion.identity, scale);
positionKey.standable = standable;
positionKey.ballVisible = false;
positionKey.isInUse = true;
totalInUse++;
return positionKey;
}
public static PositionKey GetNew(Vector3 position, bool standable, GameObject ballObject = null)
{
//IL_0057: 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_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_0069: 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)
if (pool.Count <= 0)
{
for (int i = 0; i < poolSize / 5; i++)
{
pool.Enqueue(new PositionKey());
totalAllocations++;
}
}
PositionKey positionKey = pool.Dequeue();
positionKey.position = position;
positionKey.matrix = Matrix4x4.TRS(positionKey.position, Quaternion.identity, scale);
positionKey.standable = standable;
positionKey.ballVisible = false;
positionKey.isInUse = true;
totalInUse++;
return positionKey;
}
public void ReturnToPool()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (isInUse)
{
ReturnBallToPool(this);
position = Vector3.zero;
standable = false;
ballVisible = false;
isInUse = false;
pool.Enqueue(this);
totalInUse--;
}
}
}
private class PositionYList
{
private static readonly Queue<PositionYList> pool;
private static int poolSize;
public static int totalAllocations;
public static int totalInUse;
public readonly Dictionary<int, PositionKey> list = new Dictionary<int, PositionKey>();
private bool isInUse = false;
public float rayTop = 0f;
public float rayBottom = 0f;
public static int PoolCount => pool.Count;
static PositionYList()
{
pool = new Queue<PositionYList>();
poolSize = 10000;
totalAllocations = 0;
totalInUse = 0;
for (int i = 0; i < poolSize; i++)
{
pool.Enqueue(new PositionYList());
totalAllocations++;
}
}
private PositionYList()
{
}
public static PositionYList GetNew()
{
if (pool.Count <= 0)
{
for (int i = 0; i < poolSize / 5; i++)
{
pool.Enqueue(new PositionYList());
totalAllocations++;
}
}
PositionYList positionYList = pool.Dequeue();
positionYList.list.Clear();
positionYList.isInUse = true;
totalInUse++;
return positionYList;
}
public void ReturnToPool()
{
if (!isInUse)
{
return;
}
totalInUse--;
isInUse = false;
foreach (PositionKey value in list.Values)
{
value?.ReturnToPool();
}
list.Clear();
pool.Enqueue(this);
}
}
public struct FastFrustum
{
public Vector3 camPos;
public Vector3 forward;
public Vector3 right;
public Vector3 up;
public float near;
public float far;
public float nearSqr;
public float farSqr;
public float tanHalfVertFov;
public float tanHalfHorFov;
private float XPrepZ;
private float XZPrepZ;
private float XPrepX;
private float XZPrepX;
private float XPrepY;
private float XZPrepY;
private float XPrepDistance;
private float XZPrepDistance;
public FastFrustum(Camera cam, float farClipPlaneOverride = -1f)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
XPrepZ = 0f;
XZPrepZ = 0f;
XPrepX = 0f;
XZPrepX = 0f;
XPrepY = 0f;
XZPrepY = 0f;
XPrepDistance = 0f;
XZPrepDistance = 0f;
Transform transform = ((Component)cam).transform;
camPos = transform.position;
forward = transform.forward;
right = transform.right;
up = transform.up;
near = cam.nearClipPlane;
far = cam.farClipPlane;
nearSqr = near * near;
farSqr = far * far;
if (farClipPlaneOverride > 0f)
{
far = farClipPlaneOverride;
}
float num = 0.5f * cam.fieldOfView * (MathF.PI / 180f);
tanHalfVertFov = Mathf.Tan(num);
tanHalfHorFov = tanHalfVertFov * cam.aspect;
}
public void PrepX(float x)
{
x -= camPos.x;
XPrepZ = x * forward.x;
XPrepX = x * right.x;
XPrepY = x * up.x;
XPrepDistance = x * x;
}
public void PrepXZ(float z)
{
z -= camPos.z;
XZPrepZ = XPrepZ + z * forward.z;
XZPrepX = XPrepX + z * right.z;
XZPrepY = XPrepY + z * up.z;
XZPrepDistance = XPrepDistance + z * z;
}
public bool PreppedYContains(float pointY)
{
pointY -= camPos.y;
float num = XZPrepZ + pointY * forward.y;
if (num < near || num > far)
{
return false;
}
float num2 = XZPrepX + pointY * right.y;
float num3 = num * tanHalfHorFov;
if (Mathf.Abs(num2) > num3)
{
return false;
}
float num4 = XZPrepY + pointY * up.y;
float num5 = num * tanHalfVertFov;
if (Mathf.Abs(num4) > num5)
{
return false;
}
float num6 = XZPrepDistance + pointY * pointY;
if (num6 < nearSqr || num6 > farSqr)
{
return false;
}
return true;
}
public bool Contains(Vector3 point)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = point - camPos;
float num = Vector3.Dot(val, forward);
if (num < near || num > far)
{
return false;
}
float num2 = Vector3.Dot(val, right);
float num3 = num * tanHalfHorFov;
if (Mathf.Abs(num2) > num3)
{
return false;
}
float num4 = Vector3.Dot(val, up);
float num5 = num * tanHalfVertFov;
if (Mathf.Abs(num4) > num5)
{
return false;
}
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (sqrMagnitude < nearSqr || sqrMagnitude > farSqr)
{
return false;
}
return true;
}
public (int, int, int, int) GetFrequencyQuantizedXZFrustumBounds(float freq)
{
(float, float, float, float) xZFrustumBounds = GetXZFrustumBounds();
float item = xZFrustumBounds.Item1;
float item2 = xZFrustumBounds.Item2;
float item3 = xZFrustumBounds.Item3;
float item4 = xZFrustumBounds.Item4;
int item5 = (int)Mathf.Round(Mathf.Round(item / freq) * freq * 10f);
int item6 = (int)Mathf.Round(Mathf.Round(item2 / freq) * freq * 10f);
int item7 = (int)Mathf.Round(Mathf.Round(item3 / freq) * freq * 10f);
int item8 = (int)Mathf.Round(Mathf.Round(item4 / freq) * freq * 10f);
return (item5, item6, item7, item8);
}
public (float, float, float, float) GetXZFrustumBounds()
{
//IL_003b: 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_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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00e6: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: 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)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: 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)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: 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_015a: 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_015f: 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_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: 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_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: 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_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
float num = near * tanHalfVertFov;
float num2 = near * tanHalfHorFov;
float num3 = far * tanHalfVertFov;
float num4 = far * tanHalfHorFov;
Vector3 val = camPos + forward * near;
Vector3 val2 = camPos + forward * far;
Vector3 p2 = val + up * num - right * num2;
Vector3 p3 = val + up * num + right * num2;
Vector3 p4 = val - up * num - right * num2;
Vector3 p5 = val - up * num + right * num2;
Vector3 p6 = val2 + up * num3 - right * num4;
Vector3 p7 = val2 + up * num3 + right * num4;
Vector3 p8 = val2 - up * num3 - right * num4;
Vector3 p9 = val2 - up * num3 + right * num4;
float minX = float.PositiveInfinity;
float maxX = float.NegativeInfinity;
float minZ = float.PositiveInfinity;
float maxZ = float.NegativeInfinity;
Encapsulate(p2);
Encapsulate(p3);
Encapsulate(p4);
Encapsulate(p5);
Encapsulate(p6);
Encapsulate(p7);
Encapsulate(p8);
Encapsulate(p9);
return (minX, maxX, minZ, maxZ);
void Encapsulate(Vector3 p)
{
//IL_0001: 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_0014: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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)
if (p.x < minX)
{
minX = p.x;
}
if (p.x > maxX)
{
maxX = p.x;
}
if (p.z < minZ)
{
minZ = p.z;
}
if (p.z > maxZ)
{
maxZ = p.z;
}
}
}
}
private struct SafeXZ
{
public int x;
public float y;
public int z;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass70_0
{
public Vector3 cameraPosition;
internal int <SortWithYield>b__0(Vector3 a, Vector3 b)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
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 <RenderChangedVisualizationCoroutine>d__68 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private int <overallTotalCalls>5__1;
private int <prevMinX>5__2;
private int <prevMaxX>5__3;
private int <prevMinZ>5__4;
private int <prevMaxZ>5__5;
private Rect <oldArea>5__6;
private Rect <oldCacheKeepArea>5__7;
private Rect <oldRecheckArea>5__8;
private int <minX>5__9;
private int <maxX>5__10;
private int <minZ>5__11;
private int <maxZ>5__12;
private Rect <newArea>5__13;
private Rect <newCacheKeepArea>5__14;
private Rect <recheckArea>5__15;
private List<Rect> <newAreas>5__16;
private List<Rect> <expiredCacheKeepAreas>5__17;
private List<Rect> <expiredRecheckAreas>5__18;
private PositionYList <pCache>5__19;
private List<Rect>.Enumerator <>s__20;
private Rect <area>5__21;
private int <axMax>5__22;
private int <ayMax>5__23;
private int <x>5__24;
private int <z>5__25;
private Exception <e>5__26;
private Exception <e>5__27;
private List<Rect>.Enumerator <>s__28;
private Rect <area>5__29;
private int <axMax>5__30;
private int <ayMax>5__31;
private int <x>5__32;
private int <z>5__33;
private Exception <e>5__34;
private List<Rect>.Enumerator <>s__35;
private Rect <area>5__36;
private int <axMax>5__37;
private int <ayMax>5__38;
private int <x>5__39;
private int <z>5__40;
private Exception <e>5__41;
private Rect <area>5__42;
private int <axMax>5__43;
private int <ayMax>5__44;
private int <x>5__45;
private int <z>5__46;
private Exception <e>5__47;
private Exception <e>5__48;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RenderChangedVisualizationCoroutine>d__68(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
switch (<>1__state)
{
case -3:
case 1:
case 2:
try
{
}
finally
{
<>m__Finally1();
}
break;
case -4:
case 3:
try
{
}
finally
{
<>m__Finally2();
}
break;
case -5:
case 4:
try
{
}
finally
{
<>m__Finally3();
}
break;
}
<newAreas>5__16 = null;
<expiredCacheKeepAreas>5__17 = null;
<expiredRecheckAreas>5__18 = null;
<pCache>5__19 = null;
<>s__20 = default(List<Rect>.Enumerator);
<e>5__26 = null;
<e>5__27 = null;
<>s__28 = default(List<Rect>.Enumerator);
<e>5__34 = null;
<>s__35 = default(List<Rect>.Enumerator);
<e>5__41 = null;
<e>5__47 = null;
<e>5__48 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: 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_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_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0794: Unknown result type (might be due to invalid IL or missing references)
//IL_0799: Unknown result type (might be due to invalid IL or missing references)
//IL_090e: Unknown result type (might be due to invalid IL or missing references)
//IL_0913: Unknown result type (might be due to invalid IL or missing references)
try
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
additionalDebugInfo = "";
lastScanTime = Time.time;
totalCalls = 0;
<overallTotalCalls>5__1 = 0;
(int, int, int, int) frequencyQuantizedXZFrustumBounds = cameraFrustum.GetFrequencyQuantizedXZFrustumBounds(freq);
<prevMinX>5__2 = frequencyQuantizedXZFrustumBounds.Item1;
<prevMaxX>5__3 = frequencyQuantizedXZFrustumBounds.Item2;
<prevMinZ>5__4 = frequencyQuantizedXZFrustumBounds.Item3;
<prevMaxZ>5__5 = frequencyQuantizedXZFrustumBounds.Item4;
<oldArea>5__6 = Rect.MinMaxRect((float)(nearestGridToCamera.x - safeRange), (float)(nearestGridToCamera.z - safeRange), (float)(nearestGridToCamera.x + safeRange), (float)(nearestGridToCamera.z + safeRange));
<oldCacheKeepArea>5__7 = Rect.MinMaxRect((float)(nearestGridToCamera.x - safeRange * 2), (float)(nearestGridToCamera.z - safeRange * 2), (float)(nearestGridToCamera.x + safeRange * 2), (float)(nearestGridToCamera.z + safeRange * 2));
<oldRecheckArea>5__8 = Rect.MinMaxRect((float)<prevMinX>5__2, (float)<prevMinZ>5__4, (float)<prevMaxX>5__3, (float)<prevMaxZ>5__5);
nearestGridToCamera.x = (int)Mathf.Round(Mathf.Round(focalReferencePoint.x / freq) * freq * 10f);
nearestGridToCamera.y = focalReferencePoint.y;
nearestGridToCamera.z = (int)Mathf.Round(Mathf.Round(focalReferencePoint.z / freq) * freq * 10f);
cameraFrustum = new FastFrustum(mainCamera, range);
frequencyQuantizedXZFrustumBounds = cameraFrustum.GetFrequencyQuantizedXZFrustumBounds(freq);
<minX>5__9 = frequencyQuantizedXZFrustumBounds.Item1;
<maxX>5__10 = frequencyQuantizedXZFrustumBounds.Item2;
<minZ>5__11 = frequencyQuantizedXZFrustumBounds.Item3;
<maxZ>5__12 = frequencyQuantizedXZFrustumBounds.Item4;
<newArea>5__13 = Rect.MinMaxRect((float)(nearestGridToCamera.x - safeRange), (float)(nearestGridToCamera.z - safeRange), (float)(nearestGridToCamera.x + safeRange), (float)(nearestGridToCamera.z + safeRange));
<newCacheKeepArea>5__14 = Rect.MinMaxRect((float)(nearestGridToCamera.x - safeRange * 2), (float)(nearestGridToCamera.z - safeRange * 2), (float)(nearestGridToCamera.x + safeRange * 2), (float)(nearestGridToCamera.z + safeRange * 2));
<recheckArea>5__15 = Rect.MinMaxRect((float)<minX>5__9, (float)<minZ>5__11, (float)<maxX>5__10, (float)<maxZ>5__12);
<newAreas>5__16 = SubtractRect(<newArea>5__13, <oldArea>5__6);
<expiredCacheKeepAreas>5__17 = SubtractRect(<oldCacheKeepArea>5__7, <newCacheKeepArea>5__14);
<expiredRecheckAreas>5__18 = SubtractRect(<oldRecheckArea>5__8, <recheckArea>5__15);
<pCache>5__19 = null;
<>s__20 = <newAreas>5__16.GetEnumerator();
<>1__state = -3;
goto IL_05ae;
}
case 1:
<>1__state = -3;
goto IL_04c9;
case 2:
<>1__state = -3;
goto IL_0553;
case 3:
<>1__state = -4;
goto IL_06f0;
case 4:
<>1__state = -5;
goto IL_088d;
case 5:
<>1__state = -1;
goto IL_0a44;
case 6:
{
<>1__state = -1;
goto IL_0acd;
}
IL_05ae:
if (<>s__20.MoveNext())
{
<area>5__21 = <>s__20.Current;
<axMax>5__22 = (int)Mathf.Round(((Rect)(ref <area>5__21)).xMax);
<ayMax>5__23 = (int)Mathf.Round(((Rect)(ref <area>5__21)).yMax);
<x>5__24 = (int)Mathf.Round(((Rect)(ref <area>5__21)).xMin);
goto IL_0593;
}
<>m__Finally1();
<>s__20 = default(List<Rect>.Enumerator);
<>s__28 = <expiredCacheKeepAreas>5__17.GetEnumerator();
<>1__state = -4;
goto IL_074b;
IL_04c9:
try
{
<>4__this.PlaceBallsInVerticalRay(<pCache>5__19, nearestGridToCamera.y, onlyInFrustum: true);
}
catch (Exception ex)
{
<e>5__27 = ex;
Logger.LogError((object)<e>5__27);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 2;
return true;
}
goto IL_0553;
IL_074b:
if (<>s__28.MoveNext())
{
<area>5__29 = <>s__28.Current;
<axMax>5__30 = (int)Mathf.Round(((Rect)(ref <area>5__29)).xMax);
<ayMax>5__31 = (int)Mathf.Round(((Rect)(ref <area>5__29)).yMax);
<x>5__32 = (int)Mathf.Round(((Rect)(ref <area>5__29)).xMin);
goto IL_0730;
}
<>m__Finally2();
<>s__28 = default(List<Rect>.Enumerator);
<>s__35 = <expiredRecheckAreas>5__18.GetEnumerator();
<>1__state = -5;
goto IL_08e8;
IL_0566:
if (<z>5__25 <= <ayMax>5__23)
{
cameraFrustum.PrepXZ((float)<z>5__25 / 10f);
try
{
<pCache>5__19 = <>4__this.CheckCacheMiss(<x>5__24, nearestGridToCamera.y, <z>5__25);
}
catch (Exception ex)
{
<e>5__26 = ex;
Logger.LogError((object)<e>5__26);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 1;
return true;
}
goto IL_04c9;
}
<x>5__24 += safeFreq;
goto IL_0593;
IL_08e8:
if (<>s__35.MoveNext())
{
<area>5__36 = <>s__35.Current;
<axMax>5__37 = (int)Mathf.Round(((Rect)(ref <area>5__36)).xMax);
<ayMax>5__38 = (int)Mathf.Round(((Rect)(ref <area>5__36)).yMax);
<x>5__39 = (int)Mathf.Round(((Rect)(ref <area>5__36)).xMin);
goto IL_08cd;
}
<>m__Finally3();
<>s__35 = default(List<Rect>.Enumerator);
<area>5__42 = <recheckArea>5__15;
<axMax>5__43 = (int)Mathf.Round(((Rect)(ref <area>5__42)).xMax);
<ayMax>5__44 = (int)Mathf.Round(((Rect)(ref <area>5__42)).yMax);
<x>5__45 = (int)Mathf.Round(((Rect)(ref <area>5__42)).xMin);
goto IL_0b0d;
IL_0b0d:
if (<x>5__45 <= <axMax>5__43)
{
cameraFrustum.PrepX((float)<x>5__45 / 10f);
<z>5__46 = (int)Mathf.Round(((Rect)(ref <area>5__42)).yMin);
goto IL_0ae0;
}
<>4__this.overallTotalCallsLastRender = <overallTotalCalls>5__1;
isVisualizationRunning = false;
return false;
IL_06f0:
<z>5__33 += safeFreq;
goto IL_0703;
IL_08cd:
if (<x>5__39 <= <axMax>5__37)
{
<z>5__40 = (int)Mathf.Round(((Rect)(ref <area>5__36)).yMin);
goto IL_08a0;
}
goto IL_08e8;
IL_0ae0:
if (<z>5__46 <= <ayMax>5__44)
{
try
{
cameraFrustum.PrepXZ((float)<z>5__46 / 10f);
<pCache>5__19 = <>4__this.CheckCacheMiss(<x>5__45, nearestGridToCamera.y, <z>5__46);
}
catch (Exception ex)
{
<e>5__47 = ex;
Logger.LogError((object)<e>5__47);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 5;
return true;
}
goto IL_0a44;
}
<x>5__45 += safeFreq;
goto IL_0b0d;
IL_088d:
<z>5__40 += safeFreq;
goto IL_08a0;
IL_08a0:
if (<z>5__40 <= <ayMax>5__38)
{
try
{
<>4__this.RemoveBallsInVerticalRay(<x>5__39, <z>5__40, expireCache: false);
}
catch (Exception ex)
{
<e>5__41 = ex;
Logger.LogError((object)<e>5__41);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 4;
return true;
}
goto IL_088d;
}
<x>5__39 += safeFreq;
goto IL_08cd;
IL_0730:
if (<x>5__32 <= <axMax>5__30)
{
<z>5__33 = (int)Mathf.Round(((Rect)(ref <area>5__29)).yMin);
goto IL_0703;
}
goto IL_074b;
IL_0593:
if (<x>5__24 <= <axMax>5__22)
{
cameraFrustum.PrepX((float)<x>5__24 / 10f);
<z>5__25 = (int)Mathf.Round(((Rect)(ref <area>5__21)).yMin);
goto IL_0566;
}
goto IL_05ae;
IL_0a44:
try
{
<>4__this.PlaceBallsInVerticalRay(<pCache>5__19, nearestGridToCamera.y, onlyInFrustum: true);
}
catch (Exception ex)
{
<e>5__48 = ex;
Logger.LogError((object)<e>5__48);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 6;
return true;
}
goto IL_0acd;
IL_0703:
if (<z>5__33 <= <ayMax>5__31)
{
try
{
<>4__this.RemoveBallsInVerticalRay(<x>5__32, <z>5__33);
}
catch (Exception ex)
{
<e>5__34 = ex;
Logger.LogError((object)<e>5__34);
}
if (totalCalls >= maximumRaysPerFrame)
{
<overallTotalCalls>5__1 += totalCalls;
totalCalls = 0;
<>2__current = null;
<>1__state = 3;
return true;
}
goto IL_06f0;
}
<x>5__32 += safeFreq;
goto IL_0730;
IL_0553:
<z>5__25 += safeFreq;
goto IL_0566;
IL_0acd:
<z>5__46 += safeFreq;
goto IL_0ae0;
}
}
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)<>s__20).Dispose();
}
private void <>m__Finally2()
{
<>1__state = -1;
((IDisposable)<>s__28).Dispose();
}
private void <>m__Finally3()
{
<>1__state = -1;
((IDisposable)<>s__35).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <RenderVisualizationCoroutine>d__66 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private int <totalCalls>5__1;
private int <x>5__2;
private int <z>5__3;
private Exception <e>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RenderVisualizationCoroutine>d__66(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<e>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
goto IL_01b6;
}
<>1__state = -1;
additionalDebugInfo = "";
<>4__this.ReturnAllBallsToPool();
lastScanTime = Time.time;
<totalCalls>5__1 = 0;
nearestGridToCamera.x = (int)Mathf.Round(Mathf.Round(focalReferencePoint.x / freq) * freq * 10f);
nearestGridToCamera.y = focalReferencePoint.y;
nearestGridToCamera.z = (int)Mathf.Round(Mathf.Round(focalReferencePoint.z / freq) * freq * 10f);
cameraFrustum = new FastFrustum(mainCamera, range);
<x>5__2 = -safeRange;
goto IL_01f3;
IL_01f3:
if (<x>5__2 <= safeRange)
{
cameraFrustum.PrepX((float)<x>5__2 / 10f);
<z>5__3 = -safeRange;
goto IL_01c9;
}
isVisualizationRunning = false;
return false;
IL_01c9:
if (<z>5__3 <= safeRange)
{
cameraFrustum.PrepXZ((float)<z>5__3 / 10f);
try
{
<>4__this.CheckAndPlaceBallsInVerticalRay(nearestGridToCamera.x + <x>5__2, nearestGridToCamera.y, nearestGridToCamera.z + <z>5__3, onlyInFrustum: false);
}
catch (Exception ex)
{
<e>5__4 = ex;
Logger.LogError((object)<e>5__4);
}
if (<totalCalls>5__1 >= maximumRaysPerFrame)
{
<totalCalls>5__1 = 0;
<>2__current = null;
<>1__state = 1;
return true;
}
goto IL_01b6;
}
<x>5__2 += safeFreq;
goto IL_01f3;
IL_01b6:
<z>5__3 += safeFreq;
goto IL_01c9;
}
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 <SortWithYield>d__70 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public List<Vector3> list;
public Vector3 cameraPosition;
public int chunkSize;
public Plugin <>4__this;
private <>c__DisplayClass70_0 <>8__1;
private int <n>5__2;
private int <totalIterations>5__3;
private Comparison<Vector3> <compare>5__4;
private int <i>5__5;
private int <end>5__6;
private List<Vector3> <chunk>5__7;
private int <j>5__8;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SortWithYield>d__70(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<compare>5__4 = null;
<chunk>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0034: 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_00f8: 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_013f;
}
<>1__state = -1;
<>8__1 = new <>c__DisplayClass70_0();
<>8__1.cameraPosition = cameraPosition;
<n>5__2 = list.Count;
<totalIterations>5__3 = 0;
<compare>5__4 = delegate(Vector3 a, Vector3 b)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = a - <>8__1.cameraPosition;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
val = b - <>8__1.cameraPosition;
float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
return sqrMagnitude.CompareTo(sqrMagnitude2);
};
<i>5__5 = 0;
goto IL_0185;
IL_0185:
if (<i>5__5 < <n>5__2)
{
<end>5__6 = Mathf.Min(<i>5__5 + chunkSize, <n>5__2);
<chunk>5__7 = list.GetRange(<i>5__5, <end>5__6 - <i>5__5);
<chunk>5__7.Sort(<compare>5__4);
<j>5__8 = 0;
goto IL_0150;
}
return false;
IL_0150:
if (<j>5__8 < <chunk>5__7.Count)
{
list[<i>5__5 + <j>5__8] = <chunk>5__7[<j>5__8];
<totalIterations>5__3++;
if (<totalIterations>5__3 % maximumRaysPerFrame == 0)
{
<>2__current = null;
<>1__state = 1;
return true;
}
goto IL_013f;
}
<chunk>5__7 = null;
<i>5__5 += chunkSize;
goto IL_0185;
IL_013f:
<j>5__8++;
goto IL_0150;
}
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 Camera mainCamera;
internal static Vector3 focalReferencePoint;
internal static FastFrustum cameraFrustum;
internal static bool activated = false;
private static Vector3 scale = new Vector3(0.2f, 0.2f, 0.2f);
private static List<Matrix4x4[]> standableMatrices = new List<Matrix4x4[]>();
private static List<PositionKey[]> linkedStandableMatrices = new List<PositionKey[]>();
private static List<Matrix4x4[]> nonStandableMatrices = new List<Matrix4x4[]>();
private static List<PositionKey[]> linkedNonStandableMatrices = new List<PositionKey[]>();
private static (int, int) nextFreeStandableMatrixIndex = (0, 0);
private static (int, int) nextFreeNonStandableMatrixIndex = (0, 0);
private static int cullingLayer = 0;
private static RenderParams standableRP;
private static RenderParams nonStandableRP;
internal static Material standableMaterial;
internal static Material nonStandableMaterial;
internal static float alpha = 0.25f;
internal static float baseAlpha = 0.25f;
internal static bool continuousPaused = false;
internal static bool continuousPauseToggleQueued = false;
private static readonly Dictionary<(int, int), PositionYList> positionCache = new Dictionary<(int, int), PositionYList>();
private static readonly RaycastHit[] _terrainHitBuffer = (RaycastHit[])(object)new RaycastHit[1000];
private static Mesh ballMesh;
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 ConfigEntry<float> configScalePercent;
private ConfigEntry<float> configAlpha;
private ConfigEntry<float> configRange;
private ConfigEntry<float> configXZFreq;
private ConfigEntry<int> configMaximumPointsPerFrame;
private ConfigEntry<bool> configDetectConcave;
private static SafeXZ nearestGridToCamera;
private static float freq;
private static int safeFreq;
private static float range;
private static int safeRange;
private static int maximumRaysPerFrame;
private static bool detectConcave;
private Color LastStandableColor = Color.white;
private Color LastNonStandableColor = Color.red;
private static float scalePercent = 1f;
private static bool isVisualizationRunning = false;
private static string additionalDebugInfo = "";
private Color standable;
private Color NonStandable;
private static int totalCalls = 0;
private static int highestCount = 0;
private static int highestBallCount = 0;
private int overallTotalCallsLastRender = 0;
private void Awake()
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Expected O, but got Unknown
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Expected O, but got Unknown
//IL_044e: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_0463: Unknown result type (might be due to invalid IL or missing references)
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_0491: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Expected O, but got Unknown
//IL_0496: Expected O, but got Unknown
//IL_0535: Unknown result type (might be due to invalid IL or missing references)
//IL_053a: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Unknown result type (might be due to invalid IL or missing references)
//IL_0559: Unknown result type (might be due to invalid IL or missing references)
//IL_058a: Unknown result type (might be due to invalid IL or missing references)
//IL_058c: Unknown result type (might be due to invalid IL or missing references)
//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
configMode = ((BaseUnityPlugin)this).Config.Bind<Mode>("General", "Activation Mode", Mode.Continuous, "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.\r\nContinuous: Always active. The indicator will remain visible, and updates as you move. Implemented by cjmanca on GitHub.");
configStandableBallColor = ((BaseUnityPlugin)this).Config.Bind<StandableColor>("Appearance", "Standable ground Color", StandableColor.White, "Change the ball color of standable ground.");
configNonStandableBallColor = ((BaseUnityPlugin)this).Config.Bind<NonStandableColor>("Appearance", "Non-standable ground Color", NonStandableColor.Red, "Change the ball color of non-standable ground.");
configAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Transparency Percent", 100f, new ConfigDescription("How transparent the balls are.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
configScalePercent = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Scale Percent", 100f, new ConfigDescription("How large the standing point indicators are.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>()));
configRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Detection Range", 10f, new ConfigDescription("How far from the camera the balls are placed. Increasing will affect performance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), Array.Empty<object>()));
configXZFreq = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Horizontal grid spacing", 0.5f, new ConfigDescription("How far apart the balls are placed horizontally. Reducing will affect performance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
configMaximumPointsPerFrame = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Maximum points per frame", 100, new ConfigDescription("The maximum number of raycasts to do per frame to check for standing spots. Higher values reduce fps but make the visualization appear faster.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 20000), Array.Empty<object>()));
configDetectConcave = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Detect Concave Points", true, "Detecting standing spots on concave meshes takes many extra raycasts. Disabling won't show these standing spots, but will improve performance. Remember to increase 'Maximum points per frame' by about 10x if you enable this (1000+ at least - New default assumes this is enabled).");
configActivationKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Activation Key", (KeyCode)102, (ConfigDescription)null);
configDebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Debug Mode", false, "Show debug information");
string directoryName = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
string[] array = new string[8]
{
Path.Combine(directoryName, "Foothold.assetbundle"),
Path.Combine(directoryName, "Foothold.bundle"),
Path.Combine(directoryName, "Foothold.unity3d"),
Path.Combine(directoryName, "assets", "Foothold.assetbundle"),
Path.Combine(directoryName, "assets", "Foothold.bundle"),
Path.Combine(directoryName, "assets", "Foothold.unity3d"),
Path.Combine(directoryName, "Foothold"),
Path.Combine(directoryName, "assets", "Foothold")
};
AssetBundle val = null;
string text = null;
string[] array2 = array;
foreach (string text2 in array2)
{
if (File.Exists(text2))
{
text = text2;
break;
}
}
if (text == null)
{
Logger.LogError((object)"Failed to load AssetBundle (not found)");
return;
}
val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)"Failed to load AssetBundle (failed to load from file)");
return;
}
Material val2 = val.LoadAsset<Material>("Foothold");
if ((Object)(object)val2 == (Object)null)
{
Logger.LogError((object)"Failed to load instanced material from bundle");
return;
}
Logger.LogInfo((object)("Loaded instanced material: " + ((Object)val2).name));
ballMesh = Resources.GetBuiltinResource<Mesh>("Sphere.fbx");
Logger.LogInfo((object)$"mesh = {ballMesh}");
Material val3 = new Material(val2);
val3.SetFloat("_Surface", 1f);
val3.SetFloat("_Blend", 0f);
val3.SetInt("_IgnoreProjector", 1);
val3.SetInt("_ReceiveShadows", 0);
val3.SetInt("_ZWrite", 0);
val3.SetInt("_SrcBlend", 5);
val3.SetInt("_DstBlend", 10);
val3.DisableKeyword("_ALPHATEST_ON");
val3.EnableKeyword("_ALPHABLEND_ON");
val3.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
val3.renderQueue = 3000;
val3.enableInstancing = true;
Color white = Color.white;
white.a = baseAlpha;
val3.color = white;
val3.SetColor("_BaseColor", white);
val3.enableInstancing = true;
standableMaterial = val3;
Material val4 = new Material(val2);
val3 = val4;
val3 = val4;
val3.SetFloat("_Surface", 1f);
val3.SetFloat("_Blend", 0f);
val3.SetInt("_IgnoreProjector", 1);
val3.SetInt("_ReceiveShadows", 0);
val3.SetInt("_ZWrite", 0);
val3.SetInt("_SrcBlend", 5);
val3.SetInt("_DstBlend", 10);
val3.DisableKeyword("_ALPHATEST_ON");
val3.EnableKeyword("_ALPHABLEND_ON");
val3.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
val3.renderQueue = 3000;
white = Color.magenta;
white.a = baseAlpha;
val3.color = white;
val3.SetColor("_BaseColor", white);
val3.enableInstancing = true;
nonStandableMaterial = val3;
RenderParams val5 = default(RenderParams);
((RenderParams)(ref val5))..ctor(standableMaterial);
((RenderParams)(ref val5)).layer = cullingLayer;
standableRP = val5;
((RenderParams)(ref val5))..ctor(nonStandableMaterial);
((RenderParams)(ref val5)).layer = cullingLayer;
nonStandableRP = val5;
SceneManager.sceneLoaded += OnSceneLoaded;
configStandableBallColor.SettingChanged += Color_SettingChanged;
configNonStandableBallColor.SettingChanged += Color_SettingChanged;
configMode.SettingChanged += ConfigMode_SettingChanged;
configRange.SettingChanged += Color_SettingChanged;
configXZFreq.SettingChanged += Color_SettingChanged;
configMaximumPointsPerFrame.SettingChanged += Color_SettingChanged;
configScalePercent.SettingChanged += Color_SettingChanged;
configDetectConcave.SettingChanged += Color_SettingChanged;
configAlpha.SettingChanged += Color_SettingChanged;
standableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedStandableMatrices.Add(new PositionKey[500]);
nonStandableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedNonStandableMatrices.Add(new PositionKey[500]);
Logger.LogInfo((object)"Loaded Foothold? version 1.6.0");
}
private void ConfigMode_SettingChanged(object sender, EventArgs e)
{
//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_003d: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (configMode.Value != Mode.FadeAway)
{
Color color = standableMaterial.GetColor("_BaseColor");
color.a = baseAlpha;
standableMaterial.SetColor("_BaseColor", color);
((RenderParams)(ref standableRP)).material = standableMaterial;
color = nonStandableMaterial.GetColor("_BaseColor");
color.a = baseAlpha;
nonStandableMaterial.SetColor("_BaseColor", color);
((RenderParams)(ref nonStandableRP)).material = nonStandableMaterial;
}
}
private void Color_SettingChanged(object sender, EventArgs e)
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: 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"))
{
Logger.LogInfo((object)"Color_SettingChanged called");
ReturnAllBallsToPool();
freq = configXZFreq.Value;
safeFreq = (int)Mathf.Round(freq * 10f);
range = Mathf.Round(configRange.Value / freq) * freq;
safeRange = (int)Mathf.Round(range * 10f);
maximumRaysPerFrame = configMaximumPointsPerFrame.Value * 10;
scalePercent = configScalePercent.Value / 100f;
scale = Vector3.one / 10f * scalePercent;
baseAlpha = configAlpha.Value / 100f;
detectConcave = configDetectConcave.Value;
if (configStandableBallColor.Value == StandableColor.Green)
{
standable = Color.green;
}
else
{
standable = Color.white;
}
if (configNonStandableBallColor.Value == NonStandableColor.Magenta)
{
NonStandable = Color.magenta;
}
else
{
NonStandable = Color.red;
}
if (LastStandableColor != standable || LastNonStandableColor != NonStandable)
{
ReturnAllBallsToPool();
nearestGridToCamera.x = 0;
nearestGridToCamera.y = 0f;
nearestGridToCamera.z = 0;
}
if (LastStandableColor != standable)
{
Color val = standable;
val.a = baseAlpha;
standableMaterial.color = val;
standableMaterial.SetColor("_BaseColor", val);
((RenderParams)(ref standableRP)).material = standableMaterial;
LastStandableColor = standable;
}
if (LastNonStandableColor != NonStandable)
{
Color nonStandable = NonStandable;
nonStandable.a = baseAlpha;
nonStandableMaterial.color = nonStandable;
nonStandableMaterial.SetColor("_BaseColor", nonStandable);
((RenderParams)(ref nonStandableRP)).material = nonStandableMaterial;
LastNonStandableColor = NonStandable;
}
}
}
private void OnGUI()
{
if (!configDebugMode.Value)
{
return;
}
int num = 0;
int num2 = 0;
num2 = nextFreeStandableMatrixIndex.Item1 * 500 + nextFreeStandableMatrixIndex.Item2;
num2 += nextFreeNonStandableMatrixIndex.Item1 * 500 + nextFreeNonStandableMatrixIndex.Item2;
foreach (PositionYList value in positionCache.Values)
{
num += value.list.Count;
}
if (num > highestCount)
{
highestCount = num;
}
if (num2 > highestBallCount)
{
highestBallCount = num2;
}
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("Camera Position: " + ((Vector3)(ref focalReferencePoint)).ToString("F2"), Array.Empty<GUILayoutOption>());
GUILayout.Label("balls: " + num2, Array.Empty<GUILayoutOption>());
GUILayout.Label("highestBallCount: " + highestBallCount, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (x/z count): " + positionCache.Count, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (total y count): " + num, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (highest total y count): " + highestCount, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (allocations): " + PositionKey.totalAllocations, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (totalInUse): " + PositionKey.totalInUse, Array.Empty<GUILayoutOption>());
GUILayout.Label("positionCache (leaks): " + (PositionKey.totalAllocations - (PositionKey.PoolCount + num)), Array.Empty<GUILayoutOption>());
GUILayout.Label("Total Raycasts Last Render: " + overallTotalCallsLastRender, Array.Empty<GUILayoutOption>());
GUILayout.Label("alpha: " + alpha, Array.Empty<GUILayoutOption>());
GUILayout.Label("isVisualizationRunning: " + isVisualizationRunning, Array.Empty<GUILayoutOption>());
GUILayout.Label("additionalDebugInfo: " + additionalDebugInfo, Array.Empty<GUILayoutOption>());
}
private void OnDestroy()
{
foreach (KeyValuePair<(int, int), PositionYList> item in positionCache.ToList())
{
RemoveBallsInVerticalRay(item.Key.Item1, item.Key.Item2);
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode _)
{
//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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: 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_01d1: 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_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: 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_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: 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_0277: 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_029a: Unknown result type (might be due to invalid IL or missing references)
currentScene = scene;
ReturnAllBallsToPool();
positionCache.Clear();
standableMatrices.Clear();
linkedStandableMatrices.Clear();
nonStandableMatrices.Clear();
linkedNonStandableMatrices.Clear();
standableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedStandableMatrices.Add(new PositionKey[500]);
nonStandableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedNonStandableMatrices.Add(new PositionKey[500]);
freq = configXZFreq.Value;
safeFreq = (int)Mathf.Round(freq * 10f);
range = Mathf.Round(configRange.Value / freq) * freq;
safeRange = (int)Mathf.Round(range * 10f);
maximumRaysPerFrame = configMaximumPointsPerFrame.Value * 10;
scalePercent = configScalePercent.Value / 100f;
scale = Vector3.one / 10f * scalePercent;
baseAlpha = configAlpha.Value / 100f;
detectConcave = configDetectConcave.Value;
nearestGridToCamera.x = 0;
nearestGridToCamera.y = 0f;
nearestGridToCamera.z = 0;
if (((Scene)(ref currentScene)).name.StartsWith("Level_") || ((Scene)(ref currentScene)).name.StartsWith("Airport"))
{
if (configStandableBallColor.Value == StandableColor.Green)
{
standable = Color.green;
}
else
{
standable = Color.white;
}
if (configNonStandableBallColor.Value == NonStandableColor.Magenta)
{
NonStandable = Color.magenta;
}
else
{
NonStandable = Color.red;
}
LastStandableColor = standable;
LastNonStandableColor = NonStandable;
Color val = standable;
val.a = baseAlpha;
standableMaterial.color = val;
standableMaterial.SetColor("_BaseColor", val);
((RenderParams)(ref standableRP)).material = standableMaterial;
val = NonStandable;
val.a = baseAlpha;
nonStandableMaterial.color = val;
nonStandableMaterial.SetColor("_BaseColor", val);
((RenderParams)(ref nonStandableRP)).material = nonStandableMaterial;
}
}
private void Update()
{
//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_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)
if (!((Scene)(ref currentScene)).name.StartsWith("Level_") && !((Scene)(ref currentScene)).name.StartsWith("Airport"))
{
return;
}
if ((Object)(object)mainCamera == (Object)null)
{
MainCamera obj = Object.FindFirstObjectByType<MainCamera>();
mainCamera = ((obj != null) ? ((Component)obj).GetComponent<Camera>() : null);
}
else
{
if ((Object)(object)Camera.main == (Object)null)
{
return;
}
((RenderParams)(ref standableRP)).camera = Camera.main;
((RenderParams)(ref nonStandableRP)).camera = mainCamera;
if (!isVisualizationRunning)
{
Character specCharacter = MainCameraMovement.specCharacter;
if (MainCameraMovement.IsSpectating && (Object)(object)specCharacter != (Object)null)
{
focalReferencePoint = ((Component)specCharacter.refs.ragdoll.partDict[(BodypartType)4]).transform.position;
}
else
{
focalReferencePoint = ((Component)Character.localCharacter.refs.ragdoll.partDict[(BodypartType)4]).transform.position;
}
}
CheckHotkeys();
if (configMode.Value == Mode.FadeAway)
{
SetBallAlphas();
}
if (configMode.Value == Mode.Continuous)
{
if (continuousPauseToggleQueued && !isVisualizationRunning)
{
continuousPauseToggleQueued = false;
continuousPaused = !continuousPaused;
if (GlobalEvents.OnGemActivated != null)
{
GlobalEvents.OnGemActivated(!continuousPaused);
}
}
if (!isVisualizationRunning && !continuousPaused)
{
isVisualizationRunning = true;
((MonoBehaviour)this).StartCoroutine(RenderChangedVisualizationCoroutine());
}
}
try
{
for (int i = 0; i < standableMatrices.Count; i++)
{
if (standableMatrices[i] != null && standableMatrices[i].Length != 0)
{
if (i > nextFreeStandableMatrixIndex.Item1 || (i == nextFreeStandableMatrixIndex.Item1 && nextFreeStandableMatrixIndex.Item2 == 0))
{
break;
}
Graphics.RenderMeshInstanced<Matrix4x4>(ref standableRP, ballMesh, 0, standableMatrices[i], -1, 0);
}
}
for (int j = 0; j < nonStandableMatrices.Count; j++)
{
if (nonStandableMatrices[j] != null && nonStandableMatrices[j].Length != 0)
{
if (j > nextFreeNonStandableMatrixIndex.Item1 || (j == nextFreeNonStandableMatrixIndex.Item1 && nextFreeNonStandableMatrixIndex.Item2 == 0))
{
break;
}
Graphics.RenderMeshInstanced<Matrix4x4>(ref nonStandableRP, ballMesh, 0, nonStandableMatrices[j], -1, 0);
}
}
}
catch (Exception ex)
{
Logger.LogError((object)ex);
}
}
}
private void CheckHotkeys()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (!Input.GetKeyDown(configActivationKey.Value))
{
return;
}
if (configMode.Value == Mode.Continuous)
{
continuousPauseToggleQueued = true;
}
else
{
if (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
{
ReturnAllBallsToPool();
}
}
}
private void ReturnAllBallsToPool()
{
foreach (KeyValuePair<(int, int), PositionYList> item in positionCache.ToList())
{
RemoveBallsInVerticalRay(item.Key.Item1, item.Key.Item2);
}
}
private static void ReturnBallToPool(PositionKey ball)
{
//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_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: 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)
//IL_0137: 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)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: 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)
if (!ball.ballVisible || ball.ballMatrixIndex.Item1 < 0 || ball.ballMatrixIndex.Item2 < 0)
{
ball.ballVisible = false;
ball.ballMatrixIndex.Item1 = -1;
ball.ballMatrixIndex.Item2 = -1;
return;
}
Matrix4x4 zero = Matrix4x4.zero;
PositionKey positionKey = null;
if (ball.standable)
{
nextFreeStandableMatrixIndex.Item2--;
if (nextFreeStandableMatrixIndex.Item2 < 0)
{
nextFreeStandableMatrixIndex.Item1--;
nextFreeStandableMatrixIndex.Item2 = 499;
}
if (nextFreeStandableMatrixIndex.Item1 >= 0 && nextFreeStandableMatrixIndex.Item2 >= 0)
{
zero = standableMatrices[nextFreeStandableMatrixIndex.Item1][nextFreeStandableMatrixIndex.Item2];
positionKey = linkedStandableMatrices[nextFreeStandableMatrixIndex.Item1][nextFreeStandableMatrixIndex.Item2];
standableMatrices[ball.ballMatrixIndex.Item1][ball.ballMatrixIndex.Item2] = zero;
linkedStandableMatrices[ball.ballMatrixIndex.Item1][ball.ballMatrixIndex.Item2] = positionKey;
positionKey.ballMatrixIndex = (ball.ballMatrixIndex.Item1, ball.ballMatrixIndex.Item2);
}
if (nextFreeStandableMatrixIndex.Item1 < 0)
{
nextFreeStandableMatrixIndex.Item1 = 0;
nextFreeStandableMatrixIndex.Item2 = 0;
standableMatrices[nextFreeStandableMatrixIndex.Item1][nextFreeStandableMatrixIndex.Item2] = Matrix4x4.zero;
}
}
else
{
nextFreeNonStandableMatrixIndex.Item2--;
if (nextFreeNonStandableMatrixIndex.Item2 < 0)
{
nextFreeNonStandableMatrixIndex.Item1--;
nextFreeNonStandableMatrixIndex.Item2 = 499;
}
if (nextFreeNonStandableMatrixIndex.Item1 >= 0 && nextFreeNonStandableMatrixIndex.Item2 >= 0)
{
zero = nonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2];
positionKey = linkedNonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2];
nonStandableMatrices[ball.ballMatrixIndex.Item1][ball.ballMatrixIndex.Item2] = zero;
linkedNonStandableMatrices[ball.ballMatrixIndex.Item1][ball.ballMatrixIndex.Item2] = positionKey;
positionKey.ballMatrixIndex = (ball.ballMatrixIndex.Item1, ball.ballMatrixIndex.Item2);
nonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2] = Matrix4x4.zero;
}
if (nextFreeNonStandableMatrixIndex.Item1 < 0)
{
nextFreeNonStandableMatrixIndex.Item1 = 0;
nextFreeNonStandableMatrixIndex.Item2 = 0;
nonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2] = Matrix4x4.zero;
}
}
ball.ballVisible = false;
ball.ballMatrixIndex.Item1 = -1;
ball.ballMatrixIndex.Item2 = -1;
}
private void PlaceBall(PositionKey positionKey)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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 (positionKey.ballVisible)
{
return;
}
Matrix4x4 val = (positionKey.matrix = Matrix4x4.TRS(positionKey.position, Quaternion.identity, scale));
positionKey.ballVisible = true;
if (positionKey.standable)
{
standableMatrices[nextFreeStandableMatrixIndex.Item1][nextFreeStandableMatrixIndex.Item2] = val;
linkedStandableMatrices[nextFreeStandableMatrixIndex.Item1][nextFreeStandableMatrixIndex.Item2] = positionKey;
positionKey.ballMatrixIndex = (nextFreeStandableMatrixIndex.Item1, nextFreeStandableMatrixIndex.Item2);
nextFreeStandableMatrixIndex.Item2++;
if (nextFreeStandableMatrixIndex.Item2 >= 500)
{
nextFreeStandableMatrixIndex.Item1++;
nextFreeStandableMatrixIndex.Item2 = 0;
if (standableMatrices.Count <= nextFreeStandableMatrixIndex.Item1)
{
standableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedStandableMatrices.Add(new PositionKey[500]);
}
}
return;
}
nonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2] = val;
linkedNonStandableMatrices[nextFreeNonStandableMatrixIndex.Item1][nextFreeNonStandableMatrixIndex.Item2] = positionKey;
positionKey.ballMatrixIndex = (nextFreeNonStandableMatrixIndex.Item1, nextFreeNonStandableMatrixIndex.Item2);
nextFreeNonStandableMatrixIndex.Item2++;
if (nextFreeNonStandableMatrixIndex.Item2 >= 500)
{
nextFreeNonStandableMatrixIndex.Item1++;
nextFreeNonStandableMatrixIndex.Item2 = 0;
if (nonStandableMatrices.Count <= nextFreeNonStandableMatrixIndex.Item1)
{
nonStandableMatrices.Add((Matrix4x4[])(object)new Matrix4x4[500]);
linkedNonStandableMatrices.Add(new PositionKey[500]);
}
}
}
[IteratorStateMachine(typeof(<RenderVisualizationCoroutine>d__66))]
private IEnumerator RenderVisualizationCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RenderVisualizationCoroutine>d__66(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<RenderChangedVisualizationCoroutine>d__68))]
private IEnumerator RenderChangedVisualizationCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RenderChangedVisualizationCoroutine>d__68(0)
{
<>4__this = this
};
}
public static List<Rect> SubtractRect(Rect original, Rect cut)
{
//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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
List<Rect> list = new List<Rect>();
float num = Mathf.Max(((Rect)(ref original)).xMin, ((Rect)(ref cut)).xMin);
float num2 = Mathf.Min(((Rect)(ref original)).xMax, ((Rect)(ref cut)).xMax);
float num3 = Mathf.Max(((Rect)(ref original)).yMin, ((Rect)(ref cut)).yMin);
float num4 = Mathf.Min(((Rect)(ref original)).yMax, ((Rect)(ref cut)).yMax);
if (num2 <= num || num4 <= num3)
{
list.Add(original);
return list;
}
Rect val = Rect.MinMaxRect(num, num3, num2, num4);
if (((Rect)(ref val)).yMin > ((Rect)(ref original)).yMin)
{
Rect item = default(Rect);
((Rect)(ref item))..ctor(((Rect)(ref original)).xMin, ((Rect)(ref original)).yMin, ((Rect)(ref original)).width, ((Rect)(ref val)).yMin - ((Rect)(ref original)).yMin);
list.Add(item);
}
if (((Rect)(ref val)).yMax < ((Rect)(ref original)).yMax)
{
Rect item2 = default(Rect);
((Rect)(ref item2))..ctor(((Rect)(ref original)).xMin, ((Rect)(ref val)).yMax, ((Rect)(ref original)).width, ((Rect)(ref original)).yMax - ((Rect)(ref val)).yMax);
list.Add(item2);
}
if (((Rect)(ref val)).xMin > ((Rect)(ref original)).xMin)
{
Rect item3 = default(Rect);
((Rect)(ref item3))..ctor(((Rect)(ref original)).xMin, ((Rect)(ref val)).yMin, ((Rect)(ref val)).xMin - ((Rect)(ref original)).xMin, ((Rect)(ref val)).height);
list.Add(item3);
}
if (((Rect)(ref val)).xMax < ((Rect)(ref original)).xMax)
{
Rect item4 = default(Rect);
((Rect)(ref item4))..ctor(((Rect)(ref val)).xMax, ((Rect)(ref val)).yMin, ((Rect)(ref original)).xMax - ((Rect)(ref val)).xMax, ((Rect)(ref val)).height);
list.Add(item4);
}
return list;
}
[IteratorStateMachine(typeof(<SortWithYield>d__70))]
private IEnumerator SortWithYield(List<Vector3> list, Vector3 cameraPosition, int chunkSize)
{
//IL_0015: 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)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SortWithYield>d__70(0)
{
<>4__this = this,
list = list,
cameraPosition = cameraPosition,
chunkSize = chunkSize
};
}
private void CheckAndPlaceBallsInVerticalRay(int x, float y, int z, bool onlyInFrustum)
{
PositionYList yDict = CheckCacheMiss(x, y, z);
PlaceBallsInVerticalRay(yDict, y, onlyInFrustum);
}
private void PlaceBallsInVerticalRay(int x, float y, int z, bool onlyInFrustum)
{
if (positionCache.TryGetValue((x, z), out var value))
{
PlaceBallsInVerticalRay(value, y, onlyInFrustum);
}
}
private void PlaceBallsInVerticalRay(PositionYList yDict, float y, bool onlyInFrustum)
{
foreach (PositionKey value in yDict.list.Values)
{
if (value != null)
{
bool flag;
if (onlyInFrustum)
{
flag = cameraFrustum.PreppedYContains(value.position.y);
}
else
{
float num = Mathf.Abs(y - value.position.y);
flag = num <= range;
}
if (!value.ballVisible && flag)
{
PlaceBall(value);
}
else if (value.ballVisible && !flag)
{
ReturnBallToPool(value);
}
}
}
}
private void RemoveBallsInVerticalRay(int xIndex, int zIndex, bool expireCache = true)
{
if (!positionCache.TryGetValue((xIndex, zIndex), out var value))
{
return;
}
if (expireCache)
{
positionCache.Remove((xIndex, zIndex));
value.ReturnToPool();
return;
}
foreach (PositionKey value2 in value.list.Values)
{
if (value2 != null)
{
ReturnBallToPool(value2);
}
}
}
private void DoRaycastRecursive(PositionYList pCache, Vector3 from, Vector3 to)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: 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_01ed: 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_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: 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_029e: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
Vector3[] array = (Vector3[])(object)new Vector3[100];
int num = 0;
int num2 = Physics.RaycastNonAlloc(from, Vector3.down, _terrainHitBuffer, Vector3.Distance(from, to), LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)), (QueryTriggerInteraction)0);
for (int i = 0; i < num2; i++)
{
totalCalls++;
RaycastHit val = _terrainHitBuffer[i];
if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).transform) || ((RaycastHit)(ref val)).point.y < 0.5f)
{
continue;
}
CollisionModifier component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<CollisionModifier>();
if (Object.op_Implicit((Object)(object)component) && !component.standable)
{
continue;
}
if (detectConcave && num < 100)
{
Collider collider = ((RaycastHit)(ref val)).collider;
MeshCollider val2 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null);
if (Object.op_Implicit((Object)(object)val2) && !val2.convex)
{
array[num] = ((RaycastHit)(ref val)).point;
num++;
}
}
if (!pCache.list.ContainsKey((int)Mathf.Round(((RaycastHit)(ref val)).point.y * 10f)))
{
float num3 = Vector3.Angle(Vector3.up, ((RaycastHit)(ref val)).normal);
if (!(num3 < 30f))
{
PositionKey @new = PositionKey.GetNew(((RaycastHit)(ref val)).point.x, ((RaycastHit)(ref val)).point.y, ((RaycastHit)(ref val)).point.z, num3 < 50f);
pCache.list.Add((int)Mathf.Round(((RaycastHit)(ref val)).point.y * 10f), @new);
}
}
}
if (!detectConcave)
{
return;
}
for (int j = 0; j < num; j++)
{
Vector3 val3 = array[j];
float y = to.y;
PositionKey positionKey = null;
foreach (PositionKey value in pCache.list.Values)
{
if (value != null && value.position.y > y && value.position.y < val3.y)
{
y = value.position.y;
positionKey = value;
}
}
if (positionKey != null)
{
Vector3 val4 = val3 + Vector3.down * 0.5f;
Vector3 val5 = positionKey.position + Vector3.up * 0.1f;
if (!(val5.y >= val4.y))
{
DoRaycastRecursive(pCache, val4, val5);
}
}
}
}
private PositionYList CheckCacheMiss(int x, float y, int z)
{
//IL_0093: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
PositionYList value = null;
if (!positionCache.TryGetValue((x, z), out value) || value == null || value.rayTop < y + range || value.rayBottom > y - range)
{
if (value != null)
{
positionCache.Remove((x, z));
value.ReturnToPool();
}
value = PositionYList.GetNew();
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor((float)x / 10f, y + range * 1.5f, (float)z / 10f);
Vector3 val2 = val + Vector3.down * range * 3f;
value.rayTop = val.y;
value.rayBottom = val2.y;
DoRaycastRecursive(value, val, val2);
positionCache[(x, z)] = value;
}
return value;
}
private void SetBallAlphas()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
if (configMode.Value == Mode.FadeAway && !((double)(Time.time - lastAlphaChangeTime) < 0.05))
{
lastAlphaChangeTime = Time.time;
alpha = Mathf.Lerp(baseAlpha, 0f, Mathf.Clamp01((Time.time - (lastScanTime + 3f)) / 3f));
Color color = standableMaterial.GetColor("_BaseColor");
color.a = alpha;
standableMaterial.SetColor("_BaseColor", color);
((RenderParams)(ref standableRP)).material = standableMaterial;
color = nonStandableMaterial.GetColor("_BaseColor");
color.a = alpha;
nonStandableMaterial.SetColor("_BaseColor", color);
((RenderParams)(ref nonStandableRP)).material = nonStandableMaterial;
if (alpha <= 0f)
{
ReturnAllBallsToPool();
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Foothold";
public const string PLUGIN_NAME = "Foothold?";
public const string PLUGIN_VERSION = "1.6.0";
}
}