Decompiled source of Ultratrix v1.0.1

plugins/Ultratrix.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnemyTransform.Forms;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EnemyTransform
{
	internal sealed class DeviceWeapon : MonoBehaviour
	{
		private RenderTexture screenTex;

		private Light screenLight;

		private Transform armRoot;

		private Transform armMesh;

		private Transform body;

		private Transform face;

		private AudioSource audioSource;

		private float wristRadius = 0.05f;

		private float flash;

		private float bob;

		private float denyTime;

		private bool wasCooling;

		private float spinT = 1f;

		private float spinDir = 1f;

		private bool swapPending;

		private bool latchPending;

		private const float CuffInnerRadius = 0.94f;

		private const float CuffHalfLength = 0.84f;

		private const float CaseTop = 1.3f;

		private const float SpinTime = 0.4f;

		private Transform spawnerArm;

		private Transform armBone;

		private Animator armAnimator;

		public static string ArmPoseParam = "Holding";

		private static readonly string[] ArmPoseParams = new string[5] { "Manipulating", "Holding", "SemiHolding", "Point", "Pinched" };

		private Transform armHand;

		private SkinnedMeshRenderer armSmr;

		private bool needsFit;

		private Vector3 fitCenterLocal;

		private Vector3 fitAxisLocal;

		private Vector3 fitPerpLocal;

		private float fitRadiusLocal;

		public static int SlotIndex { get; private set; } = 7;

		public static DeviceWeapon Install(GunControl gc)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FirstWeapon(gc);
			int num = (Object.op_Implicit((Object)(object)val) ? val.layer : ((Component)gc).gameObject.layer);
			GameObject val2 = new GameObject("Wrist Device");
			val2.SetActive(false);
			val2.transform.SetParent(((Component)gc).transform, false);
			DeviceWeapon deviceWeapon = val2.AddComponent<DeviceWeapon>();
			deviceWeapon.Build(val, gc);
			SetLayer(val2.transform, num);
			WeaponIcon obj = val2.AddComponent<WeaponIcon>();
			Traverse.Create((object)obj).Field("variationColoredRenderers").SetValue((object)new Renderer[0]);
			Traverse.Create((object)obj).Field("variationColoredImages").SetValue((object)new Image[0]);
			obj.weaponDescriptor = ScriptableObject.CreateInstance<WeaponDescriptor>();
			obj.weaponDescriptor.weaponName = "WRIST DEVICE";
			obj.weaponDescriptor.icon = Icons.Device;
			obj.weaponDescriptor.glowIcon = Icons.Device;
			obj.weaponDescriptor.variationColor = (WeaponVariant)2;
			gc.slots.Add(new List<GameObject> { val2 });
			SlotIndex = gc.slots.Count;
			gc.UpdateWeaponList(false);
			Plugin.Log.LogInfo((object)string.Format("Wrist device installed in slot {0} (layer {1}, template {2})", SlotIndex, num, Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "none"));
			return deviceWeapon;
		}

		public static GameObject FirstWeapon(GunControl gc)
		{
			foreach (List<GameObject> slot in gc.slots)
			{
				foreach (GameObject item in slot)
				{
					if (Object.op_Implicit((Object)(object)item) && !Object.op_Implicit((Object)(object)item.GetComponent<DeviceWeapon>()))
					{
						return item;
					}
				}
			}
			return null;
		}

		private static void SetLayer(Transform t, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			((Component)t).gameObject.layer = layer;
			foreach (Transform item in t)
			{
				SetLayer(item, layer);
			}
		}

		private void Build(GameObject template, GunControl gc)
		{
			//IL_0006: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			armRoot = new GameObject("ArmPivot").transform;
			armRoot.SetParent(((Component)this).transform, false);
			armRoot.localPosition = Pose.ArmPos;
			if (!BuildSpawnerArm())
			{
				BuildArm();
			}
			Material val = BodyMaterial(template);
			screenTex = new RenderTexture(128, 128, 0)
			{
				filterMode = (FilterMode)0
			};
			Material val2 = new Material(Shader.Find("Unlit/Texture") ?? Shader.Find("Sprites/Default"))
			{
				mainTexture = (Texture)(object)screenTex
			};
			body = new GameObject("Watch").transform;
			body.SetParent(armRoot, false);
			AddModel(body, "device_body.obj", val, val2);
			Transform transform = new GameObject("Face").transform;
			transform.SetParent(body, false);
			transform.localPosition = new Vector3(0f, 1.3f, 0f);
			face = new GameObject("Bezel").transform;
			face.SetParent(transform, false);
			List<string> materialNames;
			Mesh src = ObjModel.Load(ObjModel.AssetPath("device_face.obj"), out materialNames);
			for (int i = 0; i < materialNames.Count; i++)
			{
				bool flag = materialNames[i] == "Screen";
				AddPart(flag ? transform : face, flag ? "Screen" : "BezelRing", ObjModel.ExtractSubmesh(src, i), flag ? val2 : val);
			}
			screenLight = new GameObject("ScreenLight").AddComponent<Light>();
			((Component)screenLight).transform.SetParent(transform, false);
			((Component)screenLight).transform.localPosition = new Vector3(0f, 0.6f, 0f);
			screenLight.type = (LightType)2;
			screenLight.range = 0.5f;
			screenLight.intensity = 1.5f;
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.playOnAwake = false;
			audioSource.spatialBlend = 0f;
			audioSource.volume = 0.6f;
			AudioSource component = ((Component)gc).GetComponent<AudioSource>();
			if (Object.op_Implicit((Object)(object)component))
			{
				audioSource.outputAudioMixerGroup = component.outputAudioMixerGroup;
			}
			WristDevice.SelectionChanged += OnSelectionChanged;
			Refresh();
		}

		private static Material BodyMaterial(GameObject template)
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00e2: 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_013c: 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)
			Material val = null;
			CheatsController instance = MonoSingleton<CheatsController>.Instance;
			GameObject[] array = (GameObject[])(object)new GameObject[2]
			{
				Object.op_Implicit((Object)(object)instance) ? instance.spawnerArm : null,
				template
			};
			foreach (GameObject val2 in array)
			{
				if (!Object.op_Implicit((Object)(object)val2) || Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val3 in componentsInChildren)
				{
					if (Object.op_Implicit((Object)(object)val3.sharedMaterial) && Object.op_Implicit((Object)(object)val3.sharedMaterial.shader) && ((Object)val3.sharedMaterial.shader).name == "ULTRAKILL/Master")
					{
						val = val3.sharedMaterial;
						break;
					}
				}
			}
			Material val4 = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(Shader.Find("ULTRAKILL/Master") ?? Shader.Find("Standard")));
			string[] texturePropertyNames = val4.GetTexturePropertyNames();
			foreach (string text in texturePropertyNames)
			{
				val4.SetTexture(text, (Texture)null);
			}
			val4.mainTexture = (Texture)(object)ObjModel.LoadTexture(ObjModel.AssetPath("device_atlas.png"));
			val4.mainTextureScale = Vector2.one;
			val4.mainTextureOffset = Vector2.zero;
			val4.color = new Color(0.72f, 0.72f, 0.74f);
			return val4;
		}

		private static void AddModel(Transform parent, string file, Material bodyMat, Material screenMat)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			List<string> materialNames;
			Mesh sharedMesh = ObjModel.Load(ObjModel.AssetPath(file), out materialNames);
			GameObject val = new GameObject(Path.GetFileNameWithoutExtension(file));
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			Material[] array = (Material[])(object)new Material[materialNames.Count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = ((materialNames[i] == "Screen") ? screenMat : bodyMat);
			}
			((Renderer)val2).sharedMaterials = array;
		}

		private static void AddPart(Transform parent, string name, Mesh mesh, Material mat)
		{
			//IL_0001: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).sharedMaterial = mat;
		}

		private bool BuildSpawnerArm()
		{
			CheatsController instance = MonoSingleton<CheatsController>.Instance;
			GameObject val = (Object.op_Implicit((Object)(object)instance) ? instance.spawnerArm : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform, false);
			((Object)val2).name = "V1 Right Arm";
			val2.SetActive(true);
			MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Canvas[] componentsInChildren2 = val2.GetComponentsInChildren<Canvas>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Component)componentsInChildren2[i]).gameObject.SetActive(false);
			}
			TrailRenderer[] componentsInChildren3 = val2.GetComponentsInChildren<TrailRenderer>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				((Renderer)componentsInChildren3[i]).enabled = false;
			}
			Animator component = val2.GetComponent<Animator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.fireEvents = false;
				component.cullingMode = (AnimatorCullingMode)0;
			}
			armAnimator = component;
			spawnerArm = val2.transform;
			SkinnedMeshRenderer componentInChildren = val2.GetComponentInChildren<SkinnedMeshRenderer>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.updateWhenOffscreen = true;
			}
			Transform val3 = null;
			Transform val4 = null;
			Transform[] componentsInChildren4 = val2.GetComponentsInChildren<Transform>(true);
			foreach (Transform val5 in componentsInChildren4)
			{
				if (((Object)val5).name == "Forearm")
				{
					val3 = val5;
				}
				else if (((Object)val5).name == "Hand")
				{
					val4 = val5;
				}
			}
			if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4))
			{
				Plugin.Log.LogWarning((object)"Spawner arm has no Forearm/Hand bones");
				Object.Destroy((Object)(object)val2);
				spawnerArm = null;
				return false;
			}
			armBone = val3;
			armHand = val4;
			armSmr = componentInChildren;
			needsFit = true;
			return true;
		}

		private void FitWatchToArm()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_007b: 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_0084: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: 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_023f: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: 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_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: 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)
			SkinnedMeshRenderer obj = armSmr;
			Mesh sharedMesh = obj.sharedMesh;
			Transform[] bones = obj.bones;
			Matrix4x4[] bindposes = sharedMesh.bindposes;
			int num = Array.IndexOf(bones, armBone);
			int num2 = Array.IndexOf(bones, armHand);
			if (num < 0 || num2 < 0 || num >= bindposes.Length || num2 >= bindposes.Length)
			{
				Plugin.Log.LogWarning((object)"Arm bones not in the skin; cannot fit the watch");
				return;
			}
			Matrix4x4 val = bindposes[num];
			Matrix4x4 inverse = ((Matrix4x4)(ref bindposes[num2])).inverse;
			Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero));
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			Vector3[] vertices = sharedMesh.vertices;
			for (int i = 0; i < vertices.Length; i++)
			{
				vertices[i] = ((Matrix4x4)(ref val)).MultiplyPoint3x4(vertices[i]);
			}
			Vector3 val3 = Vector3.zero;
			int num3 = 0;
			Vector3[] array = vertices;
			foreach (Vector3 val4 in array)
			{
				float num4 = Vector3.Dot(val4, normalized);
				Vector3 val5 = val4 - normalized * num4;
				if (!(num4 < magnitude * 0.6f) && !(num4 > magnitude * 0.95f) && !(((Vector3)(ref val5)).magnitude > magnitude * 0.6f))
				{
					val3 += val5;
					num3++;
				}
			}
			Vector3 val6 = ((num3 > 0) ? (val3 / (float)num3) : Vector3.zero);
			float num5 = 0f;
			array = vertices;
			foreach (Vector3 val7 in array)
			{
				float num6 = Vector3.Dot(val7, normalized);
				Vector3 val8 = val7 - normalized * num6 - val6;
				if (!(num6 < magnitude * 0.6f) && !(num6 > magnitude * 0.95f) && !(((Vector3)(ref val8)).magnitude > magnitude * 0.6f))
				{
					num5 += ((Vector3)(ref val8)).magnitude;
				}
			}
			float num7 = ((num3 > 0) ? (num5 / (float)num3) : (magnitude * 0.15f));
			float num8 = 0.84f * (num7 * 1.3f / 0.94f);
			float num9 = Mathf.Min(magnitude * 0.78f, magnitude * 0.95f - num8);
			List<float> list = new List<float>();
			array = vertices;
			foreach (Vector3 val9 in array)
			{
				float num10 = Vector3.Dot(val9, normalized);
				if (!(Mathf.Abs(num10 - num9) > num8))
				{
					Vector3 val10 = val9 - normalized * num10 - val6;
					if (!(((Vector3)(ref val10)).magnitude > num7 * 2.5f))
					{
						list.Add(((Vector3)(ref val10)).magnitude);
					}
				}
			}
			list.Sort();
			float num11 = ((list.Count > 0) ? (list[Mathf.Min(list.Count - 1, (int)((float)list.Count * 0.95f))] * 1.06f) : (num7 * 1.3f));
			num11 = Mathf.Clamp(num11, num7, num7 * 1.8f);
			fitCenterLocal = normalized * num9 + val6;
			fitAxisLocal = normalized;
			Vector3 val11 = Vector3.Cross(normalized, (Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.9f) ? Vector3.right : Vector3.up);
			fitPerpLocal = ((Vector3)(ref val11)).normalized;
			fitRadiusLocal = num11;
			Plugin.Log.LogInfo((object)$"Watch fitted (forearm bone space): length {magnitude:0.####}, avg wrist radius {num7:0.####}, cuff radius {num11:0.####} ({list.Count} verts in cuff span, {num3} in wrist slice)");
		}

		private void BuildArm()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_011b: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0175: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: 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_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: 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_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: 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_0319: 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_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			FistControl instance = MonoSingleton<FistControl>.Instance;
			SkinnedMeshRenderer val = null;
			Transform val2 = null;
			Transform val3 = null;
			if (Object.op_Implicit((Object)(object)instance))
			{
				Transform[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Transform>(true);
				foreach (Transform val4 in componentsInChildren)
				{
					if (!(((Object)val4).name == "Feedbacker") || !Object.op_Implicit((Object)(object)((Component)val4).GetComponent<Animator>()))
					{
						continue;
					}
					val = ((Component)val4).GetComponentInChildren<SkinnedMeshRenderer>(true);
					if (!Object.op_Implicit((Object)(object)val))
					{
						break;
					}
					Transform[] bones = val.bones;
					foreach (Transform val5 in bones)
					{
						if (Object.op_Implicit((Object)(object)val5))
						{
							if (((Object)val5).name == "Forearm")
							{
								val2 = val5;
							}
							else if (((Object)val5).name == "Hand")
							{
								val3 = val5;
							}
						}
					}
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				Plugin.Log.LogWarning((object)"Feedbacker arm not found; watch shown without an arm");
				return;
			}
			Mesh val6 = new Mesh
			{
				name = "V1 Right Arm"
			};
			val.BakeMesh(val6, true);
			Transform transform = ((Component)val).transform;
			Vector3 val7 = transform.InverseTransformPoint(val2.position);
			Vector3 val8 = transform.InverseTransformPoint(val3.position);
			Vector3 val9 = val8 - val7;
			Vector3 normalized = ((Vector3)(ref val9)).normalized;
			float num = Vector3.Distance(val7, val8);
			Vector3[] vertices = val6.vertices;
			Vector3 val10 = Vector3.zero;
			int num2 = 0;
			Vector3[] array = vertices;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val11 = array[i] - val7;
				float num3 = Vector3.Dot(val11, normalized) / num;
				Vector3 val12 = val11 - normalized * Vector3.Dot(val11, normalized);
				if (!(num3 < 0.7f) && !(num3 > 0.95f) && !(((Vector3)(ref val12)).magnitude > num * 0.6f))
				{
					val10 += val12;
					num2++;
				}
			}
			Vector3 val13 = ((num2 > 0) ? (val10 / (float)num2) : Vector3.zero);
			float num4 = 0f;
			array = vertices;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val14 = array[i] - val7;
				float num5 = Vector3.Dot(val14, normalized) / num;
				Vector3 val15 = val14 - normalized * Vector3.Dot(val14, normalized) - val13;
				if (!(num5 < 0.7f) && !(num5 > 0.95f) && !(((Vector3)(ref val15)).magnitude > num * 0.6f))
				{
					num4 += ((Vector3)(ref val15)).magnitude;
				}
			}
			float num6 = ((num2 > 0) ? (num4 / (float)num2) : (num * 0.15f));
			float num7 = 0.84f * (num6 * 1.3f / 0.94f);
			float num8 = Mathf.Min(num * 0.8f, num * 0.95f - num7);
			List<float> list = new List<float>();
			array = vertices;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val16 = array[i] - val7;
				float num9 = Vector3.Dot(val16, normalized);
				if (!(Mathf.Abs(num9 - num8) > num7))
				{
					Vector3 val17 = val16 - normalized * num9 - val13;
					if (!(((Vector3)(ref val17)).magnitude > num6 * 2.5f))
					{
						list.Add(((Vector3)(ref val17)).magnitude);
					}
				}
			}
			list.Sort();
			float num10 = ((list.Count > 0) ? (list[Mathf.Min(list.Count - 1, (int)((float)list.Count * 0.95f))] * 1.06f) : (num6 * 1.3f));
			num10 = Mathf.Clamp(num10, num6, num6 * 1.8f);
			Vector3 val18 = val7 + normalized * num8 + val13;
			float num11 = transform.lossyScale.x / Mathf.Max(1E-06f, ((Component)this).transform.lossyScale.x);
			wristRadius = num10 * num11;
			Plugin.Log.LogInfo((object)$"Arm baked: forearm {num * num11:0.###}, avg wrist radius {num6 * num11:0.###}, cuff fit radius {wristRadius:0.###} at {num8 / num:P0} ({list.Count} verts), scale {num11:0.####}");
			Transform transform2 = new GameObject("RightArmMirror").transform;
			transform2.SetParent(armRoot, false);
			transform2.localScale = new Vector3(-1f, 1f, 1f);
			armMesh = new GameObject("ArmRoll").transform;
			armMesh.SetParent(transform2, false);
			Quaternion val19 = Quaternion.Inverse(Quaternion.LookRotation(normalized, (Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up));
			GameObject val20 = new GameObject("ArmMesh");
			val20.transform.SetParent(armMesh, false);
			val20.transform.localScale = Vector3.one * num11;
			val20.transform.localRotation = val19;
			val20.transform.localPosition = -(val19 * val18) * num11;
			val20.AddComponent<MeshFilter>().sharedMesh = val6;
			MeshRenderer obj = val20.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterials = ((Renderer)val).sharedMaterials;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		}

		private void OnSelectionChanged()
		{
			if (!Object.op_Implicit((Object)(object)this))
			{
				WristDevice.SelectionChanged -= OnSelectionChanged;
				return;
			}
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				Refresh();
				return;
			}
			spinDir = ((WristDevice.LastCycleDir >= 0) ? 1f : (-1f));
			spinT = 0f;
			swapPending = true;
			Sfx.PlayGame(audioSource, "QuickTwirl");
			latchPending = true;
		}

		private void Refresh()
		{
			//IL_003f: 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_00a4: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)screenTex))
			{
				return;
			}
			EnemyType? val = (Object.op_Implicit((Object)(object)WristDevice.Instance) ? WristDevice.Instance.Selected : ((EnemyType?)null));
			SpawnableObject val2 = (val.HasValue ? Prefabs.Spawnable(val.Value) : null);
			bool cooling = Object.op_Implicit((Object)(object)Transformation.Instance) && Transformation.Instance.CooldownLeft > 0f;
			DrawScreen(val2, val.HasValue && !Form.Playable(val.Value), cooling);
			screenLight.color = (Object.op_Implicit((Object)(object)val2) ? val2.backgroundColor : Color.red);
			WeaponIcon component = ((Component)this).GetComponent<WeaponIcon>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.weaponDescriptor))
			{
				component.weaponDescriptor.icon = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.gridIcon)) ? val2.gridIcon : Icons.Device);
				component.weaponDescriptor.glowIcon = component.weaponDescriptor.icon;
				HudIconColors.Glow = (Object.op_Implicit((Object)(object)val2) ? val2.backgroundColor : Color.red);
				if (((Behaviour)this).isActiveAndEnabled)
				{
					component.UpdateIcon();
				}
			}
			flash = 1f;
		}

		private void DrawScreen(SpawnableObject so, bool notPlayable, bool cooling)
		{
			//IL_004d: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007b: 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_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_01a0: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = screenTex;
			GL.PushMatrix();
			GL.LoadPixelMatrix(0f, 128f, 128f, 0f);
			Color val = (Color)(Object.op_Implicit((Object)(object)so) ? so.backgroundColor : new Color(0.05f, 0.05f, 0.05f));
			if (cooling)
			{
				val *= 0.35f;
			}
			GL.Clear(true, true, new Color(val.r, val.g, val.b, 1f));
			if (Object.op_Implicit((Object)(object)so) && Object.op_Implicit((Object)(object)so.gridIcon))
			{
				Sprite gridIcon = so.gridIcon;
				Texture2D texture = gridIcon.texture;
				Rect textureRect = gridIcon.textureRect;
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
				Color val3 = (Color)(notPlayable ? new Color(0.35f, 0.35f, 0.35f, 1f) : (cooling ? new Color(0.45f, 0.45f, 0.45f, 1f) : Color.white));
				Graphics.DrawTexture(new Rect(10f, 10f, 108f, 108f), (Texture)(object)texture, val2, 0, 0, 0, 0, val3 * 0.5f);
			}
			if (cooling)
			{
				Graphics.DrawTexture(new Rect(14f, 104f, 100f * (Transformation.Instance.CooldownLeft / Mathf.Max(0.01f, Plugin.Cooldown.Value)), 10f), (Texture)(object)Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(1f, 0.15f, 0.1f, 0.5f));
			}
			GL.PopMatrix();
			RenderTexture.active = active;
		}

		public void Deny()
		{
			denyTime = 0.35f;
		}

		public void ApplyArmPose()
		{
			if (!Object.op_Implicit((Object)(object)armAnimator) || !((Behaviour)armAnimator).isActiveAndEnabled)
			{
				return;
			}
			string[] armPoseParams = ArmPoseParams;
			foreach (string text in armPoseParams)
			{
				if (armAnimator.GetBool(text) != (text == ArmPoseParam))
				{
					armAnimator.SetBool(text, text == ArmPoseParam);
				}
			}
		}

		private void OnEnable()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			ApplyArmPose();
			Refresh();
			bob = 0f;
			spinT = 1f;
			if (Object.op_Implicit((Object)(object)armRoot))
			{
				armRoot.localPosition = Pose.ArmPos + new Vector3(0.1f, -0.6f, 0f);
			}
		}

		private void OnDestroy()
		{
			WristDevice.SelectionChanged -= OnSelectionChanged;
		}

		private void Update()
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			Transformation instance = Transformation.Instance;
			if (Object.op_Implicit((Object)(object)instance) && instance.Active)
			{
				return;
			}
			ApplyArmPose();
			bool flag = Object.op_Implicit((Object)(object)instance) && instance.CooldownLeft > 0f;
			if ((flag || wasCooling) && !swapPending)
			{
				Refresh();
			}
			wasCooling = flag;
			GunControl instance2 = MonoSingleton<GunControl>.Instance;
			if (!WristDevice.Paused() && Object.op_Implicit((Object)(object)instance2) && instance2.activated)
			{
				PlayerInput inputSource = MonoSingleton<InputManager>.Instance.InputSource;
				float num = ((Mouse.current != null) ? ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y : 0f);
				if (MonoSingleton<InputManager>.Instance.ScrRev)
				{
					num = 0f - num;
				}
				if (num > 0f)
				{
					WristDevice.Instance.Cycle(1);
				}
				else if (num < 0f)
				{
					WristDevice.Instance.Cycle(-1);
				}
				else if (inputSource.Fire1.WasPerformedThisFrame)
				{
					WristDevice.Instance.Toggle();
				}
			}
			bob += Time.deltaTime;
			Vector3 val = Pose.ArmPos + new Vector3(0f, Mathf.Sin(bob * 1.6f) * 0.006f, 0f);
			if (denyTime > 0f)
			{
				denyTime -= Time.deltaTime;
				val += new Vector3(Mathf.Sin(Time.time * 70f) * 0.01f, 0f, 0f);
			}
			if (Object.op_Implicit((Object)(object)spawnerArm))
			{
				((Component)this).transform.localPosition = (Vector3)((denyTime > 0f) ? new Vector3(Mathf.Sin(Time.time * 70f) * 0.02f, 0f, 0f) : Vector3.zero);
			}
			else
			{
				armRoot.localPosition = Vector3.Lerp(armRoot.localPosition, val, 1f - Mathf.Exp(-14f * Time.deltaTime));
			}
			if (spinT < 1f)
			{
				spinT = Mathf.Min(1f, spinT + Time.deltaTime / 0.4f);
				if (swapPending && spinT >= 0.35f)
				{
					swapPending = false;
					Refresh();
				}
				if (latchPending && spinT >= 0.8f)
				{
					latchPending = false;
					Sfx.PlayGame(audioSource, "CSFX-2_Mechanics_45");
				}
			}
			float num2 = 1f - Mathf.Pow(1f - spinT, 3f);
			face.localRotation = Quaternion.Euler(0f, spinDir * 360f * num2, 0f);
			flash = Mathf.MoveTowards(flash, 0f, Time.deltaTime * 4f);
			screenLight.intensity = 1.5f + flash * 3f;
		}

		private void LateUpdate()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//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)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: 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_00c2: 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_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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_017f: 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_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_00ea: 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_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)armBone) && needsFit)
			{
				FitWatchToArm();
				needsFit = false;
				((Component)body).gameObject.SetActive(true);
			}
			Vector3 val2;
			if (Object.op_Implicit((Object)(object)armBone))
			{
				Vector3 val = armBone.TransformPoint(fitCenterLocal);
				val2 = armBone.TransformDirection(fitAxisLocal);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				val2 = armBone.TransformVector(fitPerpLocal * fitRadiusLocal);
				float magnitude = ((Vector3)(ref val2)).magnitude;
				Vector3 val3 = Vector3.ProjectOnPlane((Object.op_Implicit((Object)(object)MonoSingleton<CameraController>.Instance) ? ((Component)MonoSingleton<CameraController>.Instance.cam).transform.position : ((Component)this).transform.position) - val, normalized);
				if (((Vector3)(ref val3)).sqrMagnitude < 1E-08f)
				{
					val3 = Vector3.ProjectOnPlane(((Component)this).transform.up, normalized);
				}
				Quaternion val4 = Quaternion.LookRotation(normalized, ((Vector3)(ref val3)).normalized) * Quaternion.Euler(0f, 180f, 0f) * Quaternion.Euler(Pose.DevRot);
				float num = magnitude / 0.94f * Pose.DevScale;
				body.position = val + val4 * Pose.DevPos * num;
				body.rotation = val4;
				body.localScale = Vector3.one * (num / Mathf.Max(1E-06f, ((Component)this).transform.lossyScale.x));
			}
			else
			{
				Vector3 val5 = ((((Vector3)(ref Pose.ArmDir)).sqrMagnitude > 0f) ? ((Vector3)(ref Pose.ArmDir)).normalized : Vector3.forward);
				val2 = armRoot.localPosition;
				Vector3 val6 = Vector3.ProjectOnPlane(-((Vector3)(ref val2)).normalized, val5);
				if (((Vector3)(ref val6)).sqrMagnitude < 0.0001f)
				{
					val6 = Vector3.up;
				}
				armRoot.localRotation = Quaternion.LookRotation(val5, val6) * Quaternion.Euler(Pose.ArmRot);
				if (Object.op_Implicit((Object)(object)armMesh))
				{
					armMesh.localRotation = Quaternion.Euler(0f, 0f, Pose.Roll);
				}
				body.localPosition = Pose.DevPos;
				body.localRotation = Quaternion.Euler(0f, 180f, 0f) * Quaternion.Euler(Pose.DevRot);
				body.localScale = Vector3.one * (wristRadius / 0.94f * Pose.DevScale);
			}
		}
	}
	[HarmonyPatch(typeof(GunControl), "Update")]
	internal static class DeviceOwnsScrollWheel
	{
		private static readonly FieldRef<GunControl, float> scrollCooldown = AccessTools.FieldRefAccess<GunControl, float>("scrollCooldown");

		private static void Prefix(GunControl __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.currentWeapon) && Object.op_Implicit((Object)(object)__instance.currentWeapon.GetComponent<DeviceWeapon>()))
			{
				scrollCooldown.Invoke(__instance) = 1f;
			}
		}
	}
	[HarmonyPatch(typeof(WeaponHUD), "UpdateImage")]
	internal static class HudIconColors
	{
		public static Color Glow = Color.red;

		private static bool? originalAspect;

		private static void Postfix(WeaponHUD __instance)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			Image component = ((Component)__instance).GetComponent<Image>();
			Image val = ((((Component)__instance).transform.childCount > 0) ? ((Component)((Component)__instance).transform.GetChild(0)).GetComponent<Image>() : null);
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			bool valueOrDefault = originalAspect == true;
			if (!originalAspect.HasValue)
			{
				valueOrDefault = component.preserveAspect;
				originalAspect = valueOrDefault;
			}
			GunControl instance = MonoSingleton<GunControl>.Instance;
			bool flag = Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.currentWeapon) && Object.op_Implicit((Object)(object)instance.currentWeapon.GetComponent<DeviceWeapon>()) && (Object)(object)component.sprite != (Object)(object)Icons.Device;
			component.preserveAspect = flag || originalAspect.Value;
			if (Object.op_Implicit((Object)(object)val))
			{
				val.preserveAspect = component.preserveAspect;
			}
			if (flag)
			{
				((Graphic)component).color = Color.white;
				if (Object.op_Implicit((Object)(object)val))
				{
					((Graphic)val).color = new Color(Glow.r, Glow.g, Glow.b, 0.8f);
				}
			}
		}
	}
	internal static class Pose
	{
		public static Vector3 ArmPos = new Vector3(0.62f, -0.58f, 1.35f);

		public static Vector3 ArmDir = new Vector3(-0.6f, 0.35f, 0.7f);

		public static Vector3 ArmRot = Vector3.zero;

		public static float Roll = 270f;

		public static Vector3 DevPos = Vector3.zero;

		public static Vector3 DevRot = Vector3.zero;

		public static float DevScale = 1f;

		public static string Set(string part, float x, float y, float z)
		{
			//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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(x, y, z);
			switch (part.ToLowerInvariant())
			{
			case "armpos":
				ArmPos = val;
				break;
			case "armrot":
				ArmRot = val;
				break;
			case "armdir":
				ArmDir = val;
				break;
			case "roll":
				Roll = x;
				break;
			case "devpos":
				DevPos = val;
				break;
			case "devrot":
				DevRot = val;
				break;
			case "devscale":
				DevScale = x;
				break;
			default:
				return "parts: armpos armdir armrot roll devpos devrot devscale";
			}
			return Dump();
		}

		public static string Dump()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			return $"armpos={ArmPos} armdir={ArmDir} armrot={ArmRot} roll={Roll} devpos={DevPos} devrot={DevRot} devscale={DevScale}";
		}
	}
	internal static class Icons
	{
		private static Sprite device;

		public static Sprite Device
		{
			get
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_010a: 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_00cd: 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)
				if (Object.op_Implicit((Object)(object)device))
				{
					return device;
				}
				Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
				{
					filterMode = (FilterMode)0
				};
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(1f, 1f, 1f, 0f);
				for (int i = 0; i < 64; i++)
				{
					for (int j = 0; j < 64; j++)
					{
						bool num = j >= 24 && j < 40;
						bool flag = j >= 12 && j < 52 && i >= 18 && i < 46;
						bool flag2 = j >= 17 && j < 47 && i >= 23 && i < 41;
						bool flag3 = (num || flag) && !flag2;
						bool flag4 = flag2 && (j - 17) % 6 < 3 && (i - 23) % 6 < 3 && (j + i) % 12 < 6;
						val.SetPixel(j, i, (flag3 || flag4) ? Color.white : val2);
					}
				}
				val.Apply();
				device = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
				return device;
			}
		}
	}
	internal sealed class EnemyCard : MonoBehaviour
	{
		private const float PickupRadius = 2.5f;

		public EnemyType Type;

		private Vector3 basePos;

		private float t;

		private static readonly List<EnemyCard> live = new List<EnemyCard>();

		public static bool OnGround(EnemyType type)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return live.Exists((EnemyCard c) => Object.op_Implicit((Object)(object)c) && c.Type == type);
		}

		private void OnEnable()
		{
			live.Add(this);
		}

		private void OnDisable()
		{
			live.Remove(this);
		}

		public static EnemyCard Spawn(EnemyType type, Vector3 pos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: 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_007d: 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_00c1: 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_00d8: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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)
			GameObject val = new GameObject($"EnemyCard ({type})");
			val.transform.position = pos;
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.transform.SetParent(val.transform, false);
			obj.transform.localScale = new Vector3(0.7f, 1f, 0.06f);
			((Renderer)obj.GetComponent<MeshRenderer>()).material.color = new Color(1f, 0.15f, 0.1f);
			Light obj2 = val.AddComponent<Light>();
			obj2.color = new Color(1f, 0.3f, 0.2f);
			obj2.range = 6f;
			obj2.intensity = 3f;
			GameObject val2 = new GameObject("Label");
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			TextMesh val3 = val2.AddComponent<TextMesh>();
			val3.text = Names.Pretty(type).ToUpperInvariant();
			val3.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			((Renderer)((Component)val3).GetComponent<MeshRenderer>()).material = val3.font.material;
			val3.anchor = (TextAnchor)7;
			val3.characterSize = 0.08f;
			val3.fontSize = 48;
			val3.color = Color.white;
			EnemyCard enemyCard = val.AddComponent<EnemyCard>();
			enemyCard.Type = type;
			enemyCard.basePos = pos;
			return enemyCard;
		}

		private void Update()
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			t += Time.deltaTime;
			((Component)this).transform.position = basePos + Vector3.up * (Mathf.Sin(t * 2.5f) * 0.2f);
			((Component)this).transform.GetChild(0).Rotate(Vector3.up, 120f * Time.deltaTime, (Space)0);
			Camera main = Camera.main;
			if (Object.op_Implicit((Object)(object)main))
			{
				((Component)this).transform.GetChild(1).rotation = Quaternion.LookRotation(((Component)this).transform.GetChild(1).position - ((Component)main).transform.position);
			}
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if (Object.op_Implicit((Object)(object)instance) && !instance.dead && Vector3.Distance(((Component)instance).transform.position, ((Component)this).transform.position) < 2.5f)
			{
				PickUp();
			}
		}

		private void PickUp()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Unlocks.Unlock(Type);
			if (flag)
			{
				Hud.Toast("<color=#FF4343>ENEMY CARD</color>: " + Names.Pretty(Type).ToUpperInvariant());
			}
			if (flag)
			{
				StyleHUD instance = MonoSingleton<StyleHUD>.Instance;
				if (instance != null)
				{
					instance.AddPoints(100, "<color=red>ENEMY CARD</color>", (GameObject)null, (EnemyIdentifier)null, -1, "", "");
				}
			}
			Plugin.Log.LogInfo((object)$"Picked up card {Type} (new: {flag})");
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "ProcessDeath")]
	internal static class DropCardOnDeath
	{
		private static void Postfix(EnemyIdentifier __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.puppet && !__instance.dontCountAsKills && !Puppet.Is(__instance) && !Unlocks.Has(__instance.enemyType) && !EnemyCard.OnGround(__instance.enemyType) && !(Random.value >= Plugin.DropChance.Value))
			{
				Vector3 pos = (Object.op_Implicit((Object)(object)__instance.overrideCenter) ? __instance.overrideCenter.position : (((Component)__instance).transform.position + Vector3.up * 1.5f));
				EnemyCard.Spawn(__instance.enemyType, pos);
				Plugin.Log.LogInfo((object)$"{__instance.enemyType} dropped a card");
			}
		}
	}
	internal sealed class FpRigSpec
	{
		public string[] Collapse;

		public string[][] Chains;
	}
	[DefaultExecutionOrder(10000)]
	internal sealed class FirstPersonArms : MonoBehaviour
	{
		private sealed class Arm
		{
			public int Side;

			public Transform Upper;

			public Transform Lower;

			public Transform Wrist;

			public Quaternion UpperRest;

			public Quaternion LowerRest;

			public Quaternion WristRest;

			public Vector3 UpperScale;

			public float A;

			public float B;

			public Vector3 Target;

			public Vector3 Velocity;

			public readonly Queue<(float dur, Vector3 pos)> Keys = new Queue<(float, Vector3)>();

			public float KeyT;

			public Vector3 KeyFrom;

			public bool Holding;
		}

		public static Vector3 Shoulder = new Vector3(0.42f, -0.52f, -0.08f);

		public static Vector3 Guard = new Vector3(0.36f, -0.38f, 0.6f);

		public static Vector3 Pole = new Vector3(0.9f, -1f, -0.4f);

		public static float Reach = 0.82f;

		public static float Twist = 90f;

		private Transform srcRoot;

		private Transform copyRoot;

		private Transform[] collapse;

		private readonly Arm[] arms = new Arm[2];

		private Renderer[] renderers;

		private bool visible;

		public FormCamera View;

		private float bob;

		private static readonly Vector3 G = new Vector3(0.36f, -0.38f, 0.6f);

		public static FirstPersonArms Current { get; private set; }

		public bool Visible
		{
			get
			{
				return visible;
			}
			set
			{
				if (visible == value)
				{
					return;
				}
				visible = value;
				Renderer[] array = renderers;
				foreach (Renderer val in array)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						val.enabled = value;
					}
				}
			}
		}

		public static FirstPersonArms Attach(Puppet puppet, FpRigSpec spec, int layer)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: 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_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: 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_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			SkinnedMeshRenderer componentInChildren = ((Component)puppet).GetComponentInChildren<SkinnedMeshRenderer>(true);
			if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)((Component)componentInChildren).transform.parent) || spec == null)
			{
				return null;
			}
			Transform parent = ((Component)componentInChildren).transform.parent;
			GameObject val = new GameObject("FpArmsHolder");
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)parent).gameObject, val.transform, false);
			((Object)val2).name = ((Object)puppet).name + " (first-person arms)";
			Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren)
			{
				if (!(val3 is Transform) && !(val3 is SkinnedMeshRenderer) && !(val3 is MeshFilter) && !(val3 is MeshRenderer))
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			Transform[] componentsInChildren2 = val2.GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Component)componentsInChildren2[i]).gameObject.layer = layer;
			}
			val2.transform.SetParent((Transform)null, false);
			val2.transform.SetPositionAndRotation(parent.position, parent.rotation);
			val2.transform.localScale = parent.lossyScale;
			Object.Destroy((Object)(object)val);
			FirstPersonArms firstPersonArms = val2.AddComponent<FirstPersonArms>();
			firstPersonArms.srcRoot = parent;
			firstPersonArms.copyRoot = val2.transform;
			Transform[] all = val2.GetComponentsInChildren<Transform>(true);
			List<Transform> list = new List<Transform>();
			string[] array = spec.Collapse;
			for (int i = 0; i < array.Length; i++)
			{
				Transform val4 = Find(array[i]);
				if (val4 != null)
				{
					list.Add(val4);
				}
			}
			firstPersonArms.collapse = list.ToArray();
			for (int j = 0; j < 2; j++)
			{
				string[] array2 = spec.Chains[j];
				Arm arm = new Arm
				{
					Side = ((j != 0) ? 1 : (-1)),
					Upper = Find(array2[0]),
					Lower = Find(array2[1]),
					Wrist = Find(array2[2])
				};
				if (!Object.op_Implicit((Object)(object)arm.Upper) || !Object.op_Implicit((Object)(object)arm.Lower) || !Object.op_Implicit((Object)(object)arm.Wrist))
				{
					Plugin.Log.LogWarning((object)("First-person arms: chain " + string.Join("/", array2) + " not found"));
					Object.Destroy((Object)(object)val2);
					return null;
				}
				arm.UpperRest = arm.Upper.localRotation;
				arm.LowerRest = arm.Lower.localRotation;
				arm.WristRest = arm.Wrist.localRotation;
				arm.UpperScale = arm.Upper.lossyScale;
				arm.A = Vector3.Distance(arm.Upper.position, arm.Lower.position);
				arm.B = Vector3.Distance(arm.Lower.position, arm.Wrist.position);
				arm.Target = GuardFor(arm.Side);
				firstPersonArms.arms[j] = arm;
			}
			List<Renderer> list2 = new List<Renderer>();
			Renderer[] componentsInChildren3 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val5 in componentsInChildren3)
			{
				SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((val5 is SkinnedMeshRenderer) ? val5 : null);
				if (val6 != null)
				{
					val6.updateWhenOffscreen = true;
				}
				val5.shadowCastingMode = (ShadowCastingMode)0;
				val5.enabled = false;
				list2.Add(val5);
			}
			firstPersonArms.renderers = list2.ToArray();
			Current = firstPersonArms;
			Plugin.Log.LogInfo((object)$"First-person arms rig for {((Object)puppet).name}: arm lengths {firstPersonArms.arms[0].A:0.##}+{firstPersonArms.arms[0].B:0.##}");
			return firstPersonArms;
			Transform Find(string n)
			{
				Transform[] array3 = all;
				foreach (Transform val7 in array3)
				{
					if (((Object)val7).name == n)
					{
						return val7;
					}
				}
				return null;
			}
		}

		private static Vector3 Mirror(Vector3 v, int side)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			return new Vector3(v.x * (float)side, v.y, v.z);
		}

		private static Vector3 GuardFor(int side)
		{
			//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)
			return Mirror(Guard, side);
		}

		private Arm ArmFor(int side)
		{
			if (side >= 0)
			{
				return arms[1];
			}
			return arms[0];
		}

		private void Play(int side, bool hold, params (float dur, Vector3 pos)[] keys)
		{
			//IL_002e: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Arm arm = ArmFor(side);
			arm.Keys.Clear();
			for (int i = 0; i < keys.Length; i++)
			{
				(float, Vector3) tuple = keys[i];
				arm.Keys.Enqueue((tuple.Item1, Mirror(tuple.Item2, side)));
			}
			arm.KeyT = 0f;
			arm.KeyFrom = arm.Target;
			arm.Holding = hold;
		}

		public void Punch(int side)
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(side, hold: false, new(float, Vector3)[3]
			{
				(0.06f, new Vector3(0.1f, -0.16f, 1f)),
				(0.08f, new Vector3(0.1f, -0.16f, 1f)),
				(0.18f, G)
			});
		}

		public void Swing(int side)
		{
			//IL_001f: 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_0069: 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)
			Play(side, hold: false, new(float, Vector3)[4]
			{
				(0.07f, new Vector3(0.55f, -0.12f, 0.45f)),
				(0.09f, new Vector3(-0.12f, -0.2f, 0.9f)),
				(0.06f, new Vector3(-0.25f, -0.3f, 0.75f)),
				(0.2f, G)
			});
		}

		public void Uppercut()
		{
			//IL_001f: 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_0069: 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)
			Play(1, hold: false, new(float, Vector3)[4]
			{
				(0.08f, new Vector3(0.18f, -0.62f, 0.5f)),
				(0.1f, new Vector3(0.04f, 0.28f, 0.78f)),
				(0.1f, new Vector3(0.04f, 0.28f, 0.78f)),
				(0.25f, G)
			});
		}

		public void OverheadWindup()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: true, new(float, Vector3)[1] { (0.12f, new Vector3(0.24f, 0.32f, 0.42f)) });
			}
		}

		public void OverheadStrike(int side)
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(side, hold: false, new(float, Vector3)[3]
			{
				(0.08f, new Vector3(0.12f, -0.45f, 0.82f)),
				(0.1f, new Vector3(0.12f, -0.45f, 0.82f)),
				(0.22f, G)
			});
		}

		public void Charge()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Play(1, hold: true, new(float, Vector3)[1] { (0.15f, new Vector3(0.42f, -0.48f, 0.22f)) });
		}

		public void Throw()
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(1, hold: false, new(float, Vector3)[3]
			{
				(0.06f, new Vector3(0.04f, -0.1f, 1.05f)),
				(0.1f, new Vector3(0.04f, -0.1f, 1.05f)),
				(0.22f, G)
			});
		}

		public void Brace()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: true, new(float, Vector3)[1] { (0.12f, new Vector3(0.48f, -0.62f, 0.16f)) });
			}
		}

		public void SlamWindup()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: true, new(float, Vector3)[1] { (0.15f, new Vector3(0.2f, 0.3f, 0.38f)) });
			}
		}

		public void Slam()
		{
			//IL_0023: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: false, new(float, Vector3)[3]
				{
					(0.07f, new Vector3(0.16f, -0.62f, 0.7f)),
					(0.15f, new Vector3(0.16f, -0.62f, 0.7f)),
					(0.25f, G)
				});
			}
		}

		public void Hop()
		{
			//IL_0023: 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)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: false, new(float, Vector3)[2]
				{
					(0.1f, new Vector3(0.36f, -0.56f, 0.34f)),
					(0.3f, G)
				});
			}
		}

		public void Jolt()
		{
			//IL_0023: 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)
			for (int i = -1; i <= 1; i += 2)
			{
				Play(i, hold: false, new(float, Vector3)[2]
				{
					(0.04f, new Vector3(0.3f, -0.4f, 0.48f)),
					(0.12f, G)
				});
			}
		}

		public void GtPunchWindup()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Play(-1, hold: true, new(float, Vector3)[1] { (0.18f, new Vector3(0.42f, -0.5f, 0.3f)) });
		}

		public void GtPunch()
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(-1, hold: false, new(float, Vector3)[3]
			{
				(0.07f, new Vector3(0.08f, -0.18f, 1.05f)),
				(0.25f, new Vector3(0.08f, -0.18f, 1.05f)),
				(0.25f, G)
			});
		}

		public void GtAim()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Play(1, hold: true, new(float, Vector3)[1] { (0.2f, new Vector3(0.14f, -0.2f, 0.9f)) });
		}

		public void GtFire()
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(1, hold: false, new(float, Vector3)[3]
			{
				(0.04f, new Vector3(0.18f, -0.12f, 0.7f)),
				(0.2f, new Vector3(0.14f, -0.2f, 0.9f)),
				(0.3f, G)
			});
		}

		public void GtMine()
		{
			//IL_001f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Play(-1, hold: false, new(float, Vector3)[3]
			{
				(0.2f, new Vector3(0.25f, -0.75f, 0.45f)),
				(0.3f, new Vector3(0.25f, -0.75f, 0.45f)),
				(0.3f, G)
			});
		}

		public void Release()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				if (ArmFor(i).Holding)
				{
					Play(i, false, (0.2f, G));
				}
			}
		}

		private void Advance(Arm arm, float dt)
		{
			//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_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_00ed: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if (arm.Keys.Count == 0)
			{
				if (!arm.Holding)
				{
					Vector3 val = GuardFor(arm.Side) + new Vector3(0f, Mathf.Sin(bob * 2f + (float)arm.Side) * 0.01f, Mathf.Sin(bob * 1.3f) * 0.006f);
					arm.Target = Vector3.SmoothDamp(arm.Target, val, ref arm.Velocity, 0.08f, float.PositiveInfinity, dt);
				}
				return;
			}
			var (num, val2) = arm.Keys.Peek();
			arm.KeyT += dt;
			float num2 = Mathf.Clamp01(arm.KeyT / Mathf.Max(0.001f, num));
			float num3 = 1f - (1f - num2) * (1f - num2);
			arm.Target = Vector3.LerpUnclamped(arm.KeyFrom, val2, num3);
			arm.Velocity = Vector3.zero;
			if (num2 >= 1f)
			{
				arm.Keys.Dequeue();
				arm.KeyFrom = val2;
				arm.KeyT = 0f;
			}
		}

		private void LateUpdate()
		{
			//IL_00a4: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0172: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: 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_0221: 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_022c: 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_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: 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_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: 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_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: 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_033f: 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_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: 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_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: 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_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)srcRoot))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float deltaTime = Time.deltaTime;
			bob += deltaTime;
			Arm[] array = arms;
			foreach (Arm arm in array)
			{
				Advance(arm, deltaTime);
			}
			if (!visible)
			{
				return;
			}
			Transform val = (Object.op_Implicit((Object)(object)MonoSingleton<CameraController>.Instance) ? ((Component)MonoSingleton<CameraController>.Instance.cam).transform : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Vector3 val2 = (Object.op_Implicit((Object)(object)View) ? View.ViewPosition : val.position);
			Quaternion rotation = val.rotation;
			copyRoot.SetPositionAndRotation(val2 - rotation * Vector3.forward * 3f, rotation);
			Transform[] array2 = collapse;
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i].localScale = Vector3.one * 0.0001f;
			}
			array = arms;
			foreach (Arm arm2 in array)
			{
				float num = Reach / (arm2.A + arm2.B);
				float num2 = arm2.A * num;
				float num3 = arm2.B * num;
				Vector3 val3 = val2 + rotation * Mirror(Shoulder, arm2.Side);
				Vector3 val4 = val2 + rotation * arm2.Target;
				Vector3 val5 = rotation * Mirror(Pole, arm2.Side);
				Vector3 val6 = val4 - val3;
				float num4 = Mathf.Clamp(((Vector3)(ref val6)).magnitude, Mathf.Abs(num2 - num3) + 0.01f, num2 + num3 - 0.001f);
				Vector3 normalized = ((Vector3)(ref val6)).normalized;
				float num5 = Mathf.Clamp((num2 * num2 + num4 * num4 - num3 * num3) / (2f * num2 * num4), -1f, 1f);
				float num6 = Mathf.Sqrt(1f - num5 * num5);
				Vector3 val7 = Vector3.ProjectOnPlane(val5, normalized);
				Vector3 normalized2 = ((Vector3)(ref val7)).normalized;
				Vector3 val8 = val3 + (normalized * num5 + normalized2 * num6) * num2;
				Vector3 val9 = val3 + normalized * num4;
				arm2.Upper.localRotation = arm2.UpperRest;
				arm2.Lower.localRotation = arm2.LowerRest;
				arm2.Wrist.localRotation = arm2.WristRest;
				arm2.Upper.position = val3;
				Vector3 val10 = (Object.op_Implicit((Object)(object)arm2.Upper.parent) ? arm2.Upper.parent.lossyScale : Vector3.one);
				Vector3 val11 = arm2.UpperScale * num;
				arm2.Upper.localScale = new Vector3(val11.x / val10.x, val11.y / val10.y, val11.z / val10.z);
				Vector3 val12 = arm2.Lower.position - arm2.Upper.position;
				arm2.Upper.rotation = Quaternion.FromToRotation(val12, val8 - val3) * arm2.Upper.rotation;
				val12 = arm2.Wrist.position - arm2.Lower.position;
				arm2.Lower.rotation = Quaternion.FromToRotation(val12, val9 - val8) * arm2.Lower.rotation;
				if (Twist != 0f)
				{
					Transform lower = arm2.Lower;
					float num7 = Twist * (float)arm2.Side;
					val7 = val9 - val8;
					lower.rotation = Quaternion.AngleAxis(num7, ((Vector3)(ref val7)).normalized) * arm2.Lower.rotation;
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Current == (Object)(object)this)
			{
				Current = null;
			}
		}
	}
	internal sealed class HudCamFollow : MonoBehaviour
	{
		public FormCamera Source;

		private Vector3 saved;

		private bool moved;

		private void OnPreCull()
		{
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Source) && !FormCamera.ThirdPerson)
			{
				saved = ((Component)this).transform.position;
				((Component)this).transform.position = Source.ViewPosition;
				moved = true;
			}
		}

		private void OnPostRender()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (moved)
			{
				((Component)this).transform.position = saved;
				moved = false;
			}
		}

		private void OnDisable()
		{
			OnPostRender();
		}
	}
	internal sealed class FormCamera : MonoBehaviour
	{
		public static bool ThirdPerson;

		private static bool initialised;

		private Puppet puppet;

		private float height;

		private bool showBody;

		private Transform head;

		private Vector3 headScale;

		private readonly List<Renderer> bodyRenderers = new List<Renderer>();

		private FirstPersonArms armsView;

		private Vector3 savedPos;

		private bool moved;

		private bool hidden;

		private bool headHidden;

		private float pulledIn = -1f;

		public Vector3 ViewPosition { get; private set; }

		private static int Mask => LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1));

		public void Init(Puppet p, Form form)
		{
			//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_0134: Unknown result type (might be due to invalid IL or missing references)
			float cameraHeight = form.CameraHeight;
			bool showBodyInFirstPerson = form.ShowBodyInFirstPerson;
			if (!initialised)
			{
				ThirdPerson = Plugin.ThirdPersonDefault.Value;
				initialised = true;
			}
			puppet = p;
			height = cameraHeight;
			showBody = showBodyInFirstPerson;
			head = (Object.op_Implicit((Object)(object)p.Eid.weakPoint) ? p.Eid.weakPoint.transform : null);
			if (Object.op_Implicit((Object)(object)head))
			{
				headScale = head.localScale;
			}
			Renderer[] componentsInChildren = ((Component)p).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val is SkinnedMeshRenderer || val is MeshRenderer)
				{
					bodyRenderers.Add(val);
				}
			}
			if (showBody && form.FpRig != null)
			{
				GunControl instance = MonoSingleton<GunControl>.Instance;
				GameObject val2 = (Object.op_Implicit((Object)(object)instance) ? DeviceWeapon.FirstWeapon(instance) : null);
				armsView = FirstPersonArms.Attach(p, form.FpRig, Object.op_Implicit((Object)(object)val2) ? val2.layer : 13);
				if (Object.op_Implicit((Object)(object)armsView))
				{
					armsView.View = this;
				}
			}
			ViewPosition = ((Component)this).transform.position;
		}

		private void Update()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Keyboard current = Keyboard.current;
			if (current != null && ((ButtonControl)current[Plugin.ViewKey.Value]).wasPressedThisFrame && !WristDevice.Paused())
			{
				ThirdPerson = !ThirdPerson;
			}
		}

		private void LateUpdate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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)
			if (Object.op_Implicit((Object)(object)puppet) && Object.op_Implicit((Object)(object)head))
			{
				if (Object.op_Implicit((Object)(object)armsView))
				{
					armsView.Visible = !ThirdPerson;
				}
				if (false)
				{
					head.localScale = headScale * 0.0001f;
					headHidden = true;
				}
				else if (headHidden)
				{
					head.localScale = headScale;
					headHidden = false;
				}
				ViewPosition = ComputeViewPosition();
			}
		}

		private Vector3 EyePosition()
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown