Decompiled source of MineKnuckle v1.4.3

BepInEx/plugins/MineKnuckle/MineKnuckle.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Rewired;
using Steamworks;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.Sprites;
using UnityEngine.UI;
using WKModUI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MineKnuckle: Tools & Luck")]
[assembly: AssemblyDescription("Minecraft-inspired building and climbing for White Knuckle")]
[assembly: AssemblyCompany("Ilyushkins")]
[assembly: AssemblyProduct("MineKnuckle: Tools & Luck")]
[assembly: AssemblyFileVersion("1.4.3.0")]
[assembly: AssemblyVersion("1.4.3.0")]
[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 WKModUI
{
	internal static class SharedLanguage
	{
		internal const string Protocol = "ilya.whiteknuckle.shared-language.v1";

		private static Dictionary<string, object> State => AppDomain.CurrentDomain.GetData("ilya.whiteknuckle.shared-language.v1") as Dictionary<string, object>;

		internal static string Current
		{
			get
			{
				Dictionary<string, object> state = State;
				if (state != null)
				{
					return (string)state["resolved"];
				}
				return "en";
			}
		}

		internal static string Label
		{
			get
			{
				if (!(Current == "ru"))
				{
					return "ENG";
				}
				return "RU";
			}
		}

		private static SortedDictionary<string, object[]> Clients(Dictionary<string, object> state)
		{
			return (SortedDictionary<string, object[]>)state["clients"];
		}

		internal static string Normalize(string language)
		{
			language = (language ?? "").Trim().ToLowerInvariant().Replace('_', '-');
			switch (language)
			{
			default:
				if (!language.StartsWith("ru-", StringComparison.Ordinal))
				{
					return "en";
				}
				break;
			case "ru":
			case "russian":
			case "русский":
				break;
			}
			return "ru";
		}

		private static string Choice(string value)
		{
			if (!(value == "ru") && !(value == "en"))
			{
				return "auto";
			}
			return value;
		}

		internal static void Connect(string id, Action<string> apply, Func<bool> visible, string automatic, string legacy, Func<object[]> settings, Action<Exception> error)
		{
			Dictionary<string, object> dictionary = State;
			if (dictionary == null)
			{
				object[] array = settings();
				dictionary = new Dictionary<string, object>(StringComparer.Ordinal)
				{
					{
						"clients",
						new SortedDictionary<string, object[]>(StringComparer.Ordinal)
					},
					{
						"read",
						array[1]
					},
					{
						"write",
						array[2]
					},
					{
						"choice",
						Choice(((Func<string>)array[1])())
					},
					{
						"allowLegacy",
						!(bool)array[0]
					},
					{ "resolved", "en" }
				};
				AppDomain.CurrentDomain.SetData("ilya.whiteknuckle.shared-language.v1", dictionary);
			}
			Clients(dictionary)[id] = new object[4]
			{
				apply,
				visible,
				Normalize(automatic),
				error
			};
			if ((bool)dictionary["allowLegacy"] && (legacy == "ru" || legacy == "en"))
			{
				SetChoice(legacy);
			}
			Refresh(dictionary);
			Apply(Clients(dictionary)[id], (string)dictionary["resolved"]);
		}

		internal static void Disconnect(string id)
		{
			Dictionary<string, object> state = State;
			if (state != null)
			{
				Clients(state).Remove(id);
				Refresh(state);
			}
		}

		internal static void Automatic(string id, string language)
		{
			Dictionary<string, object> state = State;
			if (state != null && Clients(state).TryGetValue(id, out var value))
			{
				value[2] = Normalize(language);
				state["choice"] = Choice(((Func<string>)state["read"])());
				Refresh(state);
			}
		}

		internal static void Toggle()
		{
			SetChoice((Current == "ru") ? "en" : "ru");
		}

		internal static void SetChoice(string choice)
		{
			if (choice != "auto" && choice != "ru" && choice != "en")
			{
				throw new ArgumentException("Expected auto, ru or en.", "choice");
			}
			Dictionary<string, object> state = State;
			if (state == null)
			{
				return;
			}
			state["allowLegacy"] = false;
			state["choice"] = choice;
			try
			{
				((Action<string>)state["write"])(choice);
			}
			catch (Exception exception)
			{
				foreach (object[] value in Clients(state).Values)
				{
					Report(value, exception);
				}
			}
			Refresh(state);
		}

		internal static bool OwnsButton(string id)
		{
			Dictionary<string, object> state = State;
			if (state == null)
			{
				return false;
			}
			foreach (KeyValuePair<string, object[]> item in Clients(state))
			{
				bool flag = false;
				try
				{
					flag = ((Func<bool>)item.Value[1])();
				}
				catch (Exception exception)
				{
					Report(item.Value, exception);
				}
				if (flag)
				{
					return item.Key == id;
				}
			}
			return false;
		}

		private static void Refresh(Dictionary<string, object> state)
		{
			string text = (string)state["choice"];
			if (text == "auto")
			{
				text = "en";
				using SortedDictionary<string, object[]>.ValueCollection.Enumerator enumerator = Clients(state).Values.GetEnumerator();
				if (enumerator.MoveNext())
				{
					text = (string)enumerator.Current[2];
				}
			}
			if ((string)state["resolved"] == text)
			{
				return;
			}
			state["resolved"] = text;
			foreach (object[] item in new List<object[]>(Clients(state).Values))
			{
				Apply(item, text);
			}
		}

		private static void Apply(object[] client, string language)
		{
			try
			{
				((Action<string>)client[0])(language);
			}
			catch (Exception exception)
			{
				Report(client, exception);
			}
		}

		private static void Report(object[] client, Exception exception)
		{
			if (client[3] is Action<Exception> action)
			{
				try
				{
					action(exception);
				}
				catch (Exception)
				{
				}
			}
		}
	}
	internal static class SharedLanguageConfig
	{
		internal const string Filename = "ilya.whiteknuckle.shared-language.cfg";

		internal static object[] Open(string directory)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			string text = Path.Combine(directory, "ilya.whiteknuckle.shared-language.cfg");
			bool flag = File.Exists(text);
			ConfigFile file = new ConfigFile(text, false)
			{
				SaveOnConfigSet = false
			};
			ConfigEntry<string> choice = file.Bind<string>("General", "Language", "auto", new ConfigDescription("Language for all compatible Ilyushkins WK mods. RU/ENG switches every connected mod. auto follows the game; ru = Russian; en = English. / Язык всех совместимых WK-модов Илюшкинса. RU/ENG переключает все подключённые моды. auto = язык игры; ru = русский; en = английский.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "auto", "ru", "en" }), Array.Empty<object>()));
			if (!flag)
			{
				file.Save();
			}
			return new object[3]
			{
				flag,
				(Func<string>)(() => choice.Value),
				(Action<string>)delegate(string value)
				{
					choice.Value = value;
					file.Save();
				}
			};
		}
	}
}
namespace MineKnuckle
{
	internal static class AdventureAssets
	{
		private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, Material> materials = new Dictionary<string, Material>();

		private static readonly Dictionary<string, Sprite> icons = new Dictionary<string, Sprite>();

		internal static string Key(AdventureKind kind, int stage = 0)
		{
			switch (kind)
			{
			default:
				return "shield_base_nopattern";
			case AdventureKind.Pearl:
				return "ender_pearl";
			case AdventureKind.Arrow:
				return "arrow";
			case AdventureKind.Bow:
				if (stage != 0)
				{
					return "bow_pulling_" + (stage - 1);
				}
				return "bow";
			case AdventureKind.Torch:
				return "torch";
			case AdventureKind.WindCharge:
				return "wind_charge";
			case AdventureKind.Mace:
				return "mace";
			}
		}

		internal static AdventureKind Kind(string id)
		{
			return id switch
			{
				"WK_MineKnuckleShield" => AdventureKind.Shield, 
				"WK_MineKnuckleArrow" => AdventureKind.Arrow, 
				"WK_MineKnuckleBow" => AdventureKind.Bow, 
				"WK_MineKnuckleTorch" => AdventureKind.Torch, 
				"WK_MineKnuckleWindCharge" => AdventureKind.WindCharge, 
				"WK_MineKnuckleMace" => AdventureKind.Mace, 
				_ => AdventureKind.Pearl, 
			};
		}

		internal static Sprite Icon(AdventureKind kind)
		{
			//IL_0057: 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_005c: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			string text = Key(kind);
			if (icons.TryGetValue(text, out var value))
			{
				return value;
			}
			Texture2D val = MinecraftAssets.Texture(text);
			Rect val2 = ((kind == AdventureKind.Shield) ? new Rect(1f, 41f, 12f, 22f) : new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height));
			value = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f), 16f);
			((Object)value).hideFlags = (HideFlags)32;
			icons.Add(text, value);
			return value;
		}

		internal static Mesh Mesh(AdventureKind kind, int stage = 0)
		{
			string text = Key(kind, stage);
			if (meshes.TryGetValue(text, out var value))
			{
				return value;
			}
			Texture2D val = MinecraftAssets.Texture(text);
			value = ToolAssets.MakeMesh((kind == AdventureKind.Shield) ? AdventureGeometry.Shield() : PixelGeometry.Extrude(ToolAssets.Mask(val), ((Texture)val).width, ((Texture)val).height, 0.0625f), text, kind != AdventureKind.Shield);
			meshes.Add(text, value);
			return value;
		}

		internal static Material Material(string key)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (materials.TryGetValue(key, out var value))
			{
				return value;
			}
			value = BlockMaterialFactory.Create(BlockMaterialFactory.Resolve(), MinecraftAssets.Texture(key), Vector2.one, "Minecraft " + key);
			((Object)value).hideFlags = (HideFlags)32;
			materials.Add(key, value);
			return value;
		}

		internal static GameObject Visual(Transform parent, int layer, AdventureKind kind, int stage = 0)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			GameObject val = new GameObject("Minecraft " + kind);
			val.layer = layer;
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = Mesh(kind, stage);
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			Material val3 = Material(Key(kind, stage));
			((Renderer)val2).sharedMaterials = (Material[])(object)((kind != AdventureKind.Shield) ? new Material[2] { val3, val3 } : new Material[1] { val3 });
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			return val;
		}

		internal static Renderer WindPart(Transform root, int layer, bool wind)
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			string text = (wind ? "trial_wind_shell" : "trial_wind_core");
			if (!meshes.TryGetValue(text, out var value))
			{
				float[] deform = new float[3];
				LuckyMobBox[] boxes = ((!wind) ? new LuckyMobBox[1]
				{
					new LuckyMobBox(0, 0, new float[6] { -2f, -2f, -2f, 4f, 4f, 4f }, deform, mirror: false)
				} : new LuckyMobBox[2]
				{
					new LuckyMobBox(15, 20, new float[6] { -4f, -1f, -4f, 8f, 2f, 8f }, deform, mirror: false),
					new LuckyMobBox(0, 9, new float[6] { -3f, -2f, -3f, 6f, 4f, 6f }, deform, mirror: false)
				});
				value = ToolAssets.MakeMesh(LuckyMobGeometry.Build(new LuckyMobPart(text, new float[6], boxes, new LuckyMobPart[0]), 64, 32, null), text, twoParts: false);
				meshes.Add(text, value);
			}
			if (!materials.TryGetValue("wind_charge_projectile", out var value2))
			{
				Texture2D obj = MinecraftAssets.Texture("wind_charge_projectile");
				((Texture)obj).wrapModeU = (TextureWrapMode)0;
				value2 = SlimeMaterial.Create(obj);
				((Object)value2).name = "Minecraft wind charge atlas";
				materials.Add("wind_charge_projectile", value2);
			}
			GameObject val = new GameObject(text)
			{
				layer = layer
			};
			val.transform.SetParent(root, false);
			val.AddComponent<MeshFilter>().sharedMesh = value;
			MeshRenderer obj2 = val.AddComponent<MeshRenderer>();
			((Renderer)obj2).sharedMaterial = value2;
			((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj2).receiveShadows = false;
			return (Renderer)(object)obj2;
		}

		internal static GameObject Arrow(Transform parent, int layer)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			if (!meshes.TryGetValue("arrow_entity", out var value))
			{
				value = ToolAssets.MakeMesh(AdventureGeometry.Arrow(ToolAssets.Mask(MinecraftAssets.Texture("arrow_entity"))), "Minecraft arrow projectile", twoParts: false);
				meshes.Add("arrow_entity", value);
			}
			GameObject val = new GameObject("Minecraft arrow")
			{
				layer = layer
			};
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = value;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = Material("arrow_entity");
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			return val;
		}

		internal static void Dispose()
		{
			foreach (Material value in materials.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			foreach (Sprite value2 in icons.Values)
			{
				if ((Object)(object)value2 != (Object)null)
				{
					Object.Destroy((Object)(object)value2);
				}
			}
			meshes.Clear();
			materials.Clear();
			icons.Clear();
		}
	}
	internal static class AdventureGeometry
	{
		internal static PixelGeometry Shield()
		{
			PixelGeometry pixelGeometry = new PixelGeometry();
			Box(pixelGeometry, 0f, 0f, -6f, -11f, -2f, 12f, 22f, 1f);
			Box(pixelGeometry, 26f, 0f, -1f, -3f, -1f, 2f, 6f, 6f);
			return pixelGeometry;
		}

		private static void Box(PixelGeometry g, float u, float v, float x, float y, float z, float w, float h, float d)
		{
			//IL_0085: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00c8: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_012d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(x, y, z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(x + w, y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(x + w, y + h, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(x, y + h, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(x, y, z + d);
			Vector3 val6 = default(Vector3);
			((Vector3)(ref val6))..ctor(x + w, y, z + d);
			Vector3 val7 = default(Vector3);
			((Vector3)(ref val7))..ctor(x + w, y + h, z + d);
			Vector3 val8 = default(Vector3);
			((Vector3)(ref val8))..ctor(x, y + h, z + d);
			Face(g, val6, val5, val, val2, u + d, v, u + d + w, v + d);
			Face(g, val3, val4, val8, val7, u + d + w, v + d, u + d + w + w, v);
			Face(g, val, val5, val8, val4, u, v + d, u + d, v + d + h);
			Face(g, val2, val, val4, val3, u + d, v + d, u + d + w, v + d + h);
			Face(g, val6, val2, val3, val7, u + d + w, v + d, u + d + w + d, v + d + h);
			Face(g, val5, val6, val7, val8, u + d + w + d, v + d, u + d + w + d + w, v + d + h);
		}

		private static void Face(PixelGeometry g, Vector3 a, Vector3 b, Vector3 c, Vector3 d, float u0, float v0, float u1, float v1)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0024: 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_002c: 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)
			int count = g.Vertices.Count;
			Vector3[] array = (Vector3[])(object)new Vector3[4] { a, b, c, d };
			float[] array2 = new float[4] { u1, u0, u0, u1 };
			float[] array3 = new float[4] { v0, v0, v1, v1 };
			for (int i = 0; i < 4; i++)
			{
				g.Vertices.Add(new PixelVertex(array[i].x / 16f, (0f - array[i].y) / 16f, array[i].z / 16f, array2[i] / 64f, 1f - array3[i] / 64f));
			}
			int[] array4 = new int[6] { 0, 2, 1, 0, 3, 2 };
			foreach (int num in array4)
			{
				g.Front.Add(count + num);
			}
		}

		internal static PixelGeometry Arrow(bool[] mask)
		{
			PixelGeometry pixelGeometry = new PixelGeometry();
			for (int i = 0; i < 4; i++)
			{
				float num = (float)(45 + i * 90) * ((float)Math.PI / 180f);
				float num2 = Mathf.Cos(num);
				float num3 = Mathf.Sin(num);
				for (int j = 0; j < 5; j++)
				{
					for (int k = 0; k < 16; k++)
					{
						if (mask[(31 - j) * 32 + k])
						{
							float num4 = -0.1125f + (float)j * 0.225f / 5f;
							float num5 = num4 + 0.044999998f;
							float num6 = -0.9f + (float)k * 0.9f / 16f;
							float z = num6 + 9f / 160f;
							int count = pixelGeometry.Vertices.Count;
							float u = (float)k / 32f;
							float u2 = (float)(k + 1) / 32f;
							float v = 1f - (float)j / 32f;
							float v2 = 1f - (float)(j + 1) / 32f;
							pixelGeometry.Vertices.Add(new PixelVertex(num2 * num4, num3 * num4, num6, u, v));
							pixelGeometry.Vertices.Add(new PixelVertex(num2 * num4, num3 * num4, z, u2, v));
							pixelGeometry.Vertices.Add(new PixelVertex(num2 * num5, num3 * num5, z, u2, v2));
							pixelGeometry.Vertices.Add(new PixelVertex(num2 * num5, num3 * num5, num6, u, v2));
							int[] array = new int[6] { 0, 1, 2, 0, 2, 3 };
							foreach (int num7 in array)
							{
								pixelGeometry.Front.Add(count + num7);
							}
						}
					}
				}
			}
			return pixelGeometry;
		}
	}
	[DefaultExecutionOrder(1050)]
	public sealed class AdventureHand : HandItem
	{
		public int kind;

		private readonly UseGate gate = new UseGate();

		private readonly ChargingHandMask mask = new ChargingHandMask();

		private readonly ShieldUseMotion shieldUse = new ShieldUseMotion();

		private readonly TorchLight torchLight = new TorchLight();

		private Transform model;

		private GameObject visual;

		private AdventureHeldView view;

		private int stage = -1;

		private float elapsed;

		private float throwAt = -10f;

		private float maceSwingAt = -10f;

		private int seenMaceStrike;

		private float maceClock;

		private float maceCharge;

		private float maceRaise;

		internal AdventureKind Kind => (AdventureKind)kind;

		internal bool StillHolding
		{
			get
			{
				if (((Behaviour)this).isActiveAndEnabled && base.item != null && !base.item.hasBeenDestroyed && ((Hand_Base)this).hand != null && ((Hand_Base)this).hand.inventoryHand != null)
				{
					return ((Hand_Base)this).hand.inventoryHand.currentItem == base.item;
				}
				return false;
			}
		}

		internal bool Available
		{
			get
			{
				if (StillHolding && MineKnucklePlugin.GameplayReady() && !((Hand_Base)this).hand.IsLocked() && !((HandItem)this).IsCurrentlyInteracting())
				{
					return !base.item.HasTag("unpurchased");
				}
				return false;
			}
		}

		internal float BlockingTime
		{
			get
			{
				if (Kind != AdventureKind.Shield || !Available || !gate.Held)
				{
					return 0f;
				}
				return elapsed;
			}
		}

		internal bool SlowsMovement
		{
			get
			{
				if (Available && gate.Held)
				{
					if (Kind != AdventureKind.Shield)
					{
						if (Kind == AdventureKind.Bow)
						{
							return elapsed > 0f;
						}
						return false;
					}
					return true;
				}
				return false;
			}
		}

		public override void Initialize(Item i, Hand h)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			((HandItem)this).Initialize(i, h);
			Cancel();
			if ((Object)(object)model != (Object)null)
			{
				((Component)model).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)model).gameObject);
			}
			GameObject val = new GameObject("MineKnuckle adventure hand view");
			val.layer = LayerMask.NameToLayer("Player");
			if (val.layer < 0)
			{
				val.layer = ((Component)this).gameObject.layer;
			}
			model = val.transform;
			stage = -1;
			SetVisual(0);
		}

		public override void Use()
		{
			if (Available)
			{
				((HandItem)this).Use();
			}
		}

		public override void StopUse()
		{
			((HandItem)this).StopUse();
		}

		public override void Update()
		{
			if (base.item != null && ((Hand_Base)this).hand != null)
			{
				((HandItem)this).Update();
			}
		}

		private bool Held()
		{
			if (((Hand_Base)this).hand == null || (Object)(object)InputManager.instance == (Object)null)
			{
				return false;
			}
			ButtonInput button = InputManager.GetButton(((Hand_Base)this).hand.fireButton);
			if (button == null)
			{
				return false;
			}
			if (!ReInput.isReady || button.action == null)
			{
				return button.Pressed;
			}
			Player player = ReInput.players.GetPlayer(0);
			bool flag = player.GetButton(button.action.id) || player.GetNegativeButton(button.action.id);
			if (button.altAction != null)
			{
				flag |= player.GetButton(button.altAction.id) || player.GetNegativeButton(button.altAction.id);
			}
			return flag;
		}

		public override void LateUpdate()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			if (base.item == null || ((Hand_Base)this).hand == null)
			{
				ResetCharge();
				torchLight.Set(Vector3.zero, visible: false);
				return;
			}
			((HandItem)this).LateUpdate();
			bool available = Available;
			bool flag = Held();
			bool held = gate.Held;
			gate.Tick(flag, available);
			shieldUse.Advance(Time.deltaTime, Kind == AdventureKind.Shield && available && gate.Held);
			if ((Object)(object)model == (Object)null)
			{
				return;
			}
			((Component)model).gameObject.SetActive(StillHolding);
			MineKnucklePlugin instance = MineKnucklePlugin.Instance;
			if (!available)
			{
				elapsed = 0f;
				mask.Restore();
			}
			else if (Kind == AdventureKind.Bow)
			{
				if (gate.Held && instance.Registry.FindAmmo() != null)
				{
					elapsed += Time.deltaTime;
				}
				if (held && !flag && elapsed > 0f)
				{
					instance.Adventure.FireArrow(((Hand_Base)this).hand.GetPlayer(), AdventureRules.BowPower(elapsed), instance.Registry.FindAmmo(), base.item);
					elapsed = 0f;
				}
				if (!gate.Held)
				{
					elapsed = 0f;
				}
			}
			else if (Kind == AdventureKind.Mace && gate.Held && instance.Adventure.TryMace(((Hand_Base)this).hand.GetPlayer()))
			{
				maceSwingAt = Time.time;
			}
			else if (Kind == AdventureKind.WindCharge && gate.Held && instance.Adventure.ThrowWind(((Hand_Base)this).hand.GetPlayer(), base.item))
			{
				throwAt = Time.time;
			}
			else if (Kind == AdventureKind.Shield)
			{
				elapsed = (gate.Held ? (elapsed + Time.deltaTime) : 0f);
			}
			else if (Kind == AdventureKind.Torch && gate.Pressed && instance.World != null)
			{
				ENT_Player player = ((Hand_Base)this).hand.GetPlayer();
				Aim aim = instance.World.GetAim(player, instance.BuildReach, mining: false, StackData.Count(base.item), BlockKind.Torch);
				if (instance.World.Place(aim, base.item, player, instance.BuildReach))
				{
					StackData.DestroyIfEmpty(base.item);
				}
			}
			else if (Kind == AdventureKind.Pearl && gate.Pressed && instance.Adventure.ThrowPearl(((Hand_Base)this).hand.GetPlayer(), base.item))
			{
				throwAt = Time.time;
			}
			if (!StillHolding)
			{
				((Component)model).gameObject.SetActive(false);
				ResetCharge();
				mask.Restore();
				torchLight.Set(Vector3.zero, visible: false);
				return;
			}
			bool flag2 = Kind == AdventureKind.Bow && elapsed > 0f;
			if (flag2 || shieldUse.Using)
			{
				mask.Hide(((Hand_Base)this).hand);
			}
			else
			{
				mask.Restore();
			}
			SetVisual((Kind == AdventureKind.Bow) ? AdventureRules.BowStage(elapsed, flag2) : 0);
			Camera val = HeldToolView.RenderingCamera(((Hand_Base)this).hand.GetPlayer(), ((Component)model).gameObject.layer);
			if ((Object)(object)val == (Object)null || view == null)
			{
				ResetCharge();
				torchLight.Set(Vector3.zero, visible: false);
				return;
			}
			int side = ((((Hand_Base)this).hand.id != 0) ? 1 : (-1));
			if (Kind == AdventureKind.Mace)
			{
				if (seenMaceStrike != TrialFx.MaceStrikeSequence)
				{
					seenMaceStrike = TrialFx.MaceStrikeSequence;
					if (available)
					{
						maceSwingAt = Time.time;
					}
				}
				float num = ((available && (Object)(object)instance != (Object)null) ? instance.Adventure.MaceCharge01(((Hand_Base)this).hand.GetPlayer()) : 0f);
				if (num > 0f)
				{
					maceCharge = Mathf.MoveTowards(maceCharge, num, Time.deltaTime * 12f);
					maceRaise = Mathf.Min(1f, maceRaise + Time.deltaTime * 11f);
					maceClock = Mathf.Repeat(maceClock + Time.deltaTime * (1.25f + 0.85f * num), 1f);
				}
				else
				{
					maceCharge = (maceClock = (maceRaise = 0f));
				}
			}
			HandPose pose = ((Kind == AdventureKind.Mace) ? MacePresentation.Pose(side, Mathf.Clamp01((Time.time - maceSwingAt) / 0.3f), maceCharge, val.aspect, maceRaise) : ((Kind == AdventureKind.Torch) ? AdventureMotion.Torch(side) : ((Kind == AdventureKind.Bow) ? AdventureMotion.Bow(elapsed, flag2, side) : ((Kind == AdventureKind.Shield) ? AdventureMotion.Shield(side, shieldUse.Using, shieldUse.InverseHeight) : AdventureMotion.Small(side, Mathf.Clamp01(1f - (Time.time - throwAt) / 0.2f))))));
			view.Pose(val, model, pose, maceCharge, side, maceClock);
			if (Kind == AdventureKind.Torch)
			{
				torchLight.Held(((Hand_Base)this).hand.GetPlayer(), pose, TorchLight.Enabled && StillHolding);
			}
		}

		private void ResetCharge()
		{
			if (view != null)
			{
				view.HideCharge();
			}
			maceCharge = (maceClock = (maceRaise = 0f));
			seenMaceStrike = TrialFx.MaceStrikeSequence;
		}

		private void SetVisual(int next)
		{
			if (stage != next)
			{
				if (view != null)
				{
					view.Dispose();
				}
				if ((Object)(object)visual != (Object)null)
				{
					visual.SetActive(false);
					Object.Destroy((Object)(object)visual);
				}
				visual = AdventureAssets.Visual(model, ((Component)model).gameObject.layer, Kind, next);
				view = new AdventureHeldView(visual.GetComponent<MeshFilter>(), AdventureAssets.Mesh(Kind, next));
				stage = next;
			}
		}

		internal void Cancel()
		{
			gate.Cancel();
			elapsed = 0f;
			maceSwingAt = -10f;
			ResetCharge();
			shieldUse.Reset();
			mask.Restore();
		}

		private void OnDisable()
		{
			Cancel();
			torchLight.Dispose();
			if ((Object)(object)model != (Object)null)
			{
				((Component)model).gameObject.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			Cancel();
			torchLight.Dispose();
			if (view != null)
			{
				view.Dispose();
			}
			if ((Object)(object)model != (Object)null)
			{
				((Component)model).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)model).gameObject);
			}
		}

		public override void OnDrop()
		{
			Cancel();
			torchLight.Dispose();
			if ((Object)(object)model != (Object)null)
			{
				((Component)model).gameObject.SetActive(false);
			}
			((HandItem)this).OnDrop();
		}

		public override bool CanDrop(bool pocket = false)
		{
			return true;
		}

		internal void Blocked(float damage, ENT_Player player)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			int num = AdventureItemState.Durability(base.item) - Mathf.Max(1, Mathf.CeilToInt(1f + damage / Mathf.Max(0.001f, ((GameEntity)player).maxHealth) * 20f));
			AdventureItemState.SetDurability(base.item, num);
			MinecraftAudio.Shield(((Component)player.cam).transform.position, num <= 0);
			if (num <= 0)
			{
				Cancel();
				base.item.Destroy(true);
			}
		}
	}
	internal static class AdventureItemState
	{
		private const string key = "mineknuckle-shield=";

		internal static int Durability(Item item)
		{
			if (item.data != null)
			{
				foreach (string datum in item.data)
				{
					if (datum != null && datum.StartsWith("mineknuckle-shield=", StringComparison.Ordinal) && int.TryParse(datum.Substring("mineknuckle-shield=".Length), out var result))
					{
						return Math.Max(0, result);
					}
				}
			}
			return 336;
		}

		internal static void SetDurability(Item item, int value)
		{
			List<string> list = ((item.data == null) ? new List<string>() : new List<string>(item.data));
			list.RemoveAll((string s) => s?.StartsWith("mineknuckle-shield=", StringComparison.Ordinal) ?? false);
			list.Add("mineknuckle-shield=" + Math.Max(0, value));
			item.data = list;
		}
	}
	internal sealed class AdventureHeldView : IDisposable
	{
		private readonly Mesh mesh;

		private readonly AdventureMeshClip clip = new AdventureMeshClip();

		private readonly List<PixelVertex> source = new List<PixelVertex>();

		private readonly int[] triangles;

		private readonly List<Vector3> vertices = new List<Vector3>();

		private readonly List<Vector2> uv = new List<Vector2>();

		private MaceChargeView chargeView;

		internal AdventureHeldView(MeshFilter filter, Mesh original)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			Vector3[] array = original.vertices;
			Vector2[] array2 = original.uv;
			for (int i = 0; i < array.Length; i++)
			{
				source.Add(new PixelVertex(array[i].x, array[i].y, array[i].z, array2[i].x, array2[i].y));
			}
			triangles = original.triangles;
			mesh = new Mesh
			{
				name = "Clipped Minecraft adventure item",
				hideFlags = (HideFlags)52
			};
			mesh.MarkDynamic();
			filter.sharedMesh = mesh;
			MeshRenderer component = ((Component)filter).GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterials = (Material[])(object)new Material[1] { ((Renderer)component).sharedMaterial };
		}

		internal void Pose(Camera camera, Transform root, HandPose pose, float charge = 0f, int side = 1, float clock = 0f)
		{
			//IL_00ab: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			clip.Build(source, triangles, pose);
			ToolProjection projection = HeldToolView.Projection(camera);
			projection.DepthScale = Mathf.Max(projection.DepthScale, (camera.nearClipPlane + 0.01f) / 0.05f);
			vertices.Clear();
			uv.Clear();
			foreach (PixelVertex vertex in clip.Vertices)
			{
				ToolPoint toolPoint = projection.Project(new ToolPoint(vertex.X, vertex.Y, vertex.Z));
				vertices.Add(new Vector3(toolPoint.X, toolPoint.Y, toolPoint.Z));
				uv.Add(new Vector2(vertex.U, vertex.V));
			}
			mesh.Clear();
			mesh.SetVertices(vertices);
			mesh.SetUVs(0, uv);
			mesh.SetTriangles(clip.Triangles, 0);
			mesh.RecalculateNormals();
			mesh.RecalculateBounds();
			root.SetPositionAndRotation(((Component)camera).transform.position, ((Component)camera).transform.rotation);
			root.localScale = Vector3.one;
			if (charge > 0f)
			{
				if (chargeView == null)
				{
					chargeView = new MaceChargeView(root);
				}
				chargeView.Pose(projection, pose, charge, side, clock);
			}
			else
			{
				HideCharge();
			}
		}

		internal void HideCharge()
		{
			if (chargeView != null)
			{
				chargeView.Hide();
			}
		}

		public void Dispose()
		{
			if (chargeView != null)
			{
				chargeView.Dispose();
				chargeView = null;
			}
			if ((Object)(object)mesh != (Object)null)
			{
				Object.Destroy((Object)(object)mesh);
			}
		}
	}
	internal sealed class AdventureMeshClip
	{
		internal const float Near = 0.05f;

		internal readonly List<PixelVertex> Vertices = new List<PixelVertex>();

		internal readonly List<int> Triangles = new List<int>();

		private readonly PixelVertex[] polygon = new PixelVertex[4];

		private PixelVertex[] transformed = new PixelVertex[0];

		internal void Build(IList<PixelVertex> source, IList<int> triangles, HandPose pose)
		{
			Vertices.Clear();
			Triangles.Clear();
			if (transformed.Length < source.Count)
			{
				transformed = new PixelVertex[source.Count];
			}
			for (int i = 0; i < source.Count; i++)
			{
				PixelVertex pixelVertex = source[i];
				ToolPoint toolPoint = pose.Transform(new ToolPoint(pixelVertex.X, pixelVertex.Y, pixelVertex.Z));
				transformed[i] = new PixelVertex(toolPoint.X, toolPoint.Y, toolPoint.Z, pixelVertex.U, pixelVertex.V);
			}
			for (int j = 0; j < triangles.Count; j += 3)
			{
				int num = 0;
				PixelVertex pixelVertex2 = transformed[triangles[j + 2]];
				for (int k = 0; k < 3; k++)
				{
					PixelVertex pixelVertex3 = transformed[triangles[j + k]];
					if (pixelVertex2.Z >= 0.05f != pixelVertex3.Z >= 0.05f)
					{
						float num2 = (0.05f - pixelVertex2.Z) / (pixelVertex3.Z - pixelVertex2.Z);
						polygon[num++] = new PixelVertex(pixelVertex2.X + (pixelVertex3.X - pixelVertex2.X) * num2, pixelVertex2.Y + (pixelVertex3.Y - pixelVertex2.Y) * num2, 0.05f, pixelVertex2.U + (pixelVertex3.U - pixelVertex2.U) * num2, pixelVertex2.V + (pixelVertex3.V - pixelVertex2.V) * num2);
					}
					if (pixelVertex3.Z >= 0.05f)
					{
						polygon[num++] = pixelVertex3;
					}
					pixelVertex2 = pixelVertex3;
				}
				int count = Vertices.Count;
				for (int l = 0; l < num; l++)
				{
					Vertices.Add(polygon[l]);
				}
				for (int m = 1; m < num - 1; m++)
				{
					Triangles.Add(count);
					Triangles.Add(count + m);
					Triangles.Add(count + m + 1);
				}
			}
		}
	}
	internal static class AdventurePrefab
	{
		internal static Item_Object Build(Item_Object template, string id, Transform staging, List<GameObject> owned)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Expected O, but got Unknown
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			AdventureKind adventureKind = AdventureAssets.Kind(id);
			GameObject val = Object.Instantiate<GameObject>(((Component)template.itemData.handItemAsset).gameObject, staging);
			owned.Add(val);
			val.SetActive(false);
			((Object)val).name = id + "_Hand";
			HandItem[] components = val.GetComponents<HandItem>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			Hand_SpriteController[] componentsInChildren = val.GetComponentsInChildren<Hand_SpriteController>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			SpriteRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SpriteRenderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			Renderer[] componentsInChildren3 = val.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].enabled = false;
			}
			Behaviour[] componentsInChildren4 = val.GetComponentsInChildren<Behaviour>(true);
			foreach (Behaviour val2 in componentsInChildren4)
			{
				if (!(val2 is ViewSway) || !((Object)(object)((Component)val2).gameObject == (Object)(object)val))
				{
					val2.enabled = false;
				}
			}
			AdventureHand adventureHand = val.AddComponent<AdventureHand>();
			adventureHand.kind = (int)adventureKind;
			((HandItem)adventureHand).canUseWhileHanging = true;
			((HandItem)adventureHand).useSprintViewSway = true;
			((HandItem)adventureHand).useStats = new List<string>();
			((HandItem)adventureHand).interactionModules = new List<Item_InteractionModule>();
			((HandItem)adventureHand).itemCosmetics = new List<Cosmetic_Item>();
			((HandItem)adventureHand).simpleUseModules = new List<SimpleModule>();
			((HandItem)adventureHand).itemUseEvent = new UnityEvent();
			((HandItem)adventureHand).firstGrabFlag = "";
			((HandItem)adventureHand).firstGrabEvent = new UnityEvent();
			GameObject val3 = Object.Instantiate<GameObject>(((Component)template).gameObject, staging);
			owned.Add(val3);
			val3.SetActive(false);
			((Object)val3).name = id;
			Item_Object component = val3.GetComponent<Item_Object>();
			Item val4 = (component.itemData = InventoryWeight.Clone(template.itemData));
			val4.prefabName = id;
			val4.itemName = adventureKind switch
			{
				AdventureKind.Pearl => "ENDER PEARL", 
				AdventureKind.WindCharge => "WIND CHARGE", 
				_ => adventureKind.ToString().ToUpperInvariant(), 
			};
			val4.itemTag = "mineknuckle";
			val4.itemTags = new List<string> { "mineknuckle", "tool" };
			val4.itemWeight = 0f;
			val4.worth = 0;
			val4.used = false;
			val4.allowCosmetics = false;
			val4.inventoryScale = (val4.lockboxScale = 1f);
			val4.pocketable = (val4.pouchable = true);
			val4.interactType = (InteractType)2;
			val4.data = new List<string>();
			if (ItemCatalog.IsStack(id))
			{
				StackData.Set(val4, 0);
			}
			val4.dataModules = new List<Item_Data>();
			val4.dataModuleSaves = new List<DataModuleSave>();
			val4.executionModules = new List<ItemExecutionModule>();
			val4.useFlags = false;
			val4.pickupStat = "";
			val4.unlockType = (UnlockType)0;
			val4.upDirection = Vector3.forward;
			val4.itemAsset = component;
			val4.handItemAsset = (HandItem)(object)adventureHand;
			val4.normalSprite = AdventureAssets.Icon(adventureKind);
			component.pickupEvent = new UnityEvent();
			component.onPlaceInInventory = new UnityEvent();
			component.onPlaceInWorld = new UnityEvent();
			component.onDrop = new UnityEvent();
			componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer obj in componentsInChildren3)
			{
				obj.forceRenderingOff = true;
				obj.enabled = false;
			}
			Animator[] componentsInChildren5 = val3.GetComponentsInChildren<Animator>(true);
			for (int i = 0; i < componentsInChildren5.Length; i++)
			{
				((Behaviour)componentsInChildren5[i]).enabled = false;
			}
			CL_Lamp[] componentsInChildren6 = val3.GetComponentsInChildren<CL_Lamp>(true);
			for (int i = 0; i < componentsInChildren6.Length; i++)
			{
				((Component)componentsInChildren6[i]).gameObject.SetActive(false);
			}
			Light[] componentsInChildren7 = val3.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren7.Length; i++)
			{
				((Behaviour)componentsInChildren7[i]).enabled = false;
			}
			GameObject val5 = ((adventureKind == AdventureKind.Torch) ? BlockAssets.Visual(val3.transform, "Minecraft torch", BlockKind.Torch, val3.layer) : AdventureAssets.Visual(val3.transform, val3.layer, adventureKind));
			val5.transform.localScale = Vector3.one * 0.4f;
			BoxCollider component2 = val3.GetComponent<BoxCollider>();
			if ((Object)(object)component2 != (Object)null)
			{
				val5.transform.localPosition = component2.center;
				component2.size = new Vector3(0.4f, 0.5f, 0.15f);
			}
			DroppedItemVisuals.Attach(component, val5.transform);
			if (adventureKind == AdventureKind.Torch)
			{
				NativeTorchLight nativeTorchLight = val3.AddComponent<NativeTorchLight>();
				nativeTorchLight.owner = component;
				nativeTorchLight.tip = val5.transform;
			}
			CL_Prop component3 = val3.GetComponent<CL_Prop>();
			if ((Object)(object)component3 != (Object)null)
			{
				((GameEntity)component3).entityPrefabID = id;
			}
			val.transform.SetParent((Transform)null, false);
			val3.transform.SetParent((Transform)null, false);
			Object.DontDestroyOnLoad((Object)(object)val);
			Object.DontDestroyOnLoad((Object)(object)val3);
			return component;
		}
	}
	internal enum AdventureKind
	{
		Bow,
		Arrow,
		Shield,
		Pearl,
		Torch,
		Mace,
		WindCharge
	}
	internal static class AdventureRules
	{
		internal const float ShieldDelay = 0.25f;

		internal const float PearlCooldown = 1f;

		internal const float ArrowLife = 60f;

		internal const int ShieldDurability = 336;

		internal static float BowPower(float seconds)
		{
			float num = Math.Max(0f, seconds);
			return Math.Min(1f, (num * num + 2f * num) / 3f);
		}

		internal static int BowStage(float seconds, bool usingItem)
		{
			if (usingItem)
			{
				if (!(seconds >= 0.9f))
				{
					if (!(seconds >= 0.65f))
					{
						return 1;
					}
					return 2;
				}
				return 3;
			}
			return 0;
		}

		internal static float Drag(float seconds)
		{
			return (float)Math.Pow(0.99, seconds * 20f);
		}

		internal static bool ShieldBlocks(string type, bool environmental, float elapsed, float forwardDot)
		{
			if (environmental || elapsed < 0.25f || forwardDot <= 0f)
			{
				return false;
			}
			type = (type ?? "").ToLowerInvariant();
			if (type != "falling" && type != "fall" && type != "fire" && type != "heat" && type != "steam" && type != "on_fire" && type != "starve" && type != "drown" && type != "poison" && type != "starvation" && type != "drowning" && type != "enderpearl")
			{
				return type != "void";
			}
			return false;
		}
	}
	internal static class AdventureMotion
	{
		internal static HandPose Torch(int side)
		{
			return HandPose.Identity.Scale(1f, 1f, -1f).Translate((float)side * 0.56f, -0.52f, -0.72f).Rotate(side * 45, 1)
				.Translate((float)side * 1.13f / 16f, 0.2f, 71f / (320f * (float)Math.PI))
				.Rotate(-side * 90, 1)
				.Rotate(side * 25, 2)
				.Scale(0.68f, 0.68f, 0.68f)
				.Scale(1f, 1f, -1f);
		}

		internal static HandPose Bow(float seconds, bool drawing, int side)
		{
			float num = AdventureRules.BowPower(seconds);
			float num2 = seconds * 20f;
			HandPose handPose = HandPose.Identity.Scale(1f, 1f, -1f).Translate((float)side * 0.56f, -0.52f, -0.72f);
			if (drawing)
			{
				float y = ((num > 0.1f) ? ((float)Math.Sin((num2 - 0.1f) * 1.3f) * (num - 0.1f) * 0.004f) : 0f);
				handPose = handPose.Translate((float)side * -0.2785682f, 0.18344387f, 0.15731531f).Rotate(-13.935f, 0).Rotate((float)side * 35.3f, 1)
					.Rotate((float)(-side) * 9.785f, 2)
					.Translate(0f, y, num * 0.04f)
					.Scale(1f, 1f, 1f + num * 0.2f)
					.Rotate(-side * 45, 1);
			}
			return handPose.Translate((float)side * 1.13f / 16f, 0.2f, 71f / (320f * (float)Math.PI)).Rotate(-90f, 1).Rotate(25f, 2)
				.Scale(0.68f, 0.68f, 0.68f)
				.Scale(1f, 1f, -1f);
		}

		internal static HandPose Small(int side, float throwProgress)
		{
			return HandPose.Identity.Translate((float)side * (0.52f - 0.2f * throwProgress), -0.48f + 0.2f * throwProgress, 0.8f).Rotate(side * -25, 2).Scale(0.55f, 0.55f, 0.55f);
		}

		internal static HandPose Shield(int side, bool blocking, float inverseHeight = 0f)
		{
			float num = ((side <= 0) ? (-(blocking ? 5 : 10)) : (blocking ? (-15) : (-10)));
			float num2 = ((side <= 0) ? ((float)(blocking ? 5 : 0)) : (blocking ? 3.25f : 1.75f));
			return HandPose.Identity.Scale(1f, 1f, -1f).Translate((float)side * 0.56f, -0.52f - 0.6f * Math.Max(0f, Math.Min(1f, inverseHeight)), -0.72f).Translate(num / 16f, num2 / 16f, (float)(blocking ? (-11) : (-10)) / 16f)
				.Rotate(side * 180, 1)
				.Rotate(side * (blocking ? (-5) : 5), 2)
				.Scale(1.25f, 1.25f, 1.25f)
				.Translate(-0.5f, -0.5f, -0.5f)
				.Scale(1f, 1f, -1f);
		}
	}
	internal sealed class AdventureWorld : IDisposable
	{
		private sealed class Flight
		{
			internal GameObject Object;

			internal Vector3 Position;

			internal Vector3 Velocity;

			internal ENT_Player Owner;

			internal bool Pearl;

			internal bool Critical;

			internal float Age;

			internal float Size;

			internal HeroProfile Hero;

			internal LuckyEquipmentShot Lucky;
		}

		private struct MaceContact
		{
			internal Collider Body;

			internal GameEntity Entity;

			internal Vector3 Point;

			internal float Travel;
		}

		private struct MaceSplash
		{
			internal Collider Body;

			internal Vector3 Point;

			internal float Distance;
		}

		private sealed class WindFlight
		{
			internal GameObject Obj;

			internal Transform Core;

			internal Transform Wind;

			internal Renderer CoreRenderer;

			internal Renderer WindRenderer;

			internal Vector3 Position;

			internal Vector3 Velocity;

			internal ENT_Player Owner;

			internal float Size;

			internal float Age;

			internal float NextTrail;
		}

		private readonly List<Flight> flights = new List<Flight>();

		private readonly List<MineArrowAnchor> anchors = new List<MineArrowAnchor>();

		private readonly PortalParticles portal = new PortalParticles();

		private readonly PearlDamage pearlDamage = new PearlDamage();

		private GameObject root;

		private float pearlReady;

		private ENT_Player maceMoving;

		private Vector3 maceStartFoot;

		private float maceStartHeight;

		private float maceRadius;

		private bool maceDescending;

		private bool maceStriking;

		private bool maceOwesFall;

		private bool maceOwesLanding;

		private bool maceHitSafeTop;

		private bool maceHitOtherTop;

		private bool maceResetNative;

		private float maceDebtPeak;

		private float maceDebtLanding;

		private readonly RaycastHit[] maceSweep = (RaycastHit[])(object)new RaycastHit[64];

		private readonly RaycastHit[] maceSight = (RaycastHit[])(object)new RaycastHit[48];

		private readonly Collider[] maceOverlaps = (Collider[])(object)new Collider[64];

		private readonly Dictionary<GameEntity, MaceSplash> maceSplash = new Dictionary<GameEntity, MaceSplash>();

		private const BindingFlags PlayerField = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo gravityScale = typeof(ENT_Player).GetField("gravityMult", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo extraGravity = typeof(ENT_Player).GetField("tempGravityMult", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo extraDrag = typeof(ENT_Player).GetField("tempFrictionMult", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo hasGravity = typeof(ENT_Player).GetField("hasGravity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private readonly List<WindFlight> winds = new List<WindFlight>();

		private readonly TrialFallState trialFall = new TrialFallState();

		private readonly RaycastHit[] windHits = (RaycastHit[])(object)new RaycastHit[64];

		private readonly Collider[] gustHits = (Collider[])(object)new Collider[96];

		private readonly List<Collider> maceBody = new List<Collider>(8);

		private readonly HashSet<GameEntity> pushed = new HashSet<GameEntity>();

		private MaterialPropertyBlock windUv;

		private int mainTexST;

		private int emissionST;

		private float windReady;

		private float maceReady;

		private ENT_Player trialOwner;

		private GameObject Root
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				if ((Object)(object)root == (Object)null)
				{
					root = new GameObject("MineKnuckle arrows and pearls");
				}
				return root;
			}
		}

		private static float Elevation => CL_GameManager.gMan.GetPlayerCorrectedHeight();

		internal bool FireArrow(ENT_Player owner, float power, Item ammo, Item bow = null)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (power < 0.1f || ammo == null || StackData.Count(ammo) <= 0 || !MineKnucklePlugin.GameplayReady())
			{
				return false;
			}
			if (!Launch(owner, pearl: false, power, ammo, HeroItems.Read(bow), LuckyEquipmentRuntime.SnapshotArrow(bow)))
			{
				return false;
			}
			MinecraftAudio.Bow(((Component)owner.cam).transform.position, power);
			return true;
		}

		internal bool ThrowPearl(ENT_Player owner, Item item)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < pearlReady || item == null || StackData.Count(item) <= 0 || !MineKnucklePlugin.GameplayReady())
			{
				return false;
			}
			if (!Launch(owner, pearl: true, 1f, item))
			{
				return false;
			}
			pearlReady = Time.time + 1f;
			MinecraftAudio.Pearl(((Component)owner.cam).transform.position, impact: false);
			return true;
		}

		private bool Launch(ENT_Player owner, bool pearl, float power, Item item, HeroProfile hero = null, LuckyEquipmentShot lucky = null)
		{
			//IL_0072: 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_0099: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			MineKnucklePlugin instance = MineKnucklePlugin.Instance;
			if ((Object)(object)instance == (Object)null || !instance.World.Ready)
			{
				return false;
			}
			float size = instance.World.Size;
			int layer = instance.World.Layer;
			GameObject val = null;
			bool flag = false;
			try
			{
				val = (pearl ? AdventureAssets.Visual(Root.transform, layer, AdventureKind.Pearl) : AdventureAssets.Arrow(Root.transform, layer));
				val.SetActive(false);
				val.transform.localScale = Vector3.one * (pearl ? (0.25f * size) : size);
				Vector3 position = ((Component)owner.cam).transform.position - ((Component)owner.cam).transform.up * 0.1f;
				val.transform.position = position;
				val.transform.rotation = Quaternion.LookRotation(((Component)owner.cam).transform.forward);
				Flight item2 = new Flight
				{
					Object = val,
					Owner = owner,
					Position = position,
					Velocity = ((Component)owner.cam).transform.forward * (pearl ? 30f : (60f * power)) * size,
					Pearl = pearl,
					Critical = (!pearl && power >= 1f),
					Size = size,
					Hero = hero,
					Lucky = lucky
				};
				if (!pearl && hero != null && hero.Fire > 0)
				{
					HeroArrowFlame.Attach(val);
				}
				if (!StackData.Spend(item))
				{
					Object.Destroy((Object)(object)val);
					return false;
				}
				flag = true;
				flights.Add(item2);
				val.SetActive(true);
			}
			catch
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				if (flag)
				{
					StackData.Set(item, StackData.Count(item) + 1);
				}
				throw;
			}
			StackData.DestroyIfEmpty(item);
			WK_Leaderboard_Core.disableLeaderboards = true;
			return true;
		}

		internal void Tick(float dt)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			if (!MineKnucklePlugin.SimulationReady())
			{
				return;
			}
			TickTrials(dt);
			Flight[] array = flights.ToArray();
			foreach (Flight flight in array)
			{
				if ((Object)(object)flight.Object == (Object)null || (Object)(object)flight.Owner == (Object)null || ((GameEntity)flight.Owner).dead)
				{
					Remove(flight);
					continue;
				}
				float num = Mathf.Min(dt, 0.25f);
				while (num > 0f && flights.Contains(flight))
				{
					float num2 = Mathf.Min(num, 0.025f);
					num -= num2;
					flight.Age += num2;
					Vector3 val = flight.Velocity * num2;
					if (Trace(flight, val, out var nearest))
					{
						flights.Remove(flight);
						try
						{
							Impact(flight, nearest);
						}
						finally
						{
							Remove(flight);
						}
						break;
					}
					flight.Position += val;
					flight.Object.transform.position = flight.Position;
					flight.Velocity = flight.Velocity * AdventureRules.Drag(num2) + Vector3.down * ((float)(flight.Pearl ? 12 : 20) * flight.Size * num2);
					if (flight.Pearl)
					{
						flight.Object.transform.rotation = Quaternion.LookRotation(((Component)flight.Owner.cam).transform.forward);
					}
					else if (((Vector3)(ref flight.Velocity)).sqrMagnitude > 0.001f)
					{
						flight.Object.transform.rotation = Quaternion.LookRotation(flight.Velocity);
					}
					if (flight.Age > 20f || flight.Position.y < DEN_DeathFloor.GetHeight() - flight.Size)
					{
						Remove(flight);
						break;
					}
				}
			}
			for (int num3 = anchors.Count - 1; num3 >= 0; num3--)
			{
				MineArrowAnchor mineArrowAnchor = anchors[num3];
				if ((Object)(object)mineArrowAnchor == (Object)null)
				{
					anchors.RemoveAt(num3);
				}
				else if (!mineArrowAnchor.Tick(dt))
				{
					mineArrowAnchor.Remove();
					anchors.RemoveAt(num3);
				}
			}
			ENT_Player player = ENT_Player.GetPlayer();
			portal.Tick(((Object)(object)player == (Object)null) ? null : player.cam, dt);
		}

		private static bool Trace(Flight f, Vector3 move, out RaycastHit nearest)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			nearest = default(RaycastHit);
			float num = float.MaxValue;
			bool result = false;
			RaycastHit[] array = Physics.SphereCastAll(f.Position, (f.Pearl ? 0.07f : 0.025f) * f.Size, ((Vector3)(ref move)).normalized, ((Vector3)(ref move)).magnitude, f.Pearl ? (-1) : (-5), (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				Collider collider = ((RaycastHit)(ref val)).collider;
				if (!((Object)(object)collider == (Object)null) && !((Object)(object)collider == (Object)(object)f.Owner.cCon) && !((Object)(object)collider == (Object)(object)f.Owner.capsuleCollider) && !((Component)collider).transform.IsChildOf(((Component)f.Owner).transform) && !((Object)(object)((Component)collider).GetComponentInParent<HandItem>() != (Object)null) && !StoredItems.ColliderIsStored(collider))
				{
					GameEntity val2 = BlastCombat.Entity(collider);
					if (!((Object)(object)val2 == (Object)(object)f.Owner) && (!collider.isTrigger || !((Object)(object)val2 == (Object)null) || ((Component)collider).GetComponentInParent<Damageable>() != null) && (!f.Pearl || collider.isTrigger || PearlCollision.Blocks(f.Owner, collider)) && ((RaycastHit)(ref val)).distance < num)
					{
						nearest = (f.Pearl ? PearlCollision.Contact(val, f.Position, move, 0.07f * f.Size) : val);
						num = ((RaycastHit)(ref val)).distance;
						result = true;
					}
				}
			}
			return result;
		}

		private void Impact(Flight f, RaycastHit hit)
		{
			//IL_0047: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			if (f.Pearl)
			{
				portal.Emit(Root.transform, ((RaycastHit)(ref hit)).point, f.Object.layer, f.Size);
				Teleport(f.Owner, hit, f);
				return;
			}
			MinecraftAudio.ArrowHit(((RaycastHit)(ref hit)).point);
			Damageable val = ((Component)((RaycastHit)(ref hit)).collider).GetComponent<Damageable>() ?? ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<Damageable>();
			GameEntity val2 = BlastCombat.Entity(((RaycastHit)(ref hit)).collider);
			if (val != null && (Object)(object)val2 != (Object)(object)f.Owner && ((Object)(object)val2 == (Object)null || (val2.damageable && !val2.dead)))
			{
				float num = Mathf.Ceil(((Vector3)(ref f.Velocity)).magnitude / (20f * f.Size) * 2f);
				if (f.Critical)
				{
					num += (float)Random.Range(0, Mathf.FloorToInt(num / 2f) + 2);
				}
				DamageInfo val3 = DamageInfo.CreateDamageInfo(num / 5f * MineKnucklePlugin.Instance.Registry.MeleeDamage * HeroRules.BowMultiplier(f.Hero), "Projectile", new List<string> { "player", "projectile", "arrow" }, (GameEntity)(object)f.Owner);
				val3.position = ((RaycastHit)(ref hit)).point;
				val3.direction = ((Vector3)(ref f.Velocity)).normalized;
				val3.sourceObject = ((Component)f.Owner).gameObject;
				HeroItems.EnchantProfile(f.Hero, val3);
				float num2 = (((Object)(object)val2 == (Object)null) ? 0f : val2.health);
				val.Damage(val3);
				if ((Object)(object)val2 != (Object)null && !val2.dead && val2.health < num2 && f.Hero != null && f.Hero.Punch > 0)
				{
					val2.AddForce(val3.direction * (float)(35 * f.Hero.Punch), "");
				}
				Survival.ExhaustAction(0.1f);
				LuckyEquipmentRuntime.ArrowImpact(f.Lucky, ((RaycastHit)(ref hit)).point, f.Owner, val2);
			}
			else
			{
				if (((RaycastHit)(ref hit)).collider.isTrigger || ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)f.Owner && !(val2 is CL_Prop)))
				{
					return;
				}
				LuckyEquipmentRuntime.ArrowImpact(f.Lucky, ((RaycastHit)(ref hit)).point, f.Owner, val2);
				if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null || !((RaycastHit)(ref hit)).collider.enabled || !((Component)((RaycastHit)(ref hit)).collider).gameObject.activeInHierarchy)
				{
					return;
				}
				Vector3 val4 = ((Vector3.Dot(((Vector3)(ref f.Velocity)).normalized, -((RaycastHit)(ref hit)).normal) > 0.25f) ? ((Vector3)(ref f.Velocity)).normalized : (-((RaycastHit)(ref hit)).normal));
				GameObject val5 = AdventureAssets.Arrow(Root.transform, f.Object.layer);
				val5.SetActive(false);
				val5.transform.SetPositionAndRotation(((RaycastHit)(ref hit)).point - val4 * 0.015f, Quaternion.LookRotation(val4));
				val5.transform.localScale = Vector3.one * f.Size;
				BoxCollider obj = val5.AddComponent<BoxCollider>();
				obj.center = new Vector3(0f, 0f, -0.42f);
				obj.size = new Vector3(0.12f, 0.12f, 0.78f);
				val5.AddComponent<ObjectTagger>().tags = new List<string> { "Handhold" };
				CL_Handhold val6 = val5.AddComponent<CL_Handhold>();
				val6.active = (val6.secure = true);
				val6.canHammer = false;
				val6.useSharedHandholdMaterial = false;
				val6.modules = new List<HandholdModule>();
				val6.handholdRenderer = val5.GetComponent<Renderer>();
				val6.activeEvent = new UnityEvent();
				val6.stopEvent = new UnityEvent();
				val6.hammerEvent = new UnityEvent();
				MineArrowAnchor mineArrowAnchor = val5.AddComponent<MineArrowAnchor>();
				mineArrowAnchor.Bind(((RaycastHit)(ref hit)).collider, val6);
				val5.SetActive(true);
				val6.Initialize();
				anchors.Add(mineArrowAnchor);
				Physics.SyncTransforms();
				if (anchors.Count <= 128)
				{
					return;
				}
				for (int i = 0; i < anchors.Count; i++)
				{
					if ((Object)(object)anchors[i] != (Object)null && !anchors[i].Held)
					{
						anchors[i].Remove();
						anchors.RemoveAt(i);
						break;
					}
				}
			}
		}

		private void Teleport(ENT_Player player, RaycastHit hit, Flight flight)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (!PearlLanding.Find(player, hit, flight.Position, flight.Velocity, out var destination))
			{
				MineKnucklePlugin.Instance.Status("ENDER PEARL: DESTINATION BLOCKED");
				MineKnucklePlugin.Instance.Log("Pearl landing blocked at " + ((object)((RaycastHit)(ref hit)).point/*cast due to .constrained prefix*/).ToString() + " normal " + ((object)((RaycastHit)(ref hit)).normal/*cast due to .constrained prefix*/).ToString() + " collider " + ((Object)((RaycastHit)(ref hit)).collider).name);
			}
			else
			{
				Vector3 position = ((Component)player).transform.position;
				((GameEntity)player).Teleport(destination, ((Component)player).transform.rotation, false);
				trialFall.Reset();
				MineKnucklePlugin.Instance.Slime.Clear();
				HayLanding.Clear();
				CrouchEdgeGuard.Clear();
				Physics.SyncTransforms();
				MinecraftAudio.Pearl(position, impact: true);
				MinecraftAudio.Pearl(((Component)player).transform.position, impact: true);
				pearlDamage.Apply(player, Time.time);
			}
		}

		private void Remove(Flight f)
		{
			if ((Object)(object)f.Object != (Object)null)
			{
				f.Object.SetActive(false);
				Object.Destroy((Object)(object)f.Object);
			}
			flights.Remove(f);
		}

		internal void Offset(float amount)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			OffsetTrials(amount);
			Vector3 val = Vector3.up * amount;
			if ((Object)(object)root != (Object)null)
			{
				Transform transform = root.transform;
				transform.position += val;
			}
			foreach (Flight flight in flights)
			{
				flight.Position += val;
			}
		}

		public void Dispose()
		{
			ClearTrials();
			foreach (MineArrowAnchor anchor in anchors)
			{
				if ((Object)(object)anchor != (Object)null)
				{
					anchor.Remove();
				}
			}
			anchors.Clear();
			flights.Clear();
			portal.Clear();
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)root);
			}
			root = null;
			pearlReady = 0f;
			pearlDamage.Reset();
		}

		private void ClearMaceDebt()
		{
			maceOwesFall = (maceOwesLanding = false);
			maceDebtPeak = (maceDebtLanding = 0f);
		}

		private void KeepMaceDebt()
		{
			maceDebtPeak = (maceOwesFall ? Mathf.Max(maceDebtPeak, trialFall.Peak) : trialFall.Peak);
			maceOwesFall = true;
		}

		private static bool MaceEquipped(ENT_Player p)
		{
			if ((Object)(object)p == (Object)null || p.hands == null)
			{
				return false;
			}
			Hand[] hands = p.hands;
			foreach (Hand val in hands)
			{
				AdventureHand adventureHand = ((val == null) ? null : (val.GetHandItem() as AdventureHand));
				if ((Object)(object)adventureHand != (Object)null && adventureHand.Kind == AdventureKind.Mace && adventureHand.Available)
				{
					return true;
				}
			}
			return false;
		}

		private static GameEntity MaceEntity(Collider c)
		{
			GameEntity val = BlastCombat.Entity(c);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Hitbox componentInParent = ((Component)c).GetComponentInParent<Hitbox>();
			if (componentInParent != null)
			{
				return componentInParent.GetGameEntity();
			}
			return ((Component)c).GetComponentInParent<GameEntity>();
		}

		private static bool Creature(GameEntity e)
		{
			if ((Object)(object)e == (Object)null || e is ENT_Player || e is CL_Prop)
			{
				return false;
			}
			if (e is LuckyMobEntity || e is Denizen)
			{
				return true;
			}
			ObjectTagger tagger = e.GetTagger();
			if ((Object)(object)tagger != (Object)null)
			{
				if (!tagger.HasTag("Enemy") && !tagger.HasTag("Animal"))
				{
					return tagger.HasTag("Creature");
				}
				return true;
			}
			return false;
		}

		private static bool Pet(GameEntity e)
		{
			LuckyMobEntity luckyMobEntity = e as LuckyMobEntity;
			if ((Object)(object)luckyMobEntity != (Object)null && luckyMobEntity.Friendly)
			{
				return LuckyMobRules.Pet(luckyMobEntity.Kind);
			}
			return false;
		}

		private static bool SkipMace(ENT_Player p, Collider c)
		{
			if (!((Object)(object)c == (Object)null) && c.enabled && !((Object)(object)c == (Object)(object)p.cCon) && !((Object)(object)c == (Object)(object)p.capsuleCollider) && !((Component)c).transform.IsChildOf(((Component)p).transform) && !((Object)(object)((Component)c).GetComponentInParent<HandItem>() != (Object)null))
			{
				return StoredItems.ColliderIsStored(c);
			}
			return true;
		}

		private static Vector3 Feet(ENT_Player p, float radius)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0028: 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)
			Bounds bounds = ((Collider)p.cCon).bounds;
			return new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y + radius, ((Bounds)(ref bounds)).center.z);
		}

		private static float FootRadius(ENT_Player p, float size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = ((Collider)p.cCon).bounds;
			return Mathf.Max(0.03f * size, Mathf.Min(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.92f);
		}

		private static Vector3 MaceNearest(Collider c, Vector3 p)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			MeshCollider val = (MeshCollider)(object)((c is MeshCollider) ? c : null);
			if (!(c is BoxCollider) && !(c is SphereCollider) && !(c is CapsuleCollider) && (!((Object)(object)val != (Object)null) || !val.convex))
			{
				Bounds bounds = c.bounds;
				return ((Bounds)(ref bounds)).ClosestPoint(p);
			}
			return c.ClosestPoint(p);
		}

		private static float Factor(FieldInfo f, ENT_Player p)
		{
			if (!(f == null))
			{
				return (float)f.GetValue(p);
			}
			return 1f;
		}

		private static void MaceRebound(ENT_Player p, float size)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00c5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (CanTrack(p) && !p.IsFlying() && (!(hasGravity != null) || (bool)hasGravity.GetValue(p)))
			{
				float gravity = (0f - p.gravity) * p.GetPlayerGravityVector().y * Factor(gravityScale, p) * Factor(extraGravity, p) * Mathf.Max(0.2f, 1f + ((GameEntity)p).curBuffs.GetBuff("addGravity"));
				float drag = p.dragCoefficient * Factor(extraDrag, p) * (1f + ((GameEntity)p).curBuffs.GetBuff("addDrag"));
				Vector3 velocity = p.GetVelocity();
				float num = TrialRules.BurstVelocity(3, size, gravity, drag, Mathf.Sqrt(velocity.x * velocity.x + velocity.z * velocity.z), Time.fixedDeltaTime);
				if (num > 0f && num > velocity.y)
				{
					((GameEntity)p).AddForce(Vector3.up * (10f * (num - velocity.y)), "");
				}
			}
		}

		private bool MaceAim(ENT_Player p, ToolRegistry registry, float unit, out MaceContact best)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00a6: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			best = default(MaceContact);
			Vector3 position = ((Component)p.cam).transform.position;
			Vector3 forward = ((Component)p.cam).transform.forward;
			float num = TrialRules.MaceReach(unit, registry.HammerRange);
			float hammerRadius = registry.HammerRadius;
			float wall = float.PositiveInfinity;
			RaycastHit[] array = maceSweep;
			int num2 = Physics.SphereCastNonAlloc(position, hammerRadius, forward, array, num, -1, (QueryTriggerInteraction)2);
			if (num2 == array.Length)
			{
				array = Physics.SphereCastAll(position, hammerRadius, forward, num, -1, (QueryTriggerInteraction)2);
				num2 = array.Length;
			}
			for (int i = 0; i < num2; i++)
			{
				RaycastHit val = array[i];
				if (!SkipMace(p, ((RaycastHit)(ref val)).collider))
				{
					Vector3 point = ((((RaycastHit)(ref val)).distance < 0.0001f) ? MaceNearest(((RaycastHit)(ref val)).collider, position) : ((RaycastHit)(ref val)).point);
					ConsiderMaceAim(p, ((RaycastHit)(ref val)).collider, position, forward, point, ((RaycastHit)(ref val)).distance, num, ref best, ref wall);
				}
			}
			Collider[] array2 = maceOverlaps;
			int num3 = Physics.OverlapSphereNonAlloc(position, hammerRadius, array2, -1, (QueryTriggerInteraction)2);
			if (num3 == array2.Length)
			{
				array2 = Physics.OverlapSphere(position, hammerRadius, -1, (QueryTriggerInteraction)2);
				num3 = array2.Length;
			}
			for (int j = 0; j < num3; j++)
			{
				Collider c = array2[j];
				if (!SkipMace(p, c))
				{
					Vector3 val2 = MaceNearest(c, position);
					Vector3 val3 = val2 - position;
					if (((Vector3)(ref val3)).sqrMagnitude <= hammerRadius * hammerRadius + 1E-06f && Vector3.Dot(val3, forward) >= -0.0001f)
					{
						ConsiderMaceAim(p, c, position, forward, val2, 0f, num, ref best, ref wall);
					}
				}
			}
			if ((Object)(object)best.Body != (Object)null && wall > best.Travel + 0.0001f)
			{
				return MaceClear(p, position, best.Point, best.Body, null, best.Entity);
			}
			return false;
		}

		private static void ConsiderMaceAim(ENT_Player p, Collider c, Vector3 from, Vector3 dir, Vector3 point, float travel, float reach, ref MaceContact best, ref float wall)
		{
			//IL_0051: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			GameEntity val = MaceEntity(c);
			if (ImpactReceiver(c, val) == null || (Object)(object)val == (Object)(object)p || ((Object)(object)val != (Object)null && (!val.damageable || val.dead)))
			{
				if (!c.isTrigger && PearlCollision.Blocks(p, c))
				{
					wall = Mathf.Min(wall, travel);
				}
				return;
			}
			Vector3 val2 = point - from;
			if (!(((Vector3)(ref val2)).sqrMagnitude > reach * reach) && !(Vector3.Dot(point - from, dir) < -0.0001f) && ((Object)(object)best.Body == (Object)null || travel < best.Travel || (travel == best.Travel && ((Object)c).GetInstanceID() < ((Object)best.Body).GetInstanceID())))
			{
				best = new MaceContact
				{
					Body = c,
					Entity = val,
					Point = point,
					Travel = travel
				};
			}
		}

		internal void BeginMaceMove(ENT_Player p)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!SamePlayer(p) || !CanTrack(p))
			{
				ResetTrialFall();
				return;
			}
			MineKnucklePlugin instance = MineKnucklePlugin.Instance;
			maceStartHeight = Elevation;
			maceRadius = FootRadius(p, instance.World.Size);
			maceStartFoot = Feet(p, maceRadius);
			maceStartFoot.y += maceStartHeight - ((Component)p).transform.position.y;
			maceMoving = p;
			maceHitSafeTop = (maceHitOtherTop = false);
			trialFall.Observe(maceStartHeight, p.cCon.isGrounded);
		}

		internal void MaceSurface(ENT_Player p, ControllerColliderHit hit)
		{
			//IL_0025: 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)
			if (!((Object)(object)maceMoving != (Object)(object)p) && hit != null && !((Object)(object)hit.controller != (Object)(object)p.cCon) && !(hit.normal.y < 0.9f) && !(hit.moveDirection.y >= 0f) && !((Object)(object)hit.collider == (Object)null))
			{
				MineBlock component = ((Component)hit.collider).GetComponent<MineBlock>();
				if ((Object)(object)component != (Object)null && (component.Kind == BlockKind.HayBale || component.Kind == BlockKind.Slime))
				{
					maceHitSafeTop = true;
				}
				else
				{
					maceHitOtherTop = true;
				}
			}
		}

		internal void FinishMaceMove(ENT_Player p)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)maceMoving != (Object)(object)p || (Object)(object)p == (Object)null)
			{
				return;
			}
			maceMoving = null;
			if (!CanTrack(p))
			{
				ResetTrialFall();
				return;
			}
			MineKnucklePlugin instance = MineKnucklePlugin.Instance;
			float elevation = Elevation;
			float size = instance.World.Size;
			bool isGrounded = p.cCon.isGrounded;
			maceDescending = elevation < maceStartHeight - 0.0001f * size;
			if (maceDescending && trialFall.Descent(elevation, size, descending: true) > 1.5f && MaceEquipped(p))
			{
				if (!trialFall.Protected && !p.GetGodmode())
				{
					KeepMaceDebt();
				}
				Vector3 val = maceStartFoot;
				val.y += ((Component)p).transform.position.y - elevation;
				Vector3 val2 = Feet(p, maceRadius);
				Vector3 val3 = val2 - val;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude > 0.0001f && FindMaceContact(p, val, val2, maceRadius, size, maceStartHeight, elevation, out var best))
				{
					float height = Mathf.Lerp(maceStartHeight, elevation, Mathf.Clamp01(best.Travel / magnitude));
					float descent = trialFall.Descent(height, size, descending: true);
					if (TrialRules.SmashBonus(descent) > 0f)
					{
						Collider body = best.Body;
						GameEntity entity = best.Entity;
						Vector3 point = best.Point;
						val3 = val2 - val;
						StrikeMace(p, body, entity, point, ((Vector3)(ref val3)).normalized, height, descent, size, contact: true);
					}
				}
			}
			if (maceOwesFall && !maceOwesLanding)
			{
				if (maceHitSafeTop && !maceHitOtherTop)
				{
					ClearMaceDebt();
				}
				else if (isGrounded)
				{
					maceDebtLanding = elevation;
					maceOwesLanding = true;
				}
			}
			trialFall.Observe(elevation, isGrounded);
			if (isGrounded)
			{
				maceDescending = false;
			}
		}

		internal float MaceCharge01(ENT_Player p)
		{
			MineKnucklePlugin instance = MineKnucklePlugin.Instance;
			if ((Object)(object)instance == (Object)null || instance.World == null || !instance.World.Ready || (Object)(object)p != (Object)(object)trialOwner || !CanTrack(p) || p.cCon.isGrounded || !maceDescending || !MaceEquipped(p))
			{
				return 0f;
			}
			return TrialRules.Charge(trialFall.Descent(Elevation, instance.World.Size, descending: true));
		}

		private static bool ValidMaceTarget(GameEntity e)
		{
			if ((Object)(object)e != (Object)null && e.damageable && !e.dead && Creature(e))
			{
				return !Pet(e);
			}
			return false;
		}

		private void Candidate(ref MaceContact best, Collider c, GameEntity e, Vector3 point, Vector3 centre, float travel, float minTravel, float unit)
		{
			//IL_0007: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d6: 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)
			if (travel <= minTravel)
			{
				return;
			}
			float y = centre.y;
			Bounds bounds = c.bounds;
			if (y < ((Bounds)(ref bounds)).center.y - 0.05f * unit)
			{
				return;
			}
			float y2 = point.y;
			bounds = c.bounds;
			if (y2 < ((Bounds)(ref bounds)).center.y - 0.15f * unit)
			{
				return;
			}
			if ((Object)(object)best.Body != (Object)null)
			{
				if (travel > best.Travel + 0.0001f * unit)
				{
					return;
				}
				if (Mathf.Abs(travel - best.Travel) <= 0.0001f * unit)
				{
					int instanceID = ((Object)e).GetInstanceID();
					int instanceID2 = ((Object)best.Entity).GetInstanceID();
					if (instanceID > instanceID2 || (instanceID == instanceID2 && ((Object)c).GetInstanceID() >= ((Object)best.Body).GetInstanceID()))
					{
						return;
					}
				}
			}
			best = new MaceContact
			{
				Body = c,
				Entity = e,
				Point = point,
				Travel = travel
			};
		}

		private bool FindMaceContact(ENT_Player p, Vector3 from, Vector3 to, float radius, float unit, float startHeight, float endHeight, out MaceContact best)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_015e: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			best = default(MaceContact);
			Vector3 val = to - from;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 0.0001f || val.y >= -1E-05f)
			{
				return false;
			}
			Vector3 val2 = val / magnitude;
			float num = magnitude + 0.055f * unit;
			float num2 = float.PositiveInfinity;
			float num3 = trialFall.Peak - 1.5f * unit;
			float minTravel = ((startHeight < num3) ? (-1f) : (magnitude * (startHeight - num3) / Mathf.Max(1E-06f, startHeight - endHeight)));
			RaycastHit[] array = maceSweep;
			int num4 = Physics.SphereCastNonAlloc(from, radius, val2, array, num, -1, (QueryTriggerInteraction)2);
			if (num4 == array.Length)
			{
				array = Physics.SphereCastAll(from, radius, val2, num, -1, (QueryTriggerInteraction)2);
				num4 = array.Length;
			}
			for (int i = 0; i < num4; i++)
			{
				RaycastHit val3 = array[i];
				Collider collider = ((RaycastHit)(ref val3)).collider;
				if (!SkipMace(p, collider))
				{
					GameEntity e = MaceEntity(collider);
					if (ValidMaceTarget(e))
					{
						Vector3 val4 = from + val2 * ((RaycastHit)(ref val3)).distance;
						Vector3 point = ((((RaycastHit)(ref val3)).distance < 0.0001f) ? MaceNearest(collider, val4) : ((RaycastHit)(ref val3)).point);
						Candidate(ref best, collider, e, point, val4, ((RaycastHit)(ref val3)).distance, minTravel, unit);
					}
					else if (!collider.isTrigger && PearlCollision.Blocks(p, collider) && Vector3.Dot(val2, ((RaycastHit)(ref val3)).normal) < -0.001f)
					{
						num2 = Mathf.Min(num2, ((RaycastHit)(ref val3)).distance);
					}
				}
			}
			Collider[] array2 = maceOverlaps;
			int num5 = Physics.OverlapSphereNonAlloc(from, radius, array2, -1, (QueryTriggerInteraction)2);
			if (num5 == array2.Length)
			{
				array2 = Physics.OverlapSphere(from, radius, -1, (QueryTriggerInteraction)2);
				num5 = array2.Length;
			}
			for (int j = 0; j < num5; j++)
			{
				Collider c = array2[j];
				if (SkipMace(p, c))
				{
					continue;
				}
				GameEntity e2 = MaceEntity(c);
				if (ValidMaceTarget(e2))
				{
					Vector3 val5 = MaceNearest(c, from);
					Vector3 val6 = val5 - from;
					if (((Vector3)(ref val6)).sqrMagnitude <= (radius + 0.002f * unit) * (radius + 0.002f * unit))
					{
						Candidate(ref best, c, e2, val5, from, 0f, minTravel, unit);
					}
				}
			}
			if ((Object)(object)best.Body == (Object)null || num2 <= best.Travel + 0.001f * unit)
			{
				return false;
			}
			return MaceClear(p, from, best.Point, best.Body, null, best.Entity);
		}

		private bool MaceClear(ENT_Player p, Vector3 from, Vector3 to, Collider target, GameEntity source, GameEntity end)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003e: 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)
			Vector3 val = to - from;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 0.002f)
			{
				return true;
			}
			Vector3 val2 = val / magnitude;
			RaycastHit[] array = maceSight;
			int num = Physics.RaycastNonAlloc(from, val2, array, magnitude, -5, (QueryTriggerInteraction)1);
			if (num == array.Length)
			{
				array = Physics.RaycastAll(from, val2, magnitude, -5, (QueryTriggerInteraction)1);
				num = array.Length;
			}
			for (int i = 0; i < num; i++)
			{
				Collider collider = ((RaycastHit)(ref array[i])).collider;
				if (!((Object)(object)collider == (Object)(object)target) && !SkipMace(p, collider))
				{
					GameEntity val3 = MaceEntity(collider);
					if ((!((O