using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WallWalk;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "WallWalk", "1.0.0", "marrowbytes", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("marrowbytes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Automatic wall and ceiling walking for BONELAB.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WallWalk")]
[assembly: AssemblyTitle("WallWalk")]
[assembly: AssemblyVersion("1.0.0.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 WallWalk
{
public sealed class Mod : MelonMod
{
[HarmonyPatch(typeof(RigManager), "FixedUpdate")]
private static class FixedUpdatePatch
{
private static void Prefix(RigManager __instance)
{
Run(__instance);
}
}
[HarmonyPatch(typeof(AnimationRig), "BodyVelocity")]
private static class BalancePatch
{
private static void Postfix(AnimationRig __instance, ref Vector3 __result)
{
//IL_0011: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
Walker walker = HoldingWalker(((Rig)__instance).manager);
if (walker != null)
{
Vector3 vector = SurfaceMath.BalanceUp(RigFrame.ToNumerics(__result), RigFrame.ToNumerics(walker.Up));
__result = new Vector3(vector.X, vector.Y, vector.Z);
}
}
}
[HarmonyPatch(typeof(PhysicsRig), "OnAfterFixedUpdate")]
private static class SupportPatch
{
private static void Postfix(PhysicsRig __instance)
{
//IL_0024: 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)
Walker walker = HoldingWalker(((Rig)__instance).manager);
if (walker == null)
{
return;
}
if (Object.op_Implicit((Object)(object)((Rig)__instance).centerOfPressure))
{
((Rig)__instance).centerOfPressure.position = walker.Contact;
}
if (walker.Standing)
{
__instance.footSupported = 1f;
PhysGrounder physG = __instance.physG;
if (Object.op_Implicit((Object)(object)physG))
{
physG.isGrounded = true;
physG.groundNormal = walker.Up;
}
}
}
}
[HarmonyPatch(typeof(RigManager), "InternalTeleport")]
private static class TeleportPatch
{
private static void Prefix(RigManager __instance)
{
if (__instance._teleportQueued && (Object)(object)instance?.walker?.Rig == (Object)(object)__instance)
{
instance.Clear(stopMotion: false, "teleported");
}
}
}
[HarmonyPatch(typeof(RigManager), "SwitchAvatar")]
private static class AvatarPatch
{
private static void Prefix(RigManager __instance)
{
if (!((Object)(object)instance?.walker?.Rig != (Object)(object)__instance))
{
instance.Clear(stopMotion: false, "switched avatar");
instance.bindAfter = Time.unscaledTime + 0.5f;
}
}
}
[HarmonyPatch(typeof(RemapRig), "Jump")]
private static class JumpPatch
{
private static void Postfix(RemapRig __instance)
{
if ((Object)(object)instance?.walker?.Rig == (Object)(object)((Rig)__instance).manager)
{
instance.walker.QueueJump();
}
}
}
private static Mod? instance;
private Settings settings;
private Walker? walker;
private bool loading;
private bool faulted;
private float bindAfter;
public override void OnInitializeMelon()
{
instance = this;
settings = new Settings();
settings.CreateMenu(ResetPlayer);
Hooking.OnLevelLoading += OnLoading;
Hooking.OnLevelLoaded += OnLoaded;
Hooking.OnLevelUnloaded += OnUnloaded;
((MelonBase)this).LoggerInstance.Msg("WallWalk 1.0.0 loaded. Controls are in BoneMenu > WallWalk.");
}
public override void OnUpdate()
{
if (Input.GetKeyDown((KeyCode)287))
{
settings.SetEnabled(!settings.Enabled);
}
if (Input.GetKeyDown((KeyCode)288))
{
ResetPlayer();
}
if (loading || faulted || Time.unscaledTime < bindAfter)
{
return;
}
try
{
RigManager rigManager = Player.RigManager;
if (Object.op_Implicit((Object)(object)rigManager) && Object.op_Implicit((Object)(object)rigManager.physicsRig) && Object.op_Implicit((Object)(object)rigManager.ControllerRig) && Object.op_Implicit((Object)(object)rigManager.remapHeptaRig) && Object.op_Implicit((Object)(object)rigManager.physicsRig.rbFeet))
{
if (walker == null || (Object)(object)walker.Rig != (Object)(object)rigManager)
{
Clear();
walker = new Walker(rigManager, settings, Note);
}
if (!settings.Enabled && walker.Active)
{
walker.Reset(stopMotion: false, "WallWalk was turned off");
}
walker.PollInput();
}
}
catch (Exception error)
{
Fail(error);
}
}
public override void OnDeinitializeMelon()
{
Hooking.OnLevelLoading -= OnLoading;
Hooking.OnLevelLoaded -= OnLoaded;
Hooking.OnLevelUnloaded -= OnUnloaded;
Clear();
instance = null;
}
private void OnLoading(LevelInfo level)
{
loading = true;
Clear();
}
private void OnLoaded(LevelInfo level)
{
Clear();
loading = false;
faulted = false;
}
private void OnUnloaded()
{
loading = true;
Clear();
}
private void ResetPlayer()
{
Clear(stopMotion: true, "reset");
faulted = false;
bindAfter = Time.unscaledTime + 0.8f;
}
private void Clear(bool stopMotion = false, string? reason = null)
{
Walker walker = this.walker;
this.walker = null;
if (walker == null)
{
return;
}
try
{
walker.Reset(stopMotion, reason);
}
catch (Exception value)
{
((MelonBase)this).LoggerInstance.Error($"Could not reset WallWalk: {value}");
}
}
private void Note(string message)
{
if (settings.LogEvents)
{
((MelonBase)this).LoggerInstance.Msg(message);
}
}
private void Fail(Exception error)
{
faulted = true;
Clear(stopMotion: true);
((MelonBase)this).LoggerInstance.Error($"WallWalk stopped. Use Reset or F7 to start it again. {error}");
}
private static void Run(RigManager rig)
{
Mod mod = instance;
Walker walker = mod?.walker;
if (mod == null || mod.loading || mod.faulted || walker == null || !Object.op_Implicit((Object)(object)walker.Rig) || (Object)(object)walker.Rig != (Object)(object)rig)
{
return;
}
try
{
walker.Tick();
}
catch (Exception error)
{
mod.Fail(error);
}
}
private static Walker? HoldingWalker(RigManager? rig)
{
Mod mod = instance;
Walker walker = mod?.walker;
if (mod == null || mod.loading || mod.faulted || walker == null || !walker.Holding || !((Object)(object)rig != (Object)null) || !((Object)(object)walker.Rig == (Object)(object)rig))
{
return null;
}
return walker;
}
}
internal sealed class RigFrame
{
private readonly PhysicsRig physics;
private readonly Transform[] remapRigs;
private readonly Rigidbody[] bodies;
private readonly Vector3[] velocities;
private readonly Vector3[] angularVelocities;
private readonly ConfigurableJoint? feetJoint;
private JointDrive feetDrive;
private bool couldFall;
private bool attached;
internal RigFrame(RigManager manager)
{
physics = manager.physicsRig;
List<Transform> list = new List<Transform>();
Rig[] array = (Rig[])(object)new Rig[4]
{
(Rig)manager.remapHeptaRig,
(Rig)manager.animationRig,
(Rig)manager.interpRig,
(Rig)manager.virtualHeptaRig
};
foreach (Rig rig in array)
{
if (Object.op_Implicit((Object)(object)rig) && !list.Exists((Transform existing) => (Object)(object)existing == (Object)(object)((Component)rig).transform))
{
list.Add(((Component)rig).transform);
}
}
remapRigs = list.ToArray();
List<Rigidbody> list2 = new List<Rigidbody>();
foreach (Rigidbody componentsInChild in ((Component)physics).GetComponentsInChildren<Rigidbody>(true))
{
if (Object.op_Implicit((Object)(object)componentsInChild) && (Object)(object)((Component)componentsInChild).GetComponentInParent<PhysicsRig>() == (Object)(object)physics)
{
list2.Add(componentsInChild);
}
}
bodies = list2.ToArray();
velocities = (Vector3[])(object)new Vector3[bodies.Length];
angularVelocities = (Vector3[])(object)new Vector3[bodies.Length];
feetJoint = physics._feetKneeJoint;
}
internal void Rotate(Vector3 pivot, Quaternion rotation)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0074: 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_0079: 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_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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < bodies.Length; i++)
{
if (Object.op_Implicit((Object)(object)bodies[i]))
{
velocities[i] = bodies[i].velocity;
angularVelocities[i] = bodies[i].angularVelocity;
}
}
Vector3 value = (Object.op_Implicit((Object)(object)((Rig)physics).centerOfPressure) ? ((Rig)physics).centerOfPressure.position : pivot);
Vector3 vector = SurfaceMath.TeleportOffset(ToNumerics(pivot), ToNumerics(value), new Quaternion(rotation.x, rotation.y, rotation.z, rotation.w));
((Rig)physics).Teleport(new SimpleTransform(new Vector3(vector.X, vector.Y, vector.Z), rotation), false);
for (int j = 0; j < bodies.Length; j++)
{
Rigidbody val = bodies[j];
if (Object.op_Implicit((Object)(object)val) && !val.isKinematic)
{
val.velocity = rotation * velocities[j];
val.angularVelocity = rotation * angularVelocities[j];
}
}
Transform[] array = remapRigs;
foreach (Transform val2 in array)
{
if (Object.op_Implicit((Object)(object)val2))
{
val2.SetPositionAndRotation(pivot + rotation * (val2.position - pivot), rotation * val2.rotation);
}
}
Physics.SyncTransforms();
}
internal void SetAttached(bool value)
{
//IL_00b2: 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_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)
if (value == attached || !Object.op_Implicit((Object)(object)physics))
{
return;
}
attached = value;
if (value)
{
couldFall = physics.canFall;
physics.canFall = false;
if ((Object)(object)feetJoint != (Object)null && Object.op_Implicit((Object)(object)feetJoint))
{
feetDrive = feetJoint.slerpDrive;
feetJoint.slerpDrive = default(JointDrive);
}
}
else
{
physics.canFall = couldFall;
if ((Object)(object)feetJoint != (Object)null && Object.op_Implicit((Object)(object)feetJoint))
{
feetJoint.slerpDrive = feetDrive;
}
}
}
internal void ApplyForces(Vector3 up, Vector3 acceleration)
{
//IL_0000: 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_005f: 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)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
Vector3 vector = SurfaceMath.GravityCorrection(ToNumerics(Physics.gravity), ToNumerics(up));
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(vector.X, vector.Y, vector.Z);
Rigidbody[] array = bodies;
foreach (Rigidbody val2 in array)
{
if (Object.op_Implicit((Object)(object)val2) && !val2.isKinematic)
{
val2.AddForce(val2.useGravity ? (acceleration + val) : acceleration, (ForceMode)5);
}
}
}
internal void Push(Vector3 velocityChange)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
Rigidbody[] array = bodies;
foreach (Rigidbody val in array)
{
if (Object.op_Implicit((Object)(object)val) && !val.isKinematic)
{
val.AddForce(velocityChange, (ForceMode)2);
}
}
}
internal BodyMotion MeasureMotion()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
BodyMotion result = default(BodyMotion);
Rigidbody[] array = bodies;
foreach (Rigidbody val in array)
{
if (Object.op_Implicit((Object)(object)val) && !val.isKinematic)
{
result.Add(ToNumerics(val.velocity), val.mass);
}
}
return result;
}
internal void Stop()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Rigidbody[] array = bodies;
foreach (Rigidbody val in array)
{
if (Object.op_Implicit((Object)(object)val) && !val.isKinematic)
{
val.velocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
}
}
}
internal static Vector3 ToNumerics(Vector3 value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(value.x, value.y, value.z);
}
}
internal sealed class RigTrace
{
private readonly RigManager rig;
private readonly Action<string> note;
private float nextSample;
internal RigTrace(RigManager rig, Action<string> note)
{
this.rig = rig;
this.note = note;
}
internal void Restart()
{
nextSample = 0f;
}
internal void Sample(float sinceAttach, Vector3 up, Vector3 targetUp, Vector3 surfacePoint, float gap, bool supported, float speed)
{
//IL_009e: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: 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_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: 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_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
//IL_0428: Unknown result type (might be due to invalid IL or missing references)
if (!(Time.fixedTime < nextSample))
{
nextSample = Time.fixedTime + ((sinceAttach < 2f) ? 0.25f : 1f);
PhysicsRig physicsRig = rig.physicsRig;
GameWorldSkeletonRig virtualHeptaRig = rig.virtualHeptaRig;
OpenControllerRig obj = ((Il2CppObjectBase)rig.ControllerRig).TryCast<OpenControllerRig>();
Transform part = ((obj != null) ? obj.vrRoot : null);
note($"Trace {sinceAttach:F2}s: turn left {Vector3.Angle(up, targetUp):F0} | tilt behind WallWalk (root/cop/pelvis/chest): remap {Off((Rig?)(object)rig.remapHeptaRig, up)} anim {Off((Rig?)(object)rig.animationRig, up)} interp {Off((Rig?)(object)rig.interpRig, up)} skeleton {Off((Rig?)(object)virtualHeptaRig, up)} camera rig {Off(Object.op_Implicit((Object)(object)rig.ControllerRig) ? ((Component)rig.ControllerRig).transform : null, up)} vrRoot {Off(part, up)} | body: knee {Off(Object.op_Implicit((Object)(object)physicsRig._kneeRb) ? ((Component)physicsRig._kneeRb).transform : null, up)} pelvis {Off(((Rig)physicsRig).m_pelvis, up)} chest {Off(((Rig)physicsRig).m_chest, up)} head {Off(((Rig)physicsRig).m_head, up)} | feet gap {gap:F2} m, support {(supported ? "yes" : "no")}, game support {physicsRig.footSupported:F2}, speed {speed:F1} m/s | pelvis height: body {Height(((Rig)physicsRig).m_pelvis, surfacePoint, up)} skeleton {Height(Object.op_Implicit((Object)(object)virtualHeptaRig) ? ((Rig)virtualHeptaRig).m_pelvis : null, surfacePoint, up)} (standing {(Object.op_Implicit((Object)(object)rig._avatar) ? rig._avatar._pelvisHeight : 0f):F2}) | foot height: body {Height(((Rig)physicsRig).m_footLf, surfacePoint, up)} skeleton {Height(Object.op_Implicit((Object)(object)virtualHeptaRig) ? ((Rig)virtualHeptaRig).m_footLf : null, surfacePoint, up)} | floor point height: body {Height(((Rig)physicsRig).centerOfPressure, surfacePoint, up)} skeleton {Height(Object.op_Implicit((Object)(object)virtualHeptaRig) ? ((Rig)virtualHeptaRig).centerOfPressure : null, surfacePoint, up)}");
}
}
private static string Height(Transform? part, Vector3 surfacePoint, Vector3 up)
{
//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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)part != (Object)null) || !Object.op_Implicit((Object)(object)part))
{
return "-";
}
return Vector3.Dot(part.position - surfacePoint, up).ToString("F2");
}
private static string Off(Rig? part, Vector3 up)
{
//IL_0028: 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_0066: 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)
if ((Object)(object)part == (Object)null || !Object.op_Implicit((Object)(object)part))
{
return "-";
}
return $"{Off(((Component)part).transform, up)}/{Off(part.centerOfPressure, up)}/{Off(part.m_pelvis, up)}/{Off(part.m_chest, up)}";
}
private static string Off(Transform? part, Vector3 up)
{
//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 (!((Object)(object)part != (Object)null) || !Object.op_Implicit((Object)(object)part))
{
return "-";
}
return Vector3.Angle(part.up, up).ToString("F0");
}
}
internal sealed class Settings
{
private readonly MelonPreferences_Category category;
private readonly MelonPreferences_Entry<bool> enabled;
private readonly MelonPreferences_Entry<float> turnSpeed;
private readonly MelonPreferences_Entry<float> reach;
private readonly MelonPreferences_Entry<float> speed;
private readonly MelonPreferences_Entry<bool> logEvents;
private readonly MelonPreferences_Entry<bool> debugTrace;
private BoolElement? enabledElement;
internal bool Enabled => enabled.Value;
internal bool LogEvents => logEvents.Value;
internal bool DebugTrace => debugTrace.Value;
internal float TurnSpeed => Bounded(turnSpeed.Value, 160f, 45f, 360f);
internal float Reach => Bounded(reach.Value, 0.45f, 0.2f, 0.8f);
internal float Speed => Bounded(speed.Value, 2.8f, 1f, 6f);
internal Settings()
{
category = MelonPreferences.CreateCategory("WallWalk");
enabled = category.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
turnSpeed = category.CreateEntry<float>("TurnSpeed", 160f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
reach = category.CreateEntry<float>("WallReach", 0.45f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
speed = category.CreateEntry<float>("WalkSpeed", 2.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
logEvents = category.CreateEntry<bool>("LogEvents", true, (string)null, "Write wall attach and release events to the MelonLoader log.", false, false, (ValueValidator)null, (string)null);
debugTrace = category.CreateEntry<bool>("DebugTrace", false, (string)null, "While on a surface, log how each part of the rig is oriented and positioned. For tracking down problems.", false, false, (ValueValidator)null, (string)null);
}
internal void CreateMenu(Action reset)
{
//IL_0019: 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_0054: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: 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)
Page val = Page.Root.CreatePage("WallWalk", new Color(0.3f, 0.8f, 1f), 0, true);
enabledElement = val.CreateBool("Enabled", Color.white, Enabled, (Action<bool>)SetEnabled);
val.CreateFunction("Reset to floor", Color.yellow, reset);
val.CreateFloat("Turn speed", Color.white, TurnSpeed, 15f, 45f, 360f, (Action<float>)delegate(float value)
{
Save(turnSpeed, value);
});
val.CreateFloat("Wall reach", Color.white, Reach, 0.05f, 0.2f, 0.8f, (Action<float>)delegate(float value)
{
Save(reach, value);
});
val.CreateFloat("Walk speed", Color.white, Speed, 0.2f, 1f, 6f, (Action<float>)delegate(float value)
{
Save(speed, value);
});
val.CreateBool("Log events", Color.white, LogEvents, (Action<bool>)delegate(bool value)
{
Save(logEvents, value);
});
val.CreateBool("Debug trace", Color.white, DebugTrace, (Action<bool>)delegate(bool value)
{
Save(debugTrace, value);
});
}
internal void SetEnabled(bool value)
{
enabled.Value = value;
if (enabledElement != null)
{
enabledElement.Value = value;
}
category.SaveToFile(false);
}
private void Save<T>(MelonPreferences_Entry<T> entry, T value)
{
entry.Value = value;
category.SaveToFile(false);
}
private static float Bounded(float value, float fallback, float min, float max)
{
if (!float.IsFinite(value))
{
return fallback;
}
return Math.Clamp(value, min, max);
}
}
internal static class SurfaceMath
{
internal static Quaternion Turn(Vector3 up, Vector3 target, Vector3 forward, float degrees)
{
up = Vector3.Normalize(up);
target = Vector3.Normalize(target);
float num = MathF.Acos(Math.Clamp(Vector3.Dot(up, target), -1f, 1f));
if (num < 0.0001f || degrees <= 0f)
{
return Quaternion.Identity;
}
Vector3 value = Vector3.Cross(up, target);
if (value.LengthSquared() < 1E-06f)
{
value = forward - up * Vector3.Dot(forward, up);
if (value.LengthSquared() < 1E-06f)
{
value = Vector3.Cross(up, (MathF.Abs(up.X) < 0.8f) ? Vector3.UnitX : Vector3.UnitZ);
}
}
return Quaternion.CreateFromAxisAngle(Vector3.Normalize(value), MathF.Min(num, degrees * (float)Math.PI / 180f));
}
internal static Vector2 PivotOffset(float feetDistance, float radius, float alignment, bool outerEdge, float clearance, float maxOffset)
{
float num = Math.Clamp(alignment, -1f, 1f);
float num2 = 1f - num;
float num3 = MathF.Sqrt(MathF.Max(0f, 1f - num * num));
if (num2 < 0.02f || num3 < 0.02f || !float.IsFinite(feetDistance))
{
return Vector2.Zero;
}
float num4 = (feetDistance - radius * num) / num2;
if (!outerEdge)
{
num4 = MathF.Max(num4, (clearance + feetDistance - 2f * radius * num) / (2f * num2));
}
float num5 = num4 - radius;
Vector2 vector = new Vector2(num5, (num4 - feetDistance - num5 * num) / num3);
if (vector.LengthSquared() > maxOffset * maxOffset)
{
return Vector2.Normalize(vector) * maxOffset;
}
return vector;
}
internal static Vector3 TeleportOffset(Vector3 pivot, Vector3 center, Quaternion rotation)
{
Vector3 vector = pivot - center;
return vector - Vector3.Transform(vector, rotation);
}
internal static Vector3 BalanceUp(Vector3 balance, Vector3 up)
{
return balance - Vector3.UnitY + up;
}
internal static Vector3 GravityCorrection(Vector3 gravity, Vector3 up)
{
return -gravity - up * gravity.Length();
}
internal static float Adhesion(float gap, float outwardSpeed)
{
return Math.Clamp((Math.Clamp((0f - gap) * 4f - 0.08f, -0.8f, 0.25f) - outwardSpeed) * 6f, -4f, 4f);
}
internal static float StepLift(float outwardSpeed)
{
return Math.Clamp((1.2f - outwardSpeed) * 8f, 0f, 12f);
}
internal static Vector3 MovementAcceleration(Vector3 desired, Vector3 velocity, Vector3 up, float deltaTime)
{
if (!float.IsFinite(deltaTime) || deltaTime <= 0f)
{
return Vector3.Zero;
}
Vector3 vector = desired - velocity;
vector -= up * Vector3.Dot(vector, up);
Vector3 vector2 = vector * (1f - MathF.Exp(-6f * deltaTime));
float num = 6f * deltaTime;
if (vector2.LengthSquared() > num * num)
{
vector2 = Vector3.Normalize(vector2) * num;
}
return vector2 / deltaTime;
}
internal static bool IsFlung(Vector3 relativeVelocity, float speedLimit)
{
if (Finite(relativeVelocity))
{
return relativeVelocity.LengthSquared() > speedLimit * speedLimit;
}
return true;
}
internal static bool WasMoved(Vector3 travel, float speedLimit, float deltaTime)
{
float num = MathF.Max(0.5f, speedLimit * deltaTime * 3f);
if (Finite(travel))
{
return travel.LengthSquared() > num * num;
}
return true;
}
internal static bool Finite(Vector3 value)
{
if (float.IsFinite(value.X) && float.IsFinite(value.Y))
{
return float.IsFinite(value.Z);
}
return false;
}
internal static bool CanTransfer(float alignment, float approach, bool outerEdge)
{
if (alignment > -0.35f && alignment < 0.92f)
{
if (!outerEdge)
{
return approach < -0.25f;
}
return true;
}
return false;
}
}
internal struct BodyMotion
{
private Vector3 momentum;
private float mass;
private bool invalid;
internal readonly Vector3 Velocity
{
get
{
if (!(mass > 0f))
{
return Vector3.Zero;
}
return momentum / mass;
}
}
internal readonly bool Valid
{
get
{
if (!invalid && mass > 0f && float.IsFinite(mass))
{
return SurfaceMath.Finite(momentum);
}
return false;
}
}
internal void Add(Vector3 velocity, float bodyMass)
{
if (!SurfaceMath.Finite(velocity) || !float.IsFinite(bodyMass) || bodyMass <= 0f)
{
invalid = true;
return;
}
momentum += velocity * bodyMass;
mass += bodyMass;
}
}
internal sealed class SurfaceProbe
{
private const float StepHeight = 0.5f;
private readonly RigManager rig;
private readonly Il2CppStructArray<RaycastHit> hits = new Il2CppStructArray<RaycastHit>(64L);
internal SurfaceProbe(RigManager rig)
{
this.rig = rig;
}
internal bool Cast(Vector3 origin, Vector3 direction, float radius, float distance, out RaycastHit nearest)
{
//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_0016: 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_0035: 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_00df: 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_00f7: 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_010a: Unknown result type (might be due to invalid IL or missing references)
int num = Physics.SphereCastNonAlloc(origin, radius, direction, hits, distance, -5, (QueryTriggerInteraction)1);
nearest = default(RaycastHit);
float num2 = float.PositiveInfinity;
for (int i = 0; i < num; i++)
{
RaycastHit val = ((Il2CppArrayBase<RaycastHit>)(object)hits)[i];
Collider collider = ((RaycastHit)(ref val)).collider;
if (!Object.op_Implicit((Object)(object)collider) || !float.IsFinite(((RaycastHit)(ref val)).distance) || ((RaycastHit)(ref val)).distance <= 0.001f || ((RaycastHit)(ref val)).distance >= num2 || ((Component)collider).transform.IsChildOf(((Component)rig).transform))
{
continue;
}
Rigidbody rigidbody = ((RaycastHit)(ref val)).rigidbody;
if ((!Object.op_Implicit((Object)(object)rigidbody) || (rigidbody.isKinematic && !((Component)rigidbody).transform.IsChildOf(((Component)rig).transform))) && SurfaceMath.Finite(RigFrame.ToNumerics(((RaycastHit)(ref val)).normal)) && SurfaceMath.Finite(RigFrame.ToNumerics(((RaycastHit)(ref val)).point)))
{
Vector3 normal = ((RaycastHit)(ref val)).normal;
if (!(((Vector3)(ref normal)).sqrMagnitude < 0.9f))
{
nearest = val;
num2 = ((RaycastHit)(ref val)).distance;
}
}
}
return num2 < float.PositiveInfinity;
}
internal bool Support(Vector3 feet, Vector3 up, float radius, float reach, out RaycastHit hit)
{
//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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
return Cast(feet + up * 0.12f, -up, radius * 0.65f, radius + reach, out hit);
}
internal bool Ahead(Vector3 feet, Vector3 up, Vector3 movement, float radius, float reach, out RaycastHit hit)
{
//IL_0019: 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_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_002a: 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_0041: 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_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_0066: 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_006d: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref movement)).sqrMagnitude < 0.01f)
{
hit = default(RaycastHit);
return false;
}
if (!Cast(feet + up * 0.08f, movement, radius * 0.65f, reach + radius, out hit) || !SurfaceMath.CanTransfer(Vector3.Dot(up, ((RaycastHit)(ref hit)).normal), Vector3.Dot(movement, ((RaycastHit)(ref hit)).normal), outerEdge: false))
{
return false;
}
if (Cast(feet + up * 0.5f, movement, radius * 0.65f, reach + radius + 0.5f, out var nearest))
{
return Vector3.Dot(((RaycastHit)(ref nearest)).normal, ((RaycastHit)(ref hit)).normal) > 0.8f;
}
return false;
}
internal bool StepAhead(Vector3 feet, Vector3 up, Vector3 movement, float radius)
{
//IL_001a: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref movement)).sqrMagnitude < 0.01f)
{
return false;
}
float num = radius + 0.3f;
if (!Cast(feet + up * 0.05f, movement, radius * 0.6f, num, out var nearest) || Vector3.Dot(((RaycastHit)(ref nearest)).normal, movement) > -0.5f)
{
return false;
}
RaycastHit nearest2;
return !Cast(feet + up * 0.5f, movement, radius * 0.6f, num + 0.1f, out nearest2);
}
internal bool AroundEdge(Vector3 feet, Vector3 up, Vector3 movement, float radius, out RaycastHit hit)
{
//IL_0018: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0042: 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_0010: 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_0066: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref movement)).sqrMagnitude < 0.01f)
{
hit = default(RaycastHit);
return false;
}
Vector3 origin = feet + movement * (radius + 0.28f) - up * (radius + 0.25f);
if (!Cast(origin, -movement, radius * 0.45f, radius + 0.5f, out hit))
{
return false;
}
return SurfaceMath.CanTransfer(Vector3.Dot(up, ((RaycastHit)(ref hit)).normal), 0f, outerEdge: true);
}
}
internal sealed class Walker
{
private const float JumpSpeed = 3.2f;
private const float MaxPivotOffset = 1.2f;
private const float BodyClearance = 0.5f;
private const float BodyLength = 1.6f;
private readonly Settings settings;
private readonly Action<string> note;
private readonly RigFrame frame;
private readonly SurfaceProbe probe;
private readonly RigTrace trace;
private readonly PhysicsRig physics;
private readonly OpenControllerRig controller;
private Collider? surface;
private Vector3 localPoint;
private Vector3 localNormal;
private Vector3 up = Vector3.up;
private Vector3 targetUp = Vector3.up;
private Vector3 point;
private Vector2 pivotOffset;
private Vector3 pivotAxis;
private float attachedAt;
private float lastContact;
private float lastTransfer;
private float cooldownUntil;
private Vector3 lastFeet;
private bool hasLastFeet;
private bool active;
private bool returning;
private bool touching;
private bool jumpQueued;
internal RigManager Rig { get; }
internal bool Active => active;
internal bool Holding
{
get
{
if (active)
{
return !returning;
}
return false;
}
}
internal bool Standing
{
get
{
if (Holding)
{
return touching;
}
return false;
}
}
internal Vector3 Up => up;
private Vector3 Feet
{
get
{
//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_001d: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)physics._football))
{
return physics.rbFeet.position;
}
return ((Component)physics._football).transform.TransformPoint(physics._football.center);
}
}
private Vector3 Head
{
get
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)((Rig)physics).m_head))
{
return Feet;
}
return ((Rig)physics).m_head.position;
}
}
internal Vector3 Contact => Feet - up * Mathf.Max(0.05f, physics.footballRadius);
internal Walker(RigManager rig, Settings settings, Action<string> note)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Rig = rig;
this.settings = settings;
this.note = note;
physics = rig.physicsRig;
controller = ((Il2CppObjectBase)rig.ControllerRig).Cast<OpenControllerRig>();
frame = new RigFrame(rig);
probe = new SurfaceProbe(rig);
trace = new RigTrace(rig, note);
}
internal void PollInput()
{
if (active && !returning && !((ControllerRig)controller).IsPaused)
{
BaseController val = (controller.isRightHanded ? ((ControllerRig)controller).rightController : ((ControllerRig)controller).leftController);
if (Object.op_Implicit((Object)(object)val) && val.GetAButtonDown())
{
jumpQueued = true;
}
}
}
internal void QueueJump()
{
if (active && !returning)
{
jumpQueued = true;
}
}
internal void Tick()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_0033: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: 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_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_0170: 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_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: 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_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_048e: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
//IL_044f: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: 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_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_065c: Unknown result type (might be due to invalid IL or missing references)
//IL_0661: Unknown result type (might be due to invalid IL or missing references)
//IL_066e: Unknown result type (might be due to invalid IL or missing references)
//IL_0673: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: 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_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
//IL_06db: Unknown result type (might be due to invalid IL or missing references)
//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
//IL_070e: Unknown result type (might be due to invalid IL or missing references)
//IL_0711: Unknown result type (might be due to invalid IL or missing references)
//IL_068d: Unknown result type (might be due to invalid IL or missing references)
//IL_0692: Unknown result type (might be due to invalid IL or missing references)
//IL_0593: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
//IL_060c: Unknown result type (might be due to invalid IL or missing references)
//IL_0611: Unknown result type (might be due to invalid IL or missing references)
//IL_078e: Unknown result type (might be due to invalid IL or missing references)
//IL_079c: Unknown result type (might be due to invalid IL or missing references)
//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0737: Unknown result type (might be due to invalid IL or missing references)
//IL_0739: Unknown result type (might be due to invalid IL or missing references)
//IL_0626: Unknown result type (might be due to invalid IL or missing references)
//IL_0627: Unknown result type (might be due to invalid IL or missing references)
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_0634: Unknown result type (might be due to invalid IL or missing references)
//IL_0637: Unknown result type (might be due to invalid IL or missing references)
//IL_063c: Unknown result type (might be due to invalid IL or missing references)
//IL_0641: Unknown result type (might be due to invalid IL or missing references)
//IL_0645: Unknown result type (might be due to invalid IL or missing references)
//IL_064a: Unknown result type (might be due to invalid IL or missing references)
//IL_064f: Unknown result type (might be due to invalid IL or missing references)
//IL_0651: Unknown result type (might be due to invalid IL or missing references)
//IL_0653: Unknown result type (might be due to invalid IL or missing references)
//IL_0658: Unknown result type (might be due to invalid IL or missing references)
//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
//IL_074b: Unknown result type (might be due to invalid IL or missing references)
//IL_074d: Unknown result type (might be due to invalid IL or missing references)
//IL_0752: Unknown result type (might be due to invalid IL or missing references)
//IL_081a: Unknown result type (might be due to invalid IL or missing references)
//IL_0820: Unknown result type (might be due to invalid IL or missing references)
//IL_0826: Unknown result type (might be due to invalid IL or missing references)
//IL_075e: Unknown result type (might be due to invalid IL or missing references)
//IL_0763: Unknown result type (might be due to invalid IL or missing references)
//IL_0768: Unknown result type (might be due to invalid IL or missing references)
//IL_0771: Unknown result type (might be due to invalid IL or missing references)
//IL_0774: Unknown result type (might be due to invalid IL or missing references)
//IL_0784: Unknown result type (might be due to invalid IL or missing references)
//IL_0789: Unknown result type (might be due to invalid IL or missing references)
string text = ((!settings.Enabled) ? "WallWalk was turned off" : ((Object.op_Implicit((Object)(object)Rig.activeSeat) || (int)Rig.bodyState == 1) ? "sat down" : (((int)Rig.bodyState != 0) ? "went ragdoll" : ((Object.op_Implicit((Object)(object)Rig.health) && !Rig.health.alive) ? "died" : (physics.shutdown ? "the physics rig shut down" : null)))));
if (text != null)
{
Reset(stopMotion: false, text);
return;
}
float fixedDeltaTime = Time.fixedDeltaTime;
if (fixedDeltaTime <= 0f || fixedDeltaTime > 0.1f)
{
return;
}
bool isPaused = ((ControllerRig)controller).IsPaused;
Vector3 feet = Feet;
float num = Mathf.Max(0.05f, physics.footballRadius);
Vector3 val = DesiredMovement();
Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.zero);
bool flag = !isPaused && !returning && Time.fixedTime >= cooldownUntil;
Vector3 val3;
if ((Object)(object)surface != (Object)null && Object.op_Implicit((Object)(object)surface))
{
val3 = ((Component)surface).transform.TransformDirection(localNormal);
targetUp = ((Vector3)(ref val3)).normalized;
point = ((Component)surface).transform.TransformPoint(localPoint);
}
bool flag2 = active && Vector3.Dot(up, targetUp) < 0.95f;
bool flag3 = false;
if (jumpQueued)
{
jumpQueued = false;
if (active && !returning && !isPaused && Time.fixedTime - lastTransfer > 0.3f)
{
frame.Push(up * 3.2f);
Detach("jumped off");
}
}
if (flag && !flag2 && Time.fixedTime - lastTransfer > 0.25f && probe.Ahead(feet, up, val2, num, settings.Reach, out var hit))
{
Attach(hit, feet, num, outerEdge: false, "Walked onto");
}
else if (active && !returning)
{
float reach = (flag2 ? (settings.Reach + num + 0.35f) : 0.42f);
RaycastHit hit3;
if (probe.Support(feet, targetUp, num, reach, out var hit2) && Vector3.Dot(((RaycastHit)(ref hit2)).normal, targetUp) > 0.65f)
{
flag3 = true;
if (flag2 || Vector3.Dot(((RaycastHit)(ref hit2)).normal, targetUp) < 0.9f)
{
lastContact = Time.fixedTime;
}
else
{
Remember(hit2);
pivotOffset = Vector2.zero;
}
}
else if (flag && !flag2 && probe.AroundEdge(feet, up, val2, num, out hit3))
{
Attach(hit3, feet, num, outerEdge: true, "Stepped around the edge onto");
}
else if ((Object)(object)surface == (Object)null || !Object.op_Implicit((Object)(object)surface) || !surface.enabled || !((Component)surface).gameObject.activeInHierarchy || Time.fixedTime - lastContact > 0.22f)
{
Detach("lost contact with the surface");
}
}
if (!active)
{
return;
}
BodyMotion bodyMotion = frame.MeasureMotion();
if (!bodyMotion.Valid)
{
Reset(stopMotion: false, "the body reported invalid physics values");
return;
}
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(bodyMotion.Velocity.X, bodyMotion.Velocity.Y, bodyMotion.Velocity.Z);
float speedLimit = Mathf.Max(12f, settings.Speed * 3f);
if (hasLastFeet && SurfaceMath.WasMoved(RigFrame.ToNumerics(feet - lastFeet), speedLimit, fixedDeltaTime))
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(46, 1);
defaultInterpolatedStringHandler.AppendLiteral("something else moved the player ");
val3 = feet - lastFeet;
defaultInterpolatedStringHandler.AppendFormatted(((Vector3)(ref val3)).magnitude, "F2");
defaultInterpolatedStringHandler.AppendLiteral(" m in one step");
Reset(stopMotion: false, defaultInterpolatedStringHandler.ToStringAndClear());
return;
}
if (!returning)
{
Vector3 value = val4 - SurfaceVelocity();
float num2 = Vector3.Dot(feet - point, targetUp) - num;
float num3 = (flag2 ? (0f - (num + 0.6f)) : (-0.25f));
if (SurfaceMath.IsFlung(RigFrame.ToNumerics(value), speedLimit))
{
Detach($"thrown at {((Vector3)(ref value)).magnitude:F1} m/s");
}
else if (num2 > settings.Reach + 0.65f || num2 < num3)
{
Detach($"feet {num2:F2} m from the surface");
}
}
if (!isPaused)
{
Vector3 value2 = (returning ? Vector3.up : targetUp);
float degrees = settings.TurnSpeed * (returning ? 2f : 1f) * fixedDeltaTime;
Quaternion quaternion = SurfaceMath.Turn(RigFrame.ToNumerics(up), RigFrame.ToNumerics(value2), RigFrame.ToNumerics(((Rig)controller).m_head.forward), degrees);
Quaternion val5 = default(Quaternion);
((Quaternion)(ref val5))..ctor(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
if (Quaternion.Angle(Quaternion.identity, val5) > 0.001f)
{
frame.Rotate(Pivot(feet), val5);
val3 = val5 * up;
up = ((Vector3)(ref val3)).normalized;
val4 = val5 * val4;
}
}
lastFeet = Feet;
hasLastFeet = true;
if (Vector3.Dot(up, Vector3.up) > 0.9999f && (returning || Vector3.Dot(targetUp, Vector3.up) > 0.9999f))
{
Reset(stopMotion: false, returning ? null : "walked onto level ground");
return;
}
frame.SetAttached(!returning);
if (!returning)
{
Vector3 val6 = val4 - SurfaceVelocity();
float num4 = Vector3.Dot(Feet - point, targetUp) - num - 0.015f;
float outwardSpeed = Vector3.Dot(val6, targetUp);
touching = flag3 && num4 < 0.06f;
Vector3 val8;
if (!flag2 && val2 != Vector3.zero && probe.StepAhead(feet, up, val2, num))
{
Vector3 val7 = up;
val3 = Physics.gravity;
val8 = val7 * (((Vector3)(ref val3)).magnitude + SurfaceMath.StepLift(Vector3.Dot(val6, up)));
}
else
{
val8 = targetUp * SurfaceMath.Adhesion(num4, outwardSpeed);
}
Vector3 vector = SurfaceMath.MovementAcceleration(RigFrame.ToNumerics(DesiredMovement()), RigFrame.ToNumerics(val6), RigFrame.ToNumerics(up), fixedDeltaTime);
frame.ApplyForces(up, val8 + new Vector3(vector.X, vector.Y, vector.Z));
if (settings.DebugTrace)
{
trace.Sample(Time.fixedTime - attachedAt, up, targetUp, point, num4, flag3, ((Vector3)(ref val6)).magnitude);
}
}
}
internal void Detach(string reason)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (active && !returning)
{
surface = null;
targetUp = Vector3.up;
returning = true;
touching = false;
jumpQueued = false;
cooldownUntil = Time.fixedTime + 0.8f;
frame.SetAttached(value: false);
note($"Let go after {Time.fixedTime - attachedAt:F2} s: {reason}.");
}
}
internal void Reset(bool stopMotion = false, string? reason = null)
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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)
bool flag = active;
try
{
if (active && Object.op_Implicit((Object)(object)Rig) && Object.op_Implicit((Object)(object)physics) && Object.op_Implicit((Object)(object)controller))
{
if (stopMotion)
{
frame.Stop();
}
if (Vector3.Dot(up, Vector3.up) < 0.999999f)
{
Quaternion quaternion = SurfaceMath.Turn(RigFrame.ToNumerics(up), Vector3.UnitY, RigFrame.ToNumerics(((Rig)controller).m_head.forward), 180f);
frame.Rotate(Head, new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W));
}
}
}
finally
{
frame.SetAttached(value: false);
surface = null;
up = Vector3.up;
targetUp = Vector3.up;
active = false;
returning = false;
touching = false;
hasLastFeet = false;
jumpQueued = false;
cooldownUntil = Time.fixedTime + 0.8f;
if (flag && reason != null)
{
note($"Back on the floor after {Time.fixedTime - attachedAt:F2} s: {reason}.");
}
}
}
private Vector3 Pivot(Vector3 feet)
{
//IL_0010: 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_0009: 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_004e: 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_006a: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (returning)
{
return Head;
}
Vector3 val = Vector3.Cross(pivotAxis, up);
if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
{
return feet + up * pivotOffset.x;
}
return feet + up * pivotOffset.x + ((Vector3)(ref val)).normalized * pivotOffset.y;
}
private Vector3 SurfaceVelocity()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (returning || (Object)(object)surface == (Object)null || !Object.op_Implicit((Object)(object)surface) || !Object.op_Implicit((Object)(object)surface.attachedRigidbody))
{
return Vector3.zero;
}
return surface.attachedRigidbody.GetPointVelocity(point);
}
private void Attach(RaycastHit hit, Vector3 feet, float radius, bool outerEdge, string how)
{
//IL_005a: 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)
//IL_0068: 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_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_0082: 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)
//IL_00c9: 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_00d7: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (!active)
{
up = ((Component)Rig.remapHeptaRig).transform.up;
hasLastFeet = false;
attachedAt = Time.fixedTime;
trace.Restart();
}
active = true;
returning = false;
lastTransfer = Time.fixedTime;
Remember(hit);
float num = Vector3.Dot(up, ((RaycastHit)(ref hit)).normal);
float num2 = Vector3.Dot(feet - ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal);
float clearance = 0.5f + Mathf.Max(0f, 0f - num) * 1.6f;
Vector2 vector = SurfaceMath.PivotOffset(num2, radius, num, outerEdge, clearance, 1.2f);
pivotOffset = new Vector2(vector.X, vector.Y);
Vector3 val = Vector3.Cross(up, ((RaycastHit)(ref hit)).normal);
pivotAxis = ((Vector3)(ref val)).normalized;
frame.SetAttached(value: true);
note($"{how} {((Object)((RaycastHit)(ref hit)).collider).name} ({Vector3.Angle(up, ((RaycastHit)(ref hit)).normal):F0} degree turn, feet {num2:F2} m away).");
}
private void Remember(RaycastHit hit)
{
//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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
surface = ((RaycastHit)(ref hit)).collider;
localPoint = ((Component)surface).transform.InverseTransformPoint(((RaycastHit)(ref hit)).point);
localNormal = ((Component)surface).transform.InverseTransformDirection(((RaycastHit)(ref hit)).normal);
Vector3 normal = ((RaycastHit)(ref hit)).normal;
targetUp = ((Vector3)(ref normal)).normalized;
point = ((RaycastHit)(ref hit)).point;
lastContact = Time.fixedTime;
}
private Vector3 DesiredMovement()
{
//IL_000d: 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_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_0106: 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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: 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_015d: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: 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)
if (((ControllerRig)controller).IsPaused)
{
return Vector3.zero;
}
BaseController val = (controller.isRightHanded ? ((ControllerRig)controller).leftController : ((ControllerRig)controller).rightController);
if (!Object.op_Implicit((Object)(object)val))
{
return Vector3.zero;
}
Vector2 val2 = val.GetThumbStickAxis();
if (((Vector2)(ref val2)).sqrMagnitude < 0.01f)
{
val2 = val.GetTouchPadAxis();
}
if (((Vector2)(ref val2)).sqrMagnitude < 0.0225f)
{
return Vector3.zero;
}
val2 = Vector2.ClampMagnitude(val2, 1f);
Vector3 val3 = Vector3.ProjectOnPlane((Object.op_Implicit((Object)(object)controller.directionMasterTransform) ? controller.directionMasterTransform : ((Rig)controller).m_head).forward, up);
if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
{
val3 = Vector3.ProjectOnPlane(((Component)Rig.remapHeptaRig).transform.forward, up);
}
if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
{
val3 = Vector3.Cross(((Rig)controller).m_head.right, up);
}
((Vector3)(ref val3)).Normalize();
Vector3 val4 = Vector3.Cross(up, val3);
Vector3 normalized = ((Vector3)(ref val4)).normalized;
float num = settings.Speed * (val.GetThumbStick() ? 1.5f : 1f);
return (val3 * val2.y + normalized * val2.x) * num;
}
}
}