Decompiled source of LuxMod v1.1.1

plugins/LuxMod.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using HG;
using HG.BlendableTypes;
using HG.GeneralSerializer;
using JetBrains.Annotations;
using LuxMod.Modules;
using LuxMod.Modules.Characters;
using LuxMod.Modules.LeagueSkins;
using LuxMod.Survivors.Lux;
using LuxMod.Survivors.Lux.Components;
using LuxMod.Survivors.Lux.SkillStates;
using LuxMod.Survivors.Lux.SkillStates.Emotes;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LuxMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+951d4279d51f725290c6d0f5d03fb60861b2fd75")]
[assembly: AssemblyProduct("LuxMod")]
[assembly: AssemblyTitle("LuxMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
namespace LuxMod
{
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Lemonlust.Lux", "Lux", "1.1.1")]
	public class LuxPlugin : BaseUnityPlugin
	{
		public const string MODUID = "com.Lemonlust.Lux";

		public const string MODNAME = "Lux";

		public const string MODVERSION = "1.1.1";

		public const string DEVELOPER_PREFIX = "LUX";

		public static LuxPlugin instance;

		private void Awake()
		{
			instance = this;
			Language.Init();
			new LuxSurvivor().Initialize();
			new ContentPacks().Initialize();
		}
	}
}
namespace LuxMod.Modules
{
	internal static class Asset
	{
		internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();

		internal static AssetBundle LoadAssetBundle(string bundleName)
		{
			if (bundleName == "myassetbundle")
			{
				return null;
			}
			if (loadedBundles.ContainsKey(bundleName))
			{
				return loadedBundles[bundleName];
			}
			AssetBundle val = null;
			try
			{
				val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)LuxPlugin.instance).Info.Location), "AssetBundles", bundleName));
			}
			catch
			{
			}
			loadedBundles[bundleName] = val;
			return val;
		}

		internal static void ConvertAllRenderersToHopooShader(GameObject objectToConvert)
		{
			if (!Object.op_Implicit((Object)(object)objectToConvert))
			{
				return;
			}
			MeshRenderer[] componentsInChildren = objectToConvert.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Renderer)val).sharedMaterial))
				{
					((Renderer)val).sharedMaterial.ConvertDefaultShaderToHopoo();
				}
			}
			SkinnedMeshRenderer[] componentsInChildren2 = objectToConvert.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
			{
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial))
				{
					((Renderer)val2).sharedMaterial.ConvertDefaultShaderToHopoo();
				}
			}
		}

		internal static GameObject LoadCrosshair(string crosshairName)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/" + crosshairName + "Crosshair");
			if ((Object)(object)val == (Object)null)
			{
				return LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/StandardCrosshair");
			}
			return val;
		}

		internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, bool parentToTransform)
		{
			return assetBundle.LoadEffect(resourceName, "", parentToTransform);
		}

		internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, string soundName = "", bool parentToTransform = false)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assetBundle.LoadAsset<GameObject>(resourceName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			val.AddComponent<DestroyOnTimer>().duration = 12f;
			val.AddComponent<NetworkIdentity>();
			VFXAttributes obj = val.AddComponent<VFXAttributes>();
			obj.vfxPriority = (VFXPriority)2;
			obj.DoNotPool = true;
			EffectComponent obj2 = val.AddComponent<EffectComponent>();
			obj2.applyScale = false;
			obj2.effectIndex = (EffectIndex)(-1);
			obj2.parentToReferencedTransform = parentToTransform;
			obj2.positionAtReferencedTransform = true;
			obj2.soundName = soundName;
			Content.CreateAndAddEffectDef(val);
			return val;
		}

		internal static GameObject CreateProjectileGhostPrefab(this AssetBundle assetBundle, string ghostName)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(ghostName);
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<ProjectileGhostController>()))
			{
				val.AddComponent<ProjectileGhostController>();
			}
			ConvertAllRenderersToHopooShader(val);
			return val;
		}

		internal static GameObject CloneProjectilePrefab(string prefabName, string newPrefabName)
		{
			return PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/" + prefabName), newPrefabName);
		}
	}
	public static class Config
	{
		public static ConfigFile MyConfig = ((BaseUnityPlugin)LuxPlugin.instance).Config;

		public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "")
		{
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			return MyConfig.Bind<T>(section, name, defaultValue, description);
		}

		public static ConfigEntry<float> BindAndOptions(string section, string name, float defaultValue, float min, float max, string description = "")
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			return MyConfig.Bind<float>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
		}
	}
	internal class Content
	{
		internal static void AddCharacterBodyPrefab(GameObject bprefab)
		{
			ContentPacks.bodyPrefabs.Add(bprefab);
		}

		internal static void AddProjectilePrefab(GameObject prefab)
		{
			ContentPacks.projectilePrefabs.Add(prefab);
		}

		internal static void AddSurvivorDef(SurvivorDef survivorDef)
		{
			ContentPacks.survivorDefs.Add(survivorDef);
		}

		internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, null, 100f);
		}

		internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, float sortPosition)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, null, sortPosition);
		}

		internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, UnlockableDef unlockableDef)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CreateSurvivor(bodyPrefab, displayPrefab, charColor, tokenPrefix, unlockableDef, 100f);
		}

		internal static void CreateSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string tokenPrefix, UnlockableDef unlockableDef, float sortPosition)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			SurvivorDef obj = ScriptableObject.CreateInstance<SurvivorDef>();
			obj.bodyPrefab = bodyPrefab;
			obj.displayPrefab = displayPrefab;
			obj.primaryColor = charColor;
			obj.cachedName = ((Object)bodyPrefab).name.Replace("Body", "");
			obj.displayNameToken = tokenPrefix + "NAME";
			obj.descriptionToken = tokenPrefix + "DESCRIPTION";
			obj.outroFlavorToken = tokenPrefix + "OUTRO_FLAVOR";
			obj.mainEndingEscapeFailureFlavorToken = tokenPrefix + "OUTRO_FAILURE";
			obj.desiredSortPosition = sortPosition;
			obj.unlockableDef = unlockableDef;
			AddSurvivorDef(obj);
		}

		internal static void AddSkillDef(SkillDef skillDef)
		{
			ContentPacks.skillDefs.Add(skillDef);
		}

		internal static void AddSkillFamily(SkillFamily skillFamily)
		{
			ContentPacks.skillFamilies.Add(skillFamily);
		}

		internal static void AddEntityState(Type entityState)
		{
			ContentPacks.entityStates.Add(entityState);
		}

		internal static void AddBuffDef(BuffDef buffDef)
		{
			ContentPacks.buffDefs.Add(buffDef);
		}

		internal static BuffDef CreateAndAddBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			BuffDef obj = ScriptableObject.CreateInstance<BuffDef>();
			((Object)obj).name = buffName;
			obj.buffColor = buffColor;
			obj.canStack = canStack;
			obj.isDebuff = isDebuff;
			obj.eliteDef = null;
			obj.iconSprite = buffIcon;
			AddBuffDef(obj);
			return obj;
		}

		internal static void AddEffectDef(EffectDef effectDef)
		{
			ContentPacks.effectDefs.Add(effectDef);
		}

		internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000d: Expected O, but got Unknown
			EffectDef val = new EffectDef(effectPrefab);
			AddEffectDef(val);
			return val;
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public static List<GameObject> bodyPrefabs = new List<GameObject>();

		public static List<GameObject> masterPrefabs = new List<GameObject>();

		public static List<GameObject> projectilePrefabs = new List<GameObject>();

		public static List<SurvivorDef> survivorDefs = new List<SurvivorDef>();

		public static List<UnlockableDef> unlockableDefs = new List<UnlockableDef>();

		public static List<SkillFamily> skillFamilies = new List<SkillFamily>();

		public static List<SkillDef> skillDefs = new List<SkillDef>();

		public static List<Type> entityStates = new List<Type>();

		public static List<BuffDef> buffDefs = new List<BuffDef>();

		public static List<EffectDef> effectDefs = new List<EffectDef>();

		public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>();

		public string identifier => "com.Lemonlust.Lux";

		public void Initialize()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray());
			contentPack.masterPrefabs.Add(masterPrefabs.ToArray());
			contentPack.projectilePrefabs.Add(projectilePrefabs.ToArray());
			contentPack.survivorDefs.Add(survivorDefs.ToArray());
			contentPack.unlockableDefs.Add(unlockableDefs.ToArray());
			contentPack.skillDefs.Add(skillDefs.ToArray());
			contentPack.skillFamilies.Add(skillFamilies.ToArray());
			contentPack.entityStateTypes.Add(entityStates.ToArray());
			contentPack.buffDefs.Add(buffDefs.ToArray());
			contentPack.effectDefs.Add(effectDefs.ToArray());
			contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	internal static class ItemDisplays
	{
		private static Dictionary<string, GameObject> itemDisplayPrefabs = new Dictionary<string, GameObject>();

		public static Dictionary<Object, ItemDisplayRule[]> KeyAssetDisplayPrefabs = new Dictionary<Object, ItemDisplayRule[]>();

		public static Dictionary<string, Object> KeyAssets = new Dictionary<string, Object>();

		public static int queuedDisplays;

		public static bool initialized = false;

		public static void LazyInit()
		{
			if (!initialized)
			{
				initialized = true;
				PopulateDisplays();
			}
		}

		internal static void DisposeWhenDone()
		{
			queuedDisplays--;
			if (queuedDisplays <= 0 && initialized)
			{
				initialized = false;
				itemDisplayPrefabs = null;
				KeyAssetDisplayPrefabs = null;
				KeyAssets = null;
			}
		}

		internal static void PopulateDisplays()
		{
			PopulateFromBody("LoaderBody");
			PopulateFromBody("CommandoBody");
			PopulateFromBody("MageBody");
			PopulateFromBody("CrocoBody");
		}

		private static void PopulateFromBody(string bodyName)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			KeyAssetRuleGroup[] keyAssetRuleGroups = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/" + bodyName).GetComponent<ModelLocator>().modelTransform).GetComponent<CharacterModel>().itemDisplayRuleSet.keyAssetRuleGroups;
			for (int i = 0; i < keyAssetRuleGroups.Length; i++)
			{
				ItemDisplayRule[] rules = keyAssetRuleGroups[i].displayRuleGroup.rules;
				KeyAssetDisplayPrefabs[keyAssetRuleGroups[i].keyAsset] = rules;
				KeyAssets[keyAssetRuleGroups[i].keyAsset.name] = keyAssetRuleGroups[i].keyAsset;
				for (int j = 0; j < rules.Length; j++)
				{
					GameObject val = rules[j].followerPrefab;
					if (!Object.op_Implicit((Object)(object)val) && rules[j].followerPrefabAddress != null && ((AssetReference)rules[j].followerPrefabAddress).RuntimeKeyIsValid())
					{
						try
						{
							val = Addressables.LoadAssetAsync<GameObject>(((AssetReference)rules[j].followerPrefabAddress).RuntimeKey).WaitForCompletion();
						}
						catch
						{
						}
					}
					if (Object.op_Implicit((Object)(object)val))
					{
						string key = ((Object)val).name?.ToLowerInvariant();
						if (!itemDisplayPrefabs.ContainsKey(key))
						{
							itemDisplayPrefabs[key] = val;
						}
					}
				}
			}
		}

		public static GameObject LoadDisplay(string name)
		{
			if (itemDisplayPrefabs.ContainsKey(name.ToLowerInvariant()) && Object.op_Implicit((Object)(object)itemDisplayPrefabs[name.ToLowerInvariant()]))
			{
				return itemDisplayPrefabs[name.ToLowerInvariant()];
			}
			return null;
		}

		public static KeyAssetRuleGroup CreateDisplayRuleGroupWithRules(string itemName, params ItemDisplayRule[] rules)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return CreateDisplayRuleGroupWithRules(GetKeyAssetFromString(itemName), rules);
		}

		public static KeyAssetRuleGroup CreateDisplayRuleGroupWithRules(Object keyAsset_, params ItemDisplayRule[] rules)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return new KeyAssetRuleGroup
			{
				keyAsset = keyAsset_,
				displayRuleGroup = new DisplayRuleGroup
				{
					rules = rules
				}
			};
		}

		public static ItemDisplayRule CreateDisplayRule(string prefabName, string childName, Vector3 position, Vector3 rotation, Vector3 scale)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return CreateDisplayRule(LoadDisplay(prefabName), childName, position, rotation, scale);
		}

		public static ItemDisplayRule CreateDisplayRule(GameObject itemPrefab, string childName, Vector3 position, Vector3 rotation, Vector3 scale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			return new ItemDisplayRule
			{
				ruleType = (ItemDisplayRuleType)0,
				childName = childName,
				followerPrefab = itemPrefab,
				followerPrefabAddress = new AssetReferenceGameObject(""),
				limbMask = (LimbFlags)0,
				localPos = position,
				localAngles = rotation,
				localScale = scale
			};
		}

		public static ItemDisplayRule CreateLimbMaskDisplayRule(LimbFlags limb)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			return new ItemDisplayRule
			{
				ruleType = (ItemDisplayRuleType)1,
				limbMask = limb,
				childName = "",
				followerPrefab = null,
				followerPrefabAddress = new AssetReferenceGameObject("")
			};
		}

		private static Object GetKeyAssetFromString(string itemName)
		{
			Object val = (Object)(object)LegacyResourcesAPI.Load<ItemDef>("ItemDefs/" + itemName);
			if (val == (Object)null)
			{
				val = (Object)(object)LegacyResourcesAPI.Load<EquipmentDef>("EquipmentDefs/" + itemName);
			}
			return val;
		}
	}
	internal static class Language
	{
		public static string TokensOutput = "";

		public static bool usingLanguageFolder = false;

		public static bool printingEnabled = false;

		public static void Init()
		{
			if (usingLanguageFolder)
			{
				Language.collectLanguageRootFolders += Language_collectLanguageRootFolders;
			}
		}

		private static void Language_collectLanguageRootFolders(List<string> obj)
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)LuxPlugin.instance).Info.Location), "Language");
			if (Directory.Exists(text))
			{
				obj.Add(text);
			}
		}

		public static void Add(string token, string text)
		{
			if (!usingLanguageFolder)
			{
				LanguageAPI.Add(token, text);
			}
			if (printingEnabled)
			{
				TokensOutput = TokensOutput + "\n    \"" + token + "\" : \"" + text.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n") + "\",";
			}
		}
	}
	internal static class Materials
	{
		private static List<Material> cachedMaterials = new List<Material>();

		internal static Shader hotpoo = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/HGStandard");

		public static Material LoadMaterial(this AssetBundle assetBundle, string materialName)
		{
			return assetBundle.CreateHopooMaterialFromBundle(materialName);
		}

		public static Material CreateHopooMaterialFromBundle(this AssetBundle assetBundle, string materialName)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			Material val = cachedMaterials.Find(delegate(Material mat)
			{
				materialName.Replace(" (Instance)", "");
				return ((Object)mat).name.Contains(materialName);
			});
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			val = assetBundle.LoadAsset<Material>(materialName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return new Material(hotpoo);
			}
			return val.ConvertDefaultShaderToHopoo();
		}

		public static Material ConvertDefaultShaderToHopoo(this Material tempMat)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (cachedMaterials.Contains(tempMat))
			{
				return tempMat;
			}
			string text = ((Object)tempMat.shader).name.ToLowerInvariant();
			if (!text.StartsWith("standard") && !text.StartsWith("autodesk"))
			{
				return tempMat;
			}
			float? num = null;
			Color? val = null;
			if (tempMat.IsKeywordEnabled("_NORMALMAP"))
			{
				num = tempMat.GetFloat("_BumpScale");
			}
			if (tempMat.IsKeywordEnabled("_EMISSION"))
			{
				val = tempMat.GetColor("_EmissionColor");
			}
			tempMat.shader = hotpoo;
			tempMat.SetTexture("_EmTex", tempMat.GetTexture("_EmissionMap"));
			tempMat.EnableKeyword("DITHER");
			if (num.HasValue)
			{
				tempMat.SetFloat("_NormalStrength", num.Value);
				tempMat.SetTexture("_NormalTex", tempMat.GetTexture("_BumpMap"));
			}
			if (val.HasValue)
			{
				tempMat.SetColor("_EmColor", val.Value);
				tempMat.SetFloat("_EmPower", 1f);
			}
			if (tempMat.IsKeywordEnabled("NOCULL"))
			{
				tempMat.SetInt("_Cull", 0);
			}
			if (tempMat.IsKeywordEnabled("LIMBREMOVAL"))
			{
				tempMat.SetInt("_LimbRemovalOn", 1);
			}
			cachedMaterials.Add(tempMat);
			return tempMat;
		}

		public static Material SetColor(this Material material, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			material.SetColor("_Color", color);
			return material;
		}

		public static Material SetEmission(this Material material)
		{
			return material.SetEmission(1f);
		}

		public static Material SetEmission(this Material material, float emission)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return material.SetEmission(emission, Color.white);
		}

		public static Material SetEmission(this Material material, float emission, Color emissionColor)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			material.SetFloat("_EmPower", emission);
			material.SetColor("_EmColor", emissionColor);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength)
		{
			material.SetFloat("_SpecularStrength", strength);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength, float exponent)
		{
			material.SetFloat("_SpecularStrength", strength);
			material.SetFloat("SpecularExponent", exponent);
			return material;
		}
	}
	internal static class Prefabs
	{
		private static PhysicMaterial ragdollMaterial;

		public static GameObject CreateDisplayPrefab(AssetBundle assetBundle, string displayPrefabName, GameObject prefab)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(displayPrefabName);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			CharacterModel val2 = val.GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = val.AddComponent<CharacterModel>();
			}
			val2.baseRendererInfos = prefab.GetComponentInChildren<CharacterModel>().baseRendererInfos;
			Asset.ConvertAllRenderersToHopooShader(val);
			return val;
		}

		public static GameObject LoadCharacterModel(AssetBundle assetBundle, string modelName)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(modelName);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			return val;
		}

		public static GameObject LoadCharacterBody(AssetBundle assetBundle, string bodyName)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(bodyName);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			return val;
		}

		public static GameObject CloneCharacterBody(BodyInfo bodyInfo)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/" + bodyInfo.bodyNameToClone + "Body");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			GameObject val2 = PrefabAPI.InstantiateClone(val, bodyInfo.bodyName);
			for (int num = val2.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)val2.transform.GetChild(num)).gameObject);
			}
			return val2;
		}

		public static GameObject CreateBodyPrefab(AssetBundle assetBundle, string modelPrefabName, BodyInfo bodyInfo)
		{
			return CreateBodyPrefab(LoadCharacterModel(assetBundle, modelPrefabName), bodyInfo);
		}

		public static GameObject CreateBodyPrefab(GameObject model, BodyInfo bodyInfo)
		{
			return CreateBodyPrefab(CloneCharacterBody(bodyInfo), model, bodyInfo);
		}

		public static GameObject CreateBodyPrefab(GameObject newBodyPrefab, AssetBundle assetBundle, string modelName, BodyInfo bodyInfo)
		{
			return CreateBodyPrefab(newBodyPrefab, LoadCharacterModel(assetBundle, modelName), bodyInfo);
		}

		public static GameObject CreateBodyPrefab(AssetBundle assetBundle, string bodyPrefabName, string modelPrefabName, BodyInfo bodyInfo)
		{
			return CreateBodyPrefab(LoadCharacterBody(assetBundle, bodyPrefabName), LoadCharacterModel(assetBundle, modelPrefabName), bodyInfo);
		}

		public static GameObject CreateBodyPrefab(GameObject newBodyPrefab, GameObject model, BodyInfo bodyInfo)
		{
			if ((Object)(object)model == (Object)null || (Object)(object)newBodyPrefab == (Object)null)
			{
				return null;
			}
			SetupCharacterBody(newBodyPrefab, bodyInfo);
			Transform modelBaseTransform = AddCharacterModelToSurvivorBody(newBodyPrefab, model.transform, bodyInfo);
			SetupModelLocator(newBodyPrefab, modelBaseTransform, model.transform);
			SetupCharacterDirection(newBodyPrefab, modelBaseTransform, model.transform);
			SetupCameraTargetParams(newBodyPrefab, bodyInfo);
			SetupCapsuleCollider(newBodyPrefab);
			Content.AddCharacterBodyPrefab(newBodyPrefab);
			return newBodyPrefab;
		}

		private static void SetupCharacterBody(GameObject newBodyPrefab, BodyInfo bodyInfo)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = newBodyPrefab.GetComponent<CharacterBody>();
			component.baseNameToken = bodyInfo.bodyNameToken;
			component.subtitleNameToken = bodyInfo.subtitleNameToken;
			component.portraitIcon = bodyInfo.characterPortrait;
			component.bodyColor = bodyInfo.bodyColor;
			component._defaultCrosshairPrefab = bodyInfo.crosshair;
			component.hideCrosshair = false;
			component.preferredPodPrefab = bodyInfo.podPrefab;
			component.baseMaxHealth = bodyInfo.maxHealth;
			component.baseRegen = bodyInfo.healthRegen;
			component.baseArmor = bodyInfo.armor;
			component.baseMaxShield = bodyInfo.shield;
			component.baseDamage = bodyInfo.damage;
			component.baseAttackSpeed = bodyInfo.attackSpeed;
			component.baseCrit = bodyInfo.crit;
			component.baseMoveSpeed = bodyInfo.moveSpeed;
			component.baseJumpPower = bodyInfo.jumpPower;
			component.autoCalculateLevelStats = bodyInfo.autoCalculateLevelStats;
			if (bodyInfo.autoCalculateLevelStats)
			{
				component.levelMaxHealth = Mathf.Round(component.baseMaxHealth * 0.3f);
				component.levelMaxShield = Mathf.Round(component.baseMaxShield * 0.3f);
				component.levelRegen = component.baseRegen * 0.2f;
				component.levelMoveSpeed = 0f;
				component.levelJumpPower = 0f;
				component.levelDamage = component.baseDamage * 0.2f;
				component.levelAttackSpeed = 0f;
				component.levelCrit = 0f;
				component.levelArmor = 0f;
			}
			else
			{
				component.levelMaxHealth = bodyInfo.healthGrowth;
				component.levelMaxShield = bodyInfo.shieldGrowth;
				component.levelRegen = bodyInfo.regenGrowth;
				component.levelMoveSpeed = bodyInfo.moveSpeedGrowth;
				component.levelJumpPower = bodyInfo.jumpPowerGrowth;
				component.levelDamage = bodyInfo.damageGrowth;
				component.levelAttackSpeed = bodyInfo.attackSpeedGrowth;
				component.levelCrit = bodyInfo.critGrowth;
				component.levelArmor = bodyInfo.armorGrowth;
			}
			component.baseAcceleration = bodyInfo.acceleration;
			component.baseJumpCount = bodyInfo.jumpCount;
			component.sprintingSpeedMultiplier = 1.45f;
			component.bodyFlags = (BodyFlags)16;
			component.rootMotionInMainState = false;
			component.hullClassification = (HullClassification)0;
			component.isChampion = false;
		}

		private static Transform AddCharacterModelToSurvivorBody(GameObject bodyPrefab, Transform modelTransform, BodyInfo bodyInfo)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Transform val = bodyPrefab.transform.Find("ModelBase");
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject("ModelBase").transform;
				val.parent = bodyPrefab.transform;
				val.localPosition = bodyInfo.modelBasePosition;
				val.localRotation = Quaternion.identity;
			}
			modelTransform.parent = ((Component)val).transform;
			modelTransform.localPosition = Vector3.zero;
			modelTransform.localRotation = Quaternion.identity;
			if ((Object)(object)bodyPrefab.transform.Find("CameraPivot") == (Object)null)
			{
				Transform transform = new GameObject("CameraPivot").transform;
				transform.parent = bodyPrefab.transform;
				transform.localPosition = bodyInfo.cameraPivotPosition;
				transform.localRotation = Quaternion.identity;
			}
			Transform val2 = bodyPrefab.transform.Find("AimOrigin");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = new GameObject("AimOrigin").transform;
				val2.parent = bodyPrefab.transform;
				val2.localPosition = bodyInfo.aimOriginPosition;
				val2.localRotation = Quaternion.identity;
			}
			bodyPrefab.GetComponent<CharacterBody>().aimOriginTransform = val2;
			return ((Component)val).transform;
		}

		private static void SetupCharacterDirection(GameObject prefab, Transform modelBaseTransform, Transform modelTransform)
		{
			if (Object.op_Implicit((Object)(object)prefab.GetComponent<CharacterDirection>()))
			{
				CharacterDirection component = prefab.GetComponent<CharacterDirection>();
				component.targetTransform = modelBaseTransform;
				component.overrideAnimatorForwardTransform = null;
				component.rootMotionAccumulator = null;
				component.modelAnimator = ((Component)modelTransform).GetComponent<Animator>();
				component.driveFromRootRotation = false;
				component.turnSpeed = 720f;
			}
		}

		private static void SetupCameraTargetParams(GameObject prefab, BodyInfo bodyInfo)
		{
			CameraTargetParams component = prefab.GetComponent<CameraTargetParams>();
			component.cameraParams = bodyInfo.cameraParams;
			component.cameraPivotTransform = prefab.transform.Find("CameraPivot");
		}

		private static void SetupModelLocator(GameObject prefab, Transform modelBaseTransform, Transform modelTransform)
		{
			ModelLocator component = prefab.GetComponent<ModelLocator>();
			component.modelTransform = modelTransform;
			component.modelBaseTransform = modelBaseTransform;
		}

		private static void SetupCapsuleCollider(GameObject prefab)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			CapsuleCollider component = prefab.GetComponent<CapsuleCollider>();
			component.center = new Vector3(0f, 0f, 0f);
			component.radius = 0.5f;
			component.height = 1.82f;
			component.direction = 1;
		}

		public static CharacterModel SetupCharacterModel(GameObject bodyPrefab, CustomRendererInfo[] customInfos = null)
		{
			CharacterModel val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.GetComponent<CharacterModel>();
			bool num = (Object)(object)val != (Object)null;
			if (!num)
			{
				val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.AddComponent<CharacterModel>();
			}
			val.body = bodyPrefab.GetComponent<CharacterBody>();
			val.autoPopulateLightInfos = true;
			val.invisibilityCount = 0;
			val.temporaryOverlays = new List<TemporaryOverlayInstance>();
			if (!num)
			{
				SetupCustomRendererInfos(val, customInfos);
			}
			else
			{
				SetupPreAttachedRendererInfos(val);
			}
			SetupHurtboxGroup(bodyPrefab, ((Component)val).gameObject);
			SetupAimAnimator(bodyPrefab, ((Component)val).gameObject);
			SetupFootstepController(((Component)val).gameObject);
			SetupRagdoll(((Component)val).gameObject);
			return val;
		}

		public static void SetupPreAttachedRendererInfos(CharacterModel characterModel)
		{
			for (int i = 0; i < characterModel.baseRendererInfos.Length; i++)
			{
				if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null)
				{
					characterModel.baseRendererInfos[i].defaultMaterial = characterModel.baseRendererInfos[i].renderer.sharedMaterial;
				}
				characterModel.baseRendererInfos[i].defaultMaterial.ConvertDefaultShaderToHopoo();
			}
		}

		public static void SetupCustomRendererInfos(CharacterModel characterModel, CustomRendererInfo[] customInfos)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			ChildLocator component = ((Component)characterModel).GetComponent<ChildLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			List<RendererInfo> list = new List<RendererInfo>();
			for (int i = 0; i < customInfos.Length; i++)
			{
				if (!Object.op_Implicit((Object)(object)component.FindChild(customInfos[i].childName)))
				{
					continue;
				}
				Renderer component2 = ((Component)component.FindChild(customInfos[i].childName)).GetComponent<Renderer>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Material val = customInfos[i].material;
					if ((Object)(object)val == (Object)null)
					{
						val = ((!customInfos[i].dontHotpoo) ? component2.sharedMaterial.ConvertDefaultShaderToHopoo() : component2.sharedMaterial);
					}
					list.Add(new RendererInfo
					{
						renderer = component2,
						defaultMaterial = val,
						ignoreOverlays = customInfos[i].ignoreOverlays,
						defaultShadowCastingMode = (ShadowCastingMode)1
					});
				}
			}
			characterModel.baseRendererInfos = list.ToArray();
		}

		private static void SetupHurtboxGroup(GameObject bodyPrefab, GameObject model)
		{
			SetupMainHurtboxesFromChildLocator(bodyPrefab, model);
			SetHurtboxesHealthComponents(bodyPrefab);
		}

		private static void SetupMainHurtboxesFromChildLocator(GameObject bodyPrefab, GameObject model)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bodyPrefab.GetComponent<HurtBoxGroup>() != (Object)null)
			{
				return;
			}
			ChildLocator component = model.GetComponent<ChildLocator>();
			if (!string.IsNullOrEmpty(component.FindChildNameInsensitive("MainHurtbox")))
			{
				HurtBoxGroup val = model.AddComponent<HurtBoxGroup>();
				HurtBox val2 = null;
				GameObject val3 = component.FindChildGameObjectInsensitive("HeadHurtbox");
				if (Object.op_Implicit((Object)(object)val3))
				{
					val2 = val3.AddComponent<HurtBox>();
					((Component)val2).gameObject.layer = LayerIndex.entityPrecise.intVal;
					val2.healthComponent = bodyPrefab.GetComponent<HealthComponent>();
					val2.isBullseye = false;
					val2.isSniperTarget = true;
					val2.damageModifier = (DamageModifier)0;
					val2.hurtBoxGroup = val;
					val2.indexInGroup = 1;
				}
				HurtBox val4 = component.FindChildGameObjectInsensitive("MainHurtbox").AddComponent<HurtBox>();
				((Component)val4).gameObject.layer = LayerIndex.entityPrecise.intVal;
				val4.healthComponent = bodyPrefab.GetComponent<HealthComponent>();
				val4.isBullseye = true;
				val4.isSniperTarget = (Object)(object)val2 == (Object)null;
				val4.damageModifier = (DamageModifier)0;
				val4.hurtBoxGroup = val;
				val4.indexInGroup = 0;
				if (Object.op_Implicit((Object)(object)val2))
				{
					val.hurtBoxes = (HurtBox[])(object)new HurtBox[2] { val4, val2 };
				}
				else
				{
					val.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val4 };
				}
				val.mainHurtBox = val4;
				val.bullseyeCount = 1;
			}
		}

		private static string FindChildNameInsensitive(this ChildLocator childLocator, string child)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			return childLocator.transformPairs.Where((NameTransformPair pair) => pair.name.ToLowerInvariant() == child.ToLowerInvariant()).FirstOrDefault().name;
		}

		private static GameObject FindChildGameObjectInsensitive(this ChildLocator childLocator, string child)
		{
			return childLocator.FindChildGameObject(childLocator.FindChildNameInsensitive(child));
		}

		public static void SetHurtboxesHealthComponents(GameObject bodyPrefab)
		{
			HealthComponent component = bodyPrefab.GetComponent<HealthComponent>();
			HurtBoxGroup[] componentsInChildren = bodyPrefab.GetComponentsInChildren<HurtBoxGroup>();
			foreach (HurtBoxGroup val in componentsInChildren)
			{
				val.mainHurtBox.healthComponent = component;
				for (int j = 0; j < val.hurtBoxes.Length; j++)
				{
					val.hurtBoxes[j].healthComponent = component;
				}
			}
		}

		private static void SetupFootstepController(GameObject model)
		{
			FootstepHandler obj = model.AddComponent<FootstepHandler>();
			obj.baseFootstepString = "Play_player_footstep";
			obj.sprintFootstepOverrideString = "";
			obj.enableFootstepDust = true;
			obj.footstepDustPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/GenericFootstepDust");
		}

		private static void SetupRagdoll(GameObject model)
		{
			RagdollController component = model.GetComponent<RagdollController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if ((Object)(object)ragdollMaterial == (Object)null)
			{
				ragdollMaterial = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<RagdollController>().bones[1]).GetComponent<Collider>().material;
			}
			Transform[] bones = component.bones;
			foreach (Transform val in bones)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.layer = LayerIndex.ragdoll.intVal;
					Collider component2 = ((Component)val).GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.sharedMaterial = ragdollMaterial;
					}
				}
			}
		}

		private static void SetupAimAnimator(GameObject prefab, GameObject model)
		{
			AimAnimator obj = model.AddComponent<AimAnimator>();
			obj.directionComponent = prefab.GetComponent<CharacterDirection>();
			obj.pitchRangeMax = 60f;
			obj.pitchRangeMin = -60f;
			obj.yawRangeMin = -80f;
			obj.yawRangeMax = 80f;
			obj.pitchGiveupRange = 30f;
			obj.yawGiveupRange = 10f;
			obj.giveupDuration = 3f;
			obj.inputBank = prefab.GetComponent<InputBankTest>();
		}

		public static GameObject CreateBlankMasterPrefab(GameObject bodyPrefab, string masterName)
		{
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), masterName, true);
			ContentPacks.masterPrefabs.Add(val);
			val.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab;
			AISkillDriver[] components = val.GetComponents<AISkillDriver>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
			return val;
		}

		public static void ClearEntityStateMachines(GameObject bodyPrefab)
		{
			EntityStateMachine[] components = bodyPrefab.GetComponents<EntityStateMachine>();
			for (int num = components.Length - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)components[num]);
			}
			bodyPrefab.GetComponent<NetworkStateMachine>().stateMachines = Array.Empty<EntityStateMachine>();
			CharacterDeathBehavior component = bodyPrefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.idleStateMachine = Array.Empty<EntityStateMachine>();
			}
			SetStateOnHurt component2 = bodyPrefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.idleStateMachine = Array.Empty<EntityStateMachine>();
			}
			CharacterBody component3 = bodyPrefab.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.vehicleIdleStateMachine = Array.Empty<EntityStateMachine>();
			}
		}

		public static EntityStateMachine AddEntityStateMachine(GameObject prefab, string machineName, Type mainStateType = null, Type initalStateType = null, bool addToHurt = true, bool addToDeath = true)
		{
			//IL_0036: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			EntityStateMachine val = EntityStateMachine.FindByCustomName(prefab, machineName);
			if ((Object)(object)val == (Object)null)
			{
				val = prefab.AddComponent<EntityStateMachine>();
			}
			val.customName = machineName;
			if (mainStateType == null)
			{
				mainStateType = typeof(Idle);
			}
			val.mainStateType = new SerializableEntityStateType(mainStateType);
			if (initalStateType == null)
			{
				initalStateType = typeof(Idle);
			}
			val.initialStateType = new SerializableEntityStateType(initalStateType);
			NetworkStateMachine component = prefab.GetComponent<NetworkStateMachine>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.stateMachines = component.stateMachines.Append(val).ToArray();
			}
			CharacterDeathBehavior component2 = prefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component2) && addToDeath)
			{
				component2.idleStateMachine = component2.idleStateMachine.Append(val).ToArray();
			}
			SetStateOnHurt component3 = prefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component3) && addToHurt)
			{
				component3.idleStateMachine = component3.idleStateMachine.Append(val).ToArray();
			}
			CharacterBody component4 = prefab.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				component4.vehicleIdleStateMachine = component4.vehicleIdleStateMachine.Append(val).ToArray();
			}
			return val;
		}

		public static EntityStateMachine AddMainEntityStateMachine(GameObject bodyPrefab, string machineName = "Body", Type mainStateType = null, Type initalStateType = null)
		{
			//IL_0036: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			EntityStateMachine val = EntityStateMachine.FindByCustomName(bodyPrefab, machineName);
			if ((Object)(object)val == (Object)null)
			{
				val = bodyPrefab.AddComponent<EntityStateMachine>();
			}
			val.customName = machineName;
			if (mainStateType == null)
			{
				mainStateType = typeof(GenericCharacterMain);
			}
			val.mainStateType = new SerializableEntityStateType(mainStateType);
			if (initalStateType == null)
			{
				initalStateType = typeof(SpawnTeleporterState);
			}
			val.initialStateType = new SerializableEntityStateType(initalStateType);
			NetworkStateMachine component = bodyPrefab.GetComponent<NetworkStateMachine>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.stateMachines = component.stateMachines.Append(val).ToArray();
			}
			CharacterDeathBehavior component2 = bodyPrefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.deathStateMachine = val;
			}
			SetStateOnHurt component3 = bodyPrefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.targetStateMachine = val;
			}
			return val;
		}

		public static void SetupHitBoxGroup(GameObject modelPrefab, string hitBoxGroupName, params string[] hitboxChildNames)
		{
			ChildLocator component = modelPrefab.GetComponent<ChildLocator>();
			Transform[] array = (Transform[])(object)new Transform[hitboxChildNames.Length];
			for (int i = 0; i < hitboxChildNames.Length; i++)
			{
				array[i] = component.FindChild(hitboxChildNames[i]);
			}
			SetupHitBoxGroup(modelPrefab, hitBoxGroupName, array);
		}

		public static void SetupHitBoxGroup(GameObject prefab, string hitBoxGroupName, params Transform[] hitBoxTransforms)
		{
			List<HitBox> list = new List<HitBox>();
			foreach (Transform val in hitBoxTransforms)
			{
				if (!((Object)(object)val == (Object)null))
				{
					HitBox item = ((Component)val).gameObject.AddComponent<HitBox>();
					((Component)val).gameObject.layer = LayerIndex.projectile.intVal;
					list.Add(item);
				}
			}
			if (list.Count != 0)
			{
				HitBoxGroup obj = prefab.AddComponent<HitBoxGroup>();
				obj.hitBoxes = list.ToArray();
				obj.groupName = hitBoxGroupName;
			}
		}
	}
	public class CustomRendererInfo
	{
		public string childName;

		public Material material;

		public bool dontHotpoo;

		public bool ignoreOverlays;
	}
	internal static class Skills
	{
		public static void CreateSkillFamilies(GameObject targetPrefab)
		{
			SkillSlot[] array = new SkillSlot[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CreateSkillFamilies(targetPrefab, (SkillSlot[])(object)array);
		}

		public static void CreateSkillFamilies(GameObject targetPrefab, params SkillSlot[] slots)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_002b: Expected I4, but got Unknown
			SkillLocator component = targetPrefab.GetComponent<SkillLocator>();
			foreach (SkillSlot val in slots)
			{
				switch (val - -1)
				{
				case 1:
					component.primary = CreateGenericSkillWithSkillFamily(targetPrefab, "Primary");
					break;
				case 2:
					component.secondary = CreateGenericSkillWithSkillFamily(targetPrefab, "Secondary");
					break;
				case 3:
					component.utility = CreateGenericSkillWithSkillFamily(targetPrefab, "Utility");
					break;
				case 4:
					component.special = CreateGenericSkillWithSkillFamily(targetPrefab, "Special");
					break;
				}
			}
		}

		public static void ClearGenericSkills(GameObject targetPrefab)
		{
			GenericSkill[] componentsInChildren = targetPrefab.GetComponentsInChildren<GenericSkill>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
		}

		public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, SkillSlot skillSlot, bool hidden = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected I4, but got Unknown
			SkillLocator component = targetPrefab.GetComponent<SkillLocator>();
			return (GenericSkill)((skillSlot - -1) switch
			{
				1 => component.primary = CreateGenericSkillWithSkillFamily(targetPrefab, "Primary", hidden), 
				2 => component.secondary = CreateGenericSkillWithSkillFamily(targetPrefab, "Secondary", hidden), 
				3 => component.utility = CreateGenericSkillWithSkillFamily(targetPrefab, "Utility", hidden), 
				4 => component.special = CreateGenericSkillWithSkillFamily(targetPrefab, "Special", hidden), 
				0 => null, 
				_ => null, 
			});
		}

		public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, string familyName, bool hidden = false)
		{
			return CreateGenericSkillWithSkillFamily(targetPrefab, familyName, familyName, hidden);
		}

		public static GenericSkill CreateGenericSkillWithSkillFamily(GameObject targetPrefab, string genericSkillName, string familyName, bool hidden = false)
		{
			GenericSkill obj = targetPrefab.AddComponent<GenericSkill>();
			obj.skillName = genericSkillName;
			obj.hideInCharacterSelect = hidden;
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = ((Object)targetPrefab).name + familyName + "Family";
			val.variants = (Variant[])(object)new Variant[0];
			obj._skillFamily = val;
			Content.AddSkillFamily(val);
			return obj;
		}

		public static void AddSkillToFamily(SkillFamily skillFamily, SkillDef skillDef, UnlockableDef unlockableDef = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val = new Variant
			{
				skillDef = skillDef,
				unlockableDef = unlockableDef
			};
			((Variant)(ref val)).viewableNode = new Node(skillDef.skillNameToken, false, (Node)null);
			variants[num] = val;
		}

		public static void AddSkillsToFamily(SkillFamily skillFamily, params SkillDef[] skillDefs)
		{
			foreach (SkillDef skillDef in skillDefs)
			{
				AddSkillToFamily(skillFamily, skillDef);
			}
		}

		public static void AddPrimarySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().primary.skillFamily, skillDefs);
		}

		public static void AddSecondarySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().secondary.skillFamily, skillDefs);
		}

		public static void AddUtilitySkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().utility.skillFamily, skillDefs);
		}

		public static void AddSpecialSkills(GameObject targetPrefab, params SkillDef[] skillDefs)
		{
			AddSkillsToFamily(targetPrefab.GetComponent<SkillLocator>().special.skillFamily, skillDefs);
		}

		public static SkillDef CreateSkillDef(SkillDefInfo skillDefInfo)
		{
			return Skills.CreateSkillDef<SkillDef>(skillDefInfo);
		}

		public static T CreateSkillDef<T>(SkillDefInfo skillDefInfo) where T : SkillDef
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			T val = ScriptableObject.CreateInstance<T>();
			((SkillDef)val).skillName = skillDefInfo.skillName;
			((Object)(object)val).name = skillDefInfo.skillName;
			((SkillDef)val).skillNameToken = skillDefInfo.skillNameToken;
			((SkillDef)val).skillDescriptionToken = skillDefInfo.skillDescriptionToken;
			((SkillDef)val).icon = skillDefInfo.skillIcon;
			((SkillDef)val).activationState = skillDefInfo.activationState;
			((SkillDef)val).activationStateMachineName = skillDefInfo.activationStateMachineName;
			((SkillDef)val).interruptPriority = skillDefInfo.interruptPriority;
			((SkillDef)val).baseMaxStock = skillDefInfo.baseMaxStock;
			((SkillDef)val).baseRechargeInterval = skillDefInfo.baseRechargeInterval;
			((SkillDef)val).rechargeStock = skillDefInfo.rechargeStock;
			((SkillDef)val).requiredStock = skillDefInfo.requiredStock;
			((SkillDef)val).stockToConsume = skillDefInfo.stockToConsume;
			((SkillDef)val).dontAllowPastMaxStocks = skillDefInfo.dontAllowPastMaxStocks;
			((SkillDef)val).beginSkillCooldownOnSkillEnd = skillDefInfo.beginSkillCooldownOnSkillEnd;
			((SkillDef)val).canceledFromSprinting = skillDefInfo.canceledFromSprinting;
			((SkillDef)val).forceSprintDuringState = skillDefInfo.forceSprintDuringState;
			((SkillDef)val).fullRestockOnAssign = skillDefInfo.fullRestockOnAssign;
			((SkillDef)val).resetCooldownTimerOnUse = skillDefInfo.resetCooldownTimerOnUse;
			((SkillDef)val).isCombatSkill = skillDefInfo.isCombatSkill;
			((SkillDef)val).mustKeyPress = skillDefInfo.mustKeyPress;
			((SkillDef)val).cancelSprintingOnActivation = skillDefInfo.cancelSprintingOnActivation;
			((SkillDef)val).keywordTokens = skillDefInfo.keywordTokens;
			Content.AddSkillDef((SkillDef)(object)val);
			return val;
		}
	}
	internal class SkillDefInfo
	{
		public string skillName;

		public string skillNameToken;

		public string skillDescriptionToken;

		public string[] keywordTokens = Array.Empty<string>();

		public Sprite skillIcon;

		public SerializableEntityStateType activationState;

		public string activationStateMachineName;

		public InterruptPriority interruptPriority;

		public float baseRechargeInterval;

		public int baseMaxStock = 1;

		public int rechargeStock = 1;

		public int requiredStock = 1;

		public int stockToConsume = 1;

		public bool resetCooldownTimerOnUse;

		public bool fullRestockOnAssign = true;

		public bool dontAllowPastMaxStocks;

		public bool beginSkillCooldownOnSkillEnd;

		public bool mustKeyPress;

		public bool isCombatSkill = true;

		public bool canceledFromSprinting;

		public bool cancelSprintingOnActivation = true;

		public bool forceSprintDuringState;

		public SkillDefInfo()
		{
		}

		public SkillDefInfo(string skillName, string skillNameToken, string skillDescriptionToken, Sprite skillIcon, SerializableEntityStateType activationState, string activationStateMachineName = "Weapon", bool agile = false)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			this.skillName = skillName;
			this.skillNameToken = skillNameToken;
			this.skillDescriptionToken = skillDescriptionToken;
			this.skillIcon = skillIcon;
			this.activationState = activationState;
			this.activationStateMachineName = activationStateMachineName;
			cancelSprintingOnActivation = !agile;
			if (agile)
			{
				keywordTokens = new string[1] { "KEYWORD_AGILE" };
			}
			interruptPriority = (InterruptPriority)0;
			isCombatSkill = true;
			baseRechargeInterval = 0f;
			requiredStock = 0;
			stockToConsume = 0;
		}
	}
	internal static class Skins
	{
		internal struct SkinDefInfo
		{
			internal SkinDef[] BaseSkins;

			internal Sprite Icon;

			internal string NameToken;

			internal UnlockableDef UnlockableDef;

			internal GameObject RootObject;

			internal RendererInfo[] RendererInfos;

			internal MeshReplacement[] MeshReplacements;

			internal GameObjectActivation[] GameObjectActivations;

			internal ProjectileGhostReplacement[] ProjectileGhostReplacements;

			internal MinionSkinReplacement[] MinionSkinReplacements;

			internal string Name;
		}

		internal static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, RendererInfo[] defaultRendererInfos, GameObject root, UnlockableDef unlockableDef = null)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			SkinDefInfo skinDefInfo = new SkinDefInfo
			{
				BaseSkins = Array.Empty<SkinDef>(),
				GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0],
				Icon = skinIcon,
				MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[0],
				MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[0],
				Name = skinName,
				NameToken = skinName,
				ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[0],
				RendererInfos = (RendererInfo[])(object)new RendererInfo[defaultRendererInfos.Length],
				RootObject = root,
				UnlockableDef = unlockableDef
			};
			SkinDef.Awake += new hook_Awake(DoNothing);
			SkinDef obj = ScriptableObject.CreateInstance<SkinDef>();
			obj.baseSkins = skinDefInfo.BaseSkins;
			obj.icon = skinDefInfo.Icon;
			obj.unlockableDef = skinDefInfo.UnlockableDef;
			obj.rootObject = skinDefInfo.RootObject;
			defaultRendererInfos.CopyTo(skinDefInfo.RendererInfos, 0);
			obj.rendererInfos = skinDefInfo.RendererInfos;
			obj.gameObjectActivations = skinDefInfo.GameObjectActivations;
			obj.meshReplacements = skinDefInfo.MeshReplacements;
			obj.projectileGhostReplacements = skinDefInfo.ProjectileGhostReplacements;
			obj.minionSkinReplacements = skinDefInfo.MinionSkinReplacements;
			obj.nameToken = skinDefInfo.NameToken;
			((Object)obj).name = skinDefInfo.Name;
			SkinDef.Awake -= new hook_Awake(DoNothing);
			return obj;
		}

		private static void DoNothing(orig_Awake orig, SkinDef self)
		{
		}
	}
}
namespace LuxMod.Modules.LeagueSkins
{
	internal static class LeagueResources
	{
		private static string[] resourceNames;

		internal static byte[] Load(string folder, string file)
		{
			Assembly assembly = typeof(LeagueResources).Assembly;
			if (resourceNames == null)
			{
				resourceNames = assembly.GetManifestResourceNames();
			}
			string suffix = ".LeagueSkins." + folder + "." + file;
			string text = resourceNames.FirstOrDefault((string n) => n.EndsWith(suffix, StringComparison.OrdinalIgnoreCase));
			if (text == null)
			{
				return null;
			}
			using Stream stream = assembly.GetManifestResourceStream(text);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}
	}
	internal static class LeagueBytes
	{
		internal static Vector3 ReadVector3(byte[] d, int o)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(BitConverter.ToSingle(d, o), BitConverter.ToSingle(d, o + 4), BitConverter.ToSingle(d, o + 8));
		}

		internal static Quaternion ReadQuaternion(byte[] d, int o)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(BitConverter.ToSingle(d, o), BitConverter.ToSingle(d, o + 4), BitConverter.ToSingle(d, o + 8), BitConverter.ToSingle(d, o + 12));
		}

		internal static string ReadString(byte[] d, int o, int max)
		{
			int i;
			for (i = o; i < d.Length && i < o + max && d[i] != 0; i++)
			{
			}
			return Encoding.ASCII.GetString(d, o, i - o);
		}
	}
	internal class LeagueSkeleton
	{
		internal string[] names;

		internal int[] parents;

		internal Matrix4x4[] rest;

		internal ushort[] influences;

		internal Dictionary<string, int> index = new Dictionary<string, int>();

		internal static LeagueSkeleton Read(byte[] d)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (BitConverter.ToUInt32(d, 4) != 587026371)
			{
				throw new InvalidDataException("Unsupported .skl format");
			}
			int num = BitConverter.ToUInt16(d, 14);
			int num2 = (int)BitConverter.ToUInt32(d, 16);
			int num3 = BitConverter.ToInt32(d, 20);
			int num4 = BitConverter.ToInt32(d, 28);
			LeagueSkeleton leagueSkeleton = new LeagueSkeleton
			{
				names = new string[num],
				parents = new int[num],
				rest = (Matrix4x4[])(object)new Matrix4x4[num],
				influences = new ushort[num2]
			};
			for (int i = 0; i < num; i++)
			{
				int num5 = num3 + i * 100;
				leagueSkeleton.parents[i] = BitConverter.ToInt16(d, num5 + 4);
				Vector3 val = LeagueBytes.ReadVector3(d, num5 + 56);
				Vector3 val2 = LeagueBytes.ReadVector3(d, num5 + 68);
				Quaternion val3 = LeagueBytes.ReadQuaternion(d, num5 + 80);
				Matrix4x4[] array = leagueSkeleton.rest;
				int num6 = i;
				Matrix4x4 val4 = Matrix4x4.TRS(val, val3, val2);
				array[num6] = ((Matrix4x4)(ref val4)).inverse;
				int num7 = num5 + 96;
				int o = num7 + BitConverter.ToInt32(d, num7);
				leagueSkeleton.names[i] = LeagueBytes.ReadString(d, o, 256);
				leagueSkeleton.index[leagueSkeleton.names[i]] = i;
			}
			for (int j = 0; j < num2; j++)
			{
				leagueSkeleton.influences[j] = BitConverter.ToUInt16(d, num4 + j * 2);
			}
			return leagueSkeleton;
		}
	}
	internal class LeagueMeshPart
	{
		internal string name;

		internal int vertexStart;

		internal int vertexCount;

		internal int indexStart;

		internal int indexCount;
	}
	internal class LeagueMesh
	{
		internal List<LeagueMeshPart> parts = new List<LeagueMeshPart>();

		internal ushort[] indices;

		internal Vector3[] positions;

		internal Vector3[] normals;

		internal Vector2[] uvs;

		internal byte[] boneIndices;

		internal float[] weights;

		internal static LeagueMesh Read(byte[] d)
		{
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			if (BitConverter.ToUInt32(d, 0) != 1122867)
			{
				throw new InvalidDataException("Unsupported .skn format");
			}
			int num = BitConverter.ToUInt16(d, 4);
			if (num == 0)
			{
				throw new InvalidDataException("Unsupported .skn version 0");
			}
			LeagueMesh leagueMesh = new LeagueMesh();
			int num2 = 8;
			int num3 = BitConverter.ToInt32(d, num2);
			num2 += 4;
			for (int i = 0; i < num3; i++)
			{
				leagueMesh.parts.Add(new LeagueMeshPart
				{
					name = LeagueBytes.ReadString(d, num2, 64),
					vertexStart = BitConverter.ToInt32(d, num2 + 64),
					vertexCount = BitConverter.ToInt32(d, num2 + 68),
					indexStart = BitConverter.ToInt32(d, num2 + 72),
					indexCount = BitConverter.ToInt32(d, num2 + 76)
				});
				num2 += 80;
			}
			if (num == 4)
			{
				num2 += 4;
			}
			int num4 = BitConverter.ToInt32(d, num2);
			int num5 = BitConverter.ToInt32(d, num2 + 4);
			num2 += 8;
			int num6 = 52;
			if (num == 4)
			{
				num6 = BitConverter.ToInt32(d, num2);
				num2 += 48;
			}
			leagueMesh.indices = new ushort[num4];
			for (int j = 0; j < num4; j++)
			{
				leagueMesh.indices[j] = BitConverter.ToUInt16(d, num2 + j * 2);
			}
			num2 += num4 * 2;
			leagueMesh.positions = (Vector3[])(object)new Vector3[num5];
			leagueMesh.normals = (Vector3[])(object)new Vector3[num5];
			leagueMesh.uvs = (Vector2[])(object)new Vector2[num5];
			leagueMesh.boneIndices = new byte[num5 * 4];
			leagueMesh.weights = new float[num5 * 4];
			for (int k = 0; k < num5; k++)
			{
				int num7 = num2 + k * num6;
				leagueMesh.positions[k] = LeagueBytes.ReadVector3(d, num7);
				for (int l = 0; l < 4; l++)
				{
					leagueMesh.boneIndices[k * 4 + l] = d[num7 + 12 + l];
					leagueMesh.weights[k * 4 + l] = BitConverter.ToSingle(d, num7 + 16 + l * 4);
				}
				leagueMesh.normals[k] = LeagueBytes.ReadVector3(d, num7 + 32);
				leagueMesh.uvs[k] = new Vector2(BitConverter.ToSingle(d, num7 + 44), BitConverter.ToSingle(d, num7 + 48));
			}
			return leagueMesh;
		}
	}
	internal static class LeagueTextures
	{
		private const int Dxt1 = 10;

		private const int Dxt5 = 12;

		private const int Bgra8 = 20;

		private static bool ReadHeader(byte[] d, out int width, out int height, out int format, out bool hasMips)
		{
			width = (height = (format = 0));
			hasMips = false;
			if (d == null || d.Length < 12 || d[0] != 84 || d[1] != 69 || d[2] != 88)
			{
				return false;
			}
			width = BitConverter.ToUInt16(d, 4);
			height = BitConverter.ToUInt16(d, 6);
			format = d[9];
			hasMips = d[11] != 0;
			if (format != 10 && format != 12)
			{
				return format == 20;
			}
			return true;
		}

		private static int LevelSize(int format, int width, int height)
		{
			if (format == 20)
			{
				return width * height * 4;
			}
			return Math.Max(1, (width + 3) / 4) * Math.Max(1, (height + 3) / 4) * ((format == 10) ? 8 : 16);
		}

		private static List<int> LevelSizes(int format, int width, int height)
		{
			List<int> list = new List<int>();
			while (true)
			{
				list.Add(LevelSize(format, width, height));
				if (width == 1 && height == 1)
				{
					break;
				}
				width = Math.Max(1, width / 2);
				height = Math.Max(1, height / 2);
			}
			return list;
		}

		private static byte[] TopLevel(byte[] d, int format, int width, int height, bool hasMips)
		{
			int num = LevelSize(format, width, height);
			byte[] array = new byte[num];
			Array.Copy(d, hasMips ? (d.Length - num) : 12, array, 0, num);
			return array;
		}

		internal static Texture2D Load(byte[] d, string name, out bool hasAlpha)
		{
			//IL_0029: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			hasAlpha = false;
			if (!ReadHeader(d, out var width, out var height, out var format, out var hasMips))
			{
				return null;
			}
			TextureFormat val = (TextureFormat)(format switch
			{
				12 => 12, 
				10 => 10, 
				_ => 14, 
			});
			List<int> list = LevelSizes(format, width, height);
			bool flag = hasMips && list.Sum() == d.Length - 12;
			byte[] array;
			if (flag)
			{
				array = new byte[list.Sum()];
				int num = d.Length;
				int num2 = 0;
				foreach (int item in list)
				{
					num -= item;
					Array.Copy(d, num, array, num2, item);
					num2 += item;
				}
			}
			else
			{
				array = TopLevel(d, format, width, height, hasMips);
			}
			Texture2D val2 = new Texture2D(width, height, val, flag)
			{
				name = name,
				wrapMode = (TextureWrapMode)0
			};
			val2.LoadRawTextureData(array);
			val2.Apply(false, true);
			byte[] data = TopLevel(d, format, width, height, hasMips);
			int num3;
			switch (format)
			{
			case 10:
				num3 = (Dxt1HasAlpha(data) ? 1 : 0);
				break;
			default:
				num3 = 0;
				break;
			case 12:
			case 20:
				num3 = 1;
				break;
			}
			hasAlpha = (byte)num3 != 0;
			return val2;
		}

		private static bool Dxt1HasAlpha(byte[] data)
		{
			for (int i = 0; i + 8 <= data.Length; i += 8)
			{
				ushort num = BitConverter.ToUInt16(data, i);
				ushort num2 = BitConverter.ToUInt16(data, i + 2);
				if (num > num2)
				{
					continue;
				}
				uint num3 = BitConverter.ToUInt32(data, i + 4);
				for (int j = 0; j < 16; j++)
				{
					if (((num3 >> j * 2) & 3) == 3)
					{
						return true;
					}
				}
			}
			return false;
		}

		internal static bool[] ClearTexels(byte[] d, out int width, out int height)
		{
			if (!ReadHeader(d, out width, out height, out var format, out var hasMips) || format == 10)
			{
				return null;
			}
			Color32[] array = Decode(TopLevel(d, format, width, height, hasMips), format, width, height);
			bool[] array2 = new bool[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = array[i].a < 128;
			}
			return array2;
		}

		internal static Sprite LoadIcon(byte[] d, string name)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!ReadHeader(d, out var width, out var height, out var format, out var hasMips))
			{
				return null;
			}
			Color32[] array = Decode(TopLevel(d, format, width, height, hasMips), format, width, height);
			int num = Math.Min(width, height);
			int num2 = (width - num) / 2;
			Color32[] array2 = (Color32[])(object)new Color32[num * num];
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					array2[(num - 1 - i) * num + j] = array[i * width + num2 + j];
				}
			}
			Texture2D val = new Texture2D(num, num, (TextureFormat)4, false)
			{
				name = name
			};
			val.SetPixels32(array2);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
		}

		private static Color32 Color565(ushort c)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			byte num = (byte)(((c >> 11) & 0x1F) * 255 / 31);
			byte b = (byte)(((c >> 5) & 0x3F) * 255 / 63);
			byte b2 = (byte)((c & 0x1F) * 255 / 31);
			return new Color32(num, b, b2, byte.MaxValue);
		}

		private static Color32 Mix(Color32 a, Color32 b, int wa, int wb)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			int num = wa + wb;
			return new Color32((byte)((a.r * wa + b.r * wb) / num), (byte)((a.g * wa + b.g * wb) / num), (byte)((a.b * wa + b.b * wb) / num), byte.MaxValue);
		}

		private static Color32[] Decode(byte[] data, int format, int width, int height)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			Color32[] array = (Color32[])(object)new Color32[width * height];
			int num;
			switch (format)
			{
			case 20:
			{
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = new Color32(data[i * 4 + 2], data[i * 4 + 1], data[i * 4], data[i * 4 + 3]);
				}
				return array;
			}
			default:
				num = 16;
				break;
			case 10:
				num = 8;
				break;
			}
			int num2 = num;
			int num3 = Math.Max(1, (width + 3) / 4);
			int num4 = Math.Max(1, (height + 3) / 4);
			Color32[] array2 = (Color32[])(object)new Color32[4];
			byte[] array3 = new byte[8];
			for (int j = 0; j < num4; j++)
			{
				for (int k = 0; k < num3; k++)
				{
					int num5 = (j * num3 + k) * num2;
					ulong num6 = 0uL;
					if (format == 12)
					{
						array3[0] = data[num5];
						array3[1] = data[num5 + 1];
						if (array3[0] > array3[1])
						{
							for (int l = 1; l < 7; l++)
							{
								array3[l + 1] = (byte)(((7 - l) * array3[0] + l * array3[1]) / 7);
							}
						}
						else
						{
							for (int m = 1; m < 5; m++)
							{
								array3[m + 1] = (byte)(((5 - m) * array3[0] + m * array3[1]) / 5);
							}
							array3[6] = 0;
							array3[7] = byte.MaxValue;
						}
						for (int n = 0; n < 6; n++)
						{
							num6 |= (ulong)data[num5 + 2 + n] << 8 * n;
						}
						num5 += 8;
					}
					ushort num7 = BitConverter.ToUInt16(data, num5);
					ushort num8 = BitConverter.ToUInt16(data, num5 + 2);
					array2[0] = Color565(num7);
					array2[1] = Color565(num8);
					if (num7 > num8 || format == 12)
					{
						array2[2] = Mix(array2[0], array2[1], 2, 1);
						array2[3] = Mix(array2[0], array2[1], 1, 2);
					}
					else
					{
						array2[2] = Mix(array2[0], array2[1], 1, 1);
						array2[3] = new Color32((byte)0, (byte)0, (byte)0, (byte)0);
					}
					uint num9 = BitConverter.ToUInt32(data, num5 + 4);
					for (int num10 = 0; num10 < 4; num10++)
					{
						for (int num11 = 0; num11 < 4; num11++)
						{
							int num12 = k * 4 + num11;
							int num13 = j * 4 + num10;
							if (num12 < width && num13 < height)
							{
								int num14 = num10 * 4 + num11;
								Color32 val = array2[(num9 >> num14 * 2) & 3];
								if (format == 12)
								{
									val.a = array3[(uint)((num6 >> num14 * 3) & 7)];
								}
								array[num13 * width + num12] = val;
							}
						}
					}
				}
			}
			return array;
		}
	}
	internal class LeagueSkinDefinition
	{
		internal string folder;

		internal string meshFile;

		internal string skeletonFile;

		internal string nameToken;

		internal string displayName;

		internal string iconFolder;

		internal string iconTexture;

		internal string defaultTexture;

		internal Dictionary<string, string> partTextures = new Dictionary<string, string>();

		internal string[] hiddenParts = new string[0];
	}
	internal class BuiltLeagueSkin
	{
		internal LeagueSkinDefinition definition;

		internal Sprite icon;

		internal List<GameObject> parts = new List<GameObject>();
	}
	internal static class LeagueSkinBuilder
	{
		private struct SkinFit
		{
			internal Matrix4x4 linear;

			internal Vector3 skinCenter;

			internal Vector3 baseCenter;

			internal float error;

			internal bool turned;

			internal float scale;
		}

		private struct TransferRule
		{
			internal HashSet<Transform> allowed;

			internal HashSet<Transform> damped;

			internal float damping;
		}

		private const string Log = "[Lux LeagueSkins] ";

		internal const string BaseFolder = "Base";

		internal const string BaseSkeletonFile = "lux.skl";

		internal const string BaseMeshFile = "lux.skn";

		internal static readonly string[] BaseExcludedParts = new string[1] { "pasted__lambert4" };

		internal static readonly string[] TransferIgnoredBoneKeywords = new string[2] { "BUFFBONE", "WEAPON" };

		internal const int TransferNeighbors = 8;

		internal const int TransferSmoothIterations = 4;

		internal const string WeaponBone = "WEAPON";

		internal const string WeaponCenterBone = "BUFFBONE_CSTM_WEAPON_6";

		internal const string FallbackBone = "root";

		internal static readonly string[] CoreJoints = new string[11]
		{
			"hip", "chest", "head", "L_UpArm", "R_UpArm", "L_Hand", "R_Hand", "L_Knee", "R_Knee", "L_Foot",
			"R_Foot"
		};

		private static readonly Dictionary<string, string> NewRigMap = BuildNewRigMap();

		private static readonly HashSet<string> SnapJoints = new HashSet<string>(new string[6] { "root", "hip", "spine", "chest", "neck", "head" }.Concat(new string[8] { "Shoulder", "UpArm", "ForeArm", "Hand", "Thigh", "Knee", "Foot", "Toe" }.SelectMany((string n) => new string[2]
		{
			"L_" + n,
			"R_" + n
		})));

		private static LeagueSkeleton baseSkeleton;

		internal const bool DynamicBones = true;

		private static readonly string[] SpringHairKeywords = new string[11]
		{
			"hair", "bang", "strand", "tassle", "tassel", "bun", "ponytail", "braid", "streamer", "ribbon",
			"scarf"
		};

		private static readonly string[] SpringClothKeywords = new string[11]
		{
			"skirt", "cloth", "robe", "cape", "dress", "gown", "tail", "coat", "sash", "sleeve",
			"cuff"
		};

		private const float MaxDrapeAngle = 50f;

		private const float DrapeAngle = 12f;

		private static readonly string[] HairKeywords = new string[7] { "hair", "bang", "strand", "tassle", "bun", "ponytail", "braid" };

		private static readonly string[] SkirtKeywords = new string[10] { "skirt", "cloth", "robe", "cape", "dress", "gown", "belt", "tail", "coat", "sash" };

		private static readonly Dictionary<string, TransferRule> transferRules = new Dictionary<string, TransferRule>();

		private static readonly Dictionary<string, bool[]> clearCache = new Dictionary<string, bool[]>();

		private static readonly Dictionary<string, Vector2Int> clearSize = new Dictionary<string, Vector2Int>();

		private static Dictionary<string, string> BuildNewRigMap()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "Root", "root" },
				{ "Pelvis", "hip" },
				{ "Spine1", "spine" },
				{ "Spine2", "chest" },
				{ "Spine3", "chest" },
				{ "Neck", "neck" },
				{ "Head", "head" },
				{ "Jaw", "jaw" },
				{ "Hair1", "hair" },
				{ "Hair2", "hair_b" },
				{ "F_Hair", "F_hair" },
				{ "F_Belt1", "F_Belt" },
				{ "F_Belt2", "F_Belt_b" }
			};
			string[] array = new string[2] { "L", "R" };
			foreach (string text in array)
			{
				dictionary[text + "_Clavicle"] = text + "_Shoulder";
				dictionary[text + "_Shoulder"] = text + "_UpArm";
				dictionary[text + "_Elbow"] = text + "_ForeArm";
				dictionary[text + "_Hand"] = text + "_Hand";
				dictionary[text + "_Hip"] = text + "_Thigh";
				dictionary[text + "_KneeUpper"] = text + "_Knee";
				dictionary[text + "_KneeLower"] = text + "_Knee";
				dictionary[text + "_Foot"] = text + "_Foot";
				dictionary[text + "_Toe"] = text + "_Toe";
				dictionary[text + "_Index1"] = text + "_Finger_Index";
				dictionary[text + "_Index2"] = text + "_Finger_Index_b";
				dictionary[text + "_Middle1"] = text + "_Finger_Index_c";
				dictionary[text + "_Middle2"] = text + "_Finger_Index_d";
				dictionary[text + "_Ring1"] = text + "_Finger_Index_e";
				dictionary[text + "_Ring2"] = text + "_Finger_Index_f";
				dictionary[text + "_Pinky1"] = text + "_Finger_Index_g";
				dictionary[text + "_Pinky2"] = text + "_Finger_Index_h";
				dictionary[text + "_Thumb1"] = text + "_Thumb_Index";
				dictionary[text + "_Thumb2"] = text + "_Thumb_Index_b";
				dictionary["B_" + text + "_Cloth1"] = "B_" + text + "_Cloth";
				dictionary["B_" + text + "_Cloth2"] = "B_" + text + "_Cloth_b";
				dictionary["F_" + text + "_Cloth1"] = "F_" + text + "_Cloth";
				dictionary[text + "_Cloth1"] = text + "_Cloth";
			}
			return dictionary;
		}

		internal static List<BuiltLeagueSkin> BuildAll(GameObject bodyModel, SkinnedMeshRenderer bodyRenderer, CharacterModel characterModel, GameObject displayModel)
		{
			List<BuiltLeagueSkin> list = new List<BuiltLeagueSkin>();
			if (!Object.op_Implicit((Object)(object)bodyModel) || !Object.op_Implicit((Object)(object)bodyRenderer) || !Object.op_Implicit((Object)(object)characterModel))
			{
				return list;
			}
			try
			{
				if (baseSkeleton == null)
				{
					byte[] array = LeagueResources.Load("Base", "lux.skl");
					if (array == null)
					{
						return list;
					}
					baseSkeleton = LeagueSkeleton.Read(array);
				}
			}
			catch (Exception)
			{
				return list;
			}
			RigSpace rig;
			try
			{
				rig = RigSpace.Create(baseSkeleton, bodyModel, bodyRenderer);
			}
			catch (Exception)
			{
				return list;
			}
			BaseWeightSource weightSource = null;
			try
			{
				weightSource = BaseWeightSource.Create(baseSkeleton, rig);
			}
			catch
			{
			}
			Material template = ((characterModel.baseRendererInfos.Length != 0) ? characterModel.baseRendererInfos[0].defaultMaterial : null);
			List<RendererInfo> list2 = characterModel.baseRendererInfos.ToList();
			LeagueSkinDefinition[] definitions = LeagueSkinCatalog.definitions;
			foreach (LeagueSkinDefinition definition in definitions)
			{
				try
				{
					BuiltLeagueSkin builtLeagueSkin = Build(definition, rig, template, displayModel, list2, weightSource);
					if (builtLeagueSkin != null)
					{
						list.Add(builtLeagueSkin);
					}
				}
				catch
				{
				}
			}
			characterModel.baseRendererInfos = list2.ToArray();
			return list;
		}

		internal static void AddSkins(List<SkinDef> skins, List<BuiltLeagueSkin> leagueSkins, GameObject bodyModel, GameObject[] baseObjects, CharacterModel characterModel)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			if (leagueSkins.Count == 0)
			{
				return;
			}
			baseObjects = baseObjects.Where((GameObject o) => Object.op_Implicit((Object)(object)o)).ToArray();
			List<GameObject> list = leagueSkins.SelectMany((BuiltLeagueSkin s) => s.parts).ToList();
			foreach (SkinDef skin in skins)
			{
				List<GameObjectActivation> list2 = ((IEnumerable<GameObjectActivation>)(((object)skin.gameObjectActivations) ?? ((object)new GameObjectActivation[0]))).ToList();
				GameObject[] array = baseObjects;
				foreach (GameObject gameObject in array)
				{
					list2.Add(new GameObjectActivation
					{
						gameObject = gameObject,
						shouldActivate = true
					});
				}
				foreach (GameObject item in list)
				{
					list2.Add(new GameObjectActivation
					{
						gameObject = item,
						shouldActivate = false
					});
				}
				skin.gameObjectActivations = list2.ToArray();
			}
			Sprite val = ((skins.Count > 0) ? skins[0].icon : null);
			foreach (BuiltLeagueSkin leagueSkin in leagueSkins)
			{
				LanguageAPI.Add(leagueSkin.definition.nameToken, "<color=#ffa700>" + leagueSkin.definition.displayName + "</color>");
				List<GameObjectActivation> list3 = new List<GameObjectActivation>();
				GameObject[] array = baseObjects;
				foreach (GameObject gameObject2 in array)
				{
					list3.Add(new GameObjectActivation
					{
						gameObject = gameObject2,
						shouldActivate = false
					});
				}
				foreach (GameObject item2 in list)
				{
					list3.Add(new GameObjectActivation
					{
						gameObject = item2,
						shouldActivate = leagueSkin.parts.Contains(item2)
					});
				}
				SkinDef val2 = Skins.CreateSkinDef(leagueSkin.definition.nameToken, Object.op_Implicit((Object)(object)leagueSkin.icon) ? leagueSkin.icon : val, characterModel.baseRendererInfos, bodyModel);
				val2.gameObjectActivations = list3.ToArray();
				skins.Add(val2);
			}
		}

		private static Dictionary<string, Transform> CollectBones(GameObject root)
		{
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!dictionary.ContainsKey(((Object)val).name))
				{
					dictionary[((Object)val).name] = val;
				}
			}
			return dictionary;
		}

		private static string PathFrom(Transform root, Transform target)
		{
			List<string> list = new List<string>();
			Transform val = target;
			while (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)root)
			{
				list.Insert(0, ((Object)val).name);
				val = val.parent;
			}
			return string.Join("/", list);
		}

		private static bool IsNewRig(LeagueSkeleton skeleton)
		{
			if (!skeleton.index.ContainsKey("Pelvis"))
			{
				return skeleton.index.ContainsKey("Spine1");
			}
			return true;
		}

		private static string BaseName(LeagueSkeleton skeleton, bool newRig, string name)
		{
			if (!newRig)
			{
				return name;
			}
			if (!NewRigMap.TryGetValue(name, out var value))
			{
				return null;
			}
			return value;
		}

		private static bool IsWeaponJoint(LeagueSkeleton skeleton, int joint)
		{
			for (int num = joint; num >= 0; num = skeleton.parents[num])
			{
				string text = skeleton.names[num];
				if (text.IndexOf("weapon", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("wand", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static Vector3 Position(Matrix4x4 m)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(3));
		}

		private static SkinFit FitSkin(LeagueSkeleton skeleton, bool newRig)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: 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_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			HashSet<string> hashSet = new HashSet<string>();
			for (int i = 0; i < skeleton.names.Length; i++)
			{
				string text = BaseName(skeleton, newRig, skeleton.names[i]);
				if (text != null && Array.IndexOf(CoreJoints, text) >= 0 && !hashSet.Contains(text) && baseSkeleton.index.ContainsKey(text))
				{
					hashSet.Add(text);
					list.Add(Position(skeleton.rest[i]));
					list2.Add(Position(baseSkeleton.rest[baseSkeleton.index[text]]));
				}
			}
			SkinFit result = new SkinFit
			{
				linear = Matrix4x4.identity,
				error = float.MaxValue,
				scale = 1f
			};
			if (list.Count < 3)
			{
				result.error = 0f;
				return result;
			}
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.zero;
			for (int j = 0; j < list.Count; j++)
			{
				val += list[j];
				val2 += list2[j];
			}
			val /= (float)list.Count;
			val2 /= (float)list2.Count;
			bool[] array = new bool[2] { false, true };
			foreach (bool flag in array)
			{
				Matrix4x4 val3 = (flag ? Matrix4x4.Scale(new Vector3(-1f, 1f, -1f)) : Matrix4x4.identity);
				float num = 0f;
				float num2 = 0f;
				Vector3 val5;
				for (int l = 0; l < list.Count; l++)
				{
					Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyVector(list[l] - val);
					float num3 = num;
					val5 = list2[l] - val2;
					num = num3 + ((Vector3)(ref val5)).sqrMagnitude;
					num2 += ((Vector3)(ref val4)).sqrMagnitude;
				}
				float num4 = ((num2 > 0f) ? Mathf.Sqrt(num / num2) : 1f);
				float num5 = 0f;
				for (int m = 0; m < list.Count; m++)
				{
					float num6 = num5;
					val5 = ((Matrix4x4)(ref val3)).MultiplyVector(list[m] - val) * num4 + val2 - list2[m];
					num5 = num6 + ((Vector3)(ref val5)).sqrMagnitude;
				}
				num5 = Mathf.Sqrt(num5 / (float)list.Count);
				if (num5 < result.error)
				{
					result = new SkinFit
					{
						linear = Matrix4x4.Scale(Vector3.one * num4) * val3,
						skinCenter = val,
						baseCenter = val2,
						error = num5,
						turned = flag,
						scale = num4
					};
				}
			}
			return result;
		}

		private static BuiltLeagueSkin Build(LeagueSkinDefinition definition, RigSpace rig, Material template, GameObject displayModel, List<RendererInfo> rendererInfos, BaseWeightSource weightSource)
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown re