Decompiled source of Wanderer v1.0.0

Wanderer.dll

Decompiled 2 weeks 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.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.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Wanderer
{
	[BepInPlugin("com.MarinoDev.Wanderer", "Wanderer", "1.0.0")]
	public class WandererPlugin : BaseUnityPlugin
	{
		private class FieldException : Exception
		{
			public FieldException(string message, Exception innerException)
				: base(message, innerException)
			{
			}
		}

		public class DynamicSkinExtension
		{
			private Modification AlexHuntress1CapeBaseModification;

			private Modification AlexHuntress2CapeBaseModification;

			private Modification AlexHuntress3CapeBaseModification;

			private Modification AlexHuntress4CapeBaseModification;

			private Modification AlexMerc1MCapeBaseModification;

			private Modification AlexMerc2MCapeBaseModification;

			private Modification AlexMerc3MCapeBaseModification;

			private Modification AlexMerc4MCapeBaseModification;

			internal void BeforeStart()
			{
				//IL_0038: 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()
			{
				HuntressBodyAlexHuntress1SkinAddedEvent += onSkinAdded;
				HuntressBodyAlexHuntress2SkinAddedEvent += onSkinAdded;
				HuntressBodyAlexHuntress3SkinAddedEvent += onSkinAdded;
				HuntressBodyAlexHuntress4SkinAddedEvent += onSkinAdded;
				MercBodyAlexMerc1SkinAddedEvent += onSkinAdded;
				MercBodyAlexMerc2SkinAddedEvent += onSkinAdded;
				MercBodyAlexMerc3SkinAddedEvent += onSkinAdded;
				MercBodyAlexMerc4SkinAddedEvent += onSkinAdded;
			}

			internal void AfterBodyCatalogInit()
			{
			}

			private void InitializeModifications()
			{
				AlexHuntress1CapeBaseModification = new Modification("CapeBase.prefab", "chest", "HuntressBody", "MARINODEV_SKIN_ALEXHUNTRESS1_NAME", 39, AffectsBaseModel: true, assetBundle);
				AlexHuntress2CapeBaseModification = new Modification("CapeBase.prefab", "chest", "HuntressBody", "MARINODEV_SKIN_ALEXHUNTRESS2_NAME", 39, AffectsBaseModel: true, assetBundle);
				AlexHuntress3CapeBaseModification = new Modification("CapeBase.prefab", "chest", "HuntressBody", "MARINODEV_SKIN_ALEXHUNTRESS3_NAME", 39, AffectsBaseModel: true, assetBundle);
				AlexHuntress4CapeBaseModification = new Modification("CapeBase.prefab", "chest", "HuntressBody", "MARINODEV_SKIN_ALEXHUNTRESS4_NAME", 39, AffectsBaseModel: true, assetBundle);
				AlexMerc1MCapeBaseModification = new Modification("MCapeBase.prefab", "chest", "MercBody", "MARINODEV_SKIN_ALEXMERC1_NAME", 64, AffectsBaseModel: true, assetBundle);
				AlexMerc2MCapeBaseModification = new Modification("MCapeBase.prefab", "chest", "MercBody", "MARINODEV_SKIN_ALEXMERC2_NAME", 64, AffectsBaseModel: true, assetBundle);
				AlexMerc3MCapeBaseModification = new Modification("MCapeBase.prefab", "chest", "MercBody", "MARINODEV_SKIN_ALEXMERC3_NAME", 64, AffectsBaseModel: true, assetBundle);
				AlexMerc4MCapeBaseModification = new Modification("MCapeBase.prefab", "chest", "MercBody", "MARINODEV_SKIN_ALEXMERC4_NAME", 64, AffectsBaseModel: true, assetBundle);
			}

			private void InitializeDynamicBones()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: 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_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Expected O, but got Unknown
				//IL_0153: Expected O, but got Unknown
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0212: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: 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_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Expected O, but got Unknown
				//IL_02ab: Expected O, but got Unknown
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_030a: Unknown result type (might be due to invalid IL or missing references)
				//IL_030f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0314: Unknown result type (might be due to invalid IL or missing references)
				//IL_0319: Unknown result type (might be due to invalid IL or missing references)
				//IL_0320: Unknown result type (might be due to invalid IL or missing references)
				//IL_033e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0343: Unknown result type (might be due to invalid IL or missing references)
				//IL_0354: Unknown result type (might be due to invalid IL or missing references)
				//IL_0359: Unknown result type (might be due to invalid IL or missing references)
				//IL_035e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0363: Unknown result type (might be due to invalid IL or missing references)
				//IL_036a: Unknown result type (might be due to invalid IL or missing references)
				//IL_038b: Unknown result type (might be due to invalid IL or missing references)
				//IL_039f: 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_03d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Expected O, but got Unknown
				//IL_0403: Expected O, but got Unknown
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_043b: Unknown result type (might be due to invalid IL or missing references)
				//IL_044c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0451: Unknown result type (might be due to invalid IL or missing references)
				//IL_0462: Unknown result type (might be due to invalid IL or missing references)
				//IL_0467: Unknown result type (might be due to invalid IL or missing references)
				//IL_046c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0471: Unknown result type (might be due to invalid IL or missing references)
				//IL_0478: 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)
				//IL_049b: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_050b: Unknown result type (might be due to invalid IL or missing references)
				//IL_052b: Unknown result type (might be due to invalid IL or missing references)
				//IL_055b: Expected O, but got Unknown
				//IL_055b: Expected O, but got Unknown
				//IL_058e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0593: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0604: Unknown result type (might be due to invalid IL or missing references)
				//IL_0609: Unknown result type (might be due to invalid IL or missing references)
				//IL_060e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0613: Unknown result type (might be due to invalid IL or missing references)
				//IL_061a: Unknown result type (might be due to invalid IL or missing references)
				//IL_063b: Unknown result type (might be due to invalid IL or missing references)
				//IL_064f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0663: Unknown result type (might be due to invalid IL or missing references)
				//IL_0683: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b3: Expected O, but got Unknown
				//IL_06b3: Expected O, but got Unknown
				//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0701: Unknown result type (might be due to invalid IL or missing references)
				//IL_0712: Unknown result type (might be due to invalid IL or missing references)
				//IL_0717: Unknown result type (might be due to invalid IL or missing references)
				//IL_071c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0721: Unknown result type (might be due to invalid IL or missing references)
				//IL_0728: Unknown result type (might be due to invalid IL or missing references)
				//IL_0746: Unknown result type (might be due to invalid IL or missing references)
				//IL_074b: Unknown result type (might be due to invalid IL or missing references)
				//IL_075c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0761: Unknown result type (might be due to invalid IL or missing references)
				//IL_0766: Unknown result type (might be due to invalid IL or missing references)
				//IL_076b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0772: Unknown result type (might be due to invalid IL or missing references)
				//IL_0793: Unknown result type (might be due to invalid IL or missing references)
				//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_07db: Unknown result type (might be due to invalid IL or missing references)
				//IL_080b: Expected O, but got Unknown
				//IL_080b: Expected O, but got Unknown
				//IL_083e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0843: Unknown result type (might be due to invalid IL or missing references)
				//IL_0854: Unknown result type (might be due to invalid IL or missing references)
				//IL_0859: Unknown result type (might be due to invalid IL or missing references)
				//IL_086a: Unknown result type (might be due to invalid IL or missing references)
				//IL_086f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0874: Unknown result type (might be due to invalid IL or missing references)
				//IL_0879: Unknown result type (might be due to invalid IL or missing references)
				//IL_0880: Unknown result type (might be due to invalid IL or missing references)
				//IL_089e: Unknown result type (might be due to invalid IL or missing references)
				//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_08be: Unknown result type (might be due to invalid IL or missing references)
				//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_08eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_08ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0913: Unknown result type (might be due to invalid IL or missing references)
				//IL_0933: Unknown result type (might be due to invalid IL or missing references)
				//IL_0963: Expected O, but got Unknown
				//IL_0963: Expected O, but got Unknown
				//IL_0996: Unknown result type (might be due to invalid IL or missing references)
				//IL_099b: Unknown result type (might be due to invalid IL or missing references)
				//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_09fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a16: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0abb: Expected O, but got Unknown
				//IL_0abb: Expected O, but got Unknown
				AlexHuntress1CapeBaseModification.dynamicBoneData = new DynamicBoneData("CapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("CapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "CapeBase" }, (FreezeAxis)0);
				AlexHuntress2CapeBaseModification.dynamicBoneData = new DynamicBoneData("CapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("CapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "CapeBase" }, (FreezeAxis)0);
				AlexHuntress3CapeBaseModification.dynamicBoneData = new DynamicBoneData("CapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("CapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "CapeBase" }, (FreezeAxis)0);
				AlexHuntress4CapeBaseModification.dynamicBoneData = new DynamicBoneData("CapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("CapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "CapeBase" }, (FreezeAxis)0);
				AlexMerc1MCapeBaseModification.dynamicBoneData = new DynamicBoneData("MCapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("MCapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "MCapeBase" }, (FreezeAxis)0);
				AlexMerc2MCapeBaseModification.dynamicBoneData = new DynamicBoneData("MCapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("MCapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "MCapeBase" }, (FreezeAxis)0);
				AlexMerc3MCapeBaseModification.dynamicBoneData = new DynamicBoneData("MCapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("MCapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "MCapeBase" }, (FreezeAxis)0);
				AlexMerc4MCapeBaseModification.dynamicBoneData = new DynamicBoneData("MCapeBase", 0.8f, null, 0.1f, null, 1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-0.001041412f, 0.996582f),
					new Keyframe(0.2037295f, 0.001156211f),
					new Keyframe(0.9989624f, 0f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 1f),
					new Keyframe(1f, 1f)
				})
				{
					postWrapMode = (WrapMode)8,
					preWrapMode = (WrapMode)8
				}, 0.09f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.01f, 0f), new List<DynamicBoneColliderData>
				{
					new DynamicBoneColliderData("MCapeBase", (Direction)1, new Vector3(0f, -0.15f, -0.54f), (Bound)0, 0.5f, 0f)
				}, new List<string> { "MCapeBase" }, (FreezeAxis)0);
			}

			private void AddModificationsToList()
			{
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXHUNTRESS1_NAME", 39, AlexHuntress1CapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXHUNTRESS2_NAME", 39, AlexHuntress2CapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXHUNTRESS3_NAME", 39, AlexHuntress3CapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXHUNTRESS4_NAME", 39, AlexHuntress4CapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXMERC1_NAME", 64, AlexMerc1MCapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXMERC2_NAME", 64, AlexMerc2MCapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXMERC3_NAME", 64, AlexMerc3MCapeBaseModification);
				_DynamicSkinManager.AddModification("MARINODEV_SKIN_ALEXMERC4_NAME", 64, AlexMerc4MCapeBaseModification);
			}

			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 static AssetBundle assetBundle;

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

		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;

		internal static WandererPlugin Instance { get; private set; }

		internal static ManualLogSource InstanceLogger
		{
			get
			{
				WandererPlugin instance = Instance;
				if (instance == null)
				{
					return null;
				}
				return ((BaseUnityPlugin)instance).Logger;
			}
		}

		private static event EventHandler<SkinAddedArgs> HuntressBodyAlexHuntress1SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> HuntressBodyAlexHuntress2SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> HuntressBodyAlexHuntress3SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> HuntressBodyAlexHuntress4SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyAlexMerc1SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyAlexMerc2SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyAlexMerc3SkinAddedEvent;

		private static event EventHandler<SkinAddedArgs> MercBodyAlexMerc4SkinAddedEvent;

		private void Start()
		{
			Instance = this;
			BeforeStart();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wanderer.marinodevwanderer"))
			{
				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 1/Marino/Wanderer/AlexColor1.mat", "Assets/Resources 1/Marino/Wanderer/AlexColor2.mat", "Assets/Resources 1/Marino/Wanderer/AlexColor3.mat", "Assets/Resources 1/Marino/Wanderer/AlexColor4.mat");
		}

		private static void LoadMaterialsWithReplacedShader(string shaderPath, params string[] materialPaths)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			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("MARINODEV_SKIN_ALEXHUNTRESS1_NAME", "Wanderer");
			self.SetStringByToken("MARINODEV_SKIN_ALEXHUNTRESS2_NAME", "Wanderer (Alt1)");
			self.SetStringByToken("MARINODEV_SKIN_ALEXHUNTRESS3_NAME", "Wanderer (Alt2)");
			self.SetStringByToken("MARINODEV_SKIN_ALEXHUNTRESS4_NAME", "Wanderer (Alt3)");
			self.SetStringByToken("MARINODEV_SKIN_ALEXMERC1_NAME", "Wanderer");
			self.SetStringByToken("MARINODEV_SKIN_ALEXMERC2_NAME", "Wanderer");
			self.SetStringByToken("MARINODEV_SKIN_ALEXMERC3_NAME", "Wanderer");
			self.SetStringByToken("MARINODEV_SKIN_ALEXMERC4_NAME", "Wanderer");
		}

		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));
			AddHuntressBodyAlexHuntress1Skin();
			AddHuntressBodyAlexHuntress2Skin();
			AddHuntressBodyAlexHuntress3Skin();
			AddHuntressBodyAlexHuntress4Skin();
			AddMercBodyAlexMerc1Skin();
			AddMercBodyAlexMerc2Skin();
			AddMercBodyAlexMerc3Skin();
			AddMercBodyAlexMerc4Skin();
			HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
			AfterBodyCatalogInit();
		}

		private static void HuntressBodyAlexHuntress1SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.HuntressBodyAlexHuntress1SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddHuntressBodyAlexHuntress1Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "HuntressBody";
			string text2 = "AlexHuntress1";
			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/Resources 1/Marino/Wanderer/AlexHuntress1Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXHUNTRESS1_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
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
					skin.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[11]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[0]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[1]).gameObject,
							shouldActivate = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: 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_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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor1.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[10]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandBody.mesh"),
							renderer = renderers[10]
						}
					};
				});
				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;
				HuntressBodyAlexHuntress1SkinAdded(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 HuntressBodyAlexHuntress2SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.HuntressBodyAlexHuntress2SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddHuntressBodyAlexHuntress2Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "HuntressBody";
			string text2 = "AlexHuntress2";
			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/Resources 1/Marino/Wanderer/AlexHuntress2Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXHUNTRESS2_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
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
					skin.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[11]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[0]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[1]).gameObject,
							shouldActivate = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: 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_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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor2.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[10]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandBody.mesh"),
							renderer = renderers[10]
						}
					};
				});
				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;
				HuntressBodyAlexHuntress2SkinAdded(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 HuntressBodyAlexHuntress3SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.HuntressBodyAlexHuntress3SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddHuntressBodyAlexHuntress3Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "HuntressBody";
			string text2 = "AlexHuntress3";
			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/Resources 1/Marino/Wanderer/AlexHuntress3Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXHUNTRESS3_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
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
					skin.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[11]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[0]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[1]).gameObject,
							shouldActivate = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: 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_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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor3.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[10]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandBody.mesh"),
							renderer = renderers[10]
						}
					};
				});
				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;
				HuntressBodyAlexHuntress3SkinAdded(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 HuntressBodyAlexHuntress4SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.HuntressBodyAlexHuntress4SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddHuntressBodyAlexHuntress4Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "HuntressBody";
			string text2 = "AlexHuntress4";
			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/Resources 1/Marino/Wanderer/AlexHuntress4Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXHUNTRESS4_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
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
					skin.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
					{
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[11]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[0]).gameObject,
							shouldActivate = false
						},
						new GameObjectActivation
						{
							gameObject = ((Component)renderers[1]).gameObject,
							shouldActivate = false
						}
					};
				});
				TryCatchThrow("Renderer Infos", delegate
				{
					//IL_0010: 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_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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor4.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)1,
							ignoreOverlays = false,
							renderer = renderers[10]
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandBody.mesh"),
							renderer = renderers[10]
						}
					};
				});
				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;
				HuntressBodyAlexHuntress4SkinAdded(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 MercBodyAlexMerc1SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.MercBodyAlexMerc1SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyAlexMerc1Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "MercBody";
			string text2 = "AlexMerc1";
			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/Resources 1/Marino/Wanderer/AlexHuntress1Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXMERC1_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_0010: 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_006d: 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_0077: 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_00d4: 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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor1.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor1.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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_005e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandMercBody.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandSword.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				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;
				MercBodyAlexMerc1SkinAdded(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 MercBodyAlexMerc2SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.MercBodyAlexMerc2SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyAlexMerc2Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "MercBody";
			string text2 = "AlexMerc2";
			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/Resources 1/Marino/Wanderer/AlexHuntress2Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXMERC2_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_0010: 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_006d: 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_0077: 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_00d4: 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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor2.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor2.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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_005e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandMercBody.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandSword.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				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;
				MercBodyAlexMerc2SkinAdded(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 MercBodyAlexMerc3SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.MercBodyAlexMerc3SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyAlexMerc3Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "MercBody";
			string text2 = "AlexMerc3";
			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/Resources 1/Marino/Wanderer/AlexHuntress3Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXMERC3_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_0010: 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_006d: 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_0077: 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_00d4: 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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor3.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor3.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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_005e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandMercBody.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandSword.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				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;
				MercBodyAlexMerc3SkinAdded(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 MercBodyAlexMerc4SkinAdded(SkinDef skinDef, GameObject bodyPrefab)
		{
			WandererPlugin.MercBodyAlexMerc4SkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab));
		}

		private static void AddMercBodyAlexMerc4Skin()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			string text = "MercBody";
			string text2 = "AlexMerc4";
			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/Resources 1/Marino/Wanderer/AlexHuntress4Icon.png");
				});
				((Object)skin).name = text2;
				skin.nameToken = "MARINODEV_SKIN_ALEXMERC4_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_0010: 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_006d: 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_0077: 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_00d4: 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)
					skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
					{
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor4.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new RendererInfo
						{
							defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources 1/Marino/Wanderer/AlexColor4.mat"),
							defaultShadowCastingMode = (ShadowCastingMode)0,
							ignoreOverlays = false,
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				TryCatchThrow("Mesh Replacements", delegate
				{
					//IL_0010: 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_005e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
					skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
					{
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandMercBody.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercMesh")
						},
						new MeshReplacement
						{
							mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Wanderer\\Meshes\\WandSword.mesh"),
							renderer = renderers.First((Renderer r) => ((Object)r).name == "MercSwordMesh")
						}
					};
				});
				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;
				MercBodyAlexMerc4SkinAdded(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);
			}
		}
	}
}
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_0082: 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));
			foreach (Component val in components)
			{
				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"))
				{
					string text = parent_string + "/" + ((Object)child).name;
					Debug.Log((object)("  " + ((Object)child).name + "\t\t" + text));
					PrintAllPathsInner(((Component)child).gameObject, text);
					continue;
				}
				break;
			}
		}

		public static void PrintDynamicBone(DynamicBone DB)
		{
			//IL_0120: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_01f4: 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)
			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)
		{
			_ = 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;
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i].bones = list.ToArray();
			}
			modifications.BaseModelModifications.Push(modification);
		}

		private static void ModificationApplyDynamicBones(GameObject modelObject, Modification modification)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			DynamicBone val = (modification.inst_dynamicBone = modification.instance.AddComponent<DynamicBone>());
			List<DynamicBoneCollider> list = new List<DynamicBoneCollider>();
			foreach (DynamicBoneColliderData collider in modification.dynamicBoneData.m_Colliders)
			{
				DynamicBoneCollider val2 = ((Component)Utils.FindChildInTree(modelObject.transform, collider.m_parent_name)).gameObject.AddComponent<DynamicBoneCollider>();
				val2.m_Direction = collider.m_Direction;
				val2.m_Center = collider.m_Center;
				val2.m_Bound = collider.m_Bound;
				val2.m_Radius = collider.m_Radius;
				val2.m_Height = collider.m_Height;
				list.Add(val2);
			}
			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 val3 = Utils.FindChildInTree(root, exclusion);
				if ((Object)(object)val3 != (Object)null)
				{
					val.m_Exclusions.Add(val3);
				}
				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_0044: 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_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)
			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;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].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_0064: 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_006c: 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_0074: 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_008c: 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)
			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