using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
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("Rombusz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Client-side endless airport moving walkways for PEAK.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("EndlessEscalator")]
[assembly: AssemblyTitle("EndlessEscalator")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[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 EndlessEscalator
{
internal sealed class LocalTransfer
{
internal const float Speed = 1.4f;
private readonly List<Rigidbody> bodies = new List<Rigidbody>(24);
private readonly HashSet<Rigidbody> bodySet = new HashSet<Rigidbody>();
private readonly List<Joint> joints = new List<Joint>(24);
internal static bool CanRide(Character c, bool allowStep = false)
{
//IL_01f0: 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)
if (!Object.op_Implicit((Object)(object)c) || (Object)(object)c != (Object)(object)Character.localCharacter || !Object.op_Implicit((Object)(object)((MonoBehaviourPun)c).photonView) || !((MonoBehaviourPun)c).photonView.IsMine || (Object)(object)Character.observedCharacter != (Object)(object)c || c.refs == null || !Object.op_Implicit((Object)(object)c.refs.ragdoll) || !Object.op_Implicit((Object)(object)c.refs.hip) || !Object.op_Implicit((Object)(object)c.refs.hip.Rig) || c.refs.ragdoll.partList == null || c.refs.ragdoll.partList.Count == 0 || !Object.op_Implicit((Object)(object)c.data) || !Object.op_Implicit((Object)(object)c.input) || c.warping)
{
return false;
}
CharacterData data = c.data;
if (!data.dead && !data.passedOut && !data.fullyPassedOut && !data.shouldPetrify && !data.isKinecmatic && !data.isJumping && !data.isClimbingAnything && !Object.op_Implicit((Object)(object)data.currentClimbHandle) && !data.isCarried && !Object.op_Implicit((Object)(object)data.carrier) && !Object.op_Implicit((Object)(object)data.carriedPlayer) && !Object.op_Implicit((Object)(object)data.grabJoint) && data.currentRagdollControll >= 0.8f && (data.isGrounded || data.sinceGrounded < (allowStep ? 0.5f : 0.12f)) && (!allowStep || data.avarageVelocity.y > -2f) && !c.input.jumpWasPressed && !c.input.jumpIsPressed && ((Vector2)(ref c.input.movementInput)).sqrMagnitude <= 0.01f && LaneFrame.Finite(data.avarageVelocity))
{
return LaneFrame.Finite(data.avarageLastFrameVelocity);
}
return false;
}
internal bool TryDrive(Character c, Vector3 desiredVelocity, bool allowStep = false)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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_0175: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
if (!CanRide(c, allowStep) || !LaneFrame.Finite(desiredVelocity))
{
return false;
}
bodies.Clear();
bodySet.Clear();
Vector3 val = Vector3.zero;
foreach (Bodypart part in c.refs.ragdoll.partList)
{
if (!Object.op_Implicit((Object)(object)part) || !LaneFrame.Finite(part.forcesToAdd) || !Capture(part.Rig))
{
return false;
}
val += part.Rig.linearVelocity;
}
val /= (float)c.refs.ragdoll.partList.Count;
Item currentItem = c.data.currentItem;
if (Object.op_Implicit((Object)(object)currentItem) && (!Object.op_Implicit((Object)(object)((MonoBehaviourPun)currentItem).photonView) || !((MonoBehaviourPun)currentItem).photonView.IsMine || !Capture(currentItem.rig)))
{
return false;
}
if (!InternalJoints((Component)(object)c) || (Object.op_Implicit((Object)(object)currentItem) && !InternalJoints((Component)(object)currentItem)))
{
return false;
}
desiredVelocity.y = 0f;
desiredVelocity = Vector3.ClampMagnitude(desiredVelocity, 1.4f);
Vector3 val2 = desiredVelocity - new Vector3(val.x, 0f, val.z);
foreach (Rigidbody body in bodies)
{
body.linearVelocity += val2;
body.WakeUp();
}
c.data.avarageVelocity = val + val2;
return true;
}
private bool Capture(Rigidbody body)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)body) || body.isKinematic || !LaneFrame.Finite(body.linearVelocity))
{
return false;
}
if (bodySet.Add(body))
{
bodies.Add(body);
}
return true;
}
private bool InternalJoints(Component owner)
{
owner.GetComponentsInChildren<Joint>(true, joints);
foreach (Joint joint in joints)
{
if (Object.op_Implicit((Object)(object)joint) && (!Object.op_Implicit((Object)(object)joint.connectedBody) || !bodySet.Contains(joint.connectedBody)))
{
return false;
}
}
return true;
}
}
internal readonly struct LaneFrame
{
internal readonly Vector3 Center;
internal readonly Vector3 Forward;
internal readonly float HalfLength;
internal readonly float HalfWidth;
internal readonly float HalfHeight;
internal Vector3 Right => Vector3.Cross(Vector3.up, Forward);
internal LaneFrame(Vector3 center, Vector3 forward, float halfLength, float halfWidth, float halfHeight)
{
//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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
Center = center;
Forward = forward;
HalfLength = halfLength;
HalfWidth = halfWidth;
HalfHeight = halfHeight;
}
internal static bool TryCreate(Bounds bounds, Vector3 force, out LaneFrame lane)
{
//IL_0009: 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_0023: 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_0055: 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_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_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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
lane = default(LaneFrame);
if (!Finite(((Bounds)(ref bounds)).center) || !Finite(((Bounds)(ref bounds)).extents) || !Finite(force) || ((Vector3)(ref force)).sqrMagnitude < 0.01f || Math.Abs(force.y) > 0.05f * ((Vector3)(ref force)).magnitude)
{
return false;
}
Vector3 val = new Vector3(force.x, 0f, force.z);
Vector3 normalized = ((Vector3)(ref val)).normalized;
Vector3 axis = Vector3.Cross(Vector3.up, normalized);
if (Math.Max(Math.Abs(normalized.x), Math.Abs(normalized.z)) < 0.999f)
{
return false;
}
float num = Extent(((Bounds)(ref bounds)).extents, normalized);
float num2 = Extent(((Bounds)(ref bounds)).extents, axis);
if (num < 3f || num > 80f || num2 < 0.4f || num2 > 3f || num < num2 * 3f || ((Bounds)(ref bounds)).extents.y < 0.25f || ((Bounds)(ref bounds)).extents.y > 4f)
{
return false;
}
lane = new LaneFrame(((Bounds)(ref bounds)).center, normalized, num, num2, ((Bounds)(ref bounds)).extents.y);
return true;
}
internal float Along(Vector3 point)
{
//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_000d: Unknown result type (might be due to invalid IL or missing references)
return Vector3.Dot(point - Center, Forward);
}
internal bool ContainsRider(Vector3 point)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (Finite(point) && Math.Abs(Along(point)) <= HalfLength + 0.1f && Math.Abs(Vector3.Dot(point - Center, Right)) <= HalfWidth + 0.1f)
{
return Math.Abs(point.y - Center.y) <= HalfHeight;
}
return false;
}
internal static bool AreNeighbors(LaneFrame a, LaneFrame b)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Dot(a.Forward, b.Forward) > -0.999f || Math.Abs(a.Center.y - b.Center.y) > 0.4f)
{
return false;
}
Vector3 val = b.Center - a.Center;
float num = Math.Abs(Vector3.Dot(val, a.Right));
float num2 = Math.Abs(Vector3.Dot(val, a.Forward));
if (num > a.HalfWidth + b.HalfWidth && num < a.HalfWidth + b.HalfWidth + 4f && num2 < 1.5f)
{
return Math.Abs(a.HalfLength - b.HalfLength) < 1.5f;
}
return false;
}
internal static Vector3 Destination(LaneFrame target, float riderY, float inset)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
Vector3 result = target.Center + target.Forward * (0f - target.HalfLength + inset);
result.y = riderY;
return result;
}
internal static Vector3 Redirect(Vector3 velocity, Vector3 from, Vector3 to)
{
//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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_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)
float num = Vector3.Dot(velocity, from);
return velocity - from * num + to * num;
}
internal static bool Finite(Vector3 value)
{
//IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references)
if (IsFinite(value.x) && IsFinite(value.y))
{
return IsFinite(value.z);
}
return false;
}
private static bool IsFinite(float value)
{
if (!float.IsNaN(value))
{
return !float.IsInfinity(value);
}
return false;
}
private static float Extent(Vector3 e, Vector3 axis)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0025: 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)
return Math.Abs(axis.x) * e.x + Math.Abs(axis.y) * e.y + Math.Abs(axis.z) * e.z;
}
}
internal readonly struct TurnPath
{
private readonly Vector3 start;
private readonly Vector3 centered;
private readonly Vector3 arcStart;
private readonly Vector3 arcEnd;
private readonly Vector3 end;
private readonly Vector3 forward;
private readonly Vector3 across;
private readonly float centeringLength;
private readonly float outboundLength;
private readonly float radius;
private readonly float arcLength;
private readonly float inboundLength;
internal float Length => centeringLength + outboundLength + arcLength + inboundLength;
internal TurnPath(LaneFrame source, LaneFrame target, Bounds casing, Vector3 start)
{
//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_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_003e: 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_0053: 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_0072: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00fb: 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_0108: 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_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0137: 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_0148: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
this.start = start;
forward = source.Forward;
Vector3 val = target.Center - source.Center;
val -= forward * Vector3.Dot(val, forward);
val.y = 0f;
across = ((Vector3)(ref val)).normalized;
radius = ((Vector3)(ref val)).magnitude * 0.5f;
float num = Vector3.Dot(((Bounds)(ref casing)).center - source.Center, forward) + Math.Abs(forward.x) * ((Bounds)(ref casing)).extents.x + Math.Abs(forward.z) * ((Bounds)(ref casing)).extents.z;
centered = source.Center + forward * Math.Max(source.Along(start), source.HalfLength - 2.5f);
arcStart = source.Center + forward * (num + 1f);
arcEnd = arcStart + val;
end = LaneFrame.Destination(target, start.y, 1.5f);
centered.y = (arcStart.y = (arcEnd.y = start.y));
Vector3 val2 = centered - start;
centeringLength = ((Vector3)(ref val2)).magnitude;
val2 = arcStart - centered;
outboundLength = ((Vector3)(ref val2)).magnitude;
arcLength = MathF.PI * radius;
val2 = end - arcEnd;
inboundLength = ((Vector3)(ref val2)).magnitude;
}
internal Vector3 PointAt(float distance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
distance = Mathf.Clamp(distance, 0f, Length);
if (distance < centeringLength)
{
return Vector3.Lerp(start, centered, distance / centeringLength);
}
distance -= centeringLength;
if (distance < outboundLength)
{
return Vector3.Lerp(centered, arcStart, distance / outboundLength);
}
distance -= outboundLength;
if (distance < arcLength)
{
float num = distance / radius;
return arcStart + across * (radius * (1f - (float)Math.Cos(num))) + forward * (radius * (float)Math.Sin(num));
}
return Vector3.Lerp(arcEnd, end, (distance - arcLength) / inboundLength);
}
internal Vector3 DirectionAt(float distance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
distance = Mathf.Clamp(distance, 0f, Length);
if (distance < centeringLength)
{
Vector3 val = centered - start;
return ((Vector3)(ref val)).normalized;
}
distance -= centeringLength;
if (distance < outboundLength)
{
return forward;
}
distance -= outboundLength;
if (distance >= arcLength)
{
return -forward;
}
float num = distance / radius;
return across * (float)Math.Sin(num) + forward * (float)Math.Cos(num);
}
internal float ClosestDistance(Vector3 point)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0067: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_00ee: Unknown result type (might be due to invalid IL or missing references)
float bestDistance = 0f;
float bestError = float.PositiveInfinity;
ClosestSegment(point, start, centered, 0f, ref bestDistance, ref bestError);
ClosestSegment(point, centered, arcStart, centeringLength, ref bestDistance, ref bestError);
Vector3 val = point - (arcStart + across * radius);
float num = Vector3.Dot(val, forward);
float num2 = Vector3.Dot(val, across);
float num3 = ((num > 0f) ? ((float)Math.Atan2(num, 0f - num2)) : ((num2 > 0f) ? MathF.PI : 0f));
float num4 = centeringLength + outboundLength + num3 * radius;
Vector3 val2 = point - PointAt(num4);
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (sqrMagnitude < bestError)
{
bestDistance = num4;
bestError = sqrMagnitude;
}
ClosestSegment(point, arcEnd, end, centeringLength + outboundLength + arcLength, ref bestDistance, ref bestError);
return bestDistance;
}
private static void ClosestSegment(Vector3 point, Vector3 a, Vector3 b, float offset, ref float bestDistance, ref float bestError)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_004b: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = b - a;
float num = ((((Vector3)(ref val)).sqrMagnitude > 0f) ? Mathf.Clamp01(Vector3.Dot(point - a, val) / ((Vector3)(ref val)).sqrMagnitude) : 0f);
Vector3 val2 = point - a - val * num;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude >= bestError))
{
bestError = sqrMagnitude;
bestDistance = offset + ((Vector3)(ref val)).magnitude * num;
}
}
}
[BepInPlugin("Rombusz.EndlessEscalator", "EndlessEscalator", "1.0.1")]
[DefaultExecutionOrder(100)]
public sealed class Plugin : BaseUnityPlugin
{
private sealed class Lane
{
internal readonly PlayerMoveZone Zone;
internal readonly MeshCollider Surface;
internal readonly LaneFrame Frame;
internal readonly Bounds Casing;
internal Lane? Other;
internal bool Live
{
get
{
if (Object.op_Implicit((Object)(object)Zone) && ((Behaviour)Zone).isActiveAndEnabled && Object.op_Implicit((Object)(object)Surface) && ((Collider)Surface).enabled)
{
return ((Component)Surface).gameObject.activeInHierarchy;
}
return false;
}
}
internal Lane(PlayerMoveZone zone, MeshCollider surface, LaneFrame frame, Bounds casing)
{
//IL_001c: 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)
Zone = zone;
Surface = surface;
Frame = frame;
Casing = casing;
}
internal bool FloorBelow(Vector3 point, out RaycastHit hit)
{
//IL_0000: 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_0017: 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_0029: 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_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_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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)
float num = Vector3.Dot(point - Frame.Center, Frame.Right);
point += Frame.Right * (Mathf.Clamp(num, 0f - Frame.HalfWidth + 0.02f, Frame.HalfWidth - 0.02f) - num);
if (((Collider)Surface).Raycast(new Ray(point + Vector3.up * 0.1f, Vector3.down), ref hit, 2.8f))
{
return ((RaycastHit)(ref hit)).normal.y > 0.8f;
}
return false;
}
}
public const string Guid = "Rombusz.EndlessEscalator";
public const string Name = "EndlessEscalator";
public const string Version = "1.0.1";
private readonly List<Lane> lanes = new List<Lane>();
private readonly LocalTransfer transfer = new LocalTransfer();
private readonly RaycastHit[] groundHits = (RaycastHit[])(object)new RaycastHit[24];
private ConfigEntry<bool> enabledSetting;
private Lane? riding;
private Character? rider;
private float ridingSince;
private float nextTransfer;
private float nextScan;
private TurnPath? turn;
private float turnDistance;
private float progressDistance;
private float lastProgressAt;
private bool faulted;
private void Awake()
{
enabledSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Having this enabled automatically loops you around on the airport escalators.");
SceneManager.sceneLoaded += SceneLoaded;
ResetScene();
((BaseUnityPlugin)this).Logger.LogMessage((object)"Plugin EndlessEscalator 1.0.1 is loaded!");
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= SceneLoaded;
}
private void SceneLoaded(Scene scene, LoadSceneMode mode)
{
ResetScene();
}
private void ResetScene()
{
lanes.Clear();
ResetRider();
faulted = false;
nextTransfer = 0f;
nextScan = Time.unscaledTime + 1f;
}
private void ResetRider()
{
riding = null;
rider = null;
turn = null;
}
private void FixedUpdate()
{
if (!enabledSetting.Value || faulted)
{
ResetRider();
return;
}
try
{
if (Time.unscaledTime >= nextScan)
{
nextScan = Time.unscaledTime + 5f;
DiscoverLanes();
}
if (lanes.Count > 0)
{
Tick();
}
}
catch (Exception arg)
{
faulted = true;
ResetRider();
((BaseUnityPlugin)this).Logger.LogError((object)$"EndlessEscalator stopped for this scene: {arg}");
}
}
private void DiscoverLanes()
{
lanes.Clear();
ResetRider();
PlayerMoveZone[] array = Object.FindObjectsByType<PlayerMoveZone>((FindObjectsInactive)0, (FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
Lane lane = CreateLane(array[i]);
if (lane != null)
{
lanes.Add(lane);
}
}
foreach (Lane lane2 in lanes)
{
Lane[] array2 = lanes.Where((Lane other) => other != lane2 && ((Component)other.Zone).gameObject.scene == ((Component)lane2.Zone).gameObject.scene && LaneFrame.AreNeighbors(lane2.Frame, other.Frame)).Take(2).ToArray();
lane2.Other = ((array2.Length == 1) ? array2[0] : null);
}
lanes.RemoveAll((Lane lane3) => lane3.Other == null || lane3.Other.Other != lane3);
if (lanes.Count != 0)
{
nextScan = float.PositiveInfinity;
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Linked {lanes.Count / 2} airport walkway pair(s).");
}
}
private static Lane? CreateLane(PlayerMoveZone zone)
{
//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_007b: 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_0091: 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_00b6: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: 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)
Transform parent = ((Component)zone).transform.parent;
if (!((Behaviour)zone).isActiveAndEnabled || !Object.op_Implicit((Object)(object)parent) || !((Object)parent).name.StartsWith("Conveyor", StringComparison.Ordinal) || !HasAirportAncestor(parent))
{
return null;
}
MeshCollider val = ((IEnumerable<MeshCollider>)((Component)parent).GetComponentsInChildren<MeshCollider>()).FirstOrDefault((Func<MeshCollider, bool>)((MeshCollider collider) => ((Object)((Component)collider).gameObject).name == "conveyor" && ((Collider)collider).enabled && !((Collider)collider).isTrigger && Object.op_Implicit((Object)(object)collider.sharedMesh) && ((Object)collider.sharedMesh).name == "Conveyor"));
if (!Object.op_Implicit((Object)(object)val))
{
return null;
}
Bounds zoneBounds = zone.zoneBounds;
Bounds bounds = ((Collider)val).bounds;
if (((Bounds)(ref bounds)).size.y > 0.3f || Math.Abs(((Bounds)(ref bounds)).center.x - ((Bounds)(ref zoneBounds)).center.x) > 0.25f || Math.Abs(((Bounds)(ref bounds)).center.z - ((Bounds)(ref zoneBounds)).center.z) > 0.25f)
{
return null;
}
Vector3 val2 = Vector3.Max(((Bounds)(ref zoneBounds)).min, ((Bounds)(ref bounds)).min);
Vector3 val3 = Vector3.Min(((Bounds)(ref zoneBounds)).max, ((Bounds)(ref bounds)).max);
val2.y = ((Bounds)(ref zoneBounds)).min.y;
val3.y = ((Bounds)(ref zoneBounds)).max.y;
if (val2.x >= val3.x || val2.z >= val3.z)
{
return null;
}
Bounds casing = bounds;
Collider[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Collider>();
foreach (Collider val4 in componentsInChildren)
{
if (val4.enabled && !val4.isTrigger)
{
((Bounds)(ref casing)).Encapsulate(val4.bounds);
}
}
if (!LaneFrame.TryCreate(new Bounds((val2 + val3) * 0.5f, val3 - val2), zone.forceDirection, out var lane))
{
return null;
}
return new Lane(zone, val, lane, casing);
}
private static bool HasAirportAncestor(Transform transform)
{
Transform val = transform;
while (Object.op_Implicit((Object)(object)val))
{
if (((Object)val).name == "BL_Airport")
{
return true;
}
val = val.parent;
}
return false;
}
private void Tick()
{
//IL_0031: 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_0065: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
Character localCharacter = Character.localCharacter;
if (!Object.op_Implicit((Object)(object)localCharacter) || !Object.op_Implicit((Object)(object)localCharacter.data))
{
ResetRider();
return;
}
bool flag = turn.HasValue && HasSupport(localCharacter.Center, localCharacter.data.groundPos.y);
if (!LocalTransfer.CanRide(localCharacter, flag))
{
ResetRider();
return;
}
Vector3 center = localCharacter.Center;
Lane lane = null;
foreach (Lane lane2 in lanes)
{
if (!lane2.Live || lane2.Other == null || !lane2.Other.Live)
{
ResetScene();
return;
}
}
if (turn.HasValue)
{
if ((Object)(object)rider != (Object)(object)localCharacter || !flag)
{
ResetRider();
}
else
{
FollowTurn(localCharacter);
}
return;
}
foreach (Lane lane3 in lanes)
{
if (lane3.Frame.ContainsRider(center) && lane3.FloorBelow(center, out var hit) && Math.Abs(localCharacter.data.groundPos.y - ((RaycastHit)(ref hit)).point.y) < 0.22f)
{
lane = lane3;
break;
}
}
if (lane == null)
{
ResetRider();
return;
}
if (riding != lane || (Object)(object)rider != (Object)(object)localCharacter)
{
riding = lane;
rider = localCharacter;
ridingSince = Time.fixedTime;
}
if (!(Time.fixedTime < nextTransfer) && !(Time.fixedTime - ridingSince < 0.3f) && !(lane.Frame.Along(center) < lane.Frame.HalfLength - 2.5f))
{
Bounds casing = lane.Casing;
((Bounds)(ref casing)).Encapsulate(lane.Other.Casing);
turn = new TurnPath(lane.Frame, lane.Other.Frame, casing, center);
turnDistance = (progressDistance = 0f);
lastProgressAt = Time.fixedTime;
FollowTurn(localCharacter);
}
}
private void FollowTurn(Character character)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
TurnPath value = turn.Value;
Vector3 center = character.Center;
turnDistance = Mathf.Max(turnDistance, value.ClosestDistance(center));
Vector3 val = value.PointAt(turnDistance);
val.y = center.y;
Vector3 val2 = val - center;
if (((Vector3)(ref val2)).sqrMagnitude > 2.25f || Time.fixedTime - lastProgressAt > 2.5f)
{
ResetRider();
nextTransfer = Time.fixedTime + 1f;
return;
}
if (turnDistance > progressDistance + 0.1f)
{
progressDistance = turnDistance;
lastProgressAt = Time.fixedTime;
}
Lane other = riding.Other;
if (turnDistance >= value.Length - 0.2f && other.FloorBelow(center, out var _))
{
turn = null;
riding = other;
ridingSince = Time.fixedTime;
nextTransfer = Time.fixedTime + 0.75f;
return;
}
Vector3 val3 = value.PointAt(Mathf.Min(value.Length, turnDistance + 0.4f));
val3.y = center.y;
if (HasSupport(val3, character.data.groundPos.y))
{
LocalTransfer localTransfer = transfer;
val2 = val3 - center;
if (localTransfer.TryDrive(character, ((Vector3)(ref val2)).normalized * 1.4f, allowStep: true))
{
return;
}
}
ResetRider();
nextTransfer = Time.fixedTime + 1f;
}
private bool HasSupport(Vector3 center, float floorY)
{
//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_000b: 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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
int num = Physics.RaycastNonAlloc(center + Vector3.up * 0.1f, Vector3.down, groundHits, 2.8f, -1, (QueryTriggerInteraction)1);
if (num == groundHits.Length)
{
return false;
}
for (int i = 0; i < num; i++)
{
RaycastHit val = groundHits[i];
if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody) && ((RaycastHit)(ref val)).normal.y > 0.8f && Math.Abs(((RaycastHit)(ref val)).point.y - floorY) < 0.5f)
{
return true;
}
}
return false;
}
}
}