Decompiled source of Climber Survivor v1.0.0

Climber/Climber.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Climber.Geometry;
using EntityStates;
using KinematicCharacterController;
using ModKit;
using R2API;
using RoR2;
using RoR2.Skills;
using RoR2.UI.MainMenu;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Climber")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c711c7af9d35dd9458109499691a55f1b63b85c1")]
[assembly: AssemblyProduct("Climber")]
[assembly: AssemblyTitle("Climber")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ModKit
{
	public static class EffectLifetime
	{
		public const float Margin = 0.1f;

		public const float Fallback = 2f;

		public const float Negligible = 0.01f;

		public static float Seconds(float statedDuration, float longestParticleLifetime)
		{
			if (statedDuration >= 0f)
			{
				return statedDuration + 0.1f;
			}
			if (longestParticleLifetime > 0.01f)
			{
				return longestParticleLifetime + 0.1f;
			}
			return 2f;
		}
	}
	public static class KitFormat
	{
		public static string Percent(float coefficient)
		{
			return ((int)Math.Round((double)coefficient * 100.0, MidpointRounding.AwayFromZero)).ToString(CultureInfo.InvariantCulture) + "%";
		}

		public static string BonusPercent(float multiplier)
		{
			return "+" + Percent(multiplier - 1f);
		}

		public static string Seconds(float seconds)
		{
			return Number(seconds) + "s";
		}

		public static string SecondsWord(float seconds)
		{
			string text = Number(seconds);
			return text + ((text == "1") ? " second" : " seconds");
		}

		public static string Number(float value)
		{
			return value.ToString("0.##", CultureInfo.InvariantCulture);
		}

		public static string Damage(string text)
		{
			return "<style=cIsDamage>" + text + "</style>";
		}

		public static string Utility(string text)
		{
			return "<style=cIsUtility>" + text + "</style>";
		}

		public static string Health(string text)
		{
			return "<style=cIsHealth>" + text + "</style>";
		}
	}
	public static class EffectSpawn
	{
		public static void At(GameObject prefab, Vector3 position, float scale = 1f)
		{
			//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)
			WithRotation(prefab, position, Quaternion.identity, scale);
		}

		public static void Facing(GameObject prefab, Vector3 position, Vector3 forward, float scale = 1f)
		{
			//IL_0022: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab == (Object)null) && !(((Vector3)(ref forward)).sqrMagnitude < 0.001f))
			{
				WithRotation(prefab, position, Util.QuaternionSafeLookRotation(forward), scale);
			}
		}

		public static void WithRotation(GameObject prefab, Vector3 position, Quaternion rotation, float scale = 1f)
		{
			//IL_0064: 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_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_0028: 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_0030: 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_003e: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			if ((Object)(object)prefab.GetComponent<EffectComponent>() != (Object)null)
			{
				EffectData data = new EffectData
				{
					origin = position,
					rotation = rotation,
					scale = scale
				};
				Mark(ref data, "useNonDefaultRotationFlag");
				Mark(ref data, "useNonDefaultScaleFlag");
				EffectManager.SpawnEffect(prefab, data, false);
			}
			else
			{
				GameObject val = Object.Instantiate<GameObject>(prefab, position, rotation);
				if (scale != 1f)
				{
					Transform transform = val.transform;
					transform.localScale *= scale;
				}
				Object.Destroy((Object)(object)val, LifetimeOf(val));
			}
		}

		public static void Mark(ref EffectData data, string fieldName)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			FieldInfo field = typeof(EffectData).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(field == null))
			{
				object obj = data;
				field.SetValue(obj, true);
				data = (EffectData)obj;
			}
		}

		private static float LifetimeOf(GameObject instance)
		{
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			float statedDuration = -1f;
			DestroyOnTimer component = instance.GetComponent<DestroyOnTimer>();
			if ((Object)(object)component != (Object)null)
			{
				statedDuration = component.duration;
			}
			float num = 0f;
			ParticleSystem[] componentsInChildren = instance.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val in componentsInChildren)
			{
				MainModule main = val.main;
				float duration = ((MainModule)(ref main)).duration;
				MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
				float num2 = duration + ((MinMaxCurve)(ref startLifetime)).constantMax;
				if (num2 > num)
				{
					num = num2;
				}
			}
			return EffectLifetime.Seconds(statedDuration, num);
		}
	}
}
namespace Climber
{
	public static class AttackVfx
	{
		private static bool _tried;

		private static bool _logged;

		private static GameObject _hammerSwing;

		private static GameObject _hammerImpact;

		private static GameObject _pitonSwing;

		private static GameObject _pitonImpact;

		private static GameObject _pitonTracer;

		private static GameObject _spearMuzzle;

		private static GameObject _spearWorldImpact;

		private static GameObject _spearFleshImpact;

		public static void HammerSwing(Vector3 swingOrigin, Vector3 forward)
		{
			//IL_0007: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			Ensure();
			Quaternion rotation = Util.QuaternionSafeLookRotation(forward) * Quaternion.Euler(90f, -90f, 0f);
			SpawnWithRotation(_hammerSwing, swingOrigin, rotation, 1.35f);
		}

		public static void HammerImpact(Vector3 impactPoint, Vector3 normal)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Ensure();
			Quaternion rotation = Util.QuaternionSafeLookRotation(normal);
			SpawnWithRotation(_hammerImpact, impactPoint, rotation, 1.15f);
		}

		public static void Hammer(Vector3 swingOrigin, Vector3 forward, Vector3 impactPoint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			HammerSwing(swingOrigin, forward);
			HammerImpact(impactPoint, Vector3.up);
		}

		public static void PitonTrajectory(Vector3 from, Vector3 to)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Ensure();
			if (!((Object)(object)_pitonTracer == (Object)null))
			{
				Vector3 val = to - from;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.05f))
				{
					EffectData data = new EffectData();
					data.origin = to;
					data.start = from;
					EffectSpawn.Mark(ref data, "useNonDefaultStartFlag");
					EffectManager.SpawnEffect(_pitonTracer, data, false);
				}
			}
		}

		public static void PitonSwing(Vector3 swingOrigin, Vector3 forward)
		{
			//IL_000c: 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)
			Ensure();
			Spawn(_pitonSwing, swingOrigin, forward, 1.15f);
		}

		public static void PitonImpact(Vector3 impactPoint, Vector3 normal)
		{
			//IL_0021: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			Ensure();
			Quaternion rotation = ((((Vector3)(ref normal)).sqrMagnitude > 0.001f) ? Util.QuaternionSafeLookRotation(normal) : Util.QuaternionSafeLookRotation(Vector3.up));
			SpawnWithRotation(_pitonImpact, impactPoint, rotation, 1.2f);
		}

		public static void Piton(Vector3 swingOrigin, Vector3 impactPoint, Vector3 forward, Vector3 normal)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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)
			PitonTrajectory(swingOrigin, impactPoint);
			PitonSwing(swingOrigin, forward);
			PitonImpact(impactPoint, normal);
		}

		public static void Piton(Vector3 swingOrigin, Vector3 impactPoint, Vector3 forward)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			Piton(swingOrigin, impactPoint, forward, forward);
		}

		public static void SpearThrow(Vector3 muzzle, Vector3 forward)
		{
			//IL_000c: 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)
			Ensure();
			Spawn(_spearMuzzle, muzzle, forward, 1.1f);
		}

		public static void SpearWorldImpact(Vector3 point, Vector3 normal)
		{
			//IL_0021: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			Ensure();
			Quaternion rotation = ((((Vector3)(ref normal)).sqrMagnitude > 0.001f) ? Util.QuaternionSafeLookRotation(normal) : Util.QuaternionSafeLookRotation(Vector3.up));
			SpawnWithRotation(_spearWorldImpact, point, rotation, 1.5f);
		}

		public static void SpearFleshImpact(Vector3 point, Vector3 forward)
		{
			//IL_000c: 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)
			Ensure();
			Spawn(_spearFleshImpact, point, forward, 1.25f);
		}

		private static void Ensure()
		{
			if (!_tried || !((Object)(object)_hammerSwing != (Object)null) || !((Object)(object)_hammerImpact != (Object)null) || !((Object)(object)_pitonSwing != (Object)null) || !((Object)(object)_pitonImpact != (Object)null) || !((Object)(object)_pitonTracer != (Object)null) || !((Object)(object)_spearMuzzle != (Object)null) || !((Object)(object)_spearWorldImpact != (Object)null) || !((Object)(object)_spearFleshImpact != (Object)null))
			{
				_tried = true;
				_hammerSwing = GameAssets.Load<GameObject>(RoR2_Base_Loader.LoaderSwingBasic_prefab);
				_hammerImpact = GameAssets.Load<GameObject>(RoR2_Base_Loader.OmniImpactVFXLoader_prefab);
				_pitonSwing = GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.OmniImpactVFXSlash_prefab);
				_pitonImpact = GameAssets.Load<GameObject>(RoR2_Base_Loader.ImpactLoaderFistSmall_prefab);
				_pitonTracer = GameAssets.Load<GameObject>(RoR2_Base_Toolbot.TracerToolbotNails_prefab) ?? GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.TracerSmokeLine_prefab);
				_spearMuzzle = GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.MuzzleflashSmokeRing_prefab) ?? GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.OmniImpactVFXSlash_prefab);
				_spearWorldImpact = GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.OmniImpactVFXSlash_prefab);
				_spearFleshImpact = GameAssets.Load<GameObject>(RoR2_Base_Common_VFX.OmniImpactVFXSlash_prefab);
				if (!_logged)
				{
					_logged = true;
					Debug.Log((object)("Climber attack effects hammerSwing=" + ((Object)(object)_hammerSwing != (Object)null) + " hammerImpact=" + ((Object)(object)_hammerImpact != (Object)null) + " pitonSwing=" + ((Object)(object)_pitonSwing != (Object)null) + " pitonImpact=" + ((Object)(object)_pitonImpact != (Object)null) + " pitonTracer=" + ((Object)(object)_pitonTracer != (Object)null) + " spearMuzzle=" + ((Object)(object)_spearMuzzle != (Object)null) + " spearWorldImpact=" + ((Object)(object)_spearWorldImpact != (Object)null) + " spearFleshImpact=" + ((Object)(object)_spearFleshImpact != (Object)null)));
				}
			}
		}

		private static void Spawn(GameObject prefab, Vector3 position, Vector3 forward, float scale)
		{
			//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)
			EffectSpawn.Facing(prefab, position, forward, scale);
		}

		private static void SpawnWithRotation(GameObject prefab, Vector3 position, Quaternion rotation, float scale)
		{
			//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)
			EffectSpawn.WithRotation(prefab, position, rotation, scale);
		}
	}
	public class ClimbAnchor : MonoBehaviour, IInteractable
	{
		public enum Kind
		{
			Piton,
			Rebar
		}

		public const int FallbackMaxPitons = 1;

		private const int FallbackMaxRebars = 1;

		private const float RecallGrace = 0.25f;

		public const float LaunchSpeed = 28f;

		private static readonly OwnerBuckets<CharacterBody, ClimbAnchor> PitonsByOwner = new OwnerBuckets<CharacterBody, ClimbAnchor>((CharacterBody owner) => (Object)(object)owner == (Object)null);

		private static readonly OwnerBuckets<CharacterBody, ClimbAnchor> RebarsByOwner = new OwnerBuckets<CharacterBody, ClimbAnchor>((CharacterBody owner) => (Object)(object)owner == (Object)null);

		private static bool _loggedMesh;

		private static readonly Dictionary<Mesh, MeshProfile> ProfileCache = new Dictionary<Mesh, MeshProfile>();

		private static Mesh _fallbackMesh;

		private List<ClimbAnchor> _list;

		private Kind _kind;

		private CharacterBody _owner;

		private float _recallAt;

		private bool _recalled;

		public static int MaxPitons(CharacterBody body)
		{
			GenericSkill val = PitonSlot(body);
			return (!((Object)(object)val != (Object)null)) ? 1 : Mathf.Max(1, val.maxStock);
		}

		private static GenericSkill PitonSlot(CharacterBody body)
		{
			SkillLocator val = (((Object)(object)body != (Object)null) ? body.skillLocator : null);
			return ((Object)(object)val != (Object)null) ? val.secondary : null;
		}

		public static int MaxRebars(CharacterBody body)
		{
			GenericSkill val = SpearSlot(body);
			return (!((Object)(object)val != (Object)null)) ? 1 : Mathf.Max(1, val.maxStock);
		}

		private static GenericSkill SpearSlot(CharacterBody body)
		{
			SkillLocator val = (((Object)(object)body != (Object)null) ? body.skillLocator : null);
			return ((Object)(object)val != (Object)null) ? val.special : null;
		}

		public static void Place(Kind kind, Vector3 point, Vector3 direction, CharacterBody owner = null)
		{
			//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_0004: Unknown result type (might be due to invalid IL or missing references)
			Place(kind, point, direction, Vector3.zero, owner);
		}

		public static void Place(Kind kind, Vector3 point, Vector3 direction, Vector3 normal, CharacterBody owner = null)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0085: 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_00ad: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_0117: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref direction)).sqrMagnitude < 0.001f)
			{
				direction = Vector3.forward;
			}
			((Vector3)(ref direction)).Normalize();
			RebarPin.EnsureLoaded();
			Mesh val = ((kind == Kind.Piton) ? WkMesh.Piton : WkMesh.Rebar);
			if ((Object)(object)val == (Object)null)
			{
				val = RebarPin.Mesh;
			}
			Material val2 = ((kind == Kind.Piton) ? WkTexture.Piton : WkTexture.Spear);
			Material val3 = (((Object)(object)val2 != (Object)null) ? val2 : RebarPin.Material);
			if ((Object)(object)val == (Object)null)
			{
				val = FallbackMesh();
			}
			CalculateTransform(kind, point, direction, normal, val, out var position, out var rotation, out var scale, out var _, out var stickOutDir);
			GameObject val4 = new GameObject((kind == Kind.Piton) ? "ClimberPitonAnchor" : "ClimberRebarPin");
			val4.layer = LayerIndex.defaultLayer.intVal;
			val4.transform.SetPositionAndRotation(position, rotation);
			if ((Object)(object)val != (Object)null)
			{
				GameObject val5 = new GameObject("Visual");
				val5.layer = val4.layer;
				val5.transform.SetParent(val4.transform, false);
				val5.transform.localScale = Vector3.one * scale;
				MeshFilter val6 = val5.AddComponent<MeshFilter>();
				val6.sharedMesh = val;
				MeshRenderer val7 = val5.AddComponent<MeshRenderer>();
				if ((Object)(object)val3 != (Object)null)
				{
					((Renderer)val7).sharedMaterial = val3;
				}
				((Renderer)val7).shadowCastingMode = (ShadowCastingMode)1;
				Highlight val8 = val4.AddComponent<Highlight>();
				val8.targetRenderer = (Renderer)(object)val7;
				val8.highlightColor = (HighlightColor)0;
				val8.strength = 1f;
			}
			GameObject val9 = new GameObject("Interact");
			val9.layer = val4.layer;
			val9.transform.SetParent(val4.transform, true);
			val9.transform.position = point + stickOutDir * 0.85f;
			SphereCollider val10 = val9.AddComponent<SphereCollider>();
			((Collider)val10).isTrigger = true;
			val10.radius = ((kind == Kind.Piton) ? 1.8f : 2.4f);
			ClimbAnchor climbAnchor = val4.AddComponent<ClimbAnchor>();
			climbAnchor._kind = kind;
			EntityLocator val11 = val9.AddComponent<EntityLocator>();
			val11.entity = val4;
			List<ClimbAnchor> list = ((kind == Kind.Piton) ? PitonsByOwner : RebarsByOwner).For(owner);
			int num = ((kind == Kind.Piton) ? MaxPitons(owner) : MaxRebars(owner));
			Prune(list);
			while (list.Count >= num)
			{
				ClimbAnchor climbAnchor2 = list[0];
				list.RemoveAt(0);
				if ((Object)(object)climbAnchor2 != (Object)null)
				{
					climbAnchor2.Recall();
				}
			}
			list.Add(climbAnchor);
			climbAnchor._list = list;
			if (kind == Kind.Rebar && (Object)(object)owner != (Object)null)
			{
				climbAnchor._owner = owner;
				GenericSkill val12 = SpearSlot(owner);
				float num2 = (((Object)(object)val12 != (Object)null) ? val12.CalculateFinalRechargeInterval() : 7f);
				climbAnchor._recallAt = Time.time + Mathf.Max(0.5f, num2) + 0.25f;
			}
			if (!_loggedMesh)
			{
				_loggedMesh = true;
				Debug.Log((object)("Climber anchor placed kind=" + kind.ToString() + " mesh=" + (((Object)(object)val != (Object)null) ? ((Object)val).name : "none") + " mat=" + ((Object)(object)val3 != (Object)null)));
			}
		}

		public static void CalculateTransform(Kind kind, Vector3 point, Vector3 direction, Vector3 normal, Mesh mesh, out Vector3 position, out Quaternion rotation, out float scale, out Vector3 stickInDir, out Vector3 stickOutDir)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			AnchorPlacement.Solve(kind == Kind.Piton, point, direction, normal, ProfileFor(mesh), out position, out rotation, out scale, out stickInDir, out stickOutDir);
		}

		private static MeshProfile ProfileFor(Mesh mesh)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mesh == (Object)null)
			{
				return default(MeshProfile);
			}
			if (ProfileCache.TryGetValue(mesh, out var value))
			{
				return value;
			}
			Bounds bounds = mesh.bounds;
			MeshProfile meshProfile = MeshProfile.From(((Bounds)(ref bounds)).size, ((Bounds)(ref bounds)).center, mesh.vertices);
			ProfileCache[mesh] = meshProfile;
			return meshProfile;
		}

		public static Mesh FallbackMesh()
		{
			if ((Object)(object)_fallbackMesh != (Object)null)
			{
				return _fallbackMesh;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			_fallbackMesh = val.GetComponent<MeshFilter>().sharedMesh;
			Object.Destroy((Object)(object)val);
			return _fallbackMesh;
		}

		public static float DisplayScale(Mesh mesh, Kind kind)
		{
			MeshProfile meshProfile = ProfileFor(mesh);
			if (!meshProfile.HasMesh)
			{
				return 1f;
			}
			return AnchorPlacement.ScaleForLength(meshProfile.Length, kind == Kind.Piton);
		}

		private static void Prune(List<ClimbAnchor> list)
		{
			for (int num = list.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)list[num] == (Object)null)
				{
					list.RemoveAt(num);
				}
			}
		}

		private void OnDestroy()
		{
			_list?.Remove(this);
		}

		public string GetContextString(Interactor activator)
		{
			string text = ((_kind == Kind.Piton) ? "CLIMBER_LAUNCH_CONTEXT_PITON" : "CLIMBER_LAUNCH_CONTEXT_SPEAR");
			string text2 = Language.GetString(text);
			return (!string.IsNullOrEmpty(text2) && !(text2 == text)) ? text2 : ((_kind == Kind.Piton) ? "Launch off piton" : "Launch off Rho Spear");
		}

		public Interactability GetInteractability(Interactor activator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (Interactability)2;
		}

		public void Recall()
		{
			if (_recalled)
			{
				return;
			}
			_recalled = true;
			if (_kind == Kind.Rebar && (Object)(object)_owner != (Object)null)
			{
				GenericSkill val = SpearSlot(_owner);
				if ((Object)(object)val != (Object)null && val.stock < val.maxStock)
				{
					val.AddOneStock();
				}
			}
			_list?.Remove(this);
			if ((Object)(object)this != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void Update()
		{
			if (!_recalled && !(_recallAt <= 0f) && !(Time.time < _recallAt))
			{
				Recall();
			}
		}

		public void OnInteractionBegin(Interactor activator)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)activator == (Object)null))
			{
				KinematicCharacterMotor component = ((Component)activator).GetComponent<KinematicCharacterMotor>();
				if ((Object)(object)component != (Object)null)
				{
					component.ForceUnground(0.12f);
				}
				CharacterMotor component2 = ((Component)activator).GetComponent<CharacterMotor>();
				if (!((Object)(object)component2 == (Object)null))
				{
					Vector3 velocity = component2.velocity;
					velocity.y = 28f;
					component2.velocity = velocity;
				}
			}
		}

		public bool ShouldIgnoreSpherecastForInteractibility(Interactor activator)
		{
			return false;
		}

		public bool ShouldShowOnScanner()
		{
			return false;
		}

		public bool ShouldProximityHighlight()
		{
			return true;
		}

		public bool ShouldSpawnLesserInteractionRewards(Interactor activator)
		{
			return false;
		}
	}
	public class ClimberWeaponVisual : MonoBehaviour
	{
		public bool hideWhenSpecialEmpty;

		public bool ignoreOverlays = true;

		private MeshRenderer _renderer;

		private CharacterModel _characterModel;

		private CharacterBody _body;

		private GenericSkill _specialSlot;

		private bool _registered;

		private void Awake()
		{
			_renderer = ((Component)this).GetComponent<MeshRenderer>();
			_characterModel = ((Component)this).GetComponentInParent<CharacterModel>();
		}

		private void Start()
		{
			if ((Object)(object)_renderer != (Object)null)
			{
				((Renderer)_renderer).enabled = true;
			}
			EnsureRegistered();
		}

		private void LateUpdate()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			if ((Object)(object)_renderer == (Object)null)
			{
				return;
			}
			bool flag = true;
			if ((Object)(object)_characterModel != (Object)null)
			{
				if ((int)_characterModel.visibility == 0)
				{
					flag = false;
				}
				if (!_registered)
				{
					EnsureRegistered();
				}
			}
			if (flag && hideWhenSpecialEmpty)
			{
				GenericSkill specialSlot = GetSpecialSlot();
				if ((Object)(object)specialSlot != (Object)null && specialSlot.stock <= 0)
				{
					flag = false;
				}
			}
			if (((Renderer)_renderer).enabled != flag)
			{
				((Renderer)_renderer).enabled = flag;
			}
		}

		private GenericSkill GetSpecialSlot()
		{
			if ((Object)(object)_specialSlot != (Object)null)
			{
				return _specialSlot;
			}
			if ((Object)(object)_body == (Object)null)
			{
				if ((Object)(object)_characterModel != (Object)null && (Object)(object)_characterModel.body != (Object)null)
				{
					_body = _characterModel.body;
				}
				else
				{
					_body = ((Component)this).GetComponentInParent<CharacterBody>();
				}
			}
			if ((Object)(object)_body != (Object)null && (Object)(object)_body.skillLocator != (Object)null)
			{
				_specialSlot = _body.skillLocator.special;
			}
			return _specialSlot;
		}

		private void EnsureRegistered()
		{
			//IL_008c: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_characterModel == (Object)null || (Object)(object)_renderer == (Object)null)
			{
				return;
			}
			RendererInfo[] baseRendererInfos = _characterModel.baseRendererInfos;
			if (baseRendererInfos == null)
			{
				return;
			}
			for (int i = 0; i < baseRendererInfos.Length; i++)
			{
				if ((Object)(object)baseRendererInfos[i].renderer == (Object)(object)_renderer)
				{
					_registered = true;
					return;
				}
			}
			List<RendererInfo> list = new List<RendererInfo>(baseRendererInfos);
			list.Add(new RendererInfo
			{
				renderer = (Renderer)(object)_renderer,
				defaultMaterial = ((Renderer)_renderer).sharedMaterial,
				defaultShadowCastingMode = (ShadowCastingMode)1,
				ignoreOverlays = ignoreOverlays
			});
			_characterModel.baseRendererInfos = list.ToArray();
			_registered = true;
		}
	}
	public static class EnemyFilter
	{
		public static int TeamOf(CharacterBody body)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected I4, but got Unknown
			if ((Object)(object)body == (Object)null || (Object)(object)body.teamComponent == (Object)null)
			{
				return -1;
			}
			return (int)body.teamComponent.teamIndex;
		}

		public static HurtBox Resolve(Collider collider, CharacterBody attacker, HashSet<HealthComponent> seen)
		{
			return Resolve(collider, ((Object)(object)attacker != (Object)null) ? ((Component)attacker).gameObject : null, TeamOf(attacker), seen);
		}

		public static HurtBox Resolve(Collider collider, GameObject attacker, int attackerTeam, HashSet<HealthComponent> seen)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected I4, but got Unknown
			if ((Object)(object)collider == (Object)null)
			{
				return null;
			}
			HurtBox val = ((Component)collider).GetComponent<HurtBox>() ?? ((Component)collider).GetComponentInParent<HurtBox>();
			if ((Object)(object)val == (Object)null || (Object)(object)val.healthComponent == (Object)null)
			{
				return null;
			}
			if ((Object)(object)attacker != (Object)null && (Object)(object)((Component)val.healthComponent).gameObject == (Object)(object)attacker)
			{
				return null;
			}
			if (!TargetFilter.IsHostile(attackerTeam, (int)val.teamIndex))
			{
				return null;
			}
			if (seen != null && !seen.Add(val.healthComponent))
			{
				return null;
			}
			return val;
		}

		public static bool IsCreature(Collider collider)
		{
			if ((Object)(object)collider == (Object)null)
			{
				return false;
			}
			return (Object)(object)((Component)collider).GetComponent<HurtBox>() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent<HurtBox>() != (Object)null;
		}

		public static void CollectFromCast(RaycastHit[] hits, int count, CharacterBody attacker, HashSet<HealthComponent> seen, List<HurtBox> into)
		{
			for (int i = 0; i < count; i++)
			{
				HurtBox val = Resolve(((RaycastHit)(ref hits[i])).collider, attacker, seen);
				if ((Object)(object)val != (Object)null)
				{
					into.Add(val);
				}
			}
		}

		public static void CollectFromOverlap(Collider[] colliders, int count, CharacterBody attacker, HashSet<HealthComponent> seen, List<HurtBox> into)
		{
			for (int i = 0; i < count; i++)
			{
				HurtBox val = Resolve(colliders[i], attacker, seen);
				if ((Object)(object)val != (Object)null)
				{
					into.Add(val);
				}
			}
		}

		public static int CountInCast(RaycastHit[] hits, int count, CharacterBody attacker, bool stopAtFirst = false)
		{
			if (stopAtFirst)
			{
				for (int i = 0; i < count; i++)
				{
					if ((Object)(object)Resolve(((RaycastHit)(ref hits[i])).collider, attacker, null) != (Object)null)
					{
						return 1;
					}
				}
				return 0;
			}
			HashSet<HealthComponent> seen = new HashSet<HealthComponent>();
			int num = 0;
			for (int j = 0; j < count; j++)
			{
				if ((Object)(object)Resolve(((RaycastHit)(ref hits[j])).collider, attacker, seen) != (Object)null)
				{
					num++;
				}
			}
			return num;
		}
	}
	public static class GameAssets
	{
		public static T Load<T>(string id) where T : Object
		{
			//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)
			if (string.IsNullOrEmpty(id))
			{
				return default(T);
			}
			try
			{
				return Addressables.LoadAssetAsync<T>((object)id).WaitForCompletion();
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("Climber could not load " + id + ": " + ex.Message));
				return default(T);
			}
		}
	}
	public class GripController : MonoBehaviour
	{
		public const float MaxGrip = 100f;

		private GripState _state = GripState.Full;

		private CharacterBody _body;

		private CharacterMotor _motor;

		private bool _slipPushed;

		public float Current
		{
			get
			{
				return _state.Current;
			}
			set
			{
				_state.Current = value;
			}
		}

		public float SlipUntil
		{
			get
			{
				return _state.SlipUntil;
			}
			set
			{
				_state.SlipUntil = value;
			}
		}

		public static GripController Local { get; private set; }

		public float Max => 100f;

		public bool Slipping => _state.IsSlipping(Time.time);

		private void Awake()
		{
			_body = ((Component)this).GetComponent<CharacterBody>();
			_motor = ((Component)this).GetComponent<CharacterMotor>();
		}

		private void FixedUpdate()
		{
			//IL_0088: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_body == (Object)null || !_body.hasEffectiveAuthority)
			{
				return;
			}
			if (_body.isPlayerControlled)
			{
				Local = this;
			}
			if (Slipping)
			{
				_state.Tick(0f, grounded: false, Time.time);
				if (!_slipPushed && (Object)(object)_motor != (Object)null)
				{
					Vector3 velocity = _motor.velocity;
					velocity.x *= 0.45f;
					velocity.z *= 0.45f;
					if (velocity.y > 0f)
					{
						velocity.y *= 0.35f;
					}
					_motor.velocity = velocity;
					_slipPushed = true;
				}
			}
			else
			{
				_slipPushed = false;
				bool grounded = (Object)(object)_motor != (Object)null && _motor.isGrounded;
				_state.Tick(Time.fixedDeltaTime, grounded, Time.time);
			}
		}

		public bool TrySpend(float cost)
		{
			bool flag = _state.TrySpend(cost, Time.time);
			if (!flag)
			{
				_slipPushed = false;
			}
			return flag;
		}

		public void Restore(float amount)
		{
			_state.Restore(amount, Time.time);
		}

		private void OnGUI()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0103: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Local != (Object)(object)this) && !((Object)(object)_body == (Object)null) && _body.isPlayerControlled)
			{
				float num = ((float)Screen.width - 280f) * 0.5f;
				float num2 = (float)Screen.height - 86f;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(num, num2, 280f, 18f);
				GUI.color = new Color(0.08f, 0.08f, 0.07f, 0.85f);
				GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
				float num3 = Mathf.Clamp01(_state.Fraction);
				GUI.color = (Slipping ? new Color(0.55f, 0.18f, 0.14f, 1f) : new Color(0.9f, 0.9f, 0.82f, 1f));
				GUI.DrawTexture(new Rect(num + 2f, num2 + 2f, 276f * num3, 14f), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = Color.white;
				string text = (Slipping ? "SLIP" : ("GRIP  " + Mathf.CeilToInt(Current)));
				GUI.Label(new Rect(num, num2 - 18f, 280f, 18f), text);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Local == (Object)(object)this)
			{
				Local = null;
			}
		}
	}
	public static class Icons
	{
		public static Sprite Hammer { get; set; }

		public static Sprite Piton { get; set; }

		public static Sprite Jump { get; set; }

		public static Sprite Rebar { get; set; }

		public static Sprite Portrait { get; set; }

		public static void Build()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			Hammer = LoadResourceSprite("icons.hammer.png") ?? TryLoadFile("hammer.png") ?? Glyph(new Color(0.93f, 0.91f, 0.84f), new Color(0.35f, 0.22f, 0.14f), DrawHammer);
			Piton = LoadResourceSprite("icons.piton.png") ?? TryLoadFile("piton.png") ?? Glyph(new Color(0.93f, 0.91f, 0.84f), new Color(0.22f, 0.2f, 0.18f), DrawPiton);
			Jump = LoadResourceSprite("icons.jump.png") ?? TryLoadFile("jump.png") ?? Glyph(new Color(0.18f, 0.22f, 0.26f), new Color(0.9f, 0.95f, 0.92f), DrawJump);
			Rebar = LoadResourceSprite("icons.spear.png") ?? TryLoadFile("spear.png") ?? TryLoadFile("rebar.png") ?? Glyph(new Color(0.93f, 0.91f, 0.84f), new Color(0.45f, 0.16f, 0.14f), DrawRebar);
			Portrait = LoadResourceSprite("icons.climber.png") ?? TryLoadFile("climber.png") ?? TryLoadFile("icon.png") ?? Glyph(new Color(0.18f, 0.22f, 0.26f), new Color(0.93f, 0.91f, 0.84f), DrawPortrait);
		}

		private static Sprite LoadResourceSprite(string resourceName)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0086: 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)
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
				if (stream == null)
				{
					return null;
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				byte[] array = memoryStream.ToArray();
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, array))
				{
					return null;
				}
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).height);
			}
			catch
			{
				return null;
			}
		}

		private static Sprite TryLoadFile(string filename)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_00ab: 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)
			try
			{
				string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
				string[] array = new string[2]
				{
					Path.Combine(path, "icons", filename),
					Path.Combine(path, filename)
				};
				string[] array2 = array;
				foreach (string path2 in array2)
				{
					if (File.Exists(path2))
					{
						byte[] array3 = File.ReadAllBytes(path2);
						Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
						if (ImageConversion.LoadImage(val, array3))
						{
							((Texture)val).filterMode = (FilterMode)1;
							((Texture)val).wrapMode = (TextureWrapMode)1;
							return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).height);
						}
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static Sprite Glyph(Color paper, Color ink, Action<Color[], int, Color, Color> draw)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_006a: 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)
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = paper;
			}
			draw(array, 64, paper, ink);
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)0;
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
		}

		private static void Plot(Color[] pixels, int n, int x, int y, Color ink)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if ((uint)x < (uint)n && (uint)y < (uint)n)
			{
				pixels[y * n + x] = ink;
			}
		}

		private static void Disc(Color[] pixels, int n, int cx, int cy, int r, Color ink)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -r; i <= r; i++)
			{
				for (int j = -r; j <= r; j++)
				{
					if (j * j + i * i <= r * r)
					{
						Plot(pixels, n, cx + j, cy + i, ink);
					}
				}
			}
		}

		private static void DrawPiton(Color[] pixels, int n, Color paper, Color ink)
		{
			//IL_000a: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 8; i < 52; i++)
			{
				Plot(pixels, n, i, i, ink);
				Plot(pixels, n, i, i + 1, ink);
				Plot(pixels, n, i + 1, i, ink);
			}
			Disc(pixels, n, 50, 50, 5, ink);
			Disc(pixels, n, 14, 14, 3, new Color(0.55f, 0.5f, 0.42f));
		}

		private static void DrawHammer(Color[] pixels, int n, Color paper, Color ink)
		{
			//IL_001e: 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)
			for (int i = 10; i < 46; i++)
			{
				for (int j = 28; j < 36; j++)
				{
					Plot(pixels, n, j, i, new Color(0.42f, 0.28f, 0.16f));
				}
			}
			for (int k = 40; k < 54; k++)
			{
				for (int l = 14; l < 50; l++)
				{
					Plot(pixels, n, l, k, ink);
				}
			}
		}

		private static void DrawJump(Color[] pixels, int n, Color paper, Color ink)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 18; i++)
			{
				Plot(pixels, n, 32 - i, 18 + i, ink);
				Plot(pixels, n, 32 + i, 18 + i, ink);
				Plot(pixels, n, 31 - i, 18 + i, ink);
				Plot(pixels, n, 33 + i, 18 + i, ink);
			}
			for (int j = 34; j < 52; j++)
			{
				for (int k = 28; k < 36; k++)
				{
					Plot(pixels, n, k, j, ink);
				}
			}
		}

		private static void DrawRebar(Color[] pixels, int n, Color paper, Color ink)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 6; i < 58; i++)
			{
				Plot(pixels, n, i, 30, ink);
				Plot(pixels, n, i, 31, ink);
				Plot(pixels, n, i, 32, ink);
			}
			Disc(pixels, n, 54, 31, 4, ink);
		}

		private static void DrawPortrait(Color[] pixels, int n, Color paper, Color ink)
		{
			//IL_004a: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 2; i < 20; i++)
			{
				for (int j = 12; j < 52; j++)
				{
					Plot(pixels, n, j, i, new Color(0.28f, 0.32f, 0.36f));
				}
			}
			Disc(pixels, n, 32, 38, 16, ink);
			Disc(pixels, n, 32, 38, 12, new Color(0.12f, 0.14f, 0.18f));
		}
	}
	public class ClimberAimPreview : IDisposable
	{
		private GameObject _root;

		private GameObject _ghostObj;

		private MeshRenderer _ghostRenderer;

		private MeshFilter _ghostFilter;

		private GameObject _outlineObj;

		private LineRenderer[] _rings;

		private LineRenderer _impactRing;

		private LineRenderer[] _rails;

		private GameObject _cylinderObj;

		private MeshFilter _cylinderFilter;

		private MeshRenderer _cylinderRenderer;

		private Mesh _cylinderMesh;

		private Vector3[] _cylinderVerts;

		private readonly Vector3[] _railOffsets = (Vector3[])(object)new Vector3[4];

		private readonly RaycastHit[] _castHits = (RaycastHit[])(object)new RaycastHit[32];

		private static Material _matOk;

		private static Material _matInvalid;

		private static Material _matLine;

		protected readonly CharacterBody _body;

		protected readonly ClimbAnchor.Kind _kind;

		protected readonly float _range;

		protected readonly float _radius;

		private readonly int _maxRings;

		private bool _disposed;

		private static readonly Color ColorOk = new Color(0.4f, 0.75f, 0.8f, 0.52f);

		private static readonly Color ColorOkEnemy = new Color(0.55f, 0.8f, 0.52f, 0.58f);

		private static readonly Color ColorInvalid = new Color(0.75f, 0.4f, 0.42f, 0.48f);

		private static readonly Color ColorInvalidEnemy = new Color(0.82f, 0.6f, 0.38f, 0.55f);

		public ClimberAimPreview(CharacterBody body, ClimbAnchor.Kind kind, float range, float radius)
		{
			_body = body;
			_kind = kind;
			_range = range;
			_radius = radius;
			_maxRings = PreviewGeometry.MaxRings(range);
			EnsureMaterials();
			BuildGameObjects();
		}

		private static void EnsureMaterials()
		{
			//IL_001d: 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)
			if ((Object)(object)_matOk == (Object)null)
			{
				Material source = GameAssets.Load<Material>(RoR2_Base_Engi.matBlueprintsOk_mat);
				_matOk = CreateTunedMaterial(source, ColorOk);
			}
			if ((Object)(object)_matInvalid == (Object)null)
			{
				Material source2 = GameAssets.Load<Material>(RoR2_Base_Engi.matBlueprintsInvalid_mat);
				_matInvalid = CreateTunedMaterial(source2, ColorInvalid);
			}
			if ((Object)(object)_matLine == (Object)null)
			{
				_matLine = GameAssets.Load<Material>(RoR2_Base_Common_VFX.matLaserPointerBeam_mat);
				if ((Object)(object)_matLine == (Object)null)
				{
					_matLine = _matOk;
				}
			}
		}

		private static Material CreateTunedMaterial(Material source, Color fallbackColor)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Material val;
			if ((Object)(object)source != (Object)null)
			{
				val = Object.Instantiate<Material>(source);
			}
			else
			{
				Shader val2 = Shader.Find("Hopoo Games/Deferred/Standard") ?? Shader.Find("Hopoo Games/FX/Cloud Remap") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color");
				val = new Material(val2);
			}
			TuneMaterialColors(val, fallbackColor);
			return val;
		}

		private static void TuneMaterialColors(Material mat, Color fallbackColor)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mat == (Object)null))
			{
				bool flag = false;
				if (mat.HasProperty("_Color"))
				{
					Color color = mat.GetColor("_Color");
					mat.SetColor("_Color", Desaturate(color, 0.5f, 0.65f));
					flag = true;
				}
				if (mat.HasProperty("_TintColor"))
				{
					Color color2 = mat.GetColor("_TintColor");
					mat.SetColor("_TintColor", Desaturate(color2, 0.5f, 0.65f));
					flag = true;
				}
				if (mat.HasProperty("_EmissionColor"))
				{
					Color color3 = mat.GetColor("_EmissionColor");
					mat.SetColor("_EmissionColor", Desaturate(color3, 0.5f, 0.65f));
					flag = true;
				}
				if (mat.HasProperty("_RimColor"))
				{
					Color color4 = mat.GetColor("_RimColor");
					mat.SetColor("_RimColor", Desaturate(color4, 0.5f, 0.65f));
					flag = true;
				}
				if (!flag)
				{
					mat.color = fallbackColor;
				}
			}
		}

		private static Color Desaturate(Color c, float saturation, float alphaMultiplier)
		{
			//IL_0006: 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_001f: 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_0036: 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_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.299f * c.r + 0.587f * c.g + 0.114f * c.b;
			return new Color(Mathf.Lerp(num, c.r, saturation), Mathf.Lerp(num, c.g, saturation), Mathf.Lerp(num, c.b, saturation), c.a * alphaMultiplier);
		}

		private void BuildGameObjects()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			_root = new GameObject("ClimberAimPreview_" + _kind);
			_root.layer = LayerIndex.defaultLayer.intVal;
			_ghostObj = new GameObject("AnchorGhost");
			_ghostObj.layer = _root.layer;
			_ghostObj.transform.SetParent(_root.transform, false);
			_ghostFilter = _ghostObj.AddComponent<MeshFilter>();
			_ghostRenderer = _ghostObj.AddComponent<MeshRenderer>();
			((Renderer)_ghostRenderer).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)_ghostRenderer).receiveShadows = false;
			RebarPin.EnsureLoaded();
			Mesh anchorMesh = GetAnchorMesh();
			_ghostFilter.sharedMesh = anchorMesh;
			((Renderer)_ghostRenderer).sharedMaterial = _matOk;
			_outlineObj = new GameObject("HitboxOutline");
			_outlineObj.layer = _root.layer;
			_outlineObj.transform.SetParent(_root.transform, false);
			_rings = (LineRenderer[])(object)new LineRenderer[_maxRings];
			for (int i = 0; i < _maxRings; i++)
			{
				_rings[i] = CreateLine("Ring_" + i, 24, loop: true, 0.028f);
			}
			_impactRing = CreateLine("ImpactRing", 24, loop: true, 0.034f);
			_rails = (LineRenderer[])(object)new LineRenderer[4];
			for (int j = 0; j < 4; j++)
			{
				_rails[j] = CreateLine("Rail_" + j, 2, loop: false, 0.026f);
			}
			_cylinderObj = new GameObject("HitboxCylinder");
			_cylinderObj.layer = _root.layer;
			_cylinderObj.transform.SetParent(_root.transform, false);
			_cylinderFilter = _cylinderObj.AddComponent<MeshFilter>();
			_cylinderRenderer = _cylinderObj.AddComponent<MeshRenderer>();
			((Renderer)_cylinderRenderer).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)_cylinderRenderer).receiveShadows = false;
			((Renderer)_cylinderRenderer).sharedMaterial = _matOk;
		}

		private Mesh GetAnchorMesh()
		{
			if (_kind == ClimbAnchor.Kind.Piton)
			{
				return WkMesh.Piton ?? RebarPin.Mesh ?? ClimbAnchor.FallbackMesh();
			}
			return WkMesh.Rebar ?? RebarPin.Mesh ?? ClimbAnchor.FallbackMesh();
		}

		private LineRenderer CreateLine(string name, int positionCount, bool loop, float width)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.layer = _root.layer;
			val.transform.SetParent(_outlineObj.transform, false);
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.useWorldSpace = true;
			val2.startWidth = width;
			val2.endWidth = width;
			val2.positionCount = positionCount;
			val2.loop = loop;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			((Renderer)val2).sharedMaterial = _matLine ?? _matOk;
			return val2;
		}

		public void Update(Ray aim)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0064: 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_0091: 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_0096: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01e7: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: 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_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: 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_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: 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_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_03b3: 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_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || (Object)(object)_root == (Object)null)
			{
				return;
			}
			Vector3 startPos;
			Vector3 direction;
			Vector3 hitPoint;
			Vector3 hitNormal;
			bool flag = Spear.FindWorldSurface(_body, aim, _range, 0.5f, out startPos, out direction, out hitPoint, out hitNormal);
			Vector3 val = (flag ? hitPoint : (startPos + direction * _range));
			Vector3 stickInDir = val - startPos;
			float num = Mathf.Max(0.2f, ((Vector3)(ref stickInDir)).magnitude);
			Vector3 val2 = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.forward);
			PreviewGeometry.PerpendicularBasis(val2, out var up, out var right);
			RaycastHit[] castHits = _castHits;
			Vector3 val3 = startPos;
			float radius = _radius;
			RaycastHit[] castHits2 = _castHits;
			LayerIndex entityPrecise = LayerIndex.entityPrecise;
			int num2 = EnemyFilter.CountInCast(castHits, Physics.SphereCastNonAlloc(val3, radius, val2, castHits2, num, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask), (QueryTriggerInteraction)2), _body, stopAtFirst: true);
			Material sharedMaterial = (flag ? _matOk : _matInvalid);
			Color color = ((!flag) ? ((num2 > 0) ? ColorInvalidEnemy : ColorInvalid) : ((num2 > 0) ? ColorOkEnemy : ColorOk));
			RebarPin.EnsureLoaded();
			Mesh anchorMesh = GetAnchorMesh();
			if ((Object)(object)_ghostFilter.sharedMesh != (Object)(object)anchorMesh)
			{
				_ghostFilter.sharedMesh = anchorMesh;
			}
			if (flag)
			{
				ClimbAnchor.CalculateTransform(_kind, hitPoint, direction, hitNormal, anchorMesh, out var position, out var rotation, out var scale, out stickInDir, out var _);
				_ghostObj.transform.SetPositionAndRotation(position, rotation);
				_ghostObj.transform.localScale = Vector3.one * scale;
				((Renderer)_ghostRenderer).sharedMaterial = _matOk;
				_ghostObj.SetActive(true);
			}
			else
			{
				Vector3 val4 = startPos + val2 * _range;
				Quaternion val5 = Quaternion.LookRotation(val2);
				_ghostObj.transform.SetPositionAndRotation(val4, val5);
				_ghostObj.transform.localScale = Vector3.one;
				((Renderer)_ghostRenderer).sharedMaterial = _matInvalid;
				_ghostObj.SetActive(true);
			}
			int num3 = PreviewGeometry.ActiveRings(_range, num, _maxRings);
			for (int i = 0; i < _maxRings; i++)
			{
				if (i < num3)
				{
					((Renderer)_rings[i]).enabled = true;
					float num4 = PreviewGeometry.RingFraction(i, num3);
					Vector3 center = startPos + val2 * (num * num4);
					SetRingPositions(_rings[i], center, right, up, _radius);
					SetLineColor(_rings[i], color);
				}
				else
				{
					((Renderer)_rings[i]).enabled = false;
				}
			}
			if (flag)
			{
				((Renderer)_impactRing).enabled = true;
				PreviewGeometry.PerpendicularBasis(hitNormal, out var up2, out var right2);
				SetRingPositions(_impactRing, hitPoint + hitNormal * 0.03f, right2, up2, _radius);
				SetLineColor(_impactRing, color);
			}
			else
			{
				((Renderer)_impactRing).enabled = false;
			}
			_railOffsets[0] = up * _radius;
			_railOffsets[1] = right * _radius;
			_railOffsets[2] = -up * _radius;
			_railOffsets[3] = -right * _radius;
			for (int j = 0; j < 4; j++)
			{
				_rails[j].SetPosition(0, startPos + _railOffsets[j]);
				_rails[j].SetPosition(1, val + _railOffsets[j]);
				SetLineColor(_rails[j], color);
			}
			UpdateCylinderMesh(startPos, val, right, up, _radius);
			((Renderer)_cylinderRenderer).sharedMaterial = sharedMaterial;
		}

		private static void SetRingPositions(LineRenderer lr, Vector3 center, Vector3 right, Vector3 up, float radius, int segments = 24)
		{
			//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_0034: 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)
			if (!((Object)(object)lr == (Object)null))
			{
				if (lr.positionCount != segments)
				{
					lr.positionCount = segments;
				}
				for (int i = 0; i < segments; i++)
				{
					lr.SetPosition(i, center + PreviewGeometry.RingOffset(i, segments, right, up, radius));
				}
			}
		}

		private static void SetLineColor(LineRenderer lr, Color color)
		{
			//IL_000f: 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)
			if (!((Object)(object)lr == (Object)null))
			{
				lr.startColor = color;
				lr.endColor = color;
			}
		}

		private void UpdateCylinderMesh(Vector3 startPos, Vector3 endPos, Vector3 right, Vector3 up, float radius, int segments = 24)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009b: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)_cylinderMesh == (Object)null)
			{
				_cylinderMesh = new Mesh();
				((Object)_cylinderMesh).name = "ClimberAimHitboxCylinder";
				_cylinderVerts = (Vector3[])(object)new Vector3[segments * 2];
				_cylinderMesh.vertices = _cylinderVerts;
				_cylinderMesh.triangles = PreviewGeometry.TubeTriangles(segments);
				_cylinderMesh.MarkDynamic();
				_cylinderFilter.sharedMesh = _cylinderMesh;
			}
			for (int i = 0; i < segments; i++)
			{
				Vector3 val = PreviewGeometry.RingOffset(i, segments, right, up, radius);
				_cylinderVerts[i] = startPos + val;
				_cylinderVerts[i + segments] = endPos + val;
			}
			_cylinderMesh.vertices = _cylinderVerts;
			_cylinderMesh.RecalculateBounds();
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				_disposed = true;
				if ((Object)(object)_cylinderMesh != (Object)null)
				{
					Object.Destroy((Object)(object)_cylinderMesh);
					_cylinderMesh = null;
				}
				if ((Object)(object)_root != (Object)null)
				{
					Object.Destroy((Object)(object)_root);
					_root = null;
				}
			}
		}
	}
	public class PitonPreview : ClimberAimPreview
	{
		public PitonPreview(CharacterBody body)
			: base(body, ClimbAnchor.Kind.Piton, PitonState.Range, 0.95f)
		{
		}
	}
	public class SpearPreview : ClimberAimPreview
	{
		public SpearPreview(CharacterBody body)
			: base(body, ClimbAnchor.Kind.Rebar, 90f, 0.75f)
		{
		}
	}
	[BepInPlugin("com.overlord.climber", "Climber", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ClimberPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.overlord.climber";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<bool> AutoStart;

		public static ConfigEntry<bool> DevBridge;

		private string _cmdPath;

		private string _statusPath;

		private float _autoStartAt = -1f;

		private float _nextBeat;

		private float _nextMenuTry;

		private float _lobbySelectedAt = -1f;

		private bool _autoStarted;

		private bool _openedSinglePlayer;

		private int _menuTries;

		private static int _aimProbeRuns;

		public static ClimberPlugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			AutoStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Lab", "AutoStart", false, "When a lobby is open, pick the Climber and start the run. Lab switch.");
			DevBridge = ((BaseUnityPlugin)this).Config.Bind<bool>("Lab", "DevBridge", false, "Watch BepInEx/climber_cmd.txt for development commands. Lab switch; leave off unless you are driving the game from scripts/lab.sh.");
			_cmdPath = Path.Combine(Paths.BepInExRootPath, "climber_cmd.txt");
			_statusPath = Path.Combine(Paths.BepInExRootPath, "climber_status.txt");
			Tokens.Register();
			SurvivorBuilder.Build(((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Climber plugin awake.");
		}

		private void Update()
		{
			if (!SoundBanks.Ready)
			{
				SoundBanks.EnsureLoaded(((BaseUnityPlugin)this).Logger);
			}
			if (DevBridge != null && DevBridge.Value)
			{
				PollCommands();
			}
			TryAutoStart();
			if (AutoStart != null && AutoStart.Value)
			{
				CharacterBody val = LocalBody();
				if (IsClimber(val) && (Object)(object)val.healthComponent != (Object)null)
				{
					val.healthComponent.godMode = true;
				}
			}
			if (AutoStart != null && AutoStart.Value && Time.unscaledTime >= _nextBeat)
			{
				_nextBeat = Time.unscaledTime + 2f;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("climber_beat " + Describe()));
			}
		}

		private void TryAutoStart()
		{
			if ((Object)(object)PreGameController.instance == (Object)null)
			{
				TryOpenSinglePlayer();
				return;
			}
			if (_lobbySelectedAt < 0f && LocalUserManager.GetFirstLocalUser() != null)
			{
				_lobbySelectedAt = Time.time;
				SelectClimber();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"climber_lobby_selected Climber selected on character select podium.");
				((MonoBehaviour)this).StartCoroutine(CaptureLobbyAfterDelay());
			}
			if (AutoStart != null && AutoStart.Value && !_autoStarted && LocalUserManager.GetFirstLocalUser() != null)
			{
				if (_autoStartAt < 0f)
				{
					_autoStartAt = Time.time + 5f;
				}
				if (!(Time.time < _autoStartAt))
				{
					_autoStarted = true;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("climber_autostart " + Describe()));
					SelectAndStart();
				}
			}
		}

		private void TryOpenSinglePlayer()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (_menuTries > 3)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "title")
			{
				return;
			}
			if (!_openedSinglePlayer)
			{
				_openedSinglePlayer = true;
				_nextMenuTry = Time.unscaledTime + 2.5f;
			}
			else if (!(Time.unscaledTime < _nextMenuTry))
			{
				TitleMenuController val = Object.FindObjectOfType<TitleMenuController>();
				if (!((Object)(object)val == (Object)null))
				{
					_menuTries++;
					_nextMenuTry = Time.unscaledTime + 4f;
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Opening singleplayer from the title menu.");
					val.OnSinglePlayerButtonPressed();
				}
			}
		}

		private void PollCommands()
		{
			if (string.IsNullOrEmpty(_cmdPath) || !File.Exists(_cmdPath))
			{
				return;
			}
			string text;
			try
			{
				text = File.ReadAllText(_cmdPath);
				File.Delete(_cmdPath);
			}
			catch (IOException)
			{
				return;
			}
			string[] array = text.Split('\n');
			foreach (string text2 in array)
			{
				string text3 = text2.Trim().ToLowerInvariant();
				if (text3.Length != 0)
				{
					RunCommand(text3);
				}
			}
		}

		private void RunCommand(string cmd)
		{
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: 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_0633: 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_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			switch (cmd)
			{
			case "status":
				WriteStatus(Describe());
				break;
			case "select":
				WriteStatus(SelectClimber() ? "selected" : "select_failed");
				break;
			case "startrun":
				SelectAndStart();
				WriteStatus("startrun_sent " + Describe());
				break;
			case "shot":
			{
				string text2 = Path.Combine(Paths.BepInExRootPath, "climber_shot.png");
				ScreenCapture.CaptureScreenshot(text2);
				WriteStatus("shot " + text2);
				break;
			}
			case "grip":
			{
				GripController local = GripController.Local;
				WriteStatus(((Object)(object)local == (Object)null) ? "grip none" : ("grip " + local.Current.ToString("0") + "/" + local.Max.ToString("0") + (local.Slipping ? " slipping" : "")));
				break;
			}
			case "kit":
				WriteStatus(DescribeKit());
				break;
			case "rig":
				WriteStatus(DescribeRig());
				break;
			case "testbody":
				WriteStatus(LoadTestBody());
				break;
			case "sounds":
			{
				CharacterBody val4 = LocalBody();
				WriteStatus(SoundBanks.Probe(((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject : null));
				break;
			}
			case "cast":
				((MonoBehaviour)this).StartCoroutine(CastKit());
				break;
			case "cast_primary":
				((MonoBehaviour)this).StartCoroutine(CastOne("primary"));
				break;
			case "cast_secondary":
				((MonoBehaviour)this).StartCoroutine(CastOne("secondary"));
				break;
			case "cast_utility":
				((MonoBehaviour)this).StartCoroutine(CastOne("utility"));
				break;
			case "cast_special":
				((MonoBehaviour)this).StartCoroutine(CastOne("special"));
				break;
			case "interact":
				PerformInteract();
				break;
			case "leavepod":
				WriteStatus(LeavePod());
				break;
			case "aimprobe":
				WriteStatus(AimProbe());
				break;
			case "test_interact":
				((MonoBehaviour)this).StartCoroutine(TestInteractRoutine());
				break;
			case "spearscan":
				WriteStatus(SpearScan());
				break;
			case "propscan":
				WriteStatus(PropScan());
				break;
			case "cam":
			{
				Camera main = Camera.main;
				GameObject val = GameObject.Find("ClimberDisplay(Clone)");
				GameObject val2 = GameObject.Find("ClimberHammer");
				string[] obj = new string[6] { "cam=", null, null, null, null, null };
				object obj2;
				Vector3 val3;
				if (!((Object)(object)main != (Object)null))
				{
					obj2 = "null";
				}
				else
				{
					val3 = ((Component)main).transform.position;
					string text = ((Vector3)(ref val3)).ToString("F2");
					val3 = ((Component)main).transform.eulerAngles;
					obj2 = text + " rot=" + ((Vector3)(ref val3)).ToString("F1");
				}
				obj[1] = (string)obj2;
				obj[2] = " disp=";
				object obj3;
				if (!((Object)(object)val != (Object)null))
				{
					obj3 = "null";
				}
				else
				{
					string[] obj4 = new string[6] { "pos=", null, null, null, null, null };
					val3 = val.transform.position;
					obj4[1] = ((Vector3)(ref val3)).ToString("F2");
					obj4[2] = " fwd=";
					val3 = val.transform.forward;
					obj4[3] = ((Vector3)(ref val3)).ToString("F2");
					obj4[4] = " rot=";
					val3 = val.transform.eulerAngles;
					obj4[5] = ((Vector3)(ref val3)).ToString("F1");
					obj3 = string.Concat(obj4);
				}
				obj[3] = (string)obj3;
				obj[4] = " hammer=";
				object obj5;
				if (!((Object)(object)val2 != (Object)null))
				{
					obj5 = "null";
				}
				else
				{
					string[] obj6 = new string[8] { "pos=", null, null, null, null, null, null, null };
					val3 = val2.transform.position;
					obj6[1] = ((Vector3)(ref val3)).ToString("F2");
					obj6[2] = " fwd=";
					val3 = val2.transform.forward;
					obj6[3] = ((Vector3)(ref val3)).ToString("F2");
					obj6[4] = " up=";
					val3 = val2.transform.up;
					obj6[5] = ((Vector3)(ref val3)).ToString("F2");
					obj6[6] = " right=";
					val3 = val2.transform.right;
					obj6[7] = ((Vector3)(ref val3)).ToString("F2");
					obj5 = string.Concat(obj6);
				}
				obj[5] = (string)obj5;
				WriteStatus(string.Concat(obj));
				break;
			}
			default:
				WriteStatus("unknown '" + cmd + "'; try: status, kit, rig, grip, sounds, select, startrun, shot, cast, cast_primary, cast_secondary, cast_utility, cast_special, interact, test_interact, aimprobe, leavepod, testbody, spearscan, propscan");
				break;
			}
		}

		private static string PropScan()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			ClimberWeaponVisual[] array = Object.FindObjectsOfType<ClimberWeaponVisual>();
			foreach (ClimberWeaponVisual climberWeaponVisual in array)
			{
				if ((Object)(object)climberWeaponVisual == (Object)null)
				{
					continue;
				}
				GameObject gameObject = ((Component)climberWeaponVisual).gameObject;
				MeshRenderer component = gameObject.GetComponent<MeshRenderer>();
				CharacterModel componentInParent = ((Component)climberWeaponVisual).GetComponentInParent<CharacterModel>();
				string text = (((Object)(object)componentInParent != (Object)null) ? ((Object)((Component)componentInParent).gameObject).name : "noModel");
				string text2 = ((Object)gameObject).name + "@" + text;
				if ((Object)(object)component == (Object)null)
				{
					list.Add(text2 + " norenderer");
					continue;
				}
				Material sharedMaterial = ((Renderer)component).sharedMaterial;
				text2 = text2 + " enabled=" + ((Renderer)component).enabled + " mat=" + (((Object)(object)sharedMaterial != (Object)null) ? ((Object)sharedMaterial).name : "null") + " shader=" + (((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null) ? ((Object)sharedMaterial.shader).name : "null");
				if ((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_Color"))
				{
					string text3 = text2;
					Color color = sharedMaterial.GetColor("_Color");
					text2 = text3 + " color=" + ((Color)(ref color)).ToString("F2");
				}
				if ((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_MainTex"))
				{
					Texture texture = sharedMaterial.GetTexture("_MainTex");
					text2 = text2 + " tex=" + (((Object)(object)texture != (Object)null) ? ((Object)texture).name : "none");
				}
				list.Add(text2);
			}
			list.Add("built spearMat=" + (((Object)(object)WkTexture.Spear != (Object)null) ? ((Object)WkTexture.Spear).name : "null") + " hammerMat=" + (((Object)(object)WkTexture.Hammer != (Object)null) ? ((Object)WkTexture.Hammer).name : "null") + " vanilla=" + (((Object)(object)RebarPin.Material != (Object)null) ? ((Object)RebarPin.Material).name : "null"));
			return "propscan " + string.Join(" | ", list.ToArray());
		}

		private static string SpearScan()
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			List<string> list = new List<string>();
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject val in array)
			{
				if ((Object)(object)val == (Object)null || !val.activeInHierarchy)
				{
					continue;
				}
				string name = ((Object)val).name;
				if (name.StartsWith("ClimberRebarPin"))
				{
					num++;
				}
				else if (name.StartsWith("ClimberSpearInFlight"))
				{
					num2++;
				}
				else if (name.Contains("TracerToolbotRebar") || name.Contains("RebarMesh") || (name.Contains("Rebar") && !name.StartsWith("Climber")))
				{
					num3++;
					if (list.Count < 5)
					{
						list.Add(name);
					}
				}
			}
			string text = "spearscan planted=" + num + " inflight=" + num2 + " borrowed=" + num3;
			if (list.Count > 0)
			{
				text = text + " [" + string.Join(", ", list.ToArray()) + "]";
			}
			return text;
		}

		private static string LeavePod()
		{
			CharacterBody val = LocalBody();
			if ((Object)(object)val == (Object)null)
			{
				return "leavepod nobody";
			}
			VehicleSeat val2 = ((Component)val).GetComponentInParent<VehicleSeat>();
			if ((Object)(object)val2 == (Object)null)
			{
				VehicleSeat[] array = Object.FindObjectsOfType<VehicleSeat>();
				foreach (VehicleSeat val3 in array)
				{
					if ((Object)(object)val3.currentPassengerBody == (Object)(object)val)
					{
						val2 = val3;
						break;
					}
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return "leavepod not_in_a_pod (already out)";
			}
			val2.EjectPassenger(((Component)val).gameObject);
			return "leavepod ejected";
		}

		private static string AimProbe()
		{
			//IL_004d: 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_009e: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_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_00d1: 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_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)
			//IL_013b: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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)
			CharacterBody val = LocalBody();
			if ((Object)(object)val == (Object)null)
			{
				return "aimprobe nobody";
			}
			Vector3 val2 = ((CameraRigController.readOnlyInstancesList != null && CameraRigController.readOnlyInstancesList.Count > 0 && (Object)(object)CameraRigController.readOnlyInstancesList[0].sceneCam != (Object)null) ? ((Component)CameraRigController.readOnlyInstancesList[0].sceneCam).transform.position : val.corePosition);
			Vector3 direction;
			Vector3 val3;
			if ((Object)(object)val.inputBank != (Object)null)
			{
				direction = val.inputBank.aimDirection;
				if (((Vector3)(ref direction)).sqrMagnitude > 0.01f)
				{
					val3 = val.inputBank.aimDirection;
					goto IL_00b0;
				}
			}
			val3 = ((Component)val).transform.forward;
			goto IL_00b0;
			IL_00b0:
			Vector3 val4 = val3;
			val4.y = 0f;
			if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
			{
				val4 = Vector3.forward;
			}
			((Vector3)(ref val4)).Normalize();
			StringBuilder stringBuilder = new StringBuilder("aimprobe");
			float y = val.footPosition.y;
			int num = 0;
			Vector3 val5 = Vector3.Cross(Vector3.up, val4);
			int num2 = 0;
			int num3 = 0;
			float[] array = new float[4] { -90f, -45f, 0f, 45f };
			for (int i = 0; i < array.Length; i++)
			{
				float num4 = array[i];
				direction = Quaternion.AngleAxis(0f - num4, val5) * val4;
				Vector3 normalized = ((Vector3)(ref direction)).normalized;
				num3++;
				Vector3 startPos;
				Vector3 hitPoint;
				Vector3 hitNormal;
				bool flag = Spear.FindWorldSurface(val, new Ray(val2, normalized), 90f, 0.5f, out startPos, out direction, out hitPoint, out hitNormal);
				stringBuilder.Append(' ').Append(num4.ToString("0")).Append('=');
				if (flag)
				{
					float num5 = Vector3.Distance(startPos, hitPoint);
					stringBuilder.Append(num5.ToString("0.0")).Append('m');
					if (num5 < 0.05f)
					{
						num2++;
					}
					if (startPos.y < y - 0.5f)
					{
						stringBuilder.Append("[START-UNDER-FLOOR]");
						num++;
					}
					if (num4 <= -45f && hitPoint.y > y + 1.5f)
					{
						stringBuilder.Append("[NOT-GROUND]");
						num++;
					}
				}
				else
				{
					stringBuilder.Append("miss");
					if (num4 <= -45f)
					{
						stringBuilder.Append("[SHOULD-HIT-GROUND]");
						num++;
					}
				}
			}
			stringBuilder.Append(" foot=").Append(y.ToString("0.0"));
			if (num2 == num3)
			{
				stringBuilder.Append(" ENCLOSED(no open space to cast through; exit the pod first)");
				string text = stringBuilder.ToString();
				int num6 = ++_aimProbeRuns;
				return text + " #" + num6;
			}
			stringBuilder.Append(" #").Append((++_aimProbeRuns).ToString());
			stringBuilder.Append((num == 0) ? "  ok" : "  SUSPECT");
			return stringBuilder.ToString();
		}

		private static GameObject FindBestInteractable(Interactor interactor, CharacterBody body)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_003b: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)interactor == (Object)null || (Object)(object)body == (Object)null)
			{
				return null;
			}
			Ray val = (((Object)(object)body.inputBank != (Object)null) ? new Ray(body.inputBank.aimOrigin, body.inputBank.aimDirection) : new Ray(body.aimOrigin, ((Component)body).transform.forward));
			float num = ((interactor.maxInteractionDistance > 0f) ? interactor.maxInteractionDistance : 3f);
			return interactor.FindBestInteractableObject(val, num, body.corePosition, num);
		}

		private void PerformInteract()
		{
			CharacterBody val = LocalBody();
			if ((Object)(object)val == (Object)null)
			{
				WriteStatus("interact nobody");
				return;
			}
			Interactor component = ((Component)val).GetComponent<Interactor>();
			if ((Object)(object)component == (Object)null)
			{
				WriteStatus("interact no_interactor");
				return;
			}
			GameObject val2 = FindBestInteractable(component, val);
			if ((Object)(object)val2 == (Object)null)
			{
				WriteStatus("interact no_target");
				return;
			}
			IInteractable component2 = val2.GetComponent<IInteractable>();
			string text = ((component2 != null) ? component2.GetContextString(component) : ((Object)val2).name);
			component.AttemptInteraction(val2);
			WriteStatus("interact success target=" + text);
		}

		private IEnumerator CaptureLobbyAfterDelay()
		{
			yield return (object)new WaitForSecondsRealtime(2f);
			string shot = Path.Combine(Paths.BepInExRootPath, "climber_lobby_shot.png");
			ScreenCapture.CaptureScreenshot(shot);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("climber_lobby_shot captured to " + shot));
		}

		private IEnumerator TestInteractRoutine()
		{
			CharacterBody body = LocalBody();
			if ((Object)(object)body == (Object)null)
			{
				WriteStatus("test_interact nobody");
				yield break;
			}
			Interactor interactor = ((Component)body).GetComponent<Interactor>();
			if ((Object)(object)interactor == (Object)null)
			{
				WriteStatus("test_interact no_interactor");
				yield break;
			}
			Vector3 dir = (((Object)(object)body.inputBank != (Object)null) ? body.inputBank.aimDirection : ((Component)body).transform.forward);
			Vector3 spawnPos = body.corePosition + dir * 2f;
			ClimbAnchor.Place(ClimbAnchor.Kind.Piton, spawnPos, dir, -dir, body);
			yield return null;
			GameObject best = FindBestInteractable(interactor, body);
			if ((Object)(object)best == (Object)null)
			{
				WriteStatus("test_interact no_target_after_placement");
				yield break;
			}
			if ((Object)(object)best.GetComponent<ClimbAnchor>() == (Object)null)
			{
				IInteractable other = best.GetComponent<IInteractable>();
				WriteStatus("test_interact wrong_target=" + ((other != null) ? other.GetContextString(interactor) : ((Object)best).name) + " (a vanilla interactable is nearer than our anchor; move away and retry)");
				yield break;
			}
			float preVel = (((Object)(object)body.characterMotor != (Object)null) ? body.characterMotor.velocity.y : 0f);
			IInteractable interactable = best.GetComponent<IInteractable>();
			string targetName = ((interactable != null) ? interactable.GetContextString(interactor) : ((Object)best).name);
			interactor.AttemptInteraction(best);
			yield return (object)new WaitForFixedUpdate();
			float postVel = (((Object)(object)body.characterMotor != (Object)null) ? body.characterMotor.velocity.y : 0f);
			bool launched = postVel > 14f;
			WriteStatus("test_interact " + (launched ? "success" : "NO-LAUNCH") + " target=" + targetName + " preVel=" + preVel.ToString("0.0") + " postVel=" + postVel.ToString("0.0"));
		}

		public static bool SelectClimber()
		{
			SurvivorDef survivor = SurvivorBuilder.Survivor;
			if ((Object)(object)survivor == (Object)null)
			{
				return false;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null || firstLocalUser.userProfile == null)
			{
				return false;
			}
			firstLocalUser.userProfile.SetSurvivorPreference(survivor);
			NetworkUser currentNetworkUser = firstLocalUser.currentNetworkUser;
			if ((Object)(object)currentNetworkUser != (Object)null)
			{
				currentNetworkUser.SetSurvivorPreferenceClient(survivor);
			}
			return true;
		}

		public static void SelectAndStart()
		{
			SelectClimber();
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
			if ((Object)(object)Console.instance != (Object)null && (Object)(object)val != (Object)null)
			{
				Console.instance.SubmitCmd(val, "pregame_start_run", true);
			}
			else if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)"Console or network user is not ready; pregame_start_run was not sent.");
			}
		}

		private static bool IsClimber(CharacterBody body)
		{
			return (Object)(object)body != (Object)null && ((Object)body).name.StartsWith("ClimberBody");
		}

		private static CharacterBody LocalBody()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val.master == (Object)null)
			{
				return null;
			}
			return val.master.GetBody();
		}

		private static string DescribeKit()
		{
			return DescribeKitInner();
		}

		private static string DescribeRig()
		{
			CharacterBody val = LocalBody();
			if ((Object)(object)val == (Object)null)
			{
				return "rig nobody";
			}
			ModelLocator modelLocator = val.modelLocator;
			Transform val2 = (((Object)(object)modelLocator != (Object)null) ? modelLocator.modelTransform : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return "rig nomodel";
			}
			List<string> list = new List<string>();
			SkinnedMeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val3 in componentsInChildren)
			{
				Mesh sharedMesh = val3.sharedMesh;
				list.Add("smr=" + ((Object)val3).name + " verts=" + (((Object)(object)sharedMesh != (Object)null) ? sharedMesh.vertexCount : 0) + " subs=" + (((Object)(object)sharedMesh != (Object)null) ? sharedMesh.subMeshCount : 0) + " bones=" + ((val3.bones != null) ? val3.bones.Length : 0) + " root=" + (((Object)(object)val3.rootBone != (Object)null) ? ((Object)val3.rootBone).name : "none"));
			}
			ChildLocator component = ((Component)val2).GetComponent<ChildLocator>();
			List<string> list2 = new List<string>();
			if ((Object)(object)component != (Object)null)
			{
				string[] array = new string[11]
				{
					"HandR", "hand.r", "HandL", "hand.l", "Head", "Chest", "MuzzleLeft", "MuzzleRight", "Base", "Pelvis",
					"SpearSocket"
				};
				foreach (string text in array)
				{
					if ((Object)(object)component.FindChild(text) != (Object)null)
					{
						list2.Add(text);
					}
				}
			}
			string text2 = ((list2.Count > 0) ? string.Join(",", list2.ToArray()) : "none");
			DumpBoneHierarchy(val2);
			return "rig " + string.Join(" | ", list.ToArray()) + " sockets=[" + text2 + "]";
		}

		private static void DumpBoneHierarchy(Transform model)
		{
			DumpBoneHierarchyInner(model);
		}

		private static string