Decompiled source of Peakle v1.0.0

Peakle.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.ControllerSupport;
using Zorro.Core;
using Zorro.Core.Serizalization;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Peakle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Peakle")]
[assembly: AssemblyTitle("Peakle")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Peakle
{
	internal static class ArmVisuals
	{
		private struct Saved
		{
			public Transform t;

			public Vector3 pos;

			public Quaternion rot;
		}

		private static readonly List<Saved> saved = new List<Saved>();

		private static bool hooked;

		public static void Stretch(Character character, PeakleHands hands)
		{
			//IL_002c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.StretchArms.Value)
			{
				return;
			}
			Hook();
			PeakleHands.Hand[] hands2 = hands.hands;
			foreach (PeakleHands.Hand hand in hands2)
			{
				if (hand.grabbing)
				{
					StretchArm(character, hand, hand.point + hand.normal * Plugin.HandSurfaceOffset.Value);
				}
			}
		}

		private static void StretchArm(Character character, PeakleHands.Hand hand, Vector3 target)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00a4: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_00f8: 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_00fe: 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_010a: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			bool flag = hand.id == 0;
			Transform transform = ((Component)character.GetBodypartRig((BodypartType)(flag ? 5 : 8))).transform;
			Transform transform2 = ((Component)character.GetBodypartRig((BodypartType)(flag ? 6 : 9))).transform;
			Transform transform3 = ((Component)character.GetBodypartRig((BodypartType)(flag ? 7 : 10))).transform;
			Vector3 position = transform.position;
			Vector3 position2 = transform2.position;
			Vector3 position3 = transform3.position;
			Vector3 val = position3 - target;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0004f))
			{
				Quaternion rotation = transform.rotation;
				Quaternion rotation2 = transform2.rotation;
				Quaternion rotation3 = transform3.rotation;
				Save(transform);
				Save(transform2);
				Save(transform3);
				Vector3 val2 = position2 - Vector3.Lerp(position, position3, 0.5f);
				Vector3 val3 = Vector3.Lerp(position, target, 0.5f) + val2;
				transform.rotation = Quaternion.FromToRotation(position2 - position, val3 - position) * rotation;
				transform2.SetPositionAndRotation(val3, Quaternion.FromToRotation(position3 - position2, target - val3) * rotation2);
				transform3.SetPositionAndRotation(target, rotation3);
			}
		}

		internal static void SaveForRender(Transform t)
		{
			Hook();
			Save(t);
		}

		private static void Save(Transform t)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			saved.Add(new Saved
			{
				t = t,
				pos = t.position,
				rot = t.rotation
			});
		}

		private static void Hook()
		{
			if (!hooked)
			{
				hooked = true;
				RenderPipelineManager.endContextRendering += delegate
				{
					Restore();
				};
			}
		}

		private static void Restore()
		{
			//IL_0025: 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)
			for (int i = 0; i < ArmVisuals.saved.Count; i++)
			{
				Saved saved = ArmVisuals.saved[i];
				if ((Object)(object)saved.t != (Object)null)
				{
					saved.t.SetPositionAndRotation(saved.pos, saved.rot);
				}
			}
			ArmVisuals.saved.Clear();
		}
	}
	internal class BackpackPanel
	{
		public struct Cell
		{
			public Item prefab;

			public ItemInstanceData data;

			public Texture icon;

			public bool faded;

			public string label;
		}

		private class SlotUI
		{
			public RectTransform rt;

			public Image fill;

			public Image outline;

			public RawImage icon;

			public TextMeshProUGUI name;
		}

		public const int Middle = 4;

		private const float SlotPx = 100f;

		private static readonly Color FillColor = new Color(0f, 0f, 0f, 0.45f);

		private static readonly Color HoverFill = new Color(1f, 0.85f, 0.35f, 0.45f);

		private static readonly Color Yellow = new Color(1f, 0.85f, 0.35f, 1f);

		private readonly Canvas hud;

		private readonly RectTransform hudRect;

		private readonly RectTransform container;

		private readonly RectTransform names;

		private readonly SlotUI[] slots = new SlotUI[5];

		private readonly bool[] shown = new bool[5];

		private Vector3 center;

		private Quaternion facing = Quaternion.identity;

		private float metresPerPx;

		private float spread;

		public bool Visible
		{
			get
			{
				if ((Object)(object)container != (Object)null)
				{
					return ((Component)container).gameObject.activeSelf;
				}
				return false;
			}
		}

		public bool Alive
		{
			get
			{
				if ((Object)(object)container != (Object)null)
				{
					return (Object)(object)hud != (Object)null;
				}
				return false;
			}
		}

		private BackpackPanel(Canvas hudCanvas, InventoryItemUI hotbarSlot, TextMeshProUGUI fontLike)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			hud = hudCanvas;
			hudRect = (RectTransform)((Component)hud).transform;
			container = NewRect("Peakle Backpack Slots", (Transform)(object)hudRect, Vector2.zero);
			names = NewRect("Names", (Transform)(object)container, Vector2.zero);
			for (int i = 0; i < slots.Length; i++)
			{
				slots[i] = Build(i, hotbarSlot, fontLike);
			}
			((Transform)names).SetAsLastSibling();
			((Component)container).gameObject.SetActive(false);
		}

		public static BackpackPanel Create()
		{
			GUIManager instance = GUIManager.instance;
			if ((Object)(object)instance == (Object)null || instance.items == null || instance.items.Length < 2 || (Object)(object)instance.items[1] == (Object)null)
			{
				return null;
			}
			Canvas componentInParent = ((Component)instance.items[1]).GetComponentInParent<Canvas>();
			if (!((Object)(object)componentInParent != (Object)null))
			{
				return null;
			}
			return new BackpackPanel(componentInParent.rootCanvas, instance.items[1], instance.interactNameText ?? instance.interactPromptText);
		}

		public void Destroy()
		{
			if ((Object)(object)container != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)container).gameObject);
			}
		}

		private SlotUI Build(int index, InventoryItemUI hotbarSlot, TextMeshProUGUI fontLike)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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)
			RectTransform val = NewRect($"Slot {index}", (Transform)(object)container, Vector2.one * 100f);
			SlotUI slotUI = new SlotUI
			{
				rt = val
			};
			slotUI.fill = ((Component)NewRect("Fill", (Transform)(object)val, Vector2.one * 100f * 0.86f)).gameObject.AddComponent<Image>();
			((Graphic)slotUI.fill).raycastTarget = false;
			Image outline = hotbarSlot.outline;
			slotUI.outline = ((Component)NewRect("Outline", (Transform)(object)val, Vector2.one * 100f)).gameObject.AddComponent<Image>();
			((Graphic)slotUI.outline).raycastTarget = false;
			if ((Object)(object)outline != (Object)null && (Object)(object)outline.sprite != (Object)null)
			{
				slotUI.outline.sprite = outline.sprite;
				slotUI.outline.type = outline.type;
				slotUI.outline.pixelsPerUnitMultiplier = outline.pixelsPerUnitMultiplier;
				slotUI.outline.fillCenter = false;
			}
			slotUI.icon = ((Component)NewRect("Icon", (Transform)(object)val, Vector2.one * 100f * 0.85f)).gameObject.AddComponent<RawImage>();
			((Graphic)slotUI.icon).raycastTarget = false;
			RectTransform val2 = NewRect($"Name {index}", (Transform)(object)names, new Vector2(400f, 50f));
			slotUI.name = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)fontLike != (Object)null)
			{
				((TMP_Text)slotUI.name).font = ((TMP_Text)fontLike).font;
				((TMP_Text)slotUI.name).fontSharedMaterial = ((TMP_Text)fontLike).fontSharedMaterial;
			}
			((Graphic)slotUI.name).color = Color.white;
			((TMP_Text)slotUI.name).fontSize = 30.000002f;
			((TMP_Text)slotUI.name).alignment = (TextAlignmentOptions)514;
			((TMP_Text)slotUI.name).textWrappingMode = (TextWrappingModes)0;
			((Graphic)slotUI.name).raycastTarget = false;
			return slotUI;
		}

		private static RectTransform NewRect(string name, Transform parent, Vector2 size)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_006c: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = ((Component)parent).gameObject.layer
			}.transform;
			((Transform)val).SetParent(parent, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			val.pivot = val2;
			Vector2 anchorMin = (val.anchorMax = val2);
			val.anchorMin = anchorMin;
			val.sizeDelta = size;
			return val;
		}

		private Vector2 SlotOffset(int i)
		{
			//IL_0004: 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)
			if (i == 4)
			{
				return Vector2.zero;
			}
			float num = 100f * spread;
			float num2 = 62f;
			return new Vector2((i < 2) ? (0f - num) : num, (i % 2 == 0) ? num2 : (0f - num2));
		}

		private Vector3 SlotWorld(int i)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = SlotOffset(i) * metresPerPx;
			return center + facing * new Vector3(val.x, val.y, 0f);
		}

		public void Show(Vector3 worldCenter, Quaternion worldFacing, BackpackData data, int slotCount, Cell? middle, int hovered, float spread)
		{
			//IL_0078: 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)
			Cell[] array = new Cell[Mathf.Clamp(slotCount, 0, 4)];
			for (int i = 0; i < array.Length; i++)
			{
				ItemSlot val = ((data != null) ? data.itemSlots[i] : null);
				if (val != null && !val.IsEmpty())
				{
					array[i].prefab = val.prefab;
					array[i].data = val.data;
					array[i].icon = (Texture)(object)val.prefab.UIData.GetIcon();
				}
			}
			Show(worldCenter, worldFacing, array, middle, hovered, spread);
		}

		public void Show(Vector3 worldCenter, Quaternion worldFacing, Cell[] aroundCells, Cell? middle, int hovered, float spread)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : Camera.main);
			if ((Object)(object)val == (Object)null || (Object)(object)hud == (Object)null || !((Behaviour)hud).isActiveAndEnabled)
			{
				Hide();
				return;
			}
			if (!((Component)container).gameObject.activeSelf)
			{
				((Component)container).gameObject.SetActive(true);
			}
			((Transform)container).SetAsFirstSibling();
			this.spread = spread;
			center = worldCenter;
			facing = worldFacing;
			float num = Mathf.Max(Vector3.Distance(((Component)val).transform.position, center), 0.2f);
			float num2 = 2f * num * Mathf.Tan(Plugin.PanelSlotAngle.Value * 0.5f * (MathF.PI / 180f));
			metresPerPx = num2 / 100f;
			Camera val2 = (((int)hud.renderMode == 0) ? null : hud.worldCamera);
			float num3 = (float)Screen.height * Mathf.Tan(Plugin.PanelSlotAngle.Value * 0.5f * (MathF.PI / 180f)) / Mathf.Tan(val.fieldOfView * 0.5f * (MathF.PI / 180f));
			float num4 = Mathf.Max(hud.scaleFactor, 0.0001f);
			int num5 = Mathf.Clamp(aroundCells.Length, 0, 4);
			Vector2 val5 = default(Vector2);
			for (int i = 0; i < slots.Length; i++)
			{
				bool flag = ((i == 4) ? middle.HasValue : (i < num5));
				SlotUI slotUI = slots[i];
				Vector3 val3 = SlotWorld(i);
				Vector3 val4 = val.WorldToScreenPoint(val3);
				if (val4.z <= 0.05f)
				{
					flag = false;
				}
				if (Vector3.Angle(((Component)val).transform.forward, val3 - ((Component)val).transform.position) > 70f)
				{
					flag = false;
				}
				shown[i] = flag;
				if (((Component)slotUI.rt).gameObject.activeSelf != flag)
				{
					((Component)slotUI.rt).gameObject.SetActive(flag);
				}
				if (!flag)
				{
					((Behaviour)slotUI.name).enabled = false;
					continue;
				}
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(hudRect, Vector2.op_Implicit(val4), val2, ref val5))
				{
					((Transform)slotUI.rt).localPosition = Vector2.op_Implicit(val5);
				}
				bool flag2 = i == hovered;
				float num6 = num3 / num4 / 100f * (flag2 ? 1.15f : 1f);
				((Transform)slotUI.rt).localScale = Vector3.one * num6;
				((Transform)((TMP_Text)slotUI.name).rectTransform).localPosition = Vector2.op_Implicit(val5 + new Vector2(0f, -80f * num6));
				((Transform)((TMP_Text)slotUI.name).rectTransform).localScale = Vector3.one * num6;
				Draw(slotUI, (i == 4) ? middle.Value : aroundCells[i], flag2);
			}
		}

		private static void Draw(SlotUI ui, Cell cell, bool hover)
		{
			//IL_0010: 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_003f: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)ui.fill).color = (hover ? HoverFill : FillColor);
			((Behaviour)ui.outline).enabled = Plugin.SlotOrbs.Value;
			((Graphic)ui.outline).color = (hover ? Yellow : Color.white);
			bool flag = (Object)(object)cell.icon != (Object)null;
			((Behaviour)ui.icon).enabled = flag;
			if (flag)
			{
				ui.icon.texture = cell.icon;
				IntItemData val = default(IntItemData);
				((Graphic)ui.icon).color = ((cell.data != null && cell.data.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val)) ? ItemCooking.GetCookColor(val.Value) : Color.white);
			}
			((Behaviour)ui.name).enabled = cell.label != null || (hover && (Object)(object)cell.prefab != (Object)null);
			if (((Behaviour)ui.name).enabled)
			{
				((TMP_Text)ui.name).text = cell.label ?? cell.prefab.GetItemName(cell.data);
			}
		}

		public void Hide()
		{
			if ((Object)(object)container != (Object)null && ((Component)container).gameObject.activeSelf)
			{
				((Component)container).gameObject.SetActive(false);
			}
		}

		public int HitTest(Ray ray)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!Visible || metresPerPx <= 0f)
			{
				return -1;
			}
			Plane val = default(Plane);
			((Plane)(ref val))..ctor(facing * Vector3.forward, center);
			float num = default(float);
			if (!((Plane)(ref val)).Raycast(ray, ref num))
			{
				return -1;
			}
			Vector3 val2 = Quaternion.Inverse(facing) * (((Ray)(ref ray)).GetPoint(num) - center) / metresPerPx;
			for (int i = 0; i < slots.Length; i++)
			{
				if (shown[i])
				{
					Vector2 val3 = SlotOffset(i);
					if (Mathf.Abs(val2.x - val3.x) <= 55f && Mathf.Abs(val2.y - val3.y) <= 55f)
					{
						return i;
					}
				}
			}
			return -1;
		}
	}
	[DefaultExecutionOrder(-50)]
	public class PeakleHands : MonoBehaviour
	{
		private enum PanelKind
		{
			None,
			OwnSlots,
			Held,
			WornSlots,
			ItemSlots,
			Rocket
		}

		public enum HoldKind : byte
		{
			Surface,
			Rope,
			Vine,
			Piton,
			Scout
		}

		public class Hand
		{
			public int id;

			public HoldKind kind;

			public Transform anchor;

			public ClimbModifierSurface surface;

			public CollisionModifier hazard;

			public Item collidersOf;

			public Collider[] colliders;

			public bool offUsing;

			public float offUseStart;

			public Character target;

			public Bodypart targetPart;

			public Vector3 targetLocal;

			public Vector3 anchorLocal;

			public float anchorSync;

			public bool grabbing;

			public Vector3 point;

			public Vector3 normal;

			public float holdTime;

			public float slide;

			public float slideSync;

			public float grip = 10f;

			public float grabWait;

			public float regenWait;

			public bool interacting;

			public bool cooking;

			public bool reaching;

			public Item item;

			public bool spawnPending;

			public bool down;

			public bool held;

			public bool up;

			public byte HandSlot
			{
				get
				{
					if (id != 0)
					{
						return 250;
					}
					return 0;
				}
			}

			public byte PocketSlot
			{
				get
				{
					if (id != 0)
					{
						return 2;
					}
					return 1;
				}
			}

			public BodypartType Bodypart
			{
				get
				{
					if (id == 0)
					{
						return (BodypartType)7;
					}
					return (BodypartType)10;
				}
			}

			public string GripName
			{
				get
				{
					if (id != 0)
					{
						return "Hand_R";
					}
					return "Hand_L";
				}
			}

			public float Side
			{
				get
				{
					if (id != 0)
					{
						return 1f;
					}
					return -1f;
				}
			}
		}

		private class HitDistance : IComparer<RaycastHit>
		{
			public static readonly HitDistance Instance = new HitDistance();

			public int Compare(RaycastHit a, RaycastHit b)
			{
				return ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance);
			}
		}

		private const float HideAngle = 75f;

		internal Hand backpackHand;

		private bool tabHeld;

		private bool tabWasHeld;

		private Vector3 openDirection;

		private PanelKind panelKind;

		private BackpackOnBackVisuals panelWorn;

		private Backpack panelItem;

		private float panelGrace;

		private int hoveredSlot = -1;

		private PanelKind loggedKind;

		private static BackpackPanel panel;

		private Bounds ownPackBounds;

		private float ownPackBoundsTime = -1f;

		private Renderer[] ownPackRenderers;

		private BackpackOnBackVisuals ownPackRenderersOf;

		private const float CarryHoldTime = 0.6f;

		internal string carryPrompt;

		internal float carryProgress;

		private bool carryNeedsRelease;

		public const int Left = 0;

		public const int Right = 1;

		public readonly Hand[] hands = new Hand[2]
		{
			new Hand
			{
				id = 0
			},
			new Hand
			{
				id = 1
			}
		};

		internal Character character;

		private PhotonView view;

		internal int pickupHand = -1;

		private Hand useHand;

		private Hand dropHand;

		private float reconcileTimer;

		private float swapGraceUntil;

		private WkBody body;

		private bool interactionActive;

		private bool useFeeds;

		private Hand offUseHand;

		private Hand pairHand;

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

		private int lastFreeMask = -1;

		private const float SlipGrip = 0.1f;

		private float windCost = 1f;

		private float nextHazardTime;

		internal bool wkFlight;

		internal float camWeight;

		internal Vector3 camOffsetFromHip;

		private bool remoteWk;

		private bool sentWk;

		private bool landedOnWk;

		private CharacterSyncer syncer;

		internal bool OwnBackpackShown
		{
			get
			{
				if (panelKind == PanelKind.OwnSlots)
				{
					return TabThingsInView;
				}
				return false;
			}
		}

		private bool TabThingsInView
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Cam != (Object)null)
				{
					return Vector3.Angle(Cam.forward, openDirection) <= 75f;
				}
				return false;
			}
		}

		private bool PanelIsJetpack
		{
			get
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Invalid comparison between Unknown and I4
				if (panelKind != PanelKind.WornSlots)
				{
					if (panelKind == PanelKind.ItemSlots && (Object)(object)panelItem != (Object)null)
					{
						return (int)panelItem.backpackType == 3;
					}
					return false;
				}
				return IsJetpack(panelWorn);
			}
		}

		private Transform Cam
		{
			get
			{
				if (!((Object)(object)MainCamera.instance != (Object)null))
				{
					return null;
				}
				return ((Component)MainCamera.instance).transform;
			}
		}

		public Hand ActiveHand
		{
			get
			{
				Item val = (((Object)(object)character != (Object)null) ? character.data.currentItem : null);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				Hand[] array = hands;
				foreach (Hand hand in array)
				{
					if ((Object)(object)hand.item == (Object)(object)val)
					{
						return hand;
					}
				}
				return null;
			}
		}

		internal bool Anchored
		{
			get
			{
				if (character.data.isGrounded)
				{
					return true;
				}
				Hand[] array = hands;
				foreach (Hand hand in array)
				{
					if (hand.grabbing && hand.kind != HoldKind.Scout)
					{
						return true;
					}
				}
				return false;
			}
		}

		public bool Hanging
		{
			get
			{
				if (!Holds(hands[0]))
				{
					return Holds(hands[1]);
				}
				return true;
			}
		}

		public bool HangingAirborne
		{
			get
			{
				if (Hanging)
				{
					return !BodyGrounded;
				}
				return false;
			}
		}

		public int HangingCount => (Holds(hands[0]) ? 1 : 0) + (Holds(hands[1]) ? 1 : 0);

		internal bool Disabled
		{
			get
			{
				if (!((Object)(object)character == (Object)null) && !character.isBot)
				{
					return character.isZombie;
				}
				return true;
			}
		}

		private float Scale => Plugin.WkScale.Value;

		private bool BodyGrounded
		{
			get
			{
				if (!body.Active)
				{
					return character.data.isGrounded;
				}
				return body.IsGrounded;
			}
		}

		internal Vector3? WkEyePosition
		{
			get
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				if (!view.IsMine || !body.Active)
				{
					return null;
				}
				return body.EyePosition(character.data.lookDirection_Flat);
			}
		}

		public bool OnWkPhysics
		{
			get
			{
				if (!view.IsMine)
				{
					return remoteWk;
				}
				if (!Hanging)
				{
					return wkFlight;
				}
				return true;
			}
		}

		internal Hand UsingHand
		{
			get
			{
				Hand activeHand = ActiveHand;
				if (activeHand == null)
				{
					return null;
				}
				Item item = activeHand.item;
				if (!item.isUsingPrimary && !(item.progress > 0f) && !(character.data.overrideIKForSeconds > 0f))
				{
					return null;
				}
				return activeHand;
			}
		}

		internal static event Action LocalActiveHandChanged;

		private BackpackOnBackVisuals OwnWornVisuals()
		{
			Player player = character.player;
			if ((Object)(object)player == (Object)null || player.backpackSlot == null || ((ItemSlot)player.backpackSlot).IsEmpty() || (Object)(object)character.refs.backpackHandler == (Object)null)
			{
				return null;
			}
			return character.refs.backpackHandler.activeBackpackVisuals;
		}

		private static bool IsRocket(BackpackOnBackVisuals visuals)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if ((Object)(object)visuals != (Object)null)
			{
				return (int)visuals.backpackType == 4;
			}
			return false;
		}

		private static bool IsJetpack(BackpackOnBackVisuals visuals)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if ((Object)(object)visuals != (Object)null)
			{
				return (int)visuals.backpackType == 3;
			}
			return false;
		}

		private bool CanTakeOff()
		{
			ItemSlot val = (ItemSlot)(object)(((Object)(object)character.player != (Object)null) ? character.player.backpackSlot : null);
			if (val != null && !val.IsEmpty() && (Object)(object)val.prefab != (Object)null)
			{
				return val.prefab.UIData.canDrop;
			}
			return false;
		}

		private Hand HandHoldingBackpack()
		{
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (hand.item is Backpack)
				{
					return hand;
				}
			}
			return null;
		}

		private void UpdateBackpackInput()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Invalid comparison between Unknown and I4
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			BackpackOnBackVisuals val = OwnWornVisuals();
			tabHeld = Controls.Held("Backpack");
			IInteractible val2 = (((Object)(object)Interaction.instance != (Object)null) ? Interaction.instance.bestInteractable : null);
			if (UpdateCarry(tabHeld, val2))
			{
				tabHeld = false;
			}
			Vector3 center;
			if (tabHeld && !tabWasHeld && (Object)(object)Cam != (Object)null)
			{
				center = Vector3.Lerp(((Vector3)(ref character.data.lookDirection_Flat)).normalized, Cam.forward, 0.5f);
				openDirection = ((Vector3)(ref center)).normalized;
			}
			tabWasHeld = tabHeld;
			if (backpackHand != null && (!backpackHand.held || (Object)(object)val == (Object)null || !CanTakeOff() || (Object)(object)backpackHand.item != (Object)null || backpackHand.grabbing))
			{
				backpackHand = null;
			}
			PanelKind panelKind = PanelKind.None;
			BackpackOnBackVisuals val3 = null;
			Backpack val4 = null;
			if ((tabHeld || backpackHand != null) && (Object)(object)val != (Object)null && CanTakeOff())
			{
				panelKind = PanelKind.OwnSlots;
				val3 = val;
			}
			else if (tabHeld && HandHoldingBackpack() != null)
			{
				panelKind = PanelKind.Held;
				val4 = (Backpack)HandHoldingBackpack().item;
			}
			else
			{
				BackpackOnBackVisuals val5 = (BackpackOnBackVisuals)(object)((val2 is BackpackOnBackVisuals) ? val2 : null);
				if (val5 != null && (Object)(object)val5.character != (Object)null && (Object)(object)val5.character != (Object)(object)character && (Object)(object)val5.character.player != (Object)null && !((ItemSlot)val5.character.player.backpackSlot).IsEmpty())
				{
					val3 = val5;
					panelKind = (IsRocket(val5) ? PanelKind.Rocket : ((val5.slotCount > 0 || IsJetpack(val5)) ? PanelKind.WornSlots : PanelKind.None));
				}
				else
				{
					Backpack val6 = (Backpack)(object)((val2 is Backpack) ? val2 : null);
					if (val6 != null && (int)((Item)val6).itemState == 0 && (val6.slotCount > 0 || (int)val6.backpackType == 3))
					{
						panelKind = PanelKind.ItemSlots;
						val4 = val6;
					}
				}
			}
			if (panelKind != PanelKind.None)
			{
				this.panelKind = panelKind;
				panelWorn = val3;
				panelItem = val4;
				panelGrace = 0.3f;
			}
			else
			{
				panelGrace -= Time.deltaTime;
				if (panelGrace <= 0f || this.panelKind == PanelKind.OwnSlots || this.panelKind == PanelKind.Held)
				{
					this.panelKind = PanelKind.None;
					panelWorn = null;
					panelItem = null;
				}
			}
			if (this.panelKind != PanelKind.None && !PanelAnchor(out center, out var _))
			{
				this.panelKind = PanelKind.None;
			}
			if (this.panelKind != loggedKind)
			{
				loggedKind = this.panelKind;
				Plugin.Log.LogInfo((object)string.Format("Backpack panel: {0} (looking at {1})", this.panelKind, (val2 == null) ? "nothing" : ((object)val2).GetType().Name));
			}
			hoveredSlot = ((panel != null && panel.Visible && this.panelKind != PanelKind.None && (Object)(object)Cam != (Object)null) ? panel.HitTest(new Ray(Cam.position, Cam.forward)) : (-1));
		}

		private bool TryDropHeldBackpack(Hand hand, bool dropPressed)
		{
			//IL_005d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (hand != backpackHand || !dropPressed || ((ItemSlot)character.player.backpackSlot).IsEmpty())
			{
				return false;
			}
			Vector3 position;
			Quaternion rotation;
			Vector3 val = (OwnTabPose(out position, out rotation) ? position : (character.Center + character.data.lookDirection_Flat * 0.5f));
			character.refs.items.photonView.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2]
			{
				(byte)3,
				val
			});
			backpackHand = null;
			return true;
		}

		private bool HandleBackpackButton(Hand hand)
		{
			if (hand == backpackHand)
			{
				return true;
			}
			if (!hand.down || hand.grabbing)
			{
				return false;
			}
			if (panelKind != PanelKind.None && hoveredSlot >= 0)
			{
				UseSlot(hand, hoveredSlot);
				return true;
			}
			if (panelKind == PanelKind.OwnSlots && IsFree(hand) && LookingAtOwnBackpack() && !((ItemSlot)character.player.backpackSlot).IsEmpty())
			{
				view.RPC("RPCM_PeakleMoveSlots", (RpcTarget)2, new object[3]
				{
					(byte)3,
					hand.HandSlot,
					false
				});
				return true;
			}
			return false;
		}

		private void UseSlot(Hand hand, int slotIndex)
		{
			if (slotIndex == 4)
			{
				if (panelKind == PanelKind.Rocket)
				{
					panelWorn.character.refs.backpackHandler.LightRocket(3f);
				}
				else if (panelKind == PanelKind.Held && (Object)(object)hand.item == (Object)(object)panelItem && ((ItemSlot)character.player.backpackSlot).IsEmpty())
				{
					view.RPC("RPCM_PeakleMoveSlots", (RpcTarget)2, new object[3]
					{
						hand.HandSlot,
						(byte)3,
						false
					});
				}
				else if (PanelIsJetpack && (Object)(object)hand.item != (Object)null && (Object)(object)hand.item != (Object)(object)panelItem && hand.item.progress <= 0f && hand.item.UIData.canDrop)
				{
					SetActiveHand(hand);
					if (panelKind == PanelKind.ItemSlots)
					{
						panelItem.AddFuel(character);
					}
					else
					{
						panelWorn.character.refs.backpackHandler.AddFuelToJetpack(character, 50f);
					}
				}
				return;
			}
			BackpackData val = PanelData();
			if (val == null)
			{
				return;
			}
			ItemSlot val2 = val.itemSlots[slotIndex];
			BackpackVisuals val3 = (BackpackVisuals)((panelKind == PanelKind.WornSlots || panelKind == PanelKind.OwnSlots) ? ((object)panelWorn) : ((object)((Component)panelItem).GetComponent<ItemBackpackVisuals>()));
			if (!val2.IsEmpty() && (Object)(object)hand.item == (Object)null)
			{
				Item val4 = default(Item);
				if (panelKind == PanelKind.Held)
				{
					view.RPC("RPCM_PeakleTakeFromBackpackItem", (RpcTarget)2, new object[3]
					{
						((MonoBehaviourPun)panelItem).photonView.ViewID,
						(byte)slotIndex,
						hand.HandSlot
					});
				}
				else if ((Object)(object)val3 != (Object)null && val3.TryGetSpawnedItem((byte)slotIndex, ref val4) && (Object)(object)val4 != (Object)null)
				{
					SetPickupHand(hand.id);
					val4.Interact(character);
				}
			}
			else if (val2.IsEmpty() && (Object)(object)hand.item != (Object)null && hand.item.UIData.canBackpack && hand.item.progress <= 0f && (Object)(object)hand.item != (Object)(object)panelItem)
			{
				SetActiveHand(hand);
				if (panelKind == PanelKind.ItemSlots || panelKind == PanelKind.Held)
				{
					panelItem.Stash(character, (byte)slotIndex);
				}
				else
				{
					panelWorn.character.refs.backpackHandler.StashInBackpack(character, (byte)slotIndex);
				}
			}
		}

		[PunRPC]
		public void RPCM_PeakleTakeFromBackpackItem(int backpackViewID, byte backpackSlot, byte handSlot)
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient || (Object)(object)character.player == (Object)null)
			{
				return;
			}
			PhotonView val = PhotonView.Find(backpackViewID);
			Backpack val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Backpack>() : null);
			BackpackData val3 = default(BackpackData);
			if ((Object)(object)val2 == (Object)null || ((Item)val2).data == null || !((Item)val2).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val3))
			{
				return;
			}
			ItemSlot val4 = val3.itemSlots[backpackSlot];
			ItemSlot itemSlot = character.player.GetItemSlot(handSlot);
			if (val4 != null && !val4.IsEmpty() && itemSlot != null && itemSlot.IsEmpty())
			{
				itemSlot.SetItem(val4.prefab, val4.data);
				val4.EmptyOut();
				val.RPC("SetItemInstanceDataRPC", (RpcTarget)1, new object[1] { ((Item)val2).data });
				ItemBackpackVisuals component = ((Component)val2).GetComponent<ItemBackpackVisuals>();
				if (component != null)
				{
					((BackpackVisuals)component).RefreshVisuals();
				}
				Player player = character.player;
				byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot));
				((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2] { array, false });
				player.itemsChangedAction?.Invoke(player.itemSlots);
				if (view.IsMine)
				{
					Reconcile();
				}
			}
		}

		private BackpackPanel.Cell? FuelCell()
		{
			if (!PanelIsJetpack)
			{
				return null;
			}
			Item val = (Item)((panelKind == PanelKind.ItemSlots) ? ((object)panelItem) : ((object)((ItemSlot)panelWorn.character.player.backpackSlot).prefab));
			ItemInstanceData val2 = ((panelKind == PanelKind.ItemSlots) ? ((Item)panelItem).data : ((ItemSlot)panelWorn.character.player.backpackSlot).data);
			FloatItemData val3 = default(FloatItemData);
			float num = ((val2 != null && val2.TryGetDataEntry<FloatItemData>((DataEntryKey)11, ref val3)) ? val3.Value : 0f);
			return new BackpackPanel.Cell
			{
				prefab = val,
				icon = (Texture)(object)(((Object)(object)val != (Object)null) ? val.UIData.GetIcon() : null),
				label = $"Fuel {Mathf.RoundToInt(Mathf.Clamp01(num) * 100f)}%"
			};
		}

		private BackpackData PanelData()
		{
			if (panelKind == PanelKind.ItemSlots || panelKind == PanelKind.Held)
			{
				BackpackData result = default(BackpackData);
				if (!((Object)(object)panelItem != (Object)null) || ((Item)panelItem).data == null || !((Item)panelItem).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref result))
				{
					return null;
				}
				return result;
			}
			Character val = (((Object)(object)panelWorn != (Object)null) ? panelWorn.character : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val.player == (Object)null || ((ItemSlot)val.player.backpackSlot).IsEmpty())
			{
				return null;
			}
			BackpackData result2 = default(BackpackData);
			if (!((ItemSlot)val.player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref result2))
			{
				return null;
			}
			return result2;
		}

		internal bool OwnTabPose(out Vector3 position, out Quaternion rotation)
		{
			//IL_0023: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Transform cam = Cam;
			if ((Object)(object)cam == (Object)null || openDirection == Vector3.zero)
			{
				position = default(Vector3);
				rotation = default(Quaternion);
				return false;
			}
			position = cam.position + openDirection * Plugin.TabDistance.Value;
			rotation = Quaternion.LookRotation(openDirection, Vector3.up);
			return true;
		}

		private bool LookingAtOwnBackpack()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			Transform cam = Cam;
			if ((Object)(object)cam == (Object)null || Time.time - ownPackBoundsTime > 0.5f)
			{
				return false;
			}
			Bounds val = ownPackBounds;
			((Bounds)(ref val)).Expand(0.06f);
			return ((Bounds)(ref val)).IntersectRay(new Ray(cam.position, cam.forward));
		}

		private bool PackBounds(BackpackOnBackVisuals visuals, out Bounds bounds)
		{
			//IL_0047: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ownPackRenderersOf != (Object)(object)visuals || ownPackRenderers == null)
			{
				ownPackRenderers = (((Object)(object)visuals.view != (Object)null) ? visuals.view.GetComponentsInChildren<Renderer>(true) : ((Component)visuals).GetComponentsInChildren<Renderer>(true));
				ownPackRenderersOf = visuals;
			}
			bounds = default(Bounds);
			bool flag = false;
			Renderer[] array = ownPackRenderers;
			foreach (Renderer val in array)
			{
				if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy)
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			return flag;
		}

		internal Vector3 BackpackGripPoint(Hand hand)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			OwnTabPose(out var position, out var rotation);
			return position + rotation * Vector3.right * (hand.Side * 0.17f * Plugin.WkScale.Value);
		}

		private bool PanelAnchor(out Vector3 center, out Quaternion facing)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			Transform cam = Cam;
			center = default(Vector3);
			facing = Quaternion.identity;
			if ((Object)(object)cam == (Object)null)
			{
				return false;
			}
			if (panelKind == PanelKind.OwnSlots || panelKind == PanelKind.Held)
			{
				return OwnTabPose(out center, out facing);
			}
			Transform val = (((Object)(object)panelWorn != (Object)null) ? ((Component)panelWorn).transform : (((Object)(object)panelItem != (Object)null) ? ((Item)panelItem).transform : null));
			if ((Object)(object)val == (Object)null || Vector3.Distance(val.position, cam.position) > 2.5f * Plugin.WkScale.Value)
			{
				return false;
			}
			Vector3 position = val.position;
			Vector3 val2 = cam.position - val.position;
			center = position + ((Vector3)(ref val2)).normalized * (0.15f * Plugin.WkScale.Value);
			facing = Quaternion.LookRotation(center - cam.position, Vector3.up);
			return true;
		}

		internal void RenderBackpacks()
		{
			//IL_0045: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			BackpackOnBackVisuals val = OwnWornVisuals();
			if ((Object)(object)val != (Object)null && OwnBackpackShown && OwnTabPose(out var position, out var rotation))
			{
				val.SetViewActive(true);
				ArmVisuals.SaveForRender(((Component)val).transform);
				((Component)val).transform.SetPositionAndRotation(position, rotation);
				if (PackBounds(val, out var bounds))
				{
					Transform transform = ((Component)val).transform;
					transform.position += position - ((Bounds)(ref bounds)).center;
					((Bounds)(ref bounds)).center = position;
					ownPackBounds = bounds;
					ownPackBoundsTime = Time.time;
				}
				Item val2 = default(Item);
				for (byte b = 0; b < ((BackpackVisuals)val).backpackSlots.Length; b++)
				{
					if (((BackpackVisuals)val).TryGetSpawnedItem(b, ref val2) && (Object)(object)val2 != (Object)null && (Object)(object)((BackpackVisuals)val).backpackSlots[b] != (Object)null)
					{
						Transform val3 = ((BackpackVisuals)val).backpackSlots[b];
						val2.transform.SetPositionAndRotation(val3.position - val3.rotation * val2.centerOfMass * 0.5f, val3.rotation);
					}
				}
			}
			bool flag = panelKind == PanelKind.OwnSlots || panelKind == PanelKind.Held;
			if (panelKind == PanelKind.None || (flag && !TabThingsInView) || !PanelAnchor(out var center, out var facing))
			{
				panel?.Hide();
				return;
			}
			if (panel != null && !panel.Alive)
			{
				panel.Destroy();
				panel = null;
			}
			if ((Object)(object)GUIManager.instance == (Object)null || GUIManager.instance.windowBlockingInput || !character.CanDoInput())
			{
				panel?.Hide();
				return;
			}
			if (panel == null)
			{
				panel = BackpackPanel.Create();
			}
			if (panel != null)
			{
				switch (panelKind)
				{
				case PanelKind.Rocket:
				{
					Item prefab = ((ItemSlot)panelWorn.character.player.backpackSlot).prefab;
					BackpackPanel.Cell value = new BackpackPanel.Cell
					{
						prefab = prefab,
						icon = (Texture)(object)(((Object)(object)prefab != (Object)null) ? prefab.UIData.GetIcon() : null)
					};
					panel.Show(center, facing, Array.Empty<BackpackPanel.Cell>(), value, hoveredSlot, 0f);
					break;
				}
				case PanelKind.Held:
				{
					BackpackPanel.Cell? middle = (((ItemSlot)character.player.backpackSlot).IsEmpty() ? new BackpackPanel.Cell?(new BackpackPanel.Cell
					{
						icon = (Texture)(object)((Item)panelItem).UIData.GetIcon(),
						faded = true
					}) : ((BackpackPanel.Cell?)null));
					panel.Show(center, facing, PanelData(), panelItem.slotCount, middle, hoveredSlot, 1.3f);
					break;
				}
				case PanelKind.ItemSlots:
					panel.Show(center, facing, PanelData(), panelItem.slotCount, FuelCell(), hoveredSlot, 1.3f);
					break;
				case PanelKind.OwnSlots:
					panel.Hide();
					break;
				default:
					panel.Show(center, facing, PanelData(), panelWorn.slotCount, FuelCell(), hoveredSlot, 1.3f);
					break;
				}
			}
		}

		private bool UpdateCarry(bool tab, IInteractible looked)
		{
			Character carriedPlayer = character.data.carriedPlayer;
			Character val = null;
			if ((Object)(object)carriedPlayer == (Object)null)
			{
				CharacterInteractible val2 = (CharacterInteractible)(object)((looked is CharacterInteractible) ? looked : null);
				if (val2 != null && (Object)(object)val2.character != (Object)null && (Object)(object)val2.character != (Object)(object)character && val2.character.data.fullyPassedOut && !val2.character.data.dead && (Object)(object)val2.character.data.carrier == (Object)null)
				{
					val = val2.character;
				}
			}
			if ((Object)(object)carriedPlayer == (Object)null && (Object)(object)val == (Object)null)
			{
				carryPrompt = null;
				carryProgress = 0f;
				carryNeedsRelease &= tab;
				return false;
			}
			carryPrompt = (((Object)(object)carriedPlayer != (Object)null) ? "put down" : "carry");
			if (!tab)
			{
				carryNeedsRelease = false;
			}
			if (tab && !carryNeedsRelease)
			{
				carryProgress += Time.deltaTime / 0.6f;
				if (carryProgress >= 1f)
				{
					carryProgress = 0f;
					carryNeedsRelease = true;
					if ((Object)(object)carriedPlayer != (Object)null)
					{
						character.refs.carriying.Drop(carriedPlayer);
					}
					else
					{
						character.refs.carriying.StartCarry(val);
					}
				}
			}
			else
			{
				carryProgress = 0f;
			}
			return true;
		}

		private bool TryGrabScout(Hand hand)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)MainCamera.instance).transform.position;
			Vector3 lookDirection = character.data.lookDirection;
			float num = 2.5f * Scale;
			int num2 = Physics.SphereCastNonAlloc(position, 0.08f * Scale, lookDirection, grabHits, num, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)1);
			Array.Sort(grabHits, 0, num2, HitDistance.Instance);
			Character val = default(Character);
			for (int i = 0; i < num2; i++)
			{
				Collider collider = ((RaycastHit)(ref grabHits[i])).collider;
				if (!((Object)(object)collider == (Object)null) && !character.refs.ragdoll.colliderList.Contains(collider))
				{
					if (!CharacterRagdoll.TryGetCharacterFromCollider(collider, ref val) || (Object)(object)val == (Object)(object)character || val.data.dead)
					{
						return false;
					}
					Bodypart componentInParent = ((Component)collider).GetComponentInParent<Bodypart>();
					if ((Object)(object)componentInParent == (Object)null)
					{
						return false;
					}
					Vector3 val2 = ((((RaycastHit)(ref grabHits[i])).distance > 0f) ? ((RaycastHit)(ref grabHits[i])).point : collider.ClosestPoint(position));
					Vector3 val3 = componentInParent.transform.InverseTransformPoint(val2);
					view.RPC("RPCA_PeakleGrabScout", (RpcTarget)0, new object[4]
					{
						(byte)hand.id,
						((MonoBehaviourPun)val).photonView.ViewID,
						(byte)componentInParent.partType,
						val3
					});
					return true;
				}
			}
			return false;
		}

		private void FollowScoutHolds()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (!hand.grabbing || hand.kind != HoldKind.Scout)
				{
					continue;
				}
				if ((Object)(object)hand.target == (Object)null || (Object)(object)hand.targetPart == (Object)null || hand.target.data.dead)
				{
					if (view.IsMine)
					{
						view.RPC("RPCA_PeakleRelease", (RpcTarget)0, new object[1] { (byte)hand.id });
					}
					continue;
				}
				hand.point = hand.targetPart.transform.TransformPoint(hand.targetLocal);
				Vector3 val = (body.Active ? body.Position : character.Center);
				Vector3 val2 = val - hand.point;
				hand.normal = ((Vector3)(ref val2)).normalized;
				if (view.IsMine && Vector3.Distance(val, hand.point) > 2.5f * Scale * 1.5f)
				{
					view.RPC("RPCA_PeakleRelease", (RpcTarget)0, new object[1] { (byte)hand.id });
				}
			}
		}

		[PunRPC]
		public void RPCA_PeakleGrabScout(byte id, int viewID, byte part, Vector3 local)
		{
			//IL_006c: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(viewID);
			Character val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Character>() : null);
			if (!((Object)(object)val2 == (Object)null))
			{
				Hand obj = hands[id];
				obj.grabbing = true;
				obj.kind = HoldKind.Scout;
				obj.slide = 0f;
				obj.holdTime = 0f;
				obj.anchor = null;
				obj.target = val2;
				obj.targetPart = val2.GetBodypart((BodypartType)part);
				obj.targetLocal = local;
				obj.point = obj.targetPart.transform.TransformPoint(local);
			}
		}

		private void ApplyDrags(float dt)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: 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)
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)null || (Object)(object)allCharacter == (Object)(object)character)
				{
					continue;
				}
				PeakleHands peakleHands = HandsOf.Get((Component)(object)allCharacter);
				if ((Object)(object)peakleHands == (Object)null)
				{
					continue;
				}
				Hand[] array = peakleHands.hands;
				foreach (Hand hand in array)
				{
					if (!hand.grabbing || hand.kind != HoldKind.Scout || (Object)(object)hand.target != (Object)(object)character || (Object)(object)hand.targetPart == (Object)null)
					{
						continue;
					}
					if (character.IsStuck())
					{
						character.UnStick();
					}
					character.refs.afflictions.SubtractStatus((STATUSTYPE)11, 1f, false, false);
					character.refs.afflictions.SubtractStatus((STATUSTYPE)14, 1f, false, false);
					character.data.sinceGrabFriend = 0f;
					if (peakleHands.Anchored)
					{
						character.LimitFalling();
						Vector3 val = allCharacter.GetBodypart((BodypartType)4).Rig.position + allCharacter.data.lookDirection * (Plugin.DragHoldDistance.Value * Scale) + allCharacter.data.lookDirection_Right * (hand.Side * 0.2f * Scale);
						Vector3 val2 = hand.targetPart.transform.TransformPoint(hand.targetLocal);
						Vector3 val3 = (val - val2) / Plugin.ScoutMass.Value * 8f;
						float num = (character.data.fullyConscious ? Plugin.ConsciousDragGive.Value : 1f);
						if (body.Active)
						{
							body.vel = Vector3.Lerp(body.vel, val3 / WkBody.Metres, num);
						}
						else
						{
							AddBodyVelocity((val3 - AverageVelocity()) * num);
						}
					}
				}
			}
		}

		private bool Holds(Hand hand)
		{
			if (hand.grabbing)
			{
				if (hand.kind == HoldKind.Scout)
				{
					if (!character.data.isGrounded)
					{
						return IsAnchored(hand.target);
					}
					return false;
				}
				return true;
			}
			return false;
		}

		private static bool IsAnchored(Character scout)
		{
			if ((Object)(object)scout == (Object)null)
			{
				return false;
			}
			PeakleHands peakleHands = HandsOf.Get((Component)(object)scout);
			if (!((Object)(object)peakleHands != (Object)null))
			{
				return scout.data.isGrounded;
			}
			return peakleHands.Anchored;
		}

		private void Awake()
		{
			character = ((Component)this).GetComponent<Character>();
			view = ((Component)this).GetComponent<PhotonView>();
			body = new WkBody(character);
		}

		private void Start()
		{
			if (!Disabled && view.IsMine)
			{
				PromptRefresher.RefreshAll();
			}
		}

		internal void OnInputSampled(bool active)
		{
			if (Disabled || !view.IsMine)
			{
				return;
			}
			CharacterInput input = character.input;
			Hand hand = hands[0];
			Hand hand2 = hands[1];
			hand.down = active && Controls.Down("Left Hand");
			hand.held = active && Controls.Held("Left Hand");
			hand.up = Controls.Up("Left Hand");
			hand2.down = active && Controls.Down("Right Hand");
			hand2.held = active && Controls.Held("Right Hand");
			hand2.up = Controls.Up("Right Hand");
			if (active && Hanging && Controls.Held("Hold Still"))
			{
				input.crouchIsPressed = true;
			}
			bool jumpWasPressed = input.jumpWasPressed;
			bool interactWasPressed = input.interactWasPressed;
			bool interactIsPressed = input.interactIsPressed;
			bool interactWasReleased = input.interactWasReleased;
			input.usePrimaryWasPressed = (input.usePrimaryIsPressed = (input.usePrimaryWasReleased = false));
			input.useSecondaryWasPressed = (input.useSecondaryIsPressed = (input.useSecondaryWasReleased = false));
			input.interactWasPressed = (input.interactIsPressed = (input.interactWasReleased = false));
			input.dropWasPressed = (input.dropIsPressed = (input.dropWasReleased = false));
			Hand[] array;
			if (!active || !character.data.fullyConscious || character.data.dead || !character.CanDoInput())
			{
				if (character.data.fullyPassedOut)
				{
					input.interactWasPressed = interactWasPressed;
					input.interactIsPressed = interactIsPressed;
					input.interactWasReleased = interactWasReleased;
				}
				array = hands;
				foreach (Hand hand3 in array)
				{
					hand3.down = (hand3.held = false);
					StopInteracting(hand3);
					if (hand3.reaching)
					{
						view.RPC("RPCA_PeakleReach", (RpcTarget)0, new object[2]
						{
							(byte)hand3.id,
							false
						});
					}
				}
				useHand = null;
				dropHand = null;
				backpackHand = null;
				tabHeld = false;
				return;
			}
			UpdateBackpackInput();
			if (hands[0].grabbing || hands[1].grabbing)
			{
				input.emoteIsPressed = false;
			}
			bool flag = true;
			if (Controls.OnGamepad)
			{
				if (ItemScrolling(character.data.currentItem))
				{
					flag = false;
				}
				else
				{
					input.scrollBackwardWasPressed = (input.scrollForwardWasPressed = false);
					input.scrollBackwardIsPressed = (input.scrollForwardIsPressed = false);
				}
			}
			if (flag && Controls.Down("Left Pocket"))
			{
				TryPocket(hand);
			}
			if (flag && Controls.Down("Right Pocket"))
			{
				TryPocket(hand2);
			}
			if (Controls.Down("Swap Hands"))
			{
				TrySwapHands();
			}
			if (!HandlePairThrow())
			{
				HandleDropKey(hand, "Drop Left");
				HandleDropKey(hand2, "Drop Right");
			}
			array = hands;
			foreach (Hand hand4 in array)
			{
				HandleHandButton(hand4);
			}
			UpdateOffHandUse();
			if (useHand != null)
			{
				if (useFeeds)
				{
					input.useSecondaryWasPressed = useHand.down;
					input.useSecondaryIsPressed = useHand.held;
					input.useSecondaryWasReleased = useHand.up;
				}
				else
				{
					input.usePrimaryWasPressed = useHand.down;
					input.usePrimaryIsPressed = useHand.held;
					input.usePrimaryWasReleased = useHand.up;
				}
				if (!useHand.held)
				{
					useHand = null;
					useFeeds = false;
				}
			}
			if (hand.interacting || hand2.interacting)
			{
				bool flag2 = (hand.interacting && hand.held) || (hand2.interacting && hand2.held);
				input.interactWasPressed = !interactionActive;
				input.interactIsPressed = flag2;
				input.interactWasReleased = !flag2;
				interactionActive = flag2;
				array = hands;
				foreach (Hand hand5 in array)
				{
					if (hand5.interacting && (!hand5.held || !flag2))
					{
						StopInteracting(hand5);
					}
				}
			}
			else
			{
				interactionActive = false;
			}
			if (jumpWasPressed && Hanging)
			{
				input.jumpWasPressed = false;
				GrabJump();
			}
		}

		private void HandleHandButton(Hand hand)
		{
			bool flag = hand.held && (Object)(object)hand.item == (Object)null && !hand.grabbing;
			if (flag != hand.reaching)
			{
				view.RPC("RPCA_PeakleReach", (RpcTarget)0, new object[2]
				{
					(byte)hand.id,
					flag
				});
			}
			if (hand.grabbing)
			{
				if (!hand.held)
				{
					view.RPC("RPCA_PeakleRelease", (RpcTarget)0, new object[1] { (byte)hand.id });
				}
			}
			else
			{
				if (HandleBackpackButton(hand))
				{
					return;
				}
				if (hand.down)
				{
					Hand hand2 = hands[1 - hand.id];
					if ((Object)(object)hand.item != (Object)null && IsCookingTarget(hand.item) && (!hand2.interacting || hand2.cooking))
					{
						if (!hand2.cooking)
						{
							SetActiveHand(hand);
						}
						else
						{
							ItemCooking component = ((Component)hand.item).GetComponent<ItemCooking>();
							if (component != null)
							{
								component.StartCookingVisuals();
							}
						}
						hand.interacting = true;
						hand.cooking = true;
						return;
					}
					if ((Object)(object)hand.item != (Object)null)
					{
						if (useHand == null && dropHand == null)
						{
							SetActiveHand(hand);
							useHand = hand;
							useFeeds = hand.item.canUseOnFriend && (Object)(object)Interaction.instance != (Object)null && Interaction.instance.hasValidTargetCharacter;
						}
						else if (useHand != null && useHand != hand && offUseHand == null && CanUseOffHand(hand.item))
						{
							offUseHand = hand;
							hand.item.StartUsePrimary();
							view.RPC("RPCA_PeakleOffUse", (RpcTarget)0, new object[2]
							{
								(byte)hand.id,
								true
							});
						}
						return;
					}
					if ((Object)(object)Interaction.instance != (Object)null && Interaction.instance.bestInteractable != null && !hands[1 - hand.id].interacting && !IsLitCampfire(Interaction.instance.bestInteractable) && !IsHoldInteractable(Interaction.instance.bestInteractable))
					{
						hand.interacting = true;
						SetPickupHand(hand.id);
						return;
					}
				}
				if (hand.held && !hand.interacting && (Object)(object)hand.item == (Object)null)
				{
					TryGrab(hand);
				}
			}
		}

		private static bool CanUseOffHand(Item item)
		{
			if ((Object)(object)item != (Object)null && item.progress <= 0f && item.CanUsePrimary())
			{
				if (!((Object)(object)((Component)item).GetComponent<Action_Consume>() != (Object)null) && !((Object)(object)((Component)item).GetComponent<Action_ConsumeAndSpawn>() != (Object)null))
				{
					return (Object)(object)((Component)item).GetComponent<Action_Flare>() != (Object)null;
				}
				return true;
			}
			return false;
		}

		[PunRPC]
		public void RPCA_PeakleOffUse(byte id, bool on)
		{
			hands[id].offUsing = on;
			hands[id].offUseStart = Time.time;
		}

		private void EndOffHandUse(Hand hand)
		{
			offUseHand = null;
			if (hand.offUsing)
			{
				view.RPC("RPCA_PeakleOffUse", (RpcTarget)0, new object[2]
				{
					(byte)hand.id,
					false
				});
			}
		}

		internal float UseProgress(Hand hand, Item item)
		{
			if (hand.offUsing && item.usingTimePrimary > 0f)
			{
				if (!view.IsMine)
				{
					return Mathf.Clamp01((Time.time - hand.offUseStart) / item.usingTimePrimary);
				}
				return item.progress;
			}
			return item.progress;
		}

		private void UpdateOffHandUse()
		{
			Hand hand = offUseHand;
			if (hand == null)
			{
				return;
			}
			Item item = hand.item;
			if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy)
			{
				EndOffHandUse(hand);
			}
			else if ((Object)(object)item == (Object)(object)character.data.currentItem)
			{
				EndOffHandUse(hand);
				if (hand.held && item.isUsingPrimary)
				{
					useHand = hand;
					useFeeds = false;
				}
			}
			else if (!hand.held || !item.CanUsePrimary())
			{
				if (item.isUsingPrimary && !item.finishedCast)
				{
					item.CancelUsePrimary();
				}
				EndOffHandUse(hand);
			}
			else
			{
				item.ContinueUsePrimary();
			}
		}

		internal void OnItemConsumed(Item item, bool wasInHand)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (wasInHand)
			{
				return;
			}
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if ((Object)(object)hand.item == (Object)(object)item)
				{
					character.player.EmptySlot(Optionable<byte>.Some(hand.HandSlot), true);
					Reconcile();
					break;
				}
			}
		}

		internal Item FeedItem(out Hand feedHand)
		{
			Hand activeHand = ActiveHand;
			Hand[] array = ((activeHand == null) ? hands : new Hand[2]
			{
				activeHand,
				hands[1 - activeHand.id]
			});
			foreach (Hand hand in array)
			{
				if ((Object)(object)hand.item != (Object)null && hand.item.canUseOnFriend)
				{
					feedHand = hand;
					return hand.item;
				}
			}
			feedHand = null;
			return null;
		}

		internal void AddWorldPush(Vector3 deltaVelocity)
		{
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (view.IsMine && body.Active)
			{
				WkBody wkBody = body;
				wkBody.vel += deltaVelocity * Plugin.WorldPushStrength.Value / WkBody.Metres;
			}
		}

		private void StopInteracting(Hand hand)
		{
			if (hand.cooking && (Object)(object)hand.item != (Object)null && (Object)(object)hand.item != (Object)(object)character.data.currentItem)
			{
				ItemCooking component = ((Component)hand.item).GetComponent<ItemCooking>();
				if (component != null)
				{
					component.CancelCookingVisuals();
				}
			}
			hand.interacting = false;
			hand.cooking = false;
		}

		internal IEnumerable<Item> CookingItems()
		{
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (hand.cooking && hand.held && (Object)(object)hand.item != (Object)null)
				{
					yield return hand.item;
				}
			}
		}

		private static bool IsCookingTarget(Item item)
		{
			if ((Object)(object)Interaction.instance != (Object)null && IsLitCampfire(Interaction.instance.bestInteractable))
			{
				return CanCook(item);
			}
			return false;
		}

		internal static bool IsLitCampfire(IInteractible interactible)
		{
			Campfire val = (Campfire)(object)((interactible is Campfire) ? interactible : null);
			if (val != null)
			{
				return val.Lit;
			}
			return false;
		}

		internal static bool CanCook(Item item)
		{
			if ((Object)(object)item != (Object)null && (Object)(object)item.cooking != (Object)null)
			{
				return item.cooking.canBeCooked;
			}
			return false;
		}

		internal static bool CanInteractWith(Hand hand, IInteractible target)
		{
			if (IsLitCampfire(target))
			{
				return CanCook(hand.item);
			}
			return IsFree(hand);
		}

		private static bool ItemScrolling(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (item.OnScrollBackwardPressed != null || item.OnScrollForwardPressed != null || item.OnScrollBackwardHeld != null || item.OnScrollForwardHeld != null)
			{
				if (!item.isUsingPrimary)
				{
					return ((Guidebook)(((item is Guidebook) ? item : null)?)).isOpen ?? false;
				}
				return true;
			}
			return false;
		}

		private bool HandlePairThrow()
		{
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			CharacterInput input = character.input;
			if (pairHand == null)
			{
				if (dropHand == null)
				{
					return false;
				}
				Hand hand = hands[1 - dropHand.id];
				if (!Controls.Held((hand.id == 0) ? "Drop Left" : "Drop Right") || (Object)(object)hand.item == (Object)null || !hand.item.UIData.canDrop || hand.item.progress > 0f || hand.item is Backpack)
				{
					return false;
				}
				pairHand = hand;
			}
			string name = ((dropHand.id == 0) ? "Drop Left" : "Drop Right");
			string name2 = ((pairHand.id == 0) ? "Drop Left" : "Drop Right");
			input.dropWasPressed = false;
			input.dropWasReleased = false;
			if (Controls.Held(name) && Controls.Held(name2) && (Object)(object)dropHand.item != (Object)null && (Object)(object)pairHand.item != (Object)null)
			{
				input.dropIsPressed = true;
				return true;
			}
			input.dropIsPressed = false;
			CharacterItems items = character.refs.items;
			float throwChargeLevel = items.throwChargeLevel;
			ThrowFromHand(dropHand, throwChargeLevel);
			ThrowFromHand(pairHand, throwChargeLevel);
			items.throwChargeLevel = 0f;
			items.pressedDrop = false;
			if (throwChargeLevel > 0.1f && (Object)(object)character.refs.animations != (Object)null)
			{
				character.refs.animations.throwTime = 0.125f;
			}
			items.EquipSlot(Optionable<byte>.None);
			dropHand = null;
			pairHand = null;
			return true;
		}

		private void ThrowFromHand(Hand hand, float charge)
		{
			//IL_0093: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Item item = hand.item;
			ItemSlot itemSlot = character.player.GetItemSlot(hand.HandSlot);
			if (!((Object)(object)item == (Object)null) && itemSlot != null && !itemSlot.IsEmpty())
			{
				SetActiveHand(hand);
				if (!((Object)(object)character.data.currentItem != (Object)(object)item))
				{
					character.refs.items.photonView.RPC("DropItemRpc", (RpcTarget)0, new object[7]
					{
						charge,
						hand.HandSlot,
						item.transform.position,
						((Object)(object)item.rig != (Object)null) ? item.rig.linearVelocity : Vector3.zero,
						item.transform.rotation,
						itemSlot.data,
						false
					});
				}
			}
		}

		private void HandleDropKey(Hand hand, string key)
		{
			bool flag = Controls.Down(key);
			bool flag2 = Controls.Held(key);
			bool dropWasReleased = Controls.Up(key);
			if (TryDropHeldBackpack(hand, flag))
			{
				return;
			}
			if (flag && (Object)(object)hand.item != (Object)null && dropHand == null && useHand == null)
			{
				SetActiveHand(hand);
				dropHand = hand;
			}
			if (dropHand == hand)
			{
				CharacterInput input = character.input;
				input.dropWasPressed = flag;
				input.dropIsPressed = flag2;
				input.dropWasReleased = dropWasReleased;
				if (!flag2)
				{
					dropHand = null;
				}
			}
		}

		private void TryGrab(Hand hand)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (!(hand.grabWait > 0f) && !(hand.grip <= 0.1f) && !((Object)(object)character.data.currentClimbHandle != (Object)null) && !character.data.isRopeClimbing && !character.data.isVineClimbing && !((Object)(object)character.data.carrier != (Object)null) && !TryGrabScout(hand) && !TryGrabSpecial(hand))
			{
				Vector3 position = ((Component)MainCamera.instance).transform.position;
				Vector3 val = position + character.data.lookDirection * (2.5f * Scale);
				RaycastHit val2 = HelperFunctions.LineCheck(position, val, (LayerType)1, 0f, (QueryTriggerInteraction)1);
				if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform))
				{
					val2 = HelperFunctions.LineCheck(position, val, (LayerType)1, 0.15f * Scale, (QueryTriggerInteraction)1);
				}
				if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform) && character.refs.climbing.AcceptableGrabAngle(((RaycastHit)(ref val2)).normal, ((RaycastHit)(ref val2)).collider))
				{
					view.RPC("RPCA_PeakleGrab", (RpcTarget)0, new object[4]
					{
						(byte)hand.id,
						((RaycastHit)(ref val2)).point,
						((RaycastHit)(ref val2)).normal,
						(byte)0
					});
					RememberSurface(hand, ((RaycastHit)(ref val2)).collider);
					hand.kind = HoldKind.Surface;
					hand.anchor = null;
					float num = 0f - (body.Active ? body.VelocityMetres.y : AverageVelocity().y);
					hand.slide = Mathf.Max(0f, num - Plugin.SlideMinFallSpeed.Value);
				}
			}
		}

		private bool TryGrabSpecial(Hand hand)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_011c: 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_0123: 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_0155: 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)
			Vector3 position = ((Component)MainCamera.instance).transform.position;
			Vector3 lookDirection = character.data.lookDirection;
			float num = 2.5f * Scale;
			int num2 = Physics.SphereCastNonAlloc(position, 0.08f * Scale, lookDirection, grabHits, num, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)2);
			Array.Sort(grabHits, 0, num2, HitDistance.Instance);
			Item val3 = default(Item);
			for (int i = 0; i < num2; i++)
			{
				RaycastHit val = grabHits[i];
				Collider collider = ((RaycastHit)(ref val)).collider;
				if (!((Object)(object)collider == (Object)null) && !character.refs.ragdoll.colliderList.Contains(collider) && (!(((RaycastHit)(ref val)).distance <= 0f) || !(((RaycastHit)(ref val)).point == Vector3.zero)))
				{
					HoldKind? holdKind = SpecialKind(collider);
					if (holdKind.HasValue)
					{
						Vector3 val2 = collider.ClosestPoint(position + lookDirection * ((RaycastHit)(ref val)).distance);
						hand.anchor = ((Component)collider).transform;
						hand.anchorLocal = ((Component)collider).transform.InverseTransformPoint(val2);
						view.RPC("RPCA_PeakleGrab", (RpcTarget)0, new object[4]
						{
							(byte)hand.id,
							val2,
							-lookDirection,
							(byte)holdKind.Value
						});
						RememberSurface(hand, collider);
						return true;
					}
					if ((collider.isTrigger || !Item.TryGetItemFromCollider(collider, ref val3) || !((Object)(object)val3 != (Object)null) || (!((Object)(object)val3 == (Object)(object)hands[0].item) && !((Object)(object)val3 == (Object)(object)hands[1].item))) && !collider.isTrigger)
					{
						return false;
					}
				}
			}
			return false;
		}

		private static HoldKind? SpecialKind(Collider c)
		{
			if ((Object)(object)((Component)c).GetComponentInParent<RopeSegment>() != (Object)null || (Object)(object)((Component)c).GetComponentInParent<Rope>() != (Object)null)
			{
				return HoldKind.Rope;
			}
			if ((Object)(object)((Component)c).GetComponentInParent<JungleVine>() != (Object)null)
			{
				return HoldKind.Vine;
			}
			if ((Object)(object)((Component)c).GetComponentInParent<ClimbHandle>() != (Object)null)
			{
				return HoldKind.Piton;
			}
			return null;
		}

		internal static bool IsHoldInteractable(IInteractible target)
		{
			if (!(target is RopeSegment) && !(target is JungleVine) && !(target is ClimbHandle) && !(target is BackpackOnBackVisuals))
			{
				return target is CharacterInteractible;
			}
			return true;
		}

		private void FollowAnchors(float dt)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (!hand.grabbing || hand.kind == HoldKind.Surface || hand.kind == HoldKind.Scout)
				{
					continue;
				}
				if ((Object)(object)hand.anchor == (Object)null || !((Component)hand.anchor).gameObject.activeInHierarchy)
				{
					view.RPC("RPCA_PeakleRelease", (RpcTarget)0, new object[1] { (byte)hand.id });
					continue;
				}
				Vector3 val = hand.anchor.TransformPoint(hand.anchorLocal);
				hand.anchorSync -= dt;
				if (hand.anchorSync <= 0f)
				{
					Vector3 val2 = val - hand.point;
					if (((Vector3)(ref val2)).sqrMagnitude > 0.0004f)
					{
						hand.anchorSync = 0.1f;
						view.RPC("RPCA_PeakleMoveHold", (RpcTarget)1, new object[3]
						{
							(byte)hand.id,
							val,
							hand.normal
						});
					}
				}
				hand.point = val;
			}
		}

		private float GripCostMultiplier(Hand hand)
		{
			float num = Mathf.Max(character.refs.climbing.maxStaminaUsage, 0.0001f);
			return hand.kind switch
			{
				HoldKind.Rope => Mathf.Clamp01(character.refs.ropeHandling.staminaUsageUp / num), 
				HoldKind.Vine => Mathf.Clamp01(character.refs.vineClimbing.staminaUsage / num), 
				_ => 1f, 
			};
		}

		private void GrabJump()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			float num = ((HangingCount == 2) ? 0.48f : 1f);
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (hand.grabbing)
				{
					hand.grip -= 1f * num;
				}
			}
			Vector3 val = ClimbDir();
			Vector3 val2 = ((Vector3)(ref val)).normalized * (0.080000006f * Plugin.JumpStrength.Value);
			view.RPC("RPCA_PeakleGrabJump", (RpcTarget)0, new object[1] { val2 });
		}

		private Vector3 ClimbDir()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (BodyGrounded)
			{
				return Vector3.up;
			}
			Vector3 hitNormal = body.hitNormal;
			Vector3 val;
			if (!body.hasHit)
			{
				val = Vector3.up;
			}
			else
			{
				Vector3 val2 = Vector3.ProjectOnPlane(Vector3.up, hitNormal);
				val = ((Vector3)(ref val2)).normalized;
			}
			Vector3 val3 = val;
			if (body.hasHit && Vector3.Angle(Vector3.down, hitNormal) < 10f)
			{
				return Vector3.down * 0.15f;
			}
			if (val3 != Vector3.up)
			{
				val3 += hitNormal * 0.1f;
			}
			return val3;
		}

		private void Update()
		{
			if (!Disabled && view.IsMine)
			{
				if (Hanging && ShouldForceRelease())
				{
					view.RPC("RPCA_PeakleReleaseAll", (RpcTarget)0, Array.Empty<object>());
				}
				Hand[] array = hands;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].grabWait -= Time.deltaTime;
				}
				SurfaceEffects(Time.deltaTime);
				UpdateGrip(Time.deltaTime);
				reconcileTimer -= Time.deltaTime;
				if (reconcileTimer <= 0f)
				{
					Reconcile();
				}
				IInteractible target = (((Object)(object)Interaction.instance != (Object)null) ? Interaction.instance.bestInteractable : null);
				int num = (CanInteractWith(hands[0], target) ? 1 : 0) | (CanInteractWith(hands[1], target) ? 2 : 0);
				if (num != lastFreeMask)
				{
					lastFreeMask = num;
					PromptRefresher.RefreshInteract();
				}
			}
		}

		internal static bool IsFree(Hand hand)
		{
			if ((Object)(object)hand.item == (Object)null)
			{
				return !hand.grabbing;
			}
			return false;
		}

		private bool ShouldForceRelease()
		{
			CharacterData data = character.data;
			if (!data.dead && data.fullyConscious && !(data.currentRagdollControll < 0.25f) && !((Object)(object)data.carrier != (Object)null) && !data.isRopeClimbing && !data.isVineClimbing && !((Object)(object)data.currentClimbHandle != (Object)null))
			{
				return data.isClimbing;
			}
			return true;
		}

		private void SurfaceEffects(float dt)
		{
			CharacterClimbing climbing = character.refs.climbing;
			windCost = Mathf.Max(climbing.climbingStamMinimumMultiplier, 1f);
			climbing.climbingStamMinimumMultiplier = 1f;
			float num = Mathf.Clamp01(character.data.slippy);
			Hand[] array = hands;
			foreach (Hand hand in array)
			{
				if (!hand.grabbing)
				{
					co