Decompiled source of CustomCharacterCreator v1.4.0

mod/CustomCharacterLoader.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Audio.Music;
using Assets.Scripts.Inventory__Items__Pickups.AbilitiesPassive;
using Assets.Scripts.Inventory__Items__Pickups.Stats;
using Assets.Scripts.Inventory__Items__Pickups.Upgrades;
using Assets.Scripts.Menu.Shop;
using Assets.Scripts.Saves___Serialization.Progression;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Saves___Serialization.Progression.Stats;
using Assets.Scripts.Saves___Serialization.Progression.Unlocks;
using Assets.Scripts.UI.Localization;
using Assets.Scripts._Data;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CustomCharacterLoader;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.IO;
using JigglePhysics;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.LowLevel;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("CustomCharacterLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+cdfc1c08f1ed9232b1cdd07996b807e2452d7611")]
[assembly: AssemblyProduct("CustomCharacterLoader")]
[assembly: AssemblyTitle("CustomCharacterLoader")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
public class MyPhysicsBone : MonoBehaviour
{
	public float damping = 0.4f;

	public AnimationCurve dampingCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
	{
		new Keyframe(0f, 0.8f),
		new Keyframe(1f, 1f)
	});

	public float stiffness = 1f;

	public AnimationCurve stiffnessCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
	{
		new Keyframe(0f, 1f),
		new Keyframe(1f, 1f)
	});

	public float elasticity = 0.15f;

	public AnimationCurve elasticityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
	{
		new Keyframe(0f, 1f),
		new Keyframe(1f, 0.8f)
	});

	public float inert = 0.15f;

	public AnimationCurve inertCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
	{
		new Keyframe(0f, 1f),
		new Keyframe(0.5f, 0.2f),
		new Keyframe(1f, 1f)
	});

	public Vector3 gravity = Vector3.zero;

	private Vector3[] particlePositions;

	private Vector3[] previousBonePositions;

	private Vector3[] previousParticlePositions;

	private Transform[] bones = (Transform[])(object)new Transform[0];

	private float[] segmentLengths;

	private void Start()
	{
		InitializeBones();
	}

	private void LateUpdate()
	{
		SimulateBonePhysics();
	}

	private void InitializeBones()
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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_00d3: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		Il2CppArrayBase<Transform> componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>();
		bones = Enumerable.ToArray<Transform>(Enumerable.Concat<Transform>((global::System.Collections.Generic.IEnumerable<Transform>)(object)new Transform[1] { ((Component)this).transform.parent }, (global::System.Collections.Generic.IEnumerable<Transform>)componentsInChildren));
		int num = bones.Length;
		segmentLengths = new float[num - 1];
		particlePositions = (Vector3[])(object)new Vector3[num];
		previousBonePositions = (Vector3[])(object)new Vector3[num];
		previousParticlePositions = (Vector3[])(object)new Vector3[num];
		for (int i = 0; i < num; i++)
		{
			particlePositions[i] = bones[i].position;
			previousBonePositions[i] = bones[i].position;
			previousParticlePositions[i] = particlePositions[i];
			if (i > 0)
			{
				float[] array = segmentLengths;
				int num2 = i - 1;
				Vector3 val = particlePositions[i] - particlePositions[i - 1];
				array[num2] = ((Vector3)(ref val)).magnitude;
			}
		}
	}

	private void SimulateBonePhysics()
	{
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		int num = 1;
		for (int i = 0; i < 1; i++)
		{
			for (int j = 0; j < bones.Length; j++)
			{
				int num2 = j / (bones.Length - 1);
				float num3 = damping * dampingCurve.Evaluate((float)num2);
				float num4 = elasticity * elasticityCurve.Evaluate((float)num2);
				float num5 = stiffness * stiffnessCurve.Evaluate((float)num2);
				float num6 = inert * inertCurve.Evaluate((float)num2);
				Vector3 position = bones[j].position;
				Vector3 val = particlePositions[j];
				Vector3 val2 = val - previousParticlePositions[j];
				Vector3 val3 = bones[j].position - previousBonePositions[j];
				Vector3 val4 = gravity * (float)(num * num) + val2 * ((float)num * (1f - num3)) + val3 * ((float)num * (1f - num5));
				Vector3 val5 = position - val;
				Vector3 val6 = val5 * num4;
				previousParticlePositions[j] = particlePositions[j];
				particlePositions[j] = val + val6 + val4;
				particlePositions[j] = Vector3.Lerp(particlePositions[j], position, num6);
			}
		}
		particlePositions[0] = bones[0].position;
		for (int k = 0; k < particlePositions.Length; k++)
		{
			previousBonePositions[k] = bones[k].position;
			bones[k].position = particlePositions[k];
		}
	}

	private void OnDrawGizmos()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if (bones.Length != 0)
		{
			Gizmos.color = Color.cyan;
			for (int i = 0; i < bones.Length - 1; i++)
			{
				Gizmos.DrawLine(bones[i].position, bones[i + 1].position);
			}
			Gizmos.color = Color.blue;
			for (int j = 0; j < particlePositions.Length - 1; j++)
			{
				Gizmos.DrawLine(previousParticlePositions[j], previousParticlePositions[j + 1]);
			}
		}
	}

	public static void CopyValuesTo(MyPhysicsBone oldBone, MyPhysicsBone newBone)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		newBone.stiffness = oldBone.stiffness;
		newBone.damping = oldBone.damping;
		newBone.elasticity = oldBone.elasticity;
		newBone.gravity = oldBone.gravity;
		newBone.inert = oldBone.inert;
		newBone.dampingCurve = oldBone.dampingCurve;
		newBone.elasticityCurve = oldBone.elasticityCurve;
		newBone.inertCurve = oldBone.inertCurve;
		newBone.stiffnessCurve = oldBone.stiffnessCurve;
	}
}
namespace CustomCharacterLoader
{
	public class CharacterAdder
	{
		private readonly DataManager _dataManager;

		private readonly JObject _assetJSON;

		private readonly AssetBundle _assetBundle;

		private uint _eCharacter;

		private ManualLogSource Log;

		private string _author;

		public CharacterAdder(DataManager dataManager, JObject assetJson, AssetBundle assetBundle, ManualLogSource Log)
		{
			_dataManager = dataManager;
			_assetJSON = assetJson;
			_assetBundle = assetBundle;
			this.Log = Log;
		}

		public ECharacter AddCustomCharacter()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			CharacterData val = LoadCharacter();
			Log.LogDebug((object)"Loaded character data");
			List<SkinData> val2 = LoadSkins();
			Log.LogDebug((object)"Loaded skin data");
			PassiveData passive = LoadPassive();
			Log.LogDebug((object)"Loaded passive data");
			WeaponData val3 = LoadWeapon();
			Log.LogDebug((object)"Loaded weapon data");
			val.passive = passive;
			val.weapon = val3;
			ECharacter val4 = (ECharacter)_eCharacter;
			EWeapon val5 = (EWeapon)_eCharacter;
			_dataManager.weapons.Add(val5, val3);
			EffectManager.weaponNamesCache.Add(val5, ((Object)val3).name);
			CustomCharacterLoaderPlugin.InjectComponent.Instance.AddCustomWeapon(val3);
			_dataManager.unsortedCharacterData.Add(val);
			_dataManager.unsortedWeapons.Add(val3);
			_dataManager.unsortedUnlockables.Add((UnlockableBase)(object)val3);
			Log.LogInfo((object)("Loaded Custom Character: " + ((Object)val).name));
			return (ECharacter)_eCharacter;
		}

		private List<SkinData> LoadSkins()
		{
			JSkin[] array = JSkin.FromJSON(((Il2CppObjectBase)_assetJSON["skins"]).Cast<JArray>());
			List<SkinData> val = new List<SkinData>();
			_dataManager.skinData.Add((ECharacter)_eCharacter, val);
			Log.LogDebug((object)("Skin count: " + array.Length));
			int num = 0;
			JSkin[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				JSkin jSkin = array2[i];
				num++;
				SkinData val2 = ScriptableObject.CreateInstance<SkinData>();
				val.Add(val2);
				((UnlockableBase)val2).author = _author;
				val2.character = (ECharacter)_eCharacter;
				((Object)val2).name = jSkin.skinName;
				((UnlockableBase)val2).localizedName = CreateUniqueLocalizedString("skinName" + num, jSkin.skinName);
				((UnlockableBase)val2).localizedDescription = CreateUniqueLocalizedString("skinDescription" + num, jSkin.description);
				((UnlockableBase)val2).serializedLocalizationKeysName = new List<LocalizationKey>();
				((UnlockableBase)val2).serializedLocalizationKeys = new List<LocalizationKey>();
				val2.icon = (Texture)(object)this.LoadAsset<Texture2D>(jSkin.iconPath);
				List<Material> val3 = new List<Material>();
				Enumerator<string> enumerator = jSkin.materialPaths.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					Material val4 = this.LoadAsset<Material>(current);
					val3.Add(val4);
				}
				val2.materials = ((Il2CppObjectBase)val3.ToArray()).Cast<Il2CppReferenceArray<Material>>();
			}
			return val;
		}

		private WeaponData LoadWeapon()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			JWeapon jWeapon = JWeapon.FromJSON(((Il2CppObjectBase)_assetJSON["weapon"]).Cast<JObject>());
			WeaponData val = ScriptableObject.CreateInstance<WeaponData>();
			((UnlockableBase)val).author = _author;
			val.eWeapon = (EWeapon)_eCharacter;
			((Object)val).name = jWeapon.weaponName;
			val.damageSourceName = jWeapon.weaponName;
			val.description = jWeapon.weaponDescription;
			((UnlockableBase)val).localizedName = CreateUniqueLocalizedString("weaponName", jWeapon.weaponName);
			((UnlockableBase)val).localizedDescription = CreateUniqueLocalizedString("weaponDescription", jWeapon.weaponDescription);
			((UnlockableBase)val).serializedLocalizationKeysName = new List<LocalizationKey>();
			((UnlockableBase)val).serializedLocalizationKeys = new List<LocalizationKey>();
			val.icon = (Texture)(object)this.LoadAsset<Texture2D>(jWeapon.iconPath);
			val.attack = this.LoadAsset<GameObject>(jWeapon.weaponAttackPath);
			val.baseStats = new Dictionary<EStat, float>();
			val.AchievementRequirement = null;
			Enumerator<JWeapon.BaseStat> enumerator = jWeapon.stats.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					JWeapon.BaseStat current = enumerator.Current;
					val.baseStats.Add((EStat)current.Stat, current.Value);
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
			val.upgradeData = Object.Instantiate<UpgradeData>(ScriptableObject.CreateInstance<UpgradeData>());
			val.upgradeData.upgradeModifiers = jWeapon.UpgradeOptions;
			return val;
		}

		private CharacterData LoadCharacter()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			JCharacter jCharacter = JCharacter.FromJSON(((Il2CppObjectBase)_assetJSON["character"]).Cast<JObject>());
			CharacterData val = ScriptableObject.CreateInstance<CharacterData>();
			val.eCharacter = (ECharacter)jCharacter.eCharacter;
			_dataManager.characterData.Add(val.eCharacter, val);
			_eCharacter = jCharacter.eCharacter;
			_author = jCharacter.author;
			((UnlockableBase)val).author = jCharacter.author;
			val.eCharacter = (ECharacter)jCharacter.eCharacter;
			((Object)val).name = jCharacter.characterName;
			Log.LogDebug((object)((Object)val).name);
			((UnlockableBase)val).localizedName = CreateUniqueLocalizedString("characterName", jCharacter.characterName);
			((UnlockableBase)val).serializedLocalizationKeysName = new List<LocalizationKey>();
			((UnlockableBase)val).serializedLocalizationKeys = new List<LocalizationKey>();
			val.description = jCharacter.characterDescription;
			((UnlockableBase)val).localizedDescription = CreateUniqueLocalizedString("characterDescription", jCharacter.characterDescription);
			val.colliderHeight = jCharacter.colliderHeight;
			val.colliderWidth = jCharacter.colliderWidth;
			val.coolness = jCharacter.coolness;
			val.difficulty = jCharacter.difficulty;
			val.prefab = this.LoadAsset<GameObject>(jCharacter.prefabPath);
			JToken obj = _assetJSON["character"];
			JToken obj2 = ((obj is JObject) ? obj : null);
			JToken obj3 = ((obj2 != null) ? ((JObject)obj2)["physicsBones"] : null);
			JArray val2 = (JArray)(object)((obj3 is JArray) ? obj3 : null);
			if (val2 != null)
			{
				PhysBoneAdder.SetBonesOnPrefab(val.prefab, val2);
			}
			JToken obj4 = _assetJSON["character"];
			object obj5;
			if (obj4 == null)
			{
				obj5 = null;
			}
			else
			{
				JToken obj6 = ((Il2CppObjectBase)obj4).Cast<JObject>()["jiggleBones"];
				obj5 = ((obj6 != null) ? ((Il2CppObjectBase)obj6).Cast<JArray>() : null);
			}
			JArray val3 = (JArray)obj5;
			if (val3 != null)
			{
				PhysBoneAdder.SetJiggleOnPrefab(val.prefab, val3);
			}
			val.icon = (Texture)(object)this.LoadAsset<Texture2D>(jCharacter.iconPath);
			val.statModifiers = jCharacter.statModifiers;
			val.StatCategoryRatios = jCharacter.categoryRatios;
			val.categoryRatios = new Dictionary<EStatCategory, float>();
			Enumerator<StatCategoryRatio> enumerator = jCharacter.categoryRatios.GetEnumerator();
			while (enumerator.MoveNext())
			{
				StatCategoryRatio current = enumerator.Current;
				val.categoryRatios[current.category] = current.value;
			}
			Log.LogDebug((object)"Try loading audio");
			if (!string.IsNullOrEmpty(jCharacter.themeSongPath))
			{
				val.themeSong = this.LoadAsset<MusicTrack>(jCharacter.themeSongPath);
			}
			if (jCharacter.audioFootstepsPaths != null)
			{
				val.audioFootsteps = Il2CppReferenceArray<AudioClip>.op_Implicit((AudioClip[])(object)new AudioClip[jCharacter.audioFootstepsPaths.Count]);
				for (int i = 0; i < jCharacter.audioFootstepsPaths.Count; i++)
				{
					((Il2CppArrayBase<AudioClip>)(object)val.audioFootsteps)[i] = this.LoadAsset<AudioClip>(jCharacter.audioFootstepsPaths[i]);
				}
			}
			return val;
		}

		public PassiveData LoadPassive()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			JPassive jPassive = JPassive.FromJSON(((Il2CppObjectBase)_assetJSON["passive"]).Cast<JObject>());
			PassiveData val = ScriptableObject.CreateInstance<PassiveData>();
			val.dummyPassive = new PassiveAbility();
			val.icon = (Texture)(object)this.LoadAsset<Texture2D>(jPassive.iconPath);
			val.ePassive = jPassive.passive;
			val.name = jPassive.passiveName;
			((Il2CppObjectBase)val).Cast<Object>().name = jPassive.passiveName;
			val.localizedName = CreateUniqueLocalizedString("passiveName", jPassive.passiveName);
			val.localizedDescription = CreateUniqueLocalizedString("passiveDescription", jPassive.passiveDescription);
			return val;
		}

		public void ReadJSON(string json)
		{
			JObject val = JObject.Parse(json);
		}

		public T LoadAsset<T>(string assetName) where T : Il2CppObjectBase
		{
			return ((Il2CppObjectBase)((ResourceRequest)_assetBundle.LoadAssetAsync(assetName, Il2CppType.Of<T>())).GetResult()).Cast<T>();
		}

		public LocalizedString CreateUniqueLocalizedString(string key, string value)
		{
			string text = _eCharacter.ToString() ?? "";
			string uid = $"{_eCharacter}.{key}";
			return CustomCharacterLoaderPlugin.CreateLocalizedString(uid, value);
		}
	}
	[Serializable]
	public struct JPassive
	{
		public string passiveName;

		public string passiveDescription;

		public EPassive passive;

		public string iconPath;

		public static JPassive FromJSON(JObject jobj)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			JPassive result = default(JPassive);
			result.iconPath = jobj["iconPath"].ToObject<string>();
			result.passiveName = jobj["passiveName"].ToObject<string>();
			result.passive = (EPassive)jobj["passive"].ToObject<int>();
			result.passiveDescription = jobj["passiveDescription"].ToObject<string>();
			return result;
		}
	}
	public class JTest
	{
		public string author;
	}
	[Serializable]
	public struct JCharacter
	{
		public string author;

		public uint eCharacter;

		public string assetBundleName;

		public string characterName;

		public string characterDescription;

		public float colliderHeight;

		public float colliderWidth;

		public int coolness;

		public int difficulty;

		public Il2CppArrayBase<string> audioFootstepsPaths;

		public string themeSongPath;

		public string prefabPath;

		public string iconPath;

		public List<StatModifier> statModifiers;

		public List<StatCategoryRatio> categoryRatios;

		public static JCharacter FromJSON(JObject jobj)
		{
			JCharacter result = default(JCharacter);
			result.author = jobj["author"].ToObject<string>();
			result.eCharacter = jobj["eCharacter"].ToObject<uint>();
			result.assetBundleName = jobj["assetBundleName"].ToObject<string>();
			result.characterName = jobj["characterName"].ToObject<string>();
			result.characterDescription = jobj["characterDescription"].ToObject<string>();
			result.colliderHeight = jobj["colliderHeight"].ToObject<float>();
			result.colliderWidth = jobj["colliderWidth"].ToObject<float>();
			result.coolness = jobj["coolness"].ToObject<int>();
			result.difficulty = jobj["difficulty"].ToObject<int>();
			JToken obj = jobj["audioFootstepsPaths"];
			result.audioFootstepsPaths = ((obj != null) ? obj.ToObject<Il2CppArrayBase<string>>() : null);
			JToken obj2 = jobj["themeSongPath"];
			result.themeSongPath = ((obj2 != null) ? obj2.ToObject<string>() : null);
			result.prefabPath = jobj["prefabPath"].ToObject<string>();
			result.iconPath = jobj["iconPath"].ToObject<string>();
			result.statModifiers = jobj["statModifiers"].ToObject<List<StatModifier>>();
			result.categoryRatios = jobj["categoryRatios"].ToObject<List<StatCategoryRatio>>();
			return result;
		}
	}
	[Serializable]
	public struct JWeapon
	{
		[Serializable]
		public struct BaseStat
		{
			public int Stat;

			public float Value;
		}

		public string weaponName;

		public string weaponDescription;

		public List<StatModifier> UpgradeOptions;

		public List<BaseStat> stats;

		public string iconPath;

		public string weaponAttackPath;

		public static JWeapon FromJSON(JObject jobj)
		{
			List<BaseStat> val = new List<BaseStat>();
			JArray val2 = ((Il2CppObjectBase)jobj["stats"]).Cast<JArray>();
			Enumerator<JToken> enumerator = val2._values.GetEnumerator();
			while (enumerator.MoveNext())
			{
				JToken current = enumerator.Current;
				BaseStat baseStat = default(BaseStat);
				baseStat.Stat = ((Il2CppObjectBase)current).Cast<JObject>()["Stat"].ToObject<int>();
				baseStat.Value = ((Il2CppObjectBase)current).Cast<JObject>()["Value"].ToObject<float>();
				BaseStat baseStat2 = baseStat;
				val.Add(baseStat2);
			}
			JWeapon result = default(JWeapon);
			result.weaponName = jobj["weaponName"].ToObject<string>();
			result.weaponDescription = jobj["weaponDescription"].ToObject<string>();
			result.UpgradeOptions = jobj["UpgradeOptions"].ToObject<List<StatModifier>>();
			result.stats = val;
			result.iconPath = jobj["iconPath"].ToObject<string>();
			result.weaponAttackPath = jobj["weaponAttackPath"].ToObject<string>();
			return result;
		}
	}
	[Serializable]
	public struct JSkin
	{
		public string skinName;

		public string description;

		public string iconPath;

		public List<string> materialPaths;

		public static JSkin[] FromJSON(JArray jobj)
		{
			List<JSkin> val = new List<JSkin>();
			Enumerator<JToken> enumerator = jobj._values.GetEnumerator();
			while (enumerator.MoveNext())
			{
				JToken current = enumerator.Current;
				JObject val2 = ((Il2CppObjectBase)current).Cast<JObject>();
				val.Add(new JSkin
				{
					skinName = val2["skinName"].ToObject<string>(),
					description = val2["description"].ToObject<string>(),
					iconPath = val2["iconPath"].ToObject<string>(),
					materialPaths = val2["materialPaths"].ToObject<List<string>>()
				});
			}
			return val.ToArray();
		}
	}
	public class PhysBoneAdder
	{
		public struct JJiggleBone
		{
			public struct JJiggleData
			{
				public float gravityMultiplier;

				public float friction;

				public float angleElasticity;

				public float blend;

				public float airDrag;

				public float lengthElasticity;

				public float elasticitySoften;

				public float radiusMultiplier;

				public AnimationCurve radiusCurve;

				public static JJiggleData FromJson(JObject jiggleData)
				{
					JJiggleData result = default(JJiggleData);
					result.gravityMultiplier = jiggleData["gravityMultiplier"].ToObject<float>();
					result.friction = jiggleData["friction"].ToObject<float>();
					result.angleElasticity = jiggleData["angleElasticity"].ToObject<float>();
					result.blend = jiggleData["blend"].ToObject<float>();
					result.airDrag = jiggleData["airDrag"].ToObject<float>();
					result.lengthElasticity = jiggleData["lengthElasticity"].ToObject<float>();
					result.elasticitySoften = jiggleData["elasticitySoften"].ToObject<float>();
					result.radiusMultiplier = jiggleData["radiusMultiplier"].ToObject<float>();
					result.radiusCurve = JPhysBone.GetAnimCurveFromJson(jiggleData["radiusCurve"].ToObject<JArray>());
					return result;
				}
			}

			public string name;

			public string rootName;

			public Vector3 wind;

			public string[] colliders;

			public JJiggleData data;

			public static JJiggleBone FromJson(JObject jiggleRig)
			{
				//IL_002a: 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_006f: Unknown result type (might be due to invalid IL or missing references)
				JToken obj = jiggleRig["wind"];
				string[] array = ((obj == null) ? null : obj.ToObject<string>()?.Split(' ', (StringSplitOptions)0));
				Vector3 val = default(Vector3);
				if (array != null && array.Length >= 3)
				{
					((Vector3)(ref val))..ctor(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
				}
				JJiggleBone result = default(JJiggleBone);
				result.wind = val;
				JToken obj2 = jiggleRig["colliders"];
				result.colliders = Il2CppArrayBase<string>.op_Implicit((obj2 != null) ? obj2.ToObject<List<string>>().ToArray() : null);
				JToken obj3 = jiggleRig["name"];
				result.name = ((obj3 != null) ? obj3.ToObject<string>() : null);
				JToken obj4 = jiggleRig["rootName"];
				result.rootName = ((obj4 != null) ? obj4.ToObject<string>() : null);
				result.data = JJiggleData.FromJson(((Il2CppObjectBase)jiggleRig["data"]).Cast<JObject>());
				return result;
			}
		}

		public struct JPhysBone
		{
			public string name;

			public float damping;

			public AnimationCurve dampingCurve;

			public float elasticity;

			public AnimationCurve elasticityCurve;

			public float stiffness;

			public AnimationCurve stiffnessCurve;

			public float inert;

			public AnimationCurve inertCurve;

			public Vector3 gravity;

			public static JPhysBone FromJson(JObject json)
			{
				//IL_002a: 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_0152: Unknown result type (might be due to invalid IL or missing references)
				JToken obj = json["gravity"];
				string[] array = ((obj == null) ? null : obj.ToObject<string>()?.Split(' ', (StringSplitOptions)0));
				Vector3 val = default(Vector3);
				if (array != null && array.Length >= 3)
				{
					((Vector3)(ref val))..ctor(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
				}
				JPhysBone result = default(JPhysBone);
				result.name = json["name"].ToObject<string>();
				result.damping = json["damping"].ToObject<float>();
				result.dampingCurve = GetAnimCurveFromJson(json["dampingCurve"].ToObject<JArray>());
				result.elasticity = json["elasticity"].ToObject<float>();
				result.elasticityCurve = GetAnimCurveFromJson(json["elasticityCurve"].ToObject<JArray>());
				result.stiffness = json["stiffness"].ToObject<float>();
				result.stiffnessCurve = GetAnimCurveFromJson(json["stiffnessCurve"].ToObject<JArray>());
				result.inert = json["inert"].ToObject<float>();
				result.inertCurve = GetAnimCurveFromJson(json["inertCurve"].ToObject<JArray>());
				result.gravity = val;
				return result;
			}

			public static AnimationCurve GetAnimCurveFromJson(JArray json)
			{
				//IL_0048: 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_0069: Expected O, but got Unknown
				List<Keyframe> val = new List<Keyframe>();
				Enumerator<JToken> enumerator = json._values.GetEnumerator();
				while (enumerator.MoveNext())
				{
					JToken current = enumerator.Current;
					JArray val2 = ((Il2CppObjectBase)current).Cast<JArray>();
					int num = val2[0].ToObject<int>();
					int num2 = val2[1].ToObject<int>();
					val.Add(new Keyframe((float)num, (float)num2));
				}
				return new AnimationCurve(val.ToArray());
			}
		}

		public static void SetBonesOnPrefab(GameObject prefab, JArray boneJson)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource log = CustomCharacterLoaderPlugin.InjectComponent.Instance.Log;
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(boneJson._values.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Phys Bones");
			}
			val.LogDebug(val2);
			Il2CppArrayBase<MyPhysicsBone> componentsInChildren = prefab.GetComponentsInChildren<MyPhysicsBone>();
			Enumerator<JToken> enumerator = boneJson._values.GetEnumerator();
			while (enumerator.MoveNext())
			{
				JToken current = enumerator.Current;
				JPhysBone jPhysBone = JPhysBone.FromJson(((Il2CppObjectBase)current).Cast<JObject>());
				MyPhysicsBone myPhysicsBone = Enumerable.First<MyPhysicsBone>((global::System.Collections.Generic.IEnumerable<MyPhysicsBone>)componentsInChildren, (Func<MyPhysicsBone, bool>)((MyPhysicsBone b) => ((Object)b).name == jPhysBone.name));
				myPhysicsBone.damping = jPhysBone.damping;
				myPhysicsBone.gravity = jPhysBone.gravity;
				myPhysicsBone.elasticity = jPhysBone.elasticity;
				myPhysicsBone.stiffness = jPhysBone.stiffness;
				myPhysicsBone.inert = jPhysBone.inert;
				myPhysicsBone.stiffnessCurve = jPhysBone.stiffnessCurve;
				myPhysicsBone.dampingCurve = jPhysBone.dampingCurve;
				myPhysicsBone.elasticityCurve = jPhysBone.elasticityCurve;
				myPhysicsBone.inertCurve = jPhysBone.inertCurve;
			}
		}

		public static void SetJiggleOnPrefab(GameObject prefab, JArray jiggleBones)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource log = CustomCharacterLoaderPlugin.InjectComponent.Instance.Log;
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(21, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(jiggleBones._values.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Jiggle Bones");
			}
			val.LogDebug(val2);
			Il2CppArrayBase<Collider> componentsInChildren = prefab.GetComponentsInChildren<Collider>();
			List<JiggleRigBuilder> val3 = Enumerable.ToList<JiggleRigBuilder>((global::System.Collections.Generic.IEnumerable<JiggleRigBuilder>)prefab.GetComponentsInChildren<JiggleRigBuilder>());
			ManualLogSource val4 = log;
			val2 = new BepInExDebugLogInterpolatedStringHandler(34, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Found ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val3.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Rigs for prefab's children ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)prefab).name);
			}
			val4.LogDebug(val2);
			Enumerator<JToken> enumerator = jiggleBones._values.GetEnumerator();
			while (enumerator.MoveNext())
			{
				JToken current = enumerator.Current;
				JJiggleBone jiggleData = JJiggleBone.FromJson(((Il2CppObjectBase)current).Cast<JObject>());
				JiggleRigBuilder jiggleRigBuilder = Enumerable.First<JiggleRigBuilder>((global::System.Collections.Generic.IEnumerable<JiggleRigBuilder>)val3, (Func<JiggleRigBuilder, bool>)((JiggleRigBuilder r) => ((Object)r).name == jiggleData.name));
				val3.Remove(jiggleRigBuilder);
				jiggleRigBuilder.rootTransform = Enumerable.First<Transform>((global::System.Collections.Generic.IEnumerable<Transform>)prefab.GetComponentsInChildren<Transform>(), (Func<Transform, bool>)((Transform tf) => ((Object)tf).name == jiggleData.rootName));
				jiggleRigBuilder.wind = jiggleData.wind;
				jiggleRigBuilder.colliders = new List<Collider>();
				string[] colliders = jiggleData.colliders;
				foreach (string colliderName in colliders)
				{
					Collider val5 = Enumerable.First<Collider>((global::System.Collections.Generic.IEnumerable<Collider>)componentsInChildren, (Func<Collider, bool>)((Collider c) => ((Object)c).name == colliderName));
					jiggleRigBuilder.colliders.Add(val5);
				}
				JiggleSettingsData data = default(JiggleSettingsData);
				data.gravityMultiplier = jiggleData.data.gravityMultiplier;
				data.friction = jiggleData.data.friction;
				data.angleElasticity = jiggleData.data.angleElasticity;
				data.blend = jiggleData.data.blend;
				data.airDrag = jiggleData.data.airDrag;
				data.lengthElasticity = jiggleData.data.lengthElasticity;
				data.elasticitySoften = jiggleData.data.elasticitySoften;
				data.radiusMultiplier = jiggleData.data.radiusMultiplier;
				data.radiusCurve = jiggleData.data.radiusCurve;
				jiggleRigBuilder.data = data;
				jiggleRigBuilder.Initialize();
			}
		}

		public static void CopyRigsValues(GameObject newPrefab, Il2CppArrayBase<JiggleRigBuilder> oldJiggleRigs, Il2CppArrayBase<JiggleRigBuilder> newJiggleRigs)
		{
			for (int i = 0; i < oldJiggleRigs.Length; i++)
			{
				JiggleRigBuilder oldRig = oldJiggleRigs[i];
				JiggleRigBuilder jiggleRigBuilder = newJiggleRigs[i];
				CopyRigValues(newPrefab, oldRig, jiggleRigBuilder);
				jiggleRigBuilder.Initialize();
			}
		}

		public static void CopyRigValues(GameObject newPrefab, JiggleRigBuilder oldRig, JiggleRigBuilder newRig)
		{
			//IL_000e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			newRig.colliders = new List<Collider>();
			newRig.wind = oldRig.wind;
			newRig.data = oldRig.data;
			Dictionary<string, Transform> val = Enumerable.ToDictionary<Transform, string, Transform>((global::System.Collections.Generic.IEnumerable<Transform>)newPrefab.GetComponentsInChildren<Transform>(), (Func<Transform, string>)((Transform tf) => ((Object)tf).name), (Func<Transform, Transform>)((Transform tf) => tf));
			newRig.rootTransform = val[((Object)oldRig.rootTransform).name];
			Enumerator<Collider> enumerator = oldRig.colliders.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Collider current = enumerator.Current;
					Transform val2 = val[((Object)current).name];
					newRig.colliders.Add(((Component)val2).GetComponent<Collider>());
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}
	}
	[BepInPlugin("CustomCharacterLoader", "CustomCharacterLoader", "1.4.0")]
	public class CustomCharacterLoaderPlugin : BasePlugin
	{
		[HarmonyPatch]
		public static class LoadCorrectSkinDataPatch
		{
			[HarmonyPatch(typeof(DataManager), "GetSkin")]
			[HarmonyPrefix]
			internal static bool Prefix(DataManager __instance, ECharacter character, int savedIndex, ref SkinData __result)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				List<SkinData> skins = __instance.GetSkins(character);
				if (savedIndex >= 0 && savedIndex < skins.Count)
				{
					__result = skins._items[savedIndex];
				}
				else if (skins.Count <= 0)
				{
					__result = null;
				}
				else
				{
					__result = skins._items[0];
				}
				return false;
			}

			[HarmonyPatch(typeof(PlayerRenderer), "CreateMaterials")]
			[HarmonyPostfix]
			internal static void Postfix(PlayerRenderer __instance, int amount)
			{
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				if ((Object)(object)__instance.skinData == (Object)null)
				{
					return;
				}
				CharacterData characterData = __instance.characterData;
				bool flag = !string.IsNullOrEmpty(((UnlockableBase)__instance.skinData).author);
				ManualLogSource log = InjectComponent.Instance.Log;
				Material defaultMaterial = InjectComponent.Instance.DefaultMaterial;
				if (!flag)
				{
					return;
				}
				Il2CppReferenceArray<Material> materials = __instance.skinData.materials;
				Material[] array = (Material[])(object)new Material[((Il2CppArrayBase<Material>)(object)materials).Length];
				for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)materials).Length; i++)
				{
					Material val = new Material(((Il2CppArrayBase<Material>)(object)materials)[i]);
					if (((Object)val.shader).name.EndsWith("MegabonkShader"))
					{
						val = defaultMaterial;
					}
					array[i] = val;
				}
				__instance.activeMaterials = Il2CppReferenceArray<Material>.op_Implicit(array);
				List<Material> allMaterials = new List<Material>();
				Material[] array2 = array;
				foreach (Material val2 in array2)
				{
					__instance.allMaterials.Add(val2);
				}
				__instance.allMaterials = allMaterials;
				((Renderer)__instance.renderer).materials = Il2CppReferenceArray<Material>.op_Implicit(array);
			}
		}

		[HarmonyPatch]
		public static class ActivationTogglePatches
		{
			[HarmonyPatch(typeof(MyAchievements), "IsActivated")]
			[HarmonyPrefix]
			private static bool IsActivatedPrefix(ref bool __result, UnlockableBase unlockable)
			{
				__result = !SaveManager.Instance.progression.inactivated.Contains(unlockable.GetInternalName());
				return false;
			}

			[HarmonyPatch(typeof(MyAchievements), "IsAvailable")]
			[HarmonyPrefix]
			private static bool IsAvailablePrefix(ref bool __result, UnlockableBase unlockable)
			{
				__result = MyAchievements.IsActivated(unlockable) && MyAchievements.IsPurchased(unlockable);
				return false;
			}

			[HarmonyPatch(typeof(MyAchievements), "CanToggleActivation")]
			[HarmonyPrefix]
			internal static bool Prefix(DataManager __instance, UnlockableBase unlockable, ref bool __result)
			{
				if (!string.IsNullOrEmpty(unlockable.author))
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch]
		public static class ShowCorrectCustomDamageSourcePatch
		{
			[HarmonyPatch(typeof(LocalizationUtility), "GetLocalizedDamageSource")]
			[HarmonyPrefix]
			internal static bool Prefix(LocalizationUtility __instance, ref string __result, string source)
			{
				WeaponData val = default(WeaponData);
				if (InjectComponent.Instance.CustomWeapons.TryGetValue(source, ref val))
				{
					__result = ((Object)val).name;
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(DamageSource), "GetIcon")]
			[HarmonyPrefix]
			internal static bool Prefix(DamageSource __instance, ref Texture __result)
			{
				WeaponData val = default(WeaponData);
				if (InjectComponent.Instance.CustomWeapons.TryGetValue(__instance.damageSource, ref val))
				{
					__result = val.icon;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(DataManager))]
		[HarmonyPatch("Load")]
		public static class DataManagerLoadCustomCharacterPatch
		{
			[HarmonyPostfix]
			internal static void Postfix(DataManager __instance)
			{
				InjectComponent.Instance.LoadCustomCreations();
			}
		}

		[HarmonyPatch(typeof(SaveManager), "Load", new global::System.Type[] { typeof(bool) })]
		public static class SaveManagerLoadCustomCharacterPatch
		{
			[HarmonyPostfix]
			internal static void Postfix(SaveManager __instance, bool loadBackup)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				Debug.Log(Object.op_Implicit("Patching Save File with Custom Character Skin data"));
				List<ECharacter> addedCharacters = InjectComponent.Instance.AddedCharacters;
				Enumerator<ECharacter> enumerator = addedCharacters.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ECharacter current = enumerator.Current;
						__instance.config.preferences.characterSkins.TryAdd(current, 0);
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator).Dispose();
				}
			}
		}

		[HarmonyPatch]
		public static class PlayerRendererCustomSkinLoaderPatch
		{
			[HarmonyPatch(typeof(PlayerRenderer), "SetCharacter")]
			[HarmonyPostfix]
			internal static void Postfix(PlayerRenderer __instance, CharacterData characterData, PlayerInventory inventory, Vector3 spawnDir)
			{
				Il2CppArrayBase<MyPhysicsBone> componentsInChildren = characterData.prefab.GetComponentsInChildren<MyPhysicsBone>();
				Il2CppArrayBase<MyPhysicsBone> componentsInChildren2 = __instance.rendererObject.GetComponentsInChildren<MyPhysicsBone>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					MyPhysicsBone oldBone = componentsInChildren[i];
					MyPhysicsBone myPhysicsBone = componentsInChildren2[i];
					MyPhysicsBone.CopyValuesTo(oldBone, myPhysicsBone);
					((Behaviour)myPhysicsBone).enabled = false;
				}
				Il2CppArrayBase<JiggleRigBuilder> componentsInChildren3 = characterData.prefab.GetComponentsInChildren<JiggleRigBuilder>();
				Il2CppArrayBase<JiggleRigBuilder> componentsInChildren4 = __instance.rendererObject.GetComponentsInChildren<JiggleRigBuilder>();
				PhysBoneAdder.CopyRigsValues(__instance.rendererObject, componentsInChildren3, componentsInChildren4);
			}

			[HarmonyPatch(typeof(PlayerRenderer), "SetSkin", new global::System.Type[] { typeof(SkinData) })]
			[HarmonyPrefix]
			internal static bool Prefix(PlayerRenderer __instance, SkinData skinData)
			{
				GameObject modelFromSkinData = InjectComponent.Instance.GetModelFromSkinData(skinData);
				if ((Object)(object)modelFromSkinData == (Object)null)
				{
					return true;
				}
				UpdatePlayerRendererWithNewGameObject(modelFromSkinData, __instance, skinData);
				return true;
			}

			internal static void UpdatePlayerRendererWithNewGameObject(GameObject prefab, PlayerRenderer pRenderer, SkinData skinData)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Expected O, but got Unknown
				ManualLogSource log = InjectComponent.Instance.Log;
				SkinnedMeshRenderer componentInChildren = prefab.GetComponentInChildren<SkinnedMeshRenderer>();
				SkinnedMeshRenderer renderer = pRenderer.renderer;
				GameObject rendererObject = pRenderer.rendererObject;
				if (!((Object)(object)componentInChildren.sharedMesh == (Object)(object)renderer.sharedMesh))
				{
					GameObject val = Object.Instantiate<GameObject>(prefab, ((Component)pRenderer).transform);
					val.transform.localPosition = Vector3.zero;
					Il2CppArrayBase<MyPhysicsBone> componentsInChildren = prefab.GetComponentsInChildren<MyPhysicsBone>();
					Il2CppArrayBase<MyPhysicsBone> componentsInChildren2 = val.GetComponentsInChildren<MyPhysicsBone>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						MyPhysicsBone oldBone = componentsInChildren[i];
						MyPhysicsBone newBone = componentsInChildren2[i];
						MyPhysicsBone.CopyValuesTo(oldBone, newBone);
					}
					Il2CppArrayBase<JiggleRigBuilder> componentsInChildren3 = prefab.GetComponentsInChildren<JiggleRigBuilder>();
					Il2CppArrayBase<JiggleRigBuilder> componentsInChildren4 = val.GetComponentsInChildren<JiggleRigBuilder>();
					PhysBoneAdder.CopyRigsValues(val, componentsInChildren3, componentsInChildren4);
					List<SkinData> val2 = DataManager.Instance.skinData[skinData.character];
					pRenderer.skinData = skinData;
					pRenderer.rendererObject = val;
					pRenderer.renderer = componentInChildren;
					pRenderer.hips = componentInChildren.rootBone;
					pRenderer.animator = val.GetComponent<Animator>();
					pRenderer.torso = null;
					Material[] array = (Material[])(object)new Material[((Il2CppArrayBase<Material>)(object)skinData.materials).Length];
					List<Material> val3 = new List<Material>(array.Length);
					for (int j = 0; j < ((Il2CppArrayBase<Material>)(object)skinData.materials).Length; j++)
					{
						val3.Add(array[j] = new Material(((Il2CppArrayBase<Material>)(object)skinData.materials)[j]));
					}
					pRenderer.activeMaterials = Il2CppReferenceArray<Material>.op_Implicit(array);
					Material[] array2 = array;
					foreach (Material val4 in array2)
					{
						val3.Add(val4);
					}
					pRenderer.allMaterials = val3;
					((Renderer)pRenderer.renderer).materials = Il2CppReferenceArray<Material>.op_Implicit(array);
					Object.Destroy((Object)(object)rendererObject);
					pRenderer.characterData.prefab = prefab;
				}
			}
		}

		public class InjectComponent : MonoBehaviour
		{
			public static InjectComponent Instance;

			public ManualLogSource Log;

			public List<ECharacter> AddedCharacters;

			public Material DefaultMaterial;

			public Dictionary<string, WeaponData> CustomWeapons = new Dictionary<string, WeaponData>();

			public Window gcHolder;

			public Animator scriptGcHolder;

			public Dictionary<SkinData, GameObject> SkinRenderObjects = new Dictionary<SkinData, GameObject>();

			public InjectComponent(nint handle)
				: base((global::System.IntPtr)handle)
			{
			}

			private void Update()
			{
				if (!Input.GetKeyDown((KeyCode)104))
				{
				}
			}

			public void AddCustomWeapon(WeaponData weapon)
			{
				CustomWeapons.Add(weapon.damageSourceName, weapon);
			}

			private void AnalyzeShaderProperties()
			{
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Invalid comparison between Unknown and I4
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Invalid comparison between Unknown and I4
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Expected O, but got Unknown
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Invalid comparison between Unknown and I4
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Expected O, but got Unknown
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b4: Invalid comparison between Unknown and I4
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_025e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0265: Expected O, but got Unknown
				//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c0: Invalid comparison between Unknown and I4
				//IL_02c3: 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_036a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0371: Expected O, but got Unknown
				//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e3: Invalid comparison between Unknown and I4
				//IL_0463: Unknown result type (might be due to invalid IL or missing references)
				//IL_046a: Expected O, but got Unknown
				//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0400: Expected O, but got Unknown
				//IL_049e: Unknown result type (might be due to invalid IL or missing references)
				PlayerRenderer playerRenderer = MyPlayer.Instance.playerRenderer;
				Material obj = ((Il2CppArrayBase<Material>)(object)playerRenderer.activeMaterials)[0];
				Shader val = ((obj != null) ? obj.shader : null);
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				int propertyCount = val.GetPropertyCount();
				bool flag = default(bool);
				for (int i = 0; i < propertyCount; i++)
				{
					string propertyName = val.GetPropertyName(i);
					ShaderPropertyType propertyType = val.GetPropertyType(i);
					if ((int)propertyType == 2)
					{
						float propertyDefaultFloatValue = val.GetPropertyDefaultFloatValue(i);
						ManualLogSource log = Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 4, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<ShaderPropertyType>(propertyType);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") = ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(propertyDefaultFloatValue);
						}
						log.LogInfo(val2);
					}
					else if ((int)propertyType == 3)
					{
						float propertyDefaultFloatValue2 = val.GetPropertyDefaultFloatValue(i);
						Vector2 propertyRangeLimits = val.GetPropertyRangeLimits(i);
						ManualLogSource log2 = Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(18, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", Range(");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((Vector2)(ref propertyRangeLimits))[0]);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(",");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((Vector2)(ref propertyRangeLimits))[1]);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")) = ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(propertyDefaultFloatValue2);
						}
						log2.LogInfo(val2);
					}
					else if ((int)propertyType == 1)
					{
						Vector4 propertyDefaultVectorValue = val.GetPropertyDefaultVectorValue(i);
						string text = $"({((Vector4)(ref propertyDefaultVectorValue))[0]},{((Vector4)(ref propertyDefaultVectorValue))[1]},{((Vector4)(ref propertyDefaultVectorValue))[2]},{((Vector4)(ref propertyDefaultVectorValue))[3]})";
						ManualLogSource log3 = Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(16, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", Vector) = ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						}
						log3.LogInfo(val2);
					}
					else if ((int)propertyType == 0)
					{
						Vector4 propertyDefaultVectorValue2 = val.GetPropertyDefaultVectorValue(i);
						string text2 = $"({((Vector4)(ref propertyDefaultVectorValue2))[0]},{((Vector4)(ref propertyDefaultVectorValue2))[1]},{((Vector4)(ref propertyDefaultVectorValue2))[2]},{((Vector4)(ref propertyDefaultVectorValue2))[3]})";
						ManualLogSource log4 = Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(15, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", Color) = ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
						}
						log4.LogInfo(val2);
					}
					else
					{
						if ((int)propertyType != 4)
						{
							continue;
						}
						TextureDimension propertyTextureDimension = val.GetPropertyTextureDimension(i);
						string propertyTextureDefaultName = val.GetPropertyTextureDefaultName(i);
						if ((int)propertyTextureDimension == 2)
						{
							ManualLogSource log5 = Log;
							BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(17, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", 2D) = \"");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyTextureDefaultName);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" {}");
							}
							log5.LogInfo(val2);
						}
						else
						{
							ManualLogSource log6 = Log;
							BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(7, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (\"");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(propertyName);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\", ");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<TextureDimension>(propertyTextureDimension);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
							}
							log6.LogInfo(val2);
						}
					}
				}
			}

			public void LoadCustomCreations()
			{
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Expected O, but got Unknown
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				DataManager instance = DataManager.Instance;
				string[] array = FindCustomCharacterPaths();
				AddedCharacters = new List<ECharacter>();
				DefaultMaterial = ((Il2CppArrayBase<Material>)(object)instance.skinData[(ECharacter)0]._items[0].materials)[0];
				SetupCustomSkinLoader(instance);
				Log.LogInfo((object)"Loading Custom Creations");
				string[] array2 = array;
				foreach (string text in array2)
				{
					int num = text.LastIndexOf('.');
					if (text.EndsWith(".custom.json"))
					{
						num = text.LastIndexOf(".custom.json");
					}
					string text2 = text.Substring(0, num);
					FileStream val = File.OpenRead(text2);
					AssetBundle assetBundle = AssetBundle.LoadFromStream((Stream)(object)val);
					((Stream)val).Dispose();
					FileStream val2 = File.OpenRead(text);
					StreamReader val3 = new StreamReader((Stream)(object)val2);
					JObject val4 = JObject.Parse(((TextReader)val3).ReadToEnd());
					((TextReader)val3).Dispose();
					((Stream)val2).Dispose();
					switch (DetermineCustomType(val4))
					{
					case CustomType.Character:
					{
						CharacterAdder characterAdder = new CharacterAdder(instance, val4, assetBundle, Log);
						ECharacter val5 = characterAdder.AddCustomCharacter();
						AddedCharacters.Add(val5);
						break;
					}
					case CustomType.Skin:
						SkinAdder.AddSkinToGame(val4, assetBundle, this, instance, Log);
						break;
					}
				}
			}

			public GameObject GetModelFromSkinData(SkinData skinData)
			{
				GameObject result = default(GameObject);
				SkinRenderObjects.TryGetValue(skinData, ref result);
				return result;
			}

			public void AddSoloCustomSkin(SkinData skinData, GameObject prefab)
			{
				SkinRenderObjects.Add(skinData, prefab);
				CharacterData val = ScriptableObject.CreateInstance<CharacterData>();
				val.prefab = prefab;
				((Component)this).GetComponent<DataManager>().unsortedCharacterData.Add(val);
			}

			public void SetupCustomSkinLoader(DataManager dataManager)
			{
				//IL_00dc: 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_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)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<ECharacter, List<SkinData>> skinData = dataManager.skinData;
				HashSet<CharacterData> val = new HashSet<CharacterData>();
				Enumerator<ECharacter, List<SkinData>> enumerator = skinData.GetEnumerator();
				CharacterData val2 = default(CharacterData);
				while (enumerator.MoveNext())
				{
					KeyValuePair<ECharacter, List<SkinData>> current = enumerator.Current;
					if (current.value.Count == 0)
					{
						continue;
					}
					ECharacter character = current.value._items[0].character;
					List<SkinData> value = current.value;
					if (dataManager.characterData.TryGetValue(character, ref val2))
					{
						Enumerator<SkinData> enumerator2 = value.GetEnumerator();
						while (enumerator2.MoveNext())
						{
							SkinData current2 = enumerator2.Current;
							SkinRenderObjects.Add(current2, val2.prefab);
							val.Add(val2);
						}
					}
				}
				DataManager val3 = ((Component)this).gameObject.AddComponent<DataManager>();
				val3.unsortedCharacterData = new List<CharacterData>();
				Enumerator<CharacterData> enumerator3 = val.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						CharacterData current3 = enumerator3.Current;
						val3.unsortedCharacterData.Add(Object.Instantiate<CharacterData>(current3));
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator3).Dispose();
				}
			}

			public static string[] FindCustomCharacterPaths()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Expected O, but got Unknown
				string text = Path.Combine(Paths.PluginPath, CUSTOM_CHARACTER_FOLDER);
				HashSet<string> val = Enumerable.ToHashSet<string>((global::System.Collections.Generic.IEnumerable<string>)Directory.GetFiles(text, "*.json"));
				Il2CppStringArray files = Directory.GetFiles(Paths.PluginPath, "*.custom.json", new EnumerationOptions
				{
					RecurseSubdirectories = true
				});
				val.UnionWith((global::System.Collections.Generic.IEnumerable<string>)files);
				return Enumerable.ToArray<string>((global::System.Collections.Generic.IEnumerable<string>)val);
			}
		}

		public enum CustomType
		{
			Character,
			Skin,
			Weapon
		}

		public class MyRefTest : MonoBehaviour
		{
			public List<GameObject> testObjects = new List<GameObject>();
		}

		public static readonly string CUSTOM_CHARACTER_FOLDER = "CustomCharacters";

		public static GameObject BepInExUtility;

		public static List<ScriptableObject> ScriptableObjects = new List<ScriptableObject>();

		public override void Load()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			string text = Path.Combine(Paths.PluginPath, CUSTOM_CHARACTER_FOLDER);
			if (!Directory.Exists(text) && text != null)
			{
				Directory.CreateDirectory(text);
			}
			ClassInjector.RegisterTypeInIl2Cpp<InjectComponent>();
			ClassInjector.RegisterTypeInIl2Cpp<MyPhysicsBone>();
			ClassInjector.RegisterTypeInIl2Cpp<JiggleSettings>();
			BepInExUtility = GameObject.Find("BepInExUtility");
			ClassInjector.RegisterTypeInIl2Cpp<JiggleRigBuilder>();
			ClassInjector.RegisterTypeInIl2Cpp<CachedSphereCollider.DestroyListener>();
			if ((Object)(object)BepInExUtility == (Object)null)
			{
				BepInExUtility = new GameObject("BepInExUtility");
				Object.DontDestroyOnLoad((Object)(object)BepInExUtility);
				((Object)BepInExUtility).hideFlags = (HideFlags)61;
				BepInExUtility.AddComponent<InjectComponent>();
			}
			else
			{
				BepInExUtility.AddComponent<InjectComponent>();
			}
			InjectComponent component = BepInExUtility.GetComponent<InjectComponent>();
			component.Log = ((BasePlugin)this).Log;
			InjectComponent.Instance = component;
			Harmony val = new Harmony("CustomCharacterLoader");
			val.PatchAll();
		}

		public static CustomType DetermineCustomType(JObject jsonObject)
		{
			if (jsonObject.ContainsKey("character"))
			{
				return CustomType.Character;
			}
			if (jsonObject.ContainsKey("soloSkin"))
			{
				return CustomType.Skin;
			}
			if (jsonObject.ContainsKey("soloWeapon"))
			{
				return CustomType.Weapon;
			}
			return CustomType.Character;
		}

		public static LocalizedString CreateLocalizedString(string uid, string value)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Main Menu"), (Locale)null);
			((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry(uid, value);
			return new LocalizedString(TableReference.op_Implicit(((LocalizationTable)table).TableCollectionName), TableEntryReference.op_Implicit(uid));
		}
	}
	public class SkinAdder
	{
		public struct JSoloSkin
		{
			public string author;

			public string skinName;

			public string description;

			public string iconPath;

			public string prefabPath;

			public ECharacter eCharacter;

			public List<string> materialPaths;

			public static JSoloSkin FromJSON(JObject jobj)
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				JSoloSkin result = default(JSoloSkin);
				JToken obj = jobj["author"];
				result.author = ((obj != null) ? obj.ToObject<string>() : null);
				result.skinName = jobj["skinName"].ToObject<string>();
				result.eCharacter = jobj["eCharacter"].ToObject<ECharacter>();
				result.description = jobj["description"].ToObject<string>();
				result.iconPath = jobj["iconPath"].ToObject<string>();
				result.prefabPath = jobj["prefabPath"].ToObject<string>();
				result.materialPaths = jobj["materialPaths"].ToObject<List<string>>();
				return result;
			}
		}

		public static void AddSkinToGame(JObject jsonObject, AssetBundle assetBundle, CustomCharacterLoaderPlugin.InjectComponent injectComponent, DataManager dataManager, ManualLogSource log)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			JSoloSkin jSoloSkin = JSoloSkin.FromJSON(((Il2CppObjectBase)jsonObject["soloSkin"]).Cast<JObject>());
			SkinData val = ScriptableObject.CreateInstance<SkinData>();
			List<SkinData> val2 = default(List<SkinData>);
			if (dataManager.skinData.TryGetValue(jSoloSkin.eCharacter, ref val2))
			{
				val2.Add(val);
				dataManager.unsortedSkins.Add(val);
				val.character = jSoloSkin.eCharacter;
				((UnlockableBase)val).author = jSoloSkin.author;
				((Object)val).name = jSoloSkin.skinName;
				val.skinType = (ESkinType)0;
				val.icon = (Texture)(object)SkinAdder.LoadAsset<Texture2D>(jSoloSkin.iconPath, assetBundle);
				List<Material> val3 = new List<Material>();
				Enumerator<string> enumerator = jSoloSkin.materialPaths.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					Material val4 = SkinAdder.LoadAsset<Material>(current, assetBundle);
					val3.Add(val4);
				}
				val.materials = ((Il2CppObjectBase)val3.ToArray()).Cast<Il2CppReferenceArray<Material>>();
				((UnlockableBase)val).localizedName = CreateUniqueLocalizedString(jSoloSkin.eCharacter, jSoloSkin.skinName, jSoloSkin.skinName);
				((UnlockableBase)val).localizedDescription = CreateUniqueLocalizedString(jSoloSkin.eCharacter, jSoloSkin.skinName + ".description", jSoloSkin.description);
				((UnlockableBase)val).serializedLocalizationKeysName = new List<LocalizationKey>();
				((UnlockableBase)val).serializedLocalizationKeys = new List<LocalizationKey>();
				log.LogInfo((object)("Loaded custom skin: " + jSoloSkin.skinName + " for character " + ((object)(ECharacter)(ref jSoloSkin.eCharacter)).ToString()));
				GameObject prefab = SkinAdder.LoadAsset<GameObject>(jSoloSkin.prefabPath, assetBundle);
				JToken obj = jsonObject["soloSkin"];
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					JToken obj3 = ((Il2CppObjectBase)obj).Cast<JObject>()["physicsBones"];
					obj2 = ((obj3 != null) ? ((Il2CppObjectBase)obj3).Cast<JArray>() : null);
				}
				JArray val5 = (JArray)obj2;
				if (val5 != null)
				{
					PhysBoneAdder.SetBonesOnPrefab(prefab, val5);
				}
				JToken obj4 = jsonObject["soloSkin"];
				object obj5;
				if (obj4 == null)
				{
					obj5 = null;
				}
				else
				{
					JToken obj6 = ((Il2CppObjectBase)obj4).Cast<JObject>()["jiggleBones"];
					obj5 = ((obj6 != null) ? ((Il2CppObjectBase)obj6).Cast<JArray>() : null);
				}
				JArray val6 = (JArray)obj5;
				if (val6 != null)
				{
					PhysBoneAdder.SetJiggleOnPrefab(prefab, val6);
				}
				injectComponent.AddSoloCustomSkin(val, prefab);
			}
		}

		public static T LoadAsset<T>(string assetName, AssetBundle assetBundle) where T : Il2CppObjectBase
		{
			return ((Il2CppObjectBase)((ResourceRequest)assetBundle.LoadAssetAsync(assetName, Il2CppType.Of<T>())).GetResult()).Cast<T>();
		}

		public static LocalizedString CreateUniqueLocalizedString(ECharacter eCharacter, string key, string value)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)(ECharacter)(ref eCharacter)).ToString() ?? "";
			string uid = $"{eCharacter}.{key}";
			return CustomCharacterLoaderPlugin.CreateLocalizedString(uid, value);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CustomCharacterLoader";

		public const string PLUGIN_NAME = "CustomCharacterLoader";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace JigglePhysics
{
	public static class CachedSphereCollider
	{
		public class DestroyListener : MonoBehaviour
		{
			private void OnDestroy()
			{
				_hasSphere = false;
			}
		}

		private static bool _hasSphere;

		private static SphereCollider _sphereCollider;

		public static void StartPass()
		{
			if (TryGet(out var collider))
			{
				((Collider)collider).enabled = true;
			}
		}

		public static void FinishedPass()
		{
			if (TryGet(out var collider))
			{
				((Collider)collider).enabled = false;
			}
		}

		public static bool TryGet(out SphereCollider collider)
		{
			//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_0045: Expected O, but got Unknown
			if (_hasSphere)
			{
				collider = _sphereCollider;
				return true;
			}
			try
			{
				GameObject val = new GameObject("JiggleBoneSphereCollider", (Type[])(object)new Type[2]
				{
					Il2CppType.Of<SphereCollider>(),
					Il2CppType.Of<DestroyListener>()
				})
				{
					hideFlags = (HideFlags)61
				};
				if (Application.isPlaying)
				{
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				_sphereCollider = val.GetComponent<SphereCollider>();
				collider = _sphereCollider;
				((Collider)collider).enabled = false;
				_hasSphere = true;
				return true;
			}
			catch
			{
				if ((Object)(object)_sphereCollider != (Object)null)
				{
					if (Application.isPlaying)
					{
						Object.Destroy((Object)(object)((Component)_sphereCollider).gameObject);
					}
					else
					{
						Object.DestroyImmediate((Object)(object)((Component)_sphereCollider).gameObject);
					}
				}
				_hasSphere = false;
				collider = null;
				throw;
			}
		}
	}
	[Serializable]
	public class JiggleBone
	{
		private readonly bool hasTransform;

		private readonly PositionSignal targetAnimatedBoneSignal;

		private Vector3 currentFixedAnimatedBonePosition;

		public readonly JiggleBone parent;

		private JiggleBone child;

		private Quaternion boneRotationChangeCheck;

		private Vector3 bonePositionChangeCheck;

		private Quaternion lastValidPoseBoneRotation;

		private float projectionAmount;

		private Vector3 lastValidPoseBoneLocalPosition;

		private float normalizedIndex;

		public readonly Transform transform;

		private readonly PositionSignal particleSignal;

		private Vector3 workingPosition;

		private Vector3? preTeleportPosition;

		private Vector3 extrapolatedPosition;

		private float GetLengthToParent()
		{
			//IL_0018: 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)
			if (parent == null)
			{
				return 0.1f;
			}
			return Vector3.Distance(currentFixedAnimatedBonePosition, parent.currentFixedAnimatedBonePosition);
		}

		public JiggleBone(Transform transform, JiggleBone parent, float projectionAmount = 1f)
		{
			//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)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0042: 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_0055: 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)
			this.transform = transform;
			this.parent = parent;
			this.projectionAmount = projectionAmount;
			Vector3 startPosition;
			if ((Object)(object)transform != (Object)null)
			{
				lastValidPoseBoneRotation = transform.localRotation;
				lastValidPoseBoneLocalPosition = transform.localPosition;
				startPosition = transform.position;
			}
			else
			{
				startPosition = GetProjectedPosition();
			}
			targetAnimatedBoneSignal = new PositionSignal(startPosition, Time.timeAsDouble);
			particleSignal = new PositionSignal(startPosition, Time.timeAsDouble);
			hasTransform = (Object)(object)transform != (Object)null;
			if (parent != null)
			{
				this.parent.child = this;
			}
		}

		public void CalculateNormalizedIndex()
		{
			int num = 0;
			JiggleBone jiggleBone = this;
			while (jiggleBone.parent != null)
			{
				jiggleBone = jiggleBone.parent;
				num++;
			}
			int num2 = 0;
			jiggleBone = this;
			while (jiggleBone.child != null)
			{
				jiggleBone = jiggleBone.child;
				num2++;
			}
			int num3 = num + num2;
			float num4 = (float)num / (float)num3;
			normalizedIndex = num4;
		}

		public void VerletPass(JiggleSettingsData jiggleSettings, Vector3 wind, double time)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_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)
			//IL_00e2: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			currentFixedAnimatedBonePosition = targetAnimatedBoneSignal.SamplePosition(time);
			if (parent == null)
			{
				workingPosition = currentFixedAnimatedBonePosition;
				particleSignal.SetPosition(workingPosition, time);
			}
			else
			{
				Vector3 localSpaceVelocity = particleSignal.GetCurrent() - particleSignal.GetPrevious() - (parent.particleSignal.GetCurrent() - parent.particleSignal.GetPrevious());
				workingPosition = NextPhysicsPosition(particleSignal.GetCurrent(), particleSignal.GetPrevious(), localSpaceVelocity, Time.fixedDeltaTime, jiggleSettings.gravityMultiplier, jiggleSettings.friction, jiggleSettings.airDrag);
				workingPosition += wind * (Time.fixedDeltaTime * jiggleSettings.airDrag);
			}
		}

		public void CollisionPreparePass(JiggleSettingsData jiggleSettings)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			workingPosition = ConstrainLengthBackwards(workingPosition, jiggleSettings.lengthElasticity * jiggleSettings.lengthElasticity * 0.5f);
		}

		public void ConstraintPass(JiggleSettingsData jiggleSettings)
		{
			//IL_0014: 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_0031: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (parent != null)
			{
				workingPosition = ConstrainAngle(workingPosition, jiggleSettings.angleElasticity * jiggleSettings.angleElasticity, jiggleSettings.elasticitySoften);
				workingPosition = ConstrainLength(workingPosition, jiggleSettings.lengthElasticity * jiggleSettings.lengthElasticity);
			}
		}

		public void CollisionPass(JiggleSettingsData jiggleSettings, List<Collider> colliders)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (colliders.Count == 0 || !CachedSphereCollider.TryGet(out var collider))
			{
				return;
			}
			Enumerator<Collider> enumerator = colliders.GetEnumerator();
			try
			{
				Vector3 val = default(Vector3);
				float num = default(float);
				while (enumerator.MoveNext())
				{
					Collider current = enumerator.Current;
					collider.radius = jiggleSettings.GetRadius(normalizedIndex);
					if (!(collider.radius <= 0f) && Physics.ComputePenetration((Collider)(object)collider, workingPosition, Quaternion.identity, current, ((Component)current).transform.position, ((Component)current).transform.rotation, ref val, ref num))
					{
						workingPosition += val * num;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}

		public void SignalWritePosition(double time)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			particleSignal.SetPosition(workingPosition, time);
		}

		private Vector3 GetProjectedPosition()
		{
			//IL_000c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = parent.transform.position;
			return parent.transform.TransformPoint(parent.GetParentTransform().InverseTransformPoint(position) * projectionAmount);
		}

		private Vector3 GetTransformPosition()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform)
			{
				return GetProjectedPosition();
			}
			return transform.position;
		}

		private Transform GetParentTransform()
		{
			if (parent != null)
			{
				return parent.transform;
			}
			return transform.parent;
		}

		private void CacheAnimationPosition()
		{
			//IL_0034: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform)
			{
				targetAnimatedBoneSignal.SetPosition(GetProjectedPosition(), Time.timeAsDouble);
				return;
			}
			targetAnimatedBoneSignal.SetPosition(transform.position, Time.timeAsDouble);
			lastValidPoseBoneRotation = transform.localRotation;
			lastValidPoseBoneLocalPosition = transform.localPosition;
		}

		private Vector3 ConstrainLengthBackwards(Vector3 newPosition, float elasticity)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (child == null)
			{
				return newPosition;
			}
			Vector3 val = newPosition - child.workingPosition;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			return Vector3.Lerp(newPosition, child.workingPosition + normalized * child.GetLengthToParent(), elasticity);
		}

		private Vector3 ConstrainLength(Vector3 newPosition, float elasticity)
		{
			//IL_0001: 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_000d: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = newPosition - parent.workingPosition;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			return Vector3.Lerp(newPosition, parent.workingPosition + normalized * GetLengthToParent(), elasticity);
		}

		public void MatchAnimationInstantly()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			double timeAsDouble = Time.timeAsDouble;
			Vector3 transformPosition = GetTransformPosition();
			targetAnimatedBoneSignal.FlattenSignal(timeAsDouble, transformPosition);
			particleSignal.FlattenSignal(timeAsDouble, transformPosition);
		}

		public void PrepareTeleport()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			preTeleportPosition = GetTransformPosition();
		}

		public void FinishTeleport()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (!preTeleportPosition.HasValue)
			{
				MatchAnimationInstantly();
				return;
			}
			Vector3 transformPosition = GetTransformPosition();
			Vector3 val = transformPosition - preTeleportPosition.Value;
			targetAnimatedBoneSignal.FlattenSignal(Time.timeAsDouble, transformPosition);
			particleSignal.OffsetSignal(val);
			workingPosition += val;
		}

		private Vector3 ConstrainAngleBackward(Vector3 newPosition, float elasticity, float elasticitySoften)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a1: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			if (child == null || child.child == null)
			{
				return newPosition;
			}
			Vector3 val = child.child.currentFixedAnimatedBonePosition - child.currentFixedAnimatedBonePosition;
			Vector3 val2 = child.child.workingPosition - child.workingPosition;
			Quaternion val3 = Quaternion.FromToRotation(val, val2);
			Vector3 val4 = newPosition - child.workingPosition;
			Vector3 val5 = val3 * val4;
			Debug.DrawLine(newPosition, child.workingPosition + val5, Color.cyan);
			float num = Vector3.Distance(newPosition, child.workingPosition + val5);
			num /= child.GetLengthToParent();
			num = Mathf.Clamp01(num);
			num = Mathf.Pow(num, elasticitySoften * 2f);
			return Vector3.Lerp(newPosition, child.workingPosition + val5, elasticity * num);
		}

		private Vector3 ConstrainAngle(Vector3 newPosition, float elasticity, float elasticitySoften)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform && projectionAmount == 0f)
			{
				return newPosition;
			}
			Vector3 val;
			Vector3 val2;
			if (parent.parent == null)
			{
				val = parent.currentFixedAnimatedBonePosition + (parent.currentFixedAnimatedBonePosition - currentFixedAnimatedBonePosition);
				val2 = val;
			}
			else
			{
				val2 = parent.parent.workingPosition;
				val = parent.parent.currentFixedAnimatedBonePosition;
			}
			Vector3 val3 = parent.currentFixedAnimatedBonePosition - val;
			Vector3 val4 = parent.workingPosition - val2;
			Quaternion val5 = Quaternion.FromToRotation(val3, val4);
			Vector3 val6 = currentFixedAnimatedBonePosition - val;
			Vector3 val7 = val5 * val6;
			float num = Vector3.Distance(newPosition, val2 + val7);
			num /= GetLengthToParent();
			num = Mathf.Clamp01(num);
			num = Mathf.Pow(num, elasticitySoften * 2f);
			return Vector3.Lerp(newPosition, val2 + val7, elasticity * num);
		}

		public static Vector3 NextPhysicsPosition(Vector3 newPosition, Vector3 previousPosition, Vector3 localSpaceVelocity, float deltaTime, float gravityMultiplier, float friction, float airFriction)
		{
			//IL_0005: 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_0007: 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_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			float num = deltaTime * deltaTime;
			Vector3 val = newPosition - previousPosition - localSpaceVelocity;
			return newPosition + val * (1f - airFriction) + localSpaceVelocity * (1f - friction) + Physics.gravity * (gravityMultiplier * num);
		}

		public void DebugDraw(Color simulateColor, Color targetColor, bool interpolated)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or miss