Decompiled source of Rapiers of Valheim v1.0.0

BepInEx/plugins/AlternatingRapier/AlternatingRapier.dll

Decompiled 21 hours 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.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AlternatingRapier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Twelve craftable rapiers with fencing attacks for Valheim.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Rapiers of Valheim")]
[assembly: AssemblyTitle("AlternatingRapier")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class NeedleBlade
{
	private static ConfigEntry<bool> _enabled;

	private static ConfigEntry<bool> _flip;

	private static ConfigEntry<float> _roll;

	private static ConfigEntry<float> _lengthMul;

	private static ConfigEntry<float> _thicknessMul;

	private static ConfigEntry<float> _baseInset;

	public static void BindConfig(ConfigFile config)
	{
		_enabled = config.Bind<bool>("Plains Rapier Blade", "UseVanillaNeedle", true, "Replace the placeholder blade with the game's Needle mesh.");
		_flip = config.Bind<bool>("Plains Rapier Blade", "FlipNeedle", false, "Turn the needle around if the tip ends up in the hilt.");
		_roll = config.Bind<float>("Plains Rapier Blade", "RollDegrees", 0f, "Spin the needle around the blade axis.");
		_lengthMul = config.Bind<float>("Plains Rapier Blade", "LengthMultiplier", 1f, "1 = same length as the placeholder blade.");
		_thicknessMul = config.Bind<float>("Plains Rapier Blade", "ThicknessMultiplier", 0.12f, "Scale the needle's thickness independently of its length. The designed rapier fit is 0.12.");
		_baseInset = config.Bind<float>("Plains Rapier Blade", "BaseInset", -0.015f, "Slide the needle along the blade axis (negative = deeper into the hilt collar).");
	}

	public static void Apply(GameObject rapierPrefab)
	{
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: 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_0213: 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_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: 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_0149: 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_0234: 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_0250: 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_0252: 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_025a: 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_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: 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_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: 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_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: 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_0318: 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_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: 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_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_039c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		bool flag = _flip?.Value ?? false;
		float num = _roll?.Value ?? 0f;
		float num2 = _lengthMul?.Value ?? 1f;
		float num3 = _thicknessMul?.Value ?? 1f;
		float num4 = _baseInset?.Value ?? (-0.015f);
		if (_enabled != null && !_enabled.Value)
		{
			return;
		}
		Transform val = FindDeep(rapierPrefab.transform, "Blade_Placeholder");
		if (!Object.op_Implicit((Object)(object)val))
		{
			Logger.LogWarning((object)("NeedleBlade: 'Blade_Placeholder' not found on " + ((Object)rapierPrefab).name));
			return;
		}
		GameObject prefab = Cache.GetPrefab<GameObject>("Needle");
		if (!Object.op_Implicit((Object)(object)prefab))
		{
			Logger.LogWarning((object)"NeedleBlade: vanilla 'Needle' prefab not found, keeping placeholder.");
			return;
		}
		MeshFilter val2 = null;
		MeshRenderer val3 = null;
		MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
		Vector3 val5;
		foreach (MeshFilter val4 in componentsInChildren)
		{
			MeshRenderer component = ((Component)val4).GetComponent<MeshRenderer>();
			if (!Object.op_Implicit((Object)(object)val4.sharedMesh) || !Object.op_Implicit((Object)(object)component))
			{
				continue;
			}
			if (!((Object)(object)val2 == (Object)null))
			{
				Bounds bounds = val4.sharedMesh.bounds;
				val5 = ((Bounds)(ref bounds)).size;
				float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
				bounds = val2.sharedMesh.bounds;
				val5 = ((Bounds)(ref bounds)).size;
				if (!(sqrMagnitude > ((Vector3)(ref val5)).sqrMagnitude))
				{
					continue;
				}
			}
			val2 = val4;
			val3 = component;
		}
		if (!Object.op_Implicit((Object)(object)val2))
		{
			Logger.LogWarning((object)"NeedleBlade: no mesh found on the Needle prefab.");
			return;
		}
		Transform parent = val.parent;
		if (!Object.op_Implicit((Object)(object)parent.Find("NeedleBlade")))
		{
			Bounds bounds2 = ((Component)val).GetComponent<MeshFilter>().sharedMesh.bounds;
			int num5 = LongestAxis(((Bounds)(ref bounds2)).size);
			Vector3 val6 = AxisVector(num5);
			Vector3 center = ((Bounds)(ref bounds2)).center;
			val5 = ((Bounds)(ref bounds2)).extents;
			Vector3 val7 = ToParent(val, center - val6 * ((Vector3)(ref val5))[num5]);
			Vector3 center2 = ((Bounds)(ref bounds2)).center;
			val5 = ((Bounds)(ref bounds2)).extents;
			Vector3 val8 = ToParent(val, center2 + val6 * ((Vector3)(ref val5))[num5]);
			Vector3 val9 = ((((Vector3)(ref val7)).sqrMagnitude < ((Vector3)(ref val8)).sqrMagnitude) ? val7 : val8);
			Vector3 val10 = ((((Vector3)(ref val7)).sqrMagnitude < ((Vector3)(ref val8)).sqrMagnitude) ? val8 : val7);
			val5 = val10 - val9;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			val5 = val10 - val9;
			float num6 = ((Vector3)(ref val5)).magnitude * num2;
			Mesh sharedMesh = val2.sharedMesh;
			Bounds bounds3 = sharedMesh.bounds;
			int num7 = LongestAxis(((Bounds)(ref bounds3)).size);
			Vector3 val11 = AxisVector(num7);
			if (TipIsAtMinEnd(sharedMesh, num7) ^ flag)
			{
				val11 = -val11;
			}
			val5 = ((Bounds)(ref bounds3)).size;
			float num8 = ((Vector3)(ref val5))[num7];
			float num9 = num6 / Mathf.Max(num8, 0.0001f);
			Vector3 val12 = Vector3.one * num9 * num3;
			((Vector3)(ref val12))[num7] = num9;
			Vector3 center3 = ((Bounds)(ref bounds3)).center;
			Vector3 val13 = val11;
			val5 = ((Bounds)(ref bounds3)).extents;
			Vector3 val14 = center3 - val13 * ((Vector3)(ref val5))[num7];
			GameObject val15 = new GameObject("NeedleBlade")
			{
				layer = ((Component)val).gameObject.layer
			};
			val15.transform.SetParent(parent, false);
			Quaternion val16 = Quaternion.AngleAxis(num, normalized) * Quaternion.FromToRotation(val11, normalized);
			val15.transform.localRotation = val16;
			val15.transform.localScale = val12;
			val15.transform.localPosition = val9 + normalized * num4 - val16 * Vector3.Scale(val14, val12);
			val15.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			MeshRenderer obj = val15.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterials = ((Renderer)val3).sharedMaterials;
			((Renderer)obj).shadowCastingMode = ((Renderer)val3).shadowCastingMode;
			((Renderer)obj).receiveShadows = ((Renderer)val3).receiveShadows;
			((Component)val).gameObject.SetActive(false);
			Logger.LogInfo((object)$"NeedleBlade: fitted vanilla Needle to {((Object)rapierPrefab).name} (scale {num9:0.00}).");
		}
	}

	private static Vector3 ToParent(Transform t, Vector3 local)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_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)
		return t.localPosition + t.localRotation * Vector3.Scale(t.localScale, local);
	}

	private static int LongestAxis(Vector3 v)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (!(v.x >= v.y) || !(v.x >= v.z))
		{
			if (!(v.y >= v.z))
			{
				return 2;
			}
			return 1;
		}
		return 0;
	}

	private static Vector3 AxisVector(int i)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return (Vector3)(i switch
		{
			1 => Vector3.up, 
			0 => Vector3.right, 
			_ => Vector3.forward, 
		});
	}

	private static bool TipIsAtMinEnd(Mesh mesh, int axis)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		if (!mesh.isReadable)
		{
			return false;
		}
		Vector3[] vertices = mesh.vertices;
		Bounds bounds = mesh.bounds;
		Vector3 val = ((Bounds)(ref bounds)).min;
		float num = ((Vector3)(ref val))[axis];
		val = ((Bounds)(ref bounds)).max;
		float num2 = ((Vector3)(ref val))[axis];
		float num3 = (num2 - num) * 0.15f;
		float num4 = 0f;
		float num5 = 0f;
		int num6 = 0;
		int num7 = 0;
		Vector3[] array = vertices;
		for (int i = 0; i < array.Length; i++)
		{
			Vector3 val2 = array[i];
			Vector3 val3 = val2 - ((Bounds)(ref bounds)).center;
			((Vector3)(ref val3))[axis] = 0f;
			if (((Vector3)(ref val2))[axis] < num + num3)
			{
				num4 += ((Vector3)(ref val3)).magnitude;
				num6++;
			}
			else if (((Vector3)(ref val2))[axis] > num2 - num3)
			{
				num5 += ((Vector3)(ref val3)).magnitude;
				num7++;
			}
		}
		if (num6 == 0 || num7 == 0)
		{
			return false;
		}
		return num4 / (float)num6 < num5 / (float)num7;
	}

	private static Transform FindDeep(Transform root, string name)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if (((Object)root).name == name)
		{
			return root;
		}
		foreach (Transform item in root)
		{
			Transform val = FindDeep(item, name);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
		}
		return null;
	}
}
namespace AlternatingRapier
{
	internal sealed class ArmRig
	{
		internal Quaternion UpperBasis;

		internal Quaternion LowerBasis;

		internal Quaternion WristRest;

		internal Vector3 LowerAxis;

		internal static ArmRig Read(Animator animator, Transform upper, Transform lower, Transform hand, Transform frame)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01f5: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)upper) || !Object.op_Implicit((Object)(object)lower) || !Object.op_Implicit((Object)(object)hand) || (Object)(object)hand.parent != (Object)(object)lower)
			{
				return null;
			}
			SkinnedMeshRenderer[] componentsInChildren = ((Component)animator).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val.sharedMesh))
				{
					continue;
				}
				Transform[] bones = val.bones;
				int num = Array.IndexOf(bones, upper);
				int num2 = Array.IndexOf(bones, lower);
				int num3 = Array.IndexOf(bones, hand);
				Matrix4x4[] bindposes = val.sharedMesh.bindposes;
				if (num >= 0 && num2 >= 0 && num3 >= 0 && Math.Max(num, Math.Max(num2, num3)) < bindposes.Length)
				{
					Matrix4x4 inverse = ((Matrix4x4)(ref bindposes[num])).inverse;
					Matrix4x4 inverse2 = ((Matrix4x4)(ref bindposes[num2])).inverse;
					Matrix4x4 inverse3 = ((Matrix4x4)(ref bindposes[num3])).inverse;
					Vector3 val2 = ((Matrix4x4)(ref inverse2)).MultiplyPoint3x4(Vector3.zero) - ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero);
					Vector3 val3 = ((Matrix4x4)(ref inverse3)).MultiplyPoint3x4(Vector3.zero) - ((Matrix4x4)(ref inverse2)).MultiplyPoint3x4(Vector3.zero);
					Vector3 val4 = ((Component)val).transform.InverseTransformDirection(-frame.up);
					Vector3 val5 = Vector3.Cross(val2, val4);
					Vector3 normalized = ((Vector3)(ref val5)).normalized;
					if (!(((Vector3)(ref normalized)).sqrMagnitude < 0.01f))
					{
						Vector3 val6 = Quaternion.Inverse(((Matrix4x4)(ref inverse)).rotation) * ((Vector3)(ref val2)).normalized;
						Vector3 val7 = Quaternion.Inverse(((Matrix4x4)(ref inverse2)).rotation) * ((Vector3)(ref val3)).normalized;
						return new ArmRig
						{
							UpperBasis = Quaternion.Inverse(Quaternion.LookRotation(val6, Quaternion.Inverse(((Matrix4x4)(ref inverse)).rotation) * normalized)),
							LowerBasis = Quaternion.Inverse(Quaternion.LookRotation(val7, Quaternion.Inverse(((Matrix4x4)(ref inverse2)).rotation) * normalized)),
							LowerAxis = val7,
							WristRest = Quaternion.Inverse(((Matrix4x4)(ref inverse2)).rotation) * ((Matrix4x4)(ref inverse3)).rotation
						};
					}
				}
			}
			return null;
		}

		internal float ForearmRoll(Quaternion desiredLocal)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			Quaternion val = desiredLocal * Quaternion.Inverse(WristRest);
			float num = Vector3.Dot(new Vector3(val.x, val.y, val.z), ((Vector3)(ref LowerAxis)).normalized);
			return Mathf.Clamp(Mathf.DeltaAngle(0f, 2f * Mathf.Atan2(num, val.w) * 57.29578f), -80f, 80f);
		}

		internal Quaternion LimitWrist(Quaternion local)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00f8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = local * Quaternion.Inverse(WristRest);
			Vector3 val2 = Vector3.Project(new Vector3(val.x, val.y, val.z), LowerAxis);
			Quaternion val3 = default(Quaternion);
			((Quaternion)(ref val3))..ctor(val2.x, val2.y, val2.z, val.w);
			float num = Mathf.Sqrt(val3.x * val3.x + val3.y * val3.y + val3.z * val3.z + val3.w * val3.w);
			val3 = (Quaternion)((num < 1E-05f) ? Quaternion.identity : new Quaternion(val3.x / num, val3.y / num, val3.z / num, val3.w / num));
			Quaternion val4 = val * Quaternion.Inverse(val3);
			val4 = Quaternion.RotateTowards(Quaternion.identity, val4, 40f);
			val3 = Quaternion.RotateTowards(Quaternion.identity, val3, 90f);
			return val4 * val3 * WristRest;
		}
	}
	internal static class DiagonalSlashMotion
	{
		private static MotionVector V(float x, float y, float z)
		{
			return new MotionVector(x, y, z);
		}

		private static MotionVector Unit(MotionVector v)
		{
			float num = (float)Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
			return V(v.X / num, v.Y / num, v.Z / num);
		}

		private static MotionVector Palm(MotionVector normal, MotionVector aim)
		{
			float num = normal.X * aim.X + normal.Y * aim.Y + normal.Z * aim.Z;
			return Unit(V(normal.X - aim.X * num, normal.Y - aim.Y * num, normal.Z - aim.Z * num));
		}

		internal static WheelPose Third(float phase, float hit, float shoulderY, MotionVector from)
		{
			hit = Math.Max(0.12f, Math.Min(0.75f, hit));
			float num = hit * 0.42f;
			float num2 = Math.Min(0.88f, hit + 0.12f);
			float num3 = WheelMotion.Smooth(phase / num);
			float num4 = WheelMotion.Smooth((phase - num) / (num2 - num));
			MotionVector motionVector = V(-0.12f, shoulderY + 0.08f, 0.38f);
			MotionVector b = V(0.27f, shoulderY - 0.42f, 0.38f);
			MotionVector a = MotionVector.Lerp(from, motionVector, num3);
			if (phase >= num)
			{
				a = MotionVector.Lerp(motionVector, b, num4);
				a.Z += 0.08f * (float)Math.Sin(Math.PI * (double)num4);
			}
			MotionVector motionVector2 = Unit(V(1f, -1.28f, 0f));
			float num5 = (-65f * num3 + 130f * num4) * (float)Math.PI / 180f;
			MotionVector motionVector3 = V(motionVector2.X * (float)Math.Sin(num5), motionVector2.Y * (float)Math.Sin(num5), (float)Math.Cos(num5));
			MotionVector b2 = V(motionVector2.Y, 0f - motionVector2.X, 0f);
			MotionVector normal = Palm(MotionVector.Lerp(V(0f, 1f, 0f), b2, num3), motionVector3);
			float num6 = num2 + 0.025f;
			float num7 = Math.Min(0.98f, Math.Max(num6 + 0.025f, hit + 0.43f));
			float t = WheelMotion.Smooth((phase - num6) / (num7 - num6));
			a = MotionVector.Lerp(a, V(0.31f, shoulderY - 0.24f, 0.15f), t);
			motionVector3 = Unit(MotionVector.Lerp(motionVector3, V(0f, 0f, 1f), t));
			normal = Palm(normal, motionVector3);
			return new WheelPose
			{
				Hand = a,
				Aim = motionVector3,
				Palm = normal,
				OrientationBlend = num3
			};
		}
	}
	internal struct FencingStep
	{
		internal float Lead;

		internal float Rear;

		internal float Body;

		internal float RightZ;

		internal float LeftZ;

		internal float RightLift;

		internal float LeftLift;

		internal static float Recovery(float phase, float hit)
		{
			return Smooth((phase - hit - 0.045f) / (Math.Min(0.9f, hit + 0.38f) - hit - 0.045f));
		}

		internal static FencingStep At(float phase, float hit, float distance, float thrustStart = 0.4f)
		{
			hit = Math.Max(0.12f, Math.Min(0.75f, hit));
			distance = Math.Max(0f, Math.Min(0.8f, distance));
			thrustStart = Math.Max(0f, Math.Min(0.85f, thrustStart));
			float num = Smooth((phase - hit * thrustStart) / (hit * (1f - thrustStart)));
			float num2 = Recovery(phase, hit);
			float num3 = distance * (0.8f * num + 0.2f * num2);
			return new FencingStep
			{
				Lead = num,
				Rear = num2,
				Body = num3,
				RightZ = 0.22f + distance * num - num3,
				LeftZ = -0.22f + distance * num2 - num3,
				RightLift = 0.12f * (float)Math.Sin(Math.PI * (double)num),
				LeftLift = 0.08f * (float)Math.Sin(Math.PI * (double)num2)
			};
		}

		private static float Smooth(float t)
		{
			t = Math.Max(0f, Math.Min(1f, t));
			return t * t * (3f - 2f * t);
		}
	}
	internal sealed class GuardFingerPose
	{
		internal Transform Bone;

		internal Quaternion Closed;

		internal static List<GuardFingerPose> Read(Animator animator, Transform hand)
		{
			//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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0128: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014d: 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_0239: 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_0249: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			List<GuardFingerPose> list = ReadNativeFist(animator, hand);
			if (list != null)
			{
				return list;
			}
			List<GuardFingerPose> list2 = new List<GuardFingerPose>();
			SkinnedMeshRenderer[] componentsInChildren = ((Component)animator).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val.sharedMesh))
				{
					continue;
				}
				Transform[] bones = val.bones;
				Matrix4x4[] bindposes = val.sharedMesh.bindposes;
				int num = Array.IndexOf(bones, hand);
				int num2 = Find(bones, "LeftHandIndex1");
				int num3 = Find(bones, "LeftHandPinky1");
				int num4 = Find(bones, "LeftHandMiddle1");
				if (num < 0 || num2 < 0 || num3 < 0 || num4 < 0 || bindposes.Length != bones.Length)
				{
					continue;
				}
				Matrix4x4 inverse = ((Matrix4x4)(ref bindposes[num])).inverse;
				Vector3 val2 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero);
				inverse = ((Matrix4x4)(ref bindposes[num2])).inverse;
				Vector3 val3 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero);
				inverse = ((Matrix4x4)(ref bindposes[num3])).inverse;
				Vector3 val4 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero);
				inverse = ((Matrix4x4)(ref bindposes[num4])).inverse;
				Vector3 val5 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero);
				Vector3 val6 = Vector3.Cross(val4 - val3, val5 - val2);
				Vector3 val7 = -((Vector3)(ref val6)).normalized;
				string[] array = new string[5] { "Index", "Middle", "Ring", "Pinky", "Thumb" };
				foreach (string text in array)
				{
					float[] array2 = ((!(text == "Thumb")) ? new float[3] { 85f, 100f, 65f } : new float[3] { 55f, 70f, 45f });
					for (int k = 1; k <= 3; k++)
					{
						int num5 = Find(bones, "LeftHand" + text + k);
						if (num5 < 0)
						{
							continue;
						}
						int num6 = Array.IndexOf(bones, bones[num5].parent);
						int num7 = Find(bones, "LeftHand" + text + (k + 1));
						if (num6 >= 0)
						{
							Matrix4x4 inverse2 = ((Matrix4x4)(ref bindposes[num5])).inverse;
							Matrix4x4 inverse3 = ((Matrix4x4)(ref bindposes[num6])).inverse;
							Vector3 val8 = ((Matrix4x4)(ref inverse2)).MultiplyPoint3x4(Vector3.zero);
							Vector3 val9;
							if (num7 < 0)
							{
								val9 = val8 - ((Matrix4x4)(ref inverse3)).MultiplyPoint3x4(Vector3.zero);
							}
							else
							{
								inverse = ((Matrix4x4)(ref bindposes[num7])).inverse;
								val9 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero) - val8;
							}
							Vector3 val10 = val9;
							Quaternion val11 = Quaternion.Inverse(((Matrix4x4)(ref inverse3)).rotation);
							val6 = Vector3.Cross(((Vector3)(ref val10)).normalized, val7);
							Vector3 val12 = val11 * ((Vector3)(ref val6)).normalized;
							list2.Add(new GuardFingerPose
							{
								Bone = bones[num5],
								Closed = Quaternion.AngleAxis(array2[k - 1], val12) * Quaternion.Inverse(((Matrix4x4)(ref inverse3)).rotation) * ((Matrix4x4)(ref inverse2)).rotation
							});
						}
					}
				}
				Plugin.LogInfo("Hip fist calibrated from " + list2.Count + " finger joints.");
				return list2;
			}
			Plugin.Warn("Hip fist bind poses unavailable on this player mesh.");
			return list2;
		}

		private static List<GuardFingerPose> ReadNativeFist(Animator animator, Transform hand)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//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)
			if (!Object.op_Implicit((Object)(object)animator.runtimeAnimatorController))
			{
				return null;
			}
			AnimationClip val = Array.Find(animator.runtimeAnimatorController.animationClips, (AnimationClip c) => ((Object)c).name == "Punchstep 2");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			GameObject val2 = new GameObject("Inactive fist calibration");
			val2.SetActive(false);
			try
			{
				GameObject val3 = Object.Instantiate<GameObject>(((Component)animator).gameObject, val2.transform, false);
				val.SampleAnimation(val3, val.length * 0.5f);
				Transform[] componentsInChildren = val3.GetComponentsInChildren<Transform>(true);
				Transform[] componentsInChildren2 = ((Component)hand).GetComponentsInChildren<Transform>(true);
				List<GuardFingerPose> list = new List<GuardFingerPose>();
				string[] array = new string[5] { "Index", "Middle", "Ring", "Pinky", "Thumb" };
				foreach (string text in array)
				{
					for (int num2 = 1; num2 <= 3; num2++)
					{
						string name = "LeftHand" + text + num2;
						int num3 = Find(componentsInChildren2, name);
						int num4 = Find(componentsInChildren, name);
						if (num3 < 0 || num4 < 0)
						{
							return null;
						}
						list.Add(new GuardFingerPose
						{
							Bone = componentsInChildren2[num3],
							Closed = componentsInChildren[num4].localRotation
						});
					}
				}
				Plugin.LogInfo("Hip fist uses native Punchstep 2 finger pose (15 joints).");
				return list;
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val2);
			}
		}

		private static int Find(Transform[] bones, string name)
		{
			for (int i = 0; i < bones.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)bones[i]) && ((Object)bones[i]).name.Replace("_", "").EndsWith(name, StringComparison.OrdinalIgnoreCase))
				{
					return i;
				}
			}
			return -1;
		}
	}
	internal static class GuardMirrorCheck
	{
		internal static void Run(string file)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_025c: 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_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: 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_0321: 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_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: 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_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0669: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			GameObject prefab = Cache.GetPrefab<GameObject>("Player");
			VisEquipment componentInChildren = prefab.GetComponentInChildren<VisEquipment>(true);
			Animator componentInChildren2 = prefab.GetComponentInChildren<Animator>(true);
			AnimationClip[] source = componentInChildren2.runtimeAnimatorController.animationClips.Where((AnimationClip c) => ((Object)c).name.ToLowerInvariant().Contains("idle")).Distinct().ToArray();
			stringBuilder.AppendLine("Native idle clips: " + string.Join(", ", source.Select((AnimationClip c) => ((Object)c).name)));
			string text = PathFrom(componentInChildren.m_rightHand, ((Component)componentInChildren2).transform);
			stringBuilder.AppendLine("Right-hand socket: " + text);
			GameObject val = new GameObject("Inactive mirror inspection");
			val.SetActive(false);
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)componentInChildren2).gameObject, val.transform, false);
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localRotation = Quaternion.identity;
				Transform val3 = val2.transform.Find(text);
				Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>(true);
				Transform val4 = componentsInChildren.First((Transform t) => ((Object)t).name == "RightHand");
				Transform val5 = componentsInChildren.First((Transform t) => ((Object)t).name == "RightArm");
				Transform val6 = componentsInChildren.First((Transform t) => ((Object)t).name == "LeftArm");
				Transform lower = componentsInChildren.First((Transform t) => ((Object)t).name == "RightForeArm");
				ArmRig armRig = ArmRig.Read(val2.GetComponent<Animator>(), val5, lower, val4, val.transform);
				string[] array = new string[3] { "IdleTweaked", "Sword And Shield Idle", "Fencing guard" };
				foreach (string pose in array)
				{
					source.First((AnimationClip c) => ((Object)c).name == ((pose == "Fencing guard") ? "IdleTweaked" : pose)).SampleAnimation(val2, 0.5f);
					Quaternion rotation = val4.rotation;
					stringBuilder.AppendLine("POSE " + pose);
					Vector3 val7 = val5.position - val6.position;
					Vector3 val8 = ((Vector3)(ref val7)).normalized;
					if (pose == "Fencing guard")
					{
						val8 = Vector3.right;
					}
					stringBuilder.AppendLine("Anatomical right=" + ((Vector3)(ref val8)).ToString("F5"));
					string[] array2 = new string[2] { "Rapier_AuroraNeedle", "Rapier_GoldenRune" };
					foreach (string text2 in array2)
					{
						val4.rotation = rotation;
						Transform transform = Object.Instantiate<GameObject>(((Component)ItemManager.Instance.GetItem(text2).ItemPrefab.transform.Find("attach")).gameObject, val3, false).transform;
						transform.localPosition = Vector3.zero;
						transform.localRotation = Quaternion.identity;
						((Component)transform).GetComponent<RapierVisual>().AlignGrip(val4, Quaternion.Inverse(armRig.WristRest) * armRig.LowerAxis);
						Transform val9 = transform.Find("RapierMesh");
						if (pose == "Fencing guard")
						{
							Transform val10 = componentsInChildren.First((Transform t) => ((Object)t).name == "RightHandIndex1");
							Transform val11 = componentsInChildren.First((Transform t) => ((Object)t).name == "RightHandPinky1");
							Transform val12 = componentsInChildren.First((Transform t) => ((Object)t).name == "RightHandMiddle1");
							val7 = val11.position - val10.position;
							Vector3 normalized = ((Vector3)(ref val7)).normalized;
							val7 = val12.position - val4.position;
							val7 = Vector3.Cross(normalized, ((Vector3)(ref val7)).normalized);
							Vector3 val13 = val4.InverseTransformDirection(((Vector3)(ref val7)).normalized);
							Vector3 val14 = val4.InverseTransformDirection(val9.TransformDirection(Vector3.up));
							val7 = new Vector3(0f, 0.16f, 1f);
							val4.rotation = Quaternion.LookRotation(((Vector3)(ref val7)).normalized, -Vector3.right) * Quaternion.Inverse(Quaternion.LookRotation(val14, Vector3.ProjectOnPlane(val13, val14)));
						}
						val7 = val9.TransformDirection(Vector3.right);
						string text3 = ((Vector3)(ref val7)).ToString("F4");
						val7 = val9.TransformDirection(Vector3.forward);
						stringBuilder.AppendLine("Model X=" + text3 + " lateral Z=" + ((Vector3)(ref val7)).ToString("F4"));
						Vector3 val15 = Vector3.zero;
						Vector3 val16 = Vector3.zero;
						int num3 = 0;
						MeshFilter[] componentsInChildren2 = ((Component)val9).GetComponentsInChildren<MeshFilter>(true);
						foreach (MeshFilter val17 in componentsInChildren2)
						{
							Vector3[] vertices = val17.sharedMesh.vertices;
							foreach (Vector3 val18 in vertices)
							{
								Vector3 val19 = val9.InverseTransformPoint(((Component)val17).transform.TransformPoint(val18));
								if (!(val19.y < -0.085f) && !(val19.y > 0.035f) && !(Mathf.Abs(val19.x) < 0.035f))
								{
									val16 += val9.TransformVector(val19);
									val19.z = 0f - val19.z;
									val15 += val9.TransformVector(val19);
									num3++;
								}
							}
						}
						if (num3 == 0)
						{
							throw new Exception("No guard vertices sampled for " + text2);
						}
						string[] obj = new string[7] { text2, " guard mean from grip before=", null, null, null, null, null };
						val7 = val15 / (float)num3;
						obj[2] = ((Vector3)(ref val7)).ToString("F5");
						obj[3] = " mirrored=";
						val7 = val16 / (float)num3;
						obj[4] = ((Vector3)(ref val7)).ToString("F5");
						obj[5] = " count=";
						obj[6] = num3.ToString();
						stringBuilder.AppendLine(string.Concat(obj));
						stringBuilder.AppendLine("Outward component before=" + Vector3.Dot(val15 / (float)num3, val8).ToString("F5") + " mirrored=" + Vector3.Dot(val16 / (float)num3, val8).ToString("F5"));
						Object.DestroyImmediate((Object)(object)((Component)transform).gameObject);
					}
				}
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
			}
			File.WriteAllText(file, stringBuilder.ToString());
		}

		private static string PathFrom(Transform node, Transform root)
		{
			string text = ((Object)node).name;
			while ((Object)(object)node.parent != (Object)(object)root)
			{
				node = node.parent;
				if (!Object.op_Implicit((Object)(object)node))
				{
					throw new Exception("Socket not inside visual rig");
				}
				text = ((Object)node).name + "/" + text;
			}
			return text;
		}
	}
	internal static class GuardPoseSmoke
	{
		[Serializable]
		internal class MeshView
		{
			public string name;

			public Vector3[] vertices;

			public int[] triangles;
		}

		[Serializable]
		internal class PoseView
		{
			public string name;

			public Vector3 hip;

			public Vector3 wrist;

			public Vector3 rightFoot;

			public Vector3 leftFoot;

			public Vector3 rightHand;

			public MeshView[] meshes;
		}

		internal static void Check(StringBuilder report, string exportPath)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004f: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Expected O, but got Unknown
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Expected O, but got Unknown
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: 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_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_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0719: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0723: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = Cache.GetPrefab<GameObject>("Player");
			Animator componentInChildren = prefab.GetComponentInChildren<Animator>(true);
			GameObject host = new GameObject("Inactive guard pose fixture");
			host.SetActive(false);
			host.transform.position = new Vector3(20000f, 20000f, 20000f);
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			val.transform.position = host.transform.position - Vector3.up * 0.05f;
			val.transform.localScale = new Vector3(10f, 0.1f, 10f);
			Physics.SyncTransforms();
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, host.transform, false);
				val2.transform.localPosition = prefab.transform.InverseTransformPoint(((Component)componentInChildren).transform.position);
				val2.transform.localRotation = Quaternion.Inverse(prefab.transform.rotation) * ((Component)componentInChildren).transform.rotation;
				MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				Animator component = val2.GetComponent<Animator>();
				File.WriteAllLines(Path.ChangeExtension(exportPath, "clips.txt"), from n in component.runtimeAnimatorController.animationClips.Select((AnimationClip c) => ((Object)c).name).Distinct()
					orderby n
					select n);
				Humanoid value = host.AddComponent<Humanoid>();
				RapierAnimation rapierAnimation = host.AddComponent<RapierAnimation>();
				Field("character").SetValue(rapierAnimation, value);
				Field("animator").SetValue(rapierAnimation, component);
				component.runtimeAnimatorController.animationClips.First((AnimationClip c) => ((Object)c).name == "Block idle").SampleAnimation(val2, 0.25f);
				Call(rapierAnimation, "FindBones");
				Require((bool)Call(rapierAnimation, "PrepareGuardHandAxes"), "Guard hand axes unavailable");
				Transform val3 = val2.GetComponentsInChildren<Transform>(true).First((Transform t) => ((Object)t).name == "RightHand_Attach");
				RapierVisual component2 = Object.Instantiate<GameObject>(((Component)ItemManager.Instance.GetItem("Rapier_AuroraNeedle").ItemPrefab.transform.Find("attach")).gameObject, val3, false).GetComponent<RapierVisual>();
				Field("weapon").SetValue(rapierAnimation, component2);
				Transform val4 = (Transform)Field("rightHand").GetValue(rapierAnimation);
				ArmRig armRig = (ArmRig)Field("rightRig").GetValue(rapierAnimation);
				component2.AlignGrip(val4, Quaternion.Inverse(armRig.WristRest) * armRig.LowerAxis);
				List<PoseView> list = new List<PoseView>();
				Transform[] array = ((IEnumerable<Transform>)(object)new Transform[1] { (Transform)Field("hips").GetValue(rapierAnimation) }).Concat(((Component)(Transform)Field("rightThigh").GetValue(rapierAnimation)).GetComponentsInChildren<Transform>(true)).Concat(((Component)(Transform)Field("leftThigh").GetValue(rapierAnimation)).GetComponentsInChildren<Transform>(true)).ToArray();
				string[] array2 = new string[5] { "Block idle", "Block Shield Walk FW", "Block Shield Walk BW", "Block Shield Walk Strafe L", "Block Shield Walk Strafe R" };
				foreach (string clipName in array2)
				{
					float[] array3 = new float[3] { 0.15f, 0.5f, 0.85f };
					for (int num = 0; num < array3.Length; num++)
					{
						float num2 = array3[num];
						Call(rapierAnimation, "Restore");
						AnimationClip val5 = component.runtimeAnimatorController.animationClips.First((AnimationClip c) => ((Object)c).name == clipName);
						val5.SampleAnimation(val2, val5.length * num2);
						Vector3[] array4 = array.Select((Transform b) => b.localPosition).ToArray();
						Quaternion[] array5 = array.Select((Transform b) => b.localRotation).ToArray();
						Call(rapierAnimation, "ApplyGuardArms", 1f, 1f);
						Transform val6 = (Transform)Field("rightFoot").GetValue(rapierAnimation);
						Transform val7 = (Transform)Field("leftFoot").GetValue(rapierAnimation);
						for (int num3 = 0; num3 < array.Length; num3++)
						{
							Vector3 localPosition = array[num3].localPosition;
							int valid;
							if (((Vector3)(ref localPosition)).Equals(array4[num3]))
							{
								Quaternion localRotation = array[num3].localRotation;
								valid = (((Quaternion)(ref localRotation)).Equals(array5[num3]) ? 1 : 0);
							}
							else
							{
								valid = 0;
							}
							Require((byte)valid != 0, "Guard changed native lower-body animation: " + clipName + " / " + ((Object)array[num3]).name);
						}
						Require(!(bool)Field("pelvisSaved").GetValue(rapierAnimation), "Guard changed native pelvis height");
						List<GuardFingerPose> obj = (List<GuardFingerPose>)Field("guardFist").GetValue(rapierAnimation);
						Require(obj.Count == 15, "Missing fist joints");
						foreach (GuardFingerPose item in obj)
						{
							Require(Quaternion.Angle(item.Bone.localRotation, item.Closed) < 0.05f, "Finger pose overwritten");
						}
						SkinnedMeshRenderer[] array6 = (from s in val2.GetComponentsInChildren<SkinnedMeshRenderer>(true)
							where ((Object)s).name == "body" && Object.op_Implicit((Object)(object)s.sharedMesh)
							select s).ToArray();
						Require(array6.Length != 0, "Native body mesh not found");
						MeshView[] meshes = array6.Select(delegate(SkinnedMeshRenderer s)
						{
							//IL_005a: Unknown result type (might be due to invalid IL or missing references)
							//IL_005f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0064: Unknown result type (might be due to invalid IL or missing references)
							//IL_0069: Unknown result type (might be due to invalid IL or missing references)
							//IL_0079: 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_0087: Unknown result type (might be due to invalid IL or missing references)
							//IL_009a: Unknown result type (might be due to invalid IL or missing references)
							//IL_009c: Unknown result type (might be due to invalid IL or missing references)
							//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
							//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
							//IL_00c0: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
							//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
							//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
							//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
							//IL_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_00fe: Unknown result type (might be due to invalid IL or missing references)
							//IL_010f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0111: Unknown result type (might be due to invalid IL or missing references)
							//IL_0116: Unknown result type (might be due to invalid IL or missing references)
							Mesh sharedMesh = s.sharedMesh;
							Vector3[] vertices = sharedMesh.vertices;
							BoneWeight[] boneWeights = sharedMesh.boneWeights;
							Matrix4x4[] binds = sharedMesh.bindposes;
							Matrix4x4[] array7 = s.bones.Select((Transform b, int num5) => b.localToWorldMatrix * binds[num5]).ToArray();
							Vector3[] array8 = (Vector3[])(object)new Vector3[vertices.Length];
							for (int num4 = 0; num4 < vertices.Length; num4++)
							{
								BoneWeight val8 = boneWeights[num4];
								Vector3 val9 = vertices[num4];
								Vector3 val10 = ((Matrix4x4)(ref array7[((BoneWeight)(ref val8)).boneIndex0])).MultiplyPoint3x4(val9) * ((BoneWeight)(ref val8)).weight0 + ((Matrix4x4)(ref array7[((BoneWeight)(ref val8)).boneIndex1])).MultiplyPoint3x4(val9) * ((BoneWeight)(ref val8)).weight1 + ((Matrix4x4)(ref array7[((BoneWeight)(ref val8)).boneIndex2])).MultiplyPoint3x4(val9) * ((BoneWeight)(ref val8)).weight2 + ((Matrix4x4)(ref array7[((BoneWeight)(ref val8)).boneIndex3])).MultiplyPoint3x4(val9) * ((BoneWeight)(ref val8)).weight3;
								array8[num4] = host.transform.InverseTransformPoint(val10);
							}
							return new MeshView
							{
								name = ((Object)s).name,
								vertices = array8,
								triangles = sharedMesh.triangles
							};
						}).ToArray();
						list.Add(new PoseView
						{
							name = clipName + "-" + num2.ToString("F2", CultureInfo.InvariantCulture),
							hip = host.transform.InverseTransformPoint(((Transform)Field("hips").GetValue(rapierAnimation)).position),
							wrist = host.transform.InverseTransformPoint(((Transform)Field("leftHand").GetValue(rapierAnimation)).position),
							rightFoot = host.transform.InverseTransformPoint(val6.position),
							leftFoot = host.transform.InverseTransformPoint(val7.position),
							rightHand = host.transform.InverseTransformPoint(val4.position),
							meshes = meshes
						});
					}
				}
				WriteExport(exportPath, list.ToArray());
				Call(rapierAnimation, "Restore");
				Require(((Dictionary<Transform, Quaternion>)Field("saved").GetValue(rapierAnimation)).Count == 0, "Guard pose did not restore");
				report.AppendLine("PASS runtime blocking pose: 15 closed finger joints; native pelvis and leg transforms preserved across 15 idle/forward/backward/strafe samples; saved pose restores");
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)host);
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		private static FieldInfo Field(string name)
		{
			return AccessTools.Field(typeof(RapierAnimation), name);
		}

		private static object Call(RapierAnimation target, string name, params object[] arguments)
		{
			return AccessTools.Method(typeof(RapierAnimation), name, (Type[])null, (Type[])null).Invoke(target, arguments);
		}

		private static void Require(bool valid, string message)
		{
			if (!valid)
			{
				throw new Exception(message);
			}
		}

		private static void WriteExport(string path, PoseView[] poses)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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)
			StringBuilder stringBuilder = new StringBuilder("{\"poses\":[");
			for (int i = 0; i < poses.Length; i++)
			{
				if (i > 0)
				{
					stringBuilder.Append(',');
				}
				PoseView poseView = poses[i];
				stringBuilder.Append("{\"name\":\"").Append(poseView.name).Append("\",\"hip\":");
				Vector(stringBuilder, poseView.hip);
				stringBuilder.Append(",\"wrist\":");
				Vector(stringBuilder, poseView.wrist);
				stringBuilder.Append(",\"rightFoot\":");
				Vector(stringBuilder, poseView.rightFoot);
				stringBuilder.Append(",\"leftFoot\":");
				Vector(stringBuilder, poseView.leftFoot);
				stringBuilder.Append(",\"rightHand\":");
				Vector(stringBuilder, poseView.rightHand);
				stringBuilder.Append(",\"meshes\":[");
				for (int j = 0; j < poseView.meshes.Length; j++)
				{
					if (j > 0)
					{
						stringBuilder.Append(',');
					}
					MeshView meshView = poseView.meshes[j];
					stringBuilder.Append("{\"name\":\"").Append(meshView.name).Append("\",\"vertices\":[");
					for (int k = 0; k < meshView.vertices.Length; k++)
					{
						if (k > 0)
						{
							stringBuilder.Append(',');
						}
						Vector(stringBuilder, meshView.vertices[k]);
					}
					stringBuilder.Append("],\"triangles\":[");
					for (int l = 0; l < meshView.triangles.Length; l++)
					{
						if (l > 0)
						{
							stringBuilder.Append(',');
						}
						stringBuilder.Append(meshView.triangles[l]);
					}
					stringBuilder.Append("]}");
				}
				stringBuilder.Append("]}");
			}
			File.WriteAllText(path, stringBuilder.Append("]}").ToString());
		}

		private static void Vector(StringBuilder text, Vector3 value)
		{
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			text.Append('[').Append(value.x.ToString("R", invariantCulture)).Append(',')
				.Append(value.y.ToString("R", invariantCulture))
				.Append(',')
				.Append(value.z.ToString("R", invariantCulture))
				.Append(']');
		}
	}
	internal static class HeavyAttackSmoke
	{
		internal static void Check(StringBuilder report)
		{
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			Require(Plugin.HeavySpeed.Value == 2f && Plugin.HeavyDistance.Value == 2.5f && Plugin.HeavyDuration.Value == 0.25f, "Fresh heavy-attack defaults differ from 2x / 2.5m / 0.25s");
			ItemData itemData = Cache.GetPrefab<GameObject>("SwordIron").GetComponent<ItemDrop>().m_itemData;
			string attackAnimation = itemData.m_shared.m_secondaryAttack.m_attackAnimation;
			RapierDefinition[] all = RapierCatalog.All;
			foreach (RapierDefinition rapierDefinition in all)
			{
				ItemData itemData2 = ItemManager.Instance.GetItem(rapierDefinition.Id).ItemPrefab.GetComponent<ItemDrop>().m_itemData;
				Require(RapierHeavyAttack.IsRapier(itemData2), "Heavy attack did not recognize " + rapierDefinition.Id);
				Require(itemData2.m_shared.m_secondaryAttack.m_attackAnimation == attackAnimation, "Native heavy animation changed");
				Require(Mathf.Abs(itemData2.m_shared.m_secondaryAttack.m_attackStamina - itemData2.m_shared.m_attack.m_attackStamina * 2f) < 0.001f, "Secondary stamina changed for " + rapierDefinition.Id);
			}
			Require(!RapierHeavyAttack.IsRapier(itemData), "Heavy changes apply to vanilla swords");
			Animator componentInChildren = Cache.GetPrefab<GameObject>("Player").GetComponentInChildren<Animator>(true);
			report.AppendLine("PASS heavy attack defaults and all 12 weapon gates; native secondary trigger=" + attackAnimation + "; stamina retained");
			CheckNativeAnimation(componentInChildren, attackAnimation, report);
			GameObject val = null;
			GameObject val2 = null;
			GameObject val3 = null;
			GameObject val4 = null;
			try
			{
				Vector3 val5 = default(Vector3);
				((Vector3)(ref val5))..ctor(30000f, 30000f, 30000f);
				val = new GameObject("Heavy lunge physics fixture");
				val.transform.position = val5;
				CapsuleCollider obj = val.AddComponent<CapsuleCollider>();
				obj.radius = 0.3f;
				obj.height = 1.8f;
				Rigidbody obj2 = val.AddComponent<Rigidbody>();
				obj2.useGravity = false;
				obj2.isKinematic = true;
				val3 = GameObject.CreatePrimitive((PrimitiveType)3);
				val3.transform.position = val5 + new Vector3(0f, -1.01f, 0f);
				val3.transform.localScale = new Vector3(10f, 0.2f, 10f);
				Physics.SyncTransforms();
				Require(Mathf.Abs(RapierHeavyAttack.ClearDistance(obj2, Vector3.forward, 2.5f) - 2.5f) < 0.0001f, "Clear ground obstructed lunge");
				val4 = GameObject.CreatePrimitive((PrimitiveType)3);
				val4.transform.position = val5 + Vector3.forward * 0.6f;
				val4.GetComponent<Collider>().isTrigger = true;
				Physics.SyncTransforms();
				Require(Mathf.Abs(RapierHeavyAttack.ClearDistance(obj2, Vector3.forward, 2.5f) - 2.5f) < 0.0001f, "A trigger incorrectly blocked lunge");
				val2 = GameObject.CreatePrimitive((PrimitiveType)3);
				val2.transform.position = val5 + Vector3.forward;
				val2.transform.localScale = new Vector3(4f, 4f, 0.1f);
				Physics.SyncTransforms();
				float num = RapierHeavyAttack.ClearDistance(obj2, Vector3.forward, 2.5f);
				Require(num > 0.58f && num < 0.68f, "Wall sweep failed: " + num);
				report.AppendLine("PASS heavy lunge actual Rigidbody capsule sweep: clear ground 2.5m; trigger ignored; wall stops at " + num.ToString("F3") + "m");
			}
			finally
			{
				GameObject[] array = (GameObject[])(object)new GameObject[4] { val, val2, val3, val4 };
				foreach (GameObject val6 in array)
				{
					if (Object.op_Implicit((Object)(object)val6))
					{
						Object.DestroyImmediate((Object)(object)val6);
					}
				}
			}
		}

		private static void CheckNativeAnimation(Animator source, string trigger, StringBuilder report)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//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_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_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)
			GameObject val = new GameObject("Inactive heavy animation fixture");
			val.SetActive(false);
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)source).gameObject, val.transform, false);
				MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				Animator component = val2.GetComponent<Animator>();
				component.fireEvents = false;
				component.cullingMode = (AnimatorCullingMode)0;
				val.SetActive(true);
				val2.SetActive(true);
				component.Rebind();
				component.Update(0f);
				component.SetTrigger(trigger);
				for (int j = 0; j < 100; j++)
				{
					component.Update(0.01f);
					for (int k = 0; k < component.layerCount; k++)
					{
						AnimatorStateInfo currentAnimatorStateInfo = component.GetCurrentAnimatorStateInfo(k);
						if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("attack") && !component.IsInTransition(k))
						{
							AnimatorClipInfo val3 = (from c in component.GetCurrentAnimatorClipInfo(k)
								orderby ((AnimatorClipInfo)(ref c)).weight descending
								select c).First();
							AnimationClip clip = ((AnimatorClipInfo)(ref val3)).clip;
							AnimationEvent[] array = clip.events.Where((AnimationEvent e) => e.functionName == "Hit" || e.functionName == "OnAttackTrigger").ToArray();
							Require(array.Length != 0, "Heavy animation has no native hit event: " + ((Object)clip).name);
							float normalizedTime = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime;
							component.speed = 2f;
							component.Update(0.02f);
							AnimatorStateInfo currentAnimatorStateInfo2 = component.GetCurrentAnimatorStateInfo(k);
							float num = 0.04f * Mathf.Abs(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speed * ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speedMultiplier) / clip.length;
							Require(((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).fullPathHash == ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash && Mathf.Abs(((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).normalizedTime - normalizedTime - num) < 0.001f, "Native heavy animation did not advance at 2x speed");
							report.AppendLine("PASS native heavy Animator trigger, attack tag, hit event and 2x playback: " + ((Object)clip).name + "; clip=" + clip.length.ToString("F3") + "s; hit=" + array[0].time.ToString("F3") + "s; state speed=" + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speed + " * " + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speedMultiplier);
							CheckLungeWindow(component, trigger, report);
							return;
						}
					}
				}
				throw new Exception("Native secondary trigger did not enter an attack-tagged state");
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		private static void CheckLungeWindow(Animator animator, string trigger, StringBuilder report)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			animator.Rebind();
			animator.speed = 1f;
			animator.Update(0f);
			animator.SetTrigger(trigger);
			HeavyLungeMotion motion = new HeavyLungeMotion(2.5f, 0.25f);
			bool flag = false;
			bool flag2 = false;
			float num = 0f;
			List<AnimatorClipInfo> list = new List<AnimatorClipInfo>();
			for (int i = 0; i < 150; i++)
			{
				animator.Update(0.02f);
				if (!RapierHeavyAttack.FindAttackState(animator, out var state, out var layer, out var next))
				{
					if (flag)
					{
						break;
					}
					continue;
				}
				flag = true;
				animator.speed = 2f;
				list.Clear();
				if (next)
				{
					animator.GetNextAnimatorClipInfo(layer, list);
				}
				else
				{
					animator.GetCurrentAnimatorClipInfo(layer, list);
				}
				if (list.Count != 0)
				{
					if (!flag2)
					{
						AnimatorStateInfo state2 = state;
						AnimatorClipInfo val = list[0];
						flag2 = RapierHeavyAttack.StartLunge(ref motion, state2, ((AnimatorClipInfo)(ref val)).clip, animator.speed, 0.02f);
					}
					if (flag2)
					{
						num += motion.Step(0.02f);
					}
				}
			}
			Require(motion.Finished && Mathf.Abs(num - 2.5f) < 0.0001f, "Heavy attack ended before the full lunge: " + num);
			float duration = motion.Duration;
			report.AppendLine("PASS full 2.5m lunge fits actual native heavy attack before exit; fitted travel duration=" + duration.ToString("F3") + "s");
		}

		private static void Require(bool condition, string message)
		{
			if (!condition)
			{
				throw new Exception(message);
			}
		}
	}
	internal sealed class HeavyLungeMotion
	{
		internal readonly float Distance;

		internal readonly float Duration;

		internal float Elapsed { get; private set; }

		internal bool Finished { get; private set; }

		internal HeavyLungeMotion(float distance, float duration)
		{
			Distance = Math.Max(0f, distance);
			Duration = Math.Max(0.01f, duration);
		}

		internal float Step(float dt)
		{
			if (Finished || dt <= 0f)
			{
				return 0f;
			}
			float num = Fraction(Elapsed / Duration);
			Elapsed = Math.Min(Duration, Elapsed + dt);
			float result = Distance * (Fraction(Elapsed / Duration) - num);
			Finished = Elapsed >= Duration;
			return result;
		}

		internal void Stop()
		{
			Finished = true;
		}

		private static float Fraction(float t)
		{
			t = Math.Max(0f, Math.Min(1f, t));
			return t * t * (3f - 2f * t);
		}
	}
	internal sealed class HeavyAttackSpeed
	{
		private readonly float factor;

		private float basis;

		private float applied;

		private bool ownsValue;

		internal HeavyAttackSpeed(float multiplier)
		{
			factor = multiplier;
		}

		internal float Apply(float current, bool frozen)
		{
			if (frozen || current < 0.01f)
			{
				return current;
			}
			if (!ownsValue || Math.Abs(current - applied) > 0.0001f)
			{
				basis = current;
			}
			applied = basis * factor;
			ownsValue = true;
			return applied;
		}

		internal float AnimationEvent(float nativeSpeed)
		{
			basis = nativeSpeed;
			applied = nativeSpeed * factor;
			ownsValue = true;
			return applied;
		}

		internal float Restore(float current)
		{
			if (!ownsValue || !(Math.Abs(current - applied) < 0.0001f))
			{
				return current;
			}
			return basis;
		}
	}
	internal static class LineupSmoke
	{
		internal static void Run()
		{
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0849: Invalid comparison between Unknown and I4
			string environmentVariable = Environment.GetEnvironmentVariable("RAPIER_SMOKE_REPORT");
			if (string.IsNullOrEmpty(environmentVariable))
			{
				return;
			}
			if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("RAPIER_MIST_INSPECT")))
			{
				MistwalkerInspection.Run(Path.ChangeExtension(environmentVariable, "mistwalker.txt"));
			}
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = true;
			if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("RAPIER_MIRROR_CHECK")))
			{
				GuardMirrorCheck.Run(Path.ChangeExtension(environmentVariable, "handedness.txt"));
			}
			try
			{
				Animator componentInChildren = Cache.GetPrefab<GameObject>("Player").GetComponentInChildren<Animator>(true);
				Transform val = null;
				Transform[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					if (((Object)val2).name.Replace("_", "").EndsWith("LeftHand", StringComparison.OrdinalIgnoreCase))
					{
						val = val2;
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					throw new Exception("Left hand not found on player prefab");
				}
				List<GuardFingerPose> list = GuardFingerPose.Read(componentInChildren, val);
				if (list.Count != 15)
				{
					throw new Exception("Expected 15 calibrated finger joints, got " + list.Count);
				}
				foreach (GuardFingerPose item in list)
				{
					if (float.IsNaN(item.Closed.w))
					{
						throw new Exception("Invalid finger rotation");
					}
				}
				stringBuilder.AppendLine("PASS hip fist: all 15 finger joints calibrated from the native closed-fist animation");
			}
			catch (Exception ex)
			{
				flag = false;
				stringBuilder.AppendLine("FAIL hip fist: " + ex);
			}
			RapierDefinition[] all = RapierCatalog.All;
			foreach (RapierDefinition rapierDefinition in all)
			{
				try
				{
					GameObject itemPrefab = ItemManager.Instance.GetItem(rapierDefinition.Id).ItemPrefab;
					SharedData shared = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared;
					if (!Object.op_Implicit((Object)(object)ObjectDB.instance.GetItemPrefab(rapierDefinition.Id)))
					{
						throw new Exception("Missing from ObjectDB");
					}
					Recipe recipe = ItemManager.Instance.GetItem(rapierDefinition.Id).Recipe.Recipe;
					if (!Object.op_Implicit((Object)(object)recipe) || !recipe.m_enabled)
					{
						throw new Exception("Recipe missing or disabled");
					}
					if (!Object.op_Implicit((Object)(object)itemPrefab.transform.Find("attach/RapierMesh")))
					{
						throw new Exception("No model");
					}
					if (rapierDefinition.Id == "Rapier_Wood")
					{
						Material sharedMaterial = ((Renderer)((Component)itemPrefab.transform.Find("attach/RapierMesh")).GetComponentInChildren<MeshRenderer>()).sharedMaterial;
						if (!((Object)sharedMaterial).name.Contains("WoodenWeapons"))
						{
							throw new Exception("Wrong wood material: " + ((Object)sharedMaterial).name);
						}
						stringBuilder.AppendLine("PASS native wood material: " + ((Object)sharedMaterial).name);
					}
					if (shared.m_icons.Length != 1 || !Object.op_Implicit((Object)(object)shared.m_icons[0]))
					{
						throw new Exception("No icon");
					}
					if (!Object.op_Implicit((Object)(object)itemPrefab.GetComponent<Rigidbody>()))
					{
						throw new Exception("No drop body");
					}
					if (!Object.op_Implicit((Object)(object)itemPrefab.GetComponent<CapsuleCollider>()))
					{
						throw new Exception("No drop collider");
					}
					if (!Object.op_Implicit((Object)(object)Cache.GetPrefab<GameObject>(rapierDefinition.Station)))
					{
						throw new Exception("Unknown station " + rapierDefinition.Station);
					}
					RequirementConfig[] recipe2 = rapierDefinition.Recipe;
					foreach (RequirementConfig val3 in recipe2)
					{
						if (!Object.op_Implicit((Object)(object)Cache.GetPrefab<GameObject>(val3.Item)))
						{
							throw new Exception("Unknown ingredient " + val3.Item);
						}
					}
					if (rapierDefinition.BalancePrefab != null)
					{
						PrefabExtension.FixReferences((object)recipe);
						CraftingStation componentInChildren2 = Cache.GetPrefab<GameObject>("blackforge").GetComponentInChildren<CraftingStation>(true);
						if (recipe.m_minStationLevel != 4 || !Object.op_Implicit((Object)(object)recipe.m_craftingStation) || recipe.m_craftingStation.m_name != componentInChildren2.m_name)
						{
							throw new Exception("Deep North recipe must require Black Forge 4; got " + recipe.m_minStationLevel + " / " + (object)recipe.m_craftingStation);
						}
						if (recipe.m_noCraftOnlyUpgrade || recipe.m_requireOnlyOneIngredient || recipe.m_amount != 1)
						{
							throw new Exception("Deep North recipe must craft one item using all ingredients");
						}
						string text = ((rapierDefinition.Id == "Rapier_AuroraNeedle") ? "OrbFrostFire" : "OrbThunderBlood");
						Dictionary<string, int[]> dictionary = new Dictionary<string, int[]>();
						dictionary.Add("SwordGold", new int[4] { 1, 0, 0, 0 });
						dictionary.Add("Gold", new int[4] { 20, 10, 20, 40 });
						dictionary.Add(text, new int[4] { 1, 1, 2, 4 });
						Dictionary<string, int[]> dictionary2 = dictionary;
						if (recipe.m_resources.Length != 3)
						{
							throw new Exception("Expected exactly three ingredients");
						}
						Requirement[] resources = recipe.m_resources;
						foreach (Requirement val4 in resources)
						{
							string name = ((Object)((Component)val4.m_resItem).gameObject).name;
							if (!dictionary2.ContainsKey(name))
							{
								throw new Exception("Unexpected ingredient " + name);
							}
							for (int k = 1; k <= 4; k++)
							{
								if (val4.GetAmount(k) != dictionary2[name][k - 1])
								{
									throw new Exception("Wrong cost for " + name + " at quality " + k + ": " + val4.GetAmount(k));
								}
							}
							dictionary2.Remove(name);
						}
						if (dictionary2.Count != 0)
						{
							throw new Exception("Missing recipe ingredient");
						}
						SharedData shared2 = Cache.GetPrefab<GameObject>(rapierDefinition.BalancePrefab).GetComponent<ItemDrop>().m_itemData.m_shared;
						if (shared2.m_damages.m_slash <= 0f || shared.m_damages.m_slash != 0f || Mathf.Abs(((DamageTypes)(ref shared.m_damages)).GetTotalDamage() - ((DamageTypes)(ref shared2.m_damages)).GetTotalDamage()) > 0.01f)
						{
							throw new Exception("Native balance / rapier damage conversion mismatch");
						}
						stringBuilder.AppendLine("PASS " + rapierDefinition.Id + " recipe: Black Forge 4; SwordGold 1/0/0/0; Gold 20/10/20/40; " + text + " 1/1/2/4 (qualities 1-4)");
					}
					if (rapierDefinition.Id == "Rapier_Plains")
					{
						bool flag2 = false;
						Transform[] componentsInChildren = itemPrefab.GetComponentsInChildren<Transform>(true);
						for (int j = 0; j < componentsInChildren.Length; j++)
						{
							if (((Object)componentsInChildren[j]).name == "NeedleBlade")
							{
								flag2 = true;
							}
						}
						if (!flag2)
						{
							throw new Exception("Native needle not fitted");
						}
					}
					if (rapierDefinition.Id == "Rapier_Veilneedle")
					{
						VeilneedleMistSmoke.Check(itemPrefab, stringBuilder);
					}
					else if (itemPrefab.GetComponentsInChildren<Demister>(true).Length != 0)
					{
						throw new Exception("Fog clearing leaked onto another weapon");
					}
					stringBuilder.AppendLine("PASS " + rapierDefinition.Id + " damage=" + ((DamageTypes)(ref shared.m_damages)).GetTotalDamage() + " meshes=" + ((Component)itemPrefab.transform.Find("attach/RapierMesh")).GetComponentsInChildren<MeshFilter>().Length);
				}
				catch (Exception ex2)
				{
					flag = false;
					stringBuilder.AppendLine("FAIL " + rapierDefinition.Id + " " + ex2);
				}
			}
			try
			{
				HeavyAttackSmoke.Check(stringBuilder);
			}
			catch (Exception ex3)
			{
				flag = false;
				stringBuilder.AppendLine("FAIL heavy attack: " + ex3);
			}
			try
			{
				GuardPoseSmoke.Check(stringBuilder, Path.ChangeExtension(environmentVariable, "guard-pose.json"));
			}
			catch (Exception ex4)
			{
				flag = false;
				stringBuilder.AppendLine("FAIL guard pose: " + ex4);
			}
			stringBuilder.AppendLine(flag ? ("ALL " + RapierCatalog.All.Length + " PASS") : "FAILED");
			File.WriteAllText(environmentVariable, stringBuilder.ToString());
			if ((int)SystemInfo.graphicsDeviceType != 4)
			{
				RenderPreview(Path.ChangeExtension(environmentVariable, "png"));
			}
			Plugin.LogInfo(stringBuilder.ToString());
			Application.Quit();
		}

		private unsafe static void RenderPreview(string path)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: 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_026f: Expected O, but got Unknown
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to