Decompiled source of Seeker Skin Pack v0.1.0

BepInEx/plugins/EclipseSkins/SeekerE7/Breaditation.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using Eclipse.AdvancedSkins;
using EclipseSkinRuntimeFix;
using EntityStates;
using EntityStates.Seeker;
using HG.Reflection;
using On.EntityStates.Seeker;
using On.RoR2;
using On.RoR2.Projectile;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.UI.MainMenu;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: AssemblyVersion("0.0.0.0")]
namespace EclipseSkinRuntimeFix
{
	internal static class NativeRenderers
	{
		private static readonly HashSet<string> NativePaths = new HashSet<string>(StringComparer.Ordinal)
		{
			"mdlLoader/PilotFemaleMesh", "mdlLoader/LoaderMechMesh", "mdlLoader/PilotFemaleFoldedOverJumpsuit", "mdlFalseSon/FalseSon_Body", "mdlFalseSon/FalseSon_Cloth", "mdlFalseSon/L_FalseSon_Weapon", "mdlSeeker/meshSeekerBody", "mdlSeeker/meshSeekerCloth", "mdlSeeker/meshSeekerGlass", "mdlChef/meshChef",
			"mdlChef/meshChefPizzaCutter", "mdlChef/meshlChefCleaver", "mdlChef/meshChefOven", "mdlChef/meshChefIceBox", "mdlCroco/CrocoMesh", "mdlCroco/CrocoSpineMesh", "mdlHuntress/HuntressMesh", "mdlHuntress/BowMesh", "mdlHuntress/HuntressScarfMesh", "mdlHuntress (1)/HuntressMesh",
			"mdlHuntress (1)/BowMesh", "mdlHuntress (1)/HuntressScarfMesh", "mdlMerc/MercMesh", "mdlMerc/MercSwordMesh", "mdlTreebot/TreebotBotMesh", "mdlTreebot/TreebotRootMesh", "mdlTreebot/TreebotLeafletMesh", "mdlTreebot/TreebotFlowerMesh", "mdlVoidSurvivor/mdlVoidSurvivorBody", "mdlVoidSurvivor/mdlVoidSurvivorHead",
			"mdlVoidSurvivor/mdlVoidSurvivorMetal", "mdlVoidSurvivor/metalcollar.001", "mdlBandit2/BanditArmature/ROOT/base/MainWeapon/BanditShotgunMesh", "mdlBandit2/BanditArmature/SideWeapon/SideWeaponSpinner/BanditPistolMesh", "mdlBandit2/Bandit2AccessoriesMesh"
		};

		public static T[] GetSkinRenderers<T>(this Component owner, bool inactive = false, SkinDefParams parameters = null) where T : Renderer
		{
			return owner.gameObject.GetSkinRenderers<T>(inactive, parameters);
		}

		public static T[] GetSkinRenderers<T>(this GameObject owner, bool inactive = false, SkinDefParams parameters = null) where T : Renderer
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//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_0123: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			T[] componentsInChildren = owner.GetComponentsInChildren<T>(inactive);
			CharacterModel val = owner.GetComponent<CharacterModel>() ?? owner.GetComponentInParent<CharacterModel>();
			ModelSkinController val2 = owner.GetComponent<ModelSkinController>() ?? (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<ModelSkinController>() : null);
			HashSet<Renderer> skinRefs = new HashSet<Renderer>();
			SkinDefParams val3 = parameters;
			if (!Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val2) && val2.skins != null && val2.skins.Length != 0 && Object.op_Implicit((Object)(object)val2.skins[0]))
			{
				val3 = val2.skins[0].skinDefParams;
			}
			if (Object.op_Implicit((Object)(object)val3))
			{
				if (val3.rendererInfos != null)
				{
					RendererInfo[] rendererInfos = val3.rendererInfos;
					foreach (RendererInfo val4 in rendererInfos)
					{
						if (Object.op_Implicit((Object)(object)val4.renderer))
						{
							skinRefs.Add(val4.renderer);
						}
					}
				}
				if (val3.meshReplacements != null)
				{
					MeshReplacement[] meshReplacements = val3.meshReplacements;
					foreach (MeshReplacement val5 in meshReplacements)
					{
						if (Object.op_Implicit((Object)(object)val5.renderer))
						{
							skinRefs.Add(val5.renderer);
						}
					}
				}
			}
			HashSet<Renderer> modelRefs = new HashSet<Renderer>();
			if (Object.op_Implicit((Object)(object)val) && val.baseRendererInfos != null)
			{
				RendererInfo[] rendererInfos = val.baseRendererInfos;
				foreach (RendererInfo val6 in rendererInfos)
				{
					if (Object.op_Implicit((Object)(object)val6.renderer))
					{
						modelRefs.Add(val6.renderer);
					}
				}
			}
			return Select(componentsInChildren, (T x) => ((Object)(object)x).name, (T x) => skinRefs.Contains((Renderer)(object)x), (T x) => modelRefs.Contains((Renderer)(object)x), (T x) => Path(((Component)(object)x).transform, owner.transform), (T x) => IsKnownNativePath(Path(((Component)(object)x).transform, owner.transform)));
		}

		internal static T[] Select<T>(T[] found, Func<T, string> name, Func<T, bool> skin, Func<T, bool> model, Func<T, string> path, Func<T, bool> contract = null)
		{
			HashSet<T> hashSet = new HashSet<T>();
			if (contract == null)
			{
				contract = (T x) => false;
			}
			bool flag = found.Any(skin) || found.Any(model) || found.Any(contract);
			foreach (IGrouping<string, T> item in found.GroupBy(name))
			{
				T[] array = item.ToArray();
				if (array.Length == 1)
				{
					if (!flag || skin(array[0]) || model(array[0]) || contract(array[0]))
					{
						hashSet.Add(array[0]);
					}
					continue;
				}
				T[] array2 = array.Where(skin).ToArray();
				T[] array3 = array.Where(model).ToArray();
				T[] array4 = ((array2.Length == 1) ? ((array3.Length == 0 || array3.Contains(array2[0])) ? array2 : new T[0]) : ((array2.Length <= 1) ? array3 : array2.Where(((IEnumerable<T>)array3).Contains<T>).ToArray()));
				if (array2.Length == 0 && array3.Length == 0)
				{
					T[] array5 = array.Where(contract).ToArray();
					if (array5.Length != 0)
					{
						if (array5.Length != 1)
						{
							throw new InvalidOperationException("ECLIPSE_RENDERER_PATH_AMBIGUOUS " + string.Join(";", array.Select(path)));
						}
						hashSet.Add(array5[0]);
						Debug.Log((object)("ECLIPSE_RENDERER_NATIVE_PATH name=" + item.Key + " native=" + path(array5[0])));
						continue;
					}
				}
				if (array2.Length == 0 && array3.Length == 0 && flag)
				{
					Debug.Log((object)("ECLIPSE_RENDERER_FOREIGN_DUPLICATES name=" + item.Key + " ignored=" + array.Length));
					continue;
				}
				if (array4.Length != 1)
				{
					throw new InvalidOperationException("ECLIPSE_RENDERER_AMBIGUOUS name=" + item.Key + " candidates=" + string.Join(";", array.Select(path)) + " skinRefs=" + array2.Length + " modelRefs=" + array3.Length);
				}
				hashSet.Add(array4[0]);
				Debug.Log((object)("ECLIPSE_RENDERER_RESOLVED name=" + item.Key + " native=" + path(array4[0]) + " ignoredDuplicates=" + (array.Length - 1)));
			}
			return found.Where(hashSet.Contains).ToArray();
		}

		internal static bool IsKnownNativePath(string path)
		{
			if (path == null)
			{
				return false;
			}
			int num = path.IndexOf('/');
			if (num < 0)
			{
				return false;
			}
			string text = path.Substring(0, num);
			if (text.EndsWith("(Clone)", StringComparison.Ordinal))
			{
				text = text.Substring(0, text.Length - 7);
			}
			return NativePaths.Contains(text + path.Substring(num));
		}

		private static string Path(Transform t, Transform root)
		{
			List<string> list = new List<string>();
			Transform val = t;
			while (Object.op_Implicit((Object)(object)val))
			{
				list.Add(((Object)val).name);
				if ((Object)(object)val == (Object)(object)root)
				{
					break;
				}
				val = val.parent;
			}
			list.Reverse();
			return string.Join("/", list);
		}
	}
}
namespace EclipsePlaytestSeekerE7
{
	public sealed class BreadCycloneGhost : MonoBehaviour
	{
		private ProjectileGhostController ghost;

		private Transform bread;

		private readonly Dictionary<GameObject, BreadEffectLease> hidden = new Dictionary<GameObject, BreadEffectLease>();

		private void Awake()
		{
			ghost = ((Component)this).GetComponent<ProjectileGhostController>();
		}

		private void LateUpdate()
		{
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ghost) || Breaditation.Shapes == null)
			{
				return;
			}
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			Transform val = null;
			Transform[] array = (Transform[])(object)new Transform[2] { ghost.authorityTransform, ghost.predictionTransform };
			foreach (Transform val2 in array)
			{
				ProjectileController val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<ProjectileController>() : null);
				CharacterBody body = ((Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.owner)) ? val3.owner.GetComponent<CharacterBody>() : null);
				if (!Object.op_Implicit((Object)(object)val3) || !BreadImpactRouting.Own(body) || val3.catalogIndex != Breaditation.CycloneIndex)
				{
					continue;
				}
				SeekerCycloneController component = ((Component)val3).GetComponent<SeekerCycloneController>();
				GameObject val4 = (Object.op_Implicit((Object)(object)component) ? component.projectileVfxRootObject : null);
				if (Object.op_Implicit((Object)(object)val4))
				{
					hashSet.Add(val4);
					if (!Object.op_Implicit((Object)(object)val))
					{
						val = val4.transform;
					}
					if (!hidden.ContainsKey(val4))
					{
						BreadEffectLease breadEffectLease = val4.AddComponent<BreadEffectLease>();
						breadEffectLease.Initialize(val4.GetComponentsInChildren<Renderer>(true));
						hidden.Add(val4, breadEffectLease);
					}
				}
			}
			KeyValuePair<GameObject, BreadEffectLease>[] array2 = hidden.ToArray();
			for (int i = 0; i < array2.Length; i++)
			{
				KeyValuePair<GameObject, BreadEffectLease> keyValuePair = array2[i];
				if (!Object.op_Implicit((Object)(object)keyValuePair.Key) || !hashSet.Contains(keyValuePair.Key))
				{
					if (Object.op_Implicit((Object)(object)keyValuePair.Value))
					{
						keyValuePair.Value.Dispose();
					}
					hidden.Remove(keyValuePair.Key);
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				if (Object.op_Implicit((Object)(object)bread))
				{
					((Component)bread).gameObject.SetActive(false);
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)bread))
			{
				GameObject val5 = new GameObject("BreaditationCyclone");
				bread = val5.transform;
				bread.SetParent(((Component)this).transform, false);
				for (int j = 0; j < 3; j++)
				{
					Breaditation.Shapes.Attach(bread, "pretzel", 2.2f, new Vector3(0f, (float)(j - 1) * 0.45f, 0f)).transform.localRotation = Quaternion.Euler(0f, (float)(j * 60), (float)(15 * (j - 1)));
				}
			}
			((Component)bread).gameObject.SetActive(true);
			bread.position = val.position;
			bread.rotation = val.rotation;
			Vector3 lossyScale = val.lossyScale;
			Vector3 lossyScale2 = ((Component)this).transform.lossyScale;
			bread.localScale = new Vector3(Ratio(lossyScale.x, lossyScale2.x), Ratio(lossyScale.y, lossyScale2.y), Ratio(lossyScale.z, lossyScale2.z));
		}

		private static float Ratio(float a, float b)
		{
			if (!(Mathf.Abs(b) > 0.0001f))
			{
				return 1f;
			}
			return Mathf.Clamp(Mathf.Abs(a / b), 0.05f, 12f);
		}

		private void OnDisable()
		{
			foreach (BreadEffectLease value in hidden.Values)
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					value.Dispose();
				}
			}
			hidden.Clear();
			if (Object.op_Implicit((Object)(object)bread))
			{
				Object.Destroy((Object)(object)((Component)bread).gameObject);
			}
			bread = null;
		}
	}
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("eclipseplaytest.seeker.e7", "Seeker - Breaditation (Playtest)", "0.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Breaditation : BaseUnityPlugin
	{
		private sealed class BreadRoute
		{
			internal string projectile;

			internal string shape;

			internal float scale;

			internal bool spin;

			internal bool required;

			internal BreadRoute(string p, string s, float size, bool rotate, bool needed = true)
			{
				projectile = p;
				shape = s;
				scale = size;
				spin = rotate;
				required = needed;
			}
		}

		internal static int CycloneIndex = -1;

		internal static BreadShapeBank Shapes;

		private GameObject ghostStorage;

		private readonly List<ProjectileGhostReplacement> breadGhosts = new List<ProjectileGhostReplacement>();

		public const string Guid = "eclipseplaytest.seeker.e7";

		public const string Version = "0.1.3";

		public const string SkinName = "EclipsePlaytestSeekerE7Breaditation";

		private static Breaditation instance;

		internal static Mesh BodyMesh;

		internal static SkinDef ActiveSkin;

		private BreadImpactRouting impactRouting;

		private string folder;

		private GameObject modelPrefab;

		private bool registered;

		private float deadline;

		private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>();

		private static readonly float[] AuthoredBindposes = new float[1232]
		{
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.4305112E-07f,
			-1.430509E-08f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.2012683f,
			-1.4305124E-08f,
			1f,
			0.0044540605f,
			-0.12096885f,
			0.99264467f,
			0f,
			0.036619026f,
			-0.9919704f,
			-0.12105062f,
			0f,
			0.9993033f,
			0.036889493f,
			1.1465491E-05f,
			0f,
			-0.022214059f,
			1.1199819f,
			0.2741602f,
			1f,
			-0.010773062f,
			-0.12037475f,
			0.9926685f,
			0f,
			-0.088482425f,
			-0.9887185f,
			-0.12085568f,
			0f,
			0.99600327f,
			-0.08913727f,
			4.7488555E-07f,
			0f,
			0.053676207f,
			0.5997889f,
			0.27417845f,
			1f,
			-7.2200196E-06f,
			1.19591505E-05f,
			0.9999987f,
			0f,
			0.8077158f,
			-0.5895594f,
			1.2882548E-05f,
			0f,
			0.5895621f,
			0.807712f,
			-5.4030443E-06f,
			0f,
			-0.03458087f,
			0.08683063f,
			0.26650754f,
			1f,
			-2.0184775E-07f,
			9.905754E-06f,
			0.99999857f,
			0f,
			0.9999999f,
			1.8629356E-07f,
			2.0184618E-07f,
			0f,
			-1.8629453E-07f,
			0.99998385f,
			-9.905898E-06f,
			0f,
			0.00014286602f,
			-0.058847677f,
			0.26650935f,
			1f,
			0.0662938f,
			-0.5678366f,
			0.82046574f,
			0f,
			0.09514092f,
			-0.8149303f,
			-0.5716937f,
			0f,
			0.9932387f,
			0.11596138f,
			-3.1435087E-07f,
			0f,
			-0.0863838f,
			0.79212606f,
			0.8587536f,
			1f,
			0.58683825f,
			-0.42368656f,
			0.68999827f,
			0f,
			0.050377853f,
			-0.8314103f,
			-0.5533614f,
			0f,
			0.8081274f,
			0.35949802f,
			-0.46656033f,
			0f,
			0.030353539f,
			0.84360087f,
			0.8137681f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.2302818f,
			-1.4305073E-08f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.3510144f,
			-1.4305101E-08f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.4622775f,
			-1.4305106E-08f,
			1f,
			1.0000001f,
			-7.4505797E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1.0000001f,
			-2.733147E-09f,
			0f,
			-7.4505797E-09f,
			2.733147E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.7042576f,
			-1.4305078E-08f,
			1f,
			-0.26696256f,
			-0.95242333f,
			0.14704348f,
			0f,
			-0.03968641f,
			-0.14158668f,
			-0.98913026f,
			0f,
			0.96288973f,
			(float)Math.PI * -25f / 291f,
			6.999157E-08f,
			0f,
			0.08723381f,
			0.19403057f,
			1.6791419f,
			1f,
			0.004608084f,
			-0.7485984f,
			0.6630086f,
			0f,
			0.004081131f,
			-0.6629962f,
			-0.7486123f,
			0f,
			0.9999813f,
			0.0061554923f,
			-1.3891088E-08f,
			0f,
			0.06579013f,
			0.97302663f,
			1.3704267f,
			1f,
			0.064921014f,
			-0.7462556f,
			0.66248673f,
			0f,
			0.0574173f,
			-0.659994f,
			-0.74907416f,
			0f,
			0.99623764f,
			0.08666882f,
			5.024377E-07f,
			0f,
			0.013246728f,
			0.6530304f,
			1.3708762f,
			1f,
			-0.011652997f,
			-0.74625397f,
			0.66556f,
			0f,
			0.14313233f,
			-0.6599959f,
			-0.73750895f,
			0f,
			0.98963517f,
			0.086668916f,
			0.1145039f,
			0f,
			-0.14440408f,
			0.3423188f,
			1.3633126f,
			1f,
			-0.70072967f,
			-0.13400473f,
			-0.70072913f,
			0f,
			-0.5995277f,
			-0.42179245f,
			0.68019f,
			0f,
			-0.38671082f,
			0.8967353f,
			0.21522292f,
			0f,
			0.25447518f,
			0.42884794f,
			-1.3045777f,
			1f,
			-0.44984198f,
			-0.38543135f,
			-0.8056583f,
			0f,
			-0.37667358f,
			-0.73605037f,
			0.5624476f,
			0f,
			-0.80978954f,
			0.5564826f,
			0.18592453f,
			0f,
			0.16751552f,
			0.6109193f,
			-1.2334443f,
			1f,
			-0.28010336f,
			-0.5219761f,
			-0.80565745f,
			0f,
			-0.085146f,
			-0.82243615f,
			0.5624496f,
			0f,
			-0.9561861f,
			0.22614256f,
			0.18592295f,
			0f,
			-0.046830866f,
			0.58422804f,
			-1.2334461f,
			1f,
			-0.6271295f,
			-0.7627311f,
			0.15795915f,
			0f,
			0.7631058f,
			-0.5609835f,
			0.32088593f,
			0f,
			-0.1561371f,
			0.32177648f,
			0.93385315f,
			0f,
			-1.3901865f,
			0.11016224f,
			-0.2721447f,
			1f,
			-0.62712914f,
			-0.76273113f,
			0.15795931f,
			0f,
			0.7631062f,
			-0.56098306f,
			0.32088587f,
			0f,
			-0.15613706f,
			0.32177657f,
			0.93385327f,
			0f,
			-1.390187f,
			0.046007838f,
			-0.2721445f,
			1f,
			-0.8568571f,
			-0.49076048f,
			0.15795897f,
			0f,
			0.5145683f,
			-0.7951429f,
			0.3208868f,
			0f,
			-0.031878594f,
			0.3562347f,
			0.933853f,
			0f,
			-1.2893136f,
			0.5038557f,
			-0.2719241f,
			1f,
			-0.7078689f,
			-0.70375764f,
			0.060394417f,
			0f,
			0.6939762f,
			-0.67699724f,
			0.24509592f,
			0f,
			-0.13160123f,
			0.21540804f,
			0.9676163f,
			0f,
			-1.3737191f,
			0.28893238f,
			-0.22382464f,
			1f,
			-0.90044963f,
			-0.43173823f,
			0.052850716f,
			0f,
			0.43170223f,
			-0.87223554f,
			0.22986676f,
			0f,
			-0.053143967f,
			0.22979914f,
			0.9717862f,
			0f,
			-1.2209454f,
			0.6740369f,
			-0.21205828f,
			1f,
			-0.93178517f,
			-0.35914388f,
			0.05284655f,
			0f,
			0.36133927f,
			-0.90365624f,
			0.22986941f,
			0f,
			-0.034801077f,
			0.2332843f,
			0.9717857f,
			0f,
			-1.1675222f,
			0.7214888f,
			-0.21206456f,
			1f,
			-0.7514313f,
			-0.60601544f,
			-0.2609553f,
			0f,
			0.54250604f,
			-0.79257244f,
			0.278419f,
			0f,
			-0.37555194f,
			0.06764292f,
			0.92433023f,
			0f,
			-1.2309868f,
			0.4980824f,
			-0.48070946f,
			1f,
			-0.91904837f,
			-0.29193744f,
			-0.26480928f,
			0f,
			0.22134057f,
			-0.9381866f,
			0.26611242f,
			0f,
			-0.32612836f,
			0.18595706f,
			0.9268555f,
			0f,
			-0.98887795f,
			0.8636517f,
			-0.4693957f,
			1f,
			-0.95138353f,
			-0.15730585f,
			-0.2648113f,
			0f,
			0.08469511f,
			-0.96021426f,
			0.26611313f,
			0f,
			-0.29613665f,
			0.23074734f,
			0.92685467f,
			0f,
			-0.86320823f,
			0.94335485f,
			-0.4696456f,
			1f,
			-0.7105328f,
			-0.5290969f,
			-0.46389714f,
			0f,
			0.48640203f,
			-0.8456998f,
			0.21955809f,
			0f,
			-0.5084848f,
			-0.06963724f,
			0.8582509f,
			0f,
			-1.1386653f,
			0.6134363f,
			-0.53971475f,
			1f,
			-0.8842662f,
			-0.003931301f,
			-0.46696812f,
			0f,
			-0.05624204f,
			-0.9917895f,
			0.11485141f,
			0f,
			-0.46358538f,
			0.12782237f,
			0.87678444f,
			0f,
			-0.6403971f,
			1.1517991f,
			-0.41974434f,
			1f,
			-0.8842661f,
			-0.0039312663f,
			-0.46696806f,
			0f,
			-0.056242052f,
			-0.9917895f,
			0.114851385f,
			0f,
			-0.4635854f,
			0.12782238f,
			0.8767846f,
			0f,
			-0.643911f,
			1.1181519f,
			-0.42252585f,
			1f,
			0.2669631f,
			0.9524228f,
			0.14704351f,
			0f,
			-0.03968643f,
			-0.14158666f,
			0.98913026f,
			0f,
			0.96288955f,
			-0.26989684f,
			-1.4682041E-07f,
			0f,
			0.08723383f,
			0.19403055f,
			-1.679142f,
			1f,
			-0.004607448f,
			0.7485665f,
			0.66304386f,
			0f,
			0.004081226f,
			-0.66303146f,
			0.7485805f,
			0f,
			0.99998134f,
			0.0061550774f,
			-1.8653266E-07f,
			0f,
			0.06578989f,
			0.9730912f,
			-1.3703797f,
			1f,
			-0.06492073f,
			0.746253f,
			0.66248965f,
			0f,
			0.057417218f,
			-0.6599969f,
			0.74907124f,
			0f,
			0.9962375f,
			0.086668536f,
			-2.7128624E-07f,
			0f,
			0.013246727f,
			0.65303606f,
			-1.3708735f,
			1f,
			0.011652874f,
			0.74625486f,
			0.6655586f,
			0f,
			0.14313318f,
			-0.65999424f,
			0.73750997f,
			0f,
			0.98963517f,
			0.08666939f,
			-0.114504635f,
			0f,
			-0.14440508f,
			0.3423164f,
			-1.3633127f,
			1f,
			0.7007298f,
			0.13400435f,
			-0.7007293f,
			0f,
			-0.5995279f,
			-0.42179275f,
			-0.6801894f,
			0f,
			-0.3867108f,
			0.8967355f,
			-0.21522313f,
			0f,
			0.25447553f,
			0.42884862f,
			1.3045775f,
			1f,
			0.4498424f,
			0.3854303f,
			-0.80565864f,
			0f,
			-0.37667355f,
			-0.7360514f,
			-0.5624465f,
			0f,
			-0.80979f,
			0.55648243f,
			-0.18592548f,
			0f,
			0.16751553f,
			0.6109217f,
			1.2334434f,
			1f,
			0.28010952f,
			0.52197087f,
			-0.8056583f,
			0f,
			-0.08514402f,
			-0.8224391f,
			-0.5624453f,
			0f,
			-0.9561853f,
			0.22614318f,
			-0.18593019f,
			0f,
			-0.046837498f,
			0.5842352f,
			1.2334421f,
			1f,
			0.627129f,
			0.7627309f,
			0.1579597f,
			0f,
			0.76310587f,
			-0.5609829f,
			-0.3208862f,
			0f,
			-0.15613705f,
			0.32177702f,
			-0.9338531f,
			0f,
			-1.3901867f,
			0.11016174f,
			0.2721447f,
			1f,
			0.62712765f,
			0.7627322f,
			0.1579596f,
			0f,
			0.7631068f,
			-0.56098133f,
			-0.32088676f,
			0f,
			-0.15613818f,
			0.32177693f,
			-0.9338528f,
			0f,
			-1.3901862f,
			0.046004947f,
			0.27214548f,
			1f,
			0.8568569f,
			0.49075958f,
			0.15796146f,
			0f,
			0.5145683f,
			-0.7951429f,
			-0.32088578f,
			0f,
			-0.031875797f,
			0.356235f,
			-0.9338529f,
			0f,
			-1.2893136f,
			0.50385654f,
			0.27192098f,
			1f,
			0.7078691f,
			0.70375746f,
			0.060394015f,
			0f,
			0.69397604f,
			-0.6769973f,
			-0.24509633f,
			0f,
			-0.1316017f,
			0.21540803f,
			-0.9676165f,
			0f,
			-1.3737189f,
			0.2889329f,
			0.22382538f,
			1f,
			0.9004484f,
			0.4317413f,
			0.052848686f,
			0f,
			0.43170452f,
			-0.872234f,
			-0.22986895f,
			0f,
			-0.053147484f,
			0.22980008f,
			-0.971786f,
			0f,
			-1.2209468f,
			0.674033f,
			0.21206257f,
			1f,
			0.9317855f,
			0.3591426f,
			0.052850433f,
			0f,
			0.36133873f,
			-0.9036568f,
			-0.22986817f,
			0f,
			-0.034796778f,
			0.2332846f,
			-0.97178614f,
			0f,
			-1.1675215f,
			0.7214911f,
			0.21206021f,
			1f,
			0.75142986f,
			0.60601693f,
			-0.26095524f,
			0f,
			0.54250723f,
			-0.79257125f,
			-0.27841994f,
			0f,
			-0.37555242f,
			0.06764287f,
			-0.9243298f,
			0f,
			-1.2309874f,
			0.49808007f,
			0.48071045f,
			1f,
			0.91904587f,
			0.2919399f,
			-0.26481447f,
			0f,
			0.22134107f,
			-0.93818533f,
			-0.26611507f,
			0f,
			-0.32613447f,
			0.18595752f,
			-0.92685306f,
			0f,
			-0.98887676f,
			0.86364853f,
			0.46940288f,
			1f,
			0.9513838f,
			0.1573061f,
			-0.26481086f,
			0f,
			0.08469545f,
			-0.96021396f,
			-0.26611328f,
			0f,
			-0.29613632f,
			0.23074749f,
			-0.92685467f,
			0f,
			-0.8632083f,
			0.9433549f,
			0.46964544f,
			1f,
			0.7105328f,
			0.5290977f,
			-0.4638963f,
			0f,
			0.48640278f,
			-0.84569937f,
			-0.21955822f,
			0f,
			-0.5084843f,
			-0.06963716f,
			-0.8582512f,
			0f,
			-1.138666f,
			0.61343575f,
			0.53971416f,
			1f,
			0.88429976f,
			0.003927147f,
			-0.46690437f,
			0f,
			-0.05623632f,
			-0.9917897f,
			-0.11485141f,
			0f,
			-0.46352205f,
			0.12781997f,
			-0.87681806f,
			0f,
			-0.64042425f,
			1.1518023f,
			0.41969368f,
			1f,
			0.8842677f,
			0.003931619f,
			-0.46696538f,
			0f,
			-0.056241434f,
			-0.9917895f,
			-0.114851736f,
			0f,
			-0.46358284f,
			0.1278224f,
			-0.8767855f,
			0f,
			-0.64391255f,
			1.1181524f,
			0.42252403f,
			1f,
			-7.726419E-06f,
			0.013509828f,
			0.9999089f,
			0f,
			0.034476545f,
			-0.9993144f,
			0.013502064f,
			0f,
			0.99940586f,
			0.034473497f,
			-0.0004580509f,
			0f,
			-0.07978311f,
			1.2732363f,
			-0.66251427f,
			1f,
			-5.7112297E-06f,
			0.013510032f,
			0.9999091f,
			0f,
			0.03447661f,
			-0.9993144f,
			0.0135022f,
			0f,
			0.9994057f,
			0.03447353f,
			-0.00046007262f,
			0f,
			-0.09641439f,
			1.0948541f,
			-0.66251564f,
			1f,
			1.0000001f,
			-7.462118E-09f,
			7.4390245E-09f,
			0f,
			7.4505784E-09f,
			0.9999989f,
			0.001549813f,
			0f,
			-7.4505797E-09f,
			-0.0015498132f,
			0.99999887f,
			0f,
			0.00046631167f,
			-1.742834f,
			0.081920035f,
			1f,
			1.0000001f,
			-7.2044775E-09f,
			7.688808E-09f,
			0f,
			7.4505775E-09f,
			0.9994714f,
			-0.03250274f,
			0f,
			-7.4505784E-09f,
			0.03250274f,
			0.99947155f,
			0f,
			0.00046631167f,
			-1.809376f,
			0.14361563f,
			1f,
			1.0000001f,
			-7.609175E-09f,
			7.695391E-09f,
			0f,
			7.855278E-09f,
			0.99947155f,
			-0.032503203f,
			0f,
			-7.444E-09f,
			0.032503203f,
			0.99947166f,
			0f,
			0.00046631097f,
			-1.8808306f,
			0.14361651f,
			1f,
			1.0000001f,
			-7.0828157E-09f,
			7.6888105E-09f,
			0f,
			7.328981E-09f,
			0.9994717f,
			-0.03250307f,
			0f,
			-7.454533E-09f,
			0.032503072f,
			0.9994717f,
			0f,
			3.2690117E-10f,
			-1.9923469f,
			0.29009876f,
			1f,
			1.0000001f,
			-7.204476E-09f,
			7.68881E-09f,
			0f,
			7.4505775E-09f,
			0.99947166f,
			-0.032503057f,
			0f,
			-7.4505784E-09f,
			0.032503065f,
			0.99947166f,
			0f,
			-1.7229773E-11f,
			-2.1212184f,
			0.34864944f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			-9.536743E-09f,
			-1.4985263f,
			0.15238987f,
			1f,
			1.0000001f,
			-7.450579E-09f,
			7.450581E-09f,
			0f,
			7.4505784E-09f,
			1f,
			-2.7331692E-09f,
			0f,
			-7.4505797E-09f,
			2.7331692E-09f,
			1f,
			0f,
			0.05002293f,
			-1.7024337f,
			0.3897028f,
			1f,
			0.9835304f,
			0.18074276f,
			6.32473E-08f,
			0f,
			-0.08030735f,
			0.4370012f,
			-0.8958687f,
			0f,
			-0.16192175f,
			0.88111407f,
			0.444319f,
			0f,
			0.12616053f,
			-0.53103566f,
			1.835186f,
			1f,
			-5.1467495E-08f,
			3.2554702E-08f,
			-0.9999992f,
			0f,
			0.041892517f,
			-0.9991217f,
			-3.4682337E-08f,
			0f,
			-0.99912184f,
			-0.04189251f,
			5.0058503E-08f,
			0f,
			-0.2433881f,
			1.1447482f,
			2.0667812E-08f,
			1f,
			9.776069E-09f,
			-3.4729492E-08f,
			-0.9999992f,
			0f,
			0.1272776f,
			-0.99186695f,
			3.5690867E-08f,
			0f,
			-0.991867f,
			-0.12727757f,
			-5.2763127E-09f,
			0f,
			-0.32073995f,
			0.88973963f,
			-6.151413E-08f,
			1f,
			2.1057221E-07f,
			-3.718892E-08f,
			-0.9999992f,
			0f,
			0.7259284f,
			-0.6877701f,
			1.7843746E-07f,
			0f,
			-0.6877701f,
			-0.72592837f,
			-1.1782899E-07f,
			0f,
			-0.6285424f,
			0.26263115f,
			-1.8204491E-07f,
			1f,
			-0.0044826334f,
			0.12141404f,
			0.99259305f,
			0f,
			0.036617167f,
			-0.9919165f,
			0.12149685f,
			0f,
			0.99933064f,
			0.036890116f,
			5.5935595E-07f,
			0f,
			-0.022207502f,
			1.1198591f,
			-0.2746638f,
			1f,
			0.010752041f,
			0.12019061f,
			0.99269384f,
			0f,
			-0.088495374f,
			-0.9887409f,
			0.12067062f,
			0f,
			0.99602956f,
			-0.08914521f,
			5.330993E-06f,
			0f,
			0.05368857f,
			0.5998398f,
			-0.27406663f,
			1f,
			-6.9131374E-06f,
			7.927456E-06f,
			1.0000013f,
			0f,
			0.8077449f,
			-0.58954185f,
			1.0257509E-05f,
			0f,
			0.5895417f,
			0.8077453f,
			-2.327754E-06f,
			0f,
			-0.03457998f,
			0.086826526f,
			-0.26651052f,
			1f,
			-1.2209563E-06f,
			6.3708358E-06f,
			1.0000013f,
			0f,
			1.0000005f,
			4.237586E-06f,
			1.2209291E-06f,
			0f,
			-4.237532E-06f,
			1.0000114f,
			-6.3707753E-06f,
			0f,
			0.00014339534f,
			-0.058854178f,
			-0.26650915f,
			1f,
			0.2588191f,
			7.45069E-09f,
			0.96592593f,
			0f,
			-7.1169737E-10f,
			-1.0000001f,
			7.904221E-09f,
			0f,
			0.96592593f,
			-2.7332359E-09f,
			-0.25881907f,
			0f,
			-0.17980613f,
			1.1673483f,
			-0.044170797f,
			1f,
			6.593604E-07f,
			0.31800285f,
			0.94808984f,
			0f,
			-0.0019021513f,
			-0.948088f,
			0.31800225f,
			0f,
			0.9999981f,
			-0.00180362f,
			0.0006042643f,
			0f,
			-0.16956197f,
			1.045937f,
			-0.446577f,
			1f,
			6.173579E-06f,
			0.061788123f,
			0.9980894f,
			0f,
			-0.0019022069f,
			-0.9980877f,
			0.061788008f,
			0f,
			0.9999982f,
			-0.0018989535f,
			0.000111371955f,
			0f,
			-0.1695626f,
			1.0595759f,
			-0.1784217f,
			1f,
			2.9726143E-08f,
			-0.043325763f,
			0.9990611f,
			0f,
			0.1837865f,
			-0.982043f,
			-0.04258775f,
			0f,
			0.98296607f,
			0.18361394f,
			0.007962663f,
			0f,
			-0.3904841f,
			1.1053939f,
			-0.0445556f,
			1f,
			1.7957079E-06f,
			-0.043325983f,
			0.9990612f,
			0f,
			0.18378665f,
			-0.98204315f,
			-0.042588294f,
			0f,
			0.982966f,
			0.18361421f,
			0.007960975f,
			0f,
			-0.39048436f,
			0.9810741f,
			-0.044554684f,
			1f,
			-0.17652616f,
			0.7954767f,
			0.57970303f,
			0f,
			0.9842959f,
			0.1426627f,
			0.10396549f,
			0f,
			1.14012224E-07f,
			0.58895195f,
			-0.808168f,
			0f,
			-1.1958722f,
			-0.10750785f,
			0.03964651f,
			1f,
			0.026915947f,
			0.99396425f,
			0.10635218f,
			0f,
			0.9996378f,
			-0.026763108f,
			-0.0028642705f,
			0f,
			-6.678251E-07f,
			0.10639074f,
			-0.9943245f,
			0f,
			-1.1970668f,
			0.10101968f,
			0.15433837f,
			1f,
			-0.02287937f,
			0.9768854f,
			-0.2125371f,
			0f,
			0.99973845f,
			0.022356361f,
			-0.004863992f,
			0f,
			-6.9810824E-09f,
			-0.2125927f,
			-0.97714096f,
			0f,
			-1.1962215f,
			-0.012996774f,
			0.16027224f,
			1f,
			0.03593826f,
			0.65320677f,
			-0.75632644f,
			0f,
			0.99210924f,
			-0.11428383f,
			-0.05156014f,
			0f,
			-0.1201153f,
			-0.74850523f,
			-0.65215963f,
			0f,
			-1.1805928f,
			0.13526072f,
			0.25543037f,
			1f,
			0.0359398f,
			0.65320677f,
			-0.75632644f,
			0f,
			0.9921089f,
			-0.11428661f,
			-0.051560514f,
			0f,
			-0.12011764f,
			-0.7485052f,
			-0.6521595f,
			0f,
			-1.1805923f,
			0.07716692f,
			0.25543076f,
			1f
		};

		private static readonly string[] RigNames = new string[77]
		{
			"Root", "Hips", "L_Thigh", "L_Shin", "L_Foot", "L_Toe", "L_Cannister_Back", "L_Cannister_Front", "Spine1", "Spine2",
			"Spine3", "SpineEnd", "L_Clav", "L_Upperarm", "L_Forearm", "L_Hand", "L_Thumb_01", "L_Thumb_02", "L_Thumb_03", "L_Index_01",
			"L_Index_02", "L_Index_03", "L_Middle_01", "L_Middle_02", "L_Middle_03", "L_Ring_01", "L_Ring_02", "L_Ring_03", "L_Pinky_01", "L_Pinky_02",
			"L_Pinky_03", "R_Clav", "R_Upperarm", "R_Forearm", "R_Hand", "R_Thumb_01", "R_Thumb_02", "R_Thumb_03", "R_Index_01", "R_Index_02",
			"R_Index_03", "R_Middle_01", "R_Middle_02", "R_Middle_03", "R_Ring_01", "R_Ring_02", "R_Ring_03", "R_Pinky_01", "R_Pinky_02", "R_Pinky_03",
			"R_WristCloth_01", "R_WristCloth_02", "Neck", "Neck1", "Head", "HeadTube_01", "HeadTube_02", "Pack", "PackTube_01", "PackTube_02",
			"Cloth01", "Cloth02", "Cloth03", "R_Thigh", "R_Shin", "R_Foot", "R_Toe", "TassleMain", "Tassle_Back_01", "Tassle_Back_02",
			"Tassle_Front_01", "Tassle_Front_02", "Belt_01", "Belt_02", "Belt_03", "Belt_04", "Belt_05"
		};

		private static readonly string[] RigParents = new string[77]
		{
			"SeekerArmature", "Root", "Hips", "L_Thigh", "L_Shin", "L_Foot", "L_Thigh", "L_Thigh", "Hips", "Spine1",
			"Spine2", "Spine3", "SpineEnd", "L_Clav", "L_Upperarm", "L_Forearm", "L_Hand", "L_Thumb_01", "L_Thumb_02", "L_Hand",
			"L_Index_01", "L_Index_02", "L_Hand", "L_Middle_01", "L_Middle_02", "L_Hand", "L_Ring_01", "L_Ring_02", "L_Hand", "L_Pinky_01",
			"L_Pinky_02", "SpineEnd", "R_Clav", "R_Upperarm", "R_Forearm", "R_Hand", "R_Thumb_01", "R_Thumb_02", "R_Hand", "R_Index_01",
			"R_Index_02", "R_Hand", "R_Middle_01", "R_Middle_02", "R_Hand", "R_Ring_01", "R_Ring_02", "R_Hand", "R_Pinky_01", "R_Pinky_02",
			"R_Hand", "R_WristCloth_01", "SpineEnd", "Neck", "Neck1", "Head", "HeadTube_01", "Spine3", "Pack", "PackTube_01",
			"Hips", "Cloth01", "Cloth02", "Hips", "R_Thigh", "R_Shin", "R_Foot", "Hips", "TassleMain", "Tassle_Back_01",
			"TassleMain", "Tassle_Front_01", "Hips", "Belt_01", "Belt_02", "Belt_03", "Belt_04"
		};

		private void PrepareCycloneGhost()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_007b: 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)
			CycloneIndex = ProjectileCatalog.FindProjectileIndex("SeekerCyclonePrefab");
			if (CycloneIndex >= 0)
			{
				GameObject projectilePrefab = ProjectileCatalog.GetProjectilePrefab(CycloneIndex);
				if (!Object.op_Implicit((Object)(object)projectilePrefab) || !Object.op_Implicit((Object)(object)projectilePrefab.GetComponent<SeekerCycloneController>()))
				{
					throw new InvalidOperationException("Cyclone identity mismatch");
				}
				GameObject val = new GameObject("BreaditationCycloneGhost");
				val.transform.SetParent(ghostStorage.transform, false);
				val.AddComponent<ProjectileGhostController>();
				val.AddComponent<BreadCycloneGhost>();
				breadGhosts.Add(new ProjectileGhostReplacement
				{
					projectilePrefab = projectilePrefab,
					projectileGhostReplacementPrefab = val,
					ghostReplacementAddress = new AssetReferenceT<GameObject>("")
				});
			}
		}

		private IEnumerator PrepareBreadEffects(Material material)
		{
			Shapes = new BreadShapeBank(Path.Combine(folder, "effects.meshbin"), material);
			ghostStorage = new GameObject("Breaditation_GhostTemplates");
			ghostStorage.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)ghostStorage);
			BreadRoute[] array = new BreadRoute[7]
			{
				new BreadRoute("SpiritPunchProjectile", "pretzel", 1f, rotate: true),
				new BreadRoute("SpiritPunchFinisherProjectile", "loaf", 1.2f, rotate: false),
				new BreadRoute("UnseenHandMovingProjectile", "breadPalm", 1.7f, rotate: false),
				new BreadRoute("SoulSpiralProjectile", "pretzel", 1f, rotate: true),
				new BreadRoute("PalmBlastProjectile", "breadPalm", 1f, rotate: false),
				new BreadRoute("PalmBlastChargedProjectile", "breadPalm", 1.5f, rotate: false),
				new BreadRoute("SoulSearchProjectile", "loaf", 0.85f, rotate: false, needed: false)
			};
			BreadRoute[] array2 = array;
			foreach (BreadRoute route in array2)
			{
				int num = ProjectileCatalog.FindProjectileIndex(route.projectile);
				GameObject projectile = ((num >= 0) ? ProjectileCatalog.GetProjectilePrefab(num) : null);
				if (!Object.op_Implicit((Object)(object)projectile))
				{
					if (route.required)
					{
						throw new InvalidOperationException("Required bread projectile route missing: " + route.projectile);
					}
					continue;
				}
				ProjectileController component = projectile.GetComponent<ProjectileController>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					throw new InvalidOperationException("Projectile controller missing: " + route.projectile);
				}
				GameObject val = component.ghostPrefab;
				if (!Object.op_Implicit((Object)(object)val) && component.ghostPrefabAddress != null && ((AssetReference)component.ghostPrefabAddress).RuntimeKeyIsValid())
				{
					AsyncOperationHandle<GameObject> op = Addressables.LoadAssetAsync<GameObject>(((AssetReference)component.ghostPrefabAddress).RuntimeKey);
					retainedAssets.Add(AsyncOperationHandle<GameObject>.op_Implicit(op));
					while (!op.IsDone)
					{
						CheckDeadline();
						yield return null;
					}
					val = op.Result;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					throw new InvalidOperationException("Native ghost unavailable: " + route.projectile);
				}
				GameObject val2 = Object.Instantiate<GameObject>(val, ghostStorage.transform, false);
				((Object)val2).name = "Breaditation_" + route.projectile + "Ghost";
				Renderer[] array3 = (from r in val2.GetComponentsInChildren<Renderer>(true)
					where r is MeshRenderer || r is SkinnedMeshRenderer
					select r).ToArray();
				Renderer[] array4 = array3;
				for (int num2 = 0; num2 < array4.Length; num2++)
				{
					array4[num2].enabled = false;
				}
				ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>(true);
				for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
				{
					MainModule main = componentsInChildren[num2].main;
					((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.66f, 0.25f, 0.6f), new Color(1f, 0.9f, 0.64f, 0.9f));
				}
				GameObject val3 = Shapes.Attach(val2.transform, route.shape, route.scale, Vector3.zero);
				if (route.projectile == "SoulSpiralProjectile")
				{
					if (!Object.op_Implicit((Object)(object)val2.GetComponent<SoulSpiralGhost>()))
					{
						throw new InvalidOperationException("Soul Spiral callbacks unavailable");
					}
					Transform val4 = ((IEnumerable<Transform>)val2.GetComponentsInChildren<Transform>(true)).SingleOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "FinalHit"));
					if (!Object.op_Implicit((Object)(object)val4))
					{
						throw new InvalidOperationException("Soul Spiral final-hit visual unavailable");
					}
					Shapes.Attach(val4, "bagel", 1.05f, Vector3.zero);
				}
				BreadGhostVisual breadGhostVisual = val2.AddComponent<BreadGhostVisual>();
				breadGhostVisual.NativeMeshes = array3;
				breadGhostVisual.Bread = val3.transform;
				breadGhostVisual.Spin = route.spin;
				val2.SetActive(true);
				breadGhosts.Add(new ProjectileGhostReplacement
				{
					projectilePrefab = projectile,
					projectileGhostReplacementPrefab = val2,
					ghostReplacementAddress = new AssetReferenceT<GameObject>("")
				});
				((BaseUnityPlugin)this).Logger.LogInfo((object)("BREAD_PROJECTILE_ROUTE " + route.projectile + " -> " + route.shape));
			}
			PrepareCycloneGhost();
		}

		private static void CollectBreadContent(AddContentPackProviderDelegate add)
		{
			add.Invoke((IContentPackProvider)(object)new BreadEffectContent());
		}

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(CollectBreadContent);
			instance = this;
			folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(Breaditation));
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins));
			MainMenuController.OnMainMenuInitialised += SyncDisplaySkins;
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders -= new CollectContentPackProvidersDelegate(CollectBreadContent);
			impactRouting?.Dispose();
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(SyncDisplaySkins));
			MainMenuController.OnMainMenuInitialised -= SyncDisplaySkins;
			if ((Object)(object)instance == (Object)(object)this)
			{
				instance = null;
			}
		}

		[SystemInitializer(new Type[]
		{
			typeof(BodyCatalog),
			typeof(ProjectileCatalog)
		})]
		private static IEnumerator InitializeSkin()
		{
			if (!Object.op_Implicit((Object)(object)instance))
			{
				yield break;
			}
			instance.deadline = Time.realtimeSinceStartup + 45f;
			IEnumerator routine = instance.Register();
			while (true)
			{
				bool flag;
				try
				{
					flag = routine.MoveNext();
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)instance).Logger.LogError((object)("SEEKER_E7_REGISTRATION_FAILED: " + ex));
					break;
				}
				if (!flag)
				{
					break;
				}
				yield return routine.Current;
			}
			(routine as IDisposable)?.Dispose();
		}

		private void CheckDeadline()
		{
			if (Time.realtimeSinceStartup > deadline)
			{
				throw new TimeoutException("Breaditation asset load timed out; continuing startup.");
			}
		}

		private IEnumerator Register()
		{
			GameObject obj = BodyCatalog.FindBodyPrefab("SeekerBody");
			if (!Object.op_Implicit((Object)(object)obj))
			{
				throw new InvalidOperationException("SeekerBody missing (Seekers of the Storm required)");
			}
			ModelLocator component = obj.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.modelTransform))
			{
				throw new InvalidOperationException("Seeker model locator missing");
			}
			modelPrefab = ((Component)component.modelTransform).gameObject;
			ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>();
			if (!Object.op_Implicit((Object)(object)controller) || controller.skins == null || controller.skins.Length == 0)
			{
				throw new InvalidOperationException("Default Seeker skin unavailable");
			}
			if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "EclipsePlaytestSeekerE7Breaditation"))
			{
				yield break;
			}
			SkinDef baseSkin = controller.skins.Single((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinSeekerDefault");
			SkinDefParams bp = baseSkin.skinDefParams;
			if (!Object.op_Implicit((Object)(object)bp) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid())
			{
				AsyncOperationHandle<SkinDefParams> op = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey);
				retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(op));
				while (!op.IsDone)
				{
					CheckDeadline();
					yield return null;
				}
				bp = op.Result;
			}
			if (!Object.op_Implicit((Object)(object)bp))
			{
				throw new InvalidOperationException("Default Seeker parameters unavailable");
			}
			SkinnedMeshRenderer[] renderers = modelPrefab.GetSkinRenderers<SkinnedMeshRenderer>(inactive: true, bp);
			SkinnedMeshRenderer target = renderers.Single((SkinnedMeshRenderer r) => ((Object)r).name == "meshSeekerBody");
			ValidateRig(target);
			MeshReplacement val = bp.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target);
			Mesh reference = val.mesh;
			if (!Object.op_Implicit((Object)(object)reference) && val.meshAddress != null && ((AssetReference)val.meshAddress).RuntimeKeyIsValid())
			{
				AsyncOperationHandle<Mesh> op2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val.meshAddress).RuntimeKey);
				retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(op2));
				while (!op2.IsDone)
				{
					CheckDeadline();
					yield return null;
				}
				reference = op2.Result;
			}
			if (!Object.op_Implicit((Object)(object)reference) || reference.bindposes.Length != 77)
			{
				throw new InvalidOperationException("Default Seeker body bindposes unavailable");
			}
			for (int num = 0; num < 77; num++)
			{
				Matrix4x4 val2 = target.bones[num].worldToLocalMatrix * ((Component)target).transform.localToWorldMatrix;
				for (int num2 = 0; num2 < 16; num2++)
				{
					if (!Finite(((Matrix4x4)(ref reference.bindposes[num]))[num2]) || Math.Abs(((Matrix4x4)(ref reference.bindposes[num]))[num2] - AuthoredBindposes[num * 16 + num2]) > 0.005f || Math.Abs(((Matrix4x4)(ref reference.bindposes[num]))[num2] - ((Matrix4x4)(ref val2))[num2]) > 0.005f)
					{
						throw new InvalidOperationException("Seeker bind frame mismatch at " + num);
					}
				}
			}
			RendererInfo info = bp.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target);
			Material val3 = info.defaultMaterial;
			if (!Object.op_Implicit((Object)(object)val3) && info.defaultMaterialAddress != null && ((AssetReference)info.defaultMaterialAddress).RuntimeKeyIsValid())
			{
				AsyncOperationHandle<Material> op3 = Addressables.LoadAssetAsync<Material>(((AssetReference)info.defaultMaterialAddress).RuntimeKey);
				retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(op3));
				while (!op3.IsDone)
				{
					CheckDeadline();
					yield return null;
				}
				val3 = op3.Result;
			}
			if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader))
			{
				throw new InvalidOperationException("Native Seeker material unavailable");
			}
			BodyMesh = ReadMesh(Path.Combine(folder, "body.meshbin"), target, reference);
			Material val4 = new Material(val3)
			{
				name = "matEclipseSeekerE7Breaditation"
			};
			val4.SetTexture("_MainTex", (Texture)(object)ReadTexture("albedo.png", linear: false));
			val4.SetColor("_Color", Color.white);
			val4.SetFloat("_NormalStrength", 0f);
			val4.SetFloat("_Smoothness", 0.19f);
			val4.SetFloat("_SpecularStrength", 0.17f);
			val4.SetFloat("_SpecularExponent", 12f);
			val4.SetFloat("_EmPower", 0f);
			val4.SetColor("_EmColor", Color.black);
			string[] array = new string[3] { "FLOWMAP", "FORCE_SPEC", "LIMBREMOVAL" };
			foreach (string text in array)
			{
				val4.DisableKeyword(text);
			}
			val4.SetFloat("_FlowmapOn", 0f);
			val4.SetFloat("_FlowEmissionStrength", 0f);
			val4.SetFloat("_ForceSpecOn", 0f);
			val4.SetFloat("_LimbRemovalOn", 0f);
			info.defaultMaterial = val4;
			info.defaultMaterialAddress = new AssetReferenceT<Material>("");
			List<MeshReplacement> list = new List<MeshReplacement>
			{
				new MeshReplacement
				{
					renderer = (Renderer)(object)target,
					mesh = BodyMesh,
					meshAddress = new AssetReferenceT<Mesh>("")
				}
			};
			array = new string[2] { "meshSeekerCloth", "meshSeekerGlass" };
			foreach (string name in array)
			{
				SkinnedMeshRenderer val5 = renderers.Single((SkinnedMeshRenderer x) => ((Object)x).name == name);
				ValidateRig(val5);
				Mesh val6 = new Mesh
				{
					name = "Breaditation_empty_" + name
				};
				val6.bindposes = reference.bindposes;
				list.Add(new MeshReplacement
				{
					renderer = (Renderer)(object)val5,
					mesh = val6,
					meshAddress = new AssetReferenceT<Mesh>("")
				});
			}
			SkinDefParams parameters = ScriptableObject.CreateInstance<SkinDefParams>();
			parameters.rendererInfos = (RendererInfo[])(object)new RendererInfo[1] { info };
			parameters.meshReplacements = list.ToArray();
			IEnumerator effectPreparation = PrepareBreadEffects(val4);
			while (effectPreparation.MoveNext())
			{
				yield return effectPreparation.Current;
			}
			parameters.projectileGhostReplacements = breadGhosts.ToArray();
			SkinDef val7 = ScriptableObject.CreateInstance<SkinDef>();
			((Object)val7).name = "EclipsePlaytestSeekerE7Breaditation";
			val7.nameToken = "ECLIPSE_PLAYTEST_SEEKER_E7_BREADITATION";
			LanguageAPI.Add(val7.nameToken, "Breaditation (Playtest)");
			val7.unlockableDef = null;
			val7.rootObject = modelPrefab;
			val7.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin };
			val7.skinDefParams = parameters;
			Texture2D val8 = ReadTexture("skin-icon.png", linear: false);
			val7.icon = Sprite.Create(val8, new Rect(0f, 0f, (float)((Texture)val8).width, (float)((Texture)val8).height), new Vector2(0.5f, 0.5f));
			ActiveSkin = val7;
			impactRouting = new BreadImpactRouting();
			controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { val7 }).ToArray();
			AttachBounds(modelPrefab);
			registered = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("SEEKER_E7_REGISTERED version=0.1.3 model=M009 unlocked=true vertices=" + BodyMesh.vertexCount));
		}

		private static void AttachBounds(GameObject model)
		{
			if (!Object.op_Implicit((Object)(object)model.GetComponent<BreaditationBounds>()))
			{
				model.AddComponent<BreaditationBounds>();
			}
			if (!Object.op_Implicit((Object)(object)model.GetComponent<BreadThemeHost>()))
			{
				model.AddComponent<BreadThemeHost>();
			}
		}

		private void SyncDisplaySkins()
		{
			try
			{
				SyncDisplay();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("SEEKER_E7_DISPLAY_FAILED: " + ex));
			}
		}

		private void SyncDisplay()
		{
			if (!registered)
			{
				return;
			}
			SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "SeekerBody"));
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.displayPrefab))
			{
				return;
			}
			CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true);
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			ModelSkinController component = ((Component)componentInChildren).GetComponent<ModelSkinController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Seeker lobby controller unavailable; display untouched");
				return;
			}
			string[] array = new string[3] { "meshSeekerBody", "meshSeekerCloth", "meshSeekerGlass" };
			foreach (string name in array)
			{
				ValidateRig(((Component)(object)componentInChildren).GetSkinRenderers<SkinnedMeshRenderer>(inactive: true, (SkinDefParams)null).Single((SkinnedMeshRenderer r) => ((Object)r).name == name));
			}
			component.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone();
			AttachBounds(((Component)componentInChildren).gameObject);
		}

		private static void ValidateRig(SkinnedMeshRenderer target)
		{
			if (target.bones.Length != 77 || target.bones.Any((Transform b) => !Object.op_Implicit((Object)(object)b)) || target.bones.Select((Transform b) => ((Object)b).name).Distinct().Count() != 77)
			{
				throw new InvalidOperationException("Invalid unique Seeker rig");
			}
			if (!Object.op_Implicit((Object)(object)target.rootBone) || ((Object)target.rootBone).name != "Root")
			{
				throw new InvalidOperationException("Wrong Seeker root bone");
			}
			for (int num = 0; num < 77; num++)
			{
				if (((Object)target.bones[num]).name != RigNames[num] || (Object.op_Implicit((Object)(object)target.bones[num].parent) ? ((Object)target.bones[num].parent).name : "") != RigParents[num])
				{
					throw new InvalidOperationException("Seeker bone/parent mismatch at " + num);
				}
			}
		}

		private static bool Finite(float x)
		{
			if (!float.IsNaN(x))
			{
				return !float.IsInfinity(x);
			}
			return false;
		}

		private Texture2D ReadTexture(string name, bool linear)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0018: 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_0037: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear)
			{
				name = name,
				anisoLevel = 4,
				filterMode = (FilterMode)2
			};
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false))
			{
				throw new InvalidDataException("Cannot decode " + name);
			}
			return val;
		}

		private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference)
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
			if (new string(binaryReader.ReadChars(4)) != "PWE1")
			{
				throw new InvalidDataException("Invalid mesh signature.");
			}
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			int num3 = binaryReader.ReadInt32();
			if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 77)
			{
				throw new InvalidDataException("Invalid mesh dimensions.");
			}
			int[] array = new int[num3];
			HashSet<string> hashSet = new HashSet<string>();
			for (int i = 0; i < num3; i++)
			{
				int num4 = binaryReader.ReadInt32();
				if (num4 < 1 || num4 > 128)
				{
					throw new InvalidDataException("Invalid bone name.");
				}
				string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4));
				if (!hashSet.Add(name) || name != RigNames[i])
				{
					throw new InvalidDataException("Unexpected or duplicate payload bone.");
				}
				array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name);
				if (array[i] < 0)
				{
					throw new InvalidDataException("Missing reference bone: " + name);
				}
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3[] array3 = (Vector3[])(object)new Vector3[num];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num];
			BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num];
			for (int num5 = 0; num5 < num; num5++)
			{
				array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
				int[] array6 = new int[4];
				for (int num6 = 0; num6 < 4; num6++)
				{
					int num7 = binaryReader.ReadInt32();
					if (num7 < 0 || num7 >= num3)
					{
						throw new InvalidDataException("Bone out of range.");
					}
					array6[num6] = array[num7];
				}
				float[] array7 = new float[4];
				for (int num8 = 0; num8 < 4; num8++)
				{
					array7[num8] = binaryReader.ReadSingle();
				}
				if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f)
				{
					throw new InvalidDataException("Invalid skin weight.");
				}
				if (!Finite(array2[num5]) || !Finite(array3[num5]) || float.IsNaN(array4[num5].x + array4[num5].y) || float.IsInfinity(array4[num5].x + array4[num5].y))
				{
					throw new InvalidDataException("Non-finite vertex.");
				}
				int num9 = num5;
				BoneWeight val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = array6[0];
				((BoneWeight)(ref val)).boneIndex1 = array6[1];
				((BoneWeight)(ref val)).boneIndex2 = array6[2];
				((BoneWeight)(ref val)).boneIndex3 = array6[3];
				((BoneWeight)(ref val)).weight0 = array7[0];
				((BoneWeight)(ref val)).weight1 = array7[1];
				((BoneWeight)(ref val)).weight2 = array7[2];
				((BoneWeight)(ref val)).weight3 = array7[3];
				array5[num9] = val;
			}
			int[] array8 = new int[num2];
			for (int num10 = 0; num10 < num2; num10++)
			{
				array8[num10] = binaryReader.ReadInt32();
				if (array8[num10] < 0 || array8[num10] >= num)
				{
					throw new InvalidDataException("Triangle out of range.");
				}
			}
			if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
			{
				throw new InvalidDataException("Unexpected trailing mesh data.");
			}
			Mesh val2 = new Mesh
			{
				name = "SeekerBreaditationMesh",
				indexFormat = (IndexFormat)(num > 65535),
				vertices = array2,
				normals = array3,
				uv = array4,
				boneWeights = array5,
				bindposes = reference.bindposes,
				triangles = array8
			};
			val2.RecalculateBounds();
			val2.RecalculateTangents();
			return val2;
		}

		private static bool Finite(Vector3 v)
		{
			//IL_0000: 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_000d: 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_0021: 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)
			if (!float.IsNaN(v.x + v.y + v.z))
			{
				return !float.IsInfinity(v.x + v.y + v.z);
			}
			return false;
		}
	}
	internal sealed class BreadHudColors : IDisposable
	{
		private readonly SeekerController controller;

		private readonly Dictionary<FieldInfo, Color32> old = new Dictionary<FieldInfo, Color32>();

		private readonly Dictionary<FieldInfo, Color32> owned = new Dictionary<FieldInfo, Color32>();

		internal BreadHudColors(CharacterBody actor)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00df: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			controller = (Object.op_Implicit((Object)(object)actor) ? ((Component)actor).GetComponent<SeekerController>() : null);
			if (Object.op_Implicit((Object)(object)controller))
			{
				Set("chakraDefaultColor", new Color32((byte)131, (byte)103, (byte)77, byte.MaxValue));
				Set("chakraGrantedColor", new Color32((byte)235, (byte)164, (byte)51, byte.MaxValue));
				Set("chakraFinishedColor", new Color32(byte.MaxValue, (byte)234, (byte)178, byte.MaxValue));
				Set("chakraAfterReviveColor", new Color32((byte)189, (byte)155, (byte)112, byte.MaxValue));
				Set("chakraAfterReviveCompleteColor", new Color32(byte.MaxValue, (byte)250, (byte)226, byte.MaxValue));
				Set("chakraSplashDefaultColor", new Color32((byte)139, (byte)109, (byte)76, (byte)170));
				Set("chakraSplashGrantedColor", new Color32(byte.MaxValue, (byte)206, (byte)103, (byte)230));
				Set("chakraSplashBurnedColor", new Color32((byte)69, (byte)40, (byte)26, (byte)170));
				Set("chakraBurnedColor", new Color32((byte)75, (byte)47, (byte)32, byte.MaxValue));
			}
		}

		private void Set(string name, Color32 color)
		{
			//IL_0047: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo field = typeof(SeekerController).GetField(name, BindingFlags.Instance | BindingFlags.Public);
			if (!(field == null) && !(field.FieldType != typeof(Color32)))
			{
				old[field] = (Color32)field.GetValue(controller);
				owned[field] = color;
				field.SetValue(controller, color);
			}
		}

		public void Dispose()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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)
			if (Object.op_Implicit((Object)(object)controller))
			{
				foreach (KeyValuePair<FieldInfo, Color32> item in old)
				{
					if (((object)(Color32)item.Key.GetValue(controller)/*cast due to .constrained prefix*/).Equals((object?)owned[item.Key]))
					{
						item.Key.SetValue(controller, item.Value);
					}
				}
			}
			old.Clear();
			owned.Clear();
		}
	}
	internal sealed class BreadEffectContent : IContentPackProvider
	{
		private readonly ContentPack pack = new ContentPack();

		internal static GameObject Burst;

		public string identifier => "eclipseplaytest.seeker.e7.effects";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			typeof(ContentPack).GetProperty("identifier").SetValue(pack, identifier, null);
			GameObject val = new GameObject("BreaditationEffectTemplates");
			val.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)val);
			Burst = new GameObject("BreaditationCrumbBurst");
			Burst.transform.SetParent(val.transform, false);
			Burst.AddComponent<EffectComponent>().applyScale = true;
			Burst.AddComponent<VFXAttributes>();
			Burst.AddComponent<BreadCrumbBurst>();
			pack.effectDefs.Add((EffectDef[])(object)new EffectDef[1]
			{
				new EffectDef(Burst)
				{
					shouldPool = false
				}
			});
			args.ReportProgress(1f);
			yield break;
		}

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

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	public sealed class BreadCrumbBurst : MonoBehaviour
	{
		private readonly List<Transform> crumbs = new List<Transform>();

		private Transform ring;

		private EffectComponent effect;

		private float age;

		private bool ready;

		private void Awake()
		{
			effect = ((Component)this).GetComponent<EffectComponent>();
		}

		private void Update()
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isBatchMode)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (!ready)
			{
				if (!Object.op_Implicit((Object)(object)effect) || effect.effectData == null)
				{
					return;
				}
				if (Breaditation.Shapes == null)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				ready = true;
				uint genericUInt = effect.effectData.genericUInt;
				int num = genericUInt switch
				{
					0u => 5, 
					1u => 8, 
					_ => 12, 
				};
				for (int i = 0; i < num; i++)
				{
					crumbs.Add(Breaditation.Shapes.Attach(((Component)this).transform, (genericUInt >= 2 && i % 3 == 0) ? "pretzel" : "crumb", (genericUInt >= 2 && i % 3 == 0) ? 0.2f : 1f, Vector3.zero).transform);
				}
				if (genericUInt >= 1)
				{
					ring = Breaditation.Shapes.Attach(((Component)this).transform, "bagel", 0.15f, Vector3.zero).transform;
				}
			}
			age += Time.deltaTime;
			float num2 = Mathf.Clamp01(age / 0.55f);
			Vector3 val = default(Vector3);
			for (int j = 0; j < crumbs.Count; j++)
			{
				float num3 = (float)j * 2.39996f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num3), 0.4f + (float)(j % 3) * 0.23f, Mathf.Sin(num3));
				crumbs[j].localPosition = val * num2 * 0.55f + Vector3.down * num2 * num2 * 0.18f;
				crumbs[j].localScale = Vector3.one * ((j % 3 == 0 && effect.effectData.genericUInt >= 2) ? 0.2f : 1f) * (1f - num2);
				crumbs[j].Rotate(90f * Time.deltaTime, 130f * Time.deltaTime, 40f * Time.deltaTime);
			}
			if (Object.op_Implicit((Object)(object)ring))
			{
				ring.localScale = Vector3.one * (0.15f + 1.25f * num2);
			}
			if (num2 >= 1f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	internal sealed class BreadImpactRouting : IDisposable
	{
		private sealed class Context
		{
			internal HashSet<GameObject> allowed;

			internal uint kind;
		}

		[ThreadStatic]
		private static Context current;

		private bool disposed;

		internal BreadImpactRouting()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			try
			{
				EffectManager.SpawnEffect_GameObject_EffectData_bool += new hook_SpawnEffect_GameObject_EffectData_bool(Spawn);
				EffectManager.SimpleMuzzleFlash += new hook_SimpleMuzzleFlash(Muzzle);
				ProjectileOverlapAttack.FixedUpdate += new hook_FixedUpdate(Overlap);
				ProjectileImpactExplosion.Detonate += new hook_Detonate(Detonate);
				Meditate.Update += new hook_Update(Meditate);
				UnseenHand.FixedUpdate += new hook_FixedUpdate(Unseen);
				SeekerController.UnlockGateEffects += new hook_UnlockGateEffects(Gate);
				SeekerController.UnlockPalmBlastEffects += new hook_UnlockPalmBlastEffects(PalmGate);
			}
			catch
			{
				Dispose();
				throw;
			}
		}

		internal static bool Own(CharacterBody body)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)Breaditation.ActiveSkin))
			{
				return (Object)(object)SkinCatalog.GetBodySkinDef(body.bodyIndex, (int)body.skinIndex) == (Object)(object)Breaditation.ActiveSkin;
			}
			return false;
		}

		private static CharacterBody Owner(Component component)
		{
			ProjectileController val = (Object.op_Implicit((Object)(object)component) ? component.GetComponent<ProjectileController>() : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.owner))
			{
				return null;
			}
			return val.owner.GetComponent<CharacterBody>();
		}

		private static GameObject Ref(object obj, string name)
		{
			Type type = obj.GetType();
			while (type != null)
			{
				FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null && field.FieldType == typeof(GameObject))
				{
					object? value = field.GetValue(field.IsStatic ? null : obj);
					return (GameObject)((value is GameObject) ? value : null);
				}
				type = type.BaseType;
			}
			return null;
		}

		private static void Within(CharacterBody body, uint kind, object obj, string[] fields, Action native)
		{
			Context context = current;
			current = null;
			try
			{
				if (Own(body))
				{
					HashSet<GameObject> hashSet = new HashSet<GameObject>();
					foreach (string name in fields)
					{
						GameObject val = Ref(obj, name);
						if (Object.op_Implicit((Object)(object)val))
						{
							hashSet.Add(val);
						}
					}
					current = new Context
					{
						allowed = hashSet,
						kind = kind
					};
				}
				native();
			}
			finally
			{
				current = context;
			}
		}

		private static void Spawn(orig_SpawnEffect_GameObject_EffectData_bool orig, GameObject prefab, EffectData data, bool transmit)
		{
			//IL_003e: 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_0045: 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_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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			Context context = current;
			orig.Invoke(prefab, data, transmit);
			if (context != null && Object.op_Implicit((Object)(object)prefab) && context.allowed.Contains(prefab) && data != null && Object.op_Implicit((Object)(object)BreadEffectContent.Burst))
			{
				orig.Invoke(BreadEffectContent.Burst, new EffectData
				{
					origin = data.origin,
					rotation = data.rotation,
					scale = Mathf.Clamp(data.scale, 0.2f, 12f),
					genericUInt = context.kind
				}, transmit);
			}
		}

		private static void Muzzle(orig_SimpleMuzzleFlash orig, GameObject prefab, GameObject owner, string child, bool transmit)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00b9: Expected O, but got Unknown
			orig.Invoke(prefab, owner, child, transmit);
			CharacterBody val = (Object.op_Implicit((Object)(object)owner) ? owner.GetComponent<CharacterBody>() : null);
			if (Own(val) && Object.op_Implicit((Object)(object)BreadEffectContent.Burst) && Object.op_Implicit((Object)(object)val.modelLocator) && Object.op_Implicit((Object)(object)val.modelLocator.modelTransform))
			{
				ChildLocator component = ((Component)val.modelLocator.modelTransform).GetComponent<ChildLocator>();
				Transform val2 = (Object.op_Implicit((Object)(object)component) ? component.FindChild(child) : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					EffectManager.SpawnEffect(BreadEffectContent.Burst, new EffectData
					{
						origin = val2.position,
						rotation = val2.rotation,
						scale = 0.35f,
						genericUInt = 0u
					}, transmit);
				}
			}
		}

		private static void Overlap(orig_FixedUpdate orig, ProjectileOverlapAttack self)
		{
			Within(Owner((Component)(object)self), 0u, self, new string[1] { "impactEffect" }, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void Detonate(orig_Detonate orig, ProjectileImpactExplosion self)
		{
			Within(Owner((Component)(object)self), 1u, self, new string[2] { "impactEffect", "expiredEffect" }, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void Meditate(orig_Update orig, Meditate self)
		{
			Within(Object.op_Implicit((Object)(object)((EntityState)self).outer) ? ((Component)((EntityState)self).outer).GetComponent<CharacterBody>() : null, 2u, self, new string[2] { "successEffectPrefab", "chakra7SuccessEffectPrefab" }, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void Unseen(orig_FixedUpdate orig, UnseenHand self)
		{
			Within(Object.op_Implicit((Object)(object)((EntityState)self).outer) ? ((Component)((EntityState)self).outer).GetComponent<CharacterBody>() : null, 1u, self, new string[1] { "muzzleFlashEffect" }, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void Gate(orig_UnlockGateEffects orig, SeekerController self, byte value)
		{
			Within(((Component)self).GetComponent<CharacterBody>(), (value == 7) ? 3u : 2u, self, new string[1] { "healingExplosionPrefab" }, delegate
			{
				orig.Invoke(self, value);
			});
		}

		private static void PalmGate(orig_UnlockPalmBlastEffects orig, SeekerController self, byte value)
		{
			Within(((Component)self).GetComponent<CharacterBody>(), (value == 7) ? 3u : 2u, self, new string[2] { "palmBlastSuccessEffectPrefab", "palmBlastChakra7SuccessEffectPrefab" }, delegate
			{
				orig.Invoke(self, value);
			});
		}

		public void Dispose()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			if (!disposed)
			{
				disposed = true;
				EffectManager.SpawnEffect_GameObject_EffectData_bool -= new hook_SpawnEffect_GameObject_EffectData_bool(Spawn);
				EffectManager.SimpleMuzzleFlash -= new hook_SimpleMuzzleFlash(Muzzle);
				ProjectileOverlapAttack.FixedUpdate -= new hook_FixedUpdate(Overlap);
				ProjectileImpactExplosion.Detonate -= new hook_Detonate(Detonate);
				Meditate.Update -= new hook_Update(Meditate);
				UnseenHand.FixedUpdate -= new hook_FixedUpdate(Unseen);
				SeekerController.UnlockGateEffects -= new hook_UnlockGateEffects(Gate);
				SeekerController.UnlockPalmBlastEffects -= new hook_UnlockPalmBlastEffects(PalmGate);
			}
		}
	}
	public sealed class BreadThemeHost : MonoBehaviour
	{
		private SkinnedMeshRenderer target;

		private CharacterBody actor;

		private ISkinEffectDriver driver;

		private bool faulted;

		private void LateUpdate()
		{
			if (!Object.op_Implicit((Object)(object)target))
			{
				target = ((IEnumerable<SkinnedMeshRenderer>)((Component)(object)this).GetSkinRenderers<SkinnedMeshRenderer>(inactive: true, (SkinDefParams)null)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => ((Object)r).name == "meshSeekerBody"));
			}
			CharacterModel component = ((Component)this).GetComponent<CharacterModel>();
			CharacterBody val = (Object.op_Implicit((Object)(object)component) ? component.body : null);
			if (!Object.op_Implicit((Object)(object)target) || (Object)(object)target.sharedMesh != (Object)(object)Breaditation.BodyMesh || Breaditation.Shapes == null)
			{
				Release();
				faulted = false;
				return;
			}
			if ((Object)(object)actor != (Object)(object)val)
			{
				Release();
				actor = val;
				faulted = false;
			}
			if (faulted)
			{
				return;
			}
			try
			{
				if (driver == null)
				{
					driver = (ISkinEffectDriver)(object)new BreadNativeEffects(target, val);
				}
				driver.Update();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("BREAD_NATIVE_EFFECTS_FALLBACK " + ex));
				Release();
				faulted = true;
			}
		}

		private void Release()
		{
			if (driver != null)
			{
				((IDisposable)driver).Dispose();
				driver = null;
			}
			actor = null;
		}

		private void OnDisable()
		{
			Release();
		}

		private void OnDestroy()
		{
			Release();
		}
	}
	internal sealed class BreadNativeEffects : ISkinEffectDriver, IDisposable
	{
		private static readonly FieldInfo indicator = CheckedField(typeof(UnseenHand), "areaIndicatorInstance", typeof(GameObject));

		private static readonly FieldInfo charge = CheckedField(typeof(BaseChargePalmBlast), "chargeVfxInstanceTransform", typeof(Transform));

		private static readonly FieldInfo lotus = CheckedField(typeof(Meditate), "lotus", typeof(GameObject));

		private readonly SkinnedMeshRenderer renderer;

		private readonly Transform modelRoot;

		private readonly CharacterBody actor;

		private readonly EntityStateMachine[] machines;

		private readonly Dictionary<GameObject, BreadEffectLease> leases = new Dictionary<GameObject, BreadEffectLease>();

		private BreadHudColors colors;

		private VehicleSeat seat;

		private BreadEffectLease vehicle;

		private bool disposed;

		private float nextDisplayCheck;

		private static FieldInfo CheckedField(Type t, string name, Type expected)
		{
			FieldInfo field = t.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(field != null) || !(field.FieldType == expected))
			{
				return null;
			}
			return field;
		}

		internal BreadNativeEffects(SkinnedMeshRenderer renderer, CharacterBody actor)
		{
			this.renderer = renderer;
			this.actor = actor;
			CharacterModel componentInParent = ((Component)renderer).GetComponentInParent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)componentInParent))
			{
				throw new InvalidOperationException("Bread model unavailable");
			}
			modelRoot = ((Component)componentInParent).transform;
			if (Object.op_Implicit((Object)(object)actor))
			{
				if (!Object.op_Implicit((Object)(object)actor.modelLocator) || !Object.op_Implicit((Object)(object)actor.modelLocator.modelTransform) || !((Component)renderer).transform.IsChildOf(actor.modelLocator.modelTransform))
				{
					throw new InvalidOperationException("Bread actor model ownership mismatch");
				}
				machines = ((Component)actor).GetComponents<EntityStateMachine>();
			}
			colors = new BreadHudColors(actor);
			VehicleSeat.onPassengerEnterGlobal += Enter;
			VehicleSeat.onPassengerExitGlobal += Exit;
		}

		public void Update()
		{
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			if (disposed || !Object.op_Implicit((Object)(object)renderer))
			{
				return;
			}
			KeyValuePair<GameObject, BreadEffectLease>[] array = leases.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<GameObject, BreadEffectLease> keyValuePair = array[i];
				if (!Object.op_Implicit((Object)(object)keyValuePair.Key) || !Object.op_Implicit((Object)(object)keyValuePair.Value) || keyValuePair.Value.Disposed)
				{
					if (Object.op_Implicit((Object)(object)keyValuePair.Value))
					{
						keyValuePair.Value.Dispose();
					}
					leases.Remove(keyValuePair.Key);
				}
			}
			if (Object.op_Implicit((Object)(object)actor))
			{
				VehicleSeat val = VehicleSeat.FindVehicleSeatWithPassenger(((Component)actor).gameObject, seat);
				if ((Object)(object)val != (Object)(object)seat)
				{
					ReleaseVehicle();
					if (Object.op_Implicit((Object)(object)val))
					{
						AttachVehicle(val);
					}
				}
				EntityStateMachine[] array2 = machines;
				foreach (EntityStateMachine val2 in array2)
				{
					EntityState val3 = (Object.op_Implicit((Object)(object)val2) ? val2.state : null);
					if (val3 == null)
					{
						continue;
					}
					if (indicator != null && val3 is UnseenHand)
					{
						object? value = indicator.GetValue(val3);
						GameObject val4 = (GameObject)((value is GameObject) ? value : null);
						UnseenHandIndicator val5 = (Object.op_Implicit((Object)(object)val4) ? val4.GetComponent<UnseenHandIndicator>() : null);
						if (Object.op_Implicit((Object)(object)val5) && (Object)(object)val5.caster == (Object)(object)actor)
						{
							Attach(val4, "pretzel", 0.8f, Vector3.up * 0.04f, hideMeshes: false, horizontal: true);
						}
					}
					if (charge != null && val3 is BaseChargePalmBlast)
					{
						object? value2 = charge.GetValue(val3);
						Transform val6 = (Transform)((value2 is Transform) ? value2 : null);
						if (Object.op_Implicit((Object)(object)val6) && val6.IsChildOf(actor.modelLocator.modelTransform))
						{
							Attach(((Component)val6).gameObject, "pretzel", 0.65f, Vector3.zero, hideMeshes: false, horizontal: false);
						}
					}
					if (lotus != null && val3 is Meditate)
					{
						object? value3 = lotus.GetValue(val3);
						GameObject val7 = (GameObject)((value3 is GameObject) ? value3 : null);
						if (Object.op_Implicit((Object)(object)val7) && val7.transform.IsChildOf(actor.modelLocator.modelTransform))
						{
							AttachLotus(val7);
						}
					}
				}
			}
			if (!(Time.unscaledTime >= nextDisplayCheck))
			{
				return;
			}
			nextDisplayCheck = Time.unscaledTime + 0.5f;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)modelRoot).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val8 in componentsInChildren)
			{
				if (((Object)val8).name == "meshSeekerLotus" && val8.bones.Length == 20 && ((Component)val8).transform.IsChildOf(modelRoot))
				{
					AttachLotus(((Component)val8).gameObject);
				}
			}
		}

		private void Enter(VehicleSeat current, GameObject passenger)
		{
			if (!disposed && Object.op_Implicit((Object)(object)actor) && (Object)(object)passenger == (Object)(object)((Component)actor).gameObject)
			{
				ReleaseVehicle();
				AttachVehicle(current);
			}
		}

		private void Exit(VehicleSeat current, GameObject passenger)
		{
			if ((Object)(object)current == (Object)(object)seat || (Object.op_Implicit((Object)(object)actor) && (Object)(object)passenger == (Object)(object)((Component)actor).gameObject))
			{
				ReleaseVehicle();
			}
		}

		private void AttachVehicle(VehicleSeat current)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)current) || (Object)(object)current.currentPassengerBody != (Object)(object)actor)
			{
				return;
			}
			SojournVehicleBase component = ((Component)current).GetComponent<SojournVehicleBase>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.effectsToFlatten))
			{
				return;
			}
			seat = current;
			GameObject effectsToFlatten = component.effectsToFlatten;
			HashSet<Renderer> preserve = new HashSet<Renderer>();
			SojournVehicle val = (SojournVehicle)(object)((component is SojournVehicle) ? component : null);
			if (Object.op_Implicit((Object)(object)val) && val.blastRadiusIndicators != null)
			{
				GameObject[] blastRadiusIndicators = val.blastRadiusIndicators;
				foreach (GameObject val2 in blastRadiusIndicators)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true);
						foreach (Renderer item in componentsInChildren)
						{
							preserve.Add(item);
						}
					}
				}
			}
			Renderer[] renderers = (from r in effectsToFlatten.GetComponentsInChildren<Renderer>(true)
				where !preserve.Contains(r)
				select r).ToArray();
			vehicle = effectsToFlatten.AddComponent<BreadEffectLease>();
			vehicle.Initialize(renderers);
			vehicle.AddShape("pretzel", 3.2f, Vector3.zero);
			vehicle.Spin = true;
		}

		private void ReleaseVehicle()
		{
			if (Object.op_Implicit((Object)(object)vehicle))
			{
				vehicle.Dispose();
			}
			vehicle = null;
			seat = null;
		}

		private void Attach(GameObject root, string shape, float scale, Vector3 offset, bool hideMeshes, bool horizontal)
		{
			//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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)root))
			{
				return;
			}
			Scene scene = root.scene;
			if (((Scene)(ref scene)).IsValid() && !leases.ContainsKey(root))
			{
				Renderer[] renderers = (Renderer[])(hideMeshes ? ((Array)(from r in root.GetComponentsInChildren<Renderer>(true)
					where r is MeshRenderer || r is SkinnedMeshRenderer
					select r).ToArray()) : ((Array)new Renderer[0]));
				BreadEffectLease breadEffectLease = root.AddComponent<BreadEffectLease>();
				breadEffectLease.Initialize(renderers);
				GameObject val = breadEffectLease.AddShape(shape, scale, offset);
				if (horizontal)
				{
					val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
				}
				leases.Add(root, breadEffectLease);
			}
		}

		private void AttachLotus(GameObject root)
		{
			//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)
			if (!Object.op_Implicit((Object)(object)root))
			{
				return;
			}
			Scene scene = root.scene;
			if (!((Scene)(ref scene)).IsValid() || leases.ContainsKey(root))
			{
				return;
			}
			SkinnedMeshRenderer[] array = (from r in root.GetComponentsInChildren<SkinnedMeshRenderer>(true)
				where ((Object)r).name == "meshSeekerLotus" && r.bones.Length == 20
				select r).ToArray();
			if (array.Length == 0 || array.Any((SkinnedMeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).GetComponentInParent<BreadEffectLease>())))
			{
				return;
			}
			List<Tuple<Transform, Transform>> list = new List<Tuple<Transform, Transform>>();
			SkinnedMeshRenderer[] array2 = array;
			foreach (SkinnedMeshRenderer val in array2)
			{
				int i;
				for (i = 1; i <= 9; i++)
				{
					Transform val2 = ((IEnumerable<Transform>)val.bones).FirstOrDefault((Func<Transform, bool>)((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "Petal.Base." + i.ToString("000")));
					Transform val3 = ((IEnumerable<Transform>)val.bones).FirstOrDefault((Func<Transform, bool>)((Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == "Petal.Tip." + i.ToString("000")));
					if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
					{
						return;
					}
					list.Add(Tuple.Create<Transform, Transform>(val2, val3));
				}
			}
			BreadEffectLease breadEffectLease = root.AddComponent<BreadEffectLease>();
			breadEffectLease.Initialize(array.Cast<Renderer>().ToArray());
			foreach (Tuple<Transform, Transform> item in list)
			{
				breadEffectLease.AddPetal(item.Item1, item.Item2);
			}
			leases.Add(root, breadEffectLease);
		}

		public void Dispose()
		{
			if (disposed)
			{
				return;
			}
			disposed = true;
			colors?.Dispose();
			colors = null;
			VehicleSeat.onPassengerEnterGlobal -= Enter;
			VehicleSeat.onPassengerExitGlobal -= Exit;
			ReleaseVehicle();
			foreach (BreadEffectLease value in leases.Values)
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					value.Dispose();
				}
			}
			leases.Clear();
		}
	}
	public sealed class BreadEffectLease : MonoBehaviour, IDisposable
	{
		private readonly Dictionary<Renderer, bool> borrowed = new Dictionary<Renderer, bool>();

		private readonly List<GameObject> created = new List<GameObject>();

		private readonly List<Tuple<Transform, Transform, Transform>> petals = new List<Tuple<Transform, Transform, Transform>>();

		public bool Spin;

		private float angle;

		public bool Disposed { get; private set; }

		internal void Initialize(IEnumerable<Renderer> renderers)
		{
			foreach (Renderer renderer in renderers)
			{
				if (Object.op_Implicit((Object)(object)renderer) && !borrowed.ContainsKey(renderer))
				{
					borrowed.Add(renderer, renderer.enabled);
				}
			}
		}

		internal GameObject AddShape(string shape, float scale, Vector3 offset)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Breaditation.Shapes.Attach(((Component)this).transform, shape, scale, offset);
			created.Add(val);
			return val;
		}

		internal void AddPetal(Transform a, Transform b)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Breaditation.Shapes.Attach(a, "loaf", 1f, Vector3.zero);
			created.Add(val);
			petals.Add(Tuple.Create<Transform, Transform, Transform>(a, b, val.transform));
		}

		private void LateUpdate()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_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_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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			if (Disposed)
			{
				return;
			}
			foreach (KeyValuePair<Renderer, bool> item4 in borrowed)
			{
				if (Object.op_Implicit((Object)(object)item4.Key))
				{
					item4.Key.enabled = false;
				}
			}
			foreach (Tuple<Transform, Transform, Transform> petal in petals)
			{
				Transform item = petal.Item1;
				Transform item2 = petal.Item2;
				Transform item3 = petal.Item3;
				if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item2) && Object.op_Implicit((Object)(object)item3))
				{
					Vector3 val = item.InverseTransformPoint(item2.position);
					float magnitude = ((Vector3)(ref val)).magnitude;
					if (!(magnitude < 0.0001f))
					{
						item3.localPosition = val * 0.5f;
						item3.localRotation = Quaternion.FromToRotation(Vector3.forward, val / magnitude);
						item3.localScale = new Vector3(magnitude * 0.75f, magnitude * 0.75f, magnitude / 0.7f);
					}
				}
			}
			if (!Spin)
			{
				return;
			}
			angle = (angle + 35f * Time.deltaTime) % 360f;
			foreach (GameObject item5 in created)
			{
				if (Object.op_Implicit((Object)(object)item5))
				{
					item5.transform.localRotation = Quaternion.AngleAxis(angle, Vector3.forward);
				}
			}
		}

		public void Dispose()
		{
			if (Disposed)
			{
				return;
			}
			Disposed = true;
			foreach (KeyValuePair<Renderer, bool> item in borrowed)
			{
				if (Object.op_Implicit((Object)(object)item.Key) && !item.Key.enabled)
				{
					item.Key.enabled = item.Value;
				}
			}
			borrowed.Clear();
			foreach (GameObject item2 in created)
			{
				if (Object.op_Implicit((Object)(object)item2))
				{
					Object.Destroy((Object)(object)item2);
				}
			}
			created.Clear();
			petals.Clear();
			Object.Destroy((Object)(object)this);
		}

		private void OnDisable()
		{
			Dispose();
		}

		private void OnDestroy()
		{
			Dispose();
		}
	}
	internal sealed class BreadShapeBank : IDisposable
	{
		private readonly Dictionary<string, Mesh> shapes = new Dictionary<string, Mesh>();

		internal readonly Material Material;

		internal BreadShapeBank(string file, Material material)
		{
			//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_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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			Material = material;
			try
			{
				using BinaryReader binaryReader = new BinaryReader(File.OpenRead(file));
				if (new string(binaryReader.ReadChars(4)) != "BFX1")
				{
					throw new InvalidDataException("Bread effects signature");
				}
				int num = binaryReader.ReadInt32();
				if (num < 1 || num > 16)
				{
					throw new InvalidDataException("Bread effects count");
				}
				for (int i = 0; i < num; i++)
				{
					int num2 = binaryReader.ReadInt32();
					if (num2 < 1 || num2 > 64)
					{
						throw new InvalidDataException("Bread effect name");
					}
					string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(num2));
					int num3 = binaryReader.ReadInt32();
					int num4 = binaryReader.ReadInt32();
					if (num3 < 3 || num3 > 100000 || num4 < 3 || num4 > 300000 || num4 % 3 != 0)
					{
						throw new InvalidDataException("Bread effect dimensions");
					}
					Vector3[] array = (Vector3[])(object)new Vector3[num3];
					Vector3[] array2 = (Vector3[])(object)new Vector3[num3];
					Vector2[] array3 = (Vector2[])(object)new Vector2[num3];
					for (int j = 0; j < num3; j++)
					{
						array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
						array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
						array3[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
						if (!Finite(array[j]) || !Finite(array2[j]) || !Finite(array3[j].x) || !Finite(array3[j].y) || ((Vector3)(ref array[j])).sqrMagnitude > 100f || ((Vector3)(ref array2[j])).sqrMagnitude < 0.9f || ((Vector3)(ref array2[j])).sqrMagnitude > 1.1f)
						{
							throw new InvalidDataException("Bread effect vertex");
						}
					}
					int[] array4 = new int[num4];
					for (int k = 0; k < num4; k++)
					{
						array4[k] = binaryReader.ReadInt32();
						if (array4[k] < 0 || array4[k] >= num3)
						{
							throw new InvalidDataException("Bread effect triangle");
						}
					}
					if (shapes.ContainsKey(text))
					{
						throw new InvalidDataException("Duplicate bread effect");
					}
					Mesh val = new Mesh
					{
						name = "Breaditation_" + text,
						indexFormat = (IndexFormat)(num3 > 65535)
					};
					shapes.Add(text, val);
					val.vertices = array;
					val.normals = array2;
					val.uv = array3;
					val.triangles = array4;
					val.RecalculateBounds();
					val.RecalculateTangents();
				}
				if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
				{
					throw new InvalidDataException("Trailing bread effect bytes");
				}
			}
			catch
			{
				Dispose();
				throw;
			}
		}

		internal Mesh Get(string name)
		{
			return shapes[name];
		}

		internal GameObject Attach(Transform parent, string shape, float scale, Vector3 offset)
		{
			//IL_000b: 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_001d: 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_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0075: Expected O, but got Unknown
			GameObject val = new GameObject("Breaditation_" + shape);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = offset;
			val.transform.localScale = Vector3.one * scale;
			val.layer = ((Component)parent).gameObject.layer;
			val.AddComponent<MeshFilter>().sharedMesh = Get(shape);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = Material;
			return val;
		}

		private static bool Finite(float f)
		{
			if (!float.IsNaN(f))
			{
				return !float.IsInfinity(f);
			}
			return false;
		}

		private static bool Finite(Vector3 v)
		{
			//IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references)