Decompiled source of RepoWallMoveset v1.0.0

BepInEx/plugins/RepoWallClimb.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("koku")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoWallClimb")]
[assembly: AssemblyTitle("RepoWallClimb")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 RepoWallClimb
{
	internal static class FarClip
	{
		internal enum User
		{
			Sense,
			Web
		}

		private static Camera? _cam;

		private static float _saved;

		private static readonly float[] _want = new float[2];

		internal static bool Extended => (Object)(object)_cam != (Object)null;

		internal static float Current
		{
			get
			{
				Camera main = Camera.main;
				return ((Object)(object)main != (Object)null) ? main.farClipPlane : 0f;
			}
		}

		internal static void Request(User who, float distance)
		{
			_want[(int)who] = Mathf.Max(0f, distance);
			Apply();
		}

		internal static void Release(User who)
		{
			_want[(int)who] = 0f;
			Apply();
		}

		private static void Apply()
		{
			float num = Mathf.Max(_want[0], _want[1]);
			Camera main = Camera.main;
			if (num <= 0f || (Object)(object)main == (Object)null)
			{
				Restore();
				return;
			}
			if ((Object)(object)_cam != (Object)(object)main)
			{
				Restore();
				_cam = main;
				_saved = main.farClipPlane;
			}
			main.farClipPlane = Mathf.Max(_saved, num);
		}

		internal static void Restore()
		{
			if (!((Object)(object)_cam == (Object)null))
			{
				_cam.farClipPlane = _saved;
				_cam = null;
			}
		}
	}
	[BepInPlugin("koku.RepoWallClimb", "RepoWallClimb", "1.0")]
	public class RepoWallClimb : BaseUnityPlugin
	{
		internal static RepoWallClimb Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	public enum ClimbCameraMode
	{
		Off,
		WallUp
	}
	public enum ClimbJumpMode
	{
		Detach,
		SurfaceLeap
	}
	public enum ClimbLeapMode
	{
		Normal,
		WorldUp,
		Custom
	}
	public enum DetachReason
	{
		surface_lost,
		stood_up,
		crouched,
		web,
		release_key,
		jump,
		tumble,
		disabled
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal static class WallClimbPatch2
	{
		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<KeyCode> ToggleKey;

		internal static ConfigEntry<KeyCode> ReleaseKey;

		internal static ConfigEntry<bool> RequireCrouch;

		internal static ConfigEntry<bool> HoldRequiresCrouch;

		internal static ConfigEntry<bool> BlockWhenCrouching;

		internal static ConfigEntry<bool> RequireIntent;

		internal static ConfigEntry<float> IntentDot;

		internal static ConfigEntry<float> CastRadius;

		internal static ConfigEntry<float> CastBackOff;

		internal static ConfigEntry<float> AttachRange;

		internal static ConfigEntry<float> HoldRange;

		internal static ConfigEntry<float> HoldRayOffset;

		internal static ConfigEntry<float> HoldMinDot;

		internal static ConfigEntry<float> FollowMaxAngle;

		internal static ConfigEntry<float> MinSteepness;

		internal static ConfigEntry<float> EyeHeight;

		internal static ConfigEntry<float> DetachCooldown;

		internal static ConfigEntry<bool> RequireFullBody;

		internal static ConfigEntry<float> BodyLow;

		internal static ConfigEntry<float> BodyHigh;

		internal static ConfigEntry<float> BodyWidth;

		internal static ConfigEntry<float> SwitchMinAngle;

		internal static ConfigEntry<float> SwitchMaxAngle;

		internal static ConfigEntry<float> SwitchRange;

		internal static ConfigEntry<float> SwitchCooldown;

		internal static ConfigEntry<float> SwitchRevertWindow;

		internal static ConfigEntry<float> SwitchMaxFloorDot;

		internal static ConfigEntry<bool> EdgeWrap;

		internal static ConfigEntry<float> EdgeReach;

		internal static ConfigEntry<float> EdgeDepth;

		internal static ConfigEntry<float> EdgeWindow;

		internal static ConfigEntry<float> EdgeAssist;

		internal static ConfigEntry<float> NormalBlendSpeed;

		internal static ConfigEntry<bool> CarryVelocity;

		internal static ConfigEntry<float> GraceSeconds;

		internal static ConfigEntry<bool> UseContacts;

		internal static ConfigEntry<bool> UseNearProbe;

		internal static ConfigEntry<float> StickTouchScale;

		internal static ConfigEntry<bool> CancelGravity;

		internal static ConfigEntry<bool> UseAntiGravity;

		internal static ConfigEntry<float> GravityCancelScale;

		internal static ConfigEntry<float> ClimbAccel;

		internal static ConfigEntry<float> ClimbMaxSpeed;

		internal static ConfigEntry<float> ClimbDrag;

		internal static ConfigEntry<float> StickForce;

		internal static ConfigEntry<ClimbJumpMode> JumpMode;

		internal static ConfigEntry<ClimbLeapMode> LeapMode;

		internal static ConfigEntry<float> WallJumpForce;

		internal static ConfigEntry<float> LeapForce;

		internal static ConfigEntry<float> LeapOutward;

		internal static ConfigEntry<float> LeapWindow;

		internal static ConfigEntry<float> LeapCooldown;

		internal static ConfigEntry<bool> MoveRelativeToCamera;

		internal static ConfigEntry<bool> InvertRight;

		internal static ConfigEntry<ClimbCameraMode> CameraMode;

		internal static ConfigEntry<bool> RotateVisuals;

		internal static ConfigEntry<float> VisualRestoreSpeed;

		internal static ConfigEntry<bool> RotateBody;

		internal static ConfigEntry<float> BodyRotationSpeed;

		internal static ConfigEntry<float> CameraRotationSpeed;

		internal static ConfigEntry<float> LargeTiltSlowdown;

		internal static ConfigEntry<float> OverrideTime;

		internal static ConfigEntry<bool> HeroLanding;

		internal static ConfigEntry<bool> ClimbDebug;

		private static bool _done;

		internal static WallClimb? Climb;

		private static void Setup()
		{
			if (!_done)
			{
				_done = true;
				ConfigFile config = ((BaseUnityPlugin)RepoWallClimb.Instance).Config;
				Enabled = config.Bind<bool>("Climb", "Enabled", true, "壁登りを使う。");
				ToggleKey = config.Bind<KeyCode>("Climb", "ToggleKey", (KeyCode)118, "機能のオン/オフ。");
				ReleaseKey = config.Bind<KeyCode>("Climb", "ReleaseKey", (KeyCode)99, "壁から剥がれる。");
				RequireCrouch = config.Bind<bool>("Climb", "RequireCrouch", false, "★既定 false(課題15)★ しゃがんでいる時だけ吸着する。true にすると壁登りとしゃがみが結びつき、乗り換えのたびに姿勢を切り替える必要が出て操作が分断される。誤発動の抑制は RequireIntent / RequireFullBody / MinSteepness が担う。");
				HoldRequiresCrouch = config.Bind<bool>("Climb", "HoldRequiresCrouch", false, "張り付いた後もしゃがみ続けないと剥がれるようにする。false なら張り付いている間の姿勢は一切問わない。");
				BlockWhenCrouching = config.Bind<bool>("Climb", "BlockWhenCrouching", true, "★課題19★ しゃがんでいる間は壁に張り付かない。張り付いている最中にしゃがんだら剥がれる。しゃがみを高速移動専用にして、壁沿いを速く走り抜けたい時に壁へ吸われないようにするための設定。RequireCrouch=true の時は矛盾するのでこちらは無視される。");
				RequireIntent = config.Bind<bool>("Climb", "RequireIntent", true, "★しゃがみの代わりの誤発動対策(課題15-C)★ 壁へ向かう入力があるか、接地していない時だけ吸着する。壁に沿って歩いただけでは吸い付かない。姿勢は問わない。");
				IntentDot = config.Bind<float>("Climb", "IntentDot", 0.25f, "「壁へ向かっている」とみなす一致度。1 で正面から真っ直ぐ向かった時だけ。下げるほど吸着しやすい。");
				CastRadius = config.Bind<float>("ClimbDetect", "CastRadius", 0.3f, "判定球の半径。");
				CastBackOff = config.Bind<float>("ClimbDetect", "CastBackOff", 0.5f, "★重要★ キャストを撃つ前に進行方向の逆へ下げる距離。SphereCast は開始位置で重なっている Collider を検出しないため、壁に吸い付いた状態では 0 だと判定が丸ごと失敗する。");
				AttachRange = config.Bind<float>("ClimbDetect", "AttachRange", 0.6f, "吸着する距離。");
				HoldRange = config.Bind<float>("ClimbDetect", "HoldRange", 1.4f, "吸着を維持できる距離。");
				HoldRayOffset = config.Bind<float>("ClimbDetect", "HoldRayOffset", 0.45f, "維持キャストを上下左右へ振る量。壁の継ぎ目や端で1 本外れても、他が当たれば維持できる。0 で中央 1 本だけ。");
				HoldMinDot = config.Bind<float>("ClimbDetect", "HoldMinDot", 0.3f, "維持キャストが当たった面を「同じ壁」とみなす一致度。");
				FollowMaxAngle = config.Bind<float>("ClimbDetect", "FollowMaxAngle", 25f, "曲面へなめらかに追従する上限角。これを超える差は乗り換え扱い。");
				MinSteepness = config.Bind<float>("ClimbDetect", "MinSteepness", 0.6f, "どれだけ急な面に吸着できるか。1 で完全な垂直のみ。★吸着のみに掛かる。維持と乗り換えには掛からない。");
				EyeHeight = config.Bind<float>("ClimbDetect", "EyeHeight", 0.9f, "主レイの高さ。");
				DetachCooldown = config.Bind<float>("ClimbDetect", "DetachCooldown", 0.8f, "剥がれてから再吸着までの秒数。");
				RequireFullBody = config.Bind<bool>("ClimbDetect", "RequireFullBody", true, "体全体が接する面だけを壁とみなす。柱やテーブルを除外。");
				BodyLow = config.Bind<float>("ClimbDetect", "BodyLow", 0.35f, "体の下端の高さ。");
				BodyHigh = config.Bind<float>("ClimbDetect", "BodyHigh", 1.6f, "体の上端の高さ。");
				BodyWidth = config.Bind<float>("ClimbDetect", "BodyWidth", 0.4f, "体の幅の半分。");
				SwitchMinAngle = config.Bind<float>("ClimbSwitch", "MinAngle", 20f, "これ未満の角度差は乗り換えではなく追従で処理する。");
				SwitchMaxAngle = config.Bind<float>("ClimbSwitch", "MaxAngle", 100f, "今の壁から何度まで離れた面へ乗り移れるか。");
				SwitchRange = config.Bind<float>("ClimbSwitch", "Range", 0.9f, "壁を掴んだまま乗り換え先を探す距離。「角に達した」と言える近さにしておく。大きくすると遠くの壁を見ただけで移ってしまう。壁を見失っている時だけは AttachRange の 2 倍まで探す。");
				SwitchCooldown = config.Bind<float>("ClimbSwitch", "Cooldown", 0.5f, "壁を乗り換えてから次までの秒数。内角ではこの 2 倍待つ。");
				SwitchRevertWindow = config.Bind<float>("ClimbSwitch", "RevertWindow", 0.7f, "乗り換えてからこの秒数の間に新しい面を見失ったら、剥がれる前に元の面へ戻して維持を試す。内角では使わない。");
				SwitchMaxFloorDot = config.Bind<float>("ClimbSwitch", "MaxFloorDot", 0.5f, "乗り換え先として許す面の上向き度の上限。天井やオーバーハングは許し、上を向いた床だけを弾く。");
				EdgeWrap = config.Bind<bool>("ClimbEdge", "Enabled", true, "★課題16★ 面が途切れた縁で、その穴に隣接する面へ回り込む。ドアの開口部に達したら枠の内壁へ、壁の上端に達したら天面へ張り付いて這い進む。穴を渡るのではなく、穴の形をなぞる。");
				EdgeReach = config.Bind<float>("ClimbEdge", "Reach", 0.55f, "進行方向のどれだけ先を見て「面が途切れている」と判断するか。小さいと縁に着いてから気付くので回り込みが間に合わない。大きいと手前で反応しすぎる。");
				EdgeDepth = config.Bind<float>("ClimbEdge", "Depth", 0.5f, "回り込み先を探す時、今の面よりどれだけ奥へ入った位置から撃つか。ドア枠の内壁は壁の厚みの中にあるので、面より奥に入らないと当たらない。");
				EdgeWindow = config.Bind<float>("ClimbEdge", "Window", 0.35f, "縁を回り込んでいる間、維持判定と壁への吸着を止める秒数。回り込んだ直後はまだ新しい面の裏側にいるため、吸着を掛けると逆向きに押されてしまう。");
				EdgeAssist = config.Bind<float>("ClimbEdge", "Assist", 3f, "回り込む時に進行方向へ足す速度(m/s)。縁を乗り越えるきっかけになる。0 で慣性だけに任せる。");
				NormalBlendSpeed = config.Bind<float>("ClimbSwitch", "NormalBlendSpeed", 10f, "確定した法線へ、実際に使う法線が追いつく速さ。小さいほど乗り換えが滑らかになるが、反応が鈍くなる。0 で補間なし(即座に切り替わる)。");
				CarryVelocity = config.Bind<bool>("ClimbSwitch", "CarryVelocity", true, "乗り換え時に速度を新しい面へ回して引き継ぐ。角を曲がる時に勢いが途切れなくなる。");
				GraceSeconds = config.Bind<float>("ClimbSwitch", "GraceSeconds", 0.35f, "今の壁を見失ってから剥がれるまでの猶予(秒)。★v7 でフレーム数から秒へ変更した。旧 GraceFrames=12 は 144fps だと 0.08 秒しかなく、一瞬の判定漏れで剥がれていた。フレームレートに左右されないよう秒で持つ。");
				UseContacts = config.Bind<bool>("ClimbDetect", "UseContacts", true, "★推奨 true★ 実際の接触点(OnCollisionStay)を維持判定の主軸にする。接触法線は判定球の食い込みと無関係に正しい値を返すので、SphereCast が空振りしても壁を見失わない。");
				UseNearProbe = config.Bind<bool>("ClimbDetect", "UseNearProbe", true, "接触もキャストも取れない時、周囲の Collider の最近接点から面を推定する最後の手段を使う。");
				StickTouchScale = config.Bind<float>("ClimbMove", "StickTouchScale", 0.35f, "既に壁へ接触している時に StickForce へ掛ける倍率。1 未満にすると壁へ押し込む力が減り、判定球が埋まりにくくなる。");
				CancelGravity = config.Bind<bool>("ClimbMove", "CancelGravity", true, "★重要★ 張り付き中に REPO の重力を打ち消す。REPO は rb.useGravity ではなく PlayerController.FixedUpdate 内の AddForce(0, -CustomGravity*dt, 0, Impulse) で重力を掛けている。useGravity=false では止まらないため、張り付いていても毎秒ずるずる落ちていた。");
				UseAntiGravity = config.Bind<bool>("ClimbMove", "UseAntiGravity", false, "REPO 自身の PlayerController.AntiGravity(float) を呼ぶ。★既定 false★ v7 で試したところ CustomGravity は 30 のままで、期待した「CustomGravity を 0 にする」動作ではなかった。何をしているか確認できていない API を呼び続ける必要はないので切ってある。CancelGravity 側の打ち消しだけで成立している。");
				GravityCancelScale = config.Bind<float>("ClimbMove", "GravityCancelScale", 1f, "重力の打ち消し量。1 で完全に打ち消す。0.9 などにすると、わずかに下へ流れる挙動を残せる。");
				ClimbAccel = config.Bind<float>("ClimbMove", "Accel", 60f, "壁面での加速。");
				ClimbMaxSpeed = config.Bind<float>("ClimbMove", "MaxSpeed", 4.5f, "壁面での最高速度。");
				ClimbDrag = config.Bind<float>("ClimbMove", "Drag", 14f, "壁面での減速。");
				StickForce = config.Bind<float>("ClimbMove", "StickForce", 30f, "壁へ引き寄せる力。壁抜けするなら下げる。");
				JumpMode = config.Bind<ClimbJumpMode>("ClimbMove", "JumpMode", ClimbJumpMode.SurfaceLeap, "張り付き中に Space を押した時の挙動。 SurfaceLeap : 剥がれずに壁面を跳ぶ。 Detach      : 剥がれて壁を蹴って飛ぶ(従来)。");
				LeapMode = config.Bind<ClimbLeapMode>("ClimbMove", "LeapMode", ClimbLeapMode.Normal, "跳躍の方向(課題17)。 Normal  : 壁に対して垂直。法線方向へまっすぐ飛び出す(既定)。面方向の成分はゼロになるので LeapForce は使われない。 WorldUp : ワールドの垂直。真上へ飛ぶ。 Custom  : LeapForce(面方向)と LeapOutward(法線方向)を混ぜる。入力方向へ跳ぶ従来の挙動。");
				WallJumpForce = config.Bind<float>("ClimbMove", "WallJumpForce", 7f, "JumpMode=Detach の時に壁を蹴る力。0 で Space を無視する。");
				LeapForce = config.Bind<float>("ClimbMove", "LeapForce", 5f, "JumpMode=SurfaceLeap の時、壁面に沿って跳ぶ力(m/s)。入力があればその方向、無ければ壁面の上へ跳ぶ。★用途で振り分ける(課題14-C)★ 素早く高所へ登りたい → こちらを上げる(12〜15)。壁から壁へ飛び移りたい → LeapOutward を上げる。回避に使いたい → 両方 4〜6 で短く速く。");
				LeapOutward = config.Bind<float>("ClimbMove", "LeapOutward", 9f, "跳躍時に壁から離れる速度(m/s)。StickForce で引き戻される。★見え方の目安★ 離れる距離はおよそ LeapOutward^2 / (2 * StickForce) [m]。既定(9, StickForce=30) で約 1.35m。v8 から跳躍中は維持判定を止めているので、HoldRange(1.4) を超えても剥がれない。0 にすると壁に貼り付いたまま加速するだけになる。");
				LeapWindow = config.Bind<float>("ClimbMove", "LeapWindow", 0.5f, "跳躍の勢いを保つ秒数。この間は加速・減速と法線方向の速度打ち消しを止める。短いとすぐ通常制御に戻され、勢いが消える。");
				LeapCooldown = config.Bind<float>("ClimbMove", "LeapCooldown", 0.5f, "次に跳べるようになるまでの秒数。跳躍らしさのために LeapWindow 以上にしておく。");
				MoveRelativeToCamera = config.Bind<bool>("ClimbMove", "RelativeToCamera", true, "true: W が「画面の前」になる(カメラを壁面へ投影)。false: W が常に「壁面の上」。切り分け用。");
				InvertRight = config.Bind<bool>("ClimbMove", "InvertRight", false, "D で左へ動く場合だけ true にする。右方向を反転する。");
				CameraMode = config.Bind<ClimbCameraMode>("ClimbCamera", "Mode", ClimbCameraMode.WallUp, "Off    : Frame を動かさない。移動だけを切り分けて確認する時用。 WallUp : カメラの上方向を壁の法線へ倒す(壁に立っている視点)。 どちらでも Aim(Yaw/Pitch) には一切触らない。");
				RotateVisuals = config.Bind<bool>("ClimbCamera", "RotateVisuals", true, "★課題11-D★ 見た目(PlayerAvatarVisuals.meshParent)だけを壁の向きへ倒す。コライダーも物理も一切変えないので、剥がれた後の着地は通常どおり。REPO 自身が visualFollowLerp で見た目を遅延追従させている以上、見た目と本体の姿勢がズレること自体は想定内の設計。");
				VisualRestoreSpeed = config.Bind<float>("ClimbCamera", "VisualRestoreSpeed", 14f, "剥がれた後に見た目が縦へ戻る速さ(課題11-C)。カメラより速くしておくと、落下中に傾いたまま着地しにくい。");
				RotateBody = config.Bind<bool>("ClimbCamera", "RotateBody", false, "身体(コライダー)そのものを壁の向きへ倒す。★既定 false のまま★ 物理姿勢が変わるので着地位置が乱れる。見た目だけで足りるなら RotateVisuals を使うこと。");
				BodyRotationSpeed = config.Bind<float>("ClimbCamera", "BodyRotationSpeed", 15f, "身体が回る速度。RotateBody=true の時のみ有効。");
				CameraRotationSpeed = config.Bind<float>("ClimbCamera", "CameraRotationSpeed", 8f, "カメラ Pivot が壁の向きへ倒れる速度。");
				LargeTiltSlowdown = config.Bind<float>("ClimbCamera", "LargeTiltSlowdown", 0.45f, "傾きが大きい時に回転速度へ掛ける倍率。天井への 180 度近い反転をゆっくりにして酔いを抑える。1 で可変なし。");
				OverrideTime = config.Bind<float>("ClimbCamera", "OverrideTime", 0.1f, "OverrideTurnRotation に渡す追従時間。");
				HeroLanding = config.Bind<bool>("HeroLanding", "Enabled", true, "落下によるタンブルを無効化する。攻撃によるタンブルは残る。");
				ClimbDebug = config.Bind<bool>("Climb", "Debug", false, "壁登りのログを出す。");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Post(PlayerController __instance)
		{
			Setup();
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<WallClimb>() == (Object)null)
			{
				Climb = ((Component)__instance).gameObject.AddComponent<WallClimb>();
				RepoWallClimb.Logger.LogInfo((object)"WallClimb v10 attached. (V=toggle)");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Post(PlayerController __instance)
		{
			if ((Object)(object)Climb != (Object)null)
			{
				Climb.Tick(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("FixedUpdate")]
		private static void Fixed_Post(PlayerController __instance)
		{
			if (HeroLanding != null && HeroLanding.Value && (Object)(object)__instance.CollisionController != (Object)null)
			{
				__instance.CollisionController.fallDistance = 0f;
			}
			if ((Object)(object)Climb != (Object)null)
			{
				Climb.Physics(__instance);
			}
		}
	}
	public class WallClimb : MonoBehaviour
	{
		private struct WallBasis
		{
			public Vector3 normal;

			public Vector3 up;

			public Vector3 right;

			public Vector3 forward;
		}

		private enum SurfaceUse
		{
			Attach,
			Switch,
			Hold
		}

		private const string FrameName = "WallClimbCameraFrame";

		private PlayerController? _pc;

		private Rigidbody? _rb;

		private Collider? _col;

		private LayerMask _mask;

		private bool _enabled = true;

		private bool _on;

		private Vector3 _normal = Vector3.up;

		private Vector3 _viewNormal = Vector3.up;

		private WallBasis _basis;

		private float _blockUntil;

		private float _switchUntil;

		private float _lostSince = -1f;

		private Vector2 _input;

		private bool _wantJump;

		private float _moveLogAt;

		private Vector3 _contactNormal;

		private float _contactStamp = -999f;

		private int _contactHits;

		private float _contactBestDot;

		private float _touchStamp = -999f;

		private Vector3 _altNormal;

		private float _altStamp = -999f;

		private int _altHits;

		private float _altBestAng = 999f;

		private readonly Collider[] _overlap = (Collider[])(object)new Collider[16];

		private float _surfaceDist = 1f;

		private Vector3 _prevNormal;

		private bool _hasPrev;

		private float _revertUntil;

		private Vector3 _leftNormal;

		private float _noReturnUntil;

		private bool _hasCarry;

		private Quaternion _carry = Quaternion.identity;

		private bool _wantLeap;

		private float _leapUntil;

		private float _leapReadyAt;

		private float _lastLeapAt = -99f;

		private bool _edgeWrapped;

		private float _edgeUntil;

		private Vector3 _edgeDir;

		private bool _edgeAssistPending;

		private string _holdInfo = "-";

		private readonly Vector3[] _holdOrigins = (Vector3[])(object)new Vector3[5];

		private Transform? _frame;

		private Transform? _aimParent;

		private bool _frameOwned;

		private Quaternion _currentBody = Quaternion.identity;

		private Quaternion _tilt = Quaternion.identity;

		private bool _restoring;

		private Transform? _mesh;

		private Quaternion _visualTilt = Quaternion.identity;

		private Quaternion _visualBase = Quaternion.identity;

		private Quaternion _lastVisualWrite = Quaternion.identity;

		private bool _hasVisualWrite;

		private CollisionDetectionMode _savedCdm;

		private bool _cdmChanged;

		private PhysicMaterial? _savedMat;

		private PhysicMaterial? _slipMat;

		private bool _matChanged;

		private readonly Vector3[] _switchDirs = (Vector3[])(object)new Vector3[3];

		private float _switchLogAt;

		private Vector3 Eye => ((Component)this).transform.position + Vector3.up * WallClimbPatch2.EyeHeight.Value;

		public bool Attached => _on;

		private void Awake()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006c: 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_0084: 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: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).TryGetComponent<PlayerController>(ref _pc);
			((Component)this).TryGetComponent<Rigidbody>(ref _rb);
			_col = ((Component)this).GetComponent<Collider>();
			_mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "Environment", "NavmeshOnly" }));
			_slipMat = new PhysicMaterial("WallClimbSlip")
			{
				dynamicFriction = 0f,
				staticFriction = 0f,
				bounciness = 0f,
				frictionCombine = (PhysicMaterialCombine)2,
				bounceCombine = (PhysicMaterialCombine)2
			};
			_basis = BuildBasis(Vector3.up);
		}

		private void Log(string m)
		{
			if (WallClimbPatch2.ClimbDebug.Value)
			{
				RepoWallClimb.Logger.LogInfo((object)("[Climb] " + m));
			}
		}

		private static string Fmt(Vector3 v)
		{
			//IL_0005: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			return $"({v.x:F2},{v.y:F2},{v.z:F2})";
		}

		private WallBasis BuildBasis(Vector3 normal)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0110: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0132: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			WallBasis result = new WallBasis
			{
				normal = ((Vector3)(ref normal)).normalized
			};
			Vector3 val = Vector3.ProjectOnPlane(Vector3.up, result.normal);
			if (((Vector3)(ref val)).sqrMagnitude < 0.05f)
			{
				Vector3 val2 = Vector3.ProjectOnPlane(_basis.up, result.normal);
				if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
				{
					val = val2;
				}
			}
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.ProjectOnPlane(((Component)this).transform.forward, result.normal);
			}
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.ProjectOnPlane(Vector3.forward, result.normal);
			}
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.ProjectOnPlane(Vector3.right, result.normal);
			}
			result.up = ((Vector3)(ref val)).normalized;
			Vector3 val3 = Vector3.Cross(result.normal, result.up);
			result.right = ((Vector3)(ref val3)).normalized;
			result.forward = -result.normal;
			if (WallClimbPatch2.InvertRight.Value)
			{
				result.right = -result.right;
			}
			return result;
		}

		private void UpdateView(float dt)
		{
			//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_0043: 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_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_0065: 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_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_0072: Unknown result type (might be due to invalid IL or missing references)
			float value = WallClimbPatch2.NormalBlendSpeed.Value;
			if (value <= 0f || Vector3.Angle(_viewNormal, _normal) < 0.05f)
			{
				_viewNormal = _normal;
			}
			else
			{
				Vector3 val = Vector3.Slerp(_viewNormal, _normal, 1f - Mathf.Exp((0f - value) * dt));
				_viewNormal = ((Vector3)(ref val)).normalized;
			}
			_basis = BuildBasis(_viewNormal);
		}

		private void EnsureFrame()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_010d: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_frame != (Object)null)
			{
				return;
			}
			CameraAim instance = CameraAim.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)instance).transform;
			Transform parent = transform.parent;
			if ((Object)(object)parent == (Object)null)
			{
				return;
			}
			if (((Object)parent).name == "WallClimbCameraFrame")
			{
				_frame = parent;
				_aimParent = parent.parent;
				_frameOwned = false;
				Log("frame reused (aim already parented)");
				return;
			}
			Transform val = parent.Find("WallClimbCameraFrame");
			if ((Object)(object)val != (Object)null)
			{
				_frame = val;
				_aimParent = parent;
				_frameOwned = false;
				transform.SetParent(_frame, false);
				Log("frame reused (re-parented aim)");
				return;
			}
			GameObject val2 = new GameObject("WallClimbCameraFrame");
			_frame = val2.transform;
			_frame.SetParent(parent, false);
			_frame.localPosition = Vector3.zero;
			_frame.localRotation = Quaternion.identity;
			_frame.localScale = Vector3.one;
			_frameOwned = true;
			_aimParent = parent;
			transform.SetParent(_frame, false);
			Log("frame inserted under " + ((Object)parent).name);
		}

		private void OnDestroy()
		{
			CameraAim instance = CameraAim.Instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)_aimParent != (Object)null)
			{
				((Component)instance).transform.SetParent(_aimParent, false);
			}
			if (_frameOwned && (Object)(object)_frame != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_frame).gameObject);
			}
		}

		public void Tick(PlayerController pc)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (_pc == null)
			{
				_pc = pc;
			}
			EnsureFrame();
			UpdateView(Time.deltaTime);
			if (!WallClimbPatch2.Enabled.Value)
			{
				if (_on)
				{
					Detach(DetachReason.disabled);
				}
				return;
			}
			float num = Input.GetAxisRaw("Horizontal");
			float num2 = Input.GetAxisRaw("Vertical");
			if (Mathf.Abs(num) < 0.01f && Mathf.Abs(num2) < 0.01f)
			{
				if (Input.GetKey((KeyCode)97))
				{
					num -= 1f;
				}
				if (Input.GetKey((KeyCode)100))
				{
					num += 1f;
				}
				if (Input.GetKey((KeyCode)115))
				{
					num2 -= 1f;
				}
				if (Input.GetKey((KeyCode)119))
				{
					num2 += 1f;
				}
			}
			_input = new Vector2(num, num2);
			if (Input.GetKeyDown(WallClimbPatch2.ToggleKey.Value))
			{
				_enabled = !_enabled;
				RepoWallClimb.Logger.LogInfo((object)(_enabled ? "WallClimb ON" : "WallClimb OFF"));
				if (!_enabled && _on)
				{
					Detach(DetachReason.disabled);
				}
			}
			if (!_enabled)
			{
				return;
			}
			Transform cam = (((Object)(object)_pc != (Object)null && (Object)(object)_pc.cameraGameObject != (Object)null) ? _pc.cameraGameObject.transform : ((Component)this).transform);
			if (_on)
			{
				if (Input.GetKeyDown(WallClimbPatch2.ReleaseKey.Value))
				{
					Detach(DetachReason.release_key);
					return;
				}
				if (SemiFunc.InputDown((InputKey)1))
				{
					if (WallClimbPatch2.JumpMode.Value == ClimbJumpMode.Detach)
					{
						if (WallClimbPatch2.WallJumpForce.Value > 0f)
						{
							_wantJump = true;
							Detach(DetachReason.jump);
							return;
						}
					}
					else if (Time.time >= _leapReadyAt)
					{
						_wantLeap = true;
					}
				}
				if ((Object)(object)_pc != (Object)null && (Object)(object)_pc.playerAvatarScript != (Object)null && _pc.playerAvatarScript.isTumbling)
				{
					Detach(DetachReason.tumble);
				}
				else if (WallClimbPatch2.HoldRequiresCrouch.Value && WallClimbPatch2.RequireCrouch.Value && (Object)(object)_pc != (Object)null && !_pc.Crouching)
				{
					Detach(DetachReason.stood_up);
				}
				else if (Blocked())
				{
					Detach(DetachReason.crouched);
				}
				else if (Time.time < _leapUntil)
				{
					_lostSince = -1f;
					_holdInfo = "leap";
				}
				else if (Time.time < _edgeUntil)
				{
					_lostSince = -1f;
					_holdInfo = "edge";
				}
				else if (!KeepWall())
				{
					Detach(DetachReason.surface_lost);
				}
			}
			else if (Time.time >= _blockUntil)
			{
				TryAttach(cam);
			}
		}

		private bool Cast(Vector3 origin, Vector3 dir, float range, SurfaceUse use, out RaycastHit hit)
		{
			//IL_0003: 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_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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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)
			hit = default(RaycastHit);
			if (((Vector3)(ref dir)).sqrMagnitude < 1E-06f)
			{
				return false;
			}
			dir = ((Vector3)(ref dir)).normalized;
			float num = Mathf.Max(0f, WallClimbPatch2.CastBackOff.Value);
			if (use == SurfaceUse.Hold)
			{
				float num2 = WallClimbPatch2.CastRadius.Value + 0.2f - _surfaceDist;
				if (num2 > num)
				{
					num = num2;
				}
			}
			Vector3 val = origin - dir * num;
			if (!Physics.SphereCast(val, WallClimbPatch2.CastRadius.Value, dir, ref hit, range + num, LayerMask.op_Implicit(_mask), (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (use != SurfaceUse.Hold && Vector3.Dot(((RaycastHit)(ref hit)).point - origin, dir) < 0f - WallClimbPatch2.CastRadius.Value)
			{
				return false;
			}
			return Accept(hit, use);
		}

		private static bool Accept(RaycastHit hit, SurfaceUse use)
		{
			//IL_004f: 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)
			Collider collider = ((RaycastHit)(ref hit)).collider;
			if ((Object)(object)collider == (Object)null)
			{
				return false;
			}
			if (((Component)collider).CompareTag("Player") || ((Component)collider).CompareTag("Enemy") || ((Component)collider).CompareTag("Phys Grab Object"))
			{
				return false;
			}
			float num = Vector3.Dot(((RaycastHit)(ref hit)).normal, Vector3.up);
			return use switch
			{
				SurfaceUse.Attach => Mathf.Abs(num) <= 1f - WallClimbPatch2.MinSteepness.Value, 
				SurfaceUse.Switch => num <= WallClimbPatch2.SwitchMaxFloorDot.Value, 
				_ => true, 
			};
		}

		private bool HoldCast(Vector3 n, Vector3 upAxis, Vector3 rightAxis, out Vector3 normal, out int hits, out int count)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: 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_0057: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007f: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_015d: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			normal = Vector3.zero;
			float value = WallClimbPatch2.HoldRayOffset.Value;
			_holdOrigins[0] = Eye;
			_holdOrigins[1] = Eye + upAxis * value;
			_holdOrigins[2] = Eye - upAxis * value;
			_holdOrigins[3] = Eye + rightAxis * value;
			_holdOrigins[4] = Eye - rightAxis * value;
			count = ((!(value > 0.01f)) ? 1 : _holdOrigins.Length);
			hits = 0;
			float num = -2f;
			float value2 = WallClimbPatch2.HoldMinDot.Value;
			float num2 = float.MaxValue;
			for (int i = 0; i < count; i++)
			{
				if (!Cast(_holdOrigins[i], -n, WallClimbPatch2.HoldRange.Value, SurfaceUse.Hold, out var hit))
				{
					continue;
				}
				float num3 = Vector3.Dot(((RaycastHit)(ref hit)).normal, n);
				if (num3 < value2)
				{
					continue;
				}
				hits++;
				if (num3 > num)
				{
					num = num3;
					normal = ((RaycastHit)(ref hit)).normal;
				}
				if (i == 0)
				{
					float num4 = Vector3.Dot(((RaycastHit)(ref hit)).point - Eye, -n);
					if (num4 < num2)
					{
						num2 = num4;
					}
				}
			}
			if (num2 < float.MaxValue)
			{
				_surfaceDist = Mathf.Max(0f, num2);
			}
			return hits > 0;
		}

		private void OnCollisionStay(Collision c)
		{
			//IL_00d8: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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)
			if (!_on || !WallClimbPatch2.UseContacts.Value)
			{
				return;
			}
			Collider collider = c.collider;
			if ((Object)(object)collider == (Object)null || ((1 << ((Component)collider).gameObject.layer) & ((LayerMask)(ref _mask)).value) == 0 || ((Component)collider).CompareTag("Player") || ((Component)collider).CompareTag("Enemy") || ((Component)collider).CompareTag("Phys Grab Object"))
			{
				return;
			}
			_touchStamp = Time.fixedTime;
			if (_contactStamp != Time.fixedTime)
			{
				_contactStamp = Time.fixedTime;
				_contactHits = 0;
				_contactBestDot = -2f;
				_contactNormal = Vector3.zero;
				_altStamp = Time.fixedTime;
				_altHits = 0;
				_altBestAng = 999f;
				_altNormal = Vector3.zero;
			}
			float value = WallClimbPatch2.HoldMinDot.Value;
			int contactCount = c.contactCount;
			for (int i = 0; i < contactCount; i++)
			{
				ContactPoint contact = c.GetContact(i);
				Vector3 normal = ((ContactPoint)(ref contact)).normal;
				float num = Vector3.Dot(normal, _normal);
				if (num >= value)
				{
					_contactHits++;
					if (num > _contactBestDot)
					{
						_contactBestDot = num;
						_contactNormal = normal;
					}
				}
				else
				{
					if (Vector3.Dot(normal, Vector3.up) > WallClimbPatch2.SwitchMaxFloorDot.Value)
					{
						continue;
					}
					float num2 = Vector3.Angle(normal, _normal);
					if (!(num2 < WallClimbPatch2.SwitchMinAngle.Value) && !(num2 > WallClimbPatch2.SwitchMaxAngle.Value))
					{
						_altHits++;
						if (num2 < _altBestAng)
						{
							_altBestAng = num2;
							_altNormal = normal;
						}
					}
				}
			}
		}

		private bool Fresh(float stamp)
		{
			return stamp > 0f && Time.fixedTime - stamp <= Time.fixedDeltaTime * 3f;
		}

		private bool ContactHold(out Vector3 normal)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			normal = _contactNormal;
			return WallClimbPatch2.UseContacts.Value && _contactHits > 0 && Fresh(_contactStamp);
		}

		private bool NearProbe(out Vector3 normal)
		{
			//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_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_003f: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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)
			//IL_010f: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			normal = Vector3.zero;
			if (!WallClimbPatch2.UseNearProbe.Value)
			{
				return false;
			}
			Vector3 eye = Eye;
			float num = WallClimbPatch2.CastRadius.Value + 0.5f;
			int num2 = Physics.OverlapSphereNonAlloc(eye, num, _overlap, LayerMask.op_Implicit(_mask), (QueryTriggerInteraction)1);
			float num3 = WallClimbPatch2.HoldMinDot.Value;
			bool result = false;
			for (int i = 0; i < num2; i++)
			{
				Collider val = _overlap[i];
				if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)this).transform) || ((Component)val).CompareTag("Player") || ((Component)val).CompareTag("Enemy") || ((Component)val).CompareTag("Phys Grab Object"))
				{
					continue;
				}
				Vector3 val2 = val.ClosestPoint(eye);
				Vector3 val3 = eye - val2;
				if (!(((Vector3)(ref val3)).sqrMagnitude < 1E-06f))
				{
					Vector3 normalized = ((Vector3)(ref val3)).normalized;
					float num4 = Vector3.Dot(normalized, _normal);
					if (!(num4 <= num3))
					{
						num3 = num4;
						normal = normalized;
						result = true;
					}
				}
			}
			return result;
		}

		private void TryAttach(Transform cam)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00d1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_pc == (Object)null || ((Object)(object)_pc.playerAvatarScript != (Object)null && _pc.playerAvatarScript.isTumbling) || SemiFunc.InputHold((InputKey)10) || (WallClimbPatch2.RequireCrouch.Value && !_pc.Crouching) || Blocked() || WebSwing.Active)
			{
				return;
			}
			Vector3 forward = cam.forward;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(forward.x, 0f, forward.z);
			Vector3[] array = (Vector3[])(object)new Vector3[2] { val, forward };
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val2 = array[i];
				if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f))
				{
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					if (Cast(Eye, normalized, WallClimbPatch2.AttachRange.Value, SurfaceUse.Attach, out var hit) && FullBody(normalized) && HasIntent(cam, ((RaycastHit)(ref hit)).normal))
					{
						Attach(((RaycastHit)(ref hit)).normal);
						break;
					}
				}
			}
		}

		private bool Blocked()
		{
			return WallClimbPatch2.BlockWhenCrouching.Value && !WallClimbPatch2.RequireCrouch.Value && (Object)(object)_pc != (Object)null && _pc.Crouching;
		}

		internal void ForceDetach()
		{
			if (_on)
			{
				Detach(DetachReason.web);
			}
		}

		private bool HasIntent(Transform cam, Vector3 normal)
		{
			//IL_0082: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_011a: 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)
			if (!WallClimbPatch2.RequireIntent.Value)
			{
				return true;
			}
			if ((Object)(object)_pc != (Object)null && (Object)(object)_pc.CollisionController != (Object)null && !_pc.CollisionController.Grounded)
			{
				return true;
			}
			if (((Vector2)(ref _input)).sqrMagnitude < 0.01f)
			{
				return false;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(cam.forward.x, 0f, cam.forward.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(cam.right.x, 0f, cam.right.z);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				return false;
			}
			Vector3 val3 = ((Vector3)(ref val)).normalized * _input.y + ((Vector3)(ref val2)).normalized * _input.x;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			return Vector3.Dot(normalized, -normal) >= WallClimbPatch2.IntentDot.Value;
		}

		private bool KeepWall()
		{
			//IL_0003: 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_0019: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 normal;
			int hits;
			int count;
			bool flag = HoldCast(_normal, _basis.up, _basis.right, out normal, out hits, out count);
			Vector3 normal2;
			bool flag2 = ContactHold(out normal2);
			Vector3 val = (flag ? normal : normal2);
			bool flag3 = flag || flag2;
			string text = (flag ? "ray" : (flag2 ? "contact" : "-"));
			if (!flag3 && NearProbe(out var normal3))
			{
				val = normal3;
				flag3 = true;
				text = "near";
			}
			_holdInfo = $"{text} r{hits}/{count} c{(flag2 ? _contactHits : 0)}";
			if (TrySwitch(!flag3))
			{
				return true;
			}
			if (flag3)
			{
				_lostSince = -1f;
				float num = Vector3.Angle(_normal, val);
				if (num > 0.5f && num < WallClimbPatch2.FollowMaxAngle.Value)
				{
					Vector3 val2 = Vector3.Slerp(_normal, val, 0.2f);
					_normal = ((Vector3)(ref val2)).normalized;
				}
				return true;
			}
			if (_hasPrev && Time.time < _revertUntil)
			{
				WallBasis wallBasis = BuildBasis(_prevNormal);
				if (HoldCast(wallBasis.normal, wallBasis.up, wallBasis.right, out var normal4, out var hits2, out var count2))
				{
					_hasPrev = false;
					_lostSince = -1f;
					SetNormal(normal4, $"REVERT (new wall lost, hold={hits2}/{count2})");
					return true;
				}
			}
			if (_lostSince < 0f)
			{
				_lostSince = Time.time;
			}
			return Time.time - _lostSince <= WallClimbPatch2.GraceSeconds.Value;
		}

		private void SwitchReject(string why)
		{
			if (!(Time.time < _switchLogAt))
			{
				_switchLogAt = Time.time + 1.5f;
				Log("SWITCH rejected: " + why);
			}
		}

		private bool SurfaceContinues(Vector3 moveDir, out float gap)
		{
			//IL_0009: 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_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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			gap = 0f;
			Vector3 val = Eye + moveDir * WallClimbPatch2.EdgeReach.Value;
			if (!Cast(val, -_normal, WallClimbPatch2.HoldRange.Value, SurfaceUse.Hold, out var hit))
			{
				return false;
			}
			if (Vector3.Dot(((RaycastHit)(ref hit)).normal, _normal) < WallClimbPatch2.HoldMinDot.Value)
			{
				return false;
			}
			gap = Vector3.Dot(((RaycastHit)(ref hit)).point - val, -_normal);
			return true;
		}

		private bool EdgeWrapProbe(Vector3 moveDir, out Vector3 normal, out string what)
		{
			//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_002a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00df: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			normal = Vector3.zero;
			what = "?";
			float value = WallClimbPatch2.EdgeReach.Value;
			float value2 = WallClimbPatch2.EdgeDepth.Value;
			Vector3 origin = Eye + moveDir * (value + value2) - _normal * value2;
			if (Cast(origin, -moveDir, value + value2, SurfaceUse.Switch, out var hit) && Vector3.Angle(((RaycastHit)(ref hit)).normal, _normal) >= WallClimbPatch2.SwitchMinAngle.Value)
			{
				normal = ((RaycastHit)(ref hit)).normal;
				what = (((Object)(object)((RaycastHit)(ref hit)).collider != (Object)null) ? ((Object)((RaycastHit)(ref hit)).collider).name : "?");
				return true;
			}
			Vector3 origin2 = Eye + moveDir * (value + value2);
			if (Cast(origin2, -_normal, value + value2, SurfaceUse.Switch, out var hit2) && Vector3.Angle(((RaycastHit)(ref hit2)).normal, _normal) >= WallClimbPatch2.SwitchMinAngle.Value)
			{
				normal = ((RaycastHit)(ref hit2)).normal;
				what = (((Object)(object)((RaycastHit)(ref hit2)).collider != (Object)null) ? ((Object)((RaycastHit)(ref hit2)).collider).name : "?");
				return true;
			}
			return false;
		}

		private bool TrySwitch(bool lost)
		{
			//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_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_00b5: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: 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_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			_edgeWrapped = false;
			if (Time.time < _switchUntil)
			{
				if (((Vector2)(ref _input)).sqrMagnitude > 0.01f)
				{
					SwitchReject($"cooldown {_switchUntil - Time.time:F2}s remaining");
				}
				return false;
			}
			float num = (lost ? (WallClimbPatch2.AttachRange.Value * 2f) : WallClimbPatch2.SwitchRange.Value);
			bool flag = false;
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.zero;
			string text = "?";
			string arg = "?";
			float num2;
			if (!((Object)(object)_rb != (Object)null))
			{
				num2 = 0f;
			}
			else
			{
				Vector3 val3 = Vector3.ProjectOnPlane(_rb.velocity, _basis.normal);
				num2 = ((Vector3)(ref val3)).magnitude;
			}
			float num3 = num2;
			if (!(((Vector2)(ref _input)).sqrMagnitude > 0.01f) && !(num3 > 1f) && !lost)
			{
				return false;
			}
			if (WallClimbPatch2.UseContacts.Value && _altHits > 0 && Fresh(_altStamp))
			{
				flag = true;
				val = _altNormal;
				text = "contact";
				arg = "contact";
				val2 = _basis.up * _input.y + _basis.right * _input.x;
			}
			if (!flag && WallClimbPatch2.EdgeWrap.Value)
			{
				Vector3 val4 = _basis.up * _input.y + _basis.right * _input.x;
				if (((Vector3)(ref val4)).sqrMagnitude < 0.01f && (Object)(object)_rb != (Object)null)
				{
					val4 = Vector3.ProjectOnPlane(_rb.velocity, _basis.normal);
				}
				if (((Vector3)(ref val4)).sqrMagnitude > 0.01f)
				{
					val4 = ((Vector3)(ref val4)).normalized;
					if (!SurfaceContinues(val4, out var _))
					{
						if (EdgeWrapProbe(val4, out Vector3 normal, out string what))
						{
							flag = true;
							val = normal;
							val2 = val4;
							text = "edge";
							arg = what;
							_edgeDir = val4;
							_edgeWrapped = true;
							Log($"EDGE detected ahead={WallClimbPatch2.EdgeReach.Value:F2}m " + "current n=" + Fmt(_normal) + " dir=" + Fmt(val4));
						}
						else
						{
							SwitchReject("EDGE ahead but no surface to wrap onto (dir=" + Fmt(val4) + ")");
						}
					}
				}
			}
			if (!flag)
			{
				Vector3 val5 = _basis.up * _input.y + _basis.right * _input.x;
				Vector3 val6 = (((Object)(object)_rb != (Object)null) ? Vector3.ProjectOnPlane(_rb.velocity, _basis.normal) : Vector3.zero);
				_switchDirs[0] = val5;
				_switchDirs[1] = ((((Vector3)(ref val6)).sqrMagnitude > 1f) ? val6 : Vector3.zero);
				_switchDirs[2] = ((_input.y > 0.01f || lost) ? _basis.up : Vector3.zero);
				for (int i = 0; i < _switchDirs.Length; i++)
				{
					if (flag)
					{
						break;
					}
					Vector3 val7 = _switchDirs[i];
					if (!(((Vector3)(ref val7)).sqrMagnitude < 0.01f))
					{
						val7 = ((Vector3)(ref val7)).normalized;
						if (Cast(Eye, val7, num, SurfaceUse.Switch, out var hit) && !(Vector3.Dot(((RaycastHit)(ref hit)).point - Eye, val7) > num))
						{
							flag = true;
							val = ((RaycastHit)(ref hit)).normal;
							val2 = val7;
							text = i switch
							{
								1 => "velocity", 
								0 => "input", 
								_ => "wallup", 
							};
							arg = (((Object)(object)((RaycastHit)(ref hit)).collider != (Object)null) ? ((Object)((RaycastHit)(ref hit)).collider).name : "?");
						}
					}
				}
			}
			if (!flag)
			{
				if (((Vector2)(ref _input)).sqrMagnitude > 0.01f)
				{
					SwitchReject($"no candidate within {num:F2}m " + $"(in=({_input.x:F0},{_input.y:F0}) alt={_altHits})");
				}
				return false;
			}
			if (Time.time < _noReturnUntil && Vector3.Angle(val, _leftNormal) < WallClimbPatch2.SwitchMinAngle.Value)
			{
				SwitchReject($"just left this face ({_noReturnUntil - Time.time:F2}s)");
				return false;
			}
			float num4 = Vector3.Angle(_normal, val);
			if (num4 < WallClimbPatch2.SwitchMinAngle.Value)
			{
				SwitchReject($"angle={num4:F0}deg < MinAngle " + $"{WallClimbPatch2.SwitchMinAngle.Value:F0} (via {text})");
				return false;
			}
			if (num4 > WallClimbPatch2.SwitchMaxAngle.Value)
			{
				SwitchReject($"angle={num4:F0}deg > MaxAngle " + $"{WallClimbPatch2.SwitchMaxAngle.Value:F0} (via {text})");
				return false;
			}
			bool flag2 = ((Vector3)(ref val2)).sqrMagnitude > 0.01f && Vector3.Dot(val, ((Vector3)(ref val2)).normalized) < 0f;
			Vector3 val8 = (_leftNormal = (_prevNormal = _normal));
			_noReturnUntil = Time.time + WallClimbPatch2.SwitchCooldown.Value * 3f;
			_hasPrev = true;
			_revertUntil = Time.time + WallClimbPatch2.SwitchRevertWindow.Value;
			_switchUntil = Time.time + WallClimbPatch2.SwitchCooldown.Value * (flag2 ? 2f : 1f);
			_lostSince = -1f;
			_altHits = 0;
			if (WallClimbPatch2.CarryVelocity.Value)
			{
				_carry = Quaternion.FromToRotation(val8, val);
				_hasCarry = true;
			}
			if (_edgeWrapped)
			{
				_edgeUntil = Time.time + WallClimbPatch2.EdgeWindow.Value;
				_edgeAssistPending = WallClimbPatch2.EdgeAssist.Value > 0f;
			}
			SetNormal(val, string.Format("SWITCH diff={0:F0}deg {1} ", num4, flag2 ? "inner" : "outer") + $"via={text} lost={lost} to '{arg}'");
			if (_edgeWrapped)
			{
				Log($"EDGE wrapped to n={Fmt(val)} diff={num4:F0}deg " + (flag2 ? "concave" : "convex"));
				_edgeWrapped = false;
			}
			return true;
		}

		private void SetNormal(Vector3 n, string? reason)
		{
			//IL_0002: 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_0016: 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_004e: 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_007a: 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_009c: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			_normal = n;
			if (reason != null)
			{
				WallBasis b = BuildBasis(n);
				Log(reason);
				Log("BASIS n=" + Fmt(b.normal) + " up=" + Fmt(b.up) + " right=" + Fmt(b.right) + " fwd=" + Fmt(b.forward) + " " + $"upDotN={Vector3.Dot(b.up, b.normal):F3} " + $"rightDotN={Vector3.Dot(b.right, b.normal):F3}");
				float num = Vector3.Angle(Vector3.up, TargetUpFor(b));
				Log($"CAMERA mode={WallClimbPatch2.CameraMode.Value} " + $"targetUp={Fmt(TargetUpFor(b))} tilt={num:F0}deg " + $"blendFrom={Vector3.Angle(_viewNormal, n):F0}deg");
			}
		}

		private bool FullBody(Vector3 dir)
		{
			//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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00ae: 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_00e2: 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_00e8: 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_00f1: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_014d: 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_0158: 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)
			if (!WallClimbPatch2.RequireFullBody.Value)
			{
				return true;
			}
			float value = WallClimbPatch2.AttachRange.Value;
			float num = Mathf.Max(0f, WallClimbPatch2.CastBackOff.Value);
			float num2 = WallClimbPatch2.CastRadius.Value * 0.6f;
			Vector3 position = ((Component)this).transform.position;
			float[] array = new float[2]
			{
				WallClimbPatch2.BodyLow.Value,
				WallClimbPatch2.BodyHigh.Value
			};
			RaycastHit val = default(RaycastHit);
			foreach (float num3 in array)
			{
				if (!Physics.SphereCast(position + Vector3.up * num3 - dir * num, num2, dir, ref val, value + num, LayerMask.op_Implicit(_mask), (QueryTriggerInteraction)1))
				{
					return false;
				}
			}
			Vector3 val2 = Vector3.Cross(Vector3.up, dir);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref normalized)).sqrMagnitude > 0.01f)
			{
				float value2 = WallClimbPatch2.BodyWidth.Value;
				float[] array2 = new float[2]
				{
					0f - value2,
					value2
				};
				foreach (float num4 in array2)
				{
					if (!Physics.SphereCast(Eye + normalized * num4 - dir * num, num2, dir, ref val, value + num, LayerMask.op_Implicit(_mask), (QueryTriggerInteraction)1))
					{
						return false;
					}
				}
			}
			return true;
		}

		private void Attach(Vector3 n)
		{
			//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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: 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)
			_on = true;
			_lostSince = -1f;
			_hasPrev = false;
			_hasCarry = false;
			_restoring = false;
			_holdInfo = "-";
			_leapReadyAt = 0f;
			_leapUntil = 0f;
			_edgeUntil = 0f;
			_edgeWrapped = false;
			_edgeAssistPending = false;
			_surfaceDist = 1f;
			_contactHits = 0;
			_contactStamp = -999f;
			_touchStamp = -999f;
			_altHits = 0;
			_altStamp = -999f;
			_noReturnUntil = 0f;
			_switchUntil = Time.time + WallClimbPatch2.SwitchCooldown.Value;
			_viewNormal = ((Vector3)(ref n)).normalized;
			SetNormal(n, "ATTACHED");
			_basis = BuildBasis(_viewNormal);
			Log($"GRAVITY custom={(((Object)(object)_pc != (Object)null) ? _pc.CustomGravity : (-1f)):F1} " + $"cancel={WallClimbPatch2.CancelGravity.Value} " + $"scale={WallClimbPatch2.GravityCancelScale.Value:F2}");
			if ((Object)(object)_rb != (Object)null)
			{
				_rb.useGravity = false;
				if (!_cdmChanged)
				{
					_savedCdm = _rb.collisionDetectionMode;
					_rb.collisionDetectionMode = (CollisionDetectionMode)2;
					_cdmChanged = true;
				}
			}
			if ((Object)(object)_col != (Object)null && !_matChanged)
			{
				_savedMat = _col.material;
				_col.material = _slipMat;
				_matChanged = true;
			}
		}

		private void Detach(DetachReason reason)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			float num = ((_lostSince < 0f) ? 0f : (Time.time - _lostSince));
			Log($"detaching reason={reason} " + $"lost={num:F2}s/{WallClimbPatch2.GraceSeconds.Value:F2}s " + $"hold={_holdInfo} dist={_surfaceDist:F2} " + $"touch={Fresh(_touchStamp)} n={Fmt(_normal)} " + $"in=({_input.x:F0},{_input.y:F0}) " + "crouch=" + (((Object)(object)_pc != (Object)null) ? _pc.Crouching.ToString() : "?"));
			_on = false;
			_lostSince = -1f;
			_hasPrev = false;
			_hasCarry = false;
			_wantLeap = false;
			_edgeUntil = 0f;
			_edgeWrapped = false;
			_edgeAssistPending = false;
			_blockUntil = Time.time + WallClimbPatch2.DetachCooldown.Value;
			_restoring = true;
			if ((Object)(object)_rb != (Object)null)
			{
				_rb.useGravity = true;
				if (_cdmChanged)
				{
					_rb.collisionDetectionMode = _savedCdm;
					_cdmChanged = false;
				}
				if (_wantJump)
				{
					_wantJump = false;
					Vector3 val = _normal + Vector3.up * 0.5f;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					_rb.AddForce(normalized * WallClimbPatch2.WallJumpForce.Value, (ForceMode)2);
				}
			}
			if (_matChanged && (Object)(object)_col != (Object)null)
			{
				_col.material = _savedMat;
				_matChanged = false;
			}
		}

		private void MoveAxes(Transform cam, out Vector3 axisUp, out Vector3 axisRight, out Vector3 rawF, out Vector3 rawR, out string src)
		{
			//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_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)
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0108: 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_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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_00d5: 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_00dd: 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)
			axisUp = _basis.up;
			axisRight = _basis.right;
			rawF = Vector3.zero;
			rawR = Vector3.zero;
			src = "wall";
			if (!WallClimbPatch2.MoveRelativeToCamera.Value)
			{
				return;
			}
			Vector3 normal = _basis.normal;
			rawF = Vector3.ProjectOnPlane(cam.forward, normal);
			rawR = Vector3.ProjectOnPlane(cam.right, normal);
			Vector3 val = rawF;
			src = "cam";
			if (((Vector3)(ref val)).sqrMagnitude < 0.05f)
			{
				float num = ((Vector3.Dot(cam.forward, normal) > 0f) ? (-1f) : 1f);
				val = Vector3.ProjectOnPlane(cam.up, normal) * num;
				src = "cam.up";
			}
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				axisUp = _basis.up;
				axisRight = _basis.right;
				src = "wall(fallback)";
				return;
			}
			axisUp = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(normal, axisUp);
			axisRight = ((Vector3)(ref val2)).normalized;
			if (WallClimbPatch2.InvertRight.Value)
			{
				axisRight = -axisRight;
			}
		}

		public void Physics(PlayerController pc)
		{
			//IL_0080: 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_0064: 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_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_0095: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_016f: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: 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_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			if (_pc == null)
			{
				_pc = pc;
			}
			if ((Object)(object)_pc == (Object)null)
			{
				return;
			}
			if (WallClimbPatch2.RotateBody.Valu