Decompiled source of Gyros Steel Balls v1.0.0

HtfSteelBalls.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HtfSteelBalls")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+82fe86414d94329a4ef0691cf8cb323e2592e157")]
[assembly: AssemblyProduct("HtfSteelBalls")]
[assembly: AssemblyTitle("HtfSteelBalls")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HtfSteelBalls
{
	internal static class Assets
	{
		private static string dir;

		private static Mesh ballMesh;

		private static Texture2D ballTex;

		private static Sprite ballIcon;

		private static string Dir => dir ?? (dir = Path.Combine(Path.GetDirectoryName(typeof(Assets).Assembly.Location), "assets"));

		public static Mesh BallMesh => ballMesh ?? (ballMesh = LoadMesh("steelball.mesh"));

		public static Texture2D BallTexture => ballTex ?? (ballTex = LoadTexture("steelball.png"));

		public static Sprite BallIcon => ballIcon ?? (ballIcon = MakeBallIcon());

		private static Sprite MakeBallIcon()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (File.Exists(Path.Combine(Dir, "steelball_icon.png")))
			{
				Texture2D val = LoadTexture("steelball_icon.png");
				((Texture)val).filterMode = (FilterMode)0;
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
			return Sprite.Create(BallTexture, new Rect(755f, 155f, 118f, 118f), new Vector2(0.5f, 0.5f), 100f);
		}

		public static Mesh LoadMesh(string name)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(Path.Combine(Dir, name)));
			if (new string(binaryReader.ReadChars(4)) != "SBM1")
			{
				throw new InvalidDataException(name);
			}
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			Vector3[] array = (Vector3[])(object)new Vector3[num];
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				array2[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				array3[i] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			int[] array4 = new int[num2];
			for (int j = 0; j < num2; j++)
			{
				array4[j] = binaryReader.ReadInt32();
			}
			Mesh val = new Mesh
			{
				name = name,
				vertices = array,
				normals = array2,
				uv = array3,
				triangles = array4
			};
			val.RecalculateBounds();
			return val;
		}

		public static Texture2D LoadTexture(string name)
		{
			//IL_0004: 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_0011: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = name
			};
			byte[] array = File.ReadAllBytes(Path.Combine(Dir, name));
			typeof(ImageConversion).GetMethod("LoadImage", new Type[3]
			{
				typeof(Texture2D),
				typeof(byte[]),
				typeof(bool)
			}).Invoke(null, new object[3] { val, array, false });
			return val;
		}

		public static Material Retexture(Material from, Texture2D tex, float smoothness = 0.85f, float metallic = 0.3f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(from);
			string[] array = new string[3] { "_BaseMap", "_MainTex", "_Colors" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetTexture(text, (Texture)(object)tex);
				}
			}
			if (val.HasProperty("_Normal_Map"))
			{
				val.SetTexture("_Normal_Map", (Texture)null);
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", Color.white);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", Color.white);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			return val;
		}
	}
	internal class BallRunner : MonoBehaviour
	{
		private class Flight
		{
			public Melee melee;

			public Player holder;

			public int side;

			public bool charged;

			public bool local;

			public GameObject go;

			public MeshRenderer renderer;

			public Vector3 vel;

			public Transform target;

			public Vector3 aimLocal;

			public float time;

			public float trailTimer;

			public float sparkTimer;

			public float angle;

			public float startScale;

			public float scale;

			public int bounces;

			public bool returning;

			public bool returnPass;

			public Vector3 lastSpot;

			public Vector3 targetVel;

			public bool hasLast;

			public float homeDelay;

			public float scanTimer;

			public FxSprite aura;

			public FxSprite halo;

			public readonly HashSet<Object> hit = new HashSet<Object>();
		}

		private class Pending
		{
			public Melee melee;

			public int side;

			public bool charged;

			public Transform target;

			public Vector3 point;

			public float left;
		}

		private class Spin
		{
			public int stacks = 1;
		}

		public static BallRunner Instance;

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

		private readonly List<Pending> pending = new List<Pending>();

		private readonly Collider[] overlap = (Collider[])(object)new Collider[256];

		private static readonly FieldRef<CreatureManager, List<Creature>> aliveCreatures = AccessTools.FieldRefAccess<CreatureManager, List<Creature>>("_aliveCreatures");

		private static readonly FieldRef<Item, Collider> pickUpCollider = AccessTools.FieldRefAccess<Item, Collider>("_pickUpCollider");

		private static float forceChargeUntil;

		private static bool forceChargeHeld;

		private static Melee cancelThrow;

		private Melee cancelNext;

		private FileSystemWatcher watcher;

		private volatile bool configChanged;

		private float lastReload;

		private readonly HashSet<Transform> seen = new HashSet<Transform>();

		internal static Vector3? TestAimPoint;

		internal static float LastNpcHit = -1f;

		private static readonly FieldRef<Melee, SharpnessUpgrade[]> ladder = AccessTools.FieldRefAccess<Melee, SharpnessUpgrade[]>("_sharpnessUpgrades");

		private readonly Dictionary<Object, Spin> spins = new Dictionary<Object, Spin>();

		public static float MeshSize
		{
			get
			{
				//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_0012: Unknown result type (might be due to invalid IL or missing references)
				Bounds bounds = Assets.BallMesh.bounds;
				return Mathf.Max(0.0001f, ((Bounds)(ref bounds)).size.x);
			}
		}

		private static int WallMask => LayerMask.op_Implicit(GameInfo.LevelLayer) | LayerMask.op_Implicit(GameInfo.BoatLayer);

		private static int HitMask => LayerMask.op_Implicit(GameInfo.PlayerLayers) | LayerMask.op_Implicit(GameInfo.ItemPartLayer) | LayerMask.op_Implicit(GameInfo.ItemLayer) | LayerMask.op_Implicit(GameInfo.NpcLayer);

		public static bool ForceChargeHeld
		{
			get
			{
				return forceChargeHeld;
			}
			set
			{
				forceChargeHeld = value;
			}
		}

		private void Awake()
		{
			Instance = this;
		}

		private static float Speed(bool charged)
		{
			return Plugin.ThrowSpeed.Value * (charged ? 1.35f : 1f);
		}

		private static float HitRadius(bool charged)
		{
			if (!charged)
			{
				return 0.45f;
			}
			return 0.6f;
		}

		public bool InFlight(Melee m, int side)
		{
			foreach (Flight flight in flights)
			{
				if ((Object)(object)flight.melee == (Object)(object)m && flight.side == side)
				{
					return true;
				}
			}
			return false;
		}

		public bool Busy(Melee m, int side)
		{
			foreach (Flight flight in flights)
			{
				if ((Object)(object)flight.melee == (Object)(object)m && flight.side == side)
				{
					return true;
				}
			}
			foreach (Pending item in pending)
			{
				if ((Object)(object)item.melee == (Object)(object)m && item.side == side)
				{
					return true;
				}
			}
			return false;
		}

		public static bool ChargeHeld()
		{
			if (forceChargeHeld || Time.time < forceChargeUntil)
			{
				return true;
			}
			try
			{
				PlayerInput input = GameInfo.Input;
				InputAction val = (((Object)(object)input != (Object)null) ? input.actions["PlayerRightClick"] : null);
				return val != null && val.IsPressed();
			}
			catch
			{
				return false;
			}
		}

		private static Vector3 PlayerCenter(Player p)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)p.CamObject != (Object)null))
			{
				return ((Component)p).transform.position + Vector3.up;
			}
			return p.CamObject.position - Vector3.up * 0.45f;
		}

		private static bool Alive(Transform t, out Player player, out Item item)
		{
			player = null;
			item = null;
			if ((Object)(object)t == (Object)null)
			{
				return false;
			}
			player = ((Component)t).GetComponentInChildren<Player>();
			if ((Object)(object)player != (Object)null)
			{
				return !player.Dying.IsDead;
			}
			item = ((Component)t).GetComponent<Item>();
			Item obj = item;
			Creature val = (Creature)(object)((obj is Creature) ? obj : null);
			if (val != null)
			{
				return !val.IsDead;
			}
			return false;
		}

		private static bool FriendlyFire()
		{
			try
			{
				return ServerSettings.UseFriendlyFire;
			}
			catch
			{
				return true;
			}
		}

		private static Vector3 CreatureSpot(Creature c, Collider col = null)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			if ((Object)(object)col == (Object)null)
			{
				col = pickUpCollider.Invoke((Item)(object)c);
			}
			if (!((Object)(object)col != (Object)null) || !col.enabled)
			{
				return ((Component)c).transform.position;
			}
			Bounds bounds = col.bounds;
			return ((Bounds)(ref bounds)).center;
		}

		private void EachTarget(Player holder, Vector3 from, float range, Action<Transform, Vector3> visit)
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			seen.Clear();
			if (FriendlyFire())
			{
				foreach (Player alivePlayer in PlayerManager.AlivePlayers)
				{
					if ((Object)(object)alivePlayer != (Object)null && (Object)(object)alivePlayer != (Object)(object)holder && !alivePlayer.Dying.IsDead && (Object)(object)((NetworkBehaviour)alivePlayer).NetworkObject != (Object)null)
					{
						visit(((Component)((NetworkBehaviour)alivePlayer).NetworkObject).transform, PlayerCenter(alivePlayer));
					}
				}
			}
			CreatureManager instance = CreatureManager.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				List<Creature> list = aliveCreatures.Invoke(instance);
				if (list != null)
				{
					for (int i = 0; i < list.Count; i++)
					{
						if ((Object)(object)list[i] != (Object)null)
						{
							Vector3 val = ((Component)list[i]).transform.position - from;
							if (((Vector3)(ref val)).sqrMagnitude < range * range)
							{
								Creature(list[i], null);
							}
						}
					}
				}
			}
			int num = Physics.OverlapSphereNonAlloc(from, range, overlap, LayerMask.op_Implicit(GameInfo.ItemPartLayer) | LayerMask.op_Implicit(GameInfo.ItemLayer), (QueryTriggerInteraction)2);
			for (int j = 0; j < num; j++)
			{
				Item obj = ItemManager.Get(overlap[j]);
				Creature val2 = (Creature)(object)((obj is Creature) ? obj : null);
				if (val2 != null)
				{
					Creature(val2, overlap[j]);
				}
			}
			void Creature(Creature c, Collider col)
			{
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)c == (Object)null) && !c.IsDead && !((Object)(object)((Item)c).Holder != (Object)null) && !((Object)(object)((NetworkBehaviour)c).NetworkObject == (Object)null))
				{
					Transform transform = ((Component)((NetworkBehaviour)c).NetworkObject).transform;
					if (seen.Add(transform))
					{
						visit(transform, CreatureSpot(c, col));
					}
				}
			}
		}

		public static Transform PickTarget(Player holder, Transform cam, out Vector3 aimLocal)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			aimLocal = Vector3.zero;
			BallRunner instance = Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			Transform best = null;
			Vector3 bestSpot = default(Vector3);
			float bestScore = float.MaxValue;
			float range = Plugin.ThrowRange.Value;
			float cone = Plugin.TrackAngle.Value;
			instance.EachTarget(holder, cam.position, range, delegate(Transform t, Vector3 spot)
			{
				//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = spot - cam.position;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude > range) && !(magnitude < 0.3f))
				{
					float num = Vector3.Angle(cam.forward, val);
					if (!(num > cone) && !Physics.Raycast(cam.position, val / magnitude, magnitude - 0.3f, WallMask, (QueryTriggerInteraction)1))
					{
						float num2 = num * 2f + magnitude;
						if (num2 < bestScore)
						{
							bestScore = num2;
							best = t;
							bestSpot = spot;
						}
					}
				}
			});
			if ((Object)(object)best != (Object)null)
			{
				aimLocal = best.InverseTransformPoint(bestSpot);
			}
			return best;
		}

		private void Acquire(Flight f, Vector3 pos)
		{
			//IL_000e: 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_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)
			//IL_006b: 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)
			Vector3 dir = ((Vector3)(ref f.vel)).normalized;
			Transform best = null;
			Vector3 bestSpot = default(Vector3);
			float bestScore = float.MaxValue;
			float cone = Plugin.TrackAngle.Value + 8f;
			EachTarget(f.holder, pos, 18f, delegate(Transform t, Vector3 spot)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
				Object val = (Object)(((object)((Component)t).GetComponentInChildren<Player>()) ?? ((object)((Component)t).GetComponent<Item>()));
				if (!(val != (Object)null) || !f.hit.Contains(val))
				{
					Vector3 val2 = spot - pos;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					if (!(magnitude > 18f) && !(magnitude < 0.05f))
					{
						float num = Vector3.Angle(dir, val2);
						if (!(num > cone) && !Physics.Raycast(pos, val2 / magnitude, magnitude, WallMask, (QueryTriggerInteraction)1))
						{
							float num2 = num * 2f + magnitude;
							if (num2 < bestScore)
							{
								bestScore = num2;
								best = t;
								bestSpot = spot;
							}
						}
					}
				}
			});
			if (!((Object)(object)best == (Object)null))
			{
				f.target = best;
				f.aimLocal = best.InverseTransformPoint(bestSpot);
				f.hasLast = false;
			}
		}

		private static Vector3 CrosshairPoint(Player holder)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Transform camObject = holder.CamObject;
			float value = Plugin.ThrowRange.Value;
			int num = WallMask | LayerMask.op_Implicit(GameInfo.ItemPartLayer) | LayerMask.op_Implicit(GameInfo.NpcLayer);
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(camObject.position, camObject.forward, ref val, value, num, (QueryTriggerInteraction)1) || !(((RaycastHit)(ref val)).distance > 1f))
			{
				return camObject.position + camObject.forward * value;
			}
			return ((RaycastHit)(ref val)).point;
		}

		public void Throw(Melee m, int side, bool charged, Transform target, Vector3 point)
		{
			//IL_0031: 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)
			HandRig.StartThrow(m, side, charged);
			pending.Add(new Pending
			{
				melee = m,
				side = side,
				charged = charged,
				target = target,
				point = point,
				left = HandRig.ReleaseTime(charged)
			});
		}

		private void Launch(Pending p)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: 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_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			Melee melee = p.melee;
			Player val = (((Object)(object)melee != (Object)null) ? ((Item)melee).Holder : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			MeshRenderer val2 = SteelBallItem.HeldBall(melee, p.side);
			Transform val3 = SteelBallItem.hands.Invoke(melee)[p.side];
			Vector3 val4 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).transform.position : (((Object)(object)val3 != (Object)null) ? val3.position : val.CamObject.position));
			Flight flight = new Flight
			{
				melee = melee,
				holder = val,
				side = p.side,
				charged = p.charged,
				local = ((NetworkBehaviour)val).Owner.IsLocalClient,
				target = p.target,
				aimLocal = p.point
			};
			if (flight.local)
			{
				Vector3 aimLocal = Vector3.zero;
				Transform val5 = (TestAimPoint.HasValue ? null : PickTarget(val, val.CamObject, out aimLocal));
				if ((Object)(object)val5 != (Object)null)
				{
					flight.target = val5;
					flight.aimLocal = aimLocal;
				}
				else if (TestAimPoint.HasValue || (Object)(object)flight.target == (Object)null)
				{
					flight.target = null;
					flight.aimLocal = Vector3.zero;
				}
			}
			Vector3 val6 = (Vector3)(((Object)(object)flight.target != (Object)null) ? flight.target.TransformPoint(flight.aimLocal) : (((??)TestAimPoint) ?? CrosshairPoint(val)));
			Vector3 position = val.CamObject.position;
			Vector3 val7;
			if (Physics.Linecast(val4, val6, WallMask, (QueryTriggerInteraction)1) && !Physics.Linecast(position, val6, WallMask, (QueryTriggerInteraction)1))
			{
				val7 = val6 - position;
				val4 = position + ((Vector3)(ref val7)).normalized * 0.4f;
			}
			val7 = val6 - val4;
			Vector3 normalized = ((Vector3)(ref val7)).normalized;
			flight.vel = normalized * Speed(p.charged);
			if ((Object)(object)flight.target == (Object)null && !TestAimPoint.HasValue)
			{
				Acquire(flight, val4);
			}
			flight.go = new GameObject("HSB_ThrownBall");
			flight.go.transform.position = val4;
			flight.startScale = Plugin.HeldSize.Value / MeshSize;
			flight.scale = Plugin.ThrownSize.Value * (p.charged ? 1.4f : 1f) / MeshSize;
			flight.go.transform.localScale = Vector3.one * flight.startScale;
			flight.go.AddComponent<MeshFilter>().sharedMesh = Assets.BallMesh;
			flight.renderer = flight.go.AddComponent<MeshRenderer>();
			((Renderer)flight.renderer).sharedMaterial = SteelBallItem.BallMaterial;
			flight.aura = Fx.Spawn("fx_lines", val4, p.charged ? 0.4f : 0.26f, 24f, 0f, p.charged ? Fx.Gold : Fx.Pale);
			flight.aura.follow = flight.go.transform;
			flight.aura.rollSpeed = (p.charged ? (-1400f) : (-900f));
			if (p.charged)
			{
				flight.halo = Fx.Spawn("fx_halo", val4, 0.3f, 1f, 0f, new Color(1f, 1f, 1f, 0.55f));
				flight.halo.follow = flight.go.transform;
				Fx.GoldenAt(val4 + normalized * 1.6f, 0.45f, 0.5f);
				Fx.BurstAt(val4 + normalized * 1.2f, 0.2f, gold: true);
			}
			flights.Add(flight);
		}

		private void Start()
		{
			try
			{
				string configFilePath = ((BaseUnityPlugin)Plugin.Instance).Config.ConfigFilePath;
				watcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath))
				{
					NotifyFilter = (NotifyFilters.Size | NotifyFilters.LastWrite),
					EnableRaisingEvents = true
				};
				watcher.Changed += delegate
				{
					configChanged = true;
				};
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Config watcher: " + ex.Message));
			}
		}

		private void Update()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (configChanged && Time.unscaledTime - lastReload > 0.5f)
			{
				configChanged = false;
				lastReload = Time.unscaledTime;
				try
				{
					((BaseUnityPlugin)Plugin.Instance).Config.Reload();
					Plugin.Log.LogInfo((object)"Steel balls: config reloaded");
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Config reload: " + ex.Message));
				}
			}
			if ((Object)(object)cancelNext != (Object)null)
			{
				try
				{
					((Item)cancelNext).PrimaryInputCancel(default(CallbackContext));
				}
				catch
				{
				}
				cancelNext = null;
			}
			if ((Object)(object)cancelThrow != (Object)null)
			{
				cancelNext = cancelThrow;
				cancelThrow = null;
			}
			if (Input.GetKeyDown(Plugin.GiveKey.Value))
			{
				Give();
			}
			for (int num = this.pending.Count - 1; num >= 0; num--)
			{
				Pending pending = this.pending[num];
				pending.left -= Time.deltaTime;
				if (!(pending.left > 0f))
				{
					this.pending.RemoveAt(num);
					try
					{
						Launch(pending);
					}
					catch (Exception ex2)
					{
						Plugin.Log.LogError((object)("Steel ball launch: " + ex2));
					}
				}
			}
			for (int num2 = flights.Count - 1; num2 >= 0; num2--)
			{
				bool flag = false;
				try
				{
					flag = UpdateFlight(flights[num2]);
				}
				catch (Exception ex3)
				{
					Plugin.Log.LogError((object)("Steel ball flight: " + ex3));
				}
				if (!flag)
				{
					End(flights[num2]);
					flights.RemoveAt(num2);
				}
			}
		}

		private void LateUpdate()
		{
			try
			{
				HandRig.CleanAuras();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Steel ball auras: " + ex));
			}
		}

		private void TestKeys()
		{
			Melee val = (Melee)(((Object)(object)Player.LocalPlayer != (Object)null && (Object)(object)Player.LocalPlayer.Holding != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			if (!SteelBallItem.Is((Item)(object)val))
			{
				val = null;
			}
			if (Input.GetKeyDown((KeyCode)286))
			{
				forceChargeHeld = !forceChargeHeld;
				Plugin.Log.LogInfo((object)("Steel balls test: charge held " + forceChargeHeld));
			}
			if ((Object)(object)val == (Object)null)
			{
				if (Input.GetKeyDown((KeyCode)291))
				{
					Plugin.Log.LogInfo((object)"Steel balls report: not holding the balls");
				}
				return;
			}
			bool keyDown = Input.GetKeyDown((KeyCode)292);
			if (Input.GetKeyDown((KeyCode)287) || keyDown)
			{
				TestThrow(val, keyDown);
			}
			if (Input.GetKeyDown((KeyCode)291))
			{
				Report(val);
			}
		}

		internal static void TestThrow(Melee m, bool golden)
		{
			//IL_0016: 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)
			if (golden)
			{
				forceChargeUntil = Time.time + 0.3f;
			}
			((Item)m).PrimaryInput(default(CallbackContext));
			cancelThrow = m;
			Plugin.Log.LogInfo((object)("Steel balls test: throw" + (golden ? " (Golden Spin)" : "")));
		}

		internal void LogFlights()
		{
			//IL_006f: 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_0074: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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)
			Camera viewCam = Plugin.ViewCam;
			StringBuilder stringBuilder = new StringBuilder($"Steel balls flights: {flights.Count} flying, {pending.Count} pending");
			foreach (Flight flight in flights)
			{
				Vector3 val = (((Object)(object)flight.go != (Object)null) ? flight.go.transform.position : Vector3.zero);
				Vector3 val2 = (((Object)(object)viewCam != (Object)null) ? ((Component)viewCam).transform.InverseTransformPoint(val) : val);
				stringBuilder.AppendLine().Append(string.Format("  side {0} charged {1} t {2:F2} cam-local ({3:F2},{4:F2},{5:F2}) speed {6:F1} target {7} returning {8} bounces {9} hits {10}", flight.side, flight.charged, flight.time, val2.x, val2.y, val2.z, ((Vector3)(ref flight.vel)).magnitude, ((Object)(object)flight.target != (Object)null) ? ((Object)flight.target).name : "-", flight.returning, flight.bounces, flight.hit.Count));
			}
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}

		private static float ScreenAspect(Camera cam, MeshRenderer ball)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cam == (Object)null)
			{
				return 0f;
			}
			MeshFilter component = ((Component)ball).GetComponent<MeshFilter>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null)
			{
				return 0f;
			}
			float num = float.MaxValue;
			float num2 = float.MinValue;
			float num3 = float.MaxValue;
			float num4 = float.MinValue;
			Vector3[] vertices = component.sharedMesh.vertices;
			foreach (Vector3 val in vertices)
			{
				Vector3 val2 = cam.WorldToScreenPoint(((Component)ball).transform.TransformPoint(val));
				num = Mathf.Min(num, val2.x);
				num2 = Mathf.Max(num2, val2.x);
				num3 = Mathf.Min(num3, val2.y);
				num4 = Mathf.Max(num4, val2.y);
			}
			return (num2 - num) / Mathf.Max(0.001f, num4 - num3);
		}

		internal static void Report(Melee m)
		{
			//IL_00c1: 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_00ca: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			Player holder = ((Item)m).Holder;
			Camera val = (((Object)(object)holder.CurCam != (Object)null) ? holder.CurCam : Camera.main);
			StringBuilder stringBuilder = new StringBuilder(string.Format("Steel balls report: cam {0} fov {1:F0}", ((Object)(object)val != (Object)null) ? ((Object)val).name : "-", ((Object)(object)val != (Object)null) ? val.fieldOfView : 0f));
			Transform[] array = SteelBallItem.hands.Invoke(m);
			for (int i = 0; i < 2; i++)
			{
				Transform val2 = array[i];
				MeshRenderer val3 = SteelBallItem.HeldBall(m, i);
				if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
				{
					stringBuilder.AppendLine().Append($"  side {i}: missing");
					continue;
				}
				Vector3 val4 = val2.rotation * ((i == 0) ? Vector3.back : Vector3.forward);
				Vector3 val5;
				Vector3 val6;
				if (!((Object)(object)val != (Object)null))
				{
					val5 = Vector3.zero;
				}
				else
				{
					val6 = ((Component)val).transform.position - ((Component)val3).transform.position;
					val5 = ((Vector3)(ref val6)).normalized;
				}
				Vector3 val7 = val5;
				Vector3 val8 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.InverseTransformPoint(val2.position) : val2.position);
				Vector3 val9 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.InverseTransformPoint(((Component)val3).transform.position) : ((Component)val3).transform.position);
				Vector3 val10 = (((Object)(object)val != (Object)null) ? val.WorldToViewportPoint(((Component)val3).transform.position) : Vector3.zero);
				Material sharedMaterial = ((Renderer)val3).sharedMaterial;
				StringBuilder stringBuilder2 = stringBuilder.AppendLine().Append($"  side {i}: hand cam-local ({val8.x:F3},{val8.y:F3},{val8.z:F3}) ball ({val9.x:F3},{val9.y:F3},{val9.z:F3}) viewport ({val10.x:F2},{val10.y:F2},{val10.z:F2})");
				object arg = Vector3.Dot(val4, val7);
				object arg2 = val2.lossyScale.x;
				Bounds bounds = ((Renderer)val3).bounds;
				stringBuilder2.Append($" palm.toCam {arg:F2} handScale {arg2:F4} ballSize {((Bounds)(ref bounds)).size.x:F3}").Append($" ballLossy ({((Component)val3).transform.lossyScale.x:F4},{((Component)val3).transform.lossyScale.y:F4},{((Component)val3).transform.lossyScale.z:F4}) handLossy ({val2.lossyScale.x:F4},{val2.lossyScale.y:F4},{val2.lossyScale.z:F4})").Append($" onScreen w/h {ScreenAspect(val, val3):F2} offAxis {(((Object)(object)val != (Object)null) ? Vector3.Angle(((Component)val).transform.forward, ((Component)val3).transform.position - ((Component)val).transform.position) : 0f):F0}deg")
					.Append($" enabled {((Renderer)val3).enabled} visible {((Renderer)val3).isVisible} layer {LayerMask.LayerToName(((Component)val3).gameObject.layer)}")
					.Append(" mat " + (((Object)(object)sharedMaterial != (Object)null) ? ((Object)sharedMaterial).name : "-") + " colors " + (((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_Colors") && (Object)(object)sharedMaterial.GetTexture("_Colors") != (Object)null) ? ((Object)sharedMaterial.GetTexture("_Colors")).name : "-"));
				string text = ((i == 0) ? "r_" : "l_");
				string[] array2 = new string[5] { "index", "middle", "ring", "pinky", "thumb" };
				foreach (string text2 in array2)
				{
					Transform val11 = val2.Find(text + text2 + "_low/" + text + text2 + "_mid/" + text + text2 + "_tip/" + text + text2 + "_tip_end");
					if ((Object)(object)val11 != (Object)null)
					{
						Vector3 val12 = (((Object)(object)val != (Object)null) ? val.WorldToViewportPoint(val11.position) : Vector3.zero);
						object[] obj = new object[4] { text2, null, null, null };
						val6 = val11.position - ((Component)val3).transform.position;
						obj[1] = ((Vector3)(ref val6)).magnitude;
						obj[2] = val12.x;
						obj[3] = val12.y;
						stringBuilder.Append(string.Format(" {0} {1:F3}@({2:F2},{3:F2})", obj));
					}
				}
			}
			MeshRenderer val13 = SteelBallItem.HeldBall(m, 0);
			int num = (((Object)(object)val13 != (Object)null) ? ((Component)val13).gameObject.layer : 0);
			Camera[] allCameras = Camera.allCameras;
			foreach (Camera val14 in allCameras)
			{
				stringBuilder.AppendLine().Append($"  camera {((Object)val14).name} depth {val14.depth} fov {val14.fieldOfView:F0} enabled {((Behaviour)val14).enabled} seesBall {(val14.cullingMask & (1 << num)) != 0}");
			}
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}

		internal static void Give()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.LocalPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)Server.Instance == (Object)null) && !((Object)(object)SteelBallItem.Template == (Object)null))
			{
				Transform camObject = localPlayer.CamObject;
				Server.Instance.BuyItem(SteelBallItem.Id, localPlayer, localPlayer.Holding.HeldItem, camObject.position + camObject.forward * 0.5f, camObject.rotation, true);
				Plugin.Log.LogInfo((object)"Steel balls: asked the host for a pair");
			}
		}

		private Vector3? HandSpot(Flight f)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Melee melee = f.melee;
			if ((Object)(object)melee != (Object)null && (Object)(object)((Item)melee).Holder == (Object)(object)f.holder && ((Component)melee).gameObject.activeInHierarchy)
			{
				MeshRenderer val = SteelBallItem.HeldBall(melee, f.side);
				if ((Object)(object)val != (Object)null)
				{
					return ((Component)val).transform.position;
				}
			}
			if ((Object)(object)f.holder != (Object)null && (Object)(object)f.holder.CamObject != (Object)null)
			{
				return f.holder.CamObject.position - Vector3.up * 0.3f;
			}
			return null;
		}

		private bool UpdateFlight(Flight f)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_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_025e: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: 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_01ed: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: 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_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)f.go == (Object)null)
			{
				return false;
			}
			float deltaTime = Time.deltaTime;
			f.time += deltaTime;
			Vector3 position = f.go.transform.position;
			float num = Speed(f.charged);
			Vector3 val4;
			if (f.returning)
			{
				Vector3? val = HandSpot(f);
				if (!val.HasValue)
				{
					return false;
				}
				Vector3 val2 = val.Value - position;
				if (((Vector3)(ref val2)).magnitude < 0.6f || f.time > 8f)
				{
					return false;
				}
				f.vel = Vector3.Lerp(f.vel, ((Vector3)(ref val2)).normalized * num * 1.2f, deltaTime * 8f);
				if (((Vector3)(ref val2)).magnitude < num * 1.2f * deltaTime)
				{
					f.go.transform.position = val.Value;
					return false;
				}
			}
			else
			{
				if (f.homeDelay > 0f)
				{
					f.homeDelay -= deltaTime;
				}
				if (Alive(f.target, out var _, out var _))
				{
					Vector3 val3 = f.target.TransformPoint(f.aimLocal);
					if (f.hasLast && deltaTime > 0f)
					{
						f.targetVel = Vector3.Lerp(f.targetVel, (val3 - f.lastSpot) / deltaTime, 0.35f);
					}
					else
					{
						f.targetVel = Vector3.zero;
					}
					f.lastSpot = val3;
					f.hasLast = true;
					val4 = val3 - position;
					float magnitude = ((Vector3)(ref val4)).magnitude;
					Vector3 val5 = val3 + Vector3.ClampMagnitude(f.targetVel * (magnitude / num), 6f);
					float num2 = Mathf.Lerp(40f, 10f, Mathf.Clamp01(magnitude / 14f)) * Plugin.TrackTurn.Value;
					if (f.homeDelay <= 0f)
					{
						Vector3 vel = f.vel;
						val4 = val5 - position;
						f.vel = Vector3.RotateTowards(vel, ((Vector3)(ref val4)).normalized * num, deltaTime * num2, deltaTime * num * 4f);
					}
				}
				else
				{
					f.target = null;
					f.scanTimer -= deltaTime;
					if (f.scanTimer <= 0f && f.homeDelay <= 0f)
					{
						f.scanTimer = 0.06f;
						Acquire(f, position);
					}
				}
				if (f.time > (((Object)(object)f.target != (Object)null) ? 1.6f : 1f) * Plugin.ThrowRange.Value / num)
				{
					f.returning = true;
				}
			}
			Vector3 val6 = position;
			Vector3 val7 = f.vel * deltaTime;
			RaycastHit val8 = default(RaycastHit);
			if (!f.returning && Physics.Raycast(position, ((Vector3)(ref val7)).normalized, ref val8, ((Vector3)(ref val7)).magnitude + 0.06f, WallMask, (QueryTriggerInteraction)1))
			{
				f.vel = Vector3.Reflect(f.vel, ((RaycastHit)(ref val8)).normal) * 0.85f;
				position = ((RaycastHit)(ref val8)).point + ((RaycastHit)(ref val8)).normal * 0.07f;
				if (++f.bounces > 2)
				{
					f.returning = true;
				}
				f.homeDelay = 0.12f;
				f.hasLast = false;
				Fx.BurstAt(((RaycastHit)(ref val8)).point + ((RaycastHit)(ref val8)).normal * 0.05f, f.charged ? 0.4f : 0.24f, f.charged);
				Fx.WaveAt(((RaycastHit)(ref val8)).point + ((RaycastHit)(ref val8)).normal * 0.05f, f.charged ? 0.65f : 0.4f, f.charged ? Fx.Gold : Fx.Pale);
				Fx.PlayBounce(((RaycastHit)(ref val8)).point);
			}
			else
			{
				position += val7;
			}
			f.go.transform.position = position;
			f.go.transform.localScale = Vector3.one * Mathf.Lerp(f.startScale, f.scale, Mathf.Clamp01(f.time / 0.2f));
			f.angle += (f.charged ? 2600f : 1600f) * deltaTime;
			if (((Vector3)(ref f.vel)).sqrMagnitude > 0.0001f)
			{
				f.go.transform.rotation = Quaternion.LookRotation(f.vel) * Quaternion.Euler(0f, 0f, f.angle);
			}
			f.trailTimer -= deltaTime;
			if (f.trailTimer <= 0f)
			{
				f.trailTimer = (f.charged ? 0.03f : 0.05f);
				FxSprite fxSprite = Fx.Spawn("fx_lines", position, f.charged ? 0.36f : 0.22f, 24f, f.charged ? 0.25f : 0.16f, (Color)(f.charged ? Fx.Gold : new Color(Fx.Pale.r, Fx.Pale.g, Fx.Pale.b, 0.7f)));
				fxSprite.endScale = 1.6f;
				fxSprite.roll = Random.Range(0f, 360f);
				fxSprite.rollSpeed = -900f;
			}
			if (f.charged)
			{
				f.sparkTimer -= deltaTime;
				if (f.sparkTimer <= 0f)
				{
					f.sparkTimer = 0.07f;
					FxSprite fxSprite2 = Fx.Spawn("fx_spark", position, 0.05f, 12f, 0.3f, Fx.Gold);
					val4 = Vector3.Cross(((Vector3)(ref f.vel)).normalized, Random.onUnitSphere);
					fxSprite2.velocity = ((Vector3)(ref val4)).normalized * 3f - f.vel * 0.1f;
					fxSprite2.drag = 3f;
				}
			}
			if (f.returning && !f.returnPass)
			{
				f.returnPass = true;
				f.hit.Clear();
			}
			HitAlong(f, val6, position);
			return true;
		}

		private void HitAlong(Flight f, Vector3 from, Vector3 to)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			float num = HitRadius(f.charged);
			int num2 = Physics.OverlapCapsuleNonAlloc(from, to, num, overlap, HitMask, (QueryTriggerInteraction)2);
			Vector3 normalized = ((Vector3)(ref f.vel)).normalized;
			for (int i = 0; i < num2; i++)
			{
				Collider val = overlap[i];
				Vector3 val2 = val.ClosestPoint(from);
				Player playerFromBodyPart = PlayerManager.GetPlayerFromBodyPart(((Component)val).transform);
				if ((Object)(object)playerFromBodyPart != (Object)null)
				{
					if ((Object)(object)playerFromBodyPart != (Object)(object)f.holder && !playerFromBodyPart.Dying.IsDead)
					{
						Struck(f, playerFromBodyPart, null, ((Component)val).transform, val2);
					}
				}
				else if (((Component)val).CompareTag("NPC") || ((Object)(object)val.attachedRigidbody != (Object)null && ((Component)val.attachedRigidbody).CompareTag("NPC")))
				{
					NPC componentInParent = ((Component)val).GetComponentInParent<NPC>();
					if (f.hit.Add((Object)(((Object)(object)componentInParent != (Object)null) ? ((object)componentInParent) : ((object)((Component)val).transform))))
					{
						LastNpcHit = Time.time;
						DazedUtils.PlayDeadPlayerHitEffects(val2, normalized, Damage(f), f.holder, true);
						Fx.PlayBounce(val2, 0.8f);
					}
				}
				else
				{
					Item val3 = ItemManager.Get(val);
					if ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)f.melee && (Object)(object)val3.Holder == (Object)null)
					{
						Struck(f, null, val3, ((Component)val).transform, val2);
					}
				}
			}
			if ((Object)(object)f.target != (Object)null && Alive(f.target, out var player, out var item))
			{
				Vector3 val4 = f.target.TransformPoint(f.aimLocal);
				if (SegmentDistance(from, to, val4) < num + 0.1f)
				{
					Struck(f, player, item, f.target, val4);
				}
			}
		}

		private static float SegmentDistance(Vector3 a, Vector3 b, Vector3 p)
		{
			//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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / Mathf.Max(1E-08f, ((Vector3)(ref val)).sqrMagnitude));
			Vector3 val2 = a + val * num - p;
			return ((Vector3)(ref val2)).magnitude;
		}

		private void Struck(Flight f, Player player, Item item, Transform part, Vector3 point)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (!f.hit.Add((Object)(((Object)(object)player != (Object)null) ? ((object)player) : ((object)item))))
			{
				return;
			}
			Vector3 normalized = ((Vector3)(ref f.vel)).normalized;
			if (f.local && (Object)(object)f.holder != (Object)null)
			{
				int num = Damage(f);
				Vector3 val = normalized * (f.charged ? 12f : 6f);
				if ((Object)(object)player != (Object)null)
				{
					player.Vitals.LocalHit(point, normalized, f.holder, num, true, val * 50f, false, false);
				}
				else
				{
					item.LocalHit(part, point, normalized, f.holder, num, false, val, false, false, false);
				}
			}
			if (f.charged)
			{
				StartSpin(f, player, (Creature)(object)((item is Creature) ? item : null), part);
			}
			Fx.BurstAt(point, f.charged ? 0.8f : 0.45f, f.charged);
			Fx.WaveAt(point, f.charged ? 1.1f : 0.65f, f.charged ? Fx.Gold : Fx.Pale);
			if (f.charged)
			{
				Fx.GoldenAt(point, 0.95f, 0.6f);
			}
			Fx.PlayBounce(point, 0.8f);
			if (!((Object)(object)f.target != (Object)null))
			{
				return;
			}
			bool num2;
			if (!((Object)(object)player != (Object)null))
			{
				if (!((Object)(object)item != (Object)null) || !((Object)(object)((NetworkBehaviour)item).NetworkObject != (Object)null))
				{
					return;
				}
				num2 = (Object)(object)f.target == (Object)(object)((Component)((NetworkBehaviour)item).NetworkObject).transform;
			}
			else
			{
				num2 = (Object)(object)f.target == (Object)(object)((Component)((NetworkBehaviour)player).NetworkObject).transform;
			}
			if (num2)
			{
				f.target = null;
				f.returning = !f.charged && !Plugin.Pierce.Value;
			}
		}

		private static int Damage(Flight f)
		{
			return WithSharpness(f.charged ? Plugin.ChargedDamage.Value : Plugin.ThrowDamage.Value, f.melee, f.charged ? 2f : 1f);
		}

		private static int Bonus(Melee m, int level)
		{
			SharpnessUpgrade[] array = (((Object)(object)m != (Object)null) ? ladder.Invoke(m) : null);
			if (array == null || array.Length == 0 || level <= 0)
			{
				return 0;
			}
			return Mathf.Max(0, array[Mathf.Min(level, array.Length - 1)].Damage - array[0].Damage);
		}

		private static int Capped(long v)
		{
			return (int)Math.Min(v, 1000000000L);
		}

		internal static int WithSharpness(int baseDamage, Melee m, float share, int level = -1)
		{
			return Capped(baseDamage + (long)((double)Bonus(m, (level >= 0) ? level : (((Object)(object)m != (Object)null) ? m.SharpnessIndex : 0)) * (double)share));
		}

		private void StartSpin(Flight f, Player player, Creature creature, Transform part)
		{
			Object val = (Object)(((Object)(object)player != (Object)null) ? ((object)player) : ((object)creature));
			if (!(val == (Object)null) && (!((Object)(object)player != (Object)null) || FriendlyFire()))
			{
				if (spins.TryGetValue(val, out var value))
				{
					value.stacks++;
					return;
				}
				value = new Spin();
				spins[val] = value;
				((MonoBehaviour)this).StartCoroutine(GoldenSpin(val, value, f.holder, f.local, f.melee, player, creature, part));
			}
		}

		private IEnumerator GoldenSpin(Object key, Spin s, Player thrower, bool local, Melee balls, Player player, Creature creature, Transform part)
		{
			Collider val = default(Collider);
			float num;
			Vector3 val2;
			if (!((Object)(object)creature != (Object)null) || !((Object)(object)part != (Object)null) || !((Component)part).TryGetComponent<Collider>(ref val))
			{
				num = 1f;
			}
			else
			{
				Bounds bounds = val.bounds;
				val2 = ((Bounds)(ref bounds)).size;
				num = ((Vector3)(ref val2)).magnitude * 1.1f;
			}
			float size = Mathf.Clamp(num, 0.6f, 3f);
			FxSprite glow = Fx.Spawn("fx_halo", At(), size, 1f, 0f, new Color(1f, 1f, 1f, 0.45f));
			FxSprite mark = Fx.Spawn("fx_lines", At(), size * 1.1f, 20f, 0f, Fx.Gold);
			mark.rollSpeed = -720f;
			float next = 0.5f;
			while (Going())
			{
				Vector3 val3 = At();
				if ((Object)(object)glow != (Object)null)
				{
					((Component)glow).transform.position = val3;
				}
				if ((Object)(object)mark != (Object)null)
				{
					((Component)mark).transform.position = val3;
				}
				next -= Time.deltaTime;
				if (next <= 0f)
				{
					next = 0.5f;
					int num2 = Capped((long)WithSharpness(Plugin.GoldenSpinTick.Value, balls, 0.5f) * (long)s.stacks);
					if (local && (Object)(object)thrower != (Object)null)
					{
						if ((Object)(object)player != (Object)null)
						{
							player.Vitals.LocalHit(val3, Vector3.up, thrower, num2, true, Vector3.zero, false, false);
						}
						else
						{
							Creature obj = creature;
							Transform obj2 = (((Object)(object)part != (Object)null) ? part : ((Component)creature).transform);
							Vector3 up = Vector3.up;
							val2 = default(Vector3);
							((Item)obj).LocalHit(obj2, val3, up, thrower, num2, false, val2, false, false, false);
						}
					}
					Fx.Sparks(val3, 4, 2f);
					Fx.WaveAt(val3, size * 1.1f, Fx.Gold);
				}
				yield return null;
			}
			if ((Object)(object)glow != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)glow).gameObject);
			}
			if ((Object)(object)mark != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)mark).gameObject);
			}
			spins.Remove(key);
			Vector3 At()
			{
				//IL_0021: 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)
				if (!((Object)(object)player != (Object)null))
				{
					return CreatureSpot(creature);
				}
				return PlayerCenter(player);
			}
			bool Going()
			{
				if (!((Object)(object)player != (Object)null))
				{
					if ((Object)(object)creature != (Object)null)
					{
						return !creature.IsDead;
					}
					return false;
				}
				return !player.Dying.IsDead;
			}
		}

		private void End(Flight f)
		{
			if ((Object)(object)f.aura != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)f.aura).gameObject);
			}
			if ((Object)(object)f.halo != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)f.halo).gameObject);
			}
			if ((Object)(object)f.go != (Object)null)
			{
				Object.Destroy((Object)(object)f.go);
			}
		}
	}
	internal static class Fx
	{
		public const string Burst = "fx_burst";

		public const string Spark = "fx_spark";

		public const string Halo = "fx_halo";

		public const string Lines = "fx_lines";

		public const string Golden = "fx_golden";

		public const string Wave = "fx_wave";

		private static readonly Dictionary<string, Sprite[]> sheets = new Dictionary<string, Sprite[]>();

		private static Material material;

		private static AudioClip bounce;

		public static bool Visible = true;

		public static readonly Color Gold = Color.white;

		public static readonly Color Pale = new Color(0.8f, 0.88f, 1f, 1f);

		private static readonly Dictionary<string, AudioClip> sounds = new Dictionary<string, AudioClip>();

		private static Material Material
		{
			get
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				if ((Object)(object)material != (Object)null)
				{
					return material;
				}
				Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Universal Render Pipeline/2D/Sprite-Unlit-Default");
				Plugin.Log.LogInfo((object)("Fx shader: " + (((Object)(object)val != (Object)null) ? ((Object)val).name : "(sprite renderer default)")));
				if ((Object)(object)val != (Object)null)
				{
					material = new Material(val);
				}
				return material;
			}
		}

		public static Sprite[] Frames(string sheet)
		{
			//IL_005e: 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)
			if (sheets.TryGetValue(sheet, out var value))
			{
				return value;
			}
			Texture2D val = Assets.LoadTexture(sheet + ".png");
			((Texture)val).filterMode = (FilterMode)0;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			int height = ((Texture)val).height;
			int num = ((Texture)val).width / height;
			value = (Sprite[])(object)new Sprite[num];
			for (int i = 0; i < num; i++)
			{
				value[i] = Sprite.Create(val, new Rect((float)(i * height), 0f, (float)height, (float)height), new Vector2(0.5f, 0.5f), (float)height, 0u, (SpriteMeshType)0);
			}
			sheets[sheet] = value;
			return value;
		}

		public static FxSprite Spawn(string sheet, Vector3 pos, float size, float fps, float life, Color color, Transform parent = null, Renderer layerFrom = null, bool loop = true)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("HSB_Fx_" + sheet);
			if ((Object)(object)parent != (Object)null)
			{
				val.transform.SetParent(parent, false);
			}
			val.transform.position = pos;
			SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
			if ((Object)(object)Material != (Object)null)
			{
				((Renderer)val2).sharedMaterial = Material;
			}
			val2.color = color;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			if ((Object)(object)layerFrom != (Object)null)
			{
				val.layer = ((Component)layerFrom).gameObject.layer;
				((Renderer)val2).renderingLayerMask = layerFrom.renderingLayerMask;
			}
			FxSprite fxSprite = val.AddComponent<FxSprite>();
			fxSprite.Init(Frames(sheet), size, fps, life, loop);
			return fxSprite;
		}

		public static void BurstAt(Vector3 pos, float size, bool gold, Renderer layerFrom = null)
		{
			//IL_0005: 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_0014: 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)
			Spawn("fx_burst", pos, size, 18f, 1f / 3f, gold ? Gold : Pale, null, layerFrom, loop: false).roll = Random.Range(0f, 360f);
			Sparks(pos, gold ? 6 : 3, size * 4f, layerFrom);
		}

		public static FxSprite WaveAt(Vector3 pos, float size, Color color, Renderer layerFrom = null)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Spawn("fx_wave", pos, size, 20f, 0.4f, color, null, layerFrom, loop: false);
		}

		public static FxSprite GoldenAt(Vector3 pos, float size, float life, Renderer layerFrom = null)
		{
			//IL_0005: 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)
			FxSprite fxSprite = Spawn("fx_golden", pos, size, 24f, life, Gold, null, layerFrom);
			fxSprite.loopFrom = 6;
			fxSprite.roll = Random.Range(-25f, 25f);
			return fxSprite;
		}

		public static void Sparks(Vector3 pos, int count, float speed, Renderer layerFrom = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < count; i++)
			{
				FxSprite fxSprite = Spawn("fx_spark", pos, 0.05f, 12f, Random.Range(0.2f, 0.4f), Gold, null, layerFrom);
				fxSprite.velocity = Random.onUnitSphere * speed * Random.Range(0.4f, 1f);
				fxSprite.drag = 4f;
			}
		}

		public static void PlayBounce(Vector3 pos, float volume = 0.6f)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (bounce == null)
			{
				bounce = LoadWav("ball_bounce.wav");
			}
			if ((Object)(object)bounce != (Object)null)
			{
				AudioSource.PlayClipAtPoint(bounce, pos, volume * Plugin.Volume.Value);
			}
		}

		public static AudioClip LoadSound(string name)
		{
			return LoadWav(name);
		}

		public static AudioClip Clip(string name)
		{
			if (!sounds.TryGetValue(name, out var value))
			{
				try
				{
					value = (File.Exists(Path.Combine(Path.GetDirectoryName(typeof(Fx).Assembly.Location), "assets", name + ".wav")) ? LoadWav(name + ".wav") : null);
				}
				catch
				{
					value = null;
				}
				sounds[name] = value;
			}
			return value;
		}

		public static float Sound(string name, float volume = 0.6f, string fallback = null)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			AudioClip val = Clip(name) ?? ((fallback != null) ? Clip(fallback) : null);
			Camera viewCam = Plugin.ViewCam;
			if ((Object)(object)val == (Object)null || (Object)(object)viewCam == (Object)null)
			{
				return 0f;
			}
			AudioSource.PlayClipAtPoint(val, ((Component)viewCam).transform.position, volume * Plugin.Volume.Value);
			return val.length;
		}

		private static AudioClip LoadWav(string name)
		{
			try
			{
				byte[] array = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(typeof(Fx).Assembly.Location), "assets", name));
				int num = BitConverter.ToInt16(array, 22);
				int num2 = BitConverter.ToInt32(array, 24);
				int i;
				for (i = 12; i + 8 <= array.Length && Encoding.ASCII.GetString(array, i, 4) != "data"; i += 8 + BitConverter.ToInt32(array, i + 4))
				{
				}
				int num3 = BitConverter.ToInt32(array, i + 4) / 2;
				float[] array2 = new float[num3];
				for (int j = 0; j < num3; j++)
				{
					array2[j] = (float)BitConverter.ToInt16(array, i + 8 + j * 2) / 32768f;
				}
				AudioClip val = AudioClip.Create(name, num3 / num, num, num2, false);
				typeof(AudioClip).GetMethod("SetData", new Type[2]
				{
					typeof(float[]),
					typeof(int)
				}).Invoke(val, new object[2] { array2, 0 });
				return val;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Sound " + name + ": " + ex.Message));
				return null;
			}
		}
	}
	internal class FxSprite : MonoBehaviour
	{
		private Sprite[] frames;

		private SpriteRenderer sr;

		private float fps;

		private float life;

		private float age;

		private float baseSize;

		private bool loop;

		private Color baseColor;

		public float roll;

		public float rollSpeed;

		public Vector3 velocity;

		public float drag;

		public float endScale = 1f;

		public bool fade = true;

		public Transform follow;

		public Vector3 followOffset;

		public int loopFrom;

		public bool billboard = true;

		public float towardCamera;

		public float Size
		{
			get
			{
				return baseSize;
			}
			set
			{
				baseSize = value;
			}
		}

		public float Fps
		{
			get
			{
				return fps;
			}
			set
			{
				fps = value;
			}
		}

		public Color Color
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return baseColor;
			}
			set
			{
				//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)
				baseColor = value;
			}
		}

		public void Init(Sprite[] f, float size, float fps, float life, bool loop)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			frames = f;
			this.fps = fps;
			this.life = life;
			this.loop = loop;
			baseSize = size;
			sr = ((Component)this).GetComponent<SpriteRenderer>();
			baseColor = sr.color;
			sr.sprite = frames[0];
			((Component)this).transform.localScale = Vector3.one * size;
		}

		private void LateUpdate()
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)sr).enabled = Fx.Visible;
			float deltaTime = Time.deltaTime;
			age += deltaTime;
			if (life > 0f && age >= life)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			int num = (int)(age * fps);
			int num2 = frames.Length;
			sr.sprite = frames[(!loop) ? Mathf.Min(num, num2 - 1) : ((num < num2) ? num : (loopFrom + (num - loopFrom) % Mathf.Max(1, num2 - loopFrom)))];
			float num3 = ((life > 0f) ? (age / life) : 0f);
			Camera viewCam = Plugin.ViewCam;
			if ((Object)(object)follow != (Object)null)
			{
				Vector3 val = follow.position + followOffset;
				if (towardCamera > 0f && (Object)(object)viewCam != (Object)null)
				{
					Vector3 val2 = val;
					Vector3 val3 = ((Component)viewCam).transform.position - val;
					val = val2 + ((Vector3)(ref val3)).normalized * towardCamera;
				}
				((Component)this).transform.position = val;
			}
			else if (velocity != Vector3.zero)
			{
				Transform transform = ((Component)this).transform;
				transform.position += velocity * deltaTime;
				velocity *= Mathf.Max(0f, 1f - drag * deltaTime);
			}
			((Component)this).transform.localScale = Vector3.one * (baseSize * Mathf.Lerp(1f, endScale, num3));
			Color color = baseColor;
			if (fade && life > 0f)
			{
				color.a *= 1f - num3 * num3;
			}
			sr.color = color;
			roll += rollSpeed * deltaTime;
			Camera viewCam2 = Plugin.ViewCam;
			if ((Object)(object)viewCam2 != (Object)null && billboard)
			{
				((Component)this).transform.rotation = ((Component)viewCam2).transform.rotation * Quaternion.Euler(0f, 0f, roll);
			}
		}
	}
	internal static class HandRig
	{
		private class State
		{
			public readonly float[] throwT = new float[2] { -1f, -1f };

			public readonly bool[] charged = new bool[2];

			public readonly float[] grip = new float[2] { 1f, 1f };

			public readonly float[] spin = new float[2];

			public float inspectT = -1f;

			public bool wasInspecting;
		}

		private static readonly ConditionalWeakTable<Melee, State> states = new ConditionalWeakTable<Melee, State>();

		private static readonly Dictionary<Transform, Transform[][]> chains = new Dictionary<Transform, Transform[][]>();

		private static readonly Dictionary<Transform, (Vector3 pos, Quaternion rot)> baseHand = new Dictionary<Transform, (Vector3, Quaternion)>();

		private static readonly Dictionary<Transform, (Vector3 pos, Quaternion rot)> lastHand = new Dictionary<Transform, (Vector3, Quaternion)>();

		private static readonly Dictionary<MeshRenderer, FxSprite> auras = new Dictionary<MeshRenderer, FxSprite>();

		private static readonly string[] Fingers = new string[5] { "thumb", "index", "middle", "ring", "pinky" };

		private static readonly (float t, Vector3 off, float pitch, float roll)[] Keys = new(float, Vector3, float, float)[7]
		{
			(0f, Vector3.zero, 0f, 0f),
			(0.08f, new Vector3(0.03f, 0.02f, 0f), -20f, 12f),
			(0.16f, new Vector3(0.07f, 0.08f, -0.05f), -60f, 40f),
			(0.21f, new Vector3(0.01f, 0.09f, 0.08f), -15f, 20f),
			(0.27f, new Vector3(-0.05f, 0f, 0.22f), 50f, -10f),
			(0.38f, new Vector3(-0.07f, -0.07f, 0.14f), 35f, -20f),
			(0.62f, Vector3.zero, 0f, 0f)
		};

		private const float InspectLen = 2.4f;

		private static readonly (float t, Vector3 off, float up)[] InspectKeys = new(float, Vector3, float)[5]
		{
			(0f, Vector3.zero, 0f),
			(0.35f, new Vector3(-0.07f, 0.13f, 0.1f), 1f),
			(1.2f, new Vector3(-0.08f, 0.15f, 0.11f), 1f),
			(1.9f, new Vector3(-0.06f, 0.13f, 0.1f), 1f),
			(2.4f, Vector3.zero, 0f)
		};

		private static readonly FieldRef<Tool, Animation> anim = AccessTools.FieldRefAccess<Tool, Animation>("_anim");

		private static readonly Dictionary<string, Quaternion> Rest = new Dictionary<string, Quaternion>
		{
			["r_thumb_low"] = new Quaternion(-0.2609f, 0.1618f, -0.3555f, 0.8828f),
			["r_thumb_mid"] = new Quaternion(0.1062f, -0.1121f, 0.2289f, 0.9611f),
			["r_thumb_tip"] = new Quaternion(-0.0008f, 0.0115f, 0.0737f, 0.9972f),
			["r_index_low"] = new Quaternion(-0.0298f, 0.079f, -0.0373f, 0.9957f),
			["r_index_mid"] = new Quaternion(-0.1732f, -0.001f, 0.0212f, 0.9847f),
			["r_index_tip"] = new Quaternion(-0.0185f, 0.007f, 0.0052f, 0.9998f),
			["r_middle_low"] = new Quaternion(-0.0787f, -0.0021f, -0.0395f, 0.9961f),
			["r_middle_mid"] = new Quaternion(-0.1307f, 0.0371f, 0.0369f, 0.99f),
			["r_middle_tip"] = new Quaternion(-0.0881f, 0.006f, -0.0009f, 0.9961f),
			["r_ring_low"] = new Quaternion(-0.094f, -0.0594f, -0.0117f, 0.9937f),
			["r_ring_mid"] = new Quaternion(-0.1486f, 0.0112f, 0.0281f, 0.9884f),
			["r_ring_tip"] = new Quaternion(-0.1142f, 0.0045f, 0.0374f, 0.9927f),
			["r_pinky_low"] = new Quaternion(-0.1303f, -0.0757f, 0.0208f, 0.9884f),
			["r_pinky_mid"] = new Quaternion(-0.0076f, 0.9969f, -0.0725f, -0.0282f),
			["r_pinky_tip"] = new Quaternion(0.0326f, 0.9842f, 0.1708f, 0.0334f),
			["l_thumb_low"] = new Quaternion(0.3024f, -0.0525f, -0.321f, 0.896f),
			["l_thumb_mid"] = new Quaternion(-0.158f, 0.1089f, 0.1968f, 0.9615f),
			["l_thumb_tip"] = new Quaternion(-0.0219f, 0.0611f, 0.0704f, 0.9954f),
			["l_index_low"] = new Quaternion(0.0352f, 0.0767f, -0.0322f, 0.9959f),
			["l_index_mid"] = new Quaternion(0.1567f, 0.0227f, 0.0768f, 0.9844f),
			["l_index_tip"] = new Quaternion(0.0153f, 0.0146f, 0.0117f, 0.9997f),
			["l_middle_low"] = new Quaternion(0.0782f, -0.0084f, -0.0403f, 0.9961f),
			["l_middle_mid"] = new Quaternion(0.1274f, 0.0619f, 0.047f, 0.9888f),
			["l_middle_tip"] = new Quaternion(0.0865f, 0.0147f, 0.0166f, 0.996f),
			["l_ring_low"] = new Quaternion(0.0919f, -0.0627f, -0.0232f, 0.9935f),
			["l_ring_mid"] = new Quaternion(0.1512f, 0.0196f, -0.0042f, 0.9883f),
			["l_ring_tip"] = new Quaternion(0.1181f, 0.0458f, 0.022f, 0.9917f),
			["l_pinky_low"] = new Quaternion(0.132f, -0.0728f, 0.0011f, 0.9886f),
			["l_pinky_mid"] = new Quaternion(0.0102f, 0.997f, 0.0722f, -0.0273f),
			["l_pinky_tip"] = new Quaternion(-0.0091f, 0.9846f, -0.1736f, 0.0178f)
		};

		private static readonly float[] FingerThick = new float[3] { 0.58f, 0.5f, 0.42f };

		private static readonly float[] ThumbThick = new float[3] { 0.75f, 0.62f, 0.48f };

		private const float TipPast = 0.25f;

		private static readonly float[] JointShare = new float[3] { 0.7f, 1.15f, 0.9f };

		private static readonly float[] Fan = new float[5] { 0f, 0.04f, -0.02f, -0.06f, -0.12f };

		private static State Get(Melee m)
		{
			return states.GetValue(m, (Melee _) => new State());
		}

		public static bool TryBase(Transform hand, out Vector3 pos, out Quaternion rot)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			(Vector3, Quaternion) value;
			bool result = baseHand.TryGetValue(hand, out value);
			(pos, rot) = value;
			return result;
		}

		private static float TimeScale(bool charged)
		{
			if (!charged)
			{
				return 1f;
			}
			return 1.25f;
		}

		public static float ReleaseTime(bool charged)
		{
			return Plugin.ReleaseAt.Value * TimeScale(charged);
		}

		public static bool Throwing(Melee m, int side)
		{
			return Get(m).throwT[side] >= 0f;
		}

		public static void StartThrow(Melee m, int side, bool charged)
		{
			State state = Get(m);
			state.throwT[side] = 0f;
			state.charged[side] = charged;
		}

		private static Vector3 CatmullRom(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float u)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			float num = u * u;
			float num2 = num * u;
			return 0.5f * (2f * p1 + (p2 - p0) * u + (2f * p0 - 5f * p1 + 4f * p2 - p3) * num + (3f * p1 - p0 - 3f * p2 + p3) * num2);
		}

		private static float CatmullRom(float p0, float p1, float p2, float p3, float u)
		{
			//IL_000b: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			return CatmullRom(new Vector3(p0, 0f, 0f), new Vector3(p1, 0f, 0f), new Vector3(p2, 0f, 0f), new Vector3(p3, 0f, 0f), u).x;
		}

		private static void Sample(float t, out Vector3 off, out float pitch, out float roll)
		{
			//IL_00fe: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			int num = Keys.Length;
			for (int i = 1; i < num; i++)
			{
				if (!(t > Keys[i].t))
				{
					(float, Vector3, float, float) tuple = Keys[Mathf.Max(0, i - 2)];
					(float, Vector3, float, float) tuple2 = Keys[i - 1];
					(float, Vector3, float, float) tuple3 = Keys[i];
					(float, Vector3, float, float) tuple4 = Keys[Mathf.Min(num - 1, i + 1)];
					float u = (t - tuple2.Item1) / (tuple3.Item1 - tuple2.Item1);
					off = CatmullRom(tuple.Item2, tuple2.Item2, tuple3.Item2, tuple4.Item2, u);
					pitch = CatmullRom(tuple.Item3, tuple2.Item3, tuple3.Item3, tuple4.Item3, u);
					roll = CatmullRom(tuple.Item4, tuple2.Item4, tuple3.Item4, tuple4.Item4, u);
					return;
				}
			}
			off = Vector3.zero;
			pitch = (roll = 0f);
		}

		private static void SampleInspect(float t, out Vector3 off, out float up)
		{
			//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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invali