Decompiled source of Sulf Stands v1.0.0

SulfurBizarre.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CMF;
using EZCameraShake;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using NodeCanvas.BehaviourTrees;
using PerfectRandom.Sulfur.Core;
using PerfectRandom.Sulfur.Core.DevTools;
using PerfectRandom.Sulfur.Core.Items;
using PerfectRandom.Sulfur.Core.Movement;
using PerfectRandom.Sulfur.Core.Stats;
using PerfectRandom.Sulfur.Core.UI;
using PerfectRandom.Sulfur.Core.UI.Inventory;
using PerfectRandom.Sulfur.Core.Units;
using PerfectRandom.Sulfur.Core.Units.AI;
using PerfectRandom.Sulfur.Core.Weapons;
using PerfectRandom.Sulfur.Core.World;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.UI;

[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("SulfurBizarre")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+82fe86414d94329a4ef0691cf8cb323e2592e157")]
[assembly: AssemblyProduct("SulfurBizarre")]
[assembly: AssemblyTitle("SulfurBizarre")]
[assembly: AssemblyVersion("0.1.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 SulfurBizarre
{
	internal static class ArmLook
	{
		private static readonly Color32 Sleeve = new Color32((byte)26, (byte)26, (byte)30, byte.MaxValue);

		private static readonly Color32 Glove = new Color32((byte)32, (byte)33, (byte)37, byte.MaxValue);

		private static readonly Color32 Pad = new Color32((byte)58, (byte)60, (byte)66, byte.MaxValue);

		private static readonly Color32 Cuff = new Color32((byte)138, (byte)141, (byte)147, byte.MaxValue);

		private static readonly RectInt[] CuffBoxes = (RectInt[])(object)new RectInt[2]
		{
			new RectInt(540, 990, 580, 210),
			new RectInt(1320, 1940, 360, 108)
		};

		private static string Dir => Path.GetDirectoryName(typeof(ArmLook).Assembly.Location);

		public static void Run()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = AssetAccess.GetAsset(ItemIds.Weapon_Katana)?.prefab;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Material val2 = null;
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val3 in componentsInChildren)
				{
					if ((Object)(object)val3.sharedMaterial != (Object)null && ((Object)val3.sharedMaterial).name.StartsWith("Hands"))
					{
						val2 = val3.sharedMaterial;
						break;
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.Log.LogWarning((object)"Arms: no hands material");
					return;
				}
				if (Plugin.DumpPrefabs.Value)
				{
					Dump(val2);
					SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
					foreach (SkinnedMeshRenderer val4 in componentsInChildren2)
					{
						if ((Object)(object)val4.sharedMesh != (Object)null && (((Object)val4).name == "Arm.L" || ((Object)val4).name == "Hand.L"))
						{
							UvMask(val4.sharedMesh, Path.Combine(Dir, "dump", "uv_" + ((Object)val4).name + ".png"));
						}
					}
				}
				List<string> list = TextureProps(val2);
				if (list.Count == 0)
				{
					return;
				}
				Texture2D val5 = ((!File.Exists(Path.Combine(Dir, "assets", "arms.png"))) ? Repaint(val2.GetTexture(list.Contains("_MainTex") ? "_MainTex" : list[0])) : Assets.LoadTexture("arms.png"));
				((Texture)val5).filterMode = (FilterMode)0;
				foreach (string item in list)
				{
					val2.SetTexture(item, (Texture)(object)val5);
				}
				Plugin.Log.LogInfo((object)("Arms: repainted (" + string.Join(",", list) + ")"));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Arms: " + ex));
			}
		}

		private static Texture2D Repaint(Texture src)
		{
			//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)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_00a0: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = Readable(src);
			Color32[] pixels = val.GetPixels32();
			int width = ((Texture)val).width;
			int height = ((Texture)val).height;
			float num = 2048f / (float)width;
			float num2 = 2048f / (float)height;
			Vector2Int val3 = default(Vector2Int);
			for (int i = 0; i < pixels.Length; i++)
			{
				Color32 val2 = pixels[i];
				float baseLum;
				int num3 = Classify(val2.r, val2.g, val2.b, out baseLum);
				if (num3 < 0)
				{
					continue;
				}
				Color32 val4;
				switch (num3)
				{
				case 0:
					val4 = Sleeve;
					break;
				case 1:
					val4 = Glove;
					break;
				default:
				{
					((Vector2Int)(ref val3))..ctor((int)((float)(i % width) * num), (int)((float)(height - 1 - i / width) * num2));
					val4 = Pad;
					RectInt[] cuffBoxes = CuffBoxes;
					for (int j = 0; j < cuffBoxes.Length; j++)
					{
						RectInt val5 = cuffBoxes[j];
						if (((RectInt)(ref val5)).Contains(val3))
						{
							val4 = Cuff;
							break;
						}
					}
					break;
				}
				}
				float num4 = Mathf.Clamp((float)(val2.r + val2.g + val2.b) / 3f / baseLum, 0.85f, 1.15f);
				pixels[i] = new Color32((byte)Mathf.Min(255f, (float)(int)val4.r * num4), (byte)Mathf.Min(255f, (float)(int)val4.g * num4), (byte)Mathf.Min(255f, (float)(int)val4.b * num4), val2.a);
			}
			val.SetPixels32(pixels);
			val.Apply();
			return val;
		}

		private static int Classify(int r, int g, int b, out float baseLum)
		{
			if (r > 215 && g > 205 && b < 165)
			{
				baseLum = 210.66667f;
				return 0;
			}
			if (r >= 94 && r <= 104 && g >= 66 && g <= 78 && b >= 54 && b <= 70)
			{
				baseLum = 77f;
				return 1;
			}
			if (r >= 84 && r < 96 && g >= 58 && g < 70 && b >= 48 && b < 62)
			{
				baseLum = 70.333336f;
				return 2;
			}
			baseLum = 1f;
			if (r < 60 && g < 60 && b < 60)
			{
				return -1;
			}
			int num = Sq(r - 250, g - 242, b - 140);
			int num2 = Sq(r - 99, g - 72, b - 60);
			int num3 = Sq(r - 91, g - 65, b - 55);
			if (num <= num2 && num <= num3)
			{
				baseLum = 210.66667f;
				return 0;
			}
			if (num2 <= num3)
			{
				baseLum = 77f;
				return 1;
			}
			baseLum = 70.333336f;
			return 2;
		}

		private static int Sq(int a, int b, int c)
		{
			return a * a + b * b + c * c;
		}

		private static Texture2D Readable(Texture t)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0073: Expected O, but got Unknown
			RenderTexture temporary = RenderTexture.GetTemporary(t.width, t.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			Graphics.Blit(t, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(t.width, t.height, (TextureFormat)4, true);
			val.ReadPixels(new Rect(0f, 0f, (float)t.width, (float)t.height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			return val;
		}

		private static List<string> TextureProps(Material m)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			List<string> list = new List<string>();
			Shader shader = m.shader;
			for (int i = 0; i < shader.GetPropertyCount(); i++)
			{
				if ((int)shader.GetPropertyType(i) == 4 && (Object)(object)m.GetTexture(shader.GetPropertyName(i)) != (Object)null)
				{
					Texture texture = m.GetTexture(shader.GetPropertyName(i));
					Texture2D val = (Texture2D)(object)((texture is Texture2D) ? texture : null);
					if (val != null && ((Texture)val).width > 4)
					{
						list.Add(shader.GetPropertyName(i));
					}
				}
			}
			return list;
		}

		private static void Dump(Material m)
		{
			//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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected I4, but got Unknown
			//IL_00a2: 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)
			string text = Path.Combine(Dir, "dump");
			Directory.CreateDirectory(text);
			StringBuilder stringBuilder = new StringBuilder("Arms material " + ((Object)m).name + ", shader " + ((Object)m.shader).name + ":");
			Shader shader = m.shader;
			for (int i = 0; i < shader.GetPropertyCount(); i++)
			{
				string propertyName = shader.GetPropertyName(i);
				ShaderPropertyType propertyType = shader.GetPropertyType(i);
				switch ((int)propertyType)
				{
				case 0:
					stringBuilder.Append($"\n  {propertyName} = color {m.GetColor(propertyName)}");
					break;
				case 2:
				case 3:
					stringBuilder.Append($"\n  {propertyName} = {m.GetFloat(propertyName)}");
					break;
				case 1:
					stringBuilder.Append($"\n  {propertyName} = {m.GetVector(propertyName)}");
					break;
				case 4:
				{
					Texture texture = m.GetTexture(propertyName);
					stringBuilder.Append("\n  " + propertyName + " = texture " + (((Object)(object)texture != (Object)null) ? (((Object)texture).name + " " + texture.width + "x" + texture.height) : "none"));
					if ((Object)(object)texture != (Object)null)
					{
						Save(texture, Path.Combine(text, "arms_" + propertyName + ".png"));
					}
					break;
				}
				}
			}
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}

		private static void UvMask(Mesh m, string path)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0185: 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_0189: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector2[] uv = m.uv;
				int[] triangles = m.triangles;
				Color32[] array = (Color32[])(object)new Color32[262144];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
				}
				Vector2 p = default(Vector2);
				for (int j = 0; j < triangles.Length; j += 3)
				{
					Vector2 val = uv[triangles[j]] * 512f;
					Vector2 val2 = uv[triangles[j + 1]] * 512f;
					Vector2 val3 = uv[triangles[j + 2]] * 512f;
					int num = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(val.x, Mathf.Min(val2.x, val3.x))));
					int num2 = Mathf.Min(511, Mathf.CeilToInt(Mathf.Max(val.x, Mathf.Max(val2.x, val3.x))));
					int num3 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(val.y, Mathf.Min(val2.y, val3.y))));
					int num4 = Mathf.Min(511, Mathf.CeilToInt(Mathf.Max(val.y, Mathf.Max(val2.y, val3.y))));
					for (int k = num3; k <= num4; k++)
					{
						for (int l = num; l <= num2; l++)
						{
							((Vector2)(ref p))..ctor((float)l + 0.5f, (float)k + 0.5f);
							float num5 = Edge(val, val2, p);
							float num6 = Edge(val2, val3, p);
							float num7 = Edge(val3, val, p);
							bool flag = num5 < 0f || num6 < 0f || num7 < 0f;
							bool flag2 = num5 > 0f || num6 > 0f || num7 > 0f;
							if (!(flag && flag2))
							{
								array[k * 512 + l] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
							}
						}
					}
				}
				Texture2D val4 = new Texture2D(512, 512, (TextureFormat)4, false);
				val4.SetPixels32(array);
				val4.Apply();
				File.WriteAllBytes(path, ImageConversion.EncodeToPNG(val4));
				Object.Destroy((Object)(object)val4);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Arms: UV mask " + ((Object)m).name + ": " + ex.Message));
			}
		}

		private static float Edge(Vector2 a, Vector2 b, Vector2 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x);
		}

		private static void Save(Texture t, string path)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture temporary = RenderTexture.GetTemporary(t.width, t.height, 0, (RenderTextureFormat)0);
			Graphics.Blit(t, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(t.width, t.height, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, (float)t.width, (float)t.height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			File.WriteAllBytes(path, ImageConversion.EncodeToPNG(val));
			Object.Destroy((Object)(object)val);
		}
	}
	internal class ArmPose
	{
		private class Arm
		{
			public Transform upper;

			public Transform fore;

			public Transform wrist;

			public Transform middle;

			public Transform index;

			public Transform little;

			public Transform[][] fingers;

			public float lenUpper;

			public float lenFore;

			public Vector3 target;

			public bool hasTarget;

			public Key[] anim;

			public float animT;

			public bool Ok
			{
				get
				{
					if ((Object)(object)upper != (Object)null && (Object)(object)fore != (Object)null && (Object)(object)wrist != (Object)null && (Object)(object)middle != (Object)null && (Object)(object)index != (Object)null)
					{
						return (Object)(object)little != (Object)null;
					}
					return false;
				}
			}
		}

		private struct Key
		{
			public float t;

			public float turn;

			public Vector3 off;

			public Key(float t, float x, float y, float z, float turn)
			{
				//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)
				this.t = t;
				off = new Vector3(x, y, z);
				this.turn = turn;
			}
		}

		private struct Swing
		{
			public float t;

			public float upper;

			public float fore;

			public float wrist;

			public float across;

			public Swing(float t, float upper, float fore, float wrist, float across)
			{
				this.t = t;
				this.upper = upper;
				this.fore = fore;
				this.wrist = wrist;
				this.across = across;
			}
		}

		private readonly Arm[] arms = new Arm[2]
		{
			new Arm(),
			new Arm()
		};

		private readonly List<Transform> armBones = new List<Transform>();

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

		private static readonly Key[] ThrowKeys = new Key[5]
		{
			new Key(0f, 0f, 0f, 0f, 0f),
			new Key(0.1f, -0.06f, 0.14f, -0.24f, 0.15f),
			new Key(0.18f, 0.06f, 0.1f, 0.3f, 0.5f),
			new Key(0.3f, 0.03f, -0.04f, 0.14f, 0.3f),
			new Key(0.46f, 0f, 0f, 0f, 0f)
		};

		public const float ThrowRelease = 0.16f;

		private static readonly Key[] ChargedKeys = new Key[6]
		{
			new Key(0f, 0f, 0f, 0f, 0f),
			new Key(0.2f, -0.12f, 0.42f, -0.3f, 0.1f),
			new Key(0.3f, -0.14f, 0.46f, -0.36f, 0.05f),
			new Key(0.4f, 0.08f, 0.06f, 0.4f, 0.55f),
			new Key(0.6f, 0.1f, -0.14f, 0.22f, 0.35f),
			new Key(0.85f, 0f, 0f, 0f, 0f)
		};

		public const float ChargedRelease = 0.38f;

		private static readonly Swing[] ThrowSwing = new Swing[5]
		{
			new Swing(0f, 0f, 0f, 0f, 0f),
			new Swing(0.1f, -14f, -38f, -22f, -4f),
			new Swing(0.17f, 6f, 18f, 12f, 8f),
			new Swing(0.28f, 3f, 8f, 5f, 4f),
			new Swing(0.42f, 0f, 0f, 0f, 0f)
		};

		public const float SwingRelease = 0.15f;

		private static readonly Swing[] ChargedSwing = new Swing[6]
		{
			new Swing(0f, 0f, 0f, 0f, 0f),
			new Swing(0.24f, -75f, -70f, -40f, -10f),
			new Swing(0.33f, -80f, -72f, -45f, -10f),
			new Swing(0.42f, 20f, 10f, 15f, 12f),
			new Swing(0.6f, 12f, 5f, 8f, 8f),
			new Swing(0.82f, 0f, 0f, 0f, 0f)
		};

		public const float ChargedSwingRelease = 0.4f;

		private bool logged;

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

		private static readonly float[] Fan = new float[5] { 0f, 0.07f, 0f, -0.05f, -0.12f };

		public void Play(int side, bool charged)
		{
			arms[side].anim = (charged ? ChargedKeys : ThrowKeys);
			arms[side].animT = 0f;
		}

		private static Key Sample(Key[] keys, float t)
		{
			//IL_006e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 1; i < keys.Length; i++)
			{
				if (!(t > keys[i].t))
				{
					Key key = keys[i - 1];
					Key key2 = keys[i];
					float num = Mathf.SmoothStep(0f, 1f, (t - key.t) / Mathf.Max(0.0001f, key2.t - key.t));
					return new Key
					{
						t = t,
						off = Vector3.Lerp(key.off, key2.off, num),
						turn = Mathf.Lerp(key.turn, key2.turn, num)
					};
				}
			}
			return keys[^1];
		}

		public ArmPose(Transform root)
		{
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (RefPose.IsArmBone(((Object)val).name))
				{
					armBones.Add(val);
				}
			}
			Dictionary<Transform, Matrix4x4> dictionary = new Dictionary<Transform, Matrix4x4>();
			SkinnedMeshRenderer[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
			{
				if ((Object)(object)val2.sharedMesh == (Object)null || val2.bones == null)
				{
					continue;
				}
				Matrix4x4[] bindposes = val2.sharedMesh.bindposes;
				for (int j = 0; j < val2.bones.Length && j < bindposes.Length; j++)
				{
					if ((Object)(object)val2.bones[j] != (Object)null && !dictionary.ContainsKey(val2.bones[j]))
					{
						dictionary[val2.bones[j]] = bindposes[j];
					}
				}
			}
			foreach (KeyValuePair<Transform, Matrix4x4> item in dictionary)
			{
				Transform key = item.Key;
				if (IsFinger(((Object)key).name) && !((Object)(object)key.parent == (Object)null) && dictionary.TryGetValue(key.parent, out var value))
				{
					Matrix4x4 val3 = value;
					Matrix4x4 value2 = item.Value;
					Matrix4x4 val4 = val3 * ((Matrix4x4)(ref value2)).inverse;
					fingerRest[key] = (Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3)), ((Matrix4x4)(ref val4)).rotation);
				}
			}
			Plugin.Log.LogInfo((object)$"Steel ball arms: {fingerRest.Count} finger bones with a rest pose");
			for (int k = 0; k < 2; k++)
			{
				Arm arm = arms[k];
				string text = ((k == 0) ? ".R" : ".L");
				arm.upper = Items.FindBone(root, "UpperArm" + text);
				arm.fore = Items.FindBone(root, "ForeArm" + text);
				arm.wrist = Items.FindBone(root, "Wrist" + text);
				arm.middle = Items.FindBone(root, "Middle.01" + text);
				arm.index = Items.FindBone(root, "Index.01" + text);
				arm.little = Items.FindBone(root, "Little.01" + text);
				arm.fingers = new Transform[5][];
				string[] array = new string[5] { "Thumb", "Index", "Middle", "Ring", "Little" };
				for (int l = 0; l < 5; l++)
				{
					int num = ((l == 0) ? 2 : 3);
					arm.fingers[l] = (Transform[])(object)new Transform[num];
					for (int m = 0; m < num; m++)
					{
						arm.fingers[l][m] = Items.FindBone(root, $"{array[l]}.0{m + 1}{text}");
					}
				}
				if (!arm.Ok)
				{
					Plugin.Log.LogWarning((object)("Steel ball arms: missing bones for side " + text));
				}
			}
		}

		public Vector3 PalmNormal(int side)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0155: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b5: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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)
			Arm arm = arms[side];
			Vector3 val = arm.middle.position - arm.wrist.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.zero;
			for (int i = 1; i <= 2; i++)
			{
				Transform[] array = arm.fingers[i];
				if (!((Object)(object)array[0] == (Object)null) && !((Object)(object)array[1] == (Object)null) && !((Object)(object)array[2] == (Object)null))
				{
					val = array[1].position - array[0].position;
					Vector3 normalized2 = ((Vector3)(ref val)).normalized;
					val = array[2].position - array[1].position;
					Vector3 normalized3 = ((Vector3)(ref val)).normalized;
					val2 += normalized3 - normalized2 * Vector3.Dot(normalized3, normalized2);
					val2 += normalized2 - normalized * Vector3.Dot(normalized2, normalized);
				}
			}
			val2 -= normalized * Vector3.Dot(val2, normalized);
			val = Vector3.Cross(arm.index.position - arm.little.position, arm.middle.position - arm.wrist.position);
			Vector3 val3 = ((Vector3)(ref val)).normalized;
			if (side == 1)
			{
				val3 = -val3;
			}
			if (((Vector3)(ref val2)).sqrMagnitude > 1E-08f && Vector3.Dot(val3, val2) < 0f)
			{
				val3 = -val3;
			}
			if (!Plugin.PalmFlip.Value)
			{
				return val3;
			}
			return -val3;
		}

		public bool Has(int side)
		{
			return arms[side].Ok;
		}

		public void PlayRef(RefPose.Clip clip, float time)
		{
			RefPose.Apply(armBones, clip, time);
		}

		public static float SwingLength(bool charged)
		{
			return (charged ? ChargedSwing : ThrowSwing)[(charged ? ChargedSwing : ThrowSwing).Length - 1].t;
		}

		private static Swing SampleSwing(Swing[] keys, float t)
		{
			for (int i = 1; i < keys.Length; i++)
			{
				if (!(t > keys[i].t))
				{
					Swing swing = keys[i - 1];
					Swing swing2 = keys[i];
					float num = Mathf.SmoothStep(0f, 1f, (t - swing.t) / Mathf.Max(0.0001f, swing2.t - swing.t));
					return new Swing(t, Mathf.Lerp(swing.upper, swing2.upper, num), Mathf.Lerp(swing.fore, swing2.fore, num), Mathf.Lerp(swing.wrist, swing2.wrist, num), Mathf.Lerp(swing.across, swing2.across, num));
				}
			}
			return keys[^1];
		}

		public void Layer(Transform cam, int side, bool block, float throwT, bool charged, bool holding = true)
		{
			//IL_0019: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0164: 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_016d: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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_01ad: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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)
			Arm arm = arms[side];
			if (arm.Ok)
			{
				arm.lenUpper = Vector3.Distance(arm.upper.position, arm.fore.position);
				arm.lenFore = Vector3.Distance(arm.fore.position, arm.wrist.position);
				float num = ((side == 0) ? (-1f) : 1f);
				Vector3 val;
				if (throwT >= 0f)
				{
					Swing swing = SampleSwing(charged ? ChargedSwing : ThrowSwing, throwT);
					Vector3 right = cam.right;
					arm.upper.rotation = Quaternion.AngleAxis(swing.across * (0f - num), cam.up) * Quaternion.AngleAxis(swing.upper, right) * arm.upper.rotation;
					arm.fore.rotation = Quaternion.AngleAxis(swing.fore, right) * arm.fore.rotation;
					arm.wrist.rotation = Quaternion.AngleAxis(swing.wrist, right) * arm.wrist.rotation;
				}
				else if (block)
				{
					val = cam.up + cam.forward * 0.25f + cam.right * num * 0.15f;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					val = cam.forward + cam.up * 0.15f;
					Vector3 normalized2 = ((Vector3)(ref val)).normalized;
					OrientHand(arm, side, normalized, normalized2);
				}
				else if (Plugin.PalmUpAtRest.Value)
				{
					val = cam.forward + cam.right * num * 0.3f - cam.up * 0.15f;
					Vector3 normalized3 = ((Vector3)(ref val)).normalized;
					OrientHand(arm, side, normalized3, cam.up);
				}
				if (holding)
				{
					Curl(arm, side, Plugin.FingerCurl.Value);
				}
				else
				{
					Relax(arm, side);
				}
			}
		}

		public void ReachWrist(int side, Vector3 target, Transform cam)
		{
			//IL_0019: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok)
			{
				arm.lenUpper = Vector3.Distance(arm.upper.position, arm.fore.position);
				arm.lenFore = Vector3.Distance(arm.fore.position, arm.wrist.position);
				float num = ((side == 0) ? 1f : (-1f));
				Vector3 pole = arm.upper.position + (cam.right * num * 0.6f - cam.up) * (arm.lenUpper + arm.lenFore);
				SolveTwoBone(arm, target, pole);
			}
		}

		public Vector3 WristPos(int side)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return arms[side].wrist.position;
		}

		public void ShiftShoulder(int side, Vector3 offset)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok && ((Vector3)(ref offset)).sqrMagnitude > 1E-10f)
			{
				Transform upper = arm.upper;
				upper.position += offset;
			}
		}

		public void Thrust(Transform cam, int side, float k)
		{
			//IL_0021: 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_004d: 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_007c: 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_0090: 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)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok && !(k <= 0f))
			{
				arm.lenUpper = Vector3.Distance(arm.upper.position, arm.fore.position);
				arm.lenFore = Vector3.Distance(arm.fore.position, arm.wrist.position);
				float num = (arm.lenUpper + arm.lenFore) * Plugin.PunchReach.Value;
				Vector3 val = cam.position + cam.forward * 3f;
				Vector3 position = arm.upper.position;
				Vector3 val2 = val - arm.upper.position;
				Vector3 val3 = position + ((Vector3)(ref val2)).normalized * num;
				Vector3 target = Vector3.Lerp(arm.wrist.position, val3, Mathf.Clamp01(k));
				float num2 = ((side == 0) ? 1f : (-1f));
				Vector3 pole = arm.upper.position + (cam.right * num2 * 0.6f - cam.up) * (arm.lenUpper + arm.lenFore);
				SolveTwoBone(arm, target, pole);
			}
		}

		public Vector3 FingerDir(int side)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			Vector3 val = arms[side].middle.position - arms[side].wrist.position;
			return ((Vector3)(ref val)).normalized;
		}

		private static bool IsFinger(string n)
		{
			if (n.StartsWith("Thumb") || n.StartsWith("Index") || n.StartsWith("Middle") || n.StartsWith("Ring") || n.StartsWith("Little"))
			{
				if (!n.EndsWith(".R"))
				{
					return n.EndsWith(".L");
				}
				return true;
			}
			return false;
		}

		public Vector3 PalmPoint(int side)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			Arm obj = arms[side];
			Vector3 position = obj.wrist.position;
			Vector3 val = obj.middle.position - position;
			return position + val * Plugin.PalmAlong.Value + PalmNormal(side) * (((Vector3)(ref val)).magnitude * Plugin.PalmOut.Value);
		}

		public float PalmLength(int side)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return Vector3.Distance(arms[side].wrist.position, arms[side].middle.position);
		}

		public void LogOnce(Transform cam, Transform ball)
		{
			//IL_0040: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (!logged && arms[0].Ok)
			{
				logged = true;
				Arm arm = arms[0];
				Plugin.Log.LogInfo((object)($"Steel ball arms: wrist scale {arm.wrist.lossyScale.x:F3}, palm {PalmLength(0):F3}, upper {arm.lenUpper:F3}, fore {arm.lenFore:F3}, " + $"shoulder-cam {Vector3.Distance(arm.upper.position, cam.position):F3}, ball-cam {Vector3.Distance(ball.position, cam.position):F3}, ball scale {ball.lossyScale.x:F3}"));
			}
		}

		public void Apply(Transform cam, bool block, float charge, float dt)
		{
			//IL_0022: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: 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_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: 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_0300: 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_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: 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_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			for (int i = 0; i < 2; i++)
			{
				Arm arm = arms[i];
				if (!arm.Ok)
				{
					continue;
				}
				arm.lenUpper = Vector3.Distance(arm.upper.position, arm.fore.position);
				arm.lenFore = Vector3.Distance(arm.fore.position, arm.wrist.position);
				float num = arm.lenUpper + arm.lenFore;
				if (num < 0.0001f)
				{
					continue;
				}
				float num2 = ((i == 0) ? 1f : (-1f));
				float time = Time.time;
				float value = Plugin.HandSide.Value;
				float value2 = Plugin.HandDown.Value;
				float value3 = Plugin.HandForward.Value;
				((Vector3)(ref val))..ctor(num2 * value, 0f - value2, value3);
				Vector3 val2 = (block ? new Vector3(val.x * 0.7f, val.y * 0.6f, val.z) : new Vector3(val.x, val.y + Mathf.Sin(time * 1.7f + (float)i) * 0.003f, val.z - charge * 0.015f));
				float num3 = 0f;
				bool flag = arm.anim != null;
				if (flag)
				{
					arm.animT += dt;
					Key key = Sample(arm.anim, arm.animT);
					val2 += new Vector3((0f - num2) * key.off.x, key.off.y, key.off.z) * num;
					num3 = key.turn;
					if (arm.animT >= arm.anim[arm.anim.Length - 1].t)
					{
						arm.anim = null;
					}
				}
				arm.target = (arm.hasTarget ? Vector3.Lerp(arm.target, val2, dt * (flag ? 40f : 14f)) : val2);
				arm.hasTarget = true;
				Vector3 position = arm.upper.position;
				Vector3 target = cam.position + cam.TransformDirection(arm.target);
				Vector3 pole = position + (cam.right * num2 * 0.6f - cam.up) * num;
				SolveTwoBone(arm, target, pole);
				Vector3 val3 = cam.forward - cam.right * num2 * 0.25f;
				Vector3 val4 = ((Vector3)(ref val3)).normalized;
				Vector3 val5 = cam.up;
				if (block)
				{
					val3 = cam.up + cam.forward * 0.25f - cam.right * num2 * 0.15f;
					val4 = ((Vector3)(ref val3)).normalized;
					val3 = cam.forward + cam.up * 0.15f;
					val5 = ((Vector3)(ref val3)).normalized;
				}
				if (num3 > 0f)
				{
					Vector3 val6 = val4;
					val3 = cam.up + cam.forward * 0.2f;
					val4 = Vector3.Slerp(val6, ((Vector3)(ref val3)).normalized, num3);
					val5 = Vector3.Slerp(val5, cam.forward, num3);
				}
				OrientHand(arm, i, val4, val5);
				Curl(arm, i, Plugin.FingerCurl.Value * (1f - 0.7f * num3));
			}
		}

		private static void SolveTwoBone(Arm a, Vector3 target, Vector3 pole)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = a.upper.position;
			Vector3 val = target - position;
			float num = Mathf.Clamp(((Vector3)(ref val)).magnitude, 0.01f, (a.lenUpper + a.lenFore) * 0.999f);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num2 = Mathf.Acos(Mathf.Clamp((a.lenUpper * a.lenUpper + num * num - a.lenFore * a.lenFore) / (2f * a.lenUpper * num), -1f, 1f));
			Vector3 val2 = Vector3.ProjectOnPlane(pole - position, normalized);
			Vector3 val3 = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
			{
				val3 = Vector3.down;
			}
			Vector3 childWant = position + (normalized * Mathf.Cos(num2) + val3 * Mathf.Sin(num2)) * a.lenUpper;
			Aim(a.upper, a.fore.position, childWant);
			Aim(a.fore, a.wrist.position, position + normalized * num);
		}

		private static void Aim(Transform bone, Vector3 childNow, Vector3 childWant)
		{
			//IL_0000: 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_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_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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = childNow - bone.position;
			Vector3 val2 = childWant - bone.position;
			if (!(((Vector3)(ref val)).sqrMagnitude < 1E-08f) && !(((Vector3)(ref val2)).sqrMagnitude < 1E-08f))
			{
				bone.rotation = Quaternion.FromToRotation(val, val2) * bone.rotation;
			}
		}

		private void OrientHand(Arm a, int side, Vector3 along, Vector3 palm)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00a0: 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)
			Quaternion? val = HandDelta(a, side, along, palm);
			if (val.HasValue)
			{
				Vector3 val2 = a.wrist.position - a.fore.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Quaternion val3 = Twist(val.Value, normalized);
				a.fore.rotation = Quaternion.Slerp(Quaternion.identity, val3, Plugin.ForearmRoll.Value) * a.fore.rotation;
				val = HandDelta(a, side, along, palm);
				if (val.HasValue)
				{
					a.wrist.rotation = val.Value * a.wrist.rotation;
				}
			}
		}

		private Quaternion? HandDelta(Arm a, int side, Vector3 along, Vector3 palm)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_005a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = a.middle.position - a.wrist.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = PalmNormal(side);
			if (((Vector3)(ref normalized)).sqrMagnitude < 1E-06f || ((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				return null;
			}
			return Quaternion.LookRotation(along, palm) * Quaternion.Inverse(Quaternion.LookRotation(normalized, val2));
		}

		private static Quaternion Twist(Quaternion q, Vector3 axis)
		{
			//IL_0002: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_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_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0059: 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_0067: 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_0075: 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_0099: 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_00a9: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(q.x, q.y, q.z);
			Vector3 val2 = axis * Vector3.Dot(val, axis);
			Quaternion val3 = default(Quaternion);
			((Quaternion)(ref val3))..ctor(val2.x, val2.y, val2.z, q.w);
			float num = Mathf.Sqrt(val3.x * val3.x + val3.y * val3.y + val3.z * val3.z + val3.w * val3.w);
			if (num < 1E-06f)
			{
				return Quaternion.identity;
			}
			return new Quaternion(val3.x / num, val3.y / num, val3.z / num, val3.w / num);
		}

		private void Curl(Arm a, int side, float degrees)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01a1: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: 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)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = PalmNormal(side);
			Vector3 val2 = a.index.position - a.little.position;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			Vector3 val3 = PalmPoint(side);
			float num = PalmLength(side) * Plugin.BallSize.Value * 1.04f;
			for (int i = 0; i < 5; i++)
			{
				Transform[] array = a.fingers[i];
				foreach (Transform val4 in array)
				{
					if (!((Object)(object)val4 == (Object)null) && fingerRest.TryGetValue(val4, out (Vector3, Quaternion) value))
					{
						val4.localRotation = value.Item2;
					}
				}
				for (int k = 0; k < array.Length; k++)
				{
					Transform val5 = array[k];
					if ((Object)(object)val5 == (Object)null)
					{
						continue;
					}
					Vector3 val6 = BoneDir(a, array, k);
					if (((Vector3)(ref val6)).sqrMagnitude < 1E-10f)
					{
						continue;
					}
					if (k == 0 && i > 0 && Fan[i] != 0f)
					{
						val5.rotation = Quaternion.FromToRotation(val6, val6 + normalized * (Fan[i] * ((Vector3)(ref val6)).magnitude)) * val5.rotation;
						val6 = BoneDir(a, array, k);
					}
					if (i == 0 && k == 0)
					{
						val2 = a.middle.position - a.wrist.position;
						Vector3 val7 = val3 + ((Vector3)(ref val2)).normalized * num * 0.4f + val * num * 0.6f;
						val5.rotation = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(val6, val7 - val5.position), Plugin.ThumbAcross.Value) * val5.rotation;
						val6 = BoneDir(a, array, k);
					}
					float num2 = degrees * ((i == 0) ? Plugin.ThumbCurl.Value : JointShare[Mathf.Min(k, 2)]) * 2.2f;
					val6 = BoneDir(a, array, k);
					Vector3 val8 = Vector3.Cross(val6, val);
					if (((Vector3)(ref val8)).sqrMagnitude < 1E-10f)
					{
						continue;
					}
					((Vector3)(ref val8)).Normalize();
					float num3 = 0f;
					float num4 = float.MaxValue;
					for (float num5 = 0f; num5 <= num2; num5 += 3f)
					{
						val2 = val5.position + Quaternion.AngleAxis(num5, val8) * val6 - val3;
						float num6 = Mathf.Abs(((Vector3)(ref val2)).magnitude - num);
						if (num6 < num4 - 1E-05f)
						{
							num4 = num6;
							num3 = num5;
						}
					}
					val5.rotation = Quaternion.AngleAxis(num3, val8) * val5.rotation;
				}
			}
		}

		public void FingerGun(int side, Vector3 aim)
		{
			//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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: 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_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: 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_034c: 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_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: 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_0211: 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_0239: 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_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: 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_0229: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (!arm.Ok)
			{
				return;
			}
			Vector3 val = PalmNormal(side);
			Transform[][] fingers = arm.fingers;
			foreach (Transform[] array in fingers)
			{
				foreach (Transform val2 in array)
				{
					if ((Object)(object)val2 != (Object)null && fingerRest.TryGetValue(val2, out (Vector3, Quaternion) value))
					{
						val2.localRotation = value.Item2;
					}
				}
			}
			for (int k = 0; k < 5; k++)
			{
				Transform[] array2 = arm.fingers[k];
				Transform[] array = array2;
				foreach (Transform val3 in array)
				{
					if ((Object)(object)val3 != (Object)null && fingerRest.TryGetValue(val3, out (Vector3, Quaternion) value2))
					{
						val3.localRotation = value2.Item2;
					}
				}
				if (array2.Length == 0 || (Object)(object)array2[0] == (Object)null)
				{
					continue;
				}
				Transform val4 = ((arm.fingers[2].Length != 0) ? arm.fingers[2][0] : null);
				if (k != 2 && (Object)(object)val4 != (Object)null)
				{
					Vector3 val5 = BoneDir(arm, arm.fingers[2], 0);
					Vector3 val6 = BoneDir(arm, array2, 0);
					Vector3 val7 = Vector3.ProjectOnPlane(Vector3.ProjectOnPlane(((k == 0 && arm.fingers[1].Length != 0 && (Object)(object)arm.fingers[1][0] != (Object)null) ? arm.fingers[1][0] : array2[0]).position - val4.position, val), val5);
					if (((Vector3)(ref val5)).sqrMagnitude > 1E-10f && ((Vector3)(ref val6)).sqrMagnitude > 1E-10f && ((Vector3)(ref val7)).sqrMagnitude > 1E-12f)
					{
						float num = k switch
						{
							4 => 2f * Plugin.TuskFingerSpread.Value, 
							0 => Plugin.TuskThumbSpread.Value, 
							_ => Plugin.TuskFingerSpread.Value, 
						} * ((float)Math.PI / 180f);
						Vector3 val8 = ((Vector3)(ref val5)).normalized * Mathf.Cos(num) + ((Vector3)(ref val7)).normalized * Mathf.Sin(num);
						if (k == 0)
						{
							val8 += val * Plugin.TuskThumbBend.Value;
						}
						array2[0].rotation = Quaternion.FromToRotation(val6, ((Vector3)(ref val8)).normalized) * array2[0].rotation;
					}
				}
				for (int l = 1; l < array2.Length; l++)
				{
					Transform val9 = array2[l];
					if (!((Object)(object)val9 == (Object)null) && !((Object)(object)array2[l - 1] == (Object)null))
					{
						val9.rotation = Quaternion.FromToRotation(BoneDir(arm, array2, l), BoneDir(arm, array2, l - 1)) * val9.rotation;
					}
				}
				if (k != 0)
				{
					for (int m = 1; m < array2.Length; m++)
					{
						Transform val10 = array2[m];
						if (!((Object)(object)val10 == (Object)null))
						{
							Vector3 val11 = Vector3.Cross(BoneDir(arm, array2, m), val);
							if (((Vector3)(ref val11)).sqrMagnitude > 1E-10f)
							{
								val10.rotation = Quaternion.AngleAxis(0f - Plugin.TuskFingerCurl.Value, ((Vector3)(ref val11)).normalized) * val10.rotation;
							}
						}
					}
				}
				if (k != 0)
				{
					continue;
				}
				for (int n = 0; n < array2.Length; n++)
				{
					Transform val12 = array2[n];
					if (!((Object)(object)val12 == (Object)null))
					{
						Vector3 val13 = Vector3.Cross(BoneDir(arm, array2, n), val);
						if (((Vector3)(ref val13)).sqrMagnitude > 1E-10f)
						{
							val12.rotation = Quaternion.AngleAxis(Plugin.TuskThumbCurl.Value, ((Vector3)(ref val13)).normalized) * val12.rotation;
						}
					}
				}
			}
		}

		public void PointHand(int side, Transform cam, float? tiltDegrees = null)
		{
			//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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok)
			{
				float num = ((side == 0) ? (-1f) : 1f);
				Vector3 along = TuskAlong(cam, num);
				float num2 = (tiltDegrees ?? Plugin.TuskHandTilt.Value) * ((float)Math.PI / 180f);
				Vector3 val = -cam.up * Mathf.Cos(num2) + cam.right * num * Mathf.Sin(num2);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				OrientHand(arm, side, along, normalized);
			}
		}

		private static Vector3 TuskAlong(Transform cam, float inward)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			Vector3 val = cam.forward + cam.right * inward * Plugin.TuskFingerIn.Value + cam.up * Plugin.TuskFingerPitch.Value;
			return ((Vector3)(ref val)).normalized;
		}

		public void FingersAhead(int side, Transform cam)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok)
			{
				float inward = ((side == 0) ? (-1f) : 1f);
				Vector3 val = TuskAlong(cam, inward);
				Vector3 val2 = FingerTip(side, 2) - arm.wrist.position;
				if (((Vector3)(ref val2)).sqrMagnitude > 1E-10f)
				{
					arm.wrist.rotation = Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, val) * arm.wrist.rotation;
				}
			}
		}

		public void HandPose(int side, Vector3 along, Vector3 palm)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (arm.Ok)
			{
				OrientHand(arm, side, along, palm);
			}
		}

		public void StraightFingers(int side)
		{
			//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_0058: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = arms[side];
			if (!arm.Ok)
			{
				return;
			}
			Vector3 val = PalmNormal(side);
			for (int i = 0; i < 5; i++)
			{
				Transform[] array = arm.fingers[i];
				Transform[] array2 = array;
				foreach (Transform val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && fingerRest.TryGetValue(val2, out (Vector3, Quaternion) value))
					{
						val2.localRotation = value.Item2;
					}
				}
				for (int k = 1; k < array.Length; k++)
				{
					Transform val3 = array[k];
					if (!((Object)(object)val3 == (Object)null) && !((Object)(object)array[k - 1] == (Object)null))
					{
						val3.rotation = Quaternion.FromToRotation(BoneDir(arm, array, k), BoneDir(arm, array, k - 1)) * val3.rotation;
					}
				}
				if (i != 0)
				{
					continue;
				}
				for (int l = 0; l < array.Length; l++)
				{
					Transform val4 = array[l];
					if (!((Object)(object)val4 == (Object)null))
					{
						Vector3 val5 = Vector3.Cross(BoneDir(arm, array, l), val);
						if (((Vector3)(ref val5)).sqrMagnitude > 1E-10f)
						{
							val4.rotation = Quaternion.AngleAxis(25f, ((Vector3)(ref val5)).normalized) * val4.rotation;
						}
					}
				}
			}
		}

		public Vector3 TipDir(int side, int finger)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Transform[] chain = arms[side].fingers[finger];
			Vector3 val = LastSegment(arms[side], chain);
			return ((Vector3)(ref val)).normalized;
		}

		public Vector3 FingerTip(int side, int finger)
		{
			//IL_0035: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = arms[side].fingers[finger];
			Transform val = array[^1];
			if ((Object)(object)val == (Object)null)
			{
				return arms[side].wrist.position;
			}
			return val.position + LastSegment(arms[side], array);
		}

		private static Vector3 LastSegment(Arm a, Transform[] chain)
		{
			//IL_0020: 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_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_0038: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			int num = chain.Length;
			Transform obj = chain[num - 1];
			Vector3 val = ((num > 1 && (Object)(object)chain[num - 2] != (Object)null) ? chain[num - 2].position : a.wrist.position);
			return (obj.position - val) * 0.8f;
		}

		private void Relax(Arm a, int side)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = PalmNormal(side);
			for (int i = 0; i < 5; i++)
			{
				Transform[] array = a.fingers[i];
				Transform[] array2 = array;
				foreach (Transform val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && fingerRest.TryGetValue(val2, out (Vector3, Quaternion) value))
					{
						val2.localRotation = value.Item2;
					}
				}
				for (int k = 0; k < array.Length; k++)
				{
					Transform val3 = array[k];
					if (!((Object)(object)val3 == (Object)null))
					{
						Vector3 val4 = Vector3.Cross(BoneDir(a, array, k), val);
						if (!(((Vector3)(ref val4)).sqrMagnitude < 1E-10f))
						{
							val3.rotation = Quaternion.AngleAxis((i == 0) ? 8f : 18f, ((Vector3)(ref val4)).normalized) * val3.rotation;
						}
					}
				}
			}
		}

		private static Vector3 BoneDir(Arm a, Transform[] chain, int j)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			Transform val = chain[j];
			if (j + 1 < chain.Length && (Object)(object)chain[j + 1] != (Object)null)
			{
				return chain[j + 1].position - val.position;
			}
			if (val.childCount > 0)
			{
				return val.GetChild(0).position - val.position;
			}
			Vector3 val2 = ((j > 0 && (Object)(object)chain[j - 1] != (Object)null) ? chain[j - 1].position : a.wrist.position);
			return (val.position - val2) * 0.7f;
		}
	}
	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 b