Decompiled source of SkinDetailPicker v1.0.1

DetailPicker.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HG;
using HG.Reflection;
using IL.RoR2;
using LobbySkinsFix;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.UI;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.SurvivorMannequins;
using RoR2.UI;
using RoR2BepInExPack.Utilities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("DetailPicker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DetailPicker")]
[assembly: AssemblyTitle("DetailPicker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DetailPicker
{
	[BepInPlugin("xyz.yekoc.DetailPicker", "Skin Detail Picker", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class SkinDetailPickerPlugin : BaseUnityPlugin
	{
		public class OverlaySkin
		{
			public SkinDef orig;

			public RuntimeSkin rSkin;

			public BodyIndex bodyIndex;

			public bool seperateMaterials;

			public List<MinionSkinReplacement> minions;

			public List<ProjectileGhostReplacement> projectiles;

			public int[] syncInfo;

			public int FindIndex(int category)
			{
				return (syncInfo != null && category < syncInfo.Length) ? syncInfo[category] : 0;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_FindProjectileGhostPrefab <>9__12_0;

			public static Func<Instruction, bool> <>9__12_10;

			public static Func<MinionSkinReplacement[], MasterSummon, MinionSkinReplacement[]> <>9__12_9;

			public static Manipulator <>9__12_1;

			public static hook_Apply <>9__12_2;

			public static Predicate<MPButton> <>9__12_11;

			public static Predicate<MPButton> <>9__12_12;

			public static Func<SkinDef, IEnumerable<MeshReplacement>> <>9__12_13;

			public static Func<MeshReplacement, Renderer> <>9__12_14;

			public static Func<SkinDef, IEnumerable<RendererInfo>> <>9__12_15;

			public static Func<RendererInfo, Renderer> <>9__12_16;

			public static Func<SkinDef, IEnumerable<MinionSkinReplacement>> <>9__12_17;

			public static Func<MinionSkinReplacement, GameObject> <>9__12_18;

			public static Func<SkinDef, IEnumerable<ProjectileGhostReplacement>> <>9__12_19;

			public static Func<ProjectileGhostReplacement, GameObject> <>9__12_20;

			public static Predicate<MPButton> <>9__12_89;

			public static hook_Serialize <>9__12_5;

			public static Func<SkinDef, IEnumerable<MeshReplacement>> <>9__12_90;

			public static Func<MeshReplacement, Renderer> <>9__12_91;

			public static Func<SkinDef, IEnumerable<RendererInfo>> <>9__12_92;

			public static Func<RendererInfo, Renderer> <>9__12_93;

			public static Func<SkinDef, IEnumerable<MinionSkinReplacement>> <>9__12_94;

			public static Func<MinionSkinReplacement, GameObject> <>9__12_95;

			public static Func<SkinDef, IEnumerable<ProjectileGhostReplacement>> <>9__12_96;

			public static Func<ProjectileGhostReplacement, GameObject> <>9__12_97;

			public static hook_Deserialize <>9__12_6;

			public static hook_Copy <>9__12_7;

			internal GameObject <Awake>b__12_0(orig_FindProjectileGhostPrefab orig, ProjectileController projcontroller)
			{
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass12_0 CS$<>8__locals0 = new <>c__DisplayClass12_0();
				GameObject val = orig.Invoke(projcontroller);
				CS$<>8__locals0.prefab = ProjectileCatalog.GetProjectilePrefab(projcontroller.catalogIndex);
				GameObject owner = projcontroller.owner;
				object obj;
				if (owner == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody component = owner.GetComponent<CharacterBody>();
					obj = ((component == null) ? null : component.master?.loadout);
				}
				Loadout val2 = (Loadout)obj;
				OverlaySkin overlaySkin = default(OverlaySkin);
				ProjectileGhostReplacement? val3 = ((val2 == null || !networkOSkins.TryGetValue(val2, ref overlaySkin)) ? null : overlaySkin?.projectiles?.Find((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)CS$<>8__locals0.prefab));
				return (val3.HasValue && Object.op_Implicit((Object)(object)val3.Value.projectilePrefab)) ? val3.Value.projectileGhostReplacementPrefab : val;
			}

			internal void <Awake>b__12_1(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(SkinDef).GetField("minionSkinReplacements"))
				}))
				{
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<MinionSkinReplacement[], MasterSummon, MinionSkinReplacement[]>>((Func<MinionSkinReplacement[], MasterSummon, MinionSkinReplacement[]>)delegate(MinionSkinReplacement[] reps, MasterSummon self)
				{
					GameObject summonerBodyObject = self.summonerBodyObject;
					object obj;
					if (summonerBodyObject == null)
					{
						obj = null;
					}
					else
					{
						CharacterBody component = summonerBodyObject.GetComponent<CharacterBody>();
						obj = ((component == null) ? null : component.master?.loadout);
					}
					Loadout val2 = (Loadout)obj;
					OverlaySkin overlaySkin = default(OverlaySkin);
					return (val2 != null && networkOSkins.TryGetValue(val2, ref overlaySkin) && overlaySkin.minions != null) ? overlaySkin.minions.ToArray() : reps;
				});
			}

			internal bool <Awake>b__12_10(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdfld(x, typeof(SkinDef).GetField("minionSkinReplacements"));
			}

			internal MinionSkinReplacement[] <Awake>b__12_9(MinionSkinReplacement[] reps, MasterSummon self)
			{
				GameObject summonerBodyObject = self.summonerBodyObject;
				object obj;
				if (summonerBodyObject == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody component = summonerBodyObject.GetComponent<CharacterBody>();
					obj = ((component == null) ? null : component.master?.loadout);
				}
				Loadout val = (Loadout)obj;
				OverlaySkin overlaySkin = default(OverlaySkin);
				return (val != null && networkOSkins.TryGetValue(val, ref overlaySkin) && overlaySkin.minions != null) ? overlaySkin.minions.ToArray() : reps;
			}

			internal void <Awake>b__12_2(orig_Apply orig, SkinDef self, GameObject model)
			{
				orig.Invoke(self, model);
				CharacterModel component = model.GetComponent<CharacterModel>();
				object obj;
				if (component == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody body = component.body;
					obj = ((body == null) ? null : body.master?.loadout);
				}
				Loadout val = (Loadout)obj;
				if (val == null)
				{
					val = model.GetComponentInParent<SurvivorMannequinSlotController>()?.currentLoadout;
				}
				OverlaySkin overlaySkin = default(OverlaySkin);
				if (val != null && networkOSkins.TryGetValue(val, ref overlaySkin) && (Object)(object)overlaySkin.orig == (Object)(object)self)
				{
					RuntimeSkin rSkin = overlaySkin.rSkin;
					if (rSkin != null)
					{
						rSkin.Apply(model);
					}
				}
			}

			internal bool <Awake>b__12_11(MPButton b)
			{
				string overrideBodyText = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
				return overrideBodyText.Contains(Language.GetString(oSkin.orig.nameToken));
			}

			internal bool <Awake>b__12_12(MPButton b)
			{
				string overrideBodyText = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
				return overrideBodyText.Contains(Language.GetString(oSkin.orig.baseSkins.Last().nameToken));
			}

			internal IEnumerable<MeshReplacement> <Awake>b__12_13(SkinDef s)
			{
				return s.meshReplacements;
			}

			internal Renderer <Awake>b__12_14(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.renderer;
			}

			internal IEnumerable<RendererInfo> <Awake>b__12_15(SkinDef s)
			{
				return s.rendererInfos;
			}

			internal Renderer <Awake>b__12_16(RendererInfo i)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return i.renderer;
			}

			internal IEnumerable<MinionSkinReplacement> <Awake>b__12_17(SkinDef s)
			{
				return s.minionSkinReplacements;
			}

			internal GameObject <Awake>b__12_18(MinionSkinReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.minionBodyPrefab;
			}

			internal IEnumerable<ProjectileGhostReplacement> <Awake>b__12_19(SkinDef s)
			{
				return s.projectileGhostReplacements;
			}

			internal GameObject <Awake>b__12_20(ProjectileGhostReplacement p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return p.projectilePrefab;
			}

			internal bool <Awake>b__12_89(MPButton b)
			{
				string overrideBodyText = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
				return overrideBodyText.Contains(Language.GetString(oSkin.orig.nameToken));
			}

			internal void <Awake>b__12_5(orig_Serialize orig, Loadout self, NetworkWriter writer)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Expected I4, but got Unknown
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, writer);
				OverlaySkin orCreateValue = networkOSkins.GetOrCreateValue(self);
				if ((Object)(object)orCreateValue.orig == (Object)null)
				{
					writer.Write(-1);
					return;
				}
				writer.Write((int)orCreateValue.orig.skinIndex);
				NetworkExtensions.WriteBodyIndex(writer, orCreateValue.bodyIndex);
				writer.Write(orCreateValue.seperateMaterials);
				writer.Write(orCreateValue.syncInfo.Length);
				int[] syncInfo = orCreateValue.syncInfo;
				foreach (int num in syncInfo)
				{
					writer.Write(num);
				}
			}

			internal void <Awake>b__12_6(orig_Deserialize orig, Loadout self, NetworkReader reader)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Invalid comparison between Unknown and I4
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Expected O, but got Unknown
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0991: Unknown result type (might be due to invalid IL or missing references)
				//IL_039a: Unknown result type (might be due to invalid IL or missing references)
				//IL_09ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0a29: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c55: Unknown result type (might be due to invalid IL or missing references)
				//IL_0408: Unknown result type (might be due to invalid IL or missing references)
				//IL_0432: Unknown result type (might be due to invalid IL or missing references)
				//IL_065e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0550: Unknown result type (might be due to invalid IL or missing references)
				//IL_056c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Unknown result type (might be due to invalid IL or missing references)
				//IL_0486: Unknown result type (might be due to invalid IL or missing references)
				//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_06db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ba0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ab5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
				//IL_057e: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0506: Unknown result type (might be due to invalid IL or missing references)
				//IL_0514: Unknown result type (might be due to invalid IL or missing references)
				//IL_0522: Unknown result type (might be due to invalid IL or missing references)
				//IL_0524: Unknown result type (might be due to invalid IL or missing references)
				//IL_0529: Unknown result type (might be due to invalid IL or missing references)
				//IL_052e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0530: Unknown result type (might be due to invalid IL or missing references)
				//IL_071f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0737: Unknown result type (might be due to invalid IL or missing references)
				//IL_073f: Unknown result type (might be due to invalid IL or missing references)
				//IL_074d: Unknown result type (might be due to invalid IL or missing references)
				//IL_075b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0769: Unknown result type (might be due to invalid IL or missing references)
				//IL_0777: Unknown result type (might be due to invalid IL or missing references)
				//IL_0779: Unknown result type (might be due to invalid IL or missing references)
				//IL_077e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0783: Unknown result type (might be due to invalid IL or missing references)
				//IL_0785: Unknown result type (might be due to invalid IL or missing references)
				//IL_0afe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b16: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b1e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b2c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b3a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b48: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b5d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b62: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b64: Unknown result type (might be due to invalid IL or missing references)
				//IL_0cda: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, reader);
				SkinIndex val = (SkinIndex)reader.ReadInt32();
				if ((int)val == -1)
				{
					return;
				}
				OverlaySkin orCreateValue = networkOSkins.GetOrCreateValue(self);
				orCreateValue.orig = SkinCatalog.GetSkinDef(val);
				orCreateValue.bodyIndex = NetworkExtensions.ReadBodyIndex(reader);
				orCreateValue.seperateMaterials = reader.ReadBoolean();
				int num = reader.ReadInt32();
				orCreateValue.syncInfo = new int[num];
				for (int j = 0; j < num; j++)
				{
					orCreateValue.syncInfo[j] = reader.ReadInt32();
				}
				orCreateValue.orig.Bake();
				orCreateValue.rSkin = new RuntimeSkin
				{
					meshReplacementTemplates = ArrayUtils.Clone<MeshReplacementTemplate>(orCreateValue.orig.runtimeSkin.meshReplacementTemplates),
					rendererInfoTemplates = ArrayUtils.Clone<RendererInfoTemplate>(orCreateValue.orig.runtimeSkin.rendererInfoTemplates),
					gameObjectActivationTemplates = ArrayUtils.Clone<GameObjectActivationTemplate>(orCreateValue.orig.runtimeSkin.gameObjectActivationTemplates)
				};
				SkinDef[] bodySkinDefs = SkinCatalog.GetBodySkinDefs(orCreateValue.bodyIndex);
				IEnumerable<Renderer> enumerable = (from m in bodySkinDefs.SelectMany((SkinDef s) => s.meshReplacements)
					select m.renderer).Distinct();
				IEnumerable<Renderer> enumerable2 = (from i in bodySkinDefs.SelectMany((SkinDef s) => s.rendererInfos)
					select i.renderer).Distinct();
				IEnumerable<GameObject> enumerable3 = (from m in bodySkinDefs.SelectMany((SkinDef s) => s.minionSkinReplacements)
					select m.minionBodyPrefab).Distinct();
				IEnumerable<GameObject> enumerable4 = (from p in bodySkinDefs.SelectMany((SkinDef s) => s.projectileGhostReplacements)
					select p.projectilePrefab).Distinct();
				int num2 = 0;
				if (orCreateValue.seperateMaterials)
				{
					using (IEnumerator<Renderer> enumerator = enumerable.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							<>c__DisplayClass12_31 CS$<>8__locals0 = new <>c__DisplayClass12_31
							{
								renderer = enumerator.Current
							};
							<>c__DisplayClass12_32 CS$<>8__locals1 = new <>c__DisplayClass12_32
							{
								path = Util.BuildPrefabTransformPath(orCreateValue.orig.rootObject.transform, ((Component)CS$<>8__locals0.renderer).transform, false, false)
							};
							if (orCreateValue.syncInfo[num2] == 0 && !bodySkinDefs[0].meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer))
							{
								List<MeshReplacementTemplate> list = orCreateValue.rSkin.meshReplacementTemplates.ToList();
								list.RemoveAll((MeshReplacementTemplate m) => m.path == CS$<>8__locals1.path);
								orCreateValue.rSkin.meshReplacementTemplates = list.ToArray();
								List<GameObjectActivationTemplate> list2 = orCreateValue.rSkin.gameObjectActivationTemplates.ToList();
								list2.RemoveAll((GameObjectActivationTemplate m) => m.path == CS$<>8__locals1.path && !m.shouldActivate);
								orCreateValue.rSkin.gameObjectActivationTemplates = list2.ToArray();
								num2++;
								continue;
							}
							List<SkinDef> list3 = bodySkinDefs.Where((SkinDef s) => s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer && (Object)(object)m.mesh != (Object)null)).ToList();
							if (list3.Count <= orCreateValue.syncInfo[num2])
							{
								ref MeshReplacementTemplate[] meshReplacementTemplates = ref orCreateValue.rSkin.meshReplacementTemplates;
								MeshReplacementTemplate val2 = new MeshReplacementTemplate
								{
									path = CS$<>8__locals1.path,
									mesh = null
								};
								ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates, ref val2);
								num2++;
								continue;
							}
							SkinDef val3 = list3[orCreateValue.syncInfo[num2]];
							if (val3.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer))
							{
								ref MeshReplacementTemplate[] meshReplacementTemplates2 = ref orCreateValue.rSkin.meshReplacementTemplates;
								MeshReplacementTemplate val2 = new MeshReplacementTemplate
								{
									path = CS$<>8__locals1.path,
									mesh = val3.meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer).mesh
								};
								ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates2, ref val2);
							}
							if (val3.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer))
							{
								RendererInfo val4 = val3.rendererInfos.First((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals0.renderer);
								int num3 = Array.FindIndex(orCreateValue.rSkin.rendererInfoTemplates, (RendererInfoTemplate r) => r.path == CS$<>8__locals1.path);
								ref RendererInfoTemplate[] rendererInfoTemplates = ref orCreateValue.rSkin.rendererInfoTemplates;
								int num4 = ((num3 == -1) ? orCreateValue.rSkin.rendererInfoTemplates.Length : num3);
								RendererInfoTemplate val5 = new RendererInfoTemplate
								{
									path = CS$<>8__locals1.path,
									data = new RendererInfo
									{
										defaultMaterial = val4.defaultMaterial,
										hideOnDeath = val4.hideOnDeath,
										renderer = val4.renderer,
										ignoreOverlays = val4.ignoreOverlays,
										defaultShadowCastingMode = val4.defaultShadowCastingMode
									}
								};
								ArrayUtils.ArrayInsert<RendererInfoTemplate>(ref rendererInfoTemplates, num4, ref val5);
							}
							ref GameObjectActivationTemplate[] gameObjectActivationTemplates = ref orCreateValue.rSkin.gameObjectActivationTemplates;
							if (gameObjectActivationTemplates.Contains(new GameObjectActivationTemplate
							{
								path = CS$<>8__locals1.path,
								shouldActivate = false
							}))
							{
								GameObjectActivationTemplate val6 = new GameObjectActivationTemplate
								{
									path = CS$<>8__locals1.path,
									shouldActivate = true
								};
								ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates, ref val6);
							}
							num2++;
						}
					}
					using IEnumerator<Renderer> enumerator2 = enumerable2.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						<>c__DisplayClass12_33 CS$<>8__locals2 = new <>c__DisplayClass12_33
						{
							renderer = enumerator2.Current
						};
						<>c__DisplayClass12_34 CS$<>8__locals3 = new <>c__DisplayClass12_34
						{
							path = Util.BuildPrefabTransformPath(orCreateValue.orig.rootObject.transform, ((Component)CS$<>8__locals2.renderer).transform, false, false)
						};
						List<SkinDef> list4 = bodySkinDefs.Where((SkinDef s) => s.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals2.renderer)).ToList();
						if (list4.Count <= orCreateValue.syncInfo[num2])
						{
							ref GameObjectActivationTemplate[] gameObjectActivationTemplates2 = ref orCreateValue.rSkin.gameObjectActivationTemplates;
							GameObjectActivationTemplate val6 = new GameObjectActivationTemplate
							{
								path = CS$<>8__locals3.path,
								shouldActivate = false
							};
							ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates2, ref val6);
							num2++;
							continue;
						}
						SkinDef val7 = list4[orCreateValue.syncInfo[num2]];
						if (val7.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals2.renderer))
						{
							RendererInfo val8 = val7.rendererInfos.First((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals2.renderer);
							int num5 = Array.FindIndex(orCreateValue.rSkin.rendererInfoTemplates, (RendererInfoTemplate r) => r.path == CS$<>8__locals3.path);
							ref RendererInfoTemplate[] rendererInfoTemplates2 = ref orCreateValue.rSkin.rendererInfoTemplates;
							int num6 = ((num5 == -1) ? orCreateValue.rSkin.rendererInfoTemplates.Length : num5);
							RendererInfoTemplate val5 = new RendererInfoTemplate
							{
								path = CS$<>8__locals3.path,
								data = new RendererInfo
								{
									defaultMaterial = val8.defaultMaterial,
									hideOnDeath = val8.hideOnDeath,
									renderer = val8.renderer,
									ignoreOverlays = val8.ignoreOverlays,
									defaultShadowCastingMode = val8.defaultShadowCastingMode
								}
							};
							ArrayUtils.ArrayInsert<RendererInfoTemplate>(ref rendererInfoTemplates2, num6, ref val5);
						}
						ref GameObjectActivationTemplate[] gameObjectActivationTemplates3 = ref orCreateValue.rSkin.gameObjectActivationTemplates;
						if (gameObjectActivationTemplates3.Contains(new GameObjectActivationTemplate
						{
							path = CS$<>8__locals3.path,
							shouldActivate = false
						}))
						{
							GameObjectActivationTemplate val6 = new GameObjectActivationTemplate
							{
								path = CS$<>8__locals3.path,
								shouldActivate = true
							};
							ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates3, ref val6);
						}
						num2++;
					}
				}
				else
				{
					using IEnumerator<Renderer> enumerator3 = enumerable.Concat(enumerable2).Distinct().GetEnumerator();
					while (enumerator3.MoveNext())
					{
						<>c__DisplayClass12_35 CS$<>8__locals4 = new <>c__DisplayClass12_35
						{
							renderer = enumerator3.Current
						};
						<>c__DisplayClass12_36 CS$<>8__locals5 = new <>c__DisplayClass12_36
						{
							path = Util.BuildPrefabTransformPath(orCreateValue.orig.rootObject.transform, ((Component)CS$<>8__locals4.renderer).transform, false, false)
						};
						if (orCreateValue.syncInfo[num2] == 0 && !bodySkinDefs[0].meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer) && !bodySkinDefs[0].rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer))
						{
							List<MeshReplacementTemplate> list5 = orCreateValue.rSkin.meshReplacementTemplates.ToList();
							list5.RemoveAll((MeshReplacementTemplate m) => m.path == CS$<>8__locals5.path);
							orCreateValue.rSkin.meshReplacementTemplates = list5.ToArray();
							List<GameObjectActivationTemplate> list6 = orCreateValue.rSkin.gameObjectActivationTemplates.ToList();
							list6.RemoveAll((GameObjectActivationTemplate m) => m.path == CS$<>8__locals5.path && !m.shouldActivate);
							orCreateValue.rSkin.gameObjectActivationTemplates = list6.ToArray();
							num2++;
							continue;
						}
						List<SkinDef> list7 = bodySkinDefs.Where((SkinDef s) => s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer && (Object)(object)m.mesh != (Object)null) || s.rendererInfos.Any((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)CS$<>8__locals4.renderer)).ToList();
						if (list7.Count <= orCreateValue.syncInfo[num2])
						{
							ref MeshReplacementTemplate[] meshReplacementTemplates3 = ref orCreateValue.rSkin.meshReplacementTemplates;
							MeshReplacementTemplate val2 = new MeshReplacementTemplate
							{
								path = CS$<>8__locals5.path,
								mesh = null
							};
							ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates3, ref val2);
							num2++;
							continue;
						}
						SkinDef val9 = list7[orCreateValue.syncInfo[num2]];
						if (val9.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer))
						{
							ref MeshReplacementTemplate[] meshReplacementTemplates4 = ref orCreateValue.rSkin.meshReplacementTemplates;
							MeshReplacementTemplate val2 = new MeshReplacementTemplate
							{
								path = CS$<>8__locals5.path,
								mesh = val9.meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer).mesh
							};
							ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates4, ref val2);
						}
						else
						{
							List<MeshReplacementTemplate> list8 = orCreateValue.rSkin.meshReplacementTemplates.ToList();
							list8.RemoveAll((MeshReplacementTemplate m) => m.path == CS$<>8__locals5.path);
							orCreateValue.rSkin.meshReplacementTemplates = list8.ToArray();
						}
						if (val9.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer))
						{
							RendererInfo val10 = val9.rendererInfos.First((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)CS$<>8__locals4.renderer);
							int num7 = Array.FindIndex(orCreateValue.rSkin.rendererInfoTemplates, (RendererInfoTemplate r) => r.path == CS$<>8__locals5.path);
							ref RendererInfoTemplate[] rendererInfoTemplates3 = ref orCreateValue.rSkin.rendererInfoTemplates;
							int num8 = ((num7 == -1) ? orCreateValue.rSkin.rendererInfoTemplates.Length : num7);
							RendererInfoTemplate val5 = new RendererInfoTemplate
							{
								path = CS$<>8__locals5.path,
								data = new RendererInfo
								{
									defaultMaterial = val10.defaultMaterial,
									hideOnDeath = val10.hideOnDeath,
									renderer = val10.renderer,
									ignoreOverlays = val10.ignoreOverlays,
									defaultShadowCastingMode = val10.defaultShadowCastingMode
								}
							};
							ArrayUtils.ArrayInsert<RendererInfoTemplate>(ref rendererInfoTemplates3, num8, ref val5);
						}
						ref GameObjectActivationTemplate[] gameObjectActivationTemplates4 = ref orCreateValue.rSkin.gameObjectActivationTemplates;
						if (gameObjectActivationTemplates4.Contains(new GameObjectActivationTemplate
						{
							path = CS$<>8__locals5.path,
							shouldActivate = false
						}))
						{
							GameObjectActivationTemplate val6 = new GameObjectActivationTemplate
							{
								path = CS$<>8__locals5.path,
								shouldActivate = true
							};
							ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates4, ref val6);
						}
						num2++;
					}
				}
				using (IEnumerator<GameObject> enumerator4 = enumerable3.GetEnumerator())
				{
					while (enumerator4.MoveNext())
					{
						<>c__DisplayClass12_37 CS$<>8__locals6 = new <>c__DisplayClass12_37
						{
							minion = enumerator4.Current
						};
						orCreateValue.minions.Add(bodySkinDefs.Where((SkinDef s) => s.minionSkinReplacements.Any((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)CS$<>8__locals6.minion)).ElementAt(orCreateValue.syncInfo[num2]).minionSkinReplacements.First((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)CS$<>8__locals6.minion));
						num2++;
					}
				}
				using IEnumerator<GameObject> enumerator5 = enumerable4.GetEnumerator();
				while (enumerator5.MoveNext())
				{
					<>c__DisplayClass12_38 CS$<>8__locals7 = new <>c__DisplayClass12_38
					{
						proj = enumerator5.Current
					};
					orCreateValue.projectiles.Add(bodySkinDefs.Where((SkinDef s) => s.projectileGhostReplacements.Any((ProjectileGhostReplacement m) => (Object)(object)m.projectilePrefab == (Object)(object)CS$<>8__locals7.proj)).ElementAt(orCreateValue.syncInfo[num2]).projectileGhostReplacements.First((ProjectileGhostReplacement m) => (Object)(object)m.projectilePrefab == (Object)(object)CS$<>8__locals7.proj));
					num2++;
				}
			}

			internal IEnumerable<MeshReplacement> <Awake>b__12_90(SkinDef s)
			{
				return s.meshReplacements;
			}

			internal Renderer <Awake>b__12_91(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.renderer;
			}

			internal IEnumerable<RendererInfo> <Awake>b__12_92(SkinDef s)
			{
				return s.rendererInfos;
			}

			internal Renderer <Awake>b__12_93(RendererInfo i)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return i.renderer;
			}

			internal IEnumerable<MinionSkinReplacement> <Awake>b__12_94(SkinDef s)
			{
				return s.minionSkinReplacements;
			}

			internal GameObject <Awake>b__12_95(MinionSkinReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.minionBodyPrefab;
			}

			internal IEnumerable<ProjectileGhostReplacement> <Awake>b__12_96(SkinDef s)
			{
				return s.projectileGhostReplacements;
			}

			internal GameObject <Awake>b__12_97(ProjectileGhostReplacement p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return p.projectilePrefab;
			}

			internal void <Awake>b__12_7(orig_Copy orig, Loadout self, Loadout target)
			{
				orig.Invoke(self, target);
				OverlaySkin overlaySkin = default(OverlaySkin);
				if (networkOSkins.TryGetValue(self, ref overlaySkin))
				{
					networkOSkins.Remove(target);
					networkOSkins.Add(target, overlaySkin);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_0
		{
			public GameObject prefab;

			internal bool <Awake>b__8(ProjectileGhostReplacement p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)p.projectilePrefab == (Object)(object)prefab;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_31
		{
			public Renderer renderer;

			public Func<MeshReplacement, bool> <>9__102;

			internal bool <Awake>b__99(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__98(SkinDef s)
			{
				return s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer && (Object)(object)m.mesh != (Object)null);
			}

			internal bool <Awake>b__102(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer && (Object)(object)m.mesh != (Object)null;
			}

			internal bool <Awake>b__103(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__104(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__105(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__106(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_32
		{
			public string path;

			internal bool <Awake>b__100(MeshReplacementTemplate m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.path == path;
			}

			internal bool <Awake>b__101(GameObjectActivationTemplate m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				return m.path == path && !m.shouldActivate;
			}

			internal bool <Awake>b__107(RendererInfoTemplate r)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return r.path == path;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_33
		{
			public Renderer renderer;

			public Func<RendererInfo, bool> <>9__109;

			internal bool <Awake>b__108(SkinDef s)
			{
				return s.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)renderer);
			}

			internal bool <Awake>b__109(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__110(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__111(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_34
		{
			public string path;

			internal bool <Awake>b__112(RendererInfoTemplate r)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return r.path == path;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_35
		{
			public Renderer renderer;

			public Func<MeshReplacement, bool> <>9__118;

			public Func<RendererInfo, bool> <>9__119;

			internal bool <Awake>b__114(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__115(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__113(SkinDef s)
			{
				return s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer && (Object)(object)m.mesh != (Object)null) || s.rendererInfos.Any((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)renderer);
			}

			internal bool <Awake>b__118(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer && (Object)(object)m.mesh != (Object)null;
			}

			internal bool <Awake>b__119(RendererInfo r)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)r.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__120(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__121(MeshReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__123(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}

			internal bool <Awake>b__124(RendererInfo m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.renderer == (Object)(object)renderer;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_36
		{
			public string path;

			internal bool <Awake>b__116(MeshReplacementTemplate m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.path == path;
			}

			internal bool <Awake>b__117(GameObjectActivationTemplate m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				return m.path == path && !m.shouldActivate;
			}

			internal bool <Awake>b__122(MeshReplacementTemplate m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return m.path == path;
			}

			internal bool <Awake>b__125(RendererInfoTemplate r)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return r.path == path;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_37
		{
			public GameObject minion;

			public Func<MinionSkinReplacement, bool> <>9__128;

			internal bool <Awake>b__126(SkinDef s)
			{
				return s.minionSkinReplacements.Any((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)minion);
			}

			internal bool <Awake>b__128(MinionSkinReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.minionBodyPrefab == (Object)(object)minion;
			}

			internal bool <Awake>b__127(MinionSkinReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.minionBodyPrefab == (Object)(object)minion;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_38
		{
			public GameObject proj;

			public Func<ProjectileGhostReplacement, bool> <>9__131;

			internal bool <Awake>b__129(SkinDef s)
			{
				return s.projectileGhostReplacements.Any((ProjectileGhostReplacement m) => (Object)(object)m.projectilePrefab == (Object)(object)proj);
			}

			internal bool <Awake>b__131(ProjectileGhostReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.projectilePrefab == (Object)(object)proj;
			}

			internal bool <Awake>b__130(ProjectileGhostReplacement m)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)m.projectilePrefab == (Object)(object)proj;
			}
		}

		public static bool lobbySkinFix = false;

		public Sprite icon = LegacyResourcesAPI.Load<SkillDef>("SkillDefs/CaptainBody/CaptainSkillUsedUp").icon;

		public static FixedConditionalWeakTable<Loadout, OverlaySkin> networkOSkins = new FixedConditionalWeakTable<Loadout, OverlaySkin>();

		public ConfigEntry<bool> seperateMaterials;

		public static UserProfile localProfile;

		public List<Row> detailRows = new List<Row>();

		public int rowCountStore;

		public static OverlaySkin oSkin
		{
			get
			{
				return networkOSkins.GetOrCreateValue(localProfile.loadout);
			}
			set
			{
				networkOSkins.Remove(localProfile.loadout);
				networkOSkins.Add(localProfile.loadout, value);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public void HandleLobbySkinFix()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			new Hook((MethodBase)typeof(ReverseSkin).GetMethod("Initialize", (BindingFlags)(-1)), (Delegate)new Action<Action<ReverseSkin, GameObject, SkinDef>, ReverseSkin, GameObject, SkinDef>(hook));
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			static void hook(Action<ReverseSkin, GameObject, SkinDef> orig, ReverseSkin self, GameObject model, SkinDef skin)
			{
				RuntimeSkin runtimeSkin = skin.runtimeSkin;
				CharacterModel component = model.GetComponent<CharacterModel>();
				object obj;
				if (component == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody body = component.body;
					obj = ((body == null) ? null : body.master?.loadout);
				}
				Loadout val = (Loadout)obj;
				OverlaySkin overlaySkin = default(OverlaySkin);
				skin.runtimeSkin = ((val != null && networkOSkins.TryGetValue(val, ref overlaySkin) && (Object)(object)overlaySkin.orig == (Object)(object)skin) ? overlaySkin.rSkin : runtimeSkin);
				orig(self, model, skin);
				skin.runtimeSkin = runtimeSkin;
			}
		}

		private void Awake()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			lobbySkinFix = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.LobbySkinsFix");
			seperateMaterials = ((BaseUnityPlugin)this).Config.Bind<bool>("Configuration", "Seperate Materials", false, "Present extra selections for materials (the default merges them with mesh replacements)");
			if (lobbySkinFix)
			{
				HandleLobbySkinFix();
			}
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_FindProjectileGhostPrefab val = delegate(orig_FindProjectileGhostPrefab orig, ProjectileController projcontroller)
				{
					//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_009c: Unknown result type (might be due to invalid IL or missing references)
					GameObject val48 = orig.Invoke(projcontroller);
					GameObject prefab = ProjectileCatalog.GetProjectilePrefab(projcontroller.catalogIndex);
					GameObject owner = projcontroller.owner;
					object obj29;
					if (owner == null)
					{
						obj29 = null;
					}
					else
					{
						CharacterBody component5 = owner.GetComponent<CharacterBody>();
						obj29 = ((component5 == null) ? null : component5.master?.loadout);
					}
					Loadout val49 = (Loadout)obj29;
					OverlaySkin overlaySkin4 = default(OverlaySkin);
					ProjectileGhostReplacement? val50 = ((val49 == null || !networkOSkins.TryGetValue(val49, ref overlaySkin4)) ? null : overlaySkin4?.projectiles?.Find((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)prefab));
					return (val50.HasValue && Object.op_Implicit((Object)(object)val50.Value.projectilePrefab)) ? val50.Value.projectileGhostReplacementPrefab : val48;
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			ProjectileGhostReplacementManager.FindProjectileGhostPrefab += (hook_FindProjectileGhostPrefab)obj;
			object obj2 = <>c.<>9__12_1;
			if (obj2 == null)
			{
				Manipulator val2 = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val46 = new ILCursor(il);
					if (val46.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(SkinDef).GetField("minionSkinReplacements"))
					}))
					{
						val46.Emit(OpCodes.Ldarg_0);
						val46.EmitDelegate<Func<MinionSkinReplacement[], MasterSummon, MinionSkinReplacement[]>>((Func<MinionSkinReplacement[], MasterSummon, MinionSkinReplacement[]>)delegate(MinionSkinReplacement[] reps, MasterSummon self)
						{
							GameObject summonerBodyObject = self.summonerBodyObject;
							object obj28;
							if (summonerBodyObject == null)
							{
								obj28 = null;
							}
							else
							{
								CharacterBody component4 = summonerBodyObject.GetComponent<CharacterBody>();
								obj28 = ((component4 == null) ? null : component4.master?.loadout);
							}
							Loadout val47 = (Loadout)obj28;
							OverlaySkin overlaySkin3 = default(OverlaySkin);
							return (val47 != null && networkOSkins.TryGetValue(val47, ref overlaySkin3) && overlaySkin3.minions != null) ? overlaySkin3.minions.ToArray() : reps;
						});
					}
				};
				<>c.<>9__12_1 = val2;
				obj2 = (object)val2;
			}
			MasterSummon.Perform += (Manipulator)obj2;
			object obj3 = <>c.<>9__12_2;
			if (obj3 == null)
			{
				hook_Apply val3 = delegate(orig_Apply orig, SkinDef self, GameObject model)
				{
					orig.Invoke(self, model);
					CharacterModel component3 = model.GetComponent<CharacterModel>();
					object obj27;
					if (component3 == null)
					{
						obj27 = null;
					}
					else
					{
						CharacterBody body = component3.body;
						obj27 = ((body == null) ? null : body.master?.loadout);
					}
					Loadout val45 = (Loadout)obj27;
					if (val45 == null)
					{
						val45 = model.GetComponentInParent<SurvivorMannequinSlotController>()?.currentLoadout;
					}
					OverlaySkin overlaySkin2 = default(OverlaySkin);
					if (val45 != null && networkOSkins.TryGetValue(val45, ref overlaySkin2) && (Object)(object)overlaySkin2.orig == (Object)(object)self)
					{
						RuntimeSkin rSkin = overlaySkin2.rSkin;
						if (rSkin != null)
						{
							rSkin.Apply(model);
						}
					}
				};
				<>c.<>9__12_2 = val3;
				obj3 = (object)val3;
			}
			SkinDef.Apply += (hook_Apply)obj3;
			UserProfile.onLoadoutChangedGlobal += delegate(UserProfile u)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Expected O, but got Unknown
				if (u == localProfile)
				{
					BodyIndex bodyIndexFromSurvivorIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(u.survivorPreference.survivorIndex);
					SkinDef bodySkinDef2 = SkinCatalog.GetBodySkinDef(bodyIndexFromSurvivorIndex, (int)u.loadout.bodyLoadoutManager.GetSkinIndex(bodyIndexFromSurvivorIndex));
					if (oSkin.bodyIndex != bodyIndexFromSurvivorIndex || (Object)(object)oSkin.orig != (Object)(object)bodySkinDef2)
					{
						bodySkinDef2.Bake();
						oSkin = new OverlaySkin
						{
							orig = bodySkinDef2,
							bodyIndex = bodyIndexFromSurvivorIndex,
							minions = bodySkinDef2.minionSkinReplacements.ToList(),
							projectiles = bodySkinDef2.projectileGhostReplacements.ToList(),
							seperateMaterials = seperateMaterials.Value,
							rSkin = new RuntimeSkin
							{
								meshReplacementTemplates = ArrayUtils.Clone<MeshReplacementTemplate>(bodySkinDef2.runtimeSkin.meshReplacementTemplates),
								rendererInfoTemplates = ArrayUtils.Clone<RendererInfoTemplate>(bodySkinDef2.runtimeSkin.rendererInfoTemplates),
								gameObjectActivationTemplates = ArrayUtils.Clone<GameObjectActivationTemplate>(bodySkinDef2.runtimeSkin.gameObjectActivationTemplates)
							},
							syncInfo = new int[rowCountStore]
						};
						int num22 = 0;
						foreach (Row detailRow in detailRows)
						{
							int num23 = detailRow.buttons.FindIndex(delegate(MPButton b)
							{
								string overrideBodyText3 = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
								return overrideBodyText3.Contains(Language.GetString(oSkin.orig.nameToken));
							});
							if (num23 == -1 && oSkin.orig.baseSkins.Any())
							{
								num23 = detailRow.buttons.FindIndex(delegate(MPButton b)
								{
									string overrideBodyText2 = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
									return overrideBodyText2.Contains(Language.GetString(oSkin.orig.baseSkins.Last().nameToken));
								});
							}
							if (num23 != -1)
							{
								oSkin.syncInfo[rowCountStore - 1 - num22] = num23;
								detailRow.UpdateHighlightedChoice();
							}
							num22++;
						}
					}
				}
			};
			LoadoutPanelController.Rebuild += (hook_Rebuild)delegate(orig_Rebuild orig, LoadoutPanelController self)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0252: Unknown result type (might be due to invalid IL or missing references)
				//IL_028d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0292: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02dc: Expected O, but got Unknown
				//IL_0c48: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c5e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c68: Expected O, but got Unknown
				//IL_033d: Unknown result type (might be due to invalid IL or missing references)
				//IL_035d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0367: Expected O, but got Unknown
				//IL_0d42: Unknown result type (might be due to invalid IL or missing references)
				//IL_0d4f: Unknown result type (might be due to invalid IL or missing references)
				//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0807: Expected O, but got Unknown
				//IL_1130: Unknown result type (might be due to invalid IL or missing references)
				//IL_1146: Unknown result type (might be due to invalid IL or missing references)
				//IL_1150: Expected O, but got Unknown
				//IL_115c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0d88: Expected O, but got Unknown
				//IL_1220: Unknown result type (might be due to invalid IL or missing references)
				//IL_122d: Unknown result type (might be due to invalid IL or missing references)
				//IL_049d: Unknown result type (might be due to invalid IL or missing references)
				//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_1266: Expected O, but got Unknown
				//IL_145b: Unknown result type (might be due to invalid IL or missing references)
				//IL_1471: Unknown result type (might be due to invalid IL or missing references)
				//IL_147b: Expected O, but got Unknown
				//IL_04e3: Expected O, but got Unknown
				//IL_1352: Unknown result type (might be due to invalid IL or missing references)
				//IL_135f: Unknown result type (might be due to invalid IL or missing references)
				//IL_151e: Unknown result type (might be due to invalid IL or missing references)
				//IL_152b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0583: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_064a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0657: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_070b: Unknown result type (might be due to invalid IL or missing references)
				//IL_071c: Expected O, but got Unknown
				//IL_0971: Unknown result type (might be due to invalid IL or missing references)
				//IL_097e: Unknown result type (might be due to invalid IL or missing references)
				//IL_1391: Expected O, but got Unknown
				//IL_1564: Expected O, but got Unknown
				//IL_0f9b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0fa8: Unknown result type (might be due to invalid IL or missing references)
				//IL_104f: Unknown result type (might be due to invalid IL or missing references)
				//IL_105c: Unknown result type (might be due to invalid IL or missing references)
				//IL_106d: Expected O, but got Unknown
				//IL_1650: Unknown result type (might be due to invalid IL or missing references)
				//IL_165d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0689: Expected O, but got Unknown
				//IL_09b7: Expected O, but got Unknown
				//IL_0aa3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0fda: Expected O, but got Unknown
				//IL_168f: Expected O, but got Unknown
				//IL_0b57: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b64: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b75: Expected O, but got Unknown
				//IL_0ae2: Expected O, but got Unknown
				orig.Invoke(self);
				if ((int)self.currentDisplayData.bodyIndex != -1)
				{
					localProfile = self.currentDisplayData.userProfile;
					SurvivorMannequinSlotController diorama = GameObject.Find("SurvivorMannequinDiorama").GetComponent<SurvivorMannequinDioramaController>().mannequinSlots[0];
					SkinDef[] skins = SkinCatalog.GetBodySkinDefs(self.currentDisplayData.bodyIndex);
					IEnumerable<Renderer> enumerable5 = (from m in skins.SelectMany((SkinDef s) => s.meshReplacements)
						select m.renderer).Distinct();
					IEnumerable<Renderer> enumerable6 = (from i in skins.SelectMany((SkinDef s) => s.rendererInfos)
						select i.renderer).Distinct();
					IEnumerable<GameObject> enumerable7 = (from m in skins.SelectMany((SkinDef s) => s.minionSkinReplacements)
						select m.minionBodyPrefab).Distinct();
					IEnumerable<GameObject> enumerable8 = (from p in skins.SelectMany((SkinDef s) => s.projectileGhostReplacements)
						select p.projectilePrefab).Distinct();
					SkinDef bodySkinDef = SkinCatalog.GetBodySkinDef(self.currentDisplayData.bodyIndex, (int)self.currentDisplayData.userProfile.loadout.bodyLoadoutManager.GetSkinIndex(self.currentDisplayData.bodyIndex));
					int num10 = 0;
					bool flag = false;
					if (oSkin.bodyIndex != self.currentDisplayData.bodyIndex || (Object)(object)oSkin.orig != (Object)(object)bodySkinDef)
					{
						bodySkinDef.Bake();
						flag = true;
						oSkin = new OverlaySkin
						{
							orig = bodySkinDef,
							bodyIndex = self.currentDisplayData.bodyIndex,
							seperateMaterials = seperateMaterials.Value,
							minions = bodySkinDef.minionSkinReplacements.ToList(),
							projectiles = bodySkinDef.projectileGhostReplacements.ToList(),
							rSkin = new RuntimeSkin
							{
								meshReplacementTemplates = ArrayUtils.Clone<MeshReplacementTemplate>(bodySkinDef.runtimeSkin.meshReplacementTemplates),
								rendererInfoTemplates = ArrayUtils.Clone<RendererInfoTemplate>(bodySkinDef.runtimeSkin.rendererInfoTemplates),
								gameObjectActivationTemplates = ArrayUtils.Clone<GameObjectActivationTemplate>(bodySkinDef.runtimeSkin.gameObjectActivationTemplates)
							}
						};
					}
					if (seperateMaterials.Value)
					{
						foreach (Renderer mesh in enumerable5)
						{
							Row row5 = new Row(self, self.currentDisplayData.bodyIndex, ((Object)mesh).name + " Mesh");
							int locRowCount5 = num10;
							int num11 = 0;
							string text = string.Empty;
							foreach (SkinDef item in skins.Where((SkinDef s) => s.gameObjectActivations.Contains(new GameObjectActivation
							{
								gameObject = ((Component)mesh).gameObject,
								shouldActivate = false
							})))
							{
								text = text + Language.GetString(item.nameToken) + "\n";
							}
							if (!skins[0].meshReplacements.Any((MeshReplacement m) => (Object)(object)m.mesh == (Object)(object)mesh))
							{
								Row obj7 = row5;
								Sprite obj8 = skins[0].icon;
								string nameToken = skins[0].nameToken;
								string nameToken2 = skins[0].nameToken;
								Color primaryColor = row5.primaryColor;
								UnityAction val17 = delegate
								{
									//IL_013a: Unknown result type (might be due to invalid IL or missing references)
									//IL_0155: Unknown result type (might be due to invalid IL or missing references)
									//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
									//IL_010f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0173: Unknown result type (might be due to invalid IL or missing references)
									string path12 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)mesh).transform, false, false);
									List<MeshReplacementTemplate> list13 = oSkin.rSkin.meshReplacementTemplates.ToList();
									list13.RemoveAll((MeshReplacementTemplate m) => m.path == path12);
									oSkin.rSkin.meshReplacementTemplates = list13.ToArray();
									oSkin.syncInfo[locRowCount5] = 0;
									if (skins[0].gameObjectActivations.Any((GameObjectActivation g) => (Object)(object)g.gameObject == (Object)(object)mesh))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates14 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val44 = new GameObjectActivationTemplate
										{
											path = path12,
											shouldActivate = skins[0].gameObjectActivations.First((GameObjectActivation a) => (Object)(object)a.gameObject == (Object)(object)mesh).shouldActivate
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates14, ref val44);
									}
									else if (oSkin.rSkin.gameObjectActivationTemplates.Contains(new GameObjectActivationTemplate
									{
										path = path12,
										shouldActivate = false
									}))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates15 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val44 = new GameObjectActivationTemplate
										{
											path = path12,
											shouldActivate = true
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates15, ref val44);
									}
									row5.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								};
								UnlockableDef unlockableDef = skins[0].unlockableDef;
								obj7.AddButton(self, obj8, nameToken, nameToken2, primaryColor, val17, ((unlockableDef != null) ? unlockableDef.cachedName : null) ?? "", (Node)null, false);
								num11++;
							}
							foreach (SkinDef skin5 in skins.Where((SkinDef s) => s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)mesh)))
							{
								if (skin5.meshReplacements.Contains(new MeshReplacement
								{
									mesh = null,
									renderer = mesh
								}))
								{
									text = text + Language.GetString(skin5.nameToken) + "\n";
									num11++;
								}
								else
								{
									int locCount8 = num11;
									Row obj9 = row5;
									Sprite obj10 = skin5.icon;
									string nameToken3 = skin5.nameToken;
									string nameToken4 = skin5.nameToken;
									Color primaryColor2 = row5.primaryColor;
									UnityAction val18 = delegate
									{
										//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
										//IL_012e: Unknown result type (might be due to invalid IL or missing references)
										//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
										//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
										//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
										//IL_0302: Unknown result type (might be due to invalid IL or missing references)
										//IL_0266: Unknown result type (might be due to invalid IL or missing references)
										string path11 = Util.BuildPrefabTransformPath(skin5.rootObject.transform, ((Component)mesh).transform, false, false);
										if (skin5.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)mesh))
										{
											ref MeshReplacementTemplate[] meshReplacementTemplates10 = ref oSkin.rSkin.meshReplacementTemplates;
											MeshReplacementTemplate val42 = new MeshReplacementTemplate
											{
												path = path11,
												mesh = skin5.meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)mesh).mesh
											};
											ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates10, ref val42);
										}
										else if (skin5.baseSkins.Any() && skin5.baseSkins.Last().meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)mesh))
										{
											ref MeshReplacementTemplate[] meshReplacementTemplates11 = ref oSkin.rSkin.meshReplacementTemplates;
											MeshReplacementTemplate val42 = new MeshReplacementTemplate
											{
												path = path11,
												mesh = skin5.baseSkins.Last().meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)mesh).mesh
											};
											ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates11, ref val42);
										}
										else
										{
											List<MeshReplacementTemplate> list12 = oSkin.rSkin.meshReplacementTemplates.ToList();
											list12.RemoveAll((MeshReplacementTemplate m) => m.path == path11);
											oSkin.rSkin.meshReplacementTemplates = list12.ToArray();
										}
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates13 = ref oSkin.rSkin.gameObjectActivationTemplates;
										if (gameObjectActivationTemplates13.Contains(new GameObjectActivationTemplate
										{
											path = path11,
											shouldActivate = false
										}))
										{
											GameObjectActivationTemplate val43 = new GameObjectActivationTemplate
											{
												path = path11,
												shouldActivate = true
											};
											ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates13, ref val43);
										}
										oSkin.syncInfo[locRowCount5] = locCount8;
										row5.UpdateHighlightedChoice();
										diorama.loadoutDirty = true;
									};
									UnlockableDef unlockableDef2 = skin5.unlockableDef;
									obj9.AddButton(self, obj10, nameToken3, nameToken4, primaryColor2, val18, ((unlockableDef2 != null) ? unlockableDef2.cachedName : null) ?? "", (Node)null, false);
									num11++;
								}
							}
							if (text != string.Empty)
							{
								int locCount7 = num11;
								row5.AddButton(self, icon, "Disabled", text, row5.primaryColor, (UnityAction)delegate
								{
									//IL_0050: Unknown result type (might be due to invalid IL or missing references)
									string path10 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)mesh).transform, false, false);
									ref MeshReplacementTemplate[] meshReplacementTemplates9 = ref oSkin.rSkin.meshReplacementTemplates;
									MeshReplacementTemplate val41 = new MeshReplacementTemplate
									{
										path = path10,
										mesh = null
									};
									ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates9, ref val41);
									oSkin.syncInfo[locRowCount5] = locCount7;
									row5.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								}, "", (Node)null, false);
							}
							row5.findCurrentChoice = (Loadout l) => oSkin.FindIndex(locRowCount5);
							row5.FinishSetup(false);
							if (num11 > 1)
							{
								self.rows.Add(row5);
								num10++;
							}
							else
							{
								row5.Dispose();
							}
						}
						foreach (Renderer info in enumerable6)
						{
							Row row4 = new Row(self, self.currentDisplayData.bodyIndex, ((Object)info).name + " Material");
							int num12 = 0;
							int locRowCount4 = num10;
							string text2 = string.Empty;
							foreach (SkinDef item2 in skins.Where((SkinDef s) => s.gameObjectActivations.Contains(new GameObjectActivation
							{
								gameObject = ((Component)info).gameObject,
								shouldActivate = false
							})))
							{
								text2 = text2 + Language.GetString(item2.nameToken) + "\n";
							}
							if (!skins[0].meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)info) && !skins[0].rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)info))
							{
								Row obj11 = row4;
								Sprite obj12 = skins[0].icon;
								string nameToken5 = skins[0].nameToken;
								string nameToken6 = skins[0].nameToken;
								Color primaryColor3 = row4.primaryColor;
								UnityAction val19 = delegate
								{
									//IL_013a: Unknown result type (might be due to invalid IL or missing references)
									//IL_0155: Unknown result type (might be due to invalid IL or missing references)
									//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
									//IL_010f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0173: Unknown result type (might be due to invalid IL or missing references)
									string path9 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)info).transform, false, false);
									List<MeshReplacementTemplate> list11 = oSkin.rSkin.meshReplacementTemplates.ToList();
									list11.RemoveAll((MeshReplacementTemplate m) => m.path == path9);
									oSkin.rSkin.meshReplacementTemplates = list11.ToArray();
									oSkin.syncInfo[locRowCount4] = 0;
									if (skins[0].gameObjectActivations.Any((GameObjectActivation g) => (Object)(object)g.gameObject == (Object)(object)info))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates11 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val40 = new GameObjectActivationTemplate
										{
											path = path9,
											shouldActivate = skins[0].gameObjectActivations.First((GameObjectActivation a) => (Object)(object)a.gameObject == (Object)(object)info).shouldActivate
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates11, ref val40);
									}
									else if (oSkin.rSkin.gameObjectActivationTemplates.Contains(new GameObjectActivationTemplate
									{
										path = path9,
										shouldActivate = false
									}))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates12 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val40 = new GameObjectActivationTemplate
										{
											path = path9,
											shouldActivate = true
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates12, ref val40);
									}
									row4.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								};
								UnlockableDef unlockableDef3 = skins[0].unlockableDef;
								obj11.AddButton(self, obj12, nameToken5, nameToken6, primaryColor3, val19, ((unlockableDef3 != null) ? unlockableDef3.cachedName : null) ?? "", (Node)null, false);
								num12++;
							}
							foreach (SkinDef skin4 in skins.Where((SkinDef s) => s.rendererInfos.Any((RendererInfo i) => (Object)(object)i.renderer == (Object)(object)info)))
							{
								int locCount6 = num12;
								Row obj13 = row4;
								Sprite obj14 = skin4.icon;
								string nameToken7 = skin4.nameToken;
								string nameToken8 = skin4.nameToken;
								Color primaryColor4 = row4.primaryColor;
								UnityAction val20 = delegate
								{
									//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_00db: Unknown result type (might be due to invalid IL or missing references)
									//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
									//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
									//IL_0107: Unknown result type (might be due to invalid IL or missing references)
									//IL_0114: Unknown result type (might be due to invalid IL or missing references)
									//IL_0121: Unknown result type (might be due to invalid IL or missing references)
									//IL_012e: Unknown result type (might be due to invalid IL or missing references)
									//IL_012f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0134: Unknown result type (might be due to invalid IL or missing references)
									//IL_0139: Unknown result type (might be due to invalid IL or missing references)
									//IL_013b: Unknown result type (might be due to invalid IL or missing references)
									//IL_017f: Unknown result type (might be due to invalid IL or missing references)
									//IL_019a: Unknown result type (might be due to invalid IL or missing references)
									//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
									RendererInfo val37 = skin4.rendererInfos.First((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)info);
									string path8 = Util.BuildPrefabTransformPath(skin4.rootObject.transform, ((Component)info).transform, false, false);
									ref RendererInfoTemplate[] rendererInfoTemplates5 = ref oSkin.rSkin.rendererInfoTemplates;
									int num20 = Array.FindIndex(rendererInfoTemplates5, (RendererInfoTemplate r) => r.path == path8);
									num20 = ((num20 == -1) ? rendererInfoTemplates5.Length : num20);
									int num21 = num20;
									RendererInfoTemplate val38 = new RendererInfoTemplate
									{
										path = path8,
										data = new RendererInfo
										{
											defaultMaterial = val37.defaultMaterial,
											hideOnDeath = val37.hideOnDeath,
											renderer = val37.renderer,
											ignoreOverlays = val37.ignoreOverlays,
											defaultShadowCastingMode = val37.defaultShadowCastingMode
										}
									};
									ArrayUtils.ArrayInsert<RendererInfoTemplate>(ref rendererInfoTemplates5, num21, ref val38);
									oSkin.syncInfo[locRowCount4] = locCount6;
									ref GameObjectActivationTemplate[] gameObjectActivationTemplates10 = ref oSkin.rSkin.gameObjectActivationTemplates;
									if (gameObjectActivationTemplates10.Contains(new GameObjectActivationTemplate
									{
										path = path8,
										shouldActivate = false
									}))
									{
										GameObjectActivationTemplate val39 = new GameObjectActivationTemplate
										{
											path = path8,
											shouldActivate = true
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates10, ref val39);
									}
									row4.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								};
								UnlockableDef unlockableDef4 = skin4.unlockableDef;
								obj13.AddButton(self, obj14, nameToken7, nameToken8, primaryColor4, val20, ((unlockableDef4 != null) ? unlockableDef4.cachedName : null) ?? "", (Node)null, false);
								num12++;
							}
							if (text2 != string.Empty)
							{
								int locCount5 = num12;
								row4.AddButton(self, icon, "Disabled", text2, row4.primaryColor, (UnityAction)delegate
								{
									//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
									//IL_007f: Unknown result type (might be due to invalid IL or missing references)
									string path7 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)info).transform, false, false);
									Renderer component2 = ((Component)info).GetComponent<Renderer>();
									if (component2 is MeshRenderer || component2 is SkinnedMeshRenderer)
									{
										ref MeshReplacementTemplate[] meshReplacementTemplates8 = ref oSkin.rSkin.meshReplacementTemplates;
										MeshReplacementTemplate val35 = new MeshReplacementTemplate
										{
											path = path7,
											mesh = null
										};
										ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates8, ref val35);
									}
									else
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates9 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val36 = new GameObjectActivationTemplate
										{
											path = path7,
											shouldActivate = false
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates9, ref val36);
									}
									oSkin.syncInfo[locRowCount4] = locCount5;
									row4.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								}, "", (Node)null, false);
							}
							row4.findCurrentChoice = (Loadout l) => oSkin.FindIndex(locRowCount4);
							row4.FinishSetup(false);
							if (num12 > 1)
							{
								self.rows.Add(row4);
								num10++;
							}
							else
							{
								row4.Dispose();
							}
						}
					}
					else
					{
						foreach (Renderer renderer4 in enumerable5.Concat(enumerable6).Distinct())
						{
							Row row3 = new Row(self, self.currentDisplayData.bodyIndex, ((Object)renderer4).name);
							int num13 = 0;
							int locRowCount3 = num10;
							string text3 = string.Empty;
							if (!skins[0].meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4) && !skins[0].rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)renderer4))
							{
								Row obj15 = row3;
								Sprite obj16 = skins[0].icon;
								string nameToken9 = skins[0].nameToken;
								string nameToken10 = skins[0].nameToken;
								Color primaryColor5 = row3.primaryColor;
								UnityAction val21 = delegate
								{
									//IL_013a: Unknown result type (might be due to invalid IL or missing references)
									//IL_0155: Unknown result type (might be due to invalid IL or missing references)
									//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
									//IL_010f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0173: Unknown result type (might be due to invalid IL or missing references)
									string path6 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)renderer4).transform, false, false);
									List<MeshReplacementTemplate> list10 = oSkin.rSkin.meshReplacementTemplates.ToList();
									list10.RemoveAll((MeshReplacementTemplate m) => m.path == path6);
									oSkin.rSkin.meshReplacementTemplates = list10.ToArray();
									oSkin.syncInfo[locRowCount3] = 0;
									if (skins[0].gameObjectActivations.Any((GameObjectActivation g) => (Object)(object)g.gameObject == (Object)(object)renderer4))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates7 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val34 = new GameObjectActivationTemplate
										{
											path = path6,
											shouldActivate = skins[0].gameObjectActivations.First((GameObjectActivation a) => (Object)(object)a.gameObject == (Object)(object)renderer4).shouldActivate
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates7, ref val34);
									}
									else if (oSkin.rSkin.gameObjectActivationTemplates.Contains(new GameObjectActivationTemplate
									{
										path = path6,
										shouldActivate = false
									}))
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates8 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val34 = new GameObjectActivationTemplate
										{
											path = path6,
											shouldActivate = true
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates8, ref val34);
									}
									row3.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								};
								UnlockableDef unlockableDef5 = skins[0].unlockableDef;
								obj15.AddButton(self, obj16, nameToken9, nameToken10, primaryColor5, val21, ((unlockableDef5 != null) ? unlockableDef5.cachedName : null) ?? "", (Node)null, false);
								num13++;
							}
							foreach (SkinDef item3 in skins.Where((SkinDef s) => s.gameObjectActivations.Contains(new GameObjectActivation
							{
								gameObject = ((Component)renderer4).gameObject,
								shouldActivate = false
							})))
							{
								text3 = text3 + Language.GetString(item3.nameToken) + "\n";
							}
							foreach (SkinDef skin3 in skins.Where((SkinDef s) => s.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4) || s.rendererInfos.Any((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)renderer4)))
							{
								if (skin3.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4 && (Object)(object)m.mesh == (Object)null))
								{
									text3 = text3 + Language.GetString(skin3.nameToken) + "\n";
								}
								else
								{
									int locCount4 = num13;
									Row obj17 = row3;
									Sprite obj18 = skin3.icon;
									string nameToken11 = skin3.nameToken;
									string nameToken12 = skin3.nameToken;
									Color primaryColor6 = row3.primaryColor;
									UnityAction val22 = delegate
									{
										//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
										//IL_012e: Unknown result type (might be due to invalid IL or missing references)
										//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
										//IL_0266: Unknown result type (might be due to invalid IL or missing references)
										//IL_0468: Unknown result type (might be due to invalid IL or missing references)
										//IL_0483: Unknown result type (might be due to invalid IL or missing references)
										//IL_0494: Unknown result type (might be due to invalid IL or missing references)
										//IL_038d: Unknown result type (might be due to invalid IL or missing references)
										//IL_0392: Unknown result type (might be due to invalid IL or missing references)
										//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
										//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
										//IL_0400: Unknown result type (might be due to invalid IL or missing references)
										//IL_040e: Unknown result type (might be due to invalid IL or missing references)
										//IL_041c: Unknown result type (might be due to invalid IL or missing references)
										//IL_042a: Unknown result type (might be due to invalid IL or missing references)
										//IL_0438: Unknown result type (might be due to invalid IL or missing references)
										//IL_043a: Unknown result type (might be due to invalid IL or missing references)
										//IL_043f: Unknown result type (might be due to invalid IL or missing references)
										//IL_0444: Unknown result type (might be due to invalid IL or missing references)
										//IL_0446: Unknown result type (might be due to invalid IL or missing references)
										string path5 = Util.BuildPrefabTransformPath(skin3.rootObject.transform, ((Component)renderer4).transform, false, false);
										if (skin3.meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4))
										{
											ref MeshReplacementTemplate[] meshReplacementTemplates6 = ref oSkin.rSkin.meshReplacementTemplates;
											MeshReplacementTemplate val30 = new MeshReplacementTemplate
											{
												path = path5,
												mesh = skin3.meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4).mesh
											};
											ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates6, ref val30);
										}
										else if (skin3.baseSkins.Any() && skin3.baseSkins.Last().meshReplacements.Any((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4))
										{
											ref MeshReplacementTemplate[] meshReplacementTemplates7 = ref oSkin.rSkin.meshReplacementTemplates;
											MeshReplacementTemplate val30 = new MeshReplacementTemplate
											{
												path = path5,
												mesh = skin3.baseSkins.Last().meshReplacements.First((MeshReplacement m) => (Object)(object)m.renderer == (Object)(object)renderer4).mesh
											};
											ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates7, ref val30);
										}
										else
										{
											List<MeshReplacementTemplate> list9 = oSkin.rSkin.meshReplacementTemplates.ToList();
											list9.RemoveAll((MeshReplacementTemplate m) => m.path == path5);
											oSkin.rSkin.meshReplacementTemplates = list9.ToArray();
										}
										if (skin3.rendererInfos.Any((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)renderer4))
										{
											RendererInfo val31 = skin3.rendererInfos.First((RendererInfo m) => (Object)(object)m.renderer == (Object)(object)renderer4);
											int num18 = Array.FindIndex(oSkin.rSkin.rendererInfoTemplates, (RendererInfoTemplate r) => r.path == path5);
											ref RendererInfoTemplate[] rendererInfoTemplates4 = ref oSkin.rSkin.rendererInfoTemplates;
											int num19 = ((num18 == -1) ? oSkin.rSkin.rendererInfoTemplates.Length : num18);
											RendererInfoTemplate val32 = new RendererInfoTemplate
											{
												path = path5,
												data = new RendererInfo
												{
													defaultMaterial = val31.defaultMaterial,
													hideOnDeath = val31.hideOnDeath,
													renderer = val31.renderer,
													ignoreOverlays = val31.ignoreOverlays,
													defaultShadowCastingMode = val31.defaultShadowCastingMode
												}
											};
											ArrayUtils.ArrayInsert<RendererInfoTemplate>(ref rendererInfoTemplates4, num19, ref val32);
										}
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates6 = ref oSkin.rSkin.gameObjectActivationTemplates;
										if (gameObjectActivationTemplates6.Contains(new GameObjectActivationTemplate
										{
											path = path5,
											shouldActivate = false
										}))
										{
											GameObjectActivationTemplate val33 = new GameObjectActivationTemplate
											{
												path = path5,
												shouldActivate = true
											};
											ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates6, ref val33);
										}
										diorama.loadoutDirty = true;
										oSkin.syncInfo[locRowCount3] = locCount4;
										row3.UpdateHighlightedChoice();
									};
									UnlockableDef unlockableDef6 = skin3.unlockableDef;
									obj17.AddButton(self, obj18, nameToken11, nameToken12, primaryColor6, val22, ((unlockableDef6 != null) ? unlockableDef6.cachedName : null) ?? "", (Node)null, false);
									num13++;
								}
							}
							if (text3 != string.Empty)
							{
								int locCount3 = num13;
								row3.AddButton(self, icon, "Disabled", text3, row3.primaryColor, (UnityAction)delegate
								{
									//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
									//IL_007f: Unknown result type (might be due to invalid IL or missing references)
									string path4 = Util.BuildPrefabTransformPath(skins[0].rootObject.transform, ((Component)renderer4).transform, false, false);
									Renderer component = ((Component)renderer4).GetComponent<Renderer>();
									if (component is MeshRenderer || component is SkinnedMeshRenderer)
									{
										ref MeshReplacementTemplate[] meshReplacementTemplates5 = ref oSkin.rSkin.meshReplacementTemplates;
										MeshReplacementTemplate val28 = new MeshReplacementTemplate
										{
											path = path4,
											mesh = null
										};
										ArrayUtils.ArrayAppend<MeshReplacementTemplate>(ref meshReplacementTemplates5, ref val28);
									}
									else
									{
										ref GameObjectActivationTemplate[] gameObjectActivationTemplates5 = ref oSkin.rSkin.gameObjectActivationTemplates;
										GameObjectActivationTemplate val29 = new GameObjectActivationTemplate
										{
											path = path4,
											shouldActivate = false
										};
										ArrayUtils.ArrayAppend<GameObjectActivationTemplate>(ref gameObjectActivationTemplates5, ref val29);
									}
									oSkin.syncInfo[locRowCount3] = locCount3;
									row3.UpdateHighlightedChoice();
									diorama.loadoutDirty = true;
								}, "", (Node)null, false);
							}
							row3.findCurrentChoice = (Loadout l) => oSkin.FindIndex(locRowCount3);
							row3.FinishSetup(false);
							if (num13 > 1)
							{
								self.rows.Add(row3);
								num10++;
							}
							else
							{
								row3.Dispose();
							}
						}
					}
					foreach (GameObject minion2 in enumerable7)
					{
						Row row2 = new Row(self, self.currentDisplayData.bodyIndex, Util.GetBestBodyName(minion2));
						string bodyName = BodyCatalog.GetBodyName(BodyCatalog.FindBodyIndex(minion2));
						int num14 = 0;
						int locRowCount2 = num10;
						row2.findCurrentChoice = (Loadout l) => oSkin.FindIndex(locRowCount2);
						if (!skins[0].minionSkinReplacements.Any((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)minion2))
						{
							Row obj19 = row2;
							Sprite obj20 = skins[0].icon;
							string nameToken13 = skins[0].nameToken;
							string nameToken14 = skins[0].nameToken;
							Color primaryColor7 = row2.primaryColor;
							UnityAction val23 = delegate
							{
								oSkin.minions.RemoveAll((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)minion2);
								oSkin.syncInfo[locRowCount2] = 0;
								row2.UpdateHighlightedChoice();
								diorama.loadoutDirty = true;
							};
							UnlockableDef unlockableDef7 = skins[0].unlockableDef;
							obj19.AddButton(self, obj20, nameToken13, nameToken14, primaryColor7, val23, ((unlockableDef7 != null) ? unlockableDef7.cachedName : null) ?? "", (Node)null, false);
							num14++;
						}
						foreach (SkinDef skin2 in skins.Where((SkinDef s) => s.minionSkinReplacements.Any((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)minion2)))
						{
							int locCount2 = num14;
							Row obj21 = row2;
							Sprite obj22 = skin2.icon;
							string nameToken15 = skin2.nameToken;
							string nameToken16 = skin2.nameToken;
							Color primaryColor8 = row2.primaryColor;
							UnityAction val24 = delegate
							{
								//IL_0067: Unknown result type (might be due to invalid IL or missing references)
								oSkin.minions.Add(skin2.minionSkinReplacements.First((MinionSkinReplacement m) => (Object)(object)m.minionBodyPrefab == (Object)(object)minion2));
								oSkin.syncInfo[locRowCount2] = locCount2;
								row2.UpdateHighlightedChoice();
								diorama.loadoutDirty = true;
							};
							UnlockableDef unlockableDef8 = skin2.unlockableDef;
							obj21.AddButton(self, obj22, nameToken15, nameToken16, primaryColor8, val24, ((unlockableDef8 != null) ? unlockableDef8.cachedName : null) ?? "", (Node)null, false);
							num14++;
						}
						row2.FinishSetup(false);
						if (num14 > 1)
						{
							self.rows.Add(row2);
							num10++;
						}
						else
						{
							row2.Dispose();
						}
					}
					foreach (GameObject proj2 in enumerable8)
					{
						Row row = new Row(self, self.currentDisplayData.bodyIndex, ((Object)proj2).name);
						int num15 = 0;
						int locRowCount = num10;
						if (!skins[0].projectileGhostReplacements.Any((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)proj2))
						{
							int num16 = num15;
							Row obj23 = row;
							Sprite obj24 = skins[0].icon;
							string nameToken17 = skins[0].nameToken;
							string nameToken18 = skins[0].nameToken;
							Color primaryColor9 = row.primaryColor;
							UnityAction val25 = delegate
							{
								oSkin.projectiles.RemoveAll((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)proj2);
								oSkin.syncInfo[locRowCount] = 0;
								row.UpdateHighlightedChoice();
								diorama.loadoutDirty = true;
							};
							UnlockableDef unlockableDef9 = skins[0].unlockableDef;
							obj23.AddButton(self, obj24, nameToken17, nameToken18, primaryColor9, val25, ((unlockableDef9 != null) ? unlockableDef9.cachedName : null) ?? "", (Node)null, false);
							num15++;
						}
						foreach (SkinDef skin in skins.Where((SkinDef s) => s.projectileGhostReplacements.Any((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)proj2)))
						{
							int locCount = num15;
							Row obj25 = row;
							Sprite obj26 = skin.icon;
							string nameToken19 = skin.nameToken;
							string nameToken20 = skin.nameToken;
							Color primaryColor10 = row.primaryColor;
							UnityAction val26 = delegate
							{
								//IL_0067: Unknown result type (might be due to invalid IL or missing references)
								oSkin.projectiles.Add(skin.projectileGhostReplacements.First((ProjectileGhostReplacement p) => (Object)(object)p.projectilePrefab == (Object)(object)proj2));
								oSkin.syncInfo[locRowCount] = locCount;
								row.UpdateHighlightedChoice();
								diorama.loadoutDirty = true;
							};
							UnlockableDef unlockableDef10 = skin.unlockableDef;
							obj25.AddButton(self, obj26, nameToken19, nameToken20, primaryColor10, val26, ((unlockableDef10 != null) ? unlockableDef10.cachedName : null) ?? "", (Node)null, false);
							num15++;
						}
						row.findCurrentChoice = (Loadout l) => oSkin.FindIndex(locRowCount);
						row.FinishSetup(false);
						if (num15 > 1)
						{
							self.rows.Add(row);
							num10++;
						}
						else
						{
							row.Dispose();
						}
					}
					rowCountStore = num10;
					detailRows.Clear();
					oSkin.syncInfo = new int[num10];
					self.rows.Reverse();
					for (int n = 0; n < num10; n++)
					{
						Row val27 = self.rows[n];
						detailRows.Add(val27);
						if (flag)
						{
							int num17 = val27.buttons.FindIndex(delegate(MPButton b)
							{
								string overrideBodyText = ((Component)b).GetComponent<TooltipProvider>().overrideBodyText;
								return overrideBodyText.Contains(Language.GetString(oSkin.orig.nameToken));
							});
							if (num17 != -1)
							{
								oSkin.syncInfo[num10 - 1 - n] = num17;
								val27.UpdateHighlightedChoice();
							}
						}
					}
					self.currentDisplayData.userProfile.OnLoadoutChanged();
				}
			};
			object obj4 = <>c.<>9__12_5;
			if (obj4 == null)
			{
				hook_Serialize val4 = delegate(orig_Serialize orig, Loadout self, NetworkWriter writer)
				{
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0044: Expected I4, but got Unknown
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, writer);
					OverlaySkin orCreateValue2 = networkOSkins.GetOrCreateValue(self);
					if ((Object)(object)orCreateValue2.orig == (Object)null)
					{
						writer.Write(-1);
					}
					else
					{
						writer.Write((int)orCreateValue2.orig.skinIndex);
						NetworkExtensions.WriteBodyIndex(writer, orCreateValue2.bodyIndex);
						writer.Write(orCreateValue2.seperateMaterials);
						writer.Write(orCreateValue2.syncInfo.Length);
						int[] syncInfo = orCreateValue2.syncInfo;
						foreach (int num9 in syncInfo)
						{
							writer.Write(num9);
						}
					}
				};
				<>c.<>9__12_5 = val4;
				obj4 = (object)val4;
			}
			Loadout.Serialize += (hook_Serialize)obj4;
			object obj5 = <>c.<>9__12_6;
			if (obj5 == null)
			{
				hook_Deserialize val5 = delegate(orig_Deserialize orig, Loadout self, NetworkReader reader)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Invalid comparison between Unknown and I4
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_003b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0040: Unknown result type (might be due to invalid IL or missing references)
					//IL_0098: Unknown result type (might be due to invalid IL or missing references)
					//IL_009d: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f3: Expected O, but got Unknown
					//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
					//IL_0991: Unknown result type (might be due to invalid IL or missing references)
					//IL_039a: Unknown result type (might be due to invalid IL or missing references)
					//IL_09ff: Unknown result type (might be due to invalid IL or missing references)
					//IL_0a29: Unknown result type (might be due to invalid IL or missing references)
					//IL_0c55: Unknown result type (might be due to invalid IL or missing references)
					//IL_0408: Unknown result type (might be due to invalid IL or missing references)
					//IL_0432: Unknown result type (might be due to invalid IL or missing references)
					//IL_065e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0550: Unknown result type (might be due to invalid IL or missing references)
					//IL_056c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0481: Unknown result type (might be due to invalid IL or missing references)
					//IL_0486: Unknown result type (might be due to invalid IL or missing references)
					//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
					//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
					//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
					//IL_06db: Unknown result type (might be due to invalid IL or missing references)
					//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
					//IL_0ba0: Unknown result type (might be due to invalid IL or