Decompiled source of BarbarianViking v1.0.0

plugins/BarbarianViking/NH_VLCEAuthor.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using MagicaCloth2;
using NH.JesterCryV5;
using NH_Taylor;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Barbarian Viking Taylor V5")]
[assembly: AssemblyDescription("Taylor V5 and silver armor for Barbarian Viking; multiplayer acceptance pending")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NH.JesterCryV5
{
	public static class V5ImportedVisibilityGuard
	{
		public const int ExpectedVertexCount = 15864;

		public const string ExpectedSourceBlendSha256 = "B7FE7C3574235353C5637B5426324A40452315B24EEBE2E6DA14439C4D6A0A1B";

		public const string ExpectedPositionSha256 = "1CACCDE847047BE627D54A73C5D2415761FE7F53D81A01B01B208B9257439563";

		public const string ExpectedRegionBitsSha256 = "AB79EACE538EEED37031B9CE9ADE92BEF39B79CAC7CCEA8E728AEB8D4039C9A5";

		public static byte[] Validate(Mesh importedBody, byte[] importedRegionBits)
		{
			if (!Object.op_Implicit((Object)(object)importedBody) || !importedBody.isReadable || importedBody.vertexCount != 15864 || importedRegionBits == null || importedRegionBits.Length != 15864)
			{
				throw new ArgumentException("Unexpected imported Body mesh or visibility fixture.");
			}
			Vector3[] vertices = importedBody.vertices;
			byte[] array = new byte[vertices.Length * 12];
			for (int i = 0; i < vertices.Length; i++)
			{
				float[] array2 = new float[3]
				{
					vertices[i].x,
					vertices[i].y,
					vertices[i].z
				};
				for (int j = 0; j < 3; j++)
				{
					byte[] bytes = BitConverter.GetBytes(array2[j]);
					if (!BitConverter.IsLittleEndian)
					{
						Array.Reverse((Array)bytes);
					}
					Buffer.BlockCopy(bytes, 0, array, 12 * i + 4 * j, 4);
				}
				if (importedRegionBits[i] > 7)
				{
					throw new ArgumentException("Unknown visibility region.");
				}
			}
			string text;
			using (SHA256 sHA = SHA256.Create())
			{
				text = BitConverter.ToString(sHA.ComputeHash(array)).Replace("-", "");
			}
			if (text != "1CACCDE847047BE627D54A73C5D2415761FE7F53D81A01B01B208B9257439563")
			{
				throw new InvalidOperationException("Imported Body positions/order differ from the verified mask fixture.");
			}
			using (SHA256 sHA2 = SHA256.Create())
			{
				text = BitConverter.ToString(sHA2.ComputeHash(importedRegionBits)).Replace("-", "");
			}
			if (text != "AB79EACE538EEED37031B9CE9ADE92BEF39B79CAC7CCEA8E728AEB8D4039C9A5")
			{
				throw new InvalidOperationException("Visibility mask bytes differ from the verified source mask remap.");
			}
			return (byte[])importedRegionBits.Clone();
		}
	}
	public static class V5NativeMaterials
	{
		public static Material[] CreatePlayerMaterials(SkinnedMeshRenderer nativeBody, Material[] bundledSourceMaterials, ICollection<Object> owned, Action<string> log, bool allowFlatColorFallback = false)
		{
			return Create(nativeBody, bundledSourceMaterials, owned, log, 0.2f, allowFlatColorFallback);
		}

		public static Material[] CreateArmorMaterials(SkinnedMeshRenderer nativeBody, Material[] bundledSourceMaterials, ICollection<Object> owned, Action<string> log, bool cape = false)
		{
			return Create(nativeBody, bundledSourceMaterials, owned, log, cape ? 0.1f : 0.14f, allowFlat: false);
		}

		private static Material[] Create(SkinnedMeshRenderer nativeBody, Material[] sources, ICollection<Object> owned, Action<string> log, float glossiness, bool allowFlat)
		{
			//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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Invalid comparison between Unknown and I4
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Invalid comparison between Unknown and I4
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)nativeBody) || sources == null || sources.Length == 0 || owned == null)
			{
				throw new ArgumentException("Native body, source material slots, and owned-object collection required.");
			}
			Material val = null;
			Material[] sharedMaterials = ((Renderer)nativeBody).sharedMaterials;
			foreach (Material val2 in sharedMaterials)
			{
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader) && ((Object)val2.shader).name == "Custom/Player" && val2.shader.isSupported)
				{
					val = val2;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Actual native body has no supported Custom/Player material.");
			}
			string[] array = new string[3] { "_MainTex", "_ChestTex", "_LegsTex" };
			foreach (string text in array)
			{
				if (!val.HasProperty(text))
				{
					throw new InvalidOperationException("Native Player lacks " + text);
				}
			}
			Material[] array2 = (Material[])(object)new Material[sources.Length];
			for (int j = 0; j < sources.Length; j++)
			{
				Material val3 = sources[j];
				if (!Object.op_Implicit((Object)(object)val3))
				{
					throw new InvalidOperationException("Missing source material slot " + j);
				}
				Texture val4 = (val3.HasProperty("_MainTex") ? val3.GetTexture("_MainTex") : null);
				Color val5 = Color.white;
				if (!Object.op_Implicit((Object)(object)val4))
				{
					if (!allowFlat)
					{
						throw new InvalidOperationException("Missing paired base atlas: " + ((Object)val3).name);
					}
					val4 = (Texture)(object)Texture2D.whiteTexture;
					val5 = (val3.HasProperty("_Color") ? val3.GetColor("_Color") : Color.white);
					val5.a = 1f;
					log?.Invoke("PROCEDURAL_PANTS_FLAT_COLOR_APPROXIMATION: " + ((Object)val3).name);
				}
				Material val6 = new Material(val)
				{
					name = ((Object)val3).name + "_NativePlayer_BaseOnly"
				};
				owned.Add((Object)(object)val6);
				Shader shader = val6.shader;
				for (int k = 0; k < shader.GetPropertyCount(); k++)
				{
					if ((int)shader.GetPropertyType(k) == 4 && (int)shader.GetPropertyTextureDimension(k) == 2)
					{
						val6.SetTexture(shader.GetPropertyName(k), (Texture)null);
					}
				}
				array = new string[3] { "_MainTex", "_ChestTex", "_LegsTex" };
				foreach (string text2 in array)
				{
					val6.SetTexture(text2, val4);
					val6.SetTextureScale(text2, Vector2.one);
					val6.SetTextureOffset(text2, Vector2.zero);
				}
				array = new string[4] { "_Color", "_SkinColor", "_ChestColor", "_LegsColor" };
				foreach (string text3 in array)
				{
					if (val6.HasProperty(text3))
					{
						val6.SetColor(text3, val5);
					}
				}
				array = new string[5] { "_BumpMap", "_SkinBumpMap", "_ChestBumpMap", "_LegsBumpMap", "_EmissionMap" };
				foreach (string text4 in array)
				{
					if (val6.HasProperty(text4))
					{
						val6.SetTexture(text4, (Texture)null);
					}
				}
				if (val6.HasProperty("_EmissionColor"))
				{
					val6.SetColor("_EmissionColor", Color.black);
				}
				val6.DisableKeyword("_EMISSION");
				Set(val6, "_Glossiness", glossiness);
				Set(val6, "_MetalGlossiness", 0f);
				Set(val6, "_MetalGloss", 0f);
				Set(val6, "_Metallic", 0f);
				array2[j] = val6;
				log?.Invoke("MATERIAL slot=" + j + " source=" + ((Object)val3).name + " atlas=" + ((Object)val4).name + " shader=" + ((Object)shader).name + " queue=" + val6.renderQueue + " baseOnly=true gloss=" + glossiness);
			}
			return array2;
		}

		private static void Set(Material material, string property, float value)
		{
			if (material.HasProperty(property))
			{
				material.SetFloat(property, value);
			}
		}
	}
}
namespace TaylorV5RuntimeTest
{
	public static class BuildContract
	{
		public const string BundleSHA256 = "6C2E51EEEA7BBCED0BBEB7A14C2A28023B8274F90955D792F099B57D41B89709";

		public const string MaskSHA256 = "AB79EACE538EEED37031B9CE9ADE92BEF39B79CAC7CCEA8E728AEB8D4039C9A5";

		public const string SourceSHA256 = "B7FE7C3574235353C5637B5426324A40452315B24EEBE2E6DA14439C4D6A0A1B";
	}
	[BepInPlugin("com.necroverseheroes.barbarianviking.taylor", "Barbarian Viking — Taylor V5", "1.0.0")]
	[BepInDependency("com.jotunn.jotunn", "2.30.2")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.necroverseheroes.barbarianviking.taylor";

		public const string Version = "1.0.0";

		internal static Plugin Instance;

		internal static GameObject[] Prefabs;

		internal static GameObject CloakPrefab;

		internal static byte[] RegionBits;

		internal static byte[] FaceBits;

		internal static ConfigEntry<bool> Enabled;

		private AssetBundle bundle;

		private AssetBundle armorBundle;

		private AssetBundle cloakBundle;

		private bool ready;

		private float next;

		private readonly List<TaylorV5Appearance> appearances = new List<TaylorV5Appearance>();

		private void Awake()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			Instance = this;
			try
			{
				Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Character", "EnableTaylorF8", true, "Allow this client to toggle Taylor V5 with F8.");
				if (Chainloader.PluginInfos.ContainsKey("com.nostalgiaheroes.taylorv5test"))
				{
					throw new InvalidOperationException("Standalone F8 Taylor test must be disabled before author integration");
				}
				string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
				string text = Path.Combine(directoryName, "taylor_v5_authorized_test_candidate");
				string text2 = Path.Combine(directoryName, "Body_Imported_Equipment_Visibility.bytes");
				RequireHash(text, "6C2E51EEEA7BBCED0BBEB7A14C2A28023B8274F90955D792F099B57D41B89709");
				RequireHash(text2, "AB79EACE538EEED37031B9CE9ADE92BEF39B79CAC7CCEA8E728AEB8D4039C9A5");
				RegionBits = File.ReadAllBytes(text2);
				TaylorSilverItems.Initialize();
				if ((int)SystemInfo.graphicsDeviceType == 4)
				{
					Info("TAYLOR_SILVER headless host: item registration enabled; author rendering inactive");
					return;
				}
				bundle = AssetBundle.LoadFromFile(text);
				if (!Object.op_Implicit((Object)(object)bundle))
				{
					throw new InvalidOperationException("Bundle unavailable");
				}
				RequireHash(Path.Combine(directoryName, "nh_taylor_silverarmor"), "D5C52519793EE054BC64212FD20D1DFF0AE4CBACAFA4331109AE7E9241550738");
				RequireHash(Path.Combine(directoryName, "Armor_Body_FaceMask.bytes"), "337E81265C4DFF00EEF9A26B42CC2C8B734199B9EF87595EEABBB22EB50C3790");
				FaceBits = File.ReadAllBytes(Path.Combine(directoryName, "Armor_Body_FaceMask.bytes"));
				armorBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "nh_taylor_silverarmor"));
				if (!Object.op_Implicit((Object)(object)armorBundle) || armorBundle.GetAllAssetNames().Length != 3)
				{
					throw new InvalidOperationException("Armor bundle contract");
				}
				Prefabs = (GameObject[])(object)new GameObject[5];
				for (int i = 0; i < 3; i++)
				{
					Prefabs[i + 2] = armorBundle.LoadAsset<GameObject>("taylorsilver_" + TaylorSilverItems.Slots[i].ToLowerInvariant());
					if (!Object.op_Implicit((Object)(object)Prefabs[i + 2]))
					{
						throw new InvalidOperationException("Armor component missing");
					}
				}
				for (int j = 0; j < 2; j++)
				{
					string text3 = ((j == 0) ? "Body" : "Pants");
					Prefabs[j] = bundle.LoadAsset<GameObject>("TaylorV5_" + text3);
					SkinnedMeshRenderer[] array = (Object.op_Implicit((Object)(object)Prefabs[j]) ? Prefabs[j].GetComponentsInChildren<SkinnedMeshRenderer>(true) : null);
					if (array == null || array.Length != 1 || !Object.op_Implicit((Object)(object)array[0].sharedMesh) || array[0].bones.Length != 53 || array[0].sharedMesh.bindposes.Length != 53 || !Object.op_Implicit((Object)(object)array[0].rootBone) || ((Object)array[0].rootBone).name != "Hips")
					{
						throw new InvalidOperationException("Native53 component contract failed " + text3);
					}
				}
				if (bundle.GetAllAssetNames().Length != 2)
				{
					throw new InvalidOperationException("Gearless bundle must contain only Body and Pants prefabs");
				}
				Mesh sharedMesh = Prefabs[0].GetComponentInChildren<SkinnedMeshRenderer>(true).sharedMesh;
				V5ImportedVisibilityGuard.Validate(sharedMesh, RegionBits);
				byte[] array2 = new byte[sharedMesh.triangles.Length * 4];
				Buffer.BlockCopy(sharedMesh.triangles, 0, array2, 0, array2.Length);
				using (SHA256 sHA = SHA256.Create())
				{
					if (BitConverter.ToString(sHA.ComputeHash(array2)).Replace("-", "") != "DD7C5A17F1CD6A0FB7CD1517A417FF974B67270D57840D9DD5854281A2803047")
					{
						throw new InvalidOperationException("Exact source triangle stream for equipment hiding");
					}
				}
				ready = true;
				Info("BARBARIAN_VIKING_TAYLOR 1.0.0 READY assemblySHA256=" + Hash(typeof(Plugin).Assembly.Location) + " bundleSHA256=6C2E51EEEA7BBCED0BBEB7A14C2A28023B8274F90955D792F099B57D41B89709 sourceSHA256=B7FE7C3574235353C5637B5426324A40452315B24EEBE2E6DA14439C4D6A0A1B F8=True silverArmor=True oldAvatarExcluded=True AuthorMode=False anyPlayerF8=True nativeAnimatorRetained=True liveVisualGate=PENDING");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("TAYLOR_V5_TEST safely disabled; vanilla retained: " + ex));
			}
		}

		private void TryLoadCloak(string directory)
		{
			try
			{
				string text = Path.Combine(directory, "nh_taylor_wolfcloak");
				RequireHash(text, "C1915510D2676F2EA1C48547D64E531E661FA00926F3AA7C2FFE8A1AE5152F42");
				cloakBundle = AssetBundle.LoadFromFile(text);
				if (!Object.op_Implicit((Object)(object)cloakBundle) || cloakBundle.GetAllAssetNames().Length != 1)
				{
					throw new InvalidOperationException("One custom cloak asset required");
				}
				CloakPrefab = cloakBundle.LoadAsset<GameObject>("TaylorWolfCloak");
				if (!Object.op_Implicit((Object)(object)CloakPrefab) || CloakPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 2 || CloakPrefab.GetComponentsInChildren<Animator>(true).Length != 0)
				{
					throw new InvalidOperationException("Cloak two-renderer contract");
				}
				TaylorWolfCloakItems.PrepareVisualTemplate(CloakPrefab);
				Info("TAYLOR_WOLF_CLOAK_ASSET verified hash=C1915510D2676F2EA1C48547D64E531E661FA00926F3AA7C2FFE8A1AE5152F42 physics=Pending");
			}
			catch (Exception ex)
			{
				CloakPrefab = null;
				Info("TAYLOR_WOLF_CLOAK_UNAVAILABLE acceptedTaylorPreserved=True error=" + ex.Message);
			}
		}

		internal static string Hash(string p)
		{
			using FileStream inputStream = File.OpenRead(p);
			using SHA256 sHA = SHA256.Create();
			return BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "");
		}

		internal static void RequireHash(string p, string h)
		{
			if (Hash(p) != h)
			{
				throw new InvalidOperationException("Payload mismatch " + Path.GetFileName(p));
			}
		}

		private void Update()
		{
			if (!ready || Time.realtimeSinceStartup < next)
			{
				return;
			}
			next = Time.realtimeSinceStartup + 0.5f;
			Player[] array = Object.FindObjectsByType<Player>((FindObjectsSortMode)0);
			foreach (Player val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && !Object.op_Implicit((Object)(object)((Component)val).GetComponent<TaylorV5Appearance>()))
				{
					VisEquipment component = ((Component)val).GetComponent<VisEquipment>();
					if (Object.op_Implicit((Object)(object)component) && component.m_isPlayer && !component.m_isArmorStand)
					{
						TaylorV5Appearance taylorV5Appearance = ((Component)val).gameObject.AddComponent<TaylorV5Appearance>();
						appearances.Add(taylorV5Appearance);
						taylorV5Appearance.Initialize(val, component);
					}
				}
			}
		}

		private void OnDestroy()
		{
			ready = false;
			foreach (TaylorV5Appearance appearance in appearances)
			{
				if (Object.op_Implicit((Object)(object)appearance))
				{
					Object.Destroy((Object)(object)appearance);
				}
			}
			TaylorSilverItems.Shutdown();
			CloakPrefab = null;
			if (Object.op_Implicit((Object)(object)cloakBundle))
			{
				cloakBundle.Unload(false);
			}
			if (Object.op_Implicit((Object)(object)armorBundle))
			{
				armorBundle.Unload(false);
			}
			if (Object.op_Implicit((Object)(object)bundle))
			{
				bundle.Unload(false);
			}
		}

		internal static void Info(string s)
		{
			if (Object.op_Implicit((Object)(object)Instance))
			{
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)s);
			}
		}

		internal static void Error(Exception e)
		{
			if (Object.op_Implicit((Object)(object)Instance))
			{
				((BaseUnityPlugin)Instance).Logger.LogError((object)("TAYLOR_V5_TEST vanilla restored: " + e));
			}
		}
	}
	[DefaultExecutionOrder(10000)]
	public sealed class TaylorV5Appearance : MonoBehaviour
	{
		private Player player;

		private VisEquipment equipment;

		private SkinnedMeshRenderer nativeBody;

		private Animator animator;

		private AnimatorCullingMode original;

		private bool cullingOwned;

		private bool selected;

		private bool faulted;

		private bool initialized;

		private GameObject visual;

		private readonly GameObject[] parts = (GameObject[])(object)new GameObject[5];

		private readonly SkinnedMeshRenderer[] skins = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[5];

		private readonly List<Object> owned = new List<Object>();

		private readonly Dictionary<Renderer, bool> hidden = new Dictionary<Renderer, bool>();

		private TaylorV5FittedPoseDriver driver;

		private TaylorV5GripAdapter grip;

		private TaylorV5ClothClearance clearance;

		private TaylorSilverVisibility silver;

		private TaylorWolfCloak cloak;

		private GameObject cloakRoot;

		private ZNetView view;

		private ZDO localState;

		private static readonly BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo animatorField = typeof(Character).GetField("m_animator", flags);

		private static readonly FieldInfo[] hairFields = (from f in typeof(VisEquipment).GetFields(flags)
			where (f.Name.ToLowerInvariant().Contains("hair") || f.Name.ToLowerInvariant().Contains("beard")) && (f.Name.EndsWith("Instance") || f.Name.EndsWith("Instances"))
			select f).ToArray();

		internal void Initialize(Player p, VisEquipment v)
		{
			player = p;
			equipment = v;
			view = ((Component)p).GetComponent<ZNetView>();
			selected = false;
			if ((Object)(object)p == (Object)(object)Player.m_localPlayer && Object.op_Implicit((Object)(object)view) && view.IsValid() && view.IsOwner())
			{
				localState = view.GetZDO();
				localState.Set("nh_barbarianviking_taylor_avatar_v1", false);
			}
			initialized = true;
		}

		private void Update()
		{
			if (!initialized || !Object.op_Implicit((Object)(object)view) || !view.IsValid())
			{
				return;
			}
			try
			{
				ZDO zDO = view.GetZDO();
				if ((Object)(object)player == (Object)(object)Player.m_localPlayer)
				{
					if (!AuthorState.CanActivate(Plugin.Enabled != null && Plugin.Enabled.Value, identity: true, local: true, view.IsOwner(), ready: true))
					{
						RevokeLocal();
						selected = false;
					}
					else if (Input.GetKeyDown((KeyCode)289))
					{
						bool flag = !zDO.GetBool("nh_barbarianviking_taylor_avatar_v1", false);
						if (flag)
						{
							faulted = false;
							if (!Object.op_Implicit((Object)(object)visual))
							{
								CreateVisual();
							}
						}
						selected = flag;
						zDO.Set("nh_barbarianviking_taylor_avatar_v1", selected);
						Plugin.Info("BARBARIAN_TAYLOR_F8 appearance=" + selected + " samePlayer=" + ((Object)player).GetInstanceID());
					}
					else
					{
						selected = zDO.GetBool("nh_barbarianviking_taylor_avatar_v1", false);
					}
				}
				else
				{
					selected = AuthorState.CanRender(ready: true, livePlayer: true, validView: true, zDO.GetBool("nh_barbarianviking_taylor_avatar_v1", false), validatedIdentity: true);
				}
			}
			catch (Exception e)
			{
				faulted = true;
				selected = false;
				RevokeLocal();
				DestroyVisual();
				Plugin.Error(e);
			}
		}

		private void LateUpdate()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)equipment) || !selected || faulted)
			{
				Restore();
				if (Object.op_Implicit((Object)(object)visual))
				{
					visual.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)parts[0]))
				{
					parts[0].SetActive(false);
				}
				return;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)visual) && (Object)(object)nativeBody != (Object)(object)equipment.m_bodyModel)
				{
					DestroyVisual();
				}
				if (!Object.op_Implicit((Object)(object)visual))
				{
					if (!Object.op_Implicit((Object)(object)equipment.m_bodyModel))
					{
						return;
					}
					CreateVisual();
				}
				if (!Object.op_Implicit((Object)(object)animator) || !((Behaviour)animator).isActiveAndEnabled)
				{
					throw new InvalidOperationException("Native Animator unavailable");
				}
				if (!cullingOwned)
				{
					original = animator.cullingMode;
					cullingOwned = true;
				}
				animator.cullingMode = (AnimatorCullingMode)0;
				driver.Tick();
				clearance.Tick(driver.LastAuthorLocal);
				grip.Tick();
				silver.Tick();
				visual.SetActive(true);
				if (cloak != null)
				{
					cloak.Tick();
				}
				parts[0].SetActive(true);
				Hide((Renderer)(object)nativeBody);
				HideHair();
				HideOtherArmor();
				if (driver.SuccessfulTicks == 1)
				{
					Plugin.Info("BARBARIAN_TAYLOR_DRIVER 1.0.0 initialized wrapper=" + driver.NativeWrapperScale + " acceptedFace=True Phase1NeckClosure=True starterCloth=True gripVisualAdapter=True F8=True replicatedSelection=True liveVisualGate=PENDING");
				}
			}
			catch (Exception e)
			{
				faulted = true;
				selected = false;
				RevokeLocal();
				DestroyVisual();
				Plugin.Error(e);
			}
		}

		private void CreateVisual()
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			nativeBody = equipment.m_bodyModel;
			ref Animator reference = ref animator;
			object? value = animatorField.GetValue(player);
			reference = (Animator)((value is Animator) ? value : null);
			if (!Object.op_Implicit((Object)(object)animator) || !Object.op_Implicit((Object)(object)animator.avatar) || !Object.op_Implicit((Object)(object)animator.runtimeAnimatorController))
			{
				throw new InvalidOperationException("Native animation source unavailable");
			}
			Dictionary<string, Transform> n = nativeBody.bones.ToDictionary<Transform, string>((Transform b) => ((Object)b).name, StringComparer.Ordinal);
			Transform[] array = TaylorV5MotionData.Names.Select((string x) => (!n.ContainsKey(x)) ? null : n[x]).ToArray();
			if (array.Any((Transform x) => !Object.op_Implicit((Object)(object)x)))
			{
				throw new InvalidOperationException("Native53 palette incomplete");
			}
			visual = new GameObject("NH_TaylorV5_PrivateVisual");
			visual.SetActive(false);
			visual.transform.SetParent(((Component)player).transform, false);
			TaylorV5CanonicalCoordinates.RegisterUnderPlayer(visual.transform, ((Component)player).transform);
			for (int num = 0; num < 5; num++)
			{
				parts[num] = Object.Instantiate<GameObject>(Plugin.Prefabs[num], visual.transform, false);
				skins[num] = parts[num].GetComponentInChildren<SkinnedMeshRenderer>(true);
				if (num == 0)
				{
					V5ImportedVisibilityGuard.Validate(skins[num].sharedMesh, Plugin.RegionBits);
				}
				TaylorV5CanonicalCoordinates.ConvertClone(parts[num], owned);
				if (parts[num].GetComponentsInChildren<Animator>(true).Length != 0)
				{
					throw new InvalidOperationException("Unexpected imported Animator");
				}
				Transform[] componentsInChildren = parts[num].GetComponentsInChildren<Transform>(true);
				for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
				{
					((Component)componentsInChildren[num2]).gameObject.layer = ((Component)nativeBody).gameObject.layer;
				}
				skins[num].quality = (SkinQuality)4;
				skins[num].updateWhenOffscreen = true;
				((Renderer)skins[num]).shadowCastingMode = (ShadowCastingMode)1;
				((Renderer)skins[num]).receiveShadows = true;
				((Renderer)skins[num]).sharedMaterials = ((num < 2) ? V5NativeMaterials.CreatePlayerMaterials(nativeBody, ((Renderer)skins[num]).sharedMaterials, owned, Plugin.Info) : ((Renderer)skins[num]).sharedMaterials.Select((Material m) => TaylorSilverItems.ArmorMaterial(m, owned)).ToArray());
				((Renderer)skins[num]).SetPropertyBlock((MaterialPropertyBlock)null);
			}
			parts[0].SetActive(false);
			parts[0].transform.SetParent(((Component)player).transform, false);
			TaylorV5CanonicalCoordinates.RegisterUnderPlayer(parts[0].transform, ((Component)player).transform);
			Dictionary<string, Transform> fitted = skins[0].bones.ToDictionary((Transform t) => ((Object)t).name);
			for (int num3 = 1; num3 < 5; num3++)
			{
				Transform parent = skins[num3].rootBone.parent;
				skins[num3].bones = skins[num3].bones.Select((Transform t) => fitted[((Object)t).name]).ToArray();
				skins[num3].rootBone = skins[0].rootBone;
				if (Object.op_Implicit((Object)(object)parent) && !Object.op_Implicit((Object)(object)((Component)parent).GetComponentInChildren<Renderer>(true)))
				{
					Object.Destroy((Object)(object)((Component)parent).gameObject);
				}
			}
			driver = new TaylorV5FittedPoseDriver(((Component)player).transform, array[0].parent, array, parts[0].transform, skins[0], skins[1], null, null);
			clearance = new TaylorV5ClothClearance(skins[1]);
			grip = new TaylorV5GripAdapter(player, equipment, array, skins[0].bones, Plugin.Info);
			silver = new TaylorSilverVisibility(equipment, skins[0], skins[1], parts.Skip(2).ToArray(), owned);
			TryCreateCloak(fitted);
		}

		private void TryCreateCloak(Dictionary<string, Transform> fitted)
		{
			if (!Object.op_Implicit((Object)(object)Plugin.CloakPrefab))
			{
				return;
			}
			try
			{
				cloakRoot = Object.Instantiate<GameObject>(Plugin.CloakPrefab, visual.transform, false);
				((Object)cloakRoot).name = "NH_TaylorWolfCloak_Owned";
				cloakRoot.SetActive(false);
				string[] array = new string[2] { "Mantle", "Drape" };
				SkinnedMeshRenderer[] array2 = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[2];
				for (int i = 0; i < 2; i++)
				{
					Transform obj = cloakRoot.transform.Find(array[i]);
					if (!Object.op_Implicit((Object)(object)obj))
					{
						throw new InvalidOperationException("Cloak child identity " + array[i]);
					}
					TaylorV5CanonicalCoordinates.ConvertClone(((Component)obj).gameObject, owned);
					SkinnedMeshRenderer val = ((Component)obj).GetComponentsInChildren<SkinnedMeshRenderer>(true).Single();
					Transform[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Transform>(true);
					for (int j = 0; j < componentsInChildren.Length; j++)
					{
						((Component)componentsInChildren[j]).gameObject.layer = ((Component)nativeBody).gameObject.layer;
					}
					Transform parent = val.rootBone.parent;
					val.bones = val.bones.Select((Transform b) => fitted[((Object)b).name]).ToArray();
					val.rootBone = skins[0].rootBone;
					val.quality = (SkinQuality)4;
					val.updateWhenOffscreen = true;
					((Renderer)val).shadowCastingMode = (ShadowCastingMode)1;
					((Renderer)val).receiveShadows = true;
					if (i == 0)
					{
						((Renderer)val).sharedMaterials = ((Renderer)val).sharedMaterials.Select((Material m) => TaylorWolfCloakMaterials.Mantle(m, owned)).ToArray();
					}
					((Renderer)val).SetPropertyBlock((MaterialPropertyBlock)null);
					if (Object.op_Implicit((Object)(object)parent) && !Object.op_Implicit((Object)(object)((Component)parent).GetComponentInChildren<Renderer>(true)))
					{
						Object.Destroy((Object)(object)((Component)parent).gameObject);
					}
					array2[i] = val;
				}
				cloak = new TaylorWolfCloak(cloakRoot, array2[0], array2[1], skins[0], nativeBody, equipment, player, owned, Plugin.Info);
			}
			catch (Exception ex)
			{
				if (cloak != null)
				{
					cloak.Dispose();
				}
				cloak = null;
				if (Object.op_Implicit((Object)(object)cloakRoot))
				{
					cloakRoot.SetActive(false);
					Object.Destroy((Object)(object)cloakRoot);
				}
				cloakRoot = null;
				Plugin.Info("TAYLOR_WOLF_CLOAK_CREATE_FAILED acceptedTaylorPreserved=True error=" + ex.Message);
			}
		}

		private void HideOtherArmor()
		{
			FieldInfo[] fields = typeof(VisEquipment).GetFields(flags);
			foreach (FieldInfo fieldInfo in fields)
			{
				string text = fieldInfo.Name.ToLowerInvariant();
				if ((!text.Contains("helmet") && !text.Contains("chest") && !text.Contains("leg") && !text.Contains("shoulder")) || (!text.EndsWith("instance") && !text.EndsWith("instances")))
				{
					continue;
				}
				object value = fieldInfo.GetValue(equipment);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
					foreach (Renderer r in componentsInChildren)
					{
						Hide(r);
					}
				}
				else
				{
					if (!(value is IEnumerable))
					{
						continue;
					}
					foreach (object item in (IEnumerable)value)
					{
						GameObject val2 = (GameObject)((item is GameObject) ? item : null);
						if (Object.op_Implicit((Object)(object)val2))
						{
							Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true);
							foreach (Renderer r2 in componentsInChildren)
							{
								Hide(r2);
							}
						}
					}
				}
			}
		}

		private void Hide(Renderer r)
		{
			if (Object.op_Implicit((Object)(object)r))
			{
				if (!hidden.ContainsKey(r))
				{
					hidden.Add(r, r.enabled);
				}
				r.enabled = false;
			}
		}

		private void HideHair()
		{
			FieldInfo[] array = hairFields;
			for (int i = 0; i < array.Length; i++)
			{
				object value = array[i].GetValue(equipment);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
					foreach (Renderer r in componentsInChildren)
					{
						Hide(r);
					}
				}
				else
				{
					if (!(value is IEnumerable))
					{
						continue;
					}
					foreach (object item in (IEnumerable)value)
					{
						GameObject val2 = (GameObject)((item is GameObject) ? item : null);
						if (Object.op_Implicit((Object)(object)val2))
						{
							Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true);
							foreach (Renderer r2 in componentsInChildren)
							{
								Hide(r2);
							}
						}
					}
				}
			}
		}

		private void Restore()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (cloak != null)
			{
				cloak.Restore();
			}
			if (silver != null)
			{
				silver.Restore();
			}
			if (grip != null)
			{
				grip.Restore();
			}
			foreach (KeyValuePair<Renderer, bool> item in hidden)
			{
				if (Object.op_Implicit((Object)(object)item.Key))
				{
					item.Key.enabled = item.Value;
				}
			}
			hidden.Clear();
			if (cullingOwned && Object.op_Implicit((Object)(object)animator) && (int)animator.cullingMode == 0)
			{
				animator.cullingMode = original;
			}
			cullingOwned = false;
		}

		private void DestroyVisual()
		{
			Restore();
			if (cloak != null)
			{
				cloak.Dispose();
			}
			cloak = null;
			cloakRoot = null;
			if (grip != null)
			{
				grip.Clear();
			}
			if (Object.op_Implicit((Object)(object)visual))
			{
				visual.SetActive(false);
				Object.Destroy((Object)(object)visual);
			}
			if (Object.op_Implicit((Object)(object)parts[0]))
			{
				parts[0].SetActive(false);
				Object.Destroy((Object)(object)parts[0]);
			}
			for (int i = 0; i < 5; i++)
			{
				parts[i] = null;
				skins[i] = null;
			}
			foreach (Object item in owned)
			{
				if (Object.op_Implicit(item))
				{
					Object.Destroy(item);
				}
			}
			owned.Clear();
			visual = null;
			driver = null;
			grip = null;
			clearance = null;
			silver = null;
		}

		private void RevokeLocal()
		{
			try
			{
				if (localState != null && ZDOMan.instance != null && localState.IsOwner())
				{
					localState.Set("nh_barbarianviking_taylor_avatar_v1", false);
				}
			}
			catch
			{
			}
		}

		private void OnDestroy()
		{
			RevokeLocal();
			DestroyVisual();
		}
	}
	public static class SilverBuildContract
	{
		public const string BundleSHA256 = "D5C52519793EE054BC64212FD20D1DFF0AE4CBACAFA4331109AE7E9241550738";

		public const string MaskSHA256 = "337E81265C4DFF00EEF9A26B42CC2C8B734199B9EF87595EEABBB22EB50C3790";
	}
	public static class TaylorSilverItems
	{
		public static readonly string[] Slots = new string[3] { "Helmet", "Chest", "Legguards" };

		public static readonly string[] Tiers = new string[4] { "Silver", "Plains", "Mistlands", "Ashlands" };

		private static readonly string[,] Vanilla = new string[4, 3]
		{
			{ "HelmetDrake", "ArmorWolfChest", "ArmorWolfLegs" },
			{ "HelmetPadded", "ArmorPaddedCuirass", "ArmorPaddedGreaves" },
			{ "HelmetCarapace", "ArmorCarapaceChest", "ArmorCarapaceLegs" },
			{ "HelmetFlametal", "ArmorFlametalChest", "ArmorFlametalLegs" }
		};

		private static readonly Dictionary<string, CustomItem> items = new Dictionary<string, CustomItem>();

		private static readonly Dictionary<int, int> equipmentSlots = new Dictionary<int, int>();

		public static string Id(int tier, int slot)
		{
			return "NH_Taylor" + Tiers[tier] + Slots[slot];
		}

		public static int SlotForHash(int hash)
		{
			if (!equipmentSlots.TryGetValue(hash, out var value))
			{
				return -1;
			}
			return value;
		}

		public static void Initialize()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Register;
			ItemManager.OnItemsRegistered += Synchronize;
			ItemManager.OnItemsRegisteredFejd += Synchronize;
		}

		public static void Shutdown()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			ItemManager.OnItemsRegistered -= Synchronize;
			ItemManager.OnItemsRegisteredFejd -= Synchronize;
		}

		private static void Register()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			try
			{
				for (int i = 0; i < 4; i++)
				{
					for (int j = 0; j < 3; j++)
					{
						string text = Id(i, j);
						string text2 = Vanilla[i, j];
						GameObject prefab = PrefabManager.Instance.GetPrefab(text2);
						if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemDrop>()))
						{
							throw new InvalidOperationException("Required vanilla armor unavailable " + text2);
						}
						ItemConfig val = new ItemConfig
						{
							Name = "Taylor " + Tiers[i] + " " + Slots[j],
							Description = "Fitted silver wolf armor. " + ((i == 0) ? "Mountain resources matching vanilla silver armor." : "Reforge the preceding Taylor armor using this biome's vanilla armor resources.") + ((j == 0) ? " Frost protection matching the Wolf Fur Cape." : ""),
							CraftingStation = ((i < 2) ? "forge" : "blackforge"),
							Requirements = (RequirementConfig[])(object)new RequirementConfig[0]
						};
						CustomItem val2 = new CustomItem(text, text2, val);
						if (val2.ItemDrop.m_itemData.m_shared == prefab.GetComponent<ItemDrop>().m_itemData.m_shared)
						{
							throw new InvalidOperationException("Item shared data must be independent");
						}
						Recipe val3 = ScriptableObject.CreateInstance<Recipe>();
						((Object)val3).name = "Recipe_" + text;
						val3.m_item = val2.ItemDrop;
						val3.m_resources = (Requirement[])(object)new Requirement[0];
						val3.m_amount = 1;
						val3.m_enabled = false;
						val2.Recipe = new CustomRecipe(val3, false, false);
						if (!ItemManager.Instance.AddItem(val2))
						{
							throw new InvalidOperationException("Item registration rejected " + text);
						}
						items.Add(text, val2);
						equipmentSlots.Add(StringExtensionMethods.GetStableHashCode(text), j);
					}
				}
				Plugin.Info("TAYLOR_SILVER_ITEMS registered=12 vanillaChaosItemsUnchanged=True recipesPendingExactVanillaCopy=True");
			}
			catch (Exception e)
			{
				Plugin.Error(e);
			}
		}

		private unsafe static void Synchronize()
		{
			//IL_022b: 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_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ObjectDB instance = ObjectDB.instance;
				if (!Object.op_Implicit((Object)(object)instance) || instance.m_recipes == null)
				{
					return;
				}
				for (int t = 0; t < 4; t++)
				{
					int s;
					for (s = 0; s < 3; s++)
					{
						string text = Id(t, s);
						if (!items.TryGetValue(text, out var value))
						{
							continue;
						}
						GameObject itemPrefab = instance.GetItemPrefab(Vanilla[t, s]);
						GameObject itemPrefab2 = instance.GetItemPrefab(text);
						if (!Object.op_Implicit((Object)(object)itemPrefab) || !Object.op_Implicit((Object)(object)itemPrefab2))
						{
							continue;
						}
						SharedData shared = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						SharedData shared2 = itemPrefab2.GetComponent<ItemDrop>().m_itemData.m_shared;
						shared2.m_armor = shared.m_armor;
						shared2.m_armorPerLevel = shared.m_armorPerLevel;
						shared2.m_maxQuality = shared.m_maxQuality;
						shared2.m_weight = shared.m_weight;
						shared2.m_scaleWeightByQuality = shared.m_scaleWeightByQuality;
						shared2.m_maxDurability = shared.m_maxDurability;
						shared2.m_durabilityPerLevel = shared.m_durabilityPerLevel;
						shared2.m_movementModifier = shared.m_movementModifier;
						shared2.m_eitrRegenModifier = shared.m_eitrRegenModifier;
						shared2.m_heatResistanceModifier = shared.m_heatResistanceModifier;
						shared2.m_damageModifiers = new List<DamageModPair>(shared.m_damageModifiers);
						if (s == 0)
						{
							GameObject itemPrefab3 = instance.GetItemPrefab("CapeWolf");
							if (!Object.op_Implicit((Object)(object)itemPrefab3))
							{
								throw new InvalidOperationException("CapeWolf frost reference unavailable");
							}
							List<DamageModPair> list = itemPrefab3.GetComponent<ItemDrop>().m_itemData.m_shared.m_damageModifiers.Where((DamageModPair x) => (int)x.m_type == 64).ToList();
							if (list.Count != 1)
							{
								throw new InvalidOperationException("CapeWolf has no unique Frost modifier; do not invent one");
							}
							shared2.m_damageModifiers.RemoveAll((DamageModPair x) => (int)x.m_type == 64);
							shared2.m_damageModifiers.Add(list[0]);
						}
						Recipe val = ((value.Recipe != null) ? value.Recipe.Recipe : null);
						Recipe val2 = ((IEnumerable<Recipe>)instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && ((Object)r.m_item).name == Vanilla[t, s] && r.m_resources != null && r.m_resources.Length != 0));
						if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
						{
							if (Object.op_Implicit((Object)(object)val))
							{
								val.m_enabled = false;
							}
							Plugin.Info("TAYLOR_SILVER_RECIPE unavailable=" + text + " missingVanillaRecipe=True");
							continue;
						}
						List<Requirement> list2 = ((IEnumerable<Requirement>)val2.m_resources).Select((Func<Requirement, Requirement>)((Requirement r) => new Requirement
						{
							m_resItem = r.m_resItem,
							m_amount = r.m_amount,
							m_extraAmountOnlyOneIngredient = r.m_extraAmountOnlyOneIngredient,
							m_amountPerLevel = r.m_amountPerLevel,
							m_upgraderResource = r.m_upgraderResource,
							m_recover = r.m_recover
						})).ToList();
						if (t > 0)
						{
							GameObject itemPrefab4 = instance.GetItemPrefab(Id(t - 1, s));
							if (!Object.op_Implicit((Object)(object)itemPrefab4))
							{
								throw new InvalidOperationException("Previous tier missing " + text);
							}
							list2.Add(new Requirement
							{
								m_resItem = itemPrefab4.GetComponent<ItemDrop>(),
								m_amount = 1,
								m_amountPerLevel = 0,
								m_recover = false
							});
						}
						val.m_craftingStation = val2.m_craftingStation;
						val.m_repairStation = val2.m_repairStation;
						val.m_minStationLevel = val2.m_minStationLevel;
						val.m_amount = 1;
						val.m_requireOnlyOneIngredient = val2.m_requireOnlyOneIngredient;
						val.m_qualityResultAmountMultiplier = val2.m_qualityResultAmountMultiplier;
						val.m_resources = list2.ToArray();
						val.m_enabled = true;
						string[] obj = new string[10]
						{
							"TAYLOR_SILVER_RECIPE ",
							text,
							" source=",
							Vanilla[t, s],
							" station=",
							Object.op_Implicit((Object)(object)val.m_craftingStation) ? ((Object)val.m_craftingStation).name : "none",
							" resources=",
							string.Join(",", list2.Select((Requirement r) => ((Object)r.m_resItem).name + ":" + r.m_amount + "+" + r.m_amountPerLevel + "/quality")),
							" frost=",
							null
						};
						object obj2;
						if (s != 0)
						{
							obj2 = "native";
						}
						else
						{
							DamageModPair val3 = shared2.m_damageModifiers.First((DamageModPair r) => (int)r.m_type == 64);
							obj2 = ((object)(*(DamageModifier*)(&val3.m_modifier))/*cast due to .constrained prefix*/).ToString();
						}
						obj[9] = (string)obj2;
						Plugin.Info(string.Concat(obj));
					}
				}
			}
			catch (Exception e)
			{
				Plugin.Error(e);
			}
		}

		public static Material ArmorMaterial(Material source, List<Object> owned)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = PrefabManager.Instance.GetPrefab("ArmorWolfChest");
			Renderer val = (Object.op_Implicit((Object)(object)prefab) ? ((IEnumerable<Renderer>)prefab.GetComponentsInChildren<Renderer>(true)).FirstOrDefault((Func<Renderer, bool>)((Renderer x) => Object.op_Implicit((Object)(object)x.sharedMaterial) && ((Object)x.sharedMaterial.shader).name == "Custom/Creature")) : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				prefab = PrefabManager.Instance.GetPrefab("ArmorBronzeChest");
				val = (Object.op_Implicit((Object)(object)prefab) ? ((IEnumerable<Renderer>)prefab.GetComponentsInChildren<Renderer>(true)).FirstOrDefault((Func<Renderer, bool>)((Renderer x) => Object.op_Implicit((Object)(object)x.sharedMaterial) && ((Object)x.sharedMaterial.shader).name == "Custom/Creature")) : null);
			}
			if (!Object.op_Implicit((Object)(object)val) || !val.sharedMaterial.shader.isSupported)
			{
				throw new InvalidOperationException("Supported native Custom/Creature armor shader required");
			}
			Material val2 = new Material(val.sharedMaterial)
			{
				name = ((Object)source).name + "_NativeCreature"
			};
			owned.Add((Object)(object)val2);
			val2.SetTexture("_MainTex", source.GetTexture("_MainTex"));
			val2.SetTexture("_MetallicGlossMap", source.GetTexture("_MetallicGlossMap"));
			if (val2.HasProperty("_BumpMap"))
			{
				val2.SetTexture("_BumpMap", source.GetTexture("_BumpMap"));
				if (Object.op_Implicit((Object)(object)source.GetTexture("_BumpMap")))
				{
					val2.EnableKeyword("_NORMALMAP");
				}
				else
				{
					val2.DisableKeyword("_NORMALMAP");
				}
			}
			if (val2.HasProperty("_BumpScale"))
			{
				val2.SetFloat("_BumpScale", 1f);
			}
			if (val2.HasProperty("_EmissionMap"))
			{
				val2.SetTexture("_EmissionMap", (Texture)null);
			}
			string[] array = new string[2] { "_Color", "_MetalColor" };
			foreach (string text in array)
			{
				if (val2.HasProperty(text))
				{
					val2.SetColor(text, Color.white);
				}
			}
			array = new string[3] { "_Hue", "_Saturation", "_Value" };
			foreach (string text2 in array)
			{
				if (val2.HasProperty(text2))
				{
					val2.SetFloat(text2, 0f);
				}
			}
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 1f);
			}
			if (val2.HasProperty("_MetalGloss"))
			{
				val2.SetFloat("_MetalGloss", 1f);
			}
			if (val2.HasProperty("_Glossiness"))
			{
				val2.SetFloat("_Glossiness", 1f);
			}
			if (val2.HasProperty("_UseGlossmap"))
			{
				val2.SetFloat("_UseGlossmap", 1f);
			}
			val2.DisableKeyword("_EMISSION");
			return val2;
		}
	}
	public sealed class TaylorSilverVisibility
	{
		private readonly VisEquipment equipment;

		private readonly SkinnedMeshRenderer body;

		private readonly SkinnedMeshRenderer pants;

		private readonly GameObject[] armor;

		private readonly Mesh original;

		private readonly List<Object> owned;

		private readonly Dictionary<int, Mesh> variants = new Dictionary<int, Mesh>();

		private static readonly FieldRef<VisEquipment, int> helmet = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentHelmetItemHash");

		private static readonly FieldRef<VisEquipment, int> chest = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentChestItemHash");

		private static readonly FieldRef<VisEquipment, int> legs = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentLegItemHash");

		public TaylorSilverVisibility(VisEquipment v, SkinnedMeshRenderer b, SkinnedMeshRenderer p, GameObject[] components, List<Object> owners)
		{
			equipment = v;
			body = b;
			pants = p;
			armor = components;
			owned = owners;
			original = b.sharedMesh;
			if (Plugin.FaceBits.Length != original.triangles.Length / 3)
			{
				throw new InvalidOperationException("Exact body-face coverage count");
			}
		}

		public void Tick()
		{
			int num = (int)(((TaylorSilverItems.SlotForHash(helmet.Invoke(equipment)) == 0) ? 1u : 0u) | (uint)((TaylorSilverItems.SlotForHash(chest.Invoke(equipment)) == 1) ? 2 : 0)) | ((TaylorSilverItems.SlotForHash(legs.Invoke(equipment)) == 2) ? 4 : 0);
			for (int i = 0; i < 3; i++)
			{
				armor[i].SetActive((num & (1 << i)) != 0);
			}
			((Component)pants).gameObject.SetActive((num & 4) == 0);
			body.sharedMesh = ((num == 0) ? original : Variant(num));
		}

		private Mesh Variant(int mask)
		{
			if (variants.TryGetValue(mask, out var value))
			{
				return value;
			}
			value = Object.Instantiate<Mesh>(original);
			((Object)value).name = ((Object)original).name + "_SilverEquipmentMask_" + mask;
			int i = 0;
			int num = 0;
			for (; i < original.subMeshCount; i++)
			{
				int[] triangles = original.GetTriangles(i);
				List<int> list = new List<int>();
				for (int j = 0; j < triangles.Length; j += 3)
				{
					if ((Plugin.FaceBits[num + j / 3] & mask) == 0)
					{
						list.Add(triangles[j]);
						list.Add(triangles[j + 1]);
						list.Add(triangles[j + 2]);
					}
				}
				value.SetTriangles(list, i, false);
				num += triangles.Length / 3;
			}
			owned.Add((Object)(object)value);
			variants.Add(mask, value);
			return value;
		}

		public void Restore()
		{
			if (Object.op_Implicit((Object)(object)body))
			{
				body.sharedMesh = original;
			}
			if (Object.op_Implicit((Object)(object)pants))
			{
				((Component)pants).gameObject.SetActive(true);
			}
			GameObject[] array = armor;
			foreach (GameObject val in array)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetActive(false);
				}
			}
		}
	}
	public static class TaylorV5CanonicalCoordinates
	{
		private static Vector3 Reflect(Vector3 a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(0f - a.x, a.y, a.z);
		}

		private static Matrix4x4 Conjugate(Matrix4x4 a)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					if (i == 0 != (j == 0))
					{
						((Matrix4x4)(ref a))[i, j] = 0f - ((Matrix4x4)(ref a))[i, j];
					}
				}
			}
			return a;
		}

		public static void RegisterUnderPlayer(Transform root, Transform host)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			root.SetParent(host, false);
			root.localPosition = new Vector3((float)TaylorV5MotionData.PlayerRegistration[0], (float)TaylorV5MotionData.PlayerRegistration[1], (float)TaylorV5MotionData.PlayerRegistration[2]);
			root.localRotation = Quaternion.identity;
			root.localScale = Vector3.one;
		}

		public static void ConvertClone(GameObject importedClone, ICollection<Object> owned)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_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_0103: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: 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_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)importedClone))
			{
				throw new ArgumentNullException("importedClone");
			}
			Transform[] componentsInChildren = importedClone.GetComponentsInChildren<Transform>(true);
			foreach (Transform obj in componentsInChildren)
			{
				Vector3 localPosition = obj.localPosition;
				Quaternion localRotation = obj.localRotation;
				obj.localPosition = Reflect(localPosition);
				obj.localRotation = new Quaternion(localRotation.x, 0f - localRotation.y, 0f - localRotation.z, localRotation.w);
			}
			SkinnedMeshRenderer[] componentsInChildren2 = importedClone.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			if (componentsInChildren2.Length != 1)
			{
				throw new InvalidOperationException("Expected one independently imported equipment renderer");
			}
			SkinnedMeshRenderer val = componentsInChildren2[0];
			Mesh sharedMesh = val.sharedMesh;
			if (!Object.op_Implicit((Object)(object)sharedMesh) || !sharedMesh.isReadable)
			{
				throw new InvalidOperationException("Readable imported source mesh required");
			}
			Mesh val2 = Object.Instantiate<Mesh>(sharedMesh);
			((Object)val2).name = ((Object)sharedMesh).name + "_NATIVE_COORDINATE_TEST_COPY";
			owned?.Add((Object)(object)val2);
			Vector3[] array = (Vector3[])sharedMesh.vertices.Clone();
			for (int j = 0; j < array.Length; j++)
			{
				array[j] = Reflect(array[j]);
			}
			val2.vertices = array;
			Vector3[] array2 = (Vector3[])sharedMesh.normals.Clone();
			for (int k = 0; k < array2.Length; k++)
			{
				array2[k] = Reflect(array2[k]);
			}
			val2.normals = array2;
			Vector4[] array3 = (Vector4[])sharedMesh.tangents.Clone();
			for (int l = 0; l < array3.Length; l++)
			{
				array3[l] = new Vector4(0f - array3[l].x, array3[l].y, array3[l].z, 0f - array3[l].w);
			}
			val2.tangents = array3;
			Matrix4x4[] bindposes = sharedMesh.bindposes;
			for (int m = 0; m < bindposes.Length; m++)
			{
				bindposes[m] = Conjugate(bindposes[m]);
			}
			val2.bindposes = bindposes;
			for (int n = 0; n < sharedMesh.subMeshCount; n++)
			{
				if ((int)sharedMesh.GetTopology(n) != 0)
				{
					throw new InvalidOperationException("Expected triangle submesh");
				}
				int[] triangles = sharedMesh.GetTriangles(n);
				for (int num = 0; num < triangles.Length; num += 3)
				{
					int num2 = triangles[num + 1];
					triangles[num + 1] = triangles[num + 2];
					triangles[num + 2] = num2;
				}
				val2.SetTriangles(triangles, n, false);
			}
			val2.ClearBlendShapes();
			for (int num3 = 0; num3 < sharedMesh.blendShapeCount; num3++)
			{
				string blendShapeName = sharedMesh.GetBlendShapeName(num3);
				int blendShapeFrameCount = sharedMesh.GetBlendShapeFrameCount(num3);
				for (int num4 = 0; num4 < blendShapeFrameCount; num4++)
				{
					Vector3[] array4 = (Vector3[])(object)new Vector3[sharedMesh.vertexCount];
					Vector3[] array5 = (Vector3[])(object)new Vector3[sharedMesh.vertexCount];
					Vector3[] array6 = (Vector3[])(object)new Vector3[sharedMesh.vertexCount];
					sharedMesh.GetBlendShapeFrameVertices(num3, num4, array4, array5, array6);
					for (int num5 = 0; num5 < array4.Length; num5++)
					{
						array4[num5] = Reflect(array4[num5]);
						array5[num5] = Reflect(array5[num5]);
						array6[num5] = Reflect(array6[num5]);
					}
					val2.AddBlendShapeFrame(blendShapeName, sharedMesh.GetBlendShapeFrameWeight(num3, num4), array4, array5, array6);
				}
			}
			Bounds bounds = sharedMesh.bounds;
			((Bounds)(ref bounds)).center = Reflect(((Bounds)(ref bounds)).center);
			val2.bounds = bounds;
			Bounds localBounds = ((Renderer)val).localBounds;
			((Bounds)(ref localBounds)).center = Reflect(((Bounds)(ref localBounds)).center);
			((Renderer)val).localBounds = localBounds;
			ValidateConversionOnly(sharedMesh, val2);
			val.sharedMesh = val2;
		}

		private static bool Same(Vector3 a, Vector3 b)
		{
			//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_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)
			//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)
			if (a.x == b.x && a.y == b.y)
			{
				return a.z == b.z;
			}
			return false;
		}

		private static void Require(bool ok, string error)
		{
			if (!ok)
			{
				throw new InvalidOperationException("Coordinate-only copy failed: " + error);
			}
		}

		private static void ValidateConversionOnly(Mesh source, Mesh copy)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: 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_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			Require(source.vertexCount == copy.vertexCount && source.subMeshCount == copy.subMeshCount && source.blendShapeCount == copy.blendShapeCount, "counts");
			Vector3[] vertices = source.vertices;
			Vector3[] vertices2 = copy.vertices;
			for (int i = 0; i < vertices.Length; i++)
			{
				Require(Same(vertices[i], Reflect(vertices2[i])), "position involution");
			}
			vertices = source.normals;
			vertices2 = copy.normals;
			Require(vertices.Length == vertices2.Length, "normal count");
			for (int j = 0; j < vertices.Length; j++)
			{
				Require(Same(vertices[j], Reflect(vertices2[j])), "normal involution");
			}
			Vector4[] tangents = source.tangents;
			Vector4[] tangents2 = copy.tangents;
			Require(tangents.Length == tangents2.Length, "tangent count");
			for (int k = 0; k < tangents.Length; k++)
			{
				Require(tangents[k].x == 0f - tangents2[k].x && tangents[k].y == tangents2[k].y && tangents[k].z == tangents2[k].z && tangents[k].w == 0f - tangents2[k].w, "tangent involution");
			}
			List<Vector4> list = new List<Vector4>();
			List<Vector4> list2 = new List<Vector4>();
			for (int l = 0; l < 8; l++)
			{
				source.GetUVs(l, list);
				copy.GetUVs(l, list2);
				Require(list.Count == list2.Count, "UV channel count");
				for (int m = 0; m < list.Count; m++)
				{
					Require(list[m] == list2[m], "UV unchanged");
				}
			}
			Color[] colors = source.colors;
			Color[] colors2 = copy.colors;
			Require(colors.Length == colors2.Length, "colors count");
			for (int n = 0; n < colors.Length; n++)
			{
				Require(colors[n] == colors2[n], "colors unchanged");
			}
			NativeArray<BoneWeight1> allBoneWeights = source.GetAllBoneWeights();
			try
			{
				NativeArray<BoneWeight1> allBoneWeights2 = copy.GetAllBoneWeights();
				try
				{
					NativeArray<byte> bonesPerVertex = source.GetBonesPerVertex();
					try
					{
						NativeArray<byte> bonesPerVertex2 = copy.GetBonesPerVertex();
						try
						{
							Require(allBoneWeights.Length == allBoneWeights2.Length && bonesPerVertex.Length == bonesPerVertex2.Length, "weight lengths");
							for (int num = 0; num < allBoneWeights.Length; num++)
							{
								BoneWeight1 val = allBoneWeights[num];
								int boneIndex = ((BoneWeight1)(ref val)).boneIndex;
								val = allBoneWeights2[num];
								int ok;
								if (boneIndex == ((BoneWeight1)(ref val)).boneIndex)
								{
									val = allBoneWeights[num];
									float weight = ((BoneWeight1)(ref val)).weight;
									val = allBoneWeights2[num];
									ok = ((weight == ((BoneWeight1)(ref val)).weight) ? 1 : 0);
								}
								else
								{
									ok = 0;
								}
								Require((byte)ok != 0, "weights unchanged");
							}
							for (int num2 = 0; num2 < bonesPerVertex.Length; num2++)
							{
								Require(bonesPerVertex[num2] == bonesPerVertex2[num2], "support unchanged");
							}
						}
						finally
						{
							((IDisposable)bonesPerVertex2/*cast due to .constrained prefix*/).Dispose();
						}
					}
					finally
					{
						((IDisposable)bonesPerVertex/*cast due to .constrained prefix*/).Dispose();
					}
				}
				finally
				{
					((IDisposable)allBoneWeights2/*cast due to .constrained prefix*/).Dispose();
				}
			}
			finally
			{
				((IDisposable)allBoneWeights/*cast due to .constrained prefix*/).Dispose();
			}
			Matrix4x4[] bindposes = source.bindposes;
			Matrix4x4[] bindposes2 = copy.bindposes;
			Require(bindposes.Length == bindposes2.Length, "bindpose count");
			for (int num3 = 0; num3 < bindposes.Length; num3++)
			{
				Matrix4x4 val2 = Conjugate(bindposes2[num3]);
				for (int num4 = 0; num4 < 16; num4++)
				{
					Require(((Matrix4x4)(ref bindposes[num3]))[num4] == ((Matrix4x4)(ref val2))[num4], "bindpose involution");
				}
			}
			for (int num5 = 0; num5 < source.subMeshCount; num5++)
			{
				int[] triangles = source.GetTriangles(num5);
				int[] triangles2 = copy.GetTriangles(num5);
				Require(triangles.Length == triangles2.Length, "triangle count");
				for (int num6 = 0; num6 < triangles.Length; num6 += 3)
				{
					Require(triangles[num6] == triangles2[num6] && triangles[num6 + 1] == triangles2[num6 + 2] && triangles[num6 + 2] == triangles2[num6 + 1], "triangle winding only");
				}
			}
			for (int num7 = 0; num7 < source.blendShapeCount; num7++)
			{
				Require(source.GetBlendShapeName(num7) == copy.GetBlendShapeName(num7) && source.GetBlendShapeFrameCount(num7) == copy.GetBlendShapeFrameCount(num7), "shape identity");
				for (int num8 = 0; num8 < source.GetBlendShapeFrameCount(num7); num8++)
				{
					Require(source.GetBlendShapeFrameWeight(num7, num8) == copy.GetBlendShapeFrameWeight(num7, num8), "shape frame weight");
					Vector3[] array = (Vector3[])(object)new Vector3[source.vertexCount];
					Vector3[] array2 = (Vector3[])(object)new Vector3[source.vertexCount];
					Vector3[] array3 = (Vector3[])(object)new Vector3[source.vertexCount];
					Vector3[] array4 = (Vector3[])(object)new Vector3[copy.vertexCount];
					Vector3[] array5 = (Vector3[])(object)new Vector3[copy.vertexCount];
					Vector3[] array6 = (Vector3[])(object)new Vector3[copy.vertexCount];
					source.GetBlendShapeFrameVertices(num7, num8, array, array2, array3);
					copy.GetBlendShapeFrameVertices(num7, num8, array4, array5, array6);
					for (int num9 = 0; num9 < array.Length; num9++)
					{
						Require(Same(array[num9], Reflect(array4[num9])) && Same(array2[num9], Reflect(array5[num9])) && Same(array3[num9], Reflect(array6[num9])), "all shape vectors involution");
					}
				}
			}
		}
	}
	public sealed class TaylorV5ClothClearance
	{
		private readonly SkinnedMeshRenderer renderer;

		private readonly int[] shapes;

		private static readonly int[] Bones = new int[8] { 45, 46, 47, 48, 49, 50, 51, 52 };

		private static readonly double[] Features = new double[10368]
		{
			-0.9998779801586989, -0.0156212883766205, 1.196722479174064E-05, 0.015585172038579237, -0.9976177488134809, -0.0672006671458699, 0.0010616997164432564, -0.06719228081987286, 0.9977394801209051, 0.9999803129782965,
			-0.006274502381964984, -6.538873419483716E-05, 0.006274820124836092, 0.9999505509738461, 0.007715065748306664, 1.6977302370837177E-05, -0.007715324164185276, 0.999970236299467, 0.9972567940364819, -0.062811993886371,
			-0.03916044141855581, 8.6289982830971E-07, 0.529065588639381, -0.8485809348064097, 0.07401950247963744, 0.8462530687339832, 0.5276143069619925, 0.967933299670288, 0.18968341825798168, 0.16469768737706844,
			-0.06233052322180255, 0.8164692582552336, -0.5740146829124189, -0.24335166583420645, 0.5453422330629786, 0.8021108499288614, -0.9998779801586989, 0.0156212883766205, -1.196722479174064E-05, -0.015585172038579237,
			-0.9976177488134809, -0.0672006671458699, -0.0010616997164432564, -0.06719228081987286, 0.9977394801209051, 0.9999803129782965, 0.006274502381964984, 6.538873419483716E-05, -0.006274820124836092, 0.9999505509738461,
			0.007715065748306664, -1.6977302370837177E-05, -0.007715324164185276, 0.999970236299467, 0.9972567972232398, 0.06281206086408953, 0.03916025283436906, -1.0564933328511984E-06, 0.529065561100779, -0.8485809519757098,
			-0.07401945954226917, 0.8462530809793983, 0.5276142933450024, 0.9679332418172977, -0.1896829588254479, -0.16469855650940313, 0.06232965300002831, 0.8164693612106871, -0.5740146309643237, 0.24335211883596497,
			0.5453422387230208, 0.8021107086447675, -0.9838467279704952, -0.14948438873669379, 0.0984887475083726, 0.13233908342388376, -0.9778486052792722, -0.16216803677638866, 0.12054867423691273, -0.14651458179102442,
			0.9818357777461182, 0.9870727559531174, 0.1602684623528796, -0.0011808599246328486, 0.024457615003648243, -0.14334159398508145, 0.9893710186285781, 0.1583957055082344, -0.9766100590352629, -0.14540836656702016,
			0.9961810989956853, -0.07578064625181413, -0.04336486662501959, 0.016129487855887067, 0.647849627631859, -0.7615974655937138, 0.0858082608217596, 0.757989547177874, 0.6465978570516812, 0.9679359064983084,
			0.18969799825194347, 0.16466557129680606, -0.06225757279100708, 0.8162345203090735, -0.5743563375518628, -0.2433599711157739, 0.5456884434501271, 0.8018728372650538, -0.9866714823130966, 0.11858625705783721,
			0.11143018274726915, -0.04749678510211944, -0.8648333231099959, 0.499807341526197, 0.15563881712169478, 0.4878530750907832, 0.8589388428342417, 0.9907156555251283, 0.01518795002164068, -0.13509928227624413,
			-0.001128864776800796, 0.9946248434584799, 0.10353814002342727, 0.13594563458137143, -0.1024243474440297, 0.9854075489303569, 0.9978705808120774, 0.06512398532300104, -0.003629116340983416, -0.0434920081839921,
			0.622883815532227, -0.7811044728921592, -0.04860811839487733, 0.7795990115974134, 0.6243898076862286, 0.9679376714114671, -0.18969869156246763, -0.16465439770025614, 0.062224113315235405, 0.8161432585133016,
			-0.5744896355073965, 0.24336150883958454, 0.5458246861426993, 0.8017796380630678, -0.9853909144456078, -0.15206277181124397, 0.07669197583274566, 0.15828443854362959, -0.9839091624087692, 0.08287820366659392,
			0.06285524833279137, 0.09380657523412146, 0.9936043197369202, 0.9932414284611281, 0.11535621669725656, -0.012822170557033916, 0.026563778500176112, -0.11838811194532783, 0.9926120191806136, 0.11298597461761202,
			-0.9862439851372052, -0.12065227441035749, 0.9958440178330924, -0.07768765979923768, -0.04753230123779612, 0.008579616588042663, 0.5996030562069337, -0.8002515636763897, 0.09067018432343049, 0.7965179235285436,
			0.5977776469328148, 0.9679352292020049, 0.18969753860872948, 0.16467008202904146, -0.062269682526364986, 0.8162685727345186, -0.5743066287306958, -0.24335956670681208, 0.5456376645831377, 0.8019075135453787,
			-0.9915448125442907, 0.10132469653669467, 0.08106904827524498, -0.06311292714143683, -0.9224279568937012, 0.38097693206879635, 0.1133827285972027, 0.3726391957546331, 0.9210235537939265, 0.9945467337701288,
			0.01108354895471185, -0.1037012501840611, 0.0021725527341760406, 0.9919193002247328, 0.1268518106149547, 0.10426923976794857, -0.12638535035455464, 0.9864860206074746, 0.9986876467303825, 0.051033689872858896,
			0.004306595649902865, -0.03534916154253642, 0.747710084553374, -0.6630837550682613, -0.037059695713410376, 0.6620613203889405, 0.7485328229266116, 0.9679959159726617, -0.18973340163883717, -0.1642715525062201,
			0.06119629585887055, 0.8132476271702972, -0.5786910317907429, 0.2433904682468105, 0.5501177448550786, 0.7988313631563057, -0.9855160605295832, -0.1605390691563441, 0.05463791460758632, 0.16953117418527006,
			-0.9247859300757668, 0.34063200747032446, -0.004156370726365716, 0.34496114391089605, 0.9386077635381415, 0.9972883786207926, 0.0697925620844864, -0.02334283927874319, 0.029830489039283238, -0.093409003805044,
			0.9951808378037759, 0.06727578904470265, -0.9931786124790599, -0.09523766021160032, 0.9954705366825528, -0.0798575858906684, -0.05158659295461853, 0.0007111162314715913, 0.5488531001706219, -0.8359185180068708,
			0.0950678963197163, 0.832095571679607, 0.5464238782122646, 0.9679345424074892, 0.18969711546326165, 0.16467460641921625, -0.062281796942758136, 0.8163025788837832, -0.5742569786056303, -0.24335919827281402,
			0.545586935412318, 0.8019421403838368, -0.9949769690095419, 0.08791628936387515, 0.04787021208509108, -0.07310222524665606, -0.9648235718691465, 0.2525302750753813, 0.06838783374673742, 0.24776238865119865,
			0.9664041095552522, 0.9973669016710897, 0.00621123124617158, -0.07225430130738218, 0.00472611071773215, 0.9886406645865137, 0.1502241665093192, 0.07236661750071734, -0.1501700933353324, 0.9860081215381349,
			0.9993290352247008, 0.03527772912853614, 0.009846887041188213, -0.02499225402259291, 0.8533284805681345, -0.5207743191538425, -0.026774364525390306, 0.5201788020275449, 0.8536375971836345, 0.9680544209261781,
			-0.18976610163889368, -0.16388857432432066, 0.060168338059010756, 0.8103296787634613, -0.5828769877172391, 0.24341406947935007, 0.5543957416718517, 0.7958611388902084, -0.9839579358040099, -0.17496356880323316,
			0.0348501098986566, 0.1621829461779968, -0.7958968118802977, 0.5833052003949597, -0.07432006820056838, 0.57959987442236, 0.8115050911930549, 0.9991828929885352, 0.023766281034750848, -0.03269113404025324,
			0.03425129952170218, -0.068509412784532, 0.9970623394958775, 0.02145681337326705, -0.9973673466911253, -0.06926745927323245, 0.9950625407907022, -0.08227994969761628, -0.055502700771303065, -0.007432272857829056,
			0.4958775945616676, -0.8683606235498598, 0.09897121417522291, 0.8644856396086014, 0.4928176921288335, 0.9679338584139026, 0.18969668181832944, 0.1646791263126271, -0.06229392347486063, 0.8163366231541962,
			-0.5742072664076208, -0.2433588149915325, 0.5455361460108025, 0.801976807994843, -0.9967980809311694, 0.07894339812444068, 0.012709277890739683, -0.07690479715036515, -0.9900409789576081, 0.11791739549329738,
			0.021891505823016702, 0.11656242909800577, 0.9929420738872804, 0.9991658116966275, 0.0005798611106683959, -0.04083312990344463, 0.006523022717368213, 0.9847946692673516, 0.1735998547154852, 0.04031291246298085,
			-0.1737213951811959, 0.9839693826258268, 0.9997500527279436, 0.018508719118253893, 0.012540310485632039, -0.012766969826599826, 0.9331031137523428, -0.3593822249181623, -0.018353107418667833, 0.3591322965458323,
			0.9331061874330248, 0.9681131885214144, -0.1897967955171134, -0.16350544523756802, 0.05914028745589222, 0.8073894879812781, -0.5870473925476244, 0.24343229163472707, 0.55865856398051, 0.7928690486333162,
			-0.9807964237993559, -0.19403450242634812, 0.019722751596897677, 0.13599461739017787, -0.607904101328304, 0.7822774876149298, -0.13979928148346304, 0.7699371503287694, 0.6226178165137269, 0.9989122988586004,
			-0.02252876318426688, -0.04082491908642607, 0.03981000054105499, -0.04379534859869462, 0.9982470291956993, -0.024277212483051362, -0.9987864748135635, -0.04285084227348048, 0.994622339104593, -0.08494116390866138,
			-0.059257077450300046, -0.015803243149330078, 0.4409832618405401, -0.8973761866031669, 0.10235555705515983, 0.8934868557792668, 0.4372694575311747, 0.967933176190099, 0.18969624318533465, 0.16468364142171946,
			-0.06230604661365583, 0.8163706596192418, -0.5741575590969967, -0.24335842493310977, 0.545485363171382, 0.8020114684839997, -0.996928489249659, 0.07474462161316242, -0.023384372180975933, -0.07431085450658251,
			-0.9970560086622381, -0.01890006595302339, -0.024728207069958694, -0.01710430151839794, 0.9995478771147851, 0.9999379454639766, -0.005798102602378154, -0.009512477463477975, 0.007558096080542561, 0.9803898078573012,
			0.1969230810066734, 0.008184155724212962, -0.1969827572548821, 0.9803727928392066, 0.9999246135244716, 0.0015212601679380768, 0.012184130475231736, 0.0007756112423563692, 0.982488401577852, -0.18632213822355503,
			-0.012254211322510877, 0.1863175422028164, 0.9824131553335209, 0.9681722036835475, -0.1898255071486692, -0.16312222672062202, 0.05811216127618657, 0.8044271316829597, -0.591202136772303, 0.2434451903947867,
			0.5629060904343433, 0.7898551592700834, -0.9764583886420158, -0.21544300646588005, 0.010645478645015801, 0.09479663684979416, -0.38427240689732495, 0.918339977861851, -0.1937591620868726, 0.8977299305817311,
			0.39564928768432484, 0.9964822152952891, -0.06889647419345253, -0.04771237202135405, 0.04648075380113145, -0.0193710496859941, 0.998731346238888, -0.06973330715140191, -0.997435731402166, -0.01610054644894267,
			0.994152622169653, -0.08782484216452358, -0.06282802664400616, -0.024351764057576244, 0.38449926340838547, -0.9228040463856306, 0.10520244968862445, 0.9189380357440788, 0.3801122611049621, 0.9679324920295971,
			0.1896958176586396, 0.1646881526892391, -0.06231817330442981, 0.8164046697320089, -0.5741078822971937, -0.24335804106166908, 0.5454346083652829, 0.8020461033182802, -0.9953888937742638, 0.07537524579600431,
			-0.05932556339420211, -0.06549038553795715, -0.9859249277460337, -0.1538279761651576, -0.07008537331667213, -0.1492334050076269, 0.9863150770807942, 0.999682660279292, -0.012906628535345648, 0.02163325395701208,
			0.007829773057260054, 0.9754371544717454, 0.22013871156599227, -0.023943128258224342, -0.2198994693397734, 0.975228665489943, 0.9998501428528109, -0.014868585964443102, 0.008866622165836325, 0.0149582056354098,
			0.9998368209154668, -0.01012835750857981, -0.008714580964253484, 0.01025946845946629, 0.9999093955881939, 0.9682314837623663, -0.18985216979770486, -0.16273889355169419, 0.05708401535366307, 0.801442836071916,
			-0.5953409071280983, 0.24345268337487896, 0.5671380203549288, 0.7868197104962885, -0.9715483963470324, -0.2367183472733302, 0.007624802928172515, 0.044897538387568804, -0.1524691952575488, 0.9872878787589019,
			-0.23254660737634333, 0.9595402902232397, 0.15875927322854047, 0.9919164119696062, -0.11514119965004341, -0.053332314861548685, 0.05422852031579869, 0.004662977959114727, 0.9985176634496317, -0.11472183423264089,
			-0.9933381905371917, 0.010869221250706915, 0.993656400525036, -0.09091214617586042, -0.06619621872378938, -0.0330261351806538, 0.32677089458494746, -0.944526366411855, 0.10749991670070243, 0.9407208747178152,
			0.3216955140804581, 0.9679318114465606, 0.18969537581945975, 0.16469266159271972, -0.062330283362257974, 0.8164386677294857, -0.5740582179640685, -0.2433576466145265, 0.5453838705249865, 0.8020807251177549,
			-0.9922959847716111, 0.08060853909422716, -0.09407944531742204, -0.05096769727749175, -0.9577534796659507, -0.2830380999476813, -0.11292020386259208, -0.276062557426497, 0.9544833638920971, 0.9984041921711022,
			-0.02072628293186477, 0.05253085046900766, 0.007340105384408604, 0.9699504333165962, 0.24319185792680814, -0.05599278442902035, -0.24241818847762925, 0.9685547119224137, 0.9995470930441894, -0.029949118328142118,
			0.0029426345812273145, 0.029085812613450605, 0.9865429805689444, 0.16089426029153153, -0.007721676730279229, -0.16073580124387604, 0.9869672628344686, 0.9682910131405643, -0.1898768463162945, -0.16235546527357242,
			0.056055865859045054, 0.7984365423175687, -0.5994637835555683, 0.2434548290217565, 0.5713544181372384, 0.7837626395159725, -0.9714434859597306, -0.23714867332418063, 0.007619732737246885, 0.04380454676362494,
			-0.1476915964247684, 0.9880629301964204, -0.23319244256458957, 0.9601810761966122, 0.1538622294283954, 0.9917979032074312, -0.11610962451252069, -0.05343663807636403, 0.05440248206083429, 0.005163032678182589,
			0.998505740113288, -0.11566023144954991, -0.9932229851292838, 0.011437336749045495, 0.9936457204690419, -0.09097900057920497, -0.06626464854783011, -0.03320926898662888, 0.3255478153290558, -0.9449422016122752,
			0.1075422086760921, 0.941138375260561, 0.32045784740739275, 0.9679317960441981, 0.1896953867708492, 0.16469273950150604, -0.06233056103383607, 0.8164393721570983, -0.5740571859605373, -0.24335763675681152,
			0.5453828121875326, 0.8020814477361746, -0.9922156790758806, 0.08076477798536479, -0.09478975067465897, -0.0506070240552793, -0.9569921875150403, -0.2856656824881954, -0.11378477627634379, -0.2786449419461137,
			0.9536299182678726, 0.9983664323000172, -0.020897946712059096, 0.05317652376524275, 0.007321682126908855, 0.9698296088875352, 0.24367380387699383, -0.05666444941379019, -0.24288640461802513, 0.9683983346868998,
			0.9995385304627467, -0.030247642061943768, 0.0027939703049076445, 0.029377257127430355, 0.9859600040911868, 0.1643771489477044, -0.007726764137790072, -0.16421921471679077, 0.986393606342701, 0.9682922618787472,
			-0.18987735870535388, -0.16234741832507935, 0.05603429113598523, 0.798373190907096, -0.5995501699255111, 0.24345482908052488, 0.571442767643357, 0.7836982260446126, -0.9746078448295815, -0.2231040842668489,
			-0.01908183377166846, 0.05199167232645534, -0.3083598057426854, 0.9498479332035383, -0.2177990238851803, 0.9247371506464874, 0.3121294401508426, 0.9927630608066319, -0.11671809896072705, -0.02825580423279409,
			0.0455664359901376, 0.14842175620131218, 0.9878738189653956, -0.11110897807560266, -0.982012152501746, 0.15266606476189443, 0.9945435921745143, -0.07813438101405841, -0.06912352543211092, -0.04099718371277142,
			0.3165570378782016, -0.9476871175115764, 0.0959284847802518, 0.9453500199784887, 0.3116264840067934, 0.9686322787374102, 0.18997896235469183, 0.16018583723477944, -0.0502464551209534, 0.7810344979476733,
			-0.622463177034115, -0.24336557343993956, 0.5948891551190529, 0.7660809949254641, -0.9925110190959671, 0.07708482237356014, -0.09476184428725797, -0.05796890771224879, -0.9800551652793791, -0.19008282075942073,
			-0.10752433543963245, -0.18316605353843834, 0.9771840738158908, 0.9978197003488625, -0.037842390132492215, 0.054072165711821704, 0.006330277875955638, 0.8703882544915497, 0.4923253132078075, -0.06569454450500167,
			-0.4909096046648631, 0.8687301001289561, 0.9992943016227882, -0.02947794927107104, 0.02327980349993608, 0.028782970816999508, 0.9991460093379163, 0.02964443649429587, -0.024133779960280335, -0.02895345455880448,
			0.999289376574143, 0.9682362742178283, -0.18985423678586988, -0.16270797787211483, 0.057001161467581024, 0.8012013482059284, -0.5956737926284402, 0.24345304450781582, 0.5674784299050121, 0.7865741202915447,
			-0.9780256295755748, -0.20372600381866393, -0.04428976474738099, 0.05769501537276345, -0.4686163157492846, 0.8815157592548778, -0.20034258931749185, 0.8595897067680865, 0.4700727421622296, 0.9935374650185735,
			-0.11348506704380175, -0.0021083554087989982, 0.03571313440277171, 0.2949213186390708, 0.9548539091627164, -0.10773986094104421, -0.9487584283526844, 0.29706828675264035, 0.9952706120500695, -0.06502612251317848,
			-0.07216655860148297, -0.048838084471626304, 0.3072374716231325, -0.9503788600004568, 0.08397172318478685, 0.9494086261571071, 0.30260867516290996, 0.9693855448559543, 0.18998103516084797, 0.15555986533658614,
			-0.03787815452181304, 0.7416504082997869, -0.6697162961126006, -0.24260443284150002, 0.6433209759894133, 0.7261413161483674, -0.9928360359966906, 0.07330916874946701, -0.0943523788976235, -0.06488399168624802,
			-0.9938745490765263, -0.08946199372242203, -0.10033281242563392, -0.08269913225175923, 0.9915110590788023, 0.9971726572365316, -0.056379047891723516, 0.049679921685304336, 0.0024043595718521897, 0.6847252338616869,
			0.7287973471192853, -0.0751059965307995, -0.72661733881864, 0.6829248364302138, 0.9986858840887892, -0.025722594361591883, 0.04432666309461133, 0.030530734667224776, 0.993300595781516, -0.11145313212631072,
			-0.04116283715286992, 0.11265999538165425, 0.9927806133673904, 0.9681793169373257, -0.18982875997697674, -0.16307621574091305, 0.057988772696836034, 0.8040702311953334, -0.5916995568247441, 0.24344632364422367,
			0.5634146831518385, 0.7894921040219626, -0.9814830746769091, -0.17979812181816832, -0.06605762267460333, 0.06023834111793783, -0.6170857295138471, 0.7845868624248826, -0.18183046054531155, 0.7660795244757702,
			0.6164899397369413, 0.9940593619194947, -0.10625371058477416, 0.023582492810850345, 0.02532052882450252, 0.43649345045641014, 0.8993510652290931, -0.10585299145633204, -0.8934112248542795, 0.43659080098430986,
			0.9958050599374779, -0.05193551125184194, -0.07533249812614219, -0.05656021387232377, 0.2977848499008936, -0.9529559934100936, 0.07192513336541276, 0.9532192223410685, 0.2935981766800598, 0.9701728817014593,
			0.18968972075177795, 0.15093836308970005, -0.025557533045191212, 0.699214751893624, -0.7144547174167037, -0.24106304593555922, 0.6892869798389134, 0.683207192079255, -0.9931801404012118, 0.06957528770232232,
			-0.0935547329308859, -0.0710644351207262, -0.9973911648151027, 0.012677160949693718, -0.09242864693157865, 0.019239118740509188, 0.9955334256249192, 0.9965142759661821, -0.07359261213237467, 0.039286451037595344,
			-0.004581277804764668, 0.4219465260741773, 0.9066091445753288, -0.08329651666949274, -0.9036289374369705, 0.42013858872669796, 0.997715730127279, -0.01893507797443545, 0.06484431107422961, 0.03472172094994965,
			0.9671500051529299, -0.2518238861326709, -0.057945870869831946, 0.25350015849065793, 0.9655982320273518, 0.9681225896382626, -0.18980146971153022, -0.16344434382213158, 0.05897638718128177, 0.8069187611911763,
			-0.5877107269675621, 0.24343466718433435, 0.5593366740461779, 0.792390085677384, -0.9848173580483898, -0.15232613343866153, -0.08325575270343341, 0.059411488897512826, -0.7463939485469138, 0.6628471532408713,
			-0.16311053391356692, 0.6478370340171775, 0.7441116388568705, 0.994305241724236, -0.09519323348462275, 0.04790965015997701, 0.01474046782771829, 0.568089292603894, 0.8228349009594987, -0.10554527411461533,
			-0.8174428444408512, 0.5662573541990612, 0.9961466526569452, -0.038868241313432826, -0.07862001155917403, -0.06416021520368, 0.28820305349707875, -0.955417430623901, 0.05979392264587952, 0.9567801522670506,
			0.28459871229936706, 0.9709897167941186, 0.18910573591731092, 0.14634886580786594, -0.01335811636570813, 0.653969268371468, -0.7564031707712802, -0.23874783895825447, 0.7325047553899279, 0.637523531113876,
			-0.9935380974351293, 0.06594235411172569, -0.09237778347193375, -0.07640603731929811, -0.9904527286150888, 0.11474105559950044, -0.08392953238369515, 0.12105783044945692, 0.9890909135568509, 0.9959440685232035,
			-0.08673348563041917, 0.02393146138133238, -0.013838961099630101, 0.11514746237637154, 0.993252004812457, -0.08890385553580485, -0.9895546293048606, 0.11348013082557164, 0.996407489815384, -0.009271435196606061,
			0.08417930107336634, 0.04127027253942404, 0.9211337710371299, -0.38705211594750116, -0.07395186843026333, 0.38913572997645873, 0.9182072232406807, 0.9680660985473085, -0.1897723013057025, -0.16381240032589425,
			0.05996394871753136, 0.8097469887838744, -0.5837072374141421, 0.2434180636222273, 0.5552443496448984, 0.7952681047859393, -0.9878760627674908, -0.12265088158421521, -0.09517166520355078, 0.05531578090600731,
			-0.8508995332040866, 0.5224080290116404, -0.1450553308009069, 0.5108098918772853, 0.8473678099659895, 0.9942704690478474, -0.08073687891303667, 0.07005562620343646, 0.0043392597933959364, 0.6853223718177368,
			0.7282268997438626, -0.10680545493475213, -0.7237505116195044, 0.6817461343687158, 0.99629527518802, -0.0258299676340415, -0.08202766246853177, -0.07163483399179298, 0.2784961010092942, -0.9577621689551061,
			0.04758334999761231, 0.9600899616674708, 0.27561402415036745, 0.9718311348183719, 0.18823318280062734, 0.14181859641944455, -0.0013520432242731441, 0.6061895554204235, -0.7953190522540678, -0.23567438846161304,
			0.7727240722223784, 0.5893683829586632, -0.99390422648724, 0.06246646762601797, -0.09084233040345221, -0.08083054036530936, -0.9732334683522155, 0.21513493399113373, -0.07497207690236704, 0.22116635481339633,
			0.9723500558870253, 0.9955382577757133, -0.09416214071690948, 0.0060883955609201, -0.023918708421957702, -0.18941353013486198, 0.9816060360395479, -0.09127690119807237, -0.9773719894991146, -0.19082065257780362,
			0.9948058032648976, 0.0029337799238539517, 0.10174874311676053, 0.04994467488410039, 0.8569216305976385, -0.5130212943578517, -0.08869579043677131, 0.5154383687204925, 0.8523240843772713, 0.9680098503303846,
			-0.18974129795950959, -0.16418029574826287, 0.06095141413905304, 0.8125546064640092, -0.5796895174389203, 0.24339649705325664, 0.5511381418145177, 0.7981258634197022, -0.9905396964973594, -0.09223776408715224,
			-0.1016036640044168, 0.048339460776971765, -0.9274842359408435, 0.37072400598426475, -0.12843055008334728, 0.36230537804100055, 0.9231686773541752, 0.993969380279632, -0.06352762400952272, 0.08938183290931702,
			-0.005543490490789614, 0.7849445938297627, 0.6195411643552077, -0.10951776467634315, -0.6163004345326497, 0.7798587267032182, 0.9962509821084745, -0.012826324468668453, -0.08555387804491253, -0.07898086414954242,
			0.2686686614008737, -0.9599891527924963, 0.035298778252098935, 0.9631472555023392, 0.2666483835919915, 0.9726919621758047, 0.187079643053582, 0.13737377432947906, 0.01039137446460648, 0.5561786258918369,
			-0.8309978071197324, -0.2318671301744139, 0.8097323899017577, 0.5390464643132992, -0.9942726985171374, 0.05919792773765432, -0.08897980858047826, -0.08428957748543374, -0.9462216434741538, 0.3123457516093319,
			-0.06570439947810326, 0.31805692379295664, 0.9457921151693874, 0.9953192662079573, -0.09595311233357057, -0.011513407347729643, -0.033383386450080925, -0.4531718193507524, 0.8907978736253545, -0.09069238018917643,
			-0.8862439293895499, -0.4542538825324356, 0.992971397894376, 0.01720494878137667, 0.11709736419373148, 0.06039333230479323, 0.7772200263080297, -0.6263239386442684, -0.10178628776417728, 0.628993656918078,
			0.7707181918055472, 0.9679538407560395, -0.18970841862098323, -0.16454810260212074, 0.06193872942153467, 0.8153416728901748, -0.5756574938679224, 0.24336999807551918, 0.5470179817455523, 0.8009634022124512,
			-0.9909566457323898, -0.08697526800235039, -0.10217743897127628, 0.04687310366950372, -0.9378890488394365, 0.34375433701910685, -0.12572922663882682, 0.3358562710788315, 0.933484186660827, 0.9938918350240952,
			-0.060307891713578254, 0.09242282439689563, -0.007188346297862916, 0.8003211196323197, 0.5995285090368695, -0.11012423870310335, -0.596530857263506, 0.7949991121897736, 0.996223583701562, -0.01056764099299234,
			-0.08617944209996015, -0.08024572911459657, 0.26694661334944764, -0.9603645810733177, 0.03315409832409744, 0.9636533767829095, 0.2650905037514781, 0.972843331693266, 0.18685098092947777, 0.1366109911597059,
			0.012403004756650718, 0.5472726537263801, -0.8368624785209888, -0.23113203467488436, 0.8158304685466076, 0.5300930381905337, -0.9943366217174523, 0.058653653907590975, -0.08862523114110232, -0.08479111803308335,
			-0.9405743684596319, 0.32883175591701097, -0.06407143680474944, 0.33448408972633265, 0.9402208488997265, 0.9952988283739762, -0.09577623948058152, -0.014392851988022209, -0.03489106428086674, -0.4932066445159934,
			0.8692121832088087, -0.0903485244524737, -0.8646236856322138, -0.4942297303613248, 0.9926335455211482, 0.019858330328435876, 0.11951690684870257, 0.06236156787224854, 0.7620152703081204, -0.6445492709403655,
			-0.10387338041399086, 0.6472544897749323, 0.7551635228925995, 0.9679441257050869, -0.1897025083021597, -0.16461205258693384, 0.06211050070836297, 0.8158244523407053, -0.5749545622610052, 0.24336486027109797,
			0.5462997540790737, 0.8014550040260354, -0.9941775433483135, -0.07864877711884895, -0.0736571935361533, 0.055577564305078896, -0.9598952522289065, 0.2747949036905875, -0.09231547350161583, 0.26910123486545773,
			0.9586774112004821, 0.9967021598985049, -0.03758695717598599, 0.07191679292005247, -0.018084377021943585, 0.7610787918014577, 0.648407300990482, -0.07910600332075508, -0.6475695277885486, 0.757889138936779,
			0.9973353404077323, -0.009473962270418744, -0.07233576440940141, -0.06307386965890802, 0.38626987177315986, -0.9202267509296811, 0.036659319961571006, 0.9223371564667903, 0.38464303459273785, 0.9721237599769177,
			0.1878696416189206, 0.1402868242078321, 0.0026991135403004467, 0.5893125642663117, -0.8079006228391962, -0.23445278858319746, 0.7857580412288777, 0.5723776642827008, -0.9953344800813188, 0.07227798750780809,
			-0.06391529772340783, -0.0922005866657716, -0.9077143511940273, 0.4093332486555359, -0.028431049571520844, 0.41331652417757087, 0.910143464659299, 0.9976160955184928, -0.06761732369477302, -0.013784901116592458,
			-0.007187997717137747, -0.30048987044730874, 0.9537579202540751, -0.06863278117092707, -0.9513851666359513, -0.3002595644668593, 0.9946124927522982, 0.024908526454664983, 0.10062581463479914, 0.047139508858160185,
			0.755854231135797, -0.6530407705332986, -0.09232473106200279, 0.6542659601293425, 0.7506078852838934, 0.9679427723880497, -0.18970172821393455, -0.16462090904372362, 0.06213427618777958, 0.815891151162049,
			-0.5748573398488422, 0.2433641738308169, 0.5462004062321016, 0.8015229223968153, -0.9967349691492053, -0.07124214858307769, -0.0379994413169427, 0.06287135526468213, -0.9800864963350621, 0.18835512307565322,
			-0.05066156296755182, 0.18535106141300903, 0.9813655741214664, 0.9987737396180156, -0.00813257093497857, 0.048835216180871416, -0.02868859375947799, 0.7088444393855416, 0.7047811896896082, -0.04034825445479095,
			-0.7053179581168934, 0.7077418995087594, 0.998423743184288, -0.010562042180203532, -0.05512233949007396, -0.04135399947039362, 0.5255701633859357, -0.8497445793215063, 0.03794569506120623, 0.8506846928348158,
			0.5243049471470373, 0.9712692049815537, 0.18884518033620715, 0.144822751383496, -0.009309510473954296, 0.6382248458155266, -0.7697937250968487, -0.2378013130099074, 0.7463287104537333, 0.6216461947790177,
			-0.995156101444616, 0.09174837698272983, -0.03530678516358208, -0.09700599381973521, -0.8582220417235686, 0.5040285351672806, 0.015942738804796, 0.5050120418572852, 0.8629650437060232, 0.9992595800933014,
			-0.03157668113388742, -0.021981919850819556, 0.021104950536903214, -0.02784256747274126, 0.9993894998944909, -0.03216943665335036, -0.9991134593453812, -0.027155527988081005, 0.9965067635300126, 0.03078665625050306,
			0.07763022630298304, 0.028523099802733688, 0.7481993479554578, -0.6628605950700873, -0.07849014598395326, 0.6627593209574199, 0.7447075798375337, 0.9679411475475999, -0.18970072768852492, -0.16463161542874974,
			0.06216301496744793, 0.8159718695228994, -0.574739652118645, 0.24336329726232858, 0.5460801608388167, 0.8016051169271936, -0.9977567409019767, -0.06692592280638474, -0.0015513997485200376, 0.06643773884333716,
			-0.9927911892541306, 0.09975811444064897, -0.00821661986770713, 0.09943125965149438, 0.9950105083676587, 0.999340781719294, 0.02318022102412288, 0.02794063968385931, -0.03629835475392368, 0.6518970893629132,
			0.7574381917505351, -0.0006568369879564193, -0.7579530738993244, 0.6523087507704742, 0.9991733379203984, -0.014410032247042716, -0.03801304722918104, -0.019349488052839647, 0.6537800286782469, -0.7564372223876638,
			0.03575245587511101, 0.7565474374235297, 0.652960746773333, 0.9704378714222761, 0.1895302645823401, 0.1494276296966226, -0.02153784242810501, 0.6846660485851421, -0.7285386216655575, -0.24038814249655677,
			0.7037831205152312, 0.6685079357979974, -0.993417359368156, 0.11422079913496855, -0.008692476687916248, -0.0970268028468862, -0.7986793691243188, 0.593883039717833, 0.06089129359204223, 0.5908171243118727,
			0.8045044288159875, 0.9991582382096613, 0.0024654166573553522, -0.04094797599970327, 0.03886975931795149, 0.26218614604240364, 0.9642341866133951, 0.013113231040867198, -0.9650141690898306, 0.26186961761061933,
			0.9978489944766767, 0.03640033700861469, 0.054519718336990625, 0.009718698252665284, 0.7403367183337893, -0.6721659693788646, -0.0648300171692031, 0.6712499973574785, 0.7383904860718519, 0.9679395137346903,
			-0.1896997607766823, -0.16464233511560877, 0.06219177449454413, 0.8160525662643481, -0.5746219559663475, 0.24336244767069273, 0.5459598976615779, 0.8016872889157521, -0.9972129406486516, -0.06579219299470505,
			0.03518150570707503, 0.06618885480233695, -0.9977546682045638, 0.010230228538800082, 0.03442944238329498, 0.012530339857657804, 0.9993285766354463, 0.9983848424539462, 0.05601559986057374, 0.009484668179228292,
			-0.04080432895864227, 0.5908366581945523, 0.8057586797991863, 0.039531166140715994, -0.8048442681076591, 0.5921680428711102, 0.9995456641479255, -0.020945596304766893, -0.021673654018672384, 0.0020950515241822966,
			0.765623646004082, -0.6432853514876022, 0.030067857293036366, 0.64294767646742, 0.7653196778359694, 0.9696348650222247, 0.18991954429138236, 0.15407399270962832, -0.033913040657001625, 0.7283451869994039,
			-0.6843706556013343, -0.2421944140700391, 0.6583645306902228, 0.7126696363128665, -0.9901301898761634, 0.13930345881964912, 0.015386794879827413, -0.09219643437858745, -0.730095485009255, 0.6770970390254082,
			0.10555578896330783, 0.6689956121903806, 0.7357328633997197, 0.9971589139948233, 0.029786711487870425, -0.06918708014797414, 0.042736290823011176, 0.5326503344622769, 0.8452557190838264, 0.0620299096191093,
			-0.8458110740679408, 0.5298640554865772, 0.9986374008143588, 0.04174360132520375, 0.03131794123413209, -0.009254526838400546, 0.7322743756663587, -0.6809468352782333, -0.051358499079893566, 0.6797291449473432,
			0.7316628964772055, 0.9679378832321787, -0.18969877393072254, -0.16465305758834387, 0.06222051099772695, 0.8161332338876942, -0.5745042667858925, 0.2433615873863245, 0.5458396465201065, 0.8017694294942989,
			-0.9951173733984229, -0.06784423287890333, 0.07168384215216582, 0.06214326423078482, -0.994938061050246, -0.07897132001125085, 0.07667873154510559, -0.07413106459946246, 0.9942962120967695, 0.9959213740585774,
			0.09000271894047025, -0.006334609427383884, -0.04216608703591858, 0.5263570773537215, 0.8492174328307963, 0.07976614443079295, -0.8454866868868909, 0.5280053262038884, 0.9995305930195294, -0.029890697797734057,
			-0.0067186161665585, 0.022168318759912885, 0.8570144327933134, -0.514815333520006, 0.02114614057902529, 0.5144247351839925, 0.8572747707529319, 0.9688649777391987, 0.1900111613859251, 0.15873378172019365,
			-0.04636030127688877, 0.7690038444793702, -0.6375608281893308, -0.24321056181000503, 0.6103514116676728, 0.7538698673506862, -0.9853658398955971, 0.16650245207874617, 0.03648417490651109, -0.0826334596397884,
			-0.653831065800867, 0.7521147842860569, 0.14908344279229505, 0.7380934025212982, 0.6580214709564799, 0.9935809431278103, 0.04718534327469171, -0.10281270754775475, 0.03271204158776026, 0.7501825612196166,
			0.660421113515563, 0.10829049722118415, -0.659545046393364, 0.7438235677830887, 0.9988713349658823, 0.04681105042835248, 0.008048710534650057, -0.028377062514836165, 0.7240205218414697, -0.6891944763819836,
			-0.03808934899030723, 0.6881882079127779, 0.7245317052988735, 0.9679362549565422, -0.18969779226941394, -0.1646637602777689, 0.0622492639849694, 0.8162138818590046, -0.5743865668641501, 0.24336071062115575,
			0.5457193845455418, 0.8018515559984908, -0.9915266506535826, -0.07299700086263666, 0.10745389201303032, 0.05442446556482001, -0.9845186128630868, -0.1666165612240488, 0.11795286597481001, -0.15935664024822946,
			0.9801492654780316, 0.9919989817245976, 0.12474953605589842, -0.019379719069172813, -0.04041313893246983, 0.45921946673571556, 0.887403098694494, 0.11960266911313806, -0.8795197750049761, 0.46058676372233087,
			0.9991470850332447, -0.04079955324163096, 0.006363876558732915, 0.040191943741595154, 0.9255390949000512, -0.37651293665672064, 0.00947154305506338, 0.37644757970649606, 0.9263895021022625, 0.9681325689564838,
			0.1898068569138801, 0.16337896435647511, -0.05880441993804832, 0.806421429677345, -0.5884101613270264, -0.2434365813132243, 0.5600516358565709, 0.7918843324961727, -0.9792498305120765, 0.19525392705926872,
			0.054274058352058806, -0.06863259130728895, -0.5715094033126774, 0.8177203491020839, 0.19068124410260065, 0.7970275439990268, 0.5730512693069995, 0.989068231609839, 0.05412431

plugins/BarbarianViking/Chaos_Battleaxe/NHChaosBattleaxe.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using BepInEx;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Barbarian Viking Jester Axe")]
[assembly: AssemblyDescription("Jester axe for Barbarian Viking")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NHChaosBattleaxe;

[Serializable]
public sealed class AssetContract
{
	public string itemId;

	public string visualPrefab;

	public string visualAssetPath;

	public string iconAssetPath;

	public string sourceSha256;

	public string bundleSha256;

	public string meshVertexSha256;

	public string meshTriangleSha256;

	public int vertices;

	public int triangles;

	public string auraAssetPath;

	public string auraVertexSha256;

	public string auraTriangleSha256;

	public const string ItemId = "NH_ChaosBattleaxe";

	public const string VisualPrefab = "JesterBattleaxeVisual";

	public const string IconName = "JesterBattleaxeIcon";

	public const string VisualAssetPath = "assets/jester/jesterbattleaxevisual.prefab";

	public const string IconAssetPath = "assets/jester/jesterbattleaxeicon.asset";

	public const string AuraPrefab = "JesterBladeAuraDarkPurple";

	public const string AuraAssetPath = "assets/jester/jesterbladeauradarkpurple.prefab";

	public static string Hash(byte[] bytes)
	{
		using SHA256 sHA = SHA256.Create();
		return BitConverter.ToString(sHA.ComputeHash(bytes)).Replace("-", "");
	}

	public static string FileHash(string path)
	{
		using FileStream inputStream = File.OpenRead(path);
		using SHA256 sHA = SHA256.Create();
		return BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "");
	}

	public static string VertexHash(Vector3[] vertices)
	{
		float[] array = new float[vertices.Length * 3];
		for (int i = 0; i < vertices.Length; i++)
		{
			array[3 * i] = vertices[i].x;
			array[3 * i + 1] = vertices[i].y;
			array[3 * i + 2] = vertices[i].z;
		}
		byte[] array2 = new byte[array.Length * 4];
		Buffer.BlockCopy(array, 0, array2, 0, array2.Length);
		return Hash(array2);
	}

	public static string TriangleHash(int[] triangles)
	{
		byte[] array = new byte[triangles.Length * 4];
		Buffer.BlockCopy(triangles, 0, array, 0, array.Length);
		return Hash(array);
	}

	public void Validate()
	{
		if (itemId != "NH_ChaosBattleaxe" || visualPrefab != "JesterBattleaxeVisual" || vertices != 10906 || triangles != 7840 || visualAssetPath != "assets/jester/jesterbattleaxevisual.prefab" || iconAssetPath != "assets/jester/jesterbattleaxeicon.asset" || auraAssetPath != "assets/jester/jesterbladeauradarkpurple.prefab" || !Hex(sourceSha256) || !Hex(bundleSha256) || !Hex(meshVertexSha256) || !Hex(meshTriangleSha256) || !Hex(auraVertexSha256) || !Hex(auraTriangleSha256))
		{
			throw new InvalidOperationException("Jester asset contract incomplete or wrong identity");
		}
	}

	private static bool Hex(string value)
	{
		if (value == null || value.Length != 64)
		{
			return false;
		}
		foreach (char c in value)
		{
			if ((c < '0' || c > '9') && (c < 'A' || c > 'F'))
			{
				return false;
			}
		}
		return true;
	}

	public void RequireMesh(Mesh mesh)
	{
		if (!Object.op_Implicit((Object)(object)mesh) || !mesh.isReadable || mesh.vertexCount != vertices || mesh.triangles.Length != triangles * 3 || VertexHash(mesh.vertices) != meshVertexSha256 || TriangleHash(mesh.triangles) != meshTriangleSha256)
		{
			throw new InvalidOperationException("Exact Jester custom mesh unavailable");
		}
	}

	public void RequireAura(GameObject aura)
	{
		//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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Invalid comparison between Unknown and I4
		//IL_0266: 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_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: 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_02a4: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)aura) || ((Object)aura).name != "JesterBladeAuraDarkPurple" || aura.transform.childCount != 3 || aura.GetComponentsInChildren<Collider>(true).Length != 0 || aura.GetComponentsInChildren<Rigidbody>(true).Length != 0 || aura.GetComponentsInChildren<Animator>(true).Length != 0 || aura.GetComponentsInChildren<MonoBehaviour>(true).Length != 0 || aura.GetComponentsInChildren<Light>(true).Length != 0)
		{
			throw new InvalidOperationException("Exact cosmetic aura required");
		}
		string[] array = new string[3] { "BladePulse", "BladeWisps", "BladeSwingTrail" };
		foreach (string text in array)
		{
			if (!Object.op_Implicit((Object)(object)aura.transform.Find(text)))
			{
				throw new InvalidOperationException("Aura child identity absent");
			}
		}
		Mesh sharedMesh = ((Component)aura.transform.Find("BladePulse")).GetComponent<MeshFilter>().sharedMesh;
		if (!Object.op_Implicit((Object)(object)sharedMesh) || !sharedMesh.isReadable || sharedMesh.vertexCount != 10906 || sharedMesh.triangles.Length != 8094 || VertexHash(sharedMesh.vertices) != auraVertexSha256 || TriangleHash(sharedMesh.triangles) != auraTriangleSha256)
		{
			throw new InvalidOperationException("Exact blade aura geometry required");
		}
		ParticleSystem[] componentsInChildren = aura.GetComponentsInChildren<ParticleSystem>(true);
		TrailRenderer[] componentsInChildren2 = aura.GetComponentsInChildren<TrailRenderer>(true);
		Renderer[] componentsInChildren3 = aura.GetComponentsInChildren<Renderer>(true);
		if (componentsInChildren.Length == 1 && componentsInChildren2.Length == 1 && componentsInChildren3.Length == 3)
		{
			MainModule main = componentsInChildren[0].main;
			if (((MainModule)(ref main)).maxParticles == 32)
			{
				EmissionModule emission = componentsInChildren[0].emission;
				MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
				if (((MinMaxCurve)(ref rateOverTime)).constant == 12f && componentsInChildren2[0].time == 0.16f && !componentsInChildren2[0].emitting)
				{
					Renderer[] array2 = componentsInChildren3;
					Color gamma = default(Color);
					for (int i = 0; i < array2.Length; i++)
					{
						Material sharedMaterial = array2[i].sharedMaterial;
						if (!Object.op_Implicit((Object)(object)sharedMaterial) || !Object.op_Implicit((Object)(object)sharedMaterial.shader) || ((Object)sharedMaterial.shader).name != "Necroverse/JesterDarkPurpleAura" || !sharedMaterial.shader.isSupported)
						{
							throw new InvalidOperationException("Dark purple shader unavailable");
						}
						Color color = sharedMaterial.GetColor("_AuraTint");
						((Color)(ref gamma))..ctor(22f / 85f, 0.0627451f, 0.41960785f, 1f);
						if ((int)QualitySettings.activeColorSpace == 1)
						{
							Color linear = ((Color)(ref gamma)).linear;
							gamma = ((Color)(ref linear)).gamma;
						}
						if (color.r != gamma.r || color.g != gamma.g || color.b != gamma.b || color.a <= 0f || color.a > 1f)
						{
							throw new InvalidOperationException("Dark purple material identity differs space=" + ((object)QualitySettings.activeColorSpace/*cast due to .constrained prefix*/).ToString() + " actual=" + ((Color)(ref color)).ToString("G9") + " expected=" + ((Color)(ref gamma)).ToString("G9"));
						}
					}
					if (((Component)aura.transform.Find("BladePulse")).GetComponent<Renderer>().sharedMaterial.GetFloat("_Cull") != 1f)
					{
						throw new InvalidOperationException("Aura must draw outside blade silhouette; face tint prohibited");
					}
					return;
				}
			}
		}
		throw new InvalidOperationException("Bounded cosmetic aura settings differ");
	}
}
public static class IndependentData
{
	private sealed class ReferenceComparer : IEqualityComparer<object>
	{
		public new bool Equals(object a, object b)
		{
			return a == b;
		}

		public int GetHashCode(object a)
		{
			return RuntimeHelpers.GetHashCode(a);
		}
	}

	private static readonly MethodInfo Memberwise = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic);

	public static T Copy<T>(T source)
	{
		return (T)CopyObject(source, new Dictionary<object, object>(new ReferenceComparer()));
	}

	private static object CopyObject(object source, Dictionary<object, object> seen)
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		if (source == null)
		{
			return null;
		}
		Type type = source.GetType();
		if (type.IsPrimitive || type.IsEnum || source is string || source is decimal || source is DateTime || source is Guid || source is Type || source is Object)
		{
			return source;
		}
		if (source is Delegate)
		{
			throw new InvalidOperationException("Unexpected delegate in vanilla item data: " + type.FullName);
		}
		if (!type.IsValueType && seen.TryGetValue(source, out var value))
		{
			return value;
		}
		AnimationCurve val = (AnimationCurve)((source is AnimationCurve) ? source : null);
		if (val != null)
		{
			AnimationCurve val2 = new AnimationCurve(val.keys)
			{
				preWrapMode = val.preWrapMode,
				postWrapMode = val.postWrapMode
			};
			seen.Add(source, val2);
			return val2;
		}
		if (source is Array array)
		{
			if (array.Rank != 1)
			{
				throw new InvalidOperationException("Unsupported multi-dimensional item data");
			}
			Array array2 = Array.CreateInstance(type.GetElementType(), array.Length);
			seen.Add(source, array2);
			for (int i = 0; i < array.Length; i++)
			{
				array2.SetValue(CopyObject(array.GetValue(i), seen), i);
			}
			return array2;
		}
		if (source is IList list)
		{
			IList list2 = (IList)Activator.CreateInstance(type);
			seen.Add(source, list2);
			{
				foreach (object item in list)
				{
					list2.Add(CopyObject(item, seen));
				}
				return list2;
			}
		}
		if (source is IDictionary dictionary)
		{
			IDictionary dictionary2 = (IDictionary)Activator.CreateInstance(type);
			seen.Add(source, dictionary2);
			{
				foreach (DictionaryEntry item2 in dictionary)
				{
					dictionary2.Add(CopyObject(item2.Key, seen), CopyObject(item2.Value, seen));
				}
				return dictionary2;
			}
		}
		object obj = Memberwise.Invoke(source, null);
		if (!type.IsValueType)
		{
			seen.Add(source, obj);
		}
		foreach (FieldInfo item3 in Fields(type))
		{
			item3.SetValue(obj, CopyObject(item3.GetValue(source), seen));
		}
		return obj;
	}

	public static IEnumerable<FieldInfo> Fields(Type type)
	{
		Type current = type;
		while (current != null && current != typeof(object) && current != typeof(Object))
		{
			FieldInfo[] fields = current.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!fieldInfo.IsStatic)
				{
					yield return fieldInfo;
				}
			}
			current = current.BaseType;
		}
	}

	public static void CopyRecipe(Recipe source, Recipe destination, ItemDrop item)
	{
		if (!Object.op_Implicit((Object)(object)source) || !Object.op_Implicit((Object)(object)destination) || (Object)(object)source == (Object)(object)destination || !Object.op_Implicit((Object)(object)item))
		{
			throw new InvalidOperationException("Independent recipe/source/item required");
		}
		FieldInfo[] fields = typeof(Recipe).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (!fieldInfo.IsStatic)
			{
				fieldInfo.SetValue(destination, Copy(fieldInfo.GetValue(source)));
			}
		}
		destination.m_item = item;
	}
}
[DefaultExecutionOrder(10000)]
public sealed class JesterAuraFollower : MonoBehaviour
{
	public GameObject AuraTemplate;

	public Renderer[] ReplacedNativeRenderers = (Renderer[])(object)new Renderer[0];

	public Light[] ReplacedNativeLights = (Light[])(object)new Light[0];

	public static Func<Transform, bool> AttackResolver;

	private GameObject effect;

	private MeshRenderer pulse;

	private ParticleSystem wisps;

	private TrailRenderer trail;

	private Transform lastTarget;

	private MaterialPropertyBlock block;

	private Vector3 previousPosition;

	private bool active;

	private int failures;

	public GameObject OwnedEffect => effect;

	public Transform FollowedTarget => lastTarget;

	public static Color PulseColor(float seconds)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		float num = 0.72f + 0.18f * (Mathf.Sin(seconds * 2.2f) + 1f) * 0.5f;
		return new Color(22f / 85f, 0.0627451f, 0.41960785f, num);
	}

	private void Awake()
	{
		if (Object.op_Implicit((Object)(object)AuraTemplate))
		{
			Initialize();
		}
	}

	public void Initialize()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		if (block == null)
		{
			block = new MaterialPropertyBlock();
		}
		if (!Object.op_Implicit((Object)(object)effect))
		{
			if (!Object.op_Implicit((Object)(object)AuraTemplate) || ((Object)AuraTemplate).name != "JesterBladeAuraDarkPurple")
			{
				throw new InvalidOperationException("Own dark purple aura template required");
			}
			effect = Object.Instantiate<GameObject>(AuraTemplate, ((Component)this).transform, false);
			((Object)effect).name = "NH_ChaosBattleaxe_OwnedAura";
			Transform[] componentsInChildren = effect.GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = ((Component)this).gameObject.layer;
			}
			pulse = ((Component)effect.transform.Find("BladePulse")).GetComponent<MeshRenderer>();
			wisps = effect.GetComponentInChildren<ParticleSystem>(true);
			trail = effect.GetComponentInChildren<TrailRenderer>(true);
			if (!Object.op_Implicit((Object)(object)pulse) || !Object.op_Implicit((Object)(object)wisps) || !Object.op_Implicit((Object)(object)trail) || effect.GetComponentsInChildren<Collider>(true).Length != 0 || effect.GetComponentsInChildren<Rigidbody>(true).Length != 0)
			{
				throw new InvalidOperationException("Cosmetic aura ownership contract failed");
			}
			trail.emitting = false;
			trail.Clear();
			active = false;
		}
	}

	private void LateUpdate()
	{
		try
		{
			Tick(Time.time, AttackResolver != null && AttackResolver(((Component)this).transform));
		}
		catch (Exception ex)
		{
			Suspend();
			if (failures++ == 0)
			{
				Debug.LogWarning((object)("CHAOS_AURA_UNAVAILABLE weaponPhysicsUnchanged=True reason=" + ex.Message));
			}
		}
	}

	public void Tick(float seconds, bool attacking)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0142: Unknown result type (might be due to invalid IL or missing references)
		if (float.IsNaN(seconds) || float.IsInfinity(seconds))
		{
			throw new InvalidOperationException("Finite aura clock required");
		}
		Initialize();
		if (!((Behaviour)this).isActiveAndEnabled || !((Component)this).gameObject.activeInHierarchy)
		{
			Suspend();
			return;
		}
		Transform val = ((Component)this).transform.Find("NH_ChaosBattleaxe_FittedVisual");
		Transform val2 = ((Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy) ? val : ((Component)this).transform);
		bool flag = (Object)(object)lastTarget != (Object)(object)val2;
		int num;
		if (active)
		{
			Vector3 val3 = val2.position - previousPosition;
			num = ((((Vector3)(ref val3)).sqrMagnitude > 0.5625f) ? 1 : 0);
		}
		else
		{
			num = 0;
		}
		bool flag2 = (byte)num != 0;
		if (flag || flag2)
		{
			wisps.Stop(true, (ParticleSystemStopBehavior)0);
			trail.Clear();
		}
		effect.transform.SetPositionAndRotation(val2.position, val2.rotation);
		effect.transform.localScale = Vector3.one;
		lastTarget = val2;
		previousPosition = val2.position;
		effect.SetActive(true);
		if (!active || flag || flag2)
		{
			wisps.Play(true);
		}
		active = true;
		block.SetColor("_AuraTint", PulseColor(seconds));
		((Renderer)pulse).SetPropertyBlock(block);
		trail.emitting = attacking && !flag && !flag2;
		Renderer[] replacedNativeRenderers = ReplacedNativeRenderers;
		foreach (Renderer val4 in replacedNativeRenderers)
		{
			if (Object.op_Implicit((Object)(object)val4))
			{
				val4.enabled = false;
			}
		}
		Light[] replacedNativeLights = ReplacedNativeLights;
		foreach (Light val5 in replacedNativeLights)
		{
			if (Object.op_Implicit((Object)(object)val5))
			{
				((Behaviour)val5).enabled = false;
			}
		}
	}

	public void Suspend()
	{
		if (Object.op_Implicit((Object)(object)wisps))
		{
			wisps.Stop(true, (ParticleSystemStopBehavior)0);
		}
		if (Object.op_Implicit((Object)(object)trail))
		{
			trail.emitting = false;
			trail.Clear();
		}
		if (Object.op_Implicit((Object)(object)effect))
		{
			effect.SetActive(false);
		}
		active = false;
		lastTarget = null;
	}

	private void OnDisable()
	{
		Suspend();
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)effect))
		{
			Object.Destroy((Object)(object)effect);
		}
	}
}
[Serializable]
public sealed class GripProfile
{
	public string itemId;

	public string visualPrefab;

	public string sourceSha256;

	public string meshVertexSha256;

	public string meshTriangleSha256;

	public int vertexCount;

	public int triangleCount;

	public float[] shaftOrigin;

	public float[] shaftAxis;

	public float[] nativeShaftOrigin;

	public float[] nativeShaftAxis;

	public float shaftMin;

	public float shaftMax;

	public float nativeShaftMin;

	public float nativeShaftMax;

	public float maxTiltDegrees;

	public float maxPrimaryDisplacementMetres;

	public Vector3 Origin => new Vector3(shaftOrigin[0], shaftOrigin[1], shaftOrigin[2]);

	public Vector3 Axis
	{
		get
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(shaftAxis[0], shaftAxis[1], shaftAxis[2]);
			return ((Vector3)(ref val)).normalized;
		}
	}

	public Vector3 NativeOrigin => new Vector3(nativeShaftOrigin[0], nativeShaftOrigin[1], nativeShaftOrigin[2]);

	public Vector3 NativeAxis
	{
		get
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(nativeShaftAxis[0], nativeShaftAxis[1], nativeShaftAxis[2]);
			return ((Vector3)(ref val)).normalized;
		}
	}

	public void Validate()
	{
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: 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_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: 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)
		if (itemId != "NH_ChaosBattleaxe" || visualPrefab != "JesterBattleaxeVisual" || shaftOrigin == null || shaftOrigin.Length != 3 || shaftAxis == null || shaftAxis.Length != 3 || nativeShaftOrigin == null || nativeShaftOrigin.Length != 3 || nativeShaftAxis == null || nativeShaftAxis.Length != 3)
		{
			throw new InvalidOperationException("Measured Jester grip identity/axis absent");
		}
		float[][] array = new float[4][] { shaftOrigin, shaftAxis, nativeShaftOrigin, nativeShaftAxis };
		float[] array2;
		for (int i = 0; i < array.Length; i++)
		{
			array2 = array[i];
			for (int j = 0; j < array2.Length; j++)
			{
				Finite(array2[j]);
			}
		}
		array2 = new float[6] { shaftMin, shaftMax, nativeShaftMin, nativeShaftMax, maxTiltDegrees, maxPrimaryDisplacementMetres };
		for (int i = 0; i < array2.Length; i++)
		{
			Finite(array2[i]);
		}
		Vector3 val = Axis - Vector3.forward;
		if (!(((Vector3)(ref val)).sqrMagnitude > 1E-08f))
		{
			val = NativeAxis - Vector3.forward;
			if (!(((Vector3)(ref val)).sqrMagnitude > 1E-08f))
			{
				val = NativeOrigin - new Vector3(-0.004408273f, 0f, 0f);
				if (!(((Vector3)(ref val)).sqrMagnitude > 1E-10f))
				{
					Vector2 val2 = new Vector2(Origin.x - NativeOrigin.x, Origin.y - NativeOrigin.y);
					if (!(((Vector2)(ref val2)).sqrMagnitude > 1E-10f))
					{
						if (shaftMin >= shaftMax || Mathf.Abs(nativeShaftMin - -0.153907f) > 1E-06f || Mathf.Abs(nativeShaftMax - 0.8115f) > 1E-06f || maxTiltDegrees <= 0f || maxTiltDegrees > 15f || maxPrimaryDisplacementMetres <= 0f || maxPrimaryDisplacementMetres > 0.4f)
						{
							throw new InvalidOperationException("Measured shaft/baseline bound contract invalid");
						}
						return;
					}
				}
			}
		}
		throw new InvalidOperationException("Custom packet is not aligned to the measured native shaft frame");
	}

	private static void Finite(float value)
	{
		if (float.IsNaN(value) || float.IsInfinity(value))
		{
			throw new InvalidOperationException("Nonfinite grip profile");
		}
	}
}
public static class JesterGripMath
{
	private static float Smooth(float value)
	{
		value = Mathf.Clamp01(value);
		return value * value * (3f - 2f * value);
	}

	private static void Finite(float value)
	{
		if (float.IsNaN(value) || float.IsInfinity(value))
		{
			throw new InvalidOperationException("Nonfinite custom grip input");
		}
	}

	private static void Finite(Vector3 value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		Finite(value.x);
		Finite(value.y);
		Finite(value.z);
	}

	public static void ValidateInputs(Matrix4x4 item, Vector3 nativeRight, Vector3 fittedRight, Vector3 nativeLeft, Vector3 fittedLeft)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_007c: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				Finite(((Matrix4x4)(ref item))[i, j]);
			}
		}
		Finite(nativeRight);
		Finite(fittedRight);
		Finite(nativeLeft);
		Finite(fittedLeft);
		if (Math.Abs((double)item.m00 * ((double)item.m11 * (double)item.m22 - (double)item.m12 * (double)item.m21) - (double)item.m01 * ((double)item.m10 * (double)item.m22 - (double)item.m12 * (double)item.m20) + (double)item.m02 * ((double)item.m10 * (double)item.m21 - (double)item.m11 * (double)item.m20)) < 1E-06 || Mathf.Abs(item.m30) > 1E-06f || Mathf.Abs(item.m31) > 1E-06f || Mathf.Abs(item.m32) > 1E-06f || Mathf.Abs(item.m33 - 1f) > 1E-06f)
		{
			throw new InvalidOperationException("Singular or non-affine custom grip item basis");
		}
	}

	public static Quaternion Calculate(GripProfile profile, Matrix4x4 item, Vector3 nativeRight, Vector3 fittedRight, Vector3 nativeLeft, Vector3 fittedLeft, out float weight, out float tilt)
	{
		//IL_0010: 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_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_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_011e: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: 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_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		weight = 0f;
		tilt = 0f;
		ValidateInputs(item, nativeRight, fittedRight, nativeLeft, fittedLeft);
		Vector3 val = fittedRight - nativeRight;
		if (((Vector3)(ref val)).magnitude > profile.maxPrimaryDisplacementMetres)
		{
			throw new InvalidOperationException("Jester fitted primary exceeds retained displacement bound");
		}
		((Matrix4x4)(ref item)).SetColumn(3, new Vector4(0f, 0f, 0f, 1f));
		Matrix4x4 inverse = ((Matrix4x4)(ref item)).inverse;
		Vector3 val2 = ((Matrix4x4)(ref inverse)).MultiplyVector(nativeLeft);
		inverse = ((Matrix4x4)(ref item)).inverse;
		Vector3 val3 = ((Matrix4x4)(ref inverse)).MultiplyVector(nativeRight);
		Finite(val2);
		Finite(val3);
		Vector3 val4 = val2 - profile.NativeOrigin;
		float num = Vector3.Dot(val4, profile.NativeAxis);
		val = val4 - profile.NativeAxis * num;
		float magnitude = ((Vector3)(ref val)).magnitude;
		weight = Smooth((0.065f - magnitude) / 0.025f) * Smooth((num - 0.03f) / 0.04f) * Smooth((profile.nativeShaftMax - num) / 0.05f);
		if (weight <= 0f)
		{
			return Quaternion.identity;
		}
		float num2 = Vector3.Dot(val3 - profile.Origin, profile.Axis);
		float num3 = Vector3.Dot(val2 - val3, profile.Axis);
		if (num2 < profile.shaftMin || num2 > profile.shaftMax)
		{
			throw new InvalidOperationException("Native primary joint reference outside custom shaft");
		}
		Vector3 val5 = val2 - val3 - profile.Axis * num3;
		val = fittedLeft - fittedRight;
		float magnitude2 = ((Vector3)(ref val)).magnitude;
		float num4 = magnitude2 * magnitude2 - ((Vector3)(ref val5)).sqrMagnitude;
		if (num4 <= 0f || float.IsNaN(num4) || float.IsInfinity(num4))
		{
			throw new InvalidOperationException("Custom rigid shaft cannot fit fitted reference span");
		}
		float num5 = num2 + Mathf.Sign(num3) * Mathf.Sqrt(num4);
		if (num5 < profile.shaftMin || num5 > profile.shaftMax)
		{
			throw new InvalidOperationException("Fitted offhand joint reference outside measured custom shaft");
		}
		Quaternion val6 = Quaternion.FromToRotation(((Matrix4x4)(ref item)).MultiplyVector(val5 + profile.Axis * (num5 - num2)), fittedLeft - fittedRight);
		tilt = Quaternion.Angle(Quaternion.identity, val6);
		if (float.IsNaN(tilt) || float.IsInfinity(tilt) || tilt > profile.maxTiltDegrees)
		{
			throw new InvalidOperationException("Jester fitted visual exceeds retained tilt bound");
		}
		return Quaternion.Slerp(Quaternion.identity, val6, weight);
	}
}
public sealed class JesterVisualLease
{
	private sealed class EffectPose
	{
		public Transform Transform;

		public Vector3 Position;

		public Quaternion Rotation;
	}

	public readonly MeshRenderer Original;

	public readonly GameObject Visual;

	private readonly bool originalEnabled;

	private readonly List<EffectPose> effects = new List<EffectPose>();

	private bool applied;

	public JesterVisualLease(GameObject root, AssetContract contract)
	{
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Expected O, but got Unknown
		Transform val = (Object.op_Implicit((Object)(object)root) ? root.transform.Find("default") : null);
		MeshFilter val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshFilter>() : null);
		Original = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshRenderer>() : null);
		if (!Object.op_Implicit((Object)(object)Original) || !Object.op_Implicit((Object)(object)val2) || root.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 0)
		{
			throw new InvalidOperationException("Exact Jester attach/default rigid visual absent");
		}
		contract.RequireMesh(val2.sharedMesh);
		string[] array = new string[4] { "UpgraderGlow", "equiped", "Point Light", "flare" };
		foreach (string text in array)
		{
			Transform val3 = root.transform.Find(text);
			if (!Object.op_Implicit((Object)(object)val3) || ((Component)val3).GetComponentsInChildren<Collider>(true).Length != 0 || ((Component)val3).GetComponentsInChildren<Rigidbody>(true).Length != 0)
			{
				throw new InvalidOperationException("Jester cloned effect ownership changed: " + text);
			}
			effects.Add(new EffectPose
			{
				Transform = val3
			});
		}
		originalEnabled = ((Renderer)Original).enabled;
		Visual = new GameObject("NH_ChaosBattleaxe_FittedVisual");
		Visual.transform.SetParent(val, false);
		Visual.layer = ((Component)val).gameObject.layer;
		Visual.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh;
		MeshRenderer obj = Visual.AddComponent<MeshRenderer>();
		((Renderer)obj).sharedMaterials = ((Renderer)Original).sharedMaterials;
		((Renderer)obj).shadowCastingMode = ((Renderer)Original).shadowCastingMode;
		((Renderer)obj).receiveShadows = ((Renderer)Original).receiveShadows;
		((Renderer)obj).lightProbeUsage = ((Renderer)Original).lightProbeUsage;
		((Renderer)obj).reflectionProbeUsage = ((Renderer)Original).reflectionProbeUsage;
		MaterialPropertyBlock val4 = new MaterialPropertyBlock();
		((Renderer)Original).GetPropertyBlock(val4);
		((Renderer)obj).SetPropertyBlock(val4);
		Visual.SetActive(false);
	}

	public void Apply(Vector3 origin, Vector3 nativePrimary, Vector3 fittedPrimary, Quaternion delta)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		Restore();
		if (!Object.op_Implicit((Object)(object)Original) || !Object.op_Implicit((Object)(object)Visual))
		{
			return;
		}
		((Renderer)Original).enabled = false;
		Visual.transform.SetPositionAndRotation(origin + fittedPrimary + delta * (((Component)Original).transform.position - origin - nativePrimary), delta * ((Component)Original).transform.rotation);
		foreach (EffectPose effect in effects)
		{
			if (Object.op_Implicit((Object)(object)effect.Transform))
			{
				effect.Position = effect.Transform.localPosition;
				effect.Rotation = effect.Transform.localRotation;
				effect.Transform.SetPositionAndRotation(origin + fittedPrimary + delta * (effect.Transform.position - origin - nativePrimary), delta * effect.Transform.rotation);
			}
		}
		applied = true;
		Visual.SetActive(true);
	}

	public void Restore()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)Original))
		{
			((Renderer)Original).enabled = originalEnabled;
		}
		if (Object.op_Implicit((Object)(object)Visual))
		{
			Visual.SetActive(false);
		}
		if (!applied)
		{
			return;
		}
		foreach (EffectPose effect in effects)
		{
			if (Object.op_Implicit((Object)(object)effect.Transform))
			{
				effect.Transform.localPosition = effect.Position;
				effect.Transform.localRotation = effect.Rotation;
			}
		}
		applied = false;
	}

	public void Clear()
	{
		Restore();
		if (Object.op_Implicit((Object)(object)Visual))
		{
			Object.Destroy((Object)(object)Visual);
		}
	}
}
public static class JesterItem
{
	public const string ItemId = "NH_ChaosBattleaxe";

	public const string BaseItemId = "BattleaxeCrystal";

	private static readonly Dictionary<string, CustomItem> items = new Dictionary<string, CustomItem>(StringComparer.Ordinal);

	private static GameObject visual;

	private static GameObject aura;

	private static Sprite icon;

	private static AssetContract contract;

	private static bool initialized;

	public static void Initialize(GameObject art, Sprite ownIcon, AssetContract identity, GameObject ownAura)
	{
		if (initialized || !Object.op_Implicit((Object)(object)ownIcon) || ((Object)ownIcon).name != "JesterBattleaxeIcon")
		{
			throw new InvalidOperationException("Jester initialization or own icon identity invalid");
		}
		identity.RequireAura(ownAura);
		visual = art;
		aura = ownAura;
		icon = ownIcon;
		contract = identity;
		initialized = true;
		JesterAuraFollower.AttackResolver = IsAttacking;
		PrefabManager.OnVanillaPrefabsAvailable += Register;
		ItemManager.OnItemsRegistered += Synchronize;
		ItemManager.OnItemsRegisteredFejd += Synchronize;
	}

	private static bool IsAttacking(Transform model)
	{
		Humanoid componentInParent = ((Component)model).GetComponentInParent<Humanoid>();
		if (Object.op_Implicit((Object)(object)componentInParent))
		{
			return ((Character)componentInParent).InAttack();
		}
		return false;
	}

	public static void Shutdown()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= Register;
		ItemManager.OnItemsRegistered -= Synchronize;
		ItemManager.OnItemsRegisteredFejd -= Synchronize;
		JesterAuraFollower.AttackResolver = null;
		initialized = false;
	}

	private static void Register()
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Expected O, but got Unknown
		PrefabManager.OnVanillaPrefabsAvailable -= Register;
		try
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab("BattleaxeCrystal");
			if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemDrop>()))
			{
				throw new InvalidOperationException("Actual BattleaxeCrystal prefab unavailable");
			}
			JesterTier[] tiers = JesterProgression.Tiers;
			foreach (JesterTier jesterTier in tiers)
			{
				if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab(jesterTier.Id)))
				{
					throw new InvalidOperationException("Jester tier identity already owned: " + jesterTier.Id);
				}
				CustomItem val = new CustomItem(jesterTier.Id, "BattleaxeCrystal");
				if (!Object.op_Implicit((Object)(object)val.ItemPrefab) || !Object.op_Implicit((Object)(object)val.ItemDrop) || (Object)(object)val.ItemPrefab == (Object)(object)prefab)
				{
					throw new InvalidOperationException("Independent Jester clone unavailable");
				}
				val.ItemDrop.m_itemData = IndependentData.Copy<ItemData>(prefab.GetComponent<ItemDrop>().m_itemData);
				val.ItemDrop.m_itemData.m_dropPrefab = val.ItemPrefab;
				val.ItemDrop.m_itemData.m_shared.m_name = jesterTier.Name;
				val.ItemDrop.m_itemData.m_shared.m_description = Description(jesterTier);
				val.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
				RequireIndependent(val.ItemDrop.m_itemData.m_shared, prefab.GetComponent<ItemDrop>().m_itemData.m_shared);
				ReplaceCustomCloneVisual(prefab, val.ItemPrefab);
				Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
				((Object)val2).name = "Recipe_" + jesterTier.Id;
				val2.m_item = val.ItemDrop;
				val2.m_resources = (Requirement[])(object)new Requirement[0];
				val2.m_enabled = false;
				val.Recipe = new CustomRecipe(val2, false, false);
				if (!ItemManager.Instance.AddItem(val))
				{
					throw new InvalidOperationException("Jester item registration rejected: " + jesterTier.Id);
				}
				items.Add(jesterTier.Id, val);
				Plugin.Info("CHAOS_ITEM registered=" + jesterTier.Id + " independentSharedData=True vanillaUnchanged=True recipePending=True aura=DarkPurpleCosmetic");
			}
		}
		catch (Exception error)
		{
			Plugin.Failure("CHAOS_ITEM_UNAVAILABLE", error);
		}
	}

	private static string Description(JesterTier tier)
	{
		return "A two-handed Jester battleaxe with dark-purple blade energy. " + ((tier.Previous == null) ? "Reforge it with later-biome resources to progress." : ("Reforged for " + tier.Name.Substring("Chaos Battleaxe — ".Length) + ". Reforging consumes the previous tier and starts this tier at quality 1."));
	}

	public static void RequireIndependent(SharedData ours, SharedData source)
	{
		if (ours == null || source == null || ours == source || (source.m_attack != null && ours.m_attack == source.m_attack) || (source.m_secondaryAttack != null && ours.m_secondaryAttack == source.m_secondaryAttack))
		{
			throw new InvalidOperationException("SharedData/Attack alias in custom item");
		}
	}

	private static void ReplaceCustomCloneVisual(GameObject source, GameObject target)
	{
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		Transform val = source.transform.Find("attach/default");
		Transform val2 = target.transform.Find("attach/default");
		if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || (Object)(object)val2 == (Object)(object)val || !JesterProgression.Matches(((Object)target).name))
		{
			throw new InvalidOperationException("Exact independent attach/default required");
		}
		MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
		MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
		MeshFilter component3 = visual.GetComponent<MeshFilter>();
		MeshRenderer component4 = visual.GetComponent<MeshRenderer>();
		if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component3) || !Object.op_Implicit((Object)(object)component4) || ((Component)val2).GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 0)
		{
			throw new InvalidOperationException("Exact rigid native/custom renderers required");
		}
		MeshFilter component5 = ((Component)val).GetComponent<MeshFilter>();
		Mesh val3 = (Object.op_Implicit((Object)(object)component5) ? component5.sharedMesh : null);
		if (!Object.op_Implicit((Object)(object)val3) || !val3.isReadable || val3.vertexCount != 1110 || AssetContract.VertexHash(val3.vertices) != "6C72051F7476C62CD5047CEFA768AC038C9BBE52FA605BA58D47A8EC2E75D2C4" || AssetContract.TriangleHash(val3.triangles) != "A18088D791CFBA5F1C224C322B3D6466BD2E9A839C743C13C740CBC6CC814DD0")
		{
			throw new InvalidOperationException("Installed native Crystal source mesh identity differs");
		}
		List<Transform> list = new List<Transform>();
		string[] array = new string[4] { "UpgraderGlow", "equiped", "Point Light", "flare" };
		foreach (string text in array)
		{
			Transform val4 = target.transform.Find("attach/" + text);
			Transform val5 = source.transform.Find("attach/" + text);
			if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val5) || (Object)(object)val4 == (Object)(object)val5)
			{
				throw new InvalidOperationException("Crystal effect ownership absent " + text);
			}
			list.Add(val4);
		}
		if (!Object.op_Implicit((Object)(object)((Component)val2).GetComponent<BoxCollider>()) || !Object.op_Implicit((Object)(object)((Component)val).GetComponent<BoxCollider>()))
		{
			throw new InvalidOperationException("Native collider identity absent");
		}
		contract.RequireMesh(component3.sharedMesh);
		component.sharedMesh = component3.sharedMesh;
		((Renderer)component2).sharedMaterials = ((Renderer)component4).sharedMaterials;
		((Renderer)component2).SetPropertyBlock((MaterialPropertyBlock)null);
		JesterAuraFollower jesterAuraFollower = ((Component)val2).gameObject.AddComponent<JesterAuraFollower>();
		jesterAuraFollower.AuraTemplate = aura;
		jesterAuraFollower.ReplacedNativeRenderers = list.SelectMany((Transform t) => ((Component)t).GetComponentsInChildren<Renderer>(true)).ToArray();
		jesterAuraFollower.ReplacedNativeLights = list.SelectMany((Transform t) => ((Component)t).GetComponentsInChildren<Light>(true)).ToArray();
		Renderer[] replacedNativeRenderers = jesterAuraFollower.ReplacedNativeRenderers;
		for (int i = 0; i < replacedNativeRenderers.Length; i++)
		{
			replacedNativeRenderers[i].enabled = false;
		}
		Light[] replacedNativeLights = jesterAuraFollower.ReplacedNativeLights;
		for (int i = 0; i < replacedNativeLights.Length; i++)
		{
			((Behaviour)replacedNativeLights[i]).enabled = false;
		}
		foreach (ParticleSystem item in list.SelectMany((Transform t) => ((Component)t).GetComponentsInChildren<ParticleSystem>(true)))
		{
			EmissionModule emission = item.emission;
			((EmissionModule)(ref emission)).enabled = false;
			item.Stop(true, (ParticleSystemStopBehavior)0);
		}
	}

	private static ItemDrop RequireDrop(ObjectDB db, string id)
	{
		GameObject itemPrefab = db.GetItemPrefab(id);
		ItemDrop val = (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.GetComponent<ItemDrop>() : null);
		if (!Object.op_Implicit((Object)(object)val) || val.m_itemData == null || val.m_itemData.m_shared == null)
		{
			throw new InvalidOperationException("Installed item source absent " + id);
		}
		return val;
	}

	private static void Synchronize()
	{
		ObjectDB instance = ObjectDB.instance;
		if (!Object.op_Implicit((Object)(object)instance) || instance.m_recipes == null)
		{
			return;
		}
		JesterTier[] tiers = JesterProgression.Tiers;
		foreach (JesterTier tier in tiers)
		{
			if (!items.TryGetValue(tier.Id, out var value))
			{
				continue;
			}
			Recipe val = ((value.Recipe != null) ? value.Recipe.Recipe : null);
			try
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					throw new InvalidOperationException("Owned recipe absent");
				}
				val.m_enabled = false;
				SharedData shared = RequireDrop(instance, "BattleaxeCrystal").m_itemData.m_shared;
				SharedData shared2 = RequireDrop(instance, tier.StatsSource).m_itemData.m_shared;
				ItemDrop val2 = RequireDrop(instance, tier.Id);
				SharedData chop = ((tier.ChopSource == null) ? null : RequireDrop(instance, tier.ChopSource).m_itemData.m_shared);
				SharedData val3 = JesterProgression.CreateStats(shared, shared2, chop);
				val3.m_name = tier.Name;
				val3.m_description = Description(tier);
				val3.m_icons = (Sprite[])(object)new Sprite[1] { icon };
				RequireIndependent(val3, shared);
				val2.m_itemData.m_shared = val3;
				Recipe[] array = instance.m_recipes.Where((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && ((Object)r.m_item).name == tier.RecipeSource && r.m_resources != null && r.m_resources.Length != 0).ToArray();
				if (array.Length != 1)
				{
					throw new InvalidOperationException("Exact native recipe required: " + tier.RecipeSource + " matches=" + array.Length);
				}
				Recipe val4 = array[0];
				if (!Object.op_Implicit((Object)(object)val4.m_craftingStation) || val4.m_minStationLevel < 1 || val4.m_requireOnlyOneIngredient || val4.m_amount != 1 || val4.m_resources.Any((Requirement r) => r == null || !Object.op_Implicit((Object)(object)r.m_resItem)))
				{
					throw new InvalidOperationException("Native recipe/station evidence incomplete");
				}
				ItemDrop val5 = ((tier.Previous == null) ? null : RequireDrop(instance, tier.Previous));
				IndependentData.CopyRecipe(val4, val, val2);
				val.m_resources = JesterProgression.ReforgeRequirements(val4.m_resources, val5);
				if (Object.op_Implicit((Object)(object)val5))
				{
					val.m_noCraftOnlyUpgrade = false;
				}
				val.m_enabled = val4.m_enabled;
				Plugin.Info("CHAOS_RECIPE item=" + tier.Id + " source=" + tier.RecipeSource + " stats=" + tier.StatsSource + " previous=" + (tier.Previous ?? "none") + " qualityMax=" + val3.m_maxQuality + " station=" + ((Object)val.m_craftingStation).name + " minLevel=" + val.m_minStationLevel + " qualityResetsOnReforge=True vanillaModified=False enabled=" + val.m_enabled);
			}
			catch (Exception error)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.m_enabled = false;
				}
				Plugin.Failure("CHAOS_TIER_UNAVAILABLE item=" + tier.Id, error);
			}
		}
	}
}
public sealed class JesterTier
{
	public readonly string Id;

	public readonly string Name;

	public readonly string StatsSource;

	public readonly string RecipeSource;

	public readonly string ChopSource;

	public readonly string Previous;

	public JesterTier(string id, string name, string stats, string recipe, string previous = null, string chop = null)
	{
		Id = id;
		Name = name;
		StatsSource = stats;
		RecipeSource = recipe;
		Previous = previous;
		ChopSource = chop;
	}
}
public static class JesterProgression
{
	public static readonly JesterTier[] Tiers = new JesterTier[5]
	{
		new JesterTier("NH_ChaosBattleaxe", "Chaos Battleaxe", "BattleaxeCrystal", "BattleaxeCrystal"),
		new JesterTier("NH_ChaosBattleaxe_Plains", "Chaos Battleaxe — Plains", "BattleaxeBlackmetal", "BattleaxeBlackmetal", "NH_ChaosBattleaxe"),
		new JesterTier("NH_ChaosBattleaxe_Mistlands", "Chaos Battleaxe — Mistlands", "BattleaxeSkullSplittur", "BattleaxeSkullSplittur", "NH_ChaosBattleaxe_Plains"),
		new JesterTier("NH_ChaosBattleaxe_Ashlands", "Chaos Battleaxe — Ashlands", "THSwordSlayer", "THSwordSlayer", "NH_ChaosBattleaxe_Mistlands", "AxeBerzerkr"),
		new JesterTier("NH_ChaosBattleaxe_DeepNorth", "Chaos Battleaxe — Deep North", "BattleaxeGold", "BattleaxeGold", "NH_ChaosBattleaxe_Ashlands")
	};

	public static bool Matches(string id)
	{
		if (id != null)
		{
			return Tiers.Any((JesterTier t) => string.Equals(t.Id, id, StringComparison.Ordinal));
		}
		return false;
	}

	public static SharedData CreateStats(SharedData crystal, SharedData tier, SharedData chop = null)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if (crystal == null || tier == null)
		{
			throw new InvalidOperationException("Verified Crystal and tier stats required");
		}
		SharedData val = IndependentData.Copy<SharedData>(crystal);
		JesterItem.RequireIndependent(val, crystal);
		val.m_damages = tier.m_damages;
		val.m_damagesPerLevel = tier.m_damagesPerLevel;
		val.m_maxQuality = tier.m_maxQuality;
		val.m_maxDurability = tier.m_maxDurability;
		val.m_durabilityPerLevel = tier.m_durabilityPerLevel;
		val.m_blockPower = tier.m_blockPower;
		val.m_blockPowerPerLevel = tier.m_blockPowerPerLevel;
		val.m_deflectionForce = tier.m_deflectionForce;
		val.m_deflectionForcePerLevel = tier.m_deflectionForcePerLevel;
		val.m_timedBlockBonus = tier.m_timedBlockBonus;
		val.m_toolTier = tier.m_toolTier;
		if (chop != null)
		{
			val.m_damages.m_chop = chop.m_damages.m_chop;
			val.m_damagesPerLevel.m_chop = chop.m_damagesPerLevel.m_chop;
		}
		if (val.m_maxQuality < 1 || val.m_maxDurability <= 0f || val.m_damages.m_slash <= 0f)
		{
			throw new InvalidOperationException("Native progression stats unavailable");
		}
		return val;
	}

	public static Requirement[] ReforgeRequirements(Requirement[] native, ItemDrop previous)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		if (native == null || native.Length == 0)
		{
			throw new InvalidOperationException("Native recipe evidence required");
		}
		Requirement[] array = IndependentData.Copy(native);
		if (previous == null)
		{
			return array;
		}
		return ((IEnumerable<Requirement>)(object)new Requirement[1]
		{
			new Requirement
			{
				m_resItem = previous,
				m_amount = 1,
				m_amountPerLevel = 0,
				m_extraAmountOnlyOneIngredient = 0,
				m_upgraderResource = false,
				m_recover = false
			}
		}).Concat(array).ToArray();
	}
}
[BepInPlugin("com.necroverseheroes.barbarianviking.axe", "Barbarian Viking Jester Axe", "1.0.0")]
[BepInDependency("com.jotunn.jotunn", "2.30.2")]
public sealed class Plugin : BaseUnityPlugin
{
	public const string Guid = "com.necroverseheroes.barbarianviking.axe";

	public const string Version = "1.0.0";

	internal static Plugin Instance;

	private AssetBundle bundle;

	private float next;

	private bool ready;

	private void Awake()
	{
		//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_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: 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)
		Instance = this;
		try
		{
			string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
			string text = Path.Combine(directoryName, "nh_chaosbattleaxe");
			AssetContract assetContract = JsonUtility.FromJson<AssetContract>(File.ReadAllText(Path.Combine(directoryName, "Build_Contract.json")));
			assetContract.Validate();
			if (AssetContract.FileHash(text) != assetContract.bundleSha256)
			{
				throw new InvalidOperationException("Jester bundle hash differs");
			}
			bundle = AssetBundle.LoadFromFile(text);
			if (!Object.op_Implicit((Object)(object)bundle) || !bundle.GetAllAssetNames().OrderBy<string, string>((string name) => name, StringComparer.Ordinal).SequenceEqual(new string[3] { assetContract.visualAssetPath, assetContract.iconAssetPath, assetContract.auraAssetPath }.OrderBy<string, string>((string name) => name, StringComparer.Ordinal)))
			{
				throw new InvalidOperationException("Exact Jester visual, aura and icon asset paths required");
			}
			GameObject val = bundle.LoadAsset<GameObject>(assetContract.visualAssetPath);
			Sprite val2 = bundle.LoadAsset<Sprite>(assetContract.iconAssetPath);
			if (!Object.op_Implicit((Object)(object)val2) || ((Object)val2).name != "JesterBattleaxeIcon")
			{
				throw new InvalidOperationException("Exact Jester icon Sprite identity required");
			}
			if (!Object.op_Implicit((Object)(object)val) || ((Object)val).name != "JesterBattleaxeVisual" || val.GetComponentsInChildren<MeshRenderer>(true).Length != 1 || !Object.op_Implicit((Object)(object)val.GetComponent<MeshRenderer>()) || !Object.op_Implicit((Object)(object)val.GetComponent<MeshFilter>()) || val.GetComponentsInChildren<Collider>(true).Length != 0 || val.GetComponentsInChildren<Rigidbody>(true).Length != 0 || val.GetComponentsInChildren<Animator>(true).Length != 0 || val.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 0 || Object.op_Implicit((Object)(object)val.GetComponent<ItemDrop>()) || val.transform.localPosition != Vector3.zero || val.transform.localRotation != Quaternion.identity || val.transform.localScale != Vector3.one)
			{
				throw new InvalidOperationException("Exact art-only rigid Jester prefab contract failed");
			}
			assetContract.RequireMesh(val.GetComponent<MeshFilter>().sharedMesh);
			GameObject val3 = bundle.LoadAsset<GameObject>(assetContract.auraAssetPath);
			assetContract.RequireAura(val3);
			JesterItem.Initialize(val, val2, assetContract, val3);
			ready = true;
			try
			{
				GripProfile measured = JsonUtility.FromJson<GripProfile>(File.ReadAllText(Path.Combine(directoryName, "Grip_Profile.json")));
				TaylorBridge.Initialize(assetContract, measured);
			}
			catch (Exception error)
			{
				Failure("CHAOS_TAYLOR_FIT_UNAVAILABLE normalPlayerCustomVisualPreserved=True", error);
			}
			Info("CHAOS_ASSET ready=True version=1.0.0 independentItem=NH_ChaosBattleaxe bundleSHA256=" + assetContract.bundleSha256 + " vanillaBattleaxeAndCrystalUnchanged=True registrationAndLiveAcceptance=PENDING");
		}
		catch (Exception error2)
		{
			Failure("CHAOS_ADDON_SAFELY_UNAVAILABLE vanillaItemsAndTaylorUnchanged=True", error2);
		}
	}

	private void Update()
	{
		if (ready && !(Time.realtimeSinceStartup < next))
		{
			next = Time.realtimeSinceStartup + 1f;
			TaylorBridge.TryPatch();
		}
	}

	private void OnDestroy()
	{
		ready = false;
		TaylorBridge.Shutdown();
		JesterItem.Shutdown();
		if (Object.op_Implicit((Object)(object)bundle))
		{
			bundle.Unload(false);
		}
		Instance = null;
	}

	internal static void Info(string message)
	{
		if (Object.op_Implicit((Object)(object)Instance))
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}
	}

	internal static void Failure(string stage, Exception error)
	{
		if (Object.op_Implicit((Object)(object)Instance))
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)(stage + " reason=" + error));
		}
	}
}
public static class TaylorBridge
{
	private sealed class State
	{
		public GameObject Root;

		public JesterVisualLease Lease;
	}

	public const string BaselineSha256 = "72F8F7515E64EEB7CD945279413775A89DE68C7595720420583845C7430123B7";

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

	private static FieldInfo player;

	private static FieldInfo equipment;

	private static FieldInfo native;

	private static FieldInfo fitted;

	private static readonly FieldInfo Right = typeof(VisEquipment).GetField("m_rightItemInstance", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

	private static readonly MethodInfo RightItem = typeof(Humanoid).GetMethod("GetRightItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);

	private static AssetContract contract;

	private static GripProfile profile;

	private static Harmony harmony;

	private static bool patched;

	private static bool unavailable;

	private static readonly Dictionary<object, State> states = new Dictionary<object, State>();

	private static readonly HashSet<string> logged = new HashSet<string>();

	public static void Initialize(AssetContract identity, GripProfile measured)
	{
		measured.Validate();
		if (measured.sourceSha256 != identity.sourceSha256 || measured.meshVertexSha256 != identity.meshVertexSha256 || measured.meshTriangleSha256 != identity.meshTriangleSha256 || measured.vertexCount != identity.vertices || measured.triangleCount != identity.triangles)
		{
			throw new InvalidOperationException("Grip/source/custom geometry identity differs");
		}
		contract = identity;
		profile = measured;
	}

	public static void TryPatch()
	{
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Expected O, but got Unknown
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Expected O, but got Unknown
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Expected O, but got Unknown
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Expected O, but got Unknown
		if (patched || unavailable || profile == null)
		{
			return;
		}
		Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "NH_VLCEAuthor");
		if (assembly == null)
		{
			return;
		}
		try
		{
			string text = assembly.GetName().Version.ToString();
			string text2 = AssetContract.FileHash(assembly.Location);
			if (text == "0.5.9.0")
			{
				_ = text2 == "72F8F7515E64EEB7CD945279413775A89DE68C7595720420583845C7430123B7";
			}
			else
				_ = 0;
			if (text == "0.5.10.0")
			{
				_ = text2 == "3CB3DFA314230D79D75271626CD9D2220B8280F0F3797483D1F0B7B2D826BB60";
			}
			else
				_ = 0;
			if (!(text == "1.0.0.0") || !(text2 == "9941A8524D29F31779A4461E3C3544F3AF7083683437C679BC070551684CD180"))
			{
				throw new InvalidOperationException("Barbarian Taylor companion hash/version contract differs");
			}
			Type? type = assembly.GetType("TaylorV5RuntimeTest.TaylorV5GripAdapter", throwOnError: true);
			player = RequireField(type, "player", typeof(Player));
			equipment = RequireField(type, "equipment", typeof(VisEquipment));
			native = RequireField(type, "native", typeof(Dictionary<string, Transform>));
			fitted = RequireField(type, "fitted", typeof(Dictionary<string, Transform>));
			if (Right == null || Right.FieldType != typeof(GameObject) || RightItem == null || RightItem.ReturnType != typeof(ItemData))
			{
				throw new InvalidOperationException("Installed equipment read-only accessor differs");
			}
			MethodInfo methodInfo = RequireMethod(type, "Tick");
			MethodInfo methodInfo2 = RequireMethod(type, "Restore");
			MethodInfo methodInfo3 = RequireMethod(type, "Clear");
			harmony = new Harmony("com.necroverseheroes.barbarianviking.axe.optional-taylor");
			harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(TaylorBridge).GetMethod("AfterRestore")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(TaylorBridge).GetMethod("AfterClear")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(TaylorBridge).GetMethod("AfterTick")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			patched = true;
			Plugin.Info("CHAOS_TAYLOR_BRIDGE verifiedAssemblySHA256=" + text2 + " adapter=TaylorV5GripAdapter itemOnly=NH_ChaosBattleaxe legacyMathUnchanged=True nativePlayersIndependent=True jointContactGate=PENDING");
		}
		catch (Exception error)
		{
			unavailable = true;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Plugin.Failure("CHAOS_TAYLOR_FIT_UNAVAILABLE nativeCustomVisualPreserved=True", error);
		}
	}

	private static FieldInfo RequireField(Type type, string name, Type expected)
	{
		FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field == null || field.FieldType != expected)
		{
			throw new InvalidOperationException("Optional Taylor field contract differs " + name);
		}
		return field;
	}

	private static MethodInfo RequireMethod(Type type, string name)
	{
		MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
		if (method == null || method.ReturnType != typeof(void) || method.IsStatic)
		{
			throw new InvalidOperationException("Optional Taylor method contract differs " + name);
		}
		return method;
	}

	private static Vector3 Center(Dictionary<string, Transform> bones, string side, Vector3 origin)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_008b: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.zero;
		string[] array = new string[5] { "Thumb2", "Index2", "Middle2", "Ring2", "Pinky2" };
		foreach (string text in array)
		{
			if (!bones.TryGetValue(side + "Hand" + text, out var value) || !Object.op_Implicit((Object)(object)value))
			{
				throw new InvalidOperationException("Optional fitted finger reference absent");
			}
			val += value.position - origin;
		}
		return val / 5f;
	}

	public static bool MatchesItem(string itemId)
	{
		return JesterProgression.Matches(itemId);
	}

	public static void AfterRestore(object __instance)
	{
		try
		{
			if (states.TryGetValue(__instance, out var value) && value.Lease != null)
			{
				value.Lease.Restore();
			}
		}
		catch (Exception error)
		{
			Report(error);
		}
	}

	public static void AfterClear(object __instance)
	{
		try
		{
			if (states.TryGetValue(__instance, out var value))
			{
				states.Remove(__instance);
				if (value.Lease != null)
				{
					value.Lease.Clear();
				}
			}
		}
		catch (Exception error)
		{
			Report(error);
		}
	}

	private static void Report(Exception error)
	{
		if (logged.Add(error.Message))
		{
			Plugin.Failure("CHAOS_TAYLOR_FIT_UNAVAILABLE nativeCustomVisualPreserved=True acceptedTaylorPreserved=True", error);
		}
	}

	public static void AfterTick(object __instance)
	{
		//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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01ed: 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_01fd: 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_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			AfterRestore(__instance);
			object? value = player.GetValue(__instance);
			Player val = (Player)((value is Player) ? value : null);
			object? value2 = equipment.GetValue(__instance);
			VisEquipment val2 = (VisEquipment)((value2 is VisEquipment) ? value2 : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				return;
			}
			object? obj = RightItem.Invoke(val, null);
			ItemData val3 = (ItemData)((obj is ItemData) ? obj : null);
			if (val3 == null || !Object.op_Implicit((Object)(object)val3.m_dropPrefab) || !MatchesItem(((Object)val3.m_dropPrefab).name))
			{
				AfterClear(__instance);
				return;
			}
			object? value3 = Right.GetValue(val2);
			GameObject val4 = (GameObject)((value3 is GameObject) ? value3 : null);
			if (!Object.op_Implicit((Object)(object)val4) || !val4.activeInHierarchy)
			{
				AfterClear(__instance);
				return;
			}
			Vector3 val5 = val4.transform.lossyScale - Vector3.one;
			if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f)
			{
				throw new InvalidOperationException("Jester attachment unit scale differs");
			}
			if (!states.TryGetValue(__instance, out var value4))
			{
				value4 = new State();
				states.Add(__instance, value4);
			}
			if ((Object)(object)value4.Root != (Object)(object)val4 || value4.Lease == null)
			{
				if (value4.Lease != null)
				{
					value4.Lease.Clear();
				}
				value4.Lease = null;
				value4.Root = val4;
				value4.Lease = new JesterVisualLease(val4, contract);
			}
			Dictionary<string, Transform> dictionary = native.GetValue(__instance) as Dictionary<string, Transform>;
			Dictionary<string, Transform> dictionary2 = fitted.GetValue(__instance) as Dictionary<string, Transform>;
			if (dictionary == null || dictionary2 == null || dictionary.Count != 53 || dictionary2.Count != 53)
			{
				throw new InvalidOperationException("Optional Taylor Native53 dictionaries differ");
			}
			if (!dictionary2.TryGetValue("Hips", out var value5) || !Object.op_Implicit((Object)(object)value5) || !((Component)value5).gameObject.activeInHierarchy)
			{
				throw new InvalidOperationException("Fitted Taylor hierarchy inactive; ordinary Jester visual retained");
			}
			Vector3 position = val4.transform.position;
			Vector3 val6 = Center(dictionary, "Right", position);
			Vector3 val7 = Center(dictionary2, "Right", position);
			Vector3 nativeLeft = Center(dictionary, "Left", position);
			Vector3 fittedLeft = Center(dictionary2, "Left", position);
			float weight;
			float tilt;
			Quaternion delta = JesterGripMath.Calculate(profile, val4.transform.localToWorldMatrix, val6, val7, nativeLeft, fittedLeft, out weight, out tilt);
			value4.Lease.Apply(position, val6, val7, delta);
			if (logged.Add("active"))
			{
				Plugin.Info("CHAOS_TAYLOR_FIT active=True itemOnly=NH_ChaosBattleaxe socketsCollidersUnchanged=True clonedEffectsFollow=True surfaceContactAndEffectShapeGate=PENDING");
			}
		}
		catch (Exception error)
		{
			AfterRestore(__instance);
			Report(error);
		}
	}

	public static void Shutdown()
	{
		foreach (State value in states.Values)
		{
			try
			{
				if (value.Lease != null)
				{
					value.Lease.Clear();
				}
			}
			catch (Exception error)
			{
				Report(error);
			}
		}
		states.Clear();
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		harmony = null;
		patched = false;
	}
}