Decompiled source of ClairenMercenary v1.0.1

ClairenMercenary.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using MonoMod.RuntimeDetour;
using MonoMod.RuntimeDetour.HookGen;
using RoR2;
using RuneFoxMods.DynamicSkins;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RuneFoxMods
{
	internal class Utils
	{
		public static void PrintBodyCatalog()
		{
			Debug.Log((object)"\nBodyCatalog");
			foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
			{
				Debug.Log((object)((Object)allBodyPrefab).name);
			}
			Debug.Log((object)"\n");
		}

		public static void ReadChildren(GameObject parent, int tabs, bool includecomponents = true)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			for (int i = 0; i < tabs; i++)
			{
				text += "  ";
			}
			for (int j = 0; j < parent.transform.childCount; j++)
			{
				Transform child = parent.transform.GetChild(j);
				if ((Object)(object)child == (Object)null)
				{
					break;
				}
				string text2 = ((Component)child).gameObject.activeInHierarchy.ToString();
				Debug.Log((object)(text + ((Object)child).name + " " + text2 + " " + ((Component)child).transform.position));
				if (includecomponents)
				{
					ReadComponents(((Component)child).gameObject, tabs + 1);
					Debug.Log((object)"");
				}
				ReadChildren(((Component)child).gameObject, tabs + 1, includecomponents);
			}
		}

		public static void readheiarchy(GameObject parent, bool includeComponents = true)
		{
			Debug.Log((object)((Object)parent).name);
			if (includeComponents)
			{
				ReadComponents(parent, 1);
				Debug.Log((object)"");
			}
			ReadChildren(parent, 1, includeComponents);
		}

		public static void ReadComponents(GameObject obj, int tabs)
		{
			string text = "";
			for (int i = 0; i < tabs; i++)
			{
				text += "  ";
			}
			Component[] components = obj.GetComponents(typeof(Component));
			Component[] array = components;
			foreach (Component val in array)
			{
				string text2 = "";
				Debug.Log((object)(text + "Comp: " + ((object)val).GetType().ToString() + "  " + text2));
			}
		}

		public static void PrintAllPaths(GameObject parent)
		{
			Debug.Log((object)((Object)parent).name);
			PrintAllPathsInner(parent, ((Object)parent).name);
		}

		private static void PrintAllPathsInner(GameObject parent, string parent_string)
		{
			int childCount = parent.transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				Transform child = parent.transform.GetChild(i);
				if (((Object)child).name.EndsWith("_end"))
				{
					break;
				}
				string text = parent_string + "/" + ((Object)child).name;
				Debug.Log((object)("  " + ((Object)child).name + "\t\t" + text));
				PrintAllPathsInner(((Component)child).gameObject, text);
			}
		}

		public static void PrintDynamicBone(DynamicBone DB)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Root: " + DB.m_Root));
			Debug.Log((object)("Damping: " + DB.m_Damping));
			Debug.Log((object)("Damping Dist: " + DB.m_DampingDistrib));
			Debug.Log((object)("Elasticity: " + DB.m_Elasticity));
			Debug.Log((object)("Elasticity Dist: " + DB.m_ElasticityDistrib));
			Debug.Log((object)("Stiffness: " + DB.m_Stiffness));
			Debug.Log((object)("Stiffness Dist: " + DB.m_StiffnessDistrib));
			Debug.Log((object)("Inert: " + DB.m_Inert));
			Debug.Log((object)("Inert Dist: " + DB.m_InertDistrib));
			Debug.Log((object)("Radius: " + DB.m_Radius));
			Debug.Log((object)("Radius Dist: " + DB.m_RadiusDistrib));
			Debug.Log((object)("End Length: " + DB.m_EndLength));
			Debug.Log((object)("End Offset: " + DB.m_EndOffset));
			Debug.Log((object)("Gravity: " + DB.m_Gravity));
			Debug.Log((object)("Force: " + DB.m_Force));
			Debug.Log((object)("FreezeAxis: " + DB.m_FreezeAxis));
			Debug.Log((object)("Colliders: " + DB.m_Colliders.Count));
			foreach (DynamicBoneCollider collider in DB.m_Colliders)
			{
				Debug.Log((object)("\t Parent: " + ((Object)((Component)collider).transform).name));
				Debug.Log((object)("\t Direction: " + collider.m_Direction));
				Debug.Log((object)("\t Center " + collider.m_Center));
				Debug.Log((object)("\t Bound " + collider.m_Bound));
				Debug.Log((object)("\t Radius " + collider.m_Radius));
				Debug.Log((object)("\t Height " + collider.m_Height));
			}
			Debug.Log((object)("Exclusions: " + DB.m_Exclusions.Count));
			foreach (Transform exclusion in DB.m_Exclusions)
			{
				Debug.Log((object)("\t Transform: " + ((Object)exclusion).name));
			}
		}

		public static ChildLocator GetChildLocator(GameObject body)
		{
			ChildLocator val = null;
			Transform child = body.transform.GetChild(0);
			if (Object.op_Implicit((Object)(object)child))
			{
				Transform child2 = child.GetChild(0);
				if (Object.op_Implicit((Object)(object)child2))
				{
					val = ((Component)child2).GetComponent<ChildLocator>();
					if (Object.op_Implicit((Object)(object)val))
					{
						Debug.Log((object)"Locator Found");
					}
				}
			}
			return val;
		}

		public static Transform FindChildInTree(Transform Root, string name)
		{
			Queue<Transform> queue = new Queue<Transform>();
			queue.Enqueue(Root);
			while (queue.Count != 0)
			{
				Transform val = queue.Dequeue();
				if (((Object)val).name == name)
				{
					return val;
				}
				for (int i = 0; i < val.childCount; i++)
				{
					Transform child = val.GetChild(i);
					queue.Enqueue(child);
				}
			}
			return null;
		}

		public static string RemoveCloneNaming(string str)
		{
			return str.Remove(str.Length - 7);
		}
	}
}
namespace RuneFoxMods.DynamicSkins
{
	public static class DynamicSkinHelpers
	{
		public static SkinnedMeshRenderer[] GetBaseSkinRenderers(GameObject modelObject)
		{
			SkinnedMeshRenderer[] componentsInChildren = modelObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				if ((Object)(object)((Component)val).transform.parent == (Object)(object)modelObject.transform)
				{
					list.Add(val);
				}
			}
			return list.ToArray();
		}

		public static Transform[] BoneArrayBuilder(Transform NewBoneRoot)
		{
			List<Transform> list = new List<Transform>();
			BoneArrayBuilderHelper(NewBoneRoot, list);
			return list.ToArray();
		}

		public static void BoneArrayBuilderHelper(Transform parent, List<Transform> list)
		{
			if (!((Object)parent).name.EndsWith("_end"))
			{
				list.Add(parent);
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				BoneArrayBuilderHelper(parent.GetChild(i), list);
			}
		}

		public static Transform GetArmature(GameObject obj)
		{
			return GetArmatureHelper(obj);
		}

		public static Transform GetArmatureHelper(GameObject obj)
		{
			if (((Object)obj).name.ToLower().Contains("armature"))
			{
				return obj.transform;
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform armatureHelper = GetArmatureHelper(((Component)obj.transform.GetChild(i)).gameObject);
				if (Object.op_Implicit((Object)(object)armatureHelper))
				{
					return armatureHelper;
				}
			}
			return null;
		}

		public static Transform GetTopParent(Transform obj)
		{
			Transform val = obj;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
			}
			return val;
		}

		public static string GetPrevBoneInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length - 1; i++)
			{
				if (((Object)bones[i + 1]).name == ((Object)targetBone).name)
				{
					return ((Object)bones[i]).name;
				}
			}
			return null;
		}

		public static int GetBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length; i++)
			{
				if (((Object)bones[i]).name == ((Object)targetBone).name)
				{
					return i;
				}
			}
			return -1;
		}

		public static int GetPrevBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer)
		{
			Transform[] bones = meshRenderer.bones;
			for (int i = 0; i <= bones.Length - 1; i++)
			{
				if (((Object)bones[i + 1]).name == ((Object)targetBone).name)
				{
					return i;
				}
			}
			return -1;
		}
	}
	internal class DynamicSkinManager
	{
		internal Dictionary<string, SkinDef> SkinDefs = new Dictionary<string, SkinDef>();

		private GameObject LastModelObject;

		internal Dictionary<string, SortedList<int, Modification>> ModificationList = new Dictionary<string, SortedList<int, Modification>>();

		private Dictionary<GameObject, AppliedModifications> ModifiedObjects = new Dictionary<GameObject, AppliedModifications>();

		internal ManualLogSource InstanceLogger;

		internal void AddModification(string skinNameToken, int boneIndex, Modification modification)
		{
			if (!ModificationList.TryGetValue(skinNameToken, out var value))
			{
				value = new SortedList<int, Modification>();
				ModificationList.Add(skinNameToken, value);
			}
			value.Add(boneIndex, modification);
		}

		internal void AddSkinDef(SkinDef skinDef)
		{
			SkinDefs.Add(skinDef.nameToken, skinDef);
		}

		internal void SkinDefApply(Action<SkinDef, GameObject> orig, SkinDef self, GameObject modelObject)
		{
			orig(self, modelObject);
			RemoveInvalidModelObjects();
			ModifiedObjects.TryGetValue(modelObject, out var value);
			try
			{
				if (!SkinDefs.TryGetValue(self.nameToken, out var _))
				{
					if (value != null)
					{
						ClearSkinModifications(LastModelObject, value);
					}
				}
				else if (value == null)
				{
					AppliedModifications appliedModifications = new AppliedModifications();
					ModifiedObjects.Add(modelObject, appliedModifications);
					ApplySkinModifications(self, modelObject, appliedModifications);
				}
			}
			catch (Exception ex)
			{
				InstanceLogger.LogWarning((object)"An error occured while adding accessories to a skin");
				InstanceLogger.LogError((object)ex);
			}
		}

		private void RemoveInvalidModelObjects()
		{
			foreach (GameObject item in ModifiedObjects.Keys.Where((GameObject el) => !Object.op_Implicit((Object)(object)el)).ToList())
			{
				ModifiedObjects.Remove(item);
			}
		}

		private void ClearSkinModifications(GameObject modelObject, AppliedModifications modifications)
		{
			while (modifications.BaseModelModifications.Count != 0)
			{
				Modification modification = modifications.BaseModelModifications.Pop();
				clearModification(modification, modelObject, modifications);
			}
			while (modifications.OtherModifications.Count != 0)
			{
				clearModification(modifications.OtherModifications[0], modelObject, modifications);
			}
			ModifiedObjects.Remove(modelObject);
		}

		private void ApplySkinModifications(SkinDef skindef, GameObject modelObject, AppliedModifications modifications)
		{
			CharacterModel component = modelObject.GetComponent<CharacterModel>();
			LastModelObject = modelObject;
			if (!ModificationList.TryGetValue(skindef.nameToken, out var value))
			{
				return;
			}
			foreach (KeyValuePair<int, Modification> item in value)
			{
				ApplyModification(modelObject, component, item.Value, modifications);
			}
		}

		private static void ApplyModification(GameObject modelObject, CharacterModel characterModel, Modification modification, AppliedModifications modifications)
		{
			string bodyname = modification.bodyname;
			string parentname = modification.parentname;
			Transform val = Utils.FindChildInTree(modelObject.transform, parentname);
			GameObject val2;
			if (modification.affectsbasemodel)
			{
				val2 = Object.Instantiate<GameObject>(modification.prefab, val, false);
				((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name);
				modification.instance = val2;
				modification.inst_armature = val2;
				ModificationApplyBones(modelObject, modification, modifications);
			}
			else
			{
				val2 = Object.Instantiate<GameObject>(modification.prefab, modelObject.transform, false);
				((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name);
				modification.instance = val2;
				Transform armature = DynamicSkinHelpers.GetArmature(val2);
				((Component)armature).transform.SetParent(val, false);
				modification.inst_armature = ((Component)armature).gameObject;
			}
			modification.instance = val2;
			if (modification.dynamicBoneData != null)
			{
				ModificationApplyDynamicBones(modelObject, modification);
			}
			ModificationAddRenderers(val2, characterModel);
			modifications.OtherModifications.Add(modification);
		}

		private static void ModificationApplyBones(GameObject modelObject, Modification modification, AppliedModifications modifications)
		{
			SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject);
			List<Transform> list = baseSkinRenderers[0].bones.ToList();
			Transform[] array = DynamicSkinHelpers.BoneArrayBuilder(modification.instance.transform);
			list.InsertRange(modification.boneIndex, array);
			modification.boneCount = array.Length;
			SkinnedMeshRenderer[] array2 = baseSkinRenderers;
			foreach (SkinnedMeshRenderer val in array2)
			{
				val.bones = list.ToArray();
			}
			modifications.BaseModelModifications.Push(modification);
		}

		private static void ModificationApplyDynamicBones(GameObject modelObject, Modification modification)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			DynamicBone val = (modification.inst_dynamicBone = modification.instance.AddComponent<DynamicBone>());
			List<DynamicBoneCollider> list = new List<DynamicBoneCollider>();
			foreach (DynamicBoneColliderData collider in modification.dynamicBoneData.m_Colliders)
			{
				Transform val2 = Utils.FindChildInTree(modelObject.transform, collider.m_parent_name);
				DynamicBoneCollider val3 = ((Component)val2).gameObject.AddComponent<DynamicBoneCollider>();
				val3.m_Direction = collider.m_Direction;
				val3.m_Center = collider.m_Center;
				val3.m_Bound = collider.m_Bound;
				val3.m_Radius = collider.m_Radius;
				val3.m_Height = collider.m_Height;
				list.Add(val3);
			}
			modification.inst_DB_colliders = list;
			Transform root = (val.m_Root = Utils.FindChildInTree(modification.inst_armature.transform, modification.dynamicBoneData.m_Root));
			val.m_Damping = modification.dynamicBoneData.m_Damping;
			val.m_DampingDistrib = modification.dynamicBoneData.m_DampingDistrib;
			val.m_Elasticity = modification.dynamicBoneData.m_Elasticity;
			val.m_ElasticityDistrib = modification.dynamicBoneData.m_ElasticityDistrib;
			val.m_Stiffness = modification.dynamicBoneData.m_Stiffness;
			val.m_StiffnessDistrib = modification.dynamicBoneData.m_StiffnessDistrib;
			val.m_Inert = modification.dynamicBoneData.m_Inert;
			val.m_InertDistrib = modification.dynamicBoneData.m_InertDistrib;
			val.m_Radius = modification.dynamicBoneData.m_Radius;
			val.m_RadiusDistrib = modification.dynamicBoneData.m_RadiusDistrib;
			val.m_EndLength = modification.dynamicBoneData.m_EndLength;
			val.m_EndOffset = modification.dynamicBoneData.m_EndOffset;
			val.m_Gravity = modification.dynamicBoneData.m_Gravity;
			val.m_Force = modification.dynamicBoneData.m_Force;
			val.m_Colliders = list;
			val.m_Exclusions = new List<Transform>();
			foreach (string exclusion in modification.dynamicBoneData.m_Exclusions)
			{
				Transform val4 = Utils.FindChildInTree(root, exclusion);
				if ((Object)(object)val4 != (Object)null)
				{
					val.m_Exclusions.Add(val4);
				}
				else
				{
					Debug.LogWarning((object)"Tried to exclude a transform that could not be found");
				}
			}
			val.m_FreezeAxis = modification.dynamicBoneData.m_FreezeAxis;
		}

		private static void ModificationAddRenderers(GameObject newPart, CharacterModel characterModel)
		{
			//IL_0050: 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_0082: 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)
			SkinnedMeshRenderer[] componentsInChildren = newPart.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			Array.Resize(ref characterModel.baseRendererInfos, characterModel.baseRendererInfos.Length + componentsInChildren.Length);
			if (componentsInChildren.Length != 0)
			{
				int num = componentsInChildren.Length;
				SkinnedMeshRenderer[] array = componentsInChildren;
				foreach (SkinnedMeshRenderer val in array)
				{
					characterModel.baseRendererInfos[characterModel.baseRendererInfos.Length - num] = new RendererInfo
					{
						renderer = (Renderer)(object)componentsInChildren[^num],
						ignoreOverlays = false,
						defaultShadowCastingMode = (ShadowCastingMode)1,
						defaultMaterial = ((Renderer)val).sharedMaterial
					};
					num--;
				}
			}
		}

		private void clearModification(Modification modification, GameObject modelObject, AppliedModifications modifications)
		{
			if (modification.inst_DB_colliders != null)
			{
				foreach (DynamicBoneCollider inst_DB_collider in modification.inst_DB_colliders)
				{
					Object.Destroy((Object)(object)inst_DB_collider);
				}
			}
			if (modification.affectsbasemodel)
			{
				SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject);
				List<Transform> list = baseSkinRenderers[0].bones.ToList();
				list.RemoveRange(modification.boneIndex, modification.boneCount);
				SkinnedMeshRenderer[] array = baseSkinRenderers;
				foreach (SkinnedMeshRenderer val in array)
				{
					val.bones = list.ToArray();
				}
			}
			Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_dynamicBone);
			Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_armature);
			Object.Destroy((Object)(object)modifications.OtherModifications[0].instance);
			if (!modifications.OtherModifications.Remove(modification))
			{
				InstanceLogger.LogError((object)"Skin Modification was not removed");
			}
		}
	}
	internal class Modification
	{
		public string prefabpath;

		public string bodyname;

		public string parentname;

		public GameObject prefab;

		public bool affectsbasemodel;

		public DynamicBoneData dynamicBoneData;

		public string parentSkinToken;

		public int boneIndex;

		public int boneCount;

		public GameObject instance;

		public GameObject inst_armature;

		public DynamicBone inst_dynamicBone;

		public List<DynamicBoneCollider> inst_DB_colliders = new List<DynamicBoneCollider>();

		public Modification(string PrefabPath, string ParentName, string BodyName, string ParentSkinToken, int BoneIndex, bool AffectsBaseModel, AssetBundle assetBundle)
		{
			bodyname = BodyName;
			prefabpath = PrefabPath;
			parentname = ParentName;
			parentSkinToken = ParentSkinToken;
			affectsbasemodel = AffectsBaseModel;
			boneIndex = BoneIndex;
			prefab = assetBundle.LoadAsset<GameObject>(prefabpath);
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)("Asset at " + PrefabPath + " was not loaded"));
			}
		}
	}
	internal class AppliedModifications
	{
		public Stack<Modification> BaseModelModifications = new Stack<Modification>();

		public List<Modification> OtherModifications = new List<Modification>();
	}
	internal class DynamicBoneData
	{
		public string m_Root;

		public float m_Damping;

		public AnimationCurve m_DampingDistrib;

		public float m_Elasticity;

		public AnimationCurve m_ElasticityDistrib;

		public float m_Stiffness;

		public AnimationCurve m_StiffnessDistrib;

		public float m_Inert;

		public AnimationCurve m_InertDistrib;

		public float m_Radius;

		public AnimationCurve m_RadiusDistrib;

		public float m_EndLength;

		public Vector3 m_EndOffset;

		public Vector3 m_Gravity;

		public Vector3 m_Force;

		public List<DynamicBoneColliderData> m_Colliders;

		public List<string> m_Exclusions;

		public FreezeAxis m_FreezeAxis;

		public DynamicBoneData(string root, float damping, AnimationCurve damping_dist, float elasticity, AnimationCurve elasticity_dist, float stiffness, AnimationCurve stiffness_dist, float inert, AnimationCurve inert_dist, float radius, AnimationCurve radius_dist, float end_length, Vector3 end_offset, Vector3 gravity, Vector3 force, List<DynamicBoneColliderData> colliders, List<string> exclusions, FreezeAxis freeze_axis)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			m_Root = root;
			m_Damping = damping;
			m_DampingDistrib = damping_dist;
			m_Elasticity = elasticity;
			m_ElasticityDistrib = elasticity_dist;
			m_Stiffness = stiffness;
			m_StiffnessDistrib = stiffness_dist;
			m_Inert = inert;
			m_InertDistrib = inert_dist;
			m_Radius = radius;
			m_RadiusDistrib = radius_dist;
			m_EndLength = end_length;
			m_EndOffset = end_offset;
			m_Gravity = gravity;
			m_Force = force;
			m_Colliders = colliders;
			m_Exclusions = exclusions;
			m_FreezeAxis = freeze_axis;
		}
	}
	internal class DynamicBoneColliderData
	{
		public string m_parent_name;

		public Direction m_Direction;

		public Vector3 m_Center;

		public Bound m_Bound;

		public float m_Radius;

		public float m_Height;

		public DynamicBoneColliderData(string parent_name, Direction direction, Vector3 Center, Bound bound, float radius, float heaight)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			m_parent_name = parent_name;
			m_Direction = direction;
			m_Center = Center;
			m_Bound = bound;
			m_Radius = radius;
			m_Height = heaight;
		}
	}
}
namespace ClairenMercenary
{
	[BepInPlugin("com.AntlerShed.ClairenMercenary", "ClairenMercenary", "1.0.1")]
	public class ClairenMercenaryPlugin : BaseUnityPlugin
	{
		public class DynamicSkinExtension
		{
			private Modification ClairenRivalSwordFlamePrefabModification;

			private Modification ClairenRivalbase_dynamic_capeModification;

			private Modification ClairenRivalbase_dynamic_cape1Modification;

			private Modification ClairenRivalbase_dynamic_cape3Modification;

			private Modification ClairenRivalbase_dynamic_hairModification;

			private Modification ClairenRivalbase_dynamic_hair1Modification;

			private Modification ClairenRivalbase_dynamic_hair2Modification;

			private Modification ClairenRivalbase_dynamic_hair3Modification;

			private Modification ClairenRivalbase_jacketModification;

			private Modification ClairenRivaljacket_lModification;

			private Modification ClairenRivaljacket_rModification;

			private Modification ClairenRivalbase_dynamic_tailModification;

			private Modification ClairenRivalFakeFacePrefabModification;

			private Modification ClairenLoverFacePrefabModification;

			private Modification ClairenLoverbase_dynamic_hairModification;

			private Modification ClairenLoverbase_dynamic_hair1Modification;

			private Modification ClairenLoverbase_dynamic_hair2Modification;

			private Modification ClairenLoverbase_dynamic_hair3Modification;

			private Modification ClairenLoverbase_dynamic_tailModification;

			private Modification ClairenLoverbase_jacketModification;

			private Modification ClairenLoverjacket_lModification;

			private Modification ClairenLoverjacket_rModification;

			private Modification ClairenLoverbase_dynamic_capeModification;

			private Modification ClairenLoverbase_dynamic_cape1Modification;

			private Modification ClairenLoverbase_dynamic_cape3Modification;

			private Modification ClairenRebelRebelFacePrefabModification;

			private Modification ClairenRebelbase_dynamic_hairModification;

			private Modification ClairenRebelbase_dynamic_hair1Modification;

			private Modification ClairenRebelbase_dynamic_hair2Modification;

			private Modification ClairenRebelbase_dynamic_hair3Modification;

			private Modification ClairenRebelbase_dynamic_tailModification;

			private Modification ClairenRebelbase_jacketModification;

			private Modification ClairenRebeljacket_lModification;

			private Modification ClairenRebeljacket_rModification;

			private Modification ClairenRebelbase_dynamic_capeModification;

			private Modification ClairenRebelbase_dynamic_cape1Modification;

			private Modification ClairenRebelbase_dynamic_cape3Modification;

			private Modification ClairenRebelSwordFlamePrefabModification;

			internal void BeforeStart()
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				_DynamicSkinManager.InstanceLogger = ((BaseUnityPlugin)Instance).Logger;
				new Hook((MethodBase)typeof(SkinDef).GetMethod("Apply"), (Delegate)new Action<Action<SkinDef, GameObject>, SkinDef, GameObject>(_DynamicSkinManager.SkinDefApply)).Apply();
			}

			internal void AfterStart()
			{
				InitializeModifications();
				InitializeDynamicBones();
				AddModificationsToList();
			}

			internal void BeforeBodyCatalogInit()
			{
				MercBodyClairenRivalSkinAddedEvent += onSkinAdded;
				MercBodyClairenLoverSkinAddedEvent += onSkinAdded;
				MercBodyClairenRebelSkinAddedEvent += onSkinAdded;
			}

			internal void AfterBodyCatalogInit()
			{
			}

			private void InitializeModifications()
			{
				ClairenRivalSwordFlamePrefabModification = new Modification("SwordFlamePrefab.prefab", "SwordBase", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", -1, AffectsBaseModel: false, assetBundle);
				ClairenRivalbase_dynamic_capeModification = new Modification("base_dynamic_cape.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 66, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_cape1Modification = new Modification("base_dynamic_cape1.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 78, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_cape3Modification = new Modification("base_dynamic_cape3.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 28, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_hairModification = new Modification("base_dynamic_hair.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 37, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_hair1Modification = new Modification("base_dynamic_hair1.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 34, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_hair2Modification = new Modification("base_dynamic_hair2.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 40, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_hair3Modification = new Modification("base_dynamic_hair3.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 36, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_jacketModification = new Modification("base_jacket.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 81, AffectsBaseModel: true, assetBundle);
				ClairenRivaljacket_lModification = new Modification("jacket_l.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 83, AffectsBaseModel: true, assetBundle);
				ClairenRivaljacket_rModification = new Modification("jacket_r.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 82, AffectsBaseModel: true, assetBundle);
				ClairenRivalbase_dynamic_tailModification = new Modification("base_dynamic_tail.prefab", "pelvis", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 93, AffectsBaseModel: true, assetBundle);
				ClairenRivalFakeFacePrefabModification = new Modification("FakeFacePrefab.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", -2, AffectsBaseModel: false, assetBundle);
				ClairenLoverFacePrefabModification = new Modification("FacePrefab.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", -1, AffectsBaseModel: false, assetBundle);
				ClairenLoverbase_dynamic_hairModification = new Modification("base_dynamic_hair.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 37, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_hair1Modification = new Modification("base_dynamic_hair1.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 34, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_hair2Modification = new Modification("base_dynamic_hair2.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 40, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_hair3Modification = new Modification("base_dynamic_hair3.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 36, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_tailModification = new Modification("base_dynamic_tail.prefab", "pelvis", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 93, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_jacketModification = new Modification("base_jacket.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 78, AffectsBaseModel: true, assetBundle);
				ClairenLoverjacket_lModification = new Modification("jacket_l.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 80, AffectsBaseModel: true, assetBundle);
				ClairenLoverjacket_rModification = new Modification("jacket_r.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 79, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_capeModification = new Modification("base_dynamic_cape.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 66, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_cape1Modification = new Modification("base_dynamic_cape1.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 81, AffectsBaseModel: true, assetBundle);
				ClairenLoverbase_dynamic_cape3Modification = new Modification("base_dynamic_cape3.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 28, AffectsBaseModel: true, assetBundle);
				ClairenRebelRebelFacePrefabModification = new Modification("RebelFacePrefab.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", -1, AffectsBaseModel: false, assetBundle);
				ClairenRebelbase_dynamic_hairModification = new Modification("base_dynamic_hair.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 37, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_hair1Modification = new Modification("base_dynamic_hair1.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 34, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_hair2Modification = new Modification("base_dynamic_hair2.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 40, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_hair3Modification = new Modification("base_dynamic_hair3.prefab", "head", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 36, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_tailModification = new Modification("base_dynamic_tail.prefab", "pelvis", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 93, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_jacketModification = new Modification("base_jacket.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 81, AffectsBaseModel: true, assetBundle);
				ClairenRebeljacket_lModification = new Modification("jacket_l.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 83, AffectsBaseModel: true, assetBundle);
				ClairenRebeljacket_rModification = new Modification("jacket_r.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 82, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_capeModification = new Modification("base_dynamic_cape.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 66, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_cape1Modification = new Modification("base_dynamic_cape1.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 78, AffectsBaseModel: true, assetBundle);
				ClairenRebelbase_dynamic_cape3Modification = new Modification("base_dynamic_cape3.prefab", "chest", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 28, AffectsBaseModel: true, assetBundle);
				ClairenRebelSwordFlamePrefabModification = new Modification("SwordFlamePrefab.prefab", "SwordBase", "MercBody", "ANTLERSHED_SKIN_CLAIRENREBEL_NAME", -2, AffectsBaseModel: false, assetBundle);
			}

			private void InitializeDynamicBones()
			{
				//IL_003e: 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_0066: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0338: Unknown result type (might be due to invalid IL or missing references)
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0360: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_03df: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_044a: Unknown result type (might be due to invalid IL or missing references)
				//IL_045e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0534: Unknown result type (might be due to invalid IL or missing references)
				//IL_0548: Unknown result type (might be due to invalid IL or missing references)
				//IL_055c: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0632: Unknown result type (might be due to invalid IL or missing references)
				//IL_0646: Unknown result type (might be due to invalid IL or missing references)
				//IL_065a: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0730: Unknown result type (might be due to invalid IL or missing references)
				//IL_0744: Unknown result type (might be due to invalid IL or missing references)
				//IL_0758: Unknown result type (might be due to invalid IL or missing references)
				//IL_07af: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_082e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0842: Unknown result type (might be due to invalid IL or missing references)
				//IL_0856: Unknown result type (might be due to invalid IL or missing references)
				//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_092c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0940: Unknown result type (might be due to invalid IL or missing references)
				//IL_0954: Unknown result type (might be due to invalid IL or missing references)
				//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a2a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
				//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0abd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ad1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b3c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b50: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ba7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0bbb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c26: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c3a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c4e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ca5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0cb9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ccd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0d24: Unknown result type (might be due to invalid IL or missing references)
				//IL_0d38: Unknown result type (might be due to invalid IL or missing references)
				//IL_0d4c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0da3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0db7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0e22: Unknown result type (might be due to invalid IL or missing references)
				//IL_0e36: Unknown result type (might be due to invalid IL or missing references)
				//IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ea1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0eb5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ec9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0f20: Unknown result type (might be due to invalid IL or missing references)
				//IL_0f34: Unknown result type (might be due to invalid IL or missing references)
				//IL_0f48: Unknown result type (might be due to invalid IL or missing references)
				//IL_0f9f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0fb3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0fc7: Unknown result type (might be due to invalid IL or missing references)
				//IL_101e: Unknown result type (might be due to invalid IL or missing references)
				//IL_1032: Unknown result type (might be due to invalid IL or missing references)
				//IL_1046: Unknown result type (might be due to invalid IL or missing references)
				//IL_109d: Unknown result type (might be due to invalid IL or missing references)
				//IL_10b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_10c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_111c: Unknown result type (might be due to invalid IL or missing references)
				//IL_1130: Unknown result type (might be due to invalid IL or missing references)
				//IL_1144: Unknown result type (might be due to invalid IL or missing references)
				//IL_119b: Unknown result type (might be due to invalid IL or missing references)
				//IL_11af: Unknown result type (might be due to invalid IL or missing references)
				//IL_11c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_121a: Unknown result type (might be due to invalid IL or missing references)
				//IL_122e: Unknown result type (might be due to invalid IL or missing references)
				//IL_1242: Unknown result type (might be due to invalid IL or missing references)
				//IL_1299: Unknown result type (might be due to invalid IL or missing references)
				//IL_12ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_12c1: Unknown result type (might be due to invalid IL or missing references)
				ClairenRivalSwordFlamePrefabModification.dynamicBoneData = new DynamicBoneData("SwordFlamePrefab", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_capeModification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_cape1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape1", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_cape3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape3", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_hairModification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair", 0.232f, null, 0.133f, null, 0.775f, null, 0.343f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_hair1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair1", 0.509f, null, 0.135f, null, 0.628f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_hair2Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair2", 0.535f, null, 0.091f, null, 0.691f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_dynamic_hair3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair3", 0.478f, null, 0.116f, null, 0.693f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalbase_jacketModification.dynamicBoneData = new DynamicBoneData("base_jacket", 0.559f, null, 0.149f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivaljacket_lModification.dynamicBoneData = new DynamicBoneData("jacket_l", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenRivaljacket_rModification.dynamicBoneData = new DynamicBoneData("jacket_r", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenRivalbase_dynamic_tailModification.dynamicBoneData = new DynamicBoneData("base_dynamic_tail", 0.505f, null, 0.041f, null, 0.514f, null, 0f, null, 0.1f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRivalFakeFacePrefabModification.dynamicBoneData = new DynamicBoneData("FakeFacePrefab", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverFacePrefabModification.dynamicBoneData = new DynamicBoneData("FacePrefab", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_hairModification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair", 0.232f, null, 0.133f, null, 0.775f, null, 0.343f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_hair1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair1", 0.509f, null, 0.135f, null, 0.628f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_hair2Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair2", 0.535f, null, 0.091f, null, 0.691f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_hair3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair3", 0.478f, null, 0.116f, null, 0.693f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_tailModification.dynamicBoneData = new DynamicBoneData("base_dynamic_tail", 0.505f, null, 0.041f, null, 0.514f, null, 0f, null, 0.1f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_jacketModification.dynamicBoneData = new DynamicBoneData("base_jacket", 0.559f, null, 0.149f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverjacket_lModification.dynamicBoneData = new DynamicBoneData("jacket_l", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenLoverjacket_rModification.dynamicBoneData = new DynamicBoneData("jacket_r", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenLoverbase_dynamic_capeModification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_cape1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape1", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenLoverbase_dynamic_cape3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape3", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelRebelFacePrefabModification.dynamicBoneData = new DynamicBoneData("RebelFacePrefab", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_hairModification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair", 0.232f, null, 0.133f, null, 0.775f, null, 0.343f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_hair1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair1", 0.509f, null, 0.135f, null, 0.628f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_hair2Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair2", 0.535f, null, 0.091f, null, 0.691f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_hair3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_hair3", 0.478f, null, 0.116f, null, 0.693f, null, 0f, null, 0.08f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_tailModification.dynamicBoneData = new DynamicBoneData("base_dynamic_tail", 0.505f, null, 0.041f, null, 0.514f, null, 0f, null, 0.1f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_jacketModification.dynamicBoneData = new DynamicBoneData("base_jacket", 0.559f, null, 0.149f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebeljacket_lModification.dynamicBoneData = new DynamicBoneData("jacket_l", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenRebeljacket_rModification.dynamicBoneData = new DynamicBoneData("jacket_r", 0.446f, null, 0.15f, null, 0.7f, null, 0f, null, 0.15f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)1);
				ClairenRebelbase_dynamic_capeModification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_cape1Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape1", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelbase_dynamic_cape3Modification.dynamicBoneData = new DynamicBoneData("base_dynamic_cape3", 0.561f, null, 0.12f, null, 0.429f, null, 0f, null, 0.25f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
				ClairenRebelSwordFlamePrefabModification.dynamicBoneData = new DynamicBoneData("SwordFlamePrefab", 0.1f, null, 0.1f, null, 0.1f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0);
			}

			private void AddModificationsToList()
			{
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", -1, ClairenRivalSwordFlamePrefabModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 66, ClairenRivalbase_dynamic_capeModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 78, ClairenRivalbase_dynamic_cape1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 28, ClairenRivalbase_dynamic_cape3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 37, ClairenRivalbase_dynamic_hairModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 34, ClairenRivalbase_dynamic_hair1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 40, ClairenRivalbase_dynamic_hair2Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 36, ClairenRivalbase_dynamic_hair3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 81, ClairenRivalbase_jacketModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 83, ClairenRivaljacket_lModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 82, ClairenRivaljacket_rModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", 93, ClairenRivalbase_dynamic_tailModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", -2, ClairenRivalFakeFacePrefabModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", -1, ClairenLoverFacePrefabModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 37, ClairenLoverbase_dynamic_hairModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 34, ClairenLoverbase_dynamic_hair1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 40, ClairenLoverbase_dynamic_hair2Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 36, ClairenLoverbase_dynamic_hair3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 93, ClairenLoverbase_dynamic_tailModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 78, ClairenLoverbase_jacketModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 80, ClairenLoverjacket_lModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 79, ClairenLoverjacket_rModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 66, ClairenLoverbase_dynamic_capeModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 81, ClairenLoverbase_dynamic_cape1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", 28, ClairenLoverbase_dynamic_cape3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", -1, ClairenRebelRebelFacePrefabModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 37, ClairenRebelbase_dynamic_hairModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 34, ClairenRebelbase_dynamic_hair1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 40, ClairenRebelbase_dynamic_hair2Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 36, ClairenRebelbase_dynamic_hair3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 93, ClairenRebelbase_dynamic_tailModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 81, ClairenRebelbase_jacketModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 83, ClairenRebeljacket_lModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 82, ClairenRebeljacket_rModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 66, ClairenRebelbase_dynamic_capeModification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 78, ClairenRebelbase_dynamic_cape1Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", 28, ClairenRebelbase_dynamic_cape3Modification);
				_DynamicSkinManager.AddModification("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", -2, ClairenRebelSwordFlamePrefabModification);
			}

			private static void onSkinAdded(object sender, SkinAddedArgs e)
			{
				_DynamicSkinManager.AddSkinDef(e.skinDef);
			}
		}

		public delegate void VoidDelegate();

		public class SkinAddedArgs : EventArgs
		{
			public SkinDef skinDef { get; }

			public GameObject bodyPrefab { get; }

			public SkinAddedArgs(SkinDef newSkinDef, GameObject newGameObject)
			{
				skinDef = newSkinDef;
				bodyPrefab = newGameObject;
			}
		}

		private class FieldException : Exception
		{
			public FieldException(string message, Exception innerException)
				: base(message, innerException)
			{
			}
		}

		private static DynamicSkinExtension _DynamicSkinExtension = new DynamicSkinExtension();

		private static DynamicSkinManager _DynamicSkinManager = new DynamicSkinManager();

		private static VoidDelegate BeforeStartDelegate;

		private static VoidDelegate AfterStartDelegate;

		private static VoidDelegate BeforeBodyCatalogDelegate;

		private static VoidDelegate AfterBodyCatalogDelegate;

		private static AssetBundle assetBundle;

		private static readonly List<Material> materialsWithRoRShader = new List<Material>();

		internal static ClairenMercenaryPlugin Instance { get; private set; }

		internal static ManualLogSource InstanceLogger
		{
			get
			{
				ClairenMercenaryPlugin instance = Instance;
				return (instance != null) ? ((BaseUnityPlugin)instance).Logger : null;
			}
		}

		private static event EventHandler<SkinAddedArgs> MercBodyClairenRivalSkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyClairenLoverSkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyClairenRebelSkinAddedEvent;

		private void Start()
		{
			Instance = this;
			BeforeStart();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ClairenMercenary.antlershedclairenmercenary"))
			{
				assetBundle = AssetBundle.LoadFromStream(stream);
			}
			((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit);
			HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action<Action<Language>, Language>(LanguageLoadStrings));
			ReplaceShaders();
			AfterStart();
		}

		private void BeforeStart()
		{
			BeforeStartDelegate = (VoidDelegate)Delegate.Combine(BeforeStartDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeStart));
			BeforeStartDelegate?.Invoke();
		}

		private void AfterStart()
		{
			AfterStartDelegate = (VoidDelegate)Delegate.Combine(AfterStartDelegate, new VoidDelegate(_DynamicSkinExtension.AfterStart));
			AfterStartDelegate?.Invoke();
		}

		private static void BeforeBodyCatalogInit()
		{
			BeforeBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(BeforeBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeBodyCatalogInit));
			BeforeBodyCatalogDelegate?.Invoke();
		}

		private static void AfterBodyCatalogInit()
		{
			AfterBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(AfterBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.AfterBodyCatalogInit));
			AfterBodyCatalogDelegate?.Invoke();
		}

		private static void ReplaceShaders()
		{
			LoadMaterialsWithReplacedShader("RoR2/Base/Shaders/HGStandard.shader", "Assets/Resources/Materials/ClairenDefault.mat", "Assets/Resources/Materials/ClairenLover.mat", "Assets/Resources/Materials/LoverSword.mat");
		}

		private static void LoadMaterialsWithReplacedShader(string shaderPath, params string[] materialPaths)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Shader>((object)shaderPath).WaitForCompletion();
			foreach (string text in materialPaths)
			{
				Material val = assetBundle.LoadAsset<Material>(text);
				val.shader = shader;
				materialsWithRoRShader.Add(val);
			}
		}

		private static void LanguageLoadStrings(Action<Language> orig, Language self)
		{
			orig(self);
			self.SetStringByToken("ANTLERSHED_SKIN_CLAIRENRIVAL_NAME", "Royal Guard");
			self.SetStringByToken("ANTLERSHED_SKIN_CLAIRENREBEL_NAME", "Alternate Timeline");
			self.SetStringByToken("ANTLERSHED_SKIN_CLAIRENLOVER_NAME", "Aether High");
		}

		private static void Nothing(Action<SkinDef> orig, SkinDef self)
		{
		}

		private static void BodyCatalogInit()
		{
			BeforeBodyCatalogInit();
			MethodInfo method = typeof(SkinDef).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic);
			HookEndpointManager.Add((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
			AddMercBodyClairenRivalSkin();
			AddMercBodyClairenRebelSkin();
			AddMercBodyClairenLoverSkin();
			HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
			AfterBodyCatalogInit();
		}

		private static void MercBodyClairenRivalSkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			ClairenMercenaryPlugin.MercBodyClairenRivalSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyClairenRivalSkin()
		{
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			if (!((BaseUnityPlugin)Instance).Config.Bind<bool>("ClairenRival", "Enabled", true, (ConfigDescription)null).Value)
			{
				return;
			}
			string text = "MercBody";
			string text2 = "ClairenRival";
			try
			{
				GameObject val = BodyCatalog.FindBodyPrefab(text);
				if (!Object.op_Implicit((Object)(object)val))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
					return;
				}
				ModelLocator component = val.GetComponent<ModelLocator>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
					return;
				}
				GameObject gameObject = ((Component)component.modelTransform).gameObject;
				ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)skinController))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\ClairenMercenary\\Icons\\ClairenRivalIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "ANTLERSHED_SKIN_CLAIRENRIVAL_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0075: Unknown result type (might be due to invalid IL or missing references)
					//IL_0091: Unknown result type (might be due to invalid IL or missing references)
					//IL_0092: Unknown result type (might be due to invalid IL or missing references)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/ClairenDefault.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[7]
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/RivalSword.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = true,
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: 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_0071: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\ClairenRivalMesh.mesh"),
							renderer = renderers[7]
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\RivalSword.mesh"),
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
				skinController.skins[skinController.skins.Length - 1] = skin;
				BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
				MercBodyClairenRivalSkinAdded(skin, val);
			}
			catch (FieldException ex)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
				InstanceLogger.LogError((object)ex.InnerException);
			}
			catch (Exception ex2)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex2);
			}
		}

		private static void MercBodyClairenRebelSkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			ClairenMercenaryPlugin.MercBodyClairenRebelSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyClairenRebelSkin()
		{
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			if (!((BaseUnityPlugin)Instance).Config.Bind<bool>("ClairenRebel", "Enabled", true, (ConfigDescription)null).Value)
			{
				return;
			}
			string text = "MercBody";
			string text2 = "ClairenRebel";
			try
			{
				GameObject val = BodyCatalog.FindBodyPrefab(text);
				if (!Object.op_Implicit((Object)(object)val))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
					return;
				}
				ModelLocator component = val.GetComponent<ModelLocator>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
					return;
				}
				GameObject gameObject = ((Component)component.modelTransform).gameObject;
				ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)skinController))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\ClairenMercenary\\Icons\\ClairenRebelIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "ANTLERSHED_SKIN_CLAIRENREBEL_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0075: Unknown result type (might be due to invalid IL or missing references)
					//IL_0091: Unknown result type (might be due to invalid IL or missing references)
					//IL_0092: Unknown result type (might be due to invalid IL or missing references)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/ClairenDefault.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[7]
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/RivalSword.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = true,
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: 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_0071: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\ClairenRebelMesh.mesh"),
							renderer = renderers[7]
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\RivalSword.mesh"),
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
				skinController.skins[skinController.skins.Length - 1] = skin;
				BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
				MercBodyClairenRebelSkinAdded(skin, val);
			}
			catch (FieldException ex)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
				InstanceLogger.LogError((object)ex.InnerException);
			}
			catch (Exception ex2)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex2);
			}
		}

		private static void MercBodyClairenLoverSkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			ClairenMercenaryPlugin.MercBodyClairenLoverSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyClairenLoverSkin()
		{
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			if (!((BaseUnityPlugin)Instance).Config.Bind<bool>("ClairenLover", "Enabled", true, (ConfigDescription)null).Value)
			{
				return;
			}
			string text = "MercBody";
			string text2 = "ClairenLover";
			try
			{
				GameObject val = BodyCatalog.FindBodyPrefab(text);
				if (!Object.op_Implicit((Object)(object)val))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
					return;
				}
				ModelLocator component = val.GetComponent<ModelLocator>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
					return;
				}
				GameObject gameObject = ((Component)component.modelTransform).gameObject;
				ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
				if (!Object.op_Implicit((Object)(object)skinController))
				{
					InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
					return;
				}
				Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
				SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
				TryCatchThrow("Icon", delegate
				{
					skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\ClairenMercenary\\Icons\\ClairenLoverIcon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "ANTLERSHED_SKIN_CLAIRENLOVER_NAME";
				skin.rootObject = gameObject;
				TryCatchThrow("Base Skins", delegate
				{
					skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
				});
				TryCatchThrow("Unlockable Name", delegate
				{
					skin.unlockableDef = null;
				});
				TryCatchThrow("Game Object Activations", delegate
				{
					skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0075: Unknown result type (might be due to invalid IL or missing references)
					//IL_0091: Unknown result type (might be due to invalid IL or missing references)
					//IL_0092: Unknown result type (might be due to invalid IL or missing references)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/ClairenLover.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[7]
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/Materials/LoverSword.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = true,
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: 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_0071: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\ClairenLoverMesh.mesh"),
							renderer = renderers[7]
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ClairenMercenary\\Meshes\\kendoSword.mesh"),
							renderer = renderers[8]
						}
					};
				});
				TryCatchThrow("Minion Skin Replacements", delegate
				{
					skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
				});
				TryCatchThrow("Projectile Ghost Replacements", delegate
				{
					skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
				});
				Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
				skinController.skins[skinController.skins.Length - 1] = skin;
				BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
				MercBodyClairenLoverSkinAdded(skin, val);
			}
			catch (FieldException ex)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
				InstanceLogger.LogError((object)ex.InnerException);
			}
			catch (Exception ex2)
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
				InstanceLogger.LogError((object)ex2);
			}
		}

		private static void TryCatchThrow(string message, Action action)
		{
			try
			{
				action?.Invoke();
			}
			catch (Exception innerException)
			{
				throw new FieldException(message, innerException);
			}
		}
	}
}