Decompiled source of CardCrunch v0.7.3

Mods/CardCrunch.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.UI;
using CardCrunch;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Input;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Utilities;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VFX;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(CardCrunchMod), "CardCrunch", "0.7.1", "CardCrunch", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CardCrunch
{
	internal sealed class CaptureEffect : IDisposable
	{
		private const float CrunchDuration = 0.64f;

		private readonly Action<string> _report;

		private CrunchEnergyVisual? _visual;

		private Material? _material;

		private Transform? _card;

		private Vector3 _fromCenter;

		private Vector3 _fromExtents;

		private Vector3 _endExtents;

		private Quaternion _fromRotation;

		private float _startedAt;

		private bool _contracting;

		private bool _failed;

		private bool _disposed;

		internal CaptureEffect(Action<string> report)
		{
			_report = report;
		}

		internal void BeginFrame(float now)
		{
			if (_disposed || _failed)
			{
				return;
			}
			try
			{
				_visual?.Hide();
				if (!_contracting)
				{
					return;
				}
				if (!float.IsFinite(now) || now < _startedAt || !Object.op_Implicit((Object)(object)_card) || !((Component)_card).gameObject.activeInHierarchy)
				{
					Cancel();
					return;
				}
				float num = (now - _startedAt) / 0.64f;
				if (num >= 1f)
				{
					Cancel();
				}
				else
				{
					DrawCrunch(Math.Clamp(num, 0f, 1f));
				}
			}
			catch (Exception exception)
			{
				Fail(exception);
			}
		}

		internal void ShowHold(StoredProp prop, float progress)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (_disposed || _failed || _contracting || !Object.op_Implicit((Object)(object)prop.Root) || !float.IsFinite(progress) || progress <= 0f)
			{
				return;
			}
			try
			{
				EnsureReady();
				progress = Math.Clamp(progress, 0f, 1f);
				Transform transform = prop.Root.transform;
				Vector3 center = transform.position + transform.rotation * prop.LocalCenter;
				Vector3 halfExtents = prop.HalfExtents + Vector3.one * 0.035f;
				_visual.Draw(center, transform.rotation, halfExtents, CrunchEnergyVisual.Phase.Gathering, progress, Time.unscaledTime, progress, Math.Clamp(progress * 4f, 0f, 1f));
			}
			catch (Exception exception)
			{
				Fail(exception);
			}
		}

		internal void Crunch(StoredProp prop, Transform card, Vector3 physicalSize, float now)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || _failed)
			{
				return;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)card) && float.IsFinite(now))
				{
					EnsureReady();
					_fromCenter = prop.OriginalPosition + prop.StoredRotation * prop.LocalCenter;
					_fromRotation = prop.StoredRotation;
					_fromExtents = prop.HalfExtents + Vector3.one * 0.035f;
					_card = card;
					_endExtents = physicalSize * 0.5f + Vector3.one * 0.006f;
					_startedAt = now;
					_contracting = true;
					DrawCrunch(0f);
				}
			}
			catch (Exception exception)
			{
				Fail(exception);
			}
		}

		private void DrawCrunch(float phase)
		{
			//IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_card))
			{
				Cancel();
				return;
			}
			float num = Math.Clamp((phase - 0.08f) / 0.82f, 0f, 1f);
			float num2 = num * num * (3f - 2f * num);
			Vector3 center = Vector3.Lerp(_fromCenter, _card.position, num2);
			Quaternion val = Quaternion.Slerp(_fromRotation, _card.rotation, num2);
			float num3 = (float)Math.Sin((double)phase * Math.PI) * 24f;
			val *= Quaternion.Euler(num3 * 0.32f, num3, (0f - num3) * 0.45f);
			Vector3 halfExtents = Vector3.Lerp(_fromExtents, _endExtents, num2);
			float fade = 1f - Math.Clamp((phase - 0.8f) / 0.2f, 0f, 1f);
			_visual.Draw(center, val, halfExtents, CrunchEnergyVisual.Phase.Compressing, phase, _startedAt + phase * 0.64f * 1.8f, 1f, fade);
		}

		private void EnsureReady()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			CrunchEnergyVisual? visual = _visual;
			if (visual == null || !visual.Alive || !Object.op_Implicit((Object)(object)_material))
			{
				DestroyAssets();
				Shader val = Shader.Find("Sprites/Default");
				if (!Object.op_Implicit((Object)(object)val))
				{
					throw new InvalidOperationException("The capture energy shader is unavailable.");
				}
				_material = new Material(val)
				{
					name = "CardCrunch capture energy",
					color = Color.white
				};
				_visual = new CrunchEnergyVisual("CardCrunch Capture Energy", _material);
			}
		}

		internal void Cancel()
		{
			_contracting = false;
			_card = null;
			_visual?.Hide();
		}

		private void Fail(Exception exception)
		{
			_failed = true;
			try
			{
				Cancel();
			}
			catch
			{
			}
			try
			{
				_report("Capture animation unavailable: " + exception.GetType().Name + ". Object storage remains usable.");
			}
			catch
			{
			}
		}

		private void DestroyAssets()
		{
			_visual?.Dispose();
			_visual = null;
			try
			{
				if (Object.op_Implicit((Object)(object)_material))
				{
					Object.Destroy((Object)(object)_material);
				}
			}
			catch
			{
			}
			_material = null;
		}

		public void Dispose()
		{
			if (_disposed)
			{
				return;
			}
			_disposed = true;
			try
			{
				Cancel();
			}
			finally
			{
				DestroyAssets();
			}
		}
	}
	public sealed class CardCrunchMod : MelonMod
	{
		private PocketRuntime? _runtime;

		private CardCrunchSettings? _settings;

		private bool _menuBuilt;

		private float _nextMenu;

		private float _nextWarning;

		private int _pending;

		private readonly SoloSession _session = new SoloSession();

		public override void OnInitializeMelon()
		{
			_settings = new CardCrunchSettings();
			((MelonBase)this).LoggerInstance.Msg("CardCrunch 0.7.1: hold your empty right hand's TRIGGER to crunch. Grab or force-pull; holster, or drop/throw onto clear floor to unfold. Smaller 10 cm blue cubes with visibly swirling clouds and one floating object name. BoneMenu: Megamind-style Cubes and Unfold Sound. Up to 8 objects. Desktop: hold F8. No weight or size cap. Solo, current level.");
		}

		public override void OnUpdate()
		{
			try
			{
				float unscaledTime = Time.unscaledTime;
				EnsureMenu(unscaledTime);
				Transform head = Player.Head;
				RigManager rigManager = Player.RigManager;
				OpenControllerRig controllerRig = Player.ControllerRig;
				UIRig uIRig = Player.UIRig;
				GUIMenu instance = GUIMenu.Instance;
				if ((Object)(object)head == (Object)null || (Object)(object)rigManager == (Object)null || (Object)(object)controllerRig == (Object)null || ((ControllerRig)controllerRig).IsPaused || ((Object)(object)uIRig != (Object)null && (Object)(object)uIRig.popUpMenu != (Object)null && uIRig.popUpMenu.isActive) || ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy))
				{
					_runtime?.Suspend();
					return;
				}
				if (!_session.AllowsActions(unscaledTime))
				{
					_runtime?.Suspend();
					if (_pending != 0)
					{
						_pending = 0;
						Report("CardCrunch currently works in solo play. Leave the Fusion session first.");
					}
					return;
				}
				if (_runtime == null)
				{
					_runtime = new PocketRuntime(Report);
				}
				_runtime.CubeMode = _settings?.CubeMode ?? false;
				_runtime.UnfoldSound = _settings?.UnfoldSound ?? true;
				_runtime.Bind(head, ((Component)rigManager).transform);
				if (_pending != 0)
				{
					int pending = _pending;
					_pending = 0;
					if (pending == 1)
					{
						_runtime.CreateTestCrate();
					}
					if (pending == 2)
					{
						_runtime.RecoverCard();
					}
					if (pending == 3)
					{
						_runtime.ShowHelp();
					}
				}
				BaseController rightController = Player.RightController;
				XRApi xr = MarrowGame.xr;
				XRController val = ((xr != null) ? xr.RightController : null);
				bool flag = (Object)(object)rightController != (Object)null && ((Behaviour)rightController).isActiveAndEnabled && val != null && ((XRDevice)val).IsConnected;
				Transform aim = (flag ? ((Component)rightController).transform : head);
				bool pressed = ((!flag) ? Input.GetKey((KeyCode)289) : (val.TriggerButton || val.Trigger >= 0.7f));
				bool handAvailable = !flag || (Player.HandsExist && !Player.RightHand.HasAttachedObject());
				_runtime.Tick(unscaledTime, aim, pressed, handAvailable, flag);
			}
			catch (Exception ex)
			{
				_runtime?.Suspend();
				if (Time.unscaledTime >= _nextWarning)
				{
					_nextWarning = Time.unscaledTime + 5f;
					Report("CardCrunch paused this interaction: " + ex.GetType().Name);
				}
			}
		}

		private void EnsureMenu(float now)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (_menuBuilt || now < _nextMenu)
			{
				return;
			}
			_nextMenu = now + 2f;
			if (Page.Root != null && _settings != null)
			{
				Page obj = Page.Root.CreatePage("CardCrunch", new Color(0.2f, 0.9f, 0.8f), 0, true);
				obj.CreateFunction("Controls: trigger, grab, drop", Color.cyan, (Action)delegate
				{
					_pending = 3;
				});
				obj.CreateFunction("Recover Lost Card", Color.white, (Action)delegate
				{
					_pending = 2;
				});
				obj.CreateFunction("Spawn Practice Crate", Color.yellow, (Action)delegate
				{
					_pending = 1;
				});
				obj.CreateBool("Megamind-style Cubes", Color.cyan, _settings.CubeMode, (Action<bool>)delegate(bool value)
				{
					_settings.CubeMode = value;
				});
				obj.CreateBool("Unfold Sound", Color.cyan, _settings.UnfoldSound, (Action<bool>)delegate(bool value)
				{
					_settings.UnfoldSound = value;
				});
				_menuBuilt = true;
			}
		}

		public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			_runtime?.SceneUnloaded(sceneName);
		}

		public override void OnDeinitializeMelon()
		{
			_runtime?.Dispose();
			_runtime = null;
		}

		private void Report(string message)
		{
			((MelonBase)this).LoggerInstance.Msg(message);
		}
	}
	internal sealed class CardCrunchSettings
	{
		private readonly MelonPreferences_Category _category;

		private readonly MelonPreferences_Entry<bool> _cubeMode;

		private readonly MelonPreferences_Entry<bool> _unfoldSound;

		internal bool CubeMode
		{
			get
			{
				return _cubeMode.Value;
			}
			set
			{
				_cubeMode.Value = value;
				_category.SaveToFile(false);
			}
		}

		internal bool UnfoldSound
		{
			get
			{
				return _unfoldSound.Value;
			}
			set
			{
				_unfoldSound.Value = value;
				_category.SaveToFile(false);
			}
		}

		internal CardCrunchSettings()
		{
			_category = MelonPreferences.CreateCategory("CardCrunch");
			_cubeMode = _category.CreateEntry<bool>("CubeMode", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_unfoldSound = _category.CreateEntry<bool>("UnfoldSound", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}
	}
	internal interface ICardSlot
	{
		int OriginalId { get; }

		bool Finished { get; }

		bool IsHeld { get; }

		bool NeedsRecovery { get; }
	}
	internal sealed class CardSlots<T> where T : class, ICardSlot
	{
		internal const int Capacity = 8;

		private readonly List<T> _items = new List<T>(8);

		private readonly List<long> _sequence = new List<long>(8);

		private long _nextSequence;

		private long _recallCursor = long.MaxValue;

		internal int Count => _items.Count;

		internal bool HasCapacity => Count < 8;

		internal T this[int index] => _items[index];

		internal bool TryAdd(T item, out string reason)
		{
			reason = string.Empty;
			if (item.Finished || item.OriginalId == 0)
			{
				reason = "That original object is no longer available.";
				return false;
			}
			foreach (T item2 in _items)
			{
				if (item2.OriginalId == item.OriginalId)
				{
					reason = "That object already has a storage card.";
					return false;
				}
			}
			if (!HasCapacity)
			{
				reason = "All 8 card slots are occupied. Unfold a card to free a slot.";
				return false;
			}
			_items.Add(item);
			_sequence.Add(++_nextSequence);
			return true;
		}

		internal bool Remove(T item)
		{
			int num = _items.IndexOf(item);
			if (num < 0)
			{
				return false;
			}
			_items.RemoveAt(num);
			_sequence.RemoveAt(num);
			return true;
		}

		internal T? SelectRecovery()
		{
			for (int num = Count - 1; num >= 0; num--)
			{
				if (!_items[num].Finished && !_items[num].IsHeld && _items[num].NeedsRecovery)
				{
					return Select(num);
				}
			}
			for (int num2 = Count - 1; num2 >= 0; num2--)
			{
				if (_sequence[num2] < _recallCursor && !_items[num2].Finished && !_items[num2].IsHeld)
				{
					return Select(num2);
				}
			}
			for (int num3 = Count - 1; num3 >= 0; num3--)
			{
				if (!_items[num3].Finished && !_items[num3].IsHeld)
				{
					return Select(num3);
				}
			}
			return null;
		}

		private T Select(int index)
		{
			_recallCursor = _sequence[index];
			return _items[index];
		}
	}
	internal sealed class CrunchEnergyVisual : IDisposable
	{
		internal enum Phase
		{
			Gathering,
			Compressing,
			Expanding
		}

		private sealed class MeshDraw : IDisposable
		{
			private readonly Mesh _mesh;

			private readonly MeshRenderer _renderer;

			private readonly Il2CppStructArray<Vector3> _vertices;

			private readonly Il2CppStructArray<Color> _colors;

			private int _cursor;

			internal MeshDraw(Transform parent, string name, Material material, int triangles)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				GameObject val = new GameObject("CardCrunch " + name)
				{
					layer = 2
				};
				val.transform.SetParent(parent, false);
				_mesh = new Mesh
				{
					name = "CardCrunch " + name
				};
				try
				{
					_vertices = new Il2CppStructArray<Vector3>((long)(triangles * 3));
					_colors = new Il2CppStructArray<Color>((long)(triangles * 3));
					Il2CppStructArray<int> val2 = new Il2CppStructArray<int>((long)(triangles * 3));
					for (int i = 0; i < ((Il2CppArrayBase<int>)(object)val2).Length; i++)
					{
						((Il2CppArrayBase<int>)(object)val2)[i] = i;
					}
					_mesh.MarkDynamic();
					_mesh.vertices = _vertices;
					_mesh.colors = _colors;
					_mesh.triangles = val2;
					val.AddComponent<MeshFilter>().sharedMesh = _mesh;
					_renderer = val.AddComponent<MeshRenderer>();
					((Renderer)_renderer).sharedMaterial = material;
					((Renderer)_renderer).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)_renderer).receiveShadows = false;
					((Renderer)_renderer).lightProbeUsage = (LightProbeUsage)0;
					((Renderer)_renderer).reflectionProbeUsage = (ReflectionProbeUsage)0;
					((Renderer)_renderer).enabled = false;
				}
				catch
				{
					DestroyOwned((Object?)(object)_mesh);
					DestroyOwned((Object?)(object)val);
					throw;
				}
			}

			internal void Begin()
			{
				_cursor = 0;
			}

			internal void Triangle(Vector3 a, Vector3 b, Vector3 c, Color ca, Color cb, Color cc)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				if (_cursor + 3 > ((Il2CppArrayBase<Vector3>)(object)_vertices).Length)
				{
					throw new InvalidOperationException("Energy mesh budget exceeded.");
				}
				((Il2CppArrayBase<Vector3>)(object)_vertices)[_cursor] = a;
				((Il2CppArrayBase<Color>)(object)_colors)[_cursor++] = ca;
				((Il2CppArrayBase<Vector3>)(object)_vertices)[_cursor] = b;
				((Il2CppArrayBase<Color>)(object)_colors)[_cursor++] = cb;
				((Il2CppArrayBase<Vector3>)(object)_vertices)[_cursor] = c;
				((Il2CppArrayBase<Color>)(object)_colors)[_cursor++] = cc;
			}

			internal void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Color ca, Color cb, Color cc, Color cd)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: 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_0008: 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_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				Triangle(a, b, c, ca, cb, cc);
				Triangle(a, c, d, ca, cc, cd);
			}

			internal void Commit()
			{
				if (_cursor != ((Il2CppArrayBase<Vector3>)(object)_vertices).Length)
				{
					throw new InvalidOperationException("Energy mesh was not completely filled.");
				}
				_mesh.vertices = _vertices;
				_mesh.colors = _colors;
				_mesh.RecalculateBounds();
				((Renderer)_renderer).enabled = true;
			}

			internal void Hide()
			{
				try
				{
					if (Object.op_Implicit((Object)(object)_renderer))
					{
						((Renderer)_renderer).enabled = false;
					}
				}
				catch
				{
				}
			}

			public void Dispose()
			{
				Hide();
				DestroyOwned((Object?)(object)_mesh);
			}
		}

		private const int ArcSegments = 24;

		private readonly GameObject _root;

		private MeshDraw? _solid;

		private MeshDraw? _energy;

		private bool _disposed;

		private static readonly Vector2[] PanelCorners = (Vector2[])(object)new Vector2[8]
		{
			new Vector2(-0.78f, -1f),
			new Vector2(0.78f, -1f),
			new Vector2(1f, -0.78f),
			new Vector2(1f, 0.78f),
			new Vector2(0.78f, 1f),
			new Vector2(-0.78f, 1f),
			new Vector2(-1f, 0.78f),
			new Vector2(-1f, -0.78f)
		};

		internal bool Alive
		{
			get
			{
				if (!_disposed)
				{
					return Object.op_Implicit((Object)(object)_root);
				}
				return false;
			}
		}

		internal CrunchEnergyVisual(string name, Material material, Transform? parent = null)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			_root = new GameObject(name)
			{
				layer = 2
			};
			try
			{
				if (Object.op_Implicit((Object)(object)parent))
				{
					_root.transform.SetParent(parent, false);
				}
				_solid = new MeshDraw(_root.transform, "Faceted compression shell", material, 240);
				_energy = new MeshDraw(_root.transform, "Dimensional ribbons and sparks", material, 288);
			}
			catch
			{
				Dispose();
				throw;
			}
		}

		internal void Draw(Vector3 center, Quaternion rotation, Vector3 halfExtents, Phase mode, float progress, float orbitTime, float intensity, float fade)
		{
			//IL_0008: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			if (!Alive || !Finite(center) || !Finite(rotation) || !Finite(halfExtents) || !float.IsFinite(progress) || !float.IsFinite(orbitTime) || !float.IsFinite(intensity) || !float.IsFinite(fade) || halfExtents.x <= 0f || halfExtents.y <= 0f || halfExtents.z <= 0f)
			{
				Hide();
				return;
			}
			_root.transform.SetPositionAndRotation(center, rotation);
			progress = Math.Clamp(progress, 0f, 1f);
			intensity = Math.Clamp(intensity, 0f, 1f);
			fade = Math.Clamp(fade, 0f, 1f);
			_solid.Begin();
			_energy.Begin();
			float size = Math.Clamp(Math.Max(halfExtents.x, Math.Max(halfExtents.y, halfExtents.z)), 0.075f, 1.8f);
			DrawPanels(halfExtents, mode, progress, intensity, fade, size);
			DrawCrystals(halfExtents, mode, progress, orbitTime, intensity, fade, size);
			DrawRibbons(halfExtents, mode, progress, orbitTime, intensity, fade, size);
			DrawSparks(halfExtents, mode, progress, orbitTime, intensity, fade, size);
			_solid.Commit();
			_energy.Commit();
		}

		private void DrawPanels(Vector3 half, Phase mode, float progress, float intensity, float fade, float size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			Color ca = default(Color);
			Color val9 = default(Color);
			Color val10 = default(Color);
			Color val11 = default(Color);
			for (int i = 0; i < 6; i++)
			{
				Face(i, half, out var normal, out var u, out var v, out var radius, out var width, out var height);
				float num = Math.Clamp(progress * 1.18f - (float)i * 0.027f, 0f, 1f);
				float num2;
				float num3;
				switch (mode)
				{
				case Phase.Gathering:
					num2 = (1f - num) * 0.82f;
					num3 = (0.05f + (1f - progress) * 0.17f) * size;
					break;
				case Phase.Compressing:
					num2 = (float)Math.Sin((double)num * Math.PI) * -0.76f;
					num3 = 0.055f * size * (1f - progress);
					break;
				default:
					num2 = num * 1.1f;
					num3 = (0.04f + num * 0.27f) * size;
					break;
				}
				float num4 = (float)Math.Cos(num2);
				float num5 = (float)Math.Sin(num2);
				Vector3 val = v * num4 + normal * num5;
				Vector3 val2 = normal * num4 - v * num5;
				width *= 0.94f;
				height *= 0.94f;
				Vector3 val3 = normal * (radius + num3) - v * height + val * height;
				Vector3 a = val3 + val2 * (0.024f * size);
				float num6 = fade * (0.34f + 0.66f * intensity);
				((Color)(ref ca))..ctor(0.08f, 0.43f, 1f, num6 * 0.16f);
				for (int j = 0; j < PanelCorners.Length; j++)
				{
					Vector2 val4 = PanelCorners[j];
					Vector2 val5 = PanelCorners[(j + 1) % PanelCorners.Length];
					Vector3 val6 = val3 + u * (val4.x * width) + val * (val4.y * height);
					Vector3 val7 = val3 + u * (val5.x * width) + val * (val5.y * height);
					Vector3 val8 = val3 + (val6 - val3) * 0.945f;
					Vector3 c = val3 + (val7 - val3) * 0.945f;
					float num7 = 0.65f + 0.35f * (float)((j + i) % 3) / 2f;
					((Color)(ref val9))..ctor(0.1f, 0.58f * num7, 1f, num6 * (0.095f + 0.055f * num7));
					_solid.Triangle(a, val8, c, ca, val9, val9);
					((Color)(ref val10))..ctor(0.2f + 0.35f * num7, 0.72f + 0.24f * num7, 1f, num6 * (0.6f + 0.3f * num7));
					((Color)(ref val11))..ctor(0.08f, 0.38f, 0.92f, num6 * 0.28f);
					_solid.Quad(val6, val7, c, val8, val10, val10, val11, val11);
				}
			}
		}

		private void DrawCrystals(Vector3 half, Phase mode, float progress, float time, float intensity, float fade, float size)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0091: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			float num = ((mode == Phase.Expanding) ? (-1f) : 1f);
			Vector3 normalized = default(Vector3);
			Color tipColor = default(Color);
			Color bodyColor = default(Color);
			for (int i = 0; i < 12; i++)
			{
				float num2 = (float)i * 2.3999631f + time * num * (1.8f + (float)(i % 3) * 0.25f);
				float num3 = -0.85f + (float)i / 11f * 1.7f;
				((Vector3)(ref normalized))..ctor((float)Math.Cos(num2), num3, (float)Math.Sin(num2));
				normalized = ((Vector3)(ref normalized)).normalized;
				float num4 = ((mode == Phase.Expanding) ? (1f + progress * 0.48f) : 1.17f);
				Vector3 center = Vector3.Scale(normalized, half) * num4 + normalized * (0.1f * size);
				Vector3 val = normalized + new Vector3((float)Math.Sin(num2), 0.45f, 0f - (float)Math.Cos(num2));
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				float num5 = Math.Clamp(size * (0.065f + (float)(i % 3) * 0.015f), 0.006f, 0.15f);
				float num6 = fade * (0.45f + intensity * 0.4f);
				((Color)(ref tipColor))..ctor(0.72f, 0.96f, 1f, num6);
				((Color)(ref bodyColor))..ctor(0.045f, 0.34f + (float)(i % 3) * 0.12f, 1f, num6 * 0.72f);
				Diamond(_solid, center, normalized2, num5, num5 * 0.34f, tipColor, bodyColor);
			}
		}

		private void DrawRibbons(Vector3 half, Phase mode, float progress, float time, float intensity, float fade, float size)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			float num = time * ((mode == Phase.Expanding) ? (-3.8f) : (3.2f + intensity * 2.5f));
			float num2 = ((mode == Phase.Expanding) ? (1.06f + 0.45f * progress) : 1.1f);
			float num3 = Math.Clamp(size * 0.013f, 0.0016f, 0.024f);
			Color val6 = default(Color);
			Color val7 = default(Color);
			for (int i = 0; i < 3; i++)
			{
				Quaternion val = Quaternion.Euler((float)i * 57f + 28f, (float)i * 74f, (float)i * 36f + 12f);
				for (int j = 0; j < 24; j++)
				{
					float num4 = (float)j / 24f;
					float num5 = ((float)j + 1f) / 24f;
					float num6 = num + (float)i * 2.094395f + num4 * 4.8f;
					float num7 = num + (float)i * 2.094395f + num5 * 4.8f;
					Vector3 val2 = val * new Vector3((float)Math.Cos(num6), 0f, (float)Math.Sin(num6));
					Vector3 val3 = val * new Vector3((float)Math.Cos(num7), 0f, (float)Math.Sin(num7));
					Vector3 val4 = Vector3.Scale(val2, half) * num2 + val2 * (0.075f * size);
					Vector3 val5 = Vector3.Scale(val3, half) * num2 + val3 * (0.075f * size);
					float num8 = (float)Math.Sin((double)num4 * Math.PI) * fade * (0.45f + 0.5f * intensity);
					float num9 = (float)Math.Sin((double)num5 * Math.PI) * fade * (0.45f + 0.5f * intensity);
					((Color)(ref val6))..ctor(0.27f + num4 * 0.56f, 0.76f + num4 * 0.22f, 1f, num8);
					((Color)(ref val7))..ctor(0.27f + num5 * 0.56f, 0.76f + num5 * 0.22f, 1f, num9);
					_energy.Quad(val4 - val2 * num3, val5 - val3 * num3, val5 + val3 * num3, val4 + val2 * num3, val6, val7, val7, val6);
				}
			}
		}

		private void DrawSparks(Vector3 half, Phase mode, float progress, float time, float intensity, float fade, float size)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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)
			Vector3 normalized = default(Vector3);
			for (int i = 0; i < 18; i++)
			{
				float num = (float)i * 2.3999631f;
				float num2 = -0.94f + (float)i / 17f * 1.88f;
				((Vector3)(ref normalized))..ctor((float)Math.Cos(num), num2, (float)Math.Sin(num));
				normalized = ((Vector3)(ref normalized)).normalized;
				float num3 = Frac(time * 0.9f + (float)i * 0.381966f);
				float num4 = ((mode == Phase.Expanding) ? (1.02f + progress * 0.72f + num3 * 0.15f) : (1.5f - num3 * 0.48f));
				Vector3 center = Vector3.Scale(normalized, half) * num4 + normalized * (0.055f * size);
				float num5 = (float)Math.Sin((double)num3 * Math.PI);
				float num6 = fade * num5 * (0.25f + 0.65f * intensity);
				float num7 = Math.Clamp(size * (0.025f + num3 * 0.045f), 0.004f, 0.085f);
				Diamond(_energy, center, normalized, num7, num7 * 0.12f, new Color(0.86f, 0.98f, 1f, num6), new Color(0.18f, 0.69f, 1f, num6 * 0.58f));
			}
		}

		private static void Diamond(MeshDraw draw, Vector3 center, Vector3 axis, float length, float width, Color tipColor, Color bodyColor)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_0098: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(axis, (Math.Abs(axis.y) < 0.9f) ? Vector3.up : Vector3.right);
			Vector3 val2 = ((Vector3)(ref val)).normalized * width;
			val = Vector3.Cross(axis, val2);
			Vector3 val3 = ((Vector3)(ref val)).normalized * width;
			Vector3 a = center + axis * length;
			Vector3 a2 = center - axis * length;
			draw.Triangle(a, center + val2, center + val3, tipColor, bodyColor, bodyColor);
			draw.Triangle(a, center + val3, center - val2, tipColor, bodyColor, bodyColor);
			draw.Triangle(a, center - val2, center - val3, tipColor, bodyColor, bodyColor);
			draw.Triangle(a, center - val3, center + val2, tipColor, bodyColor, bodyColor);
			draw.Triangle(a2, center + val3, center + val2, bodyColor, bodyColor, tipColor);
			draw.Triangle(a2, center - val2, center + val3, bodyColor, bodyColor, tipColor);
			draw.Triangle(a2, center - val3, center - val2, bodyColor, bodyColor, tipColor);
			draw.Triangle(a2, center + val2, center - val3, bodyColor, bodyColor, tipColor);
		}

		private static void Face(int index, Vector3 half, out Vector3 normal, out Vector3 u, out Vector3 v, out float radius, out float width, out float height)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			float num = ((index % 2 == 0) ? 1f : (-1f));
			if (index < 2)
			{
				normal = Vector3.right * num;
				u = Vector3.forward * (0f - num);
				v = Vector3.up;
				radius = half.x;
				width = half.z;
				height = half.y;
			}
			else if (index < 4)
			{
				normal = Vector3.up * num;
				u = Vector3.right;
				v = Vector3.forward * (0f - num);
				radius = half.y;
				width = half.x;
				height = half.z;
			}
			else
			{
				normal = Vector3.forward * num;
				u = Vector3.right * num;
				v = Vector3.up;
				radius = half.z;
				width = half.x;
				height = half.y;
			}
		}

		internal void Hide()
		{
			_solid?.Hide();
			_energy?.Hide();
		}

		private static float Frac(float value)
		{
			return value - (float)Math.Floor(value);
		}

		private static bool Finite(Vector3 value)
		{
			//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)
			if (float.IsFinite(value.x) && float.IsFinite(value.y))
			{
				return float.IsFinite(value.z);
			}
			return false;
		}

		private static bool Finite(Quaternion value)
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (float.IsFinite(value.x) && float.IsFinite(value.y) && float.IsFinite(value.z))
			{
				return float.IsFinite(value.w);
			}
			return false;
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				_disposed = true;
				_solid?.Dispose();
				_energy?.Dispose();
				DestroyOwned((Object?)(object)_root);
			}
		}

		private static void DestroyOwned(Object? value)
		{
			try
			{
				if (Object.op_Implicit(value))
				{
					Object.Destroy(value);
				}
			}
			catch
			{
			}
		}
	}
	internal static class CubeCloudMotion
	{
		internal static void Sample(float u, float v, float now, out float warpedU, out float warpedV)
		{
			warpedU = u;
			warpedV = v;
			if (float.IsFinite(u) && float.IsFinite(v) && float.IsFinite(now))
			{
				float value = Math.Min(Math.Min(u, 1f - u), Math.Min(v, 1f - v));
				float num = Smooth(0.07f, 0.24f, value) * Smooth(0.1f, 0.32f, v);
				if (!(num <= 0f))
				{
					double num2 = now;
					float num3 = u - 0.5f;
					float num4 = v - 0.5f;
					float num5 = MathF.Sqrt(num3 * num3 + num4 * num4);
					float x = num * (float)(0.55 * Math.Sin(num2 * 0.9 + (double)(num5 * 4f)) + 0.2 * Math.Cos(num2 * 0.57 - (double)(num5 * 3f)));
					float num6 = MathF.Cos(x);
					float num7 = MathF.Sin(x);
					warpedU = Math.Clamp(0.5f + num3 * num6 - num4 * num7 + num * 0.025f * (float)Math.Sin(num2 * 0.73 + (double)(v * 5f)), 0f, 1f);
					warpedV = Math.Clamp(0.5f + num3 * num7 + num4 * num6 + num * 0.025f * (float)Math.Cos(num2 * 0.61 + (double)(u * 5f)), 0f, 1f);
				}
			}
		}

		private static float Smooth(float from, float to, float value)
		{
			float num = Math.Clamp((value - from) / (to - from), 0f, 1f);
			return num * num * (3f - 2f * num);
		}
	}
	internal static class CubeCloudPattern
	{
		internal static byte[] BuildFace(int size, int face)
		{
			if (size < 2 || size > 512 || face < 0 || face > 5)
			{
				throw new ArgumentOutOfRangeException();
			}
			byte[] array = new byte[size * size * 4];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = (float)j / (float)(size - 1) * 2f - 1f;
					float num2 = (float)i / (float)(size - 1) * 2f - 1f;
					FacePoint(face, num, num2, out var x, out var y, out var z);
					float value = Density(x, y, z);
					float num3 = Smooth(-0.96f, 0.64f, y);
					float num4 = Smooth(0.3f, 0.76f, value);
					float num5 = 1f - Smooth(0.78f, 1f, MathF.Max(MathF.Abs(num), MathF.Abs(num2)));
					float num6 = (0.17f + 0.83f * num4) * (0.22f + 0.78f * num3);
					num6 *= 0.63f + 0.37f * num5;
					float num7;
					switch (face)
					{
					default:
						num7 = 1f;
						break;
					case 2:
					case 3:
						num7 = 0.86f;
						break;
					case 5:
						num7 = 0.67f;
						break;
					case 4:
						num7 = 1.1f;
						break;
					}
					float num8 = num7;
					num6 *= num8;
					float r = 0.004f + num6 * 0.095f;
					float g = 0.035f + num6 * 0.98f;
					float b = 0.085f + num6 * 1.08f;
					float a = 0.7f + 0.23f * (1f - num3) + 0.08f * (1f - num5);
					Write(array, (i * size + j) * 4, r, g, b, a);
				}
			}
			return array;
		}

		internal static byte[] BuildSlice(int size, float depth)
		{
			if (size < 2 || size > 512 || !float.IsFinite(depth) || MathF.Abs(depth) > 1f)
			{
				throw new ArgumentOutOfRangeException();
			}
			byte[] array = new byte[size * size * 4];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = (float)j / (float)(size - 1) * 2f - 1f;
					float num2 = (float)i / (float)(size - 1) * 2f - 1f;
					float value = num * num + num2 * num2;
					float num3 = 1f - Smooth(0.38f, 1f, value);
					float num4 = Smooth(0.3f, 0.8f, Density(num, num2, depth));
					float a = num3 * num4 * (0.36f - MathF.Abs(depth) * 0.09f);
					Write(array, (i * size + j) * 4, 0.055f + 0.11f * num4, 0.61f + 0.32f * num4, 1f, a);
				}
			}
			return array;
		}

		internal static void FacePoint(int face, float u, float v, out float x, out float y, out float z)
		{
			x = (y = (z = 0f));
			switch (face)
			{
			case 0:
				x = u;
				y = v;
				z = -1f;
				break;
			case 1:
				x = 0f - u;
				y = v;
				z = 1f;
				break;
			case 2:
				x = -1f;
				y = v;
				z = 0f - u;
				break;
			case 3:
				x = 1f;
				y = v;
				z = u;
				break;
			case 4:
				x = u;
				y = 1f;
				z = v;
				break;
			case 5:
				x = u;
				y = -1f;
				z = 0f - v;
				break;
			default:
				throw new ArgumentOutOfRangeException("face");
			}
		}

		private static float Density(float x, float y, float z)
		{
			float num = Fractal(x * 1.18f + 3.7f, y * 1.13f - 0.5f, z * 1.18f + 1.4f, 3);
			float num2 = Fractal(x * 1.31f - 4.2f, y * 1.12f + 2.6f, z * 1.31f - 3.1f, 3);
			float num3 = Fractal(x * 3.25f + num * 2.5f, y * 2f + num2 * 0.9f, z * 3.25f + num2 * 2.5f, 4);
			float num4 = Fractal(x * 6.2f + num2 * 4.5f, y * 2.7f + num * 1.3f, z * 6.2f + num * 4.5f, 2);
			return num3 * 0.79f + num4 * 0.21f;
		}

		private static float Fractal(float x, float y, float z, int octaves)
		{
			float num = 0f;
			float num2 = 0.57f;
			float num3 = 0f;
			for (int i = 0; i < octaves; i++)
			{
				num += Noise(x, y, z) * num2;
				num3 += num2;
				x = x * 2.03f + 1.7f;
				y = y * 2.01f - 2.1f;
				z = z * 2.07f + 0.6f;
				num2 *= 0.47f;
			}
			return num / num3;
		}

		private static float Noise(float x, float y, float z)
		{
			int num = (int)MathF.Floor(x);
			int num2 = (int)MathF.Floor(y);
			int num3 = (int)MathF.Floor(z);
			float t = Fade(x - (float)num);
			float t2 = Fade(y - (float)num2);
			float t3 = Fade(z - (float)num3);
			float a = Lerp(Lerp(Hash(num, num2, num3), Hash(num + 1, num2, num3), t), Lerp(Hash(num, num2 + 1, num3), Hash(num + 1, num2 + 1, num3), t), t2);
			float b = Lerp(Lerp(Hash(num, num2, num3 + 1), Hash(num + 1, num2, num3 + 1), t), Lerp(Hash(num, num2 + 1, num3 + 1), Hash(num + 1, num2 + 1, num3 + 1), t), t2);
			return Lerp(a, b, t3);
		}

		private static float Hash(int x, int y, int z)
		{
			int num = x * 374761393 + y * 668265263 + z * -2048144777 + 1103515245;
			int num2 = (num ^ (num >>> 13)) * 1274126177;
			return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFFFF) / 16777215f;
		}

		private static float Fade(float value)
		{
			return value * value * value * (value * (value * 6f - 15f) + 10f);
		}

		private static float Lerp(float a, float b, float t)
		{
			return a + (b - a) * t;
		}

		private static float Smooth(float a, float b, float value)
		{
			float num = Math.Clamp((value - a) / (b - a), 0f, 1f);
			return num * num * (3f - 2f * num);
		}

		private static void Write(byte[] pixels, int offset, float r, float g, float b, float a)
		{
			pixels[offset] = Channel(r);
			pixels[offset + 1] = Channel(g);
			pixels[offset + 2] = Channel(b);
			pixels[offset + 3] = Channel(a);
		}

		private static byte Channel(float value)
		{
			return (byte)(Math.Clamp(value, 0f, 1f) * 255f + 0.5f);
		}
	}
	internal sealed class CubeVisual : IDisposable
	{
		private sealed class CloudAssets
		{
			private static CloudAssets? _shared;

			private int _references;

			internal readonly Shader Shader;

			internal readonly Font Font;

			internal Mesh Quad;

			internal Mesh Surface;

			internal Mesh Bevel;

			private const int SurfaceSegments = 12;

			private Il2CppStructArray<Vector2>? _surfaceUv;

			private float _lastSurfaceUpdate = float.NegativeInfinity;

			internal Material BevelMaterial;

			internal readonly Material[] FaceMaterials = (Material[])(object)new Material[6];

			internal readonly Texture2D[] CloudTextures = (Texture2D[])(object)new Texture2D[5];

			private readonly Texture2D[] _faceTextures = (Texture2D[])(object)new Texture2D[6];

			private CloudAssets()
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Expected O, but got Unknown
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Expected O, but got Unknown
				Shader = Shader.Find("Sprites/Default");
				Font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				if (!Object.op_Implicit((Object)(object)Shader) || !Object.op_Implicit((Object)(object)Font))
				{
					throw new InvalidOperationException("Unity's transparent material or label font is unavailable.");
				}
				try
				{
					Quad = HologramCard.CreateQuad();
					Surface = CreateSurface();
					Bevel = CreateBevel();
					BevelMaterial = new Material(Shader)
					{
						name = "CardCrunch navy soft edges",
						color = Color.white,
						renderQueue = 3011
					};
					for (int i = 0; i < 6; i++)
					{
						_faceTextures[i] = Texture(CubeCloudPattern.BuildFace(192, i), 192, "CardCrunch continuous blue face " + i);
						FaceMaterials[i] = new Material(Shader)
						{
							name = "CardCrunch dense cyan face " + i,
							mainTexture = (Texture)(object)_faceTextures[i],
							color = Color.white,
							renderQueue = 3010
						};
					}
					for (int j = 0; j < 5; j++)
					{
						CloudTextures[j] = Texture(CubeCloudPattern.BuildSlice(128, 0.7f - (float)j * 0.35f), 128, "CardCrunch blue interior " + j);
					}
				}
				catch
				{
					DestroyAssets();
					throw;
				}
			}

			internal static CloudAssets Acquire()
			{
				CloudAssets? obj = _shared ?? (_shared = new CloudAssets());
				obj._references++;
				return obj;
			}

			internal void Release()
			{
				if (--_references <= 0)
				{
					if (_shared == this)
					{
						_shared = null;
					}
					DestroyAssets();
				}
			}

			private void DestroyAssets()
			{
				Material[] faceMaterials = FaceMaterials;
				foreach (Material val in faceMaterials)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						Object.Destroy((Object)(object)val);
					}
				}
				Texture2D[] faceTextures = _faceTextures;
				foreach (Texture2D val2 in faceTextures)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						Object.Destroy((Object)(object)val2);
					}
				}
				faceTextures = CloudTextures;
				foreach (Texture2D val3 in faceTextures)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						Object.Destroy((Object)(object)val3);
					}
				}
				if (Object.op_Implicit((Object)(object)BevelMaterial))
				{
					Object.Destroy((Object)(object)BevelMaterial);
				}
				if (Object.op_Implicit((Object)(object)Quad))
				{
					Object.Destroy((Object)(object)Quad);
				}
				if (Object.op_Implicit((Object)(object)Surface))
				{
					Object.Destroy((Object)(object)Surface);
				}
				if (Object.op_Implicit((Object)(object)Bevel))
				{
					Object.Destroy((Object)(object)Bevel);
				}
			}

			internal void AnimateSurface(float now)
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)Surface) || _surfaceUv == null || !float.IsFinite(now) || (now >= _lastSurfaceUpdate && now - _lastSurfaceUpdate < 0.05f))
				{
					return;
				}
				_lastSurfaceUpdate = now;
				for (int i = 0; i <= 12; i++)
				{
					for (int j = 0; j <= 12; j++)
					{
						CubeCloudMotion.Sample((float)j / 12f, (float)i / 12f, now, out var warpedU, out var warpedV);
						((Il2CppArrayBase<Vector2>)(object)_surfaceUv)[i * 13 + j] = new Vector2(warpedU, warpedV);
					}
				}
				Surface.uv = _surfaceUv;
			}

			private Mesh CreateSurface()
			{
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Expected O, but got Unknown
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				int num = 169;
				Il2CppStructArray<Vector3> val = new Il2CppStructArray<Vector3>((long)num);
				Il2CppStructArray<Color> val2 = new Il2CppStructArray<Color>((long)num);
				_surfaceUv = new Il2CppStructArray<Vector2>((long)num);
				Il2CppStructArray<int> val3 = new Il2CppStructArray<int>(864L);
				int num2 = 0;
				for (int i = 0; i <= 12; i++)
				{
					for (int j = 0; j <= 12; j++)
					{
						int num3 = i * 13 + j;
						float num4 = (float)j / 12f;
						float num5 = (float)i / 12f;
						((Il2CppArrayBase<Vector3>)(object)val)[num3] = new Vector3(num4 - 0.5f, num5 - 0.5f, 0f);
						((Il2CppArrayBase<Vector2>)(object)_surfaceUv)[num3] = new Vector2(num4, num5);
						((Il2CppArrayBase<Color>)(object)val2)[num3] = Color.white;
						if (j != 12 && i != 12)
						{
							int num6 = num3 + 12 + 1;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num3;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num6;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num3 + 1;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num3 + 1;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num6;
							((Il2CppArrayBase<int>)(object)val3)[num2++] = num6 + 1;
						}
					}
				}
				Mesh val4 = new Mesh
				{
					name = "CardCrunch flowing cloud surface"
				};
				try
				{
					val4.MarkDynamic();
					val4.vertices = val;
					val4.colors = val2;
					val4.uv = _surfaceUv;
					val4.triangles = val3;
					val4.RecalculateBounds();
					return val4;
				}
				catch
				{
					Object.Destroy((Object)(object)val4);
					throw;
				}
			}

			private static Texture2D Texture(byte[] rgba, int size, string name)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
				{
					name = name,
					wrapMode = (TextureWrapMode)1,
					filterMode = (FilterMode)1
				};
				try
				{
					Color32[] array = (Color32[])(object)new Color32[size * size];
					for (int i = 0; i < array.Length; i++)
					{
						int num = i * 4;
						array[i] = new Color32
						{
							r = rgba[num],
							g = rgba[num + 1],
							b = rgba[num + 2],
							a = rgba[num + 3]
						};
					}
					val.SetPixels32(new Il2CppStructArray<Color32>(array));
					val.Apply(false, true);
					return val;
				}
				catch
				{
					Object.Destroy((Object)(object)val);
					throw;
				}
			}

			private static Mesh CreateBevel()
			{
				//IL_0255: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0266: Expected O, but got Unknown
				//IL_0052: 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_00be: 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_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				List<Vector3> list = new List<Vector3>(72);
				List<Color> list2 = new List<Color>(72);
				List<int> list3 = new List<int>(96);
				for (int i = 0; i < 3; i++)
				{
					for (int j = -1; j <= 1; j += 2)
					{
						for (int k = -1; k <= 1; k += 2)
						{
							int count = list.Count;
							list.Add(Axes(i, -0.04916667f, (float)j * 0.05f, (float)k * 0.04916667f));
							list.Add(Axes(i, -0.04916667f, (float)j * 0.04916667f, (float)k * 0.05f));
							list.Add(Axes(i, 0.04916667f, (float)j * 0.04916667f, (float)k * 0.05f));
							list.Add(Axes(i, 0.04916667f, (float)j * 0.05f, (float)k * 0.04916667f));
							for (int l = 0; l < 4; l++)
							{
								list2.Add(EdgeColor(list[count + l].y));
							}
							list3.AddRange(new int[6]
							{
								count,
								count + 1,
								count + 2,
								count,
								count + 2,
								count + 3
							});
						}
					}
				}
				for (int m = -1; m <= 1; m += 2)
				{
					for (int n = -1; n <= 1; n += 2)
					{
						for (int num = -1; num <= 1; num += 2)
						{
							int count2 = list.Count;
							list.Add(new Vector3((float)m * 0.05f, (float)n * 0.04916667f, (float)num * 0.04916667f));
							list.Add(new Vector3((float)m * 0.04916667f, (float)n * 0.05f, (float)num * 0.04916667f));
							list.Add(new Vector3((float)m * 0.04916667f, (float)n * 0.04916667f, (float)num * 0.05f));
							for (int num2 = 0; num2 < 3; num2++)
							{
								list2.Add(EdgeColor(list[count2 + num2].y));
							}
							list3.AddRange(new int[3]
							{
								count2,
								count2 + 1,
								count2 + 2
							});
						}
					}
				}
				Mesh val = new Mesh
				{
					name = "CardCrunch soft cube edge mesh"
				};
				try
				{
					val.vertices = new Il2CppStructArray<Vector3>(list.ToArray());
					val.colors = new Il2CppStructArray<Color>(list2.ToArray());
					val.triangles = new Il2CppStructArray<int>(list3.ToArray());
					val.RecalculateNormals();
					val.RecalculateBounds();
					return val;
				}
				catch
				{
					Object.Destroy((Object)(object)val);
					throw;
				}
			}

			private static Vector3 Axes(int axis, float length, float first, float second)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				return (Vector3)(axis switch
				{
					0 => new Vector3(length, first, second), 
					1 => new Vector3(second, length, first), 
					_ => new Vector3(first, second, length), 
				});
			}

			private static Color EdgeColor(float y)
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				float num = Mathf.Clamp01(y / 0.1f + 0.5f);
				return new Color(0.004f + num * 0.008f, 0.032f + num * 0.1f, 0.07f + num * 0.2f, 0.97f);
			}
		}

		private const float HalfSize = 0.05f;

		private const float EdgeInset = 0.00083333335f;

		private const float CloudRadius = 1f / 24f;

		private const int CloudLayers = 5;

		private CloudAssets? _assets;

		private GameObject? _root;

		private readonly Transform?[] _faces = (Transform?[])(object)new Transform[6];

		private readonly Transform?[] _clouds = (Transform?[])(object)new Transform[5];

		private readonly Material?[] _cloudMaterials = (Material?[])(object)new Material[5];

		private Transform? _cloudRoot;

		private Transform? _nameRoot;

		private TextMesh? _nameText;

		private MeshRenderer? _nameRenderer;

		private Material? _nameMaterial;

		private bool _nameFitted;

		private float _nameBaseScale = 0.01f;

		private float _lastGlow = float.NegativeInfinity;

		private bool _disposed;

		internal bool EnsureReady(out string error)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			error = string.Empty;
			if (_disposed)
			{
				error = "The cube display has been closed.";
				return false;
			}
			try
			{
				if (_assets == null)
				{
					_assets = CloudAssets.Acquire();
				}
				if (!Object.op_Implicit((Object)(object)_nameMaterial))
				{
					_nameMaterial = new Material(_assets.Shader)
					{
						name = "CardCrunch cube name",
						renderQueue = 3020,
						mainTexture = _assets.Font.material.mainTexture,
						color = new Color(0.68f, 0.93f, 1f, 0.95f)
					};
				}
				for (int i = 0; i < 5; i++)
				{
					if (!Object.op_Implicit((Object)(object)_cloudMaterials[i]))
					{
						_cloudMaterials[i] = new Material(_assets.Shader)
						{
							name = "CardCrunch contained cloud " + i,
							renderQueue = 3000 + i,
							mainTexture = (Texture)(object)_assets.CloudTextures[i],
							color = Color.white
						};
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				ReleaseAssets();
				error = "Could not prepare the blue cube: " + ex.Message;
				return false;
			}
		}

		internal void Create(GameObject root, string displayName)
		{
			//IL_0053: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)root) || root.activeInHierarchy)
			{
				throw new InvalidOperationException("Prepare cube graphics on an inactive storage body.");
			}
			if (!EnsureReady(out string error))
			{
				throw new InvalidOperationException(error);
			}
			if (Object.op_Implicit((Object)(object)_root))
			{
				throw new InvalidOperationException("A cube display already exists.");
			}
			_root = root;
			Quaternion[] array = (Quaternion[])(object)new Quaternion[6]
			{
				Quaternion.identity,
				Quaternion.Euler(0f, 180f, 0f),
				Quaternion.Euler(0f, 90f, 0f),
				Quaternion.Euler(0f, -90f, 0f),
				Quaternion.Euler(90f, 0f, 0f),
				Quaternion.Euler(-90f, 0f, 0f)
			};
			for (int i = 0; i < 6; i++)
			{
				Transform val = Child(root.transform, "CardCrunch blue cloud face " + i);
				_faces[i] = val;
				val.localRotation = array[i];
				val.localPosition = array[i] * new Vector3(0f, 0f, -0.05f);
				float num = 0.09833334f;
				val.localScale = new Vector3(num, num, 1f);
				Render(val, _assets.Surface, _assets.FaceMaterials[i]);
			}
			Render(Child(root.transform, "CardCrunch soft dark cube edges"), _assets.Bevel, _assets.BevelMaterial);
			_cloudRoot = Child(root.transform, "CardCrunch contained blue turbulence");
			for (int j = 0; j < 5; j++)
			{
				Transform val2 = Child(_cloudRoot, "CardCrunch internal wisp " + j);
				_clouds[j] = val2;
				float num2 = 1f / 24f * (0.44f - (float)j * 0.22f);
				float num3 = MathF.Sqrt((0.0017361112f - num2 * num2) * 2f);
				val2.localPosition = Vector3.forward * num2;
				val2.localScale = new Vector3(num3, num3, 1f);
				Render(val2, _assets.Quad, _cloudMaterials[j]);
			}
			_nameRoot = Child(root.transform, "CardCrunch object name above cube");
			_nameRoot.localPosition = Vector3.up * 0.089f;
			_nameRoot.localScale = Vector3.one * 0.01f;
			_nameText = ((Component)_nameRoot).gameObject.AddComponent<TextMesh>();
			_nameText.font = _assets.Font;
			_nameText.text = CleanName(displayName);
			_nameText.fontSize = 96;
			_nameText.characterSize = 0.002f;
			_nameText.anchor = (TextAnchor)4;
			_nameText.alignment = (TextAlignment)1;
			_nameText.richText = false;
			_nameText.color = Color.white;
			_nameRenderer = ((Component)_nameRoot).GetComponent<MeshRenderer>();
			((Renderer)_nameRenderer).sharedMaterial = _nameMaterial;
			ConfigureRenderer((Renderer)(object)_nameRenderer);
			_nameFitted = false;
			_lastGlow = float.NegativeInfinity;
		}

		internal void Tick(float now, Transform head, bool selected)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_root) || !_root.activeInHierarchy || !Object.op_Implicit((Object)(object)head) || !float.IsFinite(now))
			{
				return;
			}
			Transform transform = _root.transform;
			Vector3 val = transform.position - head.position;
			if (!Finite(val))
			{
				return;
			}
			for (int i = 0; i < _faces.Length; i++)
			{
				Transform val2 = _faces[i];
				if (Object.op_Implicit((Object)(object)val2))
				{
					bool flag = Vector3.Dot(head.position - val2.position, val2.forward) <= 0f;
					if (((Component)val2).gameObject.activeSelf != flag)
					{
						((Component)val2).gameObject.SetActive(flag);
					}
				}
			}
			Quaternion rotation = Facing(val, head);
			if (Object.op_Implicit((Object)(object)_cloudRoot))
			{
				_cloudRoot.rotation = rotation;
			}
			UpdateName(transform, head, ((Vector3)(ref val)).magnitude, selected);
			_assets.AnimateSurface(now);
			if (now - _lastGlow < 0.05f && now >= _lastGlow)
			{
				return;
			}
			_lastGlow = now;
			for (int j = 0; j < 5; j++)
			{
				float num = (float)j * 1.71f;
				if (Object.op_Implicit((Object)(object)_clouds[j]))
				{
					_clouds[j].localRotation = Quaternion.Euler(0f, 0f, (float)j * 53f + now % 3600f * ((j % 2 == 0) ? 10f : (-12f)) + MathF.Sin(now * 0.65f + num) * 7f);
				}
				if (Object.op_Implicit((Object)(object)_cloudMaterials[j]))
				{
					float num2 = 0.92f + MathF.Sin(now * 0.85f + num) * 0.08f;
					_cloudMaterials[j].color = new Color(num2, num2, 1f, selected ? 1f : 0.96f);
				}
			}
		}

		private void UpdateName(Transform pose, Transform head, float distance, bool selected)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_nameRoot) || !Object.op_Implicit((Object)(object)_nameRenderer) || !Object.op_Implicit((Object)(object)_nameMaterial) || _assets == null)
			{
				return;
			}
			if (!_nameFitted)
			{
				Bounds localBounds = ((Renderer)_nameRenderer).localBounds;
				Vector3 size = ((Bounds)(ref localBounds)).size;
				if (Finite(size) && size.x > 1E-05f && size.y > 1E-05f)
				{
					_nameBaseScale = Mathf.Clamp(Mathf.Min(0.22f / size.x, 0.017f / size.y), 0.01f, 30f);
					_nameFitted = true;
				}
			}
			float num = 0.05f * (MathF.Abs(pose.right.y) + MathF.Abs(pose.up.y) + MathF.Abs(pose.forward.y));
			Vector3 val = pose.position + Vector3.up * (num + 0.039f);
			_nameRoot.SetPositionAndRotation(val, Facing(val - head.position, head));
			float num2 = Mathf.Lerp(1f, 1.4f, Mathf.Clamp01((distance - 0.8f) / 3.2f));
			_nameRoot.localScale = Vector3.one * (_nameBaseScale * num2);
			float num3 = Mathf.Clamp01((8f - distance) / 2f) * (selected ? 1f : 0.9f);
			((Renderer)_nameRenderer).enabled = num3 > 0f;
			_nameMaterial.color = new Color(0.73f, 0.94f, 1f, num3);
			Texture mainTexture = _assets.Font.material.mainTexture;
			if ((Object)(object)_nameMaterial.mainTexture != (Object)(object)mainTexture)
			{
				_nameMaterial.mainTexture = mainTexture;
			}
		}

		private static Quaternion Facing(Vector3 away, Transform head)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref away)).sqrMagnitude > 1E-05f)
			{
				Vector3 val = Vector3.Cross(away, Vector3.up);
				if (((Vector3)(ref val)).sqrMagnitude > 1E-06f)
				{
					return Quaternion.LookRotation(away, Vector3.up);
				}
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(head.forward.x, 0f, head.forward.z);
			return Quaternion.LookRotation((((Vector3)(ref val2)).sqrMagnitude > 1E-05f) ? val2 : Vector3.forward, Vector3.up);
		}

		internal void HideName()
		{
			if (Object.op_Implicit((Object)(object)_nameRenderer))
			{
				((Renderer)_nameRenderer).enabled = false;
			}
		}

		internal void ClearDisplay()
		{
			_root = null;
			_cloudRoot = (_nameRoot = null);
			_nameText = null;
			_nameRenderer = null;
			Array.Clear(_faces, 0, _faces.Length);
			Array.Clear(_clouds, 0, _clouds.Length);
			_nameFitted = false;
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				_disposed = true;
				ClearDisplay();
				ReleaseAssets();
			}
		}

		private void ReleaseAssets()
		{
			if (Object.op_Implicit((Object)(object)_nameMaterial))
			{
				Object.Destroy((Object)(object)_nameMaterial);
			}
			_nameMaterial = null;
			for (int i = 0; i < _cloudMaterials.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)_cloudMaterials[i]))
				{
					Object.Destroy((Object)(object)_cloudMaterials[i]);
				}
				_cloudMaterials[i] = null;
			}
			_assets?.Release();
			_assets = null;
		}

		private static Transform Child(Transform parent, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 2
			};
			val.transform.SetParent(parent, false);
			return val.transform;
		}

		private static void Render(Transform target, Mesh mesh, Material material)
		{
			((Component)target).gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = ((Component)target).gameObject.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = material;
			ConfigureRenderer((Renderer)(object)obj);
		}

		private static void ConfigureRenderer(Renderer renderer)
		{
			renderer.shadowCastingMode = (ShadowCastingMode)0;
			renderer.receiveShadows = false;
			renderer.lightProbeUsage = (LightProbeUsage)0;
			renderer.reflectionProbeUsage = (ReflectionProbeUsage)0;
		}

		private static string CleanName(string value)
		{
			string text = (string.IsNullOrWhiteSpace(value) ? "STORED OBJECT" : value.Trim());
			text = text.Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' ');
			if (text.Length <= 32)
			{
				return text;
			}
			return text.Substring(0, 30) + "..";
		}

		private static bool Finite(Vector3 value)
		{
			//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)
			if (float.IsFinite(value.x) && float.IsFinite(value.y))
			{
				return float.IsFinite(value.z);
			}
			return false;
		}
	}
	internal sealed class HoldConfirm
	{
		private const float DefaultDuration = 0.65f;

		private re