Decompiled source of UltraEditor v0.1.0

UltraEditor.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using BlackholeChaos.Scripts;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ScriptableObjects;
using TMPro;
using ULTRAKILL.Portal;
using ULTRAKILL.Portal.Geometry;
using UltraEditor;
using UltraEditor.Classes;
using UltraEditor.Classes.ActionTypes;
using UltraEditor.Classes.ActionTypes.Base;
using UltraEditor.Classes.Canvas;
using UltraEditor.Classes.Editor;
using UltraEditor.Classes.IO;
using UltraEditor.Classes.IO.SaveObjects;
using UltraEditor.Classes.TempScripts;
using UltraEditor.Classes.World;
using UltraEditor.Libraries;
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using plog;
using plog.Models;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("UltraEditor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("WIP in-game level editor for ultrakill")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+0cf782396ca7885efcc72c463cd0c4b1fd43cd3b")]
[assembly: AssemblyProduct("UltraEditor")]
[assembly: AssemblyTitle("UltraEditor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[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;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class ExtensionMarkerAttribute : Attribute
	{
		private readonly string <Name>k__BackingField;

		public string Name => <Name>k__BackingField;

		public ExtensionMarkerAttribute(string name)
		{
			<Name>k__BackingField = name;
		}
	}
}
public class NonDefaultScriptChecker : MonoBehaviour
{
	public static void CheckScripts()
	{
		MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>(true);
		MonoBehaviour[] array2 = array;
		foreach (MonoBehaviour val in array2)
		{
			Type type = ((object)val).GetType();
			string name = type.Assembly.GetName().Name;
			if (name != "Assembly-CSharp" && !name.StartsWith("UnityEngine") && !name.StartsWith("Unity") && !name.StartsWith("UnityEditor"))
			{
				Plugin.LogError("Non-default script detected: " + type.FullName + " in assembly " + name + " on GameObject '" + ((Object)((Component)val).gameObject).name + "'");
			}
		}
		Plugin.LogInfo("Script scan complete");
	}
}
public static class AttributeHelper
{
	public static IEnumerable<(Type type, T attr)> GetTypesWithAttribute<T>() where T : Attribute
	{
		return from t in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes())
			select (type: t, attr: t.GetCustomAttribute<T>()) into x
			where x.attr != null
			select x;
	}

	public static IEnumerable<(FieldInfo field, T attr)> GetFieldsWithAttribute<T>() where T : Attribute
	{
		return from f in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes()).SelectMany((Type t) => t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
			select (field: f, attr: f.GetCustomAttribute<T>()) into x
			where x.attr != null
			select x;
	}
}
[AttributeUsage(AttributeTargets.Class)]
public class EditorComp : Attribute
{
	public string description;

	public EditorComp(string description)
	{
		this.description = description;
	}
}
[AttributeUsage(AttributeTargets.Field)]
public class EditorVar : Attribute
{
	public string display;

	public EditorVar(string display)
	{
		this.display = display;
	}
}
[AttributeUsage(AttributeTargets.Class)]
public class SavableComponent : Attribute
{
}
[AttributeUsage(AttributeTargets.Field)]
public class SavableVariable : Attribute
{
}
namespace BlackholeChaos.Scripts
{
	public class Blackhole : MonoBehaviour
	{
		public float range = 0f;

		public float force = 0f;

		public int difficulty = 1;

		public MeshRenderer meshRendeder;

		public MeshRenderer meshRendeder2;

		public MeshRenderer meshRendeder3;

		private bool inHole = false;

		public bool white = false;

		private List<Rigidbody> touchedRigidbodies = new List<Rigidbody>();

		private float A = 0f;

		public void Create()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = Vector3.zero + new Vector3(0f, 25f, 0f);
			((Component)this).transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position + new Vector3(0f, 25f, 0f);
			difficulty = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
			SetupVisual();
		}

		private void SetupVisual()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00a8: 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_0139: 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_0150: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			Color color = default(Color);
			((Color)(ref color))..ctor(0f, 0f, 0f, 0f);
			if (white)
			{
				((Color)(ref color))..ctor(1f, 1f, 1f, 0f);
			}
			MeshFilter val = ((Component)this).gameObject.AddComponent<MeshFilter>();
			MeshRenderer val2 = ((Component)this).gameObject.AddComponent<MeshRenderer>();
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0);
			MeshFilter component = val3.GetComponent<MeshFilter>();
			if ((Object)(object)component != (Object)null)
			{
				val.mesh = component.sharedMesh;
			}
			Object.Destroy((Object)(object)val3);
			((Renderer)val2).enabled = false;
			Material val4 = new Material(Shader.Find("Standard"));
			val4.color = color;
			val4.SetFloat("_Mode", 3f);
			val4.SetInt("_SrcBlend", 5);
			val4.SetInt("_DstBlend", 10);
			val4.SetInt("_ZWrite", 0);
			val4.DisableKeyword("_ALPHATEST_ON");
			val4.EnableKeyword("_ALPHABLEND_ON");
			val4.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val4.renderQueue = 3000;
			((Renderer)val2).material = val4;
			((Component)this).transform.localScale = Vector3.one * 2f;
			GameObject val5 = new GameObject("BlackholeShell");
			val5.transform.parent = ((Component)this).transform;
			val5.transform.localPosition = Vector3.zero;
			MeshFilter val6 = val5.AddComponent<MeshFilter>();
			MeshRenderer val7 = val5.AddComponent<MeshRenderer>();
			val6.mesh = Object.Instantiate<Mesh>(val.mesh);
			Material val8 = new Material(Shader.Find("Standard"));
			val8.color = color;
			val8.SetFloat("_Mode", 3f);
			val8.SetInt("_SrcBlend", 5);
			val8.SetInt("_DstBlend", 10);
			val8.SetInt("_ZWrite", 0);
			val8.DisableKeyword("_ALPHATEST_ON");
			val8.EnableKeyword("_ALPHABLEND_ON");
			val8.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val8.renderQueue = 3000;
			val8.shader = MonoSingleton<DefaultReferenceManager>.Instance.masterShader;
			((Renderer)val7).material = val8;
			meshRendeder = val7;
			val5 = new GameObject("BlackholeShell");
			val5.transform.parent = ((Component)this).transform;
			val5.transform.localPosition = Vector3.zero;
			val6 = val5.AddComponent<MeshFilter>();
			val7 = val5.AddComponent<MeshRenderer>();
			val6.mesh = Object.Instantiate<Mesh>(val.mesh);
			val8 = new Material(Shader.Find("Standard"));
			val8.color = color;
			val8.SetFloat("_Mode", 3f);
			val8.SetInt("_SrcBlend", 5);
			val8.SetInt("_DstBlend", 10);
			val8.SetInt("_ZWrite", 0);
			val8.DisableKeyword("_ALPHATEST_ON");
			val8.EnableKeyword("_ALPHABLEND_ON");
			val8.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val8.renderQueue = 3000;
			val8.shader = MonoSingleton<DefaultReferenceManager>.Instance.masterShader;
			((Renderer)val7).material = val8;
			Mesh val9 = Object.Instantiate<Mesh>(val6.mesh);
			MemoryExtensions.Reverse<int>(val9.triangles);
			val9.RecalculateNormals();
			val6.mesh = val9;
			meshRendeder3 = val7;
			val5 = new GameObject("BlackholeShell");
			val5.transform.parent = ((Component)this).transform;
			val5.transform.localPosition = Vector3.zero;
			val6 = val5.AddComponent<MeshFilter>();
			val7 = val5.AddComponent<MeshRenderer>();
			val6.mesh = val.mesh;
			val8 = new Material(Shader.Find("Standard"));
			val8.color = color;
			val8.SetFloat("_Mode", 3f);
			val8.SetInt("_SrcBlend", 5);
			val8.SetInt("_DstBlend", 10);
			val8.SetInt("_ZWrite", 0);
			val8.DisableKeyword("_ALPHATEST_ON");
			val8.EnableKeyword("_ALPHABLEND_ON");
			val8.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val8.renderQueue = 3000;
			val8.shader = Shader.Find("Legacy Shaders/Diffuse");
			if (white)
			{
				val8.shader = Shader.Find("Unlit/Texture");
			}
			((Renderer)val7).material = val8;
			meshRendeder2 = val7;
		}

		public void Update()
		{
			//IL_003a: 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)
			if (Time.deltaTime != 0f && !((Object)(object)meshRendeder == (Object)null))
			{
				((Component)meshRendeder3).transform.position = ((Component)Camera.main).transform.position;
				((Renderer)meshRendeder3).enabled = Vector3.Distance(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ((Component)this).transform.position) <= range;
			}
		}

		public void FixedUpdate()
		{
			//IL_00b3: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: 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_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			if (Time.deltaTime == 0f || (Object)(object)meshRendeder == (Object)null)
			{
				return;
			}
			float num = ((float)difficulty + 1f) / 4f;
			force = force * (1f + Time.fixedDeltaTime / 2000f) + Time.fixedDeltaTime * 500f * num;
			range = range * (1f + Time.fixedDeltaTime / 1000f) + Time.fixedDeltaTime * 7f * num;
			((Component)meshRendeder).transform.localScale = new Vector3(1f, 1f, 1f) * range;
			((Component)meshRendeder3).transform.localScale = new Vector3(1f, 1f, 1f);
			((Component)meshRendeder2).transform.localScale = new Vector3(1f, 1f, 1f) * range / 5f;
			if (Vector3.Distance(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ((Component)this).transform.position) < range)
			{
				if (Vector3.Distance(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ((Component)this).transform.position) < range / 5f)
				{
					MonoSingleton<NewMovement>.Instance.GetHurt(1000, false, 1f, false, false, 0.35f, false);
					MonoSingleton<StatsManager>.Instance.currentCheckPoint = null;
					MonoSingleton<CheckPointsController>.Instance.DisableCheckpoints();
				}
				inHole = true;
			}
			else
			{
				inHole = false;
			}
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, range);
			int num2 = 0;
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Rigidbody attachedRigidbody = val.attachedRigidbody;
				EnemyIdentifier component = ((Component)val).GetComponent<EnemyIdentifier>();
				if ((Object)(object)attachedRigidbody != (Object)null && (Object)(object)attachedRigidbody != (Object)(object)((Component)this).GetComponent<Rigidbody>())
				{
					num2++;
					if (num2 > 25 && (Object)(object)component == (Object)null)
					{
						continue;
					}
					Vector3 val2 = ((Component)this).transform.position - attachedRigidbody.position;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					float num3 = Vector3.Distance(((Component)this).transform.position, attachedRigidbody.position);
					float num4 = (float)((!white) ? 1 : (-1)) * force / Mathf.Max(num3, 1f);
					if (num3 < range / 5f)
					{
						Transform transform = ((Component)attachedRigidbody).transform;
						transform.localScale += 10f * new Vector3(Random.Range(0f, 0.1f), Random.Range(0f, 0.2f), Random.Range(0f, 0.1f)) * Time.fixedDeltaTime;
						if (!touchedRigidbodies.Contains(attachedRigidbody))
						{
							Fat();
							touchedRigidbodies.Add(attachedRigidbody);
						}
						if (num3 <= range / 10f && (Object)(object)component == (Object)null && (Object)(object)((Component)MonoSingleton<NewMovement>.Instance).gameObject != (Object)(object)((Component)attachedRigidbody).gameObject)
						{
							Fat();
							Object.Destroy((Object)(object)((Component)attachedRigidbody).gameObject);
							continue;
						}
					}
					attachedRigidbody.AddForce(normalized * num4, (ForceMode)0);
				}
				if ((Object)(object)component != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < range / 5f)
				{
					Fat();
					DamageEnemy(component);
				}
			}
		}

		private void Fat()
		{
			range += 3f;
			force += 400f;
		}

		public void OnGUI()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (inHole)
			{
				float num = Vector3.Distance(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ((Component)this).transform.position);
				float num2 = range;
				float num3 = Mathf.Clamp01(5f - num / num2) * 0.6f + 0.1f;
				A -= (A - num3) / 200f;
			}
			else
			{
				A -= (A - 0f) / 20f;
			}
			Color color = GUI.color;
			float num4 = (white ? 1f : 0f);
			GUI.color = new Color(num4, num4, num4, A / 2f);
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}

		private void DamageEnemy(EnemyIdentifier eid)
		{
			//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)
			eid.DeliverDamage(((Component)this).gameObject, Vector3.zero, Vector3.zero, 1000f, false, 0f, (GameObject)null, false, false);
		}
	}
}
namespace UltraEditor
{
	[BepInPlugin("duviz.ultrakill.ultraeditor", "UltraEditor", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "duviz.ultrakill.ultraeditor";

		public const string Name = "UltraEditor";

		public const string Version = "0.1.0";

		public const string ExpectedBuildGUID = "cd2a9e08be6e44379c465e9b5d8b4fc2";

		public static Plugin Instance;

		public Logger Log;

		public static KeyCode EditorOpenKey = (KeyCode)282;

		public static KeyCode SelectCursorKey = (KeyCode)283;

		public static KeyCode SelectMoveKey = (KeyCode)284;

		public static KeyCode SelectScaleKey = (KeyCode)285;

		public static KeyCode SelectRotationKey = (KeyCode)286;

		public static KeyCode ToggleEditorCanvasKey = (KeyCode)290;

		public static KeyCode DeleteObjectKey = (KeyCode)127;

		public static KeyCode CreateCubeKey = (KeyCode)270;

		public static KeyCode CtrlKey = (KeyCode)306;

		public static KeyCode ShiftKey = (KeyCode)304;

		public static KeyCode AltKey = (KeyCode)308;

		private const string LastPlayedVersionPref = "UltraEditor_LastPlayedVersion";

		private static bool SeenWelcomeMessage = false;

		public static bool IsToggleEnabledKeyPressed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(AltKey) && Input.GetKey(ShiftKey) && Input.GetKeyDown((KeyCode)97);
		}

		public static bool IsDuplicateKeyPressed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(CtrlKey) && Input.GetKeyDown((KeyCode)100);
		}

		public static bool IsUndoPressed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(CtrlKey) && !Input.GetKey(ShiftKey) && Input.GetKeyDown((KeyCode)122);
		}

		public static bool IsRedoPressed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(CtrlKey) && ((Input.GetKey(ShiftKey) && Input.GetKeyDown((KeyCode)122)) || Input.GetKeyDown((KeyCode)121));
		}

		public static bool IsSelectPressed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(AltKey) && Input.GetKeyDown((KeyCode)115);
		}

		public static bool CanMove()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return !Input.GetKey(CtrlKey) && !Input.GetKey(AltKey);
		}

		public void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			if (Application.buildGUID != "cd2a9e08be6e44379c465e9b5d8b4fc2")
			{
				((BaseUnityPlugin)this).Logger.LogFatal((object)("Incompatible game version!\nGUID: " + Application.buildGUID + " EXPECTED: cd2a9e08be6e44379c465e9b5d8b4fc2"));
				Object.Destroy((Object)(object)this);
				return;
			}
			Instance = this;
			LogInfo("Hi :3");
			Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
			BundlesManager.Load();
			EditorVariablesList.SetupEditorVariables();
			EditorComponentsList.SetupEditorComponents();
			Harmony val = new Harmony("duviz.ultrakill.ultraeditor");
			val.PatchAll();
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
		}

		public void Start()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			GameObject val = new GameObject("ChapterSelectChanger", new Type[1] { typeof(ChapterSelectChanger) });
			AssetsWindowManager.Load();
			EmptySceneLoader.Load();
		}

		public void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(EditorOpenKey) && (!SceneHelper.CurrentScene.StartsWith(EditorManager.EditorSceneName) || EditorManager.canOpenEditor || EmptySceneLoader.forceLevelCanOpenEditor || ((Object)(object)EditorManager.Instance != (Object)null && EditorManager.Instance.editorCanvas.activeInHierarchy)) && SceneHelper.PendingScene == null)
			{
				EditorManager.Create();
			}
			if (SceneHelper.CurrentScene == "Main Menu" && SceneHelper.PendingScene == null && !SeenWelcomeMessage)
			{
				if (Preferences.GetString("UltraEditor_LastPlayedVersion") != GetVersion().ToString())
				{
					Object.Instantiate<GameObject>(BundlesManager.welcomeCanvas);
					Preferences.SetString("UltraEditor_LastPlayedVersion", GetVersion().ToString());
				}
				SeenWelcomeMessage = true;
			}
		}

		[Obsolete("Use AssHelper.Ass")]
		public static T Ass<T>(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
		}

		[Obsolete("Use AssHelper.ResAss")]
		public static T Ast<T>(string path) where T : Object
		{
			T val = Resources.Load<T>(path);
			if ((Object)(object)val == (Object)null)
			{
				LogError("Resources.Load failed for \"" + path + "\"");
			}
			return val;
		}

		public static void LogInfo(object data, string stackTrace = null)
		{
			//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_0046: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			ManualLogSource logger = ((BaseUnityPlugin)Instance).Logger;
			if (logger != null)
			{
				logger.LogInfo((stackTrace != null) ? $"{data}\n{stackTrace}" : data);
			}
			Plugin instance = Instance;
			Logger obj = instance.Log;
			if (obj == null)
			{
				Logger val = new Logger("ULTRAEDITOR");
				Logger val2 = val;
				instance.Log = val;
				obj = val2;
			}
			if (obj != null)
			{
				obj.Info(data.ToString(), (IEnumerable<Tag>)null, stackTrace, (object)null);
			}
		}

		public static void LogError(object data, string stackTrace = null)
		{
			//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_0046: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			ManualLogSource logger = ((BaseUnityPlugin)Instance).Logger;
			if (logger != null)
			{
				logger.LogError((stackTrace != null) ? $"{data}\n{stackTrace}" : data);
			}
			Plugin instance = Instance;
			Logger obj = instance.Log;
			if (obj == null)
			{
				Logger val = new Logger("ULTRAEDITOR");
				Logger val2 = val;
				instance.Log = val;
				obj = val2;
			}
			if (obj != null)
			{
				obj.Error(data.ToString(), (IEnumerable<Tag>)null, stackTrace, (object)null);
			}
		}

		public static Version GetVersion()
		{
			return ((BaseUnityPlugin)Instance).Info.Metadata.Version;
		}

		public static void FormatURLforProxy(ref string uri)
		{
			if (!File.Exists(uri))
			{
				uri = "https://ultraeditor-proxy.fredayddd321ewq.workers.dev/" + uri;
			}
		}
	}
}
namespace UltraEditor.Patches
{
	[HarmonyPatch]
	public static class CursorCameraControllerPatch
	{
		[HarmonyPatch(typeof(CameraController), "LateUpdate")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> FixCursor(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo get_isDebugBuild = AccessTools.Method(typeof(Debug), "get_isDebugBuild", (Type[])null, (Type[])null);
			foreach (CodeInstruction instr in instructions)
			{
				if (CodeInstructionExtensions.Calls(instr, get_isDebugBuild))
				{
					yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
				}
				else
				{
					yield return instr;
				}
			}
		}
	}
	[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
	public static class LeaderboardControllerPatch
	{
		public static bool Prefix()
		{
			return (Object)(object)EditorManager.Instance == (Object)null;
		}
	}
	[HarmonyPatch(typeof(Revolver), "Shoot")]
	public static class LookThisPatchIsNeeded
	{
		public static void Postfix(int shotType = 1)
		{
			((Component)MonoSingleton<CameraController>.Instance).GetComponent<Camera>().fieldOfView = MonoSingleton<CameraController>.Instance.defaultFov;
		}
	}
	[HarmonyPatch]
	public static class PortalPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PortalManagerV2), "Update")]
		public static void ShutTheFuckUp(PortalManagerV2 __instance)
		{
			__instance.portalComponents = __instance.portalComponents.Where((Portal p) => Object.op_Implicit((Object)(object)p)).ToList();
		}
	}
	[HarmonyPatch]
	public static class RemovePauseMeun
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(OptionsManager), "Pause")]
		public static bool DontFuckingExistYouFuckAssMenu()
		{
			EditorManager instance = EditorManager.Instance;
			return instance == null || !instance.editorOpen;
		}
	}
	[HarmonyPatch]
	public static class SceneHelperPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(SceneHelper), "LoadSceneCoroutine")]
		public static bool LoadScenePatch(ref IEnumerator __result, string sceneName)
		{
			if (sceneName.StartsWith(EditorManager.EditorSceneName))
			{
				__result = EmptySceneLoader.LoadLevelAsync();
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GetMissionName), "GetMissionNumberOnly")]
		public static bool FixMissionNum(ref string __result)
		{
			if (SceneHelper.CurrentScene.StartsWith(EditorManager.EditorSceneName))
			{
				__result = "C";
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GetMissionName), "GetMissionNameOnly")]
		public static bool FixMissionNameOnly(ref string __result)
		{
			if (SceneHelper.CurrentScene.StartsWith(EditorManager.EditorSceneName))
			{
				__result = MapInfoBase.Instance.levelName;
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GetMissionName), "GetMission")]
		public static bool FixMissionName(ref string __result)
		{
			if (SceneHelper.CurrentScene.StartsWith(EditorManager.EditorSceneName))
			{
				__result = MapInfoBase.Instance.levelName;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StatsManager), "SecretFound")]
	public static class SecretFoundPatch2
	{
		public static bool Prefix(int i)
		{
			return i != 100000;
		}
	}
}
namespace UltraEditor.Libraries
{
	public static class AssHelper
	{
		[SpecialName]
		public sealed class <G>$34505F560D9EACF86A87F3ED1F85E448
		{
			[SpecialName]
			public static class <M>$69FE22D2D9367C6033D7C9FA04F1ABE9
			{
			}

			[ExtensionMarker("<M>$69FE22D2D9367C6033D7C9FA04F1ABE9")]
			public int Occurrences(char lookUp)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$69FE22D2D9367C6033D7C9FA04F1ABE9")]
			public IEnumerable<int> Occurences(char lookUp)
			{
				throw new NotSupportedException();
			}
		}

		private static List<string> cache_PrefabKeys = null;

		public static Dictionary<string, object> CachedAddressableAssets = new Dictionary<string, object>();

		public static Dictionary<string, object> CachedResourceAssets = new Dictionary<string, object>();

		public static IResourceLocator MainAddressablesLocator => Addressables.ResourceLocators.FirstOrDefault((Func<IResourceLocator, bool>)((IResourceLocator loc) => loc.LocatorId == "AddressablesMainContentCatalog"));

		public static IEnumerable<object> GetAddressableKeys()
		{
			IResourceLocator mainAddressablesLocator = MainAddressablesLocator;
			return ((mainAddressablesLocator != null) ? mainAddressablesLocator.Keys : null) ?? Array.Empty<object>();
		}

		public static List<string> GetPrefabAddressableKeys(Func<string, bool> Search = null)
		{
			if (cache_PrefabKeys != null)
			{
				return cache_PrefabKeys.Where(Search).ToList();
			}
			List<string> list = new List<string>();
			IList<IResourceLocation> list2 = default(IList<IResourceLocation>);
			foreach (object addressableKey in GetAddressableKeys())
			{
				if (MainAddressablesLocator.Locate(addressableKey, typeof(GameObject), ref list2) && !list.Contains(list2[0].PrimaryKey))
				{
					list.Add(list2[0].PrimaryKey);
				}
			}
			list.Sort();
			cache_PrefabKeys = list;
			return list.Where(Search).ToList();
		}

		public static T Ass<T>(string key)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (CachedAddressableAssets.TryGetValue(key + typeof(T).Name, out var value))
			{
				return (T)value;
			}
			T val = Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
			if (val != null)
			{
				CachedAddressableAssets.Add(key + typeof(T).Name, val);
			}
			else
			{
				Plugin.LogError("Failed to load asset: " + key);
			}
			return val;
		}

		public static T ResAss<T>(string path) where T : Object
		{
			if (CachedResourceAssets.TryGetValue(path + typeof(T).Name, out var value))
			{
				return (T)value;
			}
			T val = Resources.Load<T>(path);
			if ((Object)(object)val != (Object)null)
			{
				CachedResourceAssets.Add(path + typeof(T).Name, val);
			}
			else
			{
				Plugin.LogError("Failed to load asset: " + path);
			}
			return val;
		}

		public static int Occurrences(this string str, char lookUp)
		{
			int num = 0;
			foreach (char c in str)
			{
				if (c == lookUp)
				{
					num++;
				}
			}
			return num;
		}

		public static IEnumerable<int> Occurences(this string str, char lookUp)
		{
			for (int i = 0; i < str.Length; i++)
			{
				if (str[i] == lookUp)
				{
					yield return i;
				}
			}
		}
	}
	public static class PrefabFixer
	{
		public static Dictionary<string, string> replaceKeys = new Dictionary<string, string>
		{
			["Assets/Prefabs/Enemies/Projectile Zombie.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Stray.prefab",
			["Assets/Prefabs/Enemies/ShotgunHusk.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Soldier.prefab",
			["Assets/Prefabs/Enemies/Super Projectile Zombie.prefab"] = "Assets/Prefabs/Enemies/Schism.prefab",
			["Assets/Prefabs/Enemies/Zombie.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Filth.prefab",
			["Assets/Prefabs/Enemies/Mass.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Statue/Mass.prefab",
			["Assets/Prefabs/Enemies/Flesh Prison.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Statue/Flesh Prison.prefab",
			["Assets/Prefabs/Enemies/Flesh Prison 2.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Statue/Flesh Panopticon.prefab",
			["Assets/Prefabs/Enemies/Cerberus.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Statue/Cerberus.prefab",
			["Assets/Prefabs/Enemies/SwordsMachineNonboss.prefab"] = "Assets/Prefabs/Enemies/Rewrite/Machine/Swordsmachine.prefab",
			["Assets/Prefabs/Enemies/Spider.prefab"] = "Assets/Prefabs/Enemies/Malicious Face.prefab",
			["Assets/Prefabs/Enemies/Gabriel 2nd Variant.prefab"] = "Assets/Prefabs/Enemies/Gabriel 2nd.prefab"
		};

		public static string FixKey(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return text;
			}
			foreach (KeyValuePair<string, string> replaceKey in replaceKeys)
			{
				text = text.Replace(replaceKey.Key, replaceKey.Value);
			}
			return text;
		}
	}
	public static class Preferences
	{
		private static PrefsManager Prefs => MonoSingleton<PrefsManager>.Instance;

		public static void SetInt(string key, int value)
		{
			Prefs.SetInt(key, value);
		}

		public static int GetInt(string key, int fallback = 0)
		{
			if (PlayerPrefs.HasKey(key))
			{
				int num = PlayerPrefs.GetInt(key);
				Prefs.SetInt(key, num);
				PlayerPrefs.DeleteKey(key);
				return num;
			}
			return Prefs.GetInt(key, fallback);
		}

		public static void SetString(string key, string value)
		{
			Prefs.SetString(key, value);
		}

		public static string GetString(string key, string fallback = null)
		{
			if (PlayerPrefs.HasKey(key))
			{
				string text = PlayerPrefs.GetString(key);
				Prefs.SetString(key, text);
				PlayerPrefs.DeleteKey(key);
				return text;
			}
			return Prefs.GetString(key, fallback);
		}
	}
	public static class TextPatcher
	{
		private static List<(string, string)> patches = new List<(string, string)>(2)
		{
			("<b>", "<b><color=white>"),
			("</b>", "</b></color>")
		};

		public static string Patch(string originalText)
		{
			string text = originalText;
			foreach (var patch in patches)
			{
				text = text.Replace(patch.Item1, patch.Item2);
			}
			return text;
		}
	}
	public static class TimePatcher
	{
		private static float maxValue = 0.1f;

		public static float DeltaTime()
		{
			return Mathf.Min(Time.deltaTime, maxValue);
		}

		public static float UnscaledDeltaTime()
		{
			return Mathf.Min(Time.unscaledDeltaTime, maxValue);
		}
	}
	public static class UnityExtensions
	{
		[SpecialName]
		public sealed class <G>$8F1CC08547E77D955A6D73192FA545FB
		{
			[SpecialName]
			public static class <M>$FBB089F2B221EA509DF4F38D05894EE9
			{
			}

			[ExtensionMarker("<M>$FBB089F2B221EA509DF4F38D05894EE9")]
			public Color ToColor()
			{
				throw new NotSupportedException();
			}
		}

		[SpecialName]
		public sealed class <G>$E097208BAD00A7FA165DB19BE8CEAA48
		{
			[SpecialName]
			public static class <M>$2F5DE5709635644365E6D8FAF0C96A2E
			{
			}

			[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
			public GameObject parent
			{
				[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
				get
				{
					throw new NotSupportedException();
				}
			}

			[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
			public T AddComponent<T>() where T : Component
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
			public void SetActive(bool value)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
			public GameObject Find(string childName)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$2F5DE5709635644365E6D8FAF0C96A2E")]
			public T Find<T>(string childName) where T : Component
			{
				throw new NotSupportedException();
			}
		}

		[SpecialName]
		public sealed class <G>$5E80EE1F91F68F4C0C8D9D82C38C5E67
		{
			[SpecialName]
			public static class <M>$24BC8566157842FEB6EA2D06D7BBA5FC
			{
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public GameObject parent
			{
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				get
				{
					throw new NotSupportedException();
				}
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				set
				{
					throw new NotSupportedException();
				}
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public Vector3 scale
			{
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				get
				{
					throw new NotSupportedException();
				}
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				set
				{
					throw new NotSupportedException();
				}
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public Vector3 rotation
			{
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				get
				{
					throw new NotSupportedException();
				}
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				set
				{
					throw new NotSupportedException();
				}
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public Vector3 position
			{
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				get
				{
					throw new NotSupportedException();
				}
				[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
				set
				{
					throw new NotSupportedException();
				}
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public T GetOrAddComponent<T>() where T : Component
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public GameObject Find(string childPath)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public T Find<T>(string childPath) where T : Component
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public static T Create<T>(string name) where T : Component
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public static T Create<T>(string name, Transform parent, bool active = true) where T : Component
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$24BC8566157842FEB6EA2D06D7BBA5FC")]
			public static GameObject FindObject(string Path, Scene? scene = null)
			{
				throw new NotSupportedException();
			}
		}

		public static Color ToColor(this Vector3 vector)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			return new Color(vector.x / 255f, vector.y / 255f, vector.z / 255f);
		}

		public static GameObject get_parent(Component comp)
		{
			Transform parent = comp.transform.parent;
			return (parent != null) ? ((Component)parent).gameObject : null;
		}

		public static T AddComponent<T>(this Component comp) where T : Component
		{
			return comp.gameObject.AddComponent<T>();
		}

		public static void SetActive(this Component comp, bool value)
		{
			comp.gameObject.SetActive(value);
		}

		public static GameObject Find(this Component comp, string childName)
		{
			Transform obj = comp.transform.Find(childName);
			return (obj != null) ? ((Component)obj).gameObject : null;
		}

		public static T Find<T>(this Component comp, string childName) where T : Component
		{
			GameObject obj = comp.Find(childName);
			return (obj != null) ? obj.GetComponent<T>() : default(T);
		}

		public static GameObject get_parent(GameObject obj)
		{
			return ((Component)obj.transform.parent).gameObject;
		}

		public static void set_parent(GameObject obj, GameObject value)
		{
			obj.transform.parent = value.transform;
		}

		public static Vector3 get_scale(GameObject obj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return obj.transform.localScale;
		}

		public static void set_scale(GameObject obj, Vector3 value)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			obj.transform.localScale = value;
		}

		public static Vector3 get_rotation(GameObject obj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return obj.transform.eulerAngles;
		}

		public static void set_rotation(GameObject obj, Vector3 value)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			obj.transform.eulerAngles = value;
		}

		public static Vector3 get_position(GameObject obj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return obj.transform.position;
		}

		public static void set_position(GameObject obj, Vector3 value)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			obj.transform.position = value;
		}

		public static T GetOrAddComponent<T>(this GameObject obj) where T : Component
		{
			return obj.GetComponent<T>() ?? obj.AddComponent<T>();
		}

		public static GameObject Find(this GameObject obj, string childPath)
		{
			Transform obj2 = obj.transform.Find(childPath);
			return (obj2 != null) ? ((Component)obj2).gameObject : null;
		}

		public static T Find<T>(this GameObject obj, string childPath) where T : Component
		{
			GameObject obj2 = obj.Find(childPath);
			return (obj2 != null) ? obj2.GetComponent<T>() : default(T);
		}

		public static T Create<T>(string name) where T : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject(name).AddComponent<T>();
		}

		public static T Create<T>(string name, Transform parent, bool active = true) where T : Component
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_002b: 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)
			GameObject val = new GameObject(name);
			if (!active)
			{
				val.SetActive(false);
			}
			val.transform.SetParent(parent);
			val.transform.localPosition = Vector3.zero;
			val.transform.localScale = Vector3.one;
			return val.AddComponent<T>();
		}

		public static GameObject FindObject(string Path, Scene? scene = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Scene value = scene.GetValueOrDefault();
			if (!scene.HasValue)
			{
				value = SceneManager.GetSceneAt(0);
				scene = value;
			}
			string rootSearchObj = Path;
			if (Path.IndexOf('/') != -1)
			{
				rootSearchObj = Path.Substring(0, Path.IndexOf('/'));
				Path = Path.Substring(Path.IndexOf('/') + 1);
			}
			value = scene.Value;
			GameObject val = (from g in ((Scene)(ref value)).GetRootGameObjects()
				where ((Object)g).name == rootSearchObj
				select g).FirstOrDefault();
			object result;
			if (Path.IndexOf('/') != -1)
			{
				Transform obj = val.transform.Find(Path);
				result = ((obj != null) ? ((Component)obj).gameObject : null);
			}
			else
			{
				result = val;
			}
			return (GameObject)result;
		}
	}
}
namespace UltraEditor.Classes
{
	public class AssetFolder : MonoBehaviour
	{
		public string folderPath;

		public string folderName;

		public TMP_Text folderNameText;

		public void Start()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (!string.IsNullOrEmpty(folderPath))
			{
				folderNameText.text = folderName;
			}
			Button component = ((Component)this).GetComponent<Button>();
			if (component != null)
			{
				((UnityEvent)component.onClick).AddListener((UnityAction)delegate
				{
					AssetsWindowManager.Instance.CurrentFolder = folderPath;
					AssetsWindowManager.Instance.Refresh();
				});
			}
		}
	}
	public class AssetItem : MonoBehaviour
	{
		public string assetPath;

		public string assetName;

		public TMP_Text assetNameText;

		public GameObject assetItemObject;

		public Image assetItemPreview;

		public static Dictionary<string, Sprite> cachedPreviews = new Dictionary<string, Sprite>();

		public void Start()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			assetNameText.text = assetName;
			Button component = ((Component)this).GetComponent<Button>();
			if (component == null)
			{
				return;
			}
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				if (AssetsWindowManager.Instance.CurrentFolder.StartsWith("Search"))
				{
					AssetsWindowManager.Instance.CurrentFolder = Path.GetDirectoryName(assetPath).Replace('\\', '/') + "/";
					AssetsWindowManager.Instance.Refresh();
				}
				EditorManager.Instance.SpawnAsset(assetPath);
			});
		}

		public void SetPreview(string path)
		{
			((MonoBehaviour)this).StartCoroutine(WaitForPreview(path));
		}

		private IEnumerator WaitForPreview(string path)
		{
			if ((Object)(object)assetItemPreview == (Object)null)
			{
				yield break;
			}
			if (cachedPreviews.TryGetValue(path, out var cachedAsset))
			{
				assetItemPreview.sprite = cachedAsset;
				yield break;
			}
			Sprite spr = BundlesManager.editorBundle.LoadAsset<Sprite>(path.Replace("/", "-"));
			if ((Object)(object)spr != (Object)null)
			{
				assetItemPreview.sprite = spr;
				cachedPreviews[path] = assetItemPreview.sprite;
				yield break;
			}
			GameObject previewObj = EditorManager.Instance.SpawnAsset(path, isLoading: true);
			SetLayerRecursively(previewObj, LayerMask.NameToLayer("Invisible"));
			Bounds b = GetBoundsRecursive(previewObj);
			_ = ((Bounds)(ref b)).center;
			float size = Mathf.Max(new float[3]
			{
				((Bounds)(ref b)).extents.x,
				((Bounds)(ref b)).extents.y,
				((Bounds)(ref b)).extents.z
			});
			float distance = 5f;
			if (size > 5f)
			{
				distance = 15f;
			}
			previewObj.transform.position = new Vector3(0f, -10000f, distance);
			if (size > 5f)
			{
				previewObj.transform.Rotate(0f, 180f, 0f);
			}
			((Behaviour)AssetsWindowManager.Instance.PreviewCamera).enabled = false;
			AssetsWindowManager.Instance.PreviewCamera.Render();
			assetItemPreview.sprite = RenderTextureToSprite(AssetsWindowManager.Instance.PreviewTexture);
			cachedPreviews[path] = assetItemPreview.sprite;
			Object.DestroyImmediate((Object)(object)previewObj);
		}

		public static void SetLayerRecursively(GameObject obj, int layer)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			obj.layer = layer;
			foreach (Transform item in obj.transform)
			{
				Transform val = item;
				SetLayerRecursively(((Component)val).gameObject, layer);
			}
		}

		public Bounds GetBoundsRecursive(GameObject go)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length == 0)
			{
				return new Bounds(go.transform.position, Vector3.one);
			}
			Bounds bounds = componentsInChildren[0].bounds;
			for (int i = 1; i < componentsInChildren.Length; i++)
			{
				((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds);
			}
			return bounds;
		}

		public static Sprite RenderTextureToSprite(RenderTexture rt)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_003b: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = rt;
			Texture2D val = new Texture2D(((Texture)rt).width, ((Texture)rt).height, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)rt).width, (float)((Texture)rt).height), 0, 0);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)0;
			RenderTexture.active = active;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	public class AssetsWindowManager : MonoBehaviour
	{
		public static AssetsWindowManager Instance;

		public static bool HasChangedFolder;

		public const string StartingFolder = "Assets/UltraEditor/";

		public Camera PreviewCamera;

		public RenderTexture PreviewTexture;

		public Light PreviewLight;

		public AssetItem Template;

		public AssetFolder FolderTemplate;

		public TextMeshProUGUI AssetsFolderPathText;

		private TMP_InputField SearchField;

		[HideInInspector]
		public string CurrentFolder;

		public static Dictionary<string, List<string>> Folders = new Dictionary<string, List<string>>();

		public static Dictionary<string, Color> ItemColorListeners = new Dictionary<string, Color>();

		public static List<string> BlacklistedKeys = new List<string>();

		public void Awake()
		{
			Instance = this;
		}

		public void Start()
		{
			CurrentFolder = "Assets/UltraEditor/";
			Animator componentInParent = ((Component)this).GetComponentInParent<Animator>();
			componentInParent.speed *= 2f;
			FuckingKillEveryone();
			CreatePreviewCamera();
			Refresh();
		}

		public void FuckingKillEveryone()
		{
			SearchField = ((Component)((Component)this).transform.parent.Find("Field").GetChild(0)).GetComponent<TMP_InputField>();
			((UnityEvent<string>)(object)SearchField.onSubmit).AddListener((UnityAction<string>)delegate(string _)
			{
				SearchFor(_);
			});
		}

		public void PreviousFolder()
		{
			if (CurrentFolder.StartsWith("Search"))
			{
				CurrentFolder = "Assets/UltraEditor/";
			}
			else
			{
				string currentFolder = CurrentFolder;
				int num = currentFolder.Substring(0, currentFolder.Length - 1).LastIndexOf('/') + 1;
				if (num == 0)
				{
					return;
				}
				CurrentFolder = CurrentFolder.Substring(0, num);
			}
			Refresh();
			if (!HasChangedFolder)
			{
				WarnAboutFolders();
			}
		}

		public void SearchFor(string search)
		{
			if (search == "")
			{
				CurrentFolder = "Assets/UltraEditor/";
				Refresh();
				return;
			}
			search = search.ToLower();
			List<string> prefabAddressableKeys = AssHelper.GetPrefabAddressableKeys((string key) => !BlacklistedKeys.Contains(key) && Path.GetFileNameWithoutExtension(key.ToLower()).Contains(search));
			List<string> folders = Folders.Keys.Where((string f) => Path.GetFileNameWithoutExtension(f.Substring(0, f.Length - 1).ToLower()).Contains(search)).ToList();
			CurrentFolder = "Search: " + search;
			Refresh(prefabAddressableKeys, folders);
			if (!HasChangedFolder)
			{
				WarnAboutFolders();
			}
		}

		public void Refresh(List<string> keys = null, List<string> folders = null)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			if (keys == null && !Folders.TryGetValue(CurrentFolder, out keys))
			{
				return;
			}
			for (int i = 2; i < ((Component)this).transform.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)((Component)this).transform.GetChild(i)).gameObject);
			}
			if (folders == null)
			{
				folders = Folders.Keys.Where((string text2) => text2.StartsWith(CurrentFolder) && text2.Substring(CurrentFolder.Length).Occurrences('/') == 1).ToList();
			}
			foreach (string folder in folders)
			{
				AssetFolder assetFolder = Object.Instantiate<AssetFolder>(FolderTemplate, ((Component)this).transform);
				assetFolder.folderPath = folder;
				string text = folder;
				assetFolder.folderName = Path.GetFileNameWithoutExtension(text.Substring(0, text.Length - 1));
				((Component)assetFolder).gameObject.SetActive(true);
			}
			foreach (string key2 in keys)
			{
				AssetItem assetItem = Object.Instantiate<AssetItem>(Template, ((Component)this).transform);
				assetItem.assetName = Path.GetFileNameWithoutExtension(key2);
				assetItem.assetPath = key2;
				string key = Path.GetDirectoryName(key2).Replace('\\', '/') + "/";
				if (ItemColorListeners.TryGetValue(key, out var value) || ItemColorListeners.TryGetValue(key2, out value))
				{
					((Graphic)((Component)assetItem).GetComponent<Image>()).color = value;
				}
				((Component)assetItem).gameObject.SetActive(true);
				if (CurrentFolder == "Assets/UltraEditor/" && EditorManager.canOpenEditor)
				{
					assetItem.SetPreview(key2);
				}
				else
				{
					((Component)assetItem.assetItemPreview).gameObject.SetActive(false);
				}
			}
			((TMP_Text)AssetsFolderPathText).text = CurrentFolder;
			((MonoBehaviour)this).StartCoroutine(((Component)((Component)this).transform.parent.Find("Scrollbar")).GetComponent<ResetScrollbar>().Reset());
		}

		public void WarnAboutFolders()
		{
			HasChangedFolder = true;
			EditorManager.Instance.SetAlert("Some external assets can break your game and force you to restart if you don't know what you're doing, please experiment with pacience.", "Warning!");
		}

		public void CreatePreviewCamera()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0018: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			PreviewTexture = new RenderTexture(100, 100, 16);
			PreviewCamera = new GameObject("Preview camera").AddComponent<Camera>();
			((Component)PreviewCamera).transform.position = new Vector3(0f, -10000f, 0f);
			PreviewCamera.cullingMask = LayerMask.GetMask(new string[1] { "Invisible" });
			PreviewCamera.forceIntoRenderTexture = true;
			PreviewCamera.targetTexture = PreviewTexture;
			((Behaviour)PreviewCamera).enabled = false;
			PreviewCamera.clearFlags = (CameraClearFlags)2;
			PreviewCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
			PreviewLight = ((Component)PreviewCamera).gameObject.AddComponent<Light>();
			PreviewLight.type = (LightType)0;
			PreviewLight.range = 250f;
			PreviewLight.spotAngle = 120f;
			PreviewLight.cullingMask = LayerMask.GetMask(new string[1] { "Invisible" });
		}

		public static void Load()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			RegisterItemColorListener(new Color(1f, 1f, 0f), new List<string>(3) { "Assets/Prefabs/Levels/Special Rooms/", "Assets/Prefabs/Levels/", "Bonus" });
			RegisterItemColorListener(new Color(0f, 0.9f, 1f), new List<string>(3) { "Assets/Prefabs/Levels/Interactive/", "AltarBlueOff", "AltarRedOff" });
			RegisterItemColorListener(new Color(0.25f, 1f, 0.75f), new List<string>(1) { "Assets/Prefabs/Levels/Obstacles/" });
			RegisterItemColorListener(new Color(0.5f, 0.4f, 1f), new List<string>(1) { "Assets/Prefabs/Levels/Decorations/" });
			RegisterItemColorListener(new Color(0.4f, 0f, 0.4f), new List<string>(1) { "Assets/Prefabs/Levels/Doors/" });
			RegisterItemColorListener(new Color(1f, 0.2f, 0.2f), new List<string>(1) { "Assets/Prefabs/Enemies/" });
			BlacklistedKeys.AddRange(new <>z__ReadOnlyArray<string>(new string[5] { "FirstRoom", "FirstRoom Pit", "FirstRoom Player Only", "FirstRoom Prime", "FirstRoom Secret" }));
			LoadFolders();
			LoadDefaultAssets();
		}

		public static void RegisterItemColorListener(Color col, [ParamCollection] List<string> keyFolders)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			keyFolders.ForEach(delegate(string kF)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				ItemColorListeners.Add(kF, col);
			});
		}

		public static void LoadFolders()
		{
			List<string> keys = AssHelper.GetPrefabAddressableKeys((string key) => !BlacklistedKeys.Contains(key));
			foreach (string item in keys)
			{
				string text = Path.GetDirectoryName(item).Replace('\\', '/') + "/";
				if (Folders.ContainsKey(text))
				{
					continue;
				}
				Folders.Add(text, GetAssetsInFolder(text));
				string text2 = text;
				foreach (int item2 in text2.Substring(0, text2.Length - 1).Occurences('/'))
				{
					string text3 = text.Substring(0, item2 + 1);
					if (!Folders.ContainsKey(text3))
					{
						Folders.TryAdd(text3, GetAssetsInFolder(text3));
					}
				}
			}
			List<string> GetAssetsInFolder(string folder)
			{
				return keys.Where((string key) => key.StartsWith(folder) && !key.Substring(folder.Length).Contains('/')).Concat((folder == "Assets/") ? GetAssetsInFolder("") : new List<string>()).ToList();
			}
		}

		public static void LoadDefaultAssets()
		{
			Folders.Add("Assets/UltraEditor/", new List<string>(145)
			{
				"Assets/Prefabs/Enemies/Zombie.prefab", "Assets/Prefabs/Enemies/Projectile Zombie.prefab", "Assets/Prefabs/Enemies/Super Projectile Zombie.prefab", "Assets/Prefabs/Enemies/ShotgunHusk.prefab", "Assets/Prefabs/Enemies/MinosBoss.prefab", "Assets/Prefabs/Enemies/Stalker.prefab", "Assets/Prefabs/Enemies/Sisyphus.prefab", "Assets/Prefabs/Enemies/Ferryman.prefab", "Assets/Prefabs/Enemies/MirrorReaperCyberGrind.prefab", "Assets/Prefabs/Enemies/SwordsMachineNonboss.prefab",
				"Assets/Prefabs/Enemies/Drone.prefab", "Assets/Prefabs/Enemies/Streetcleaner.prefab", "Assets/Prefabs/Enemies/V2.prefab", "Assets/Prefabs/Enemies/Mindflayer.prefab", "Assets/Prefabs/Enemies/V2 Green Arm Variant.prefab", "Assets/Prefabs/Enemies/Turret.prefab", "Assets/Prefabs/Enemies/Gutterman.prefab", "Assets/Prefabs/Enemies/Guttertank.prefab", "Assets/Prefabs/Enemies/Spider.prefab", "Assets/Prefabs/Enemies/Cerberus.prefab",
				"Assets/Prefabs/Enemies/CerberusStatue.prefab", "Assets/Prefabs/Enemies/Mass.prefab", "Assets/Prefabs/Enemies/Idol.prefab", "Assets/Prefabs/Enemies/Mannequin.prefab", "Assets/Prefabs/Enemies/MannequinPoserWithEnemy.prefab", "Assets/Prefabs/Enemies/Minotaur.prefab", "Assets/Prefabs/Enemies/Deathcatcher.prefab", "Assets/Prefabs/Enemies/DeathcatcherCase.prefab", "Assets/Prefabs/Enemies/DeathcatcherClosed.prefab", "Assets/Prefabs/Enemies/Gabriel.prefab",
				"Assets/Prefabs/Enemies/Virtue.prefab", "Assets/Prefabs/Enemies/Gabriel 2nd Variant.prefab", "Assets/Prefabs/Enemies/Providence.prefab", "Assets/Prefabs/Enemies/Power.prefab", "Assets/Prefabs/Enemies/PowerWithSpawnEffect.prefab", "Assets/Prefabs/Enemies/Cancerous Rodent.prefab", "Assets/Prefabs/Enemies/Very Cancerous Rodent.prefab", "Assets/Prefabs/Enemies/Mandalore.prefab", "Assets/Prefabs/Enemies/Big Johninator.prefab", "Assets/Prefabs/Enemies/Flesh Prison.prefab",
				"Assets/Prefabs/Enemies/Flesh Prison 2.prefab", "Assets/Prefabs/Enemies/MinosPrime.prefab", "Assets/Prefabs/Enemies/SisyphusPrime.prefab", "Assets/Prefabs/Enemies/Puppet.prefab", "Assets/Prefabs/Enemies/SwordsMachine Agony.prefab", "Assets/Prefabs/Enemies/SwordsMachine Tundra.prefab", "Assets/Prefabs/Enemies/CentaurRocketLauncher.prefab", "Assets/Prefabs/Enemies/Brain.prefab", "Assets/Prefabs/Enemies/CentaurTower.prefab", "Assets/Prefabs/Enemies/CentaurMortar.prefab",
				"Assets/Prefabs/Levels/Decorations/SuicideTreeHungry.prefab", "Assets/Prefabs/Levels/Interactive/Altar (Blue).prefab", "AltarBlueOff", "Assets/Prefabs/Levels/Interactive/Altar (Red).prefab", "AltarRedOff", "Assets/Prefabs/Levels/Interactive/Altar (Torch) Variant.prefab", "Assets/Prefabs/Levels/Interactive/Altar.prefab", "Assets/Prefabs/Levels/Interactive/Breakable.prefab", "Assets/Prefabs/Levels/Interactive/Crate.prefab", "Assets/Prefabs/Levels/Interactive/GrapplePoint.prefab",
				"Assets/Prefabs/Levels/Interactive/GrapplePointSlingshot Variant.prefab", "Assets/Prefabs/Levels/Interactive/JumpPad.prefab", "Assets/Prefabs/Levels/Interactive/Plank.prefab", "Assets/Prefabs/Levels/Interactive/GlassFloor.prefab", "Assets/Prefabs/Levels/Interactive/GlassWall.prefab", "Assets/Prefabs/Levels/Interactive/ChandelierFerry.prefab", "Assets/Prefabs/Fishing/Fish Pickup Template.prefab", "DuvizPlushFixed", "Assets/Prefabs/Items/Florp Throwable.prefab", "Assets/Prefabs/Items/KITR.prefab",
				"Assets/Prefabs/Levels/Interactive/ElectricityBox.prefab", "Assets/Prefabs/Sandbox/Procedural Water Brush.prefab", "Assets/Prefabs/Sandbox/Lava.prefab", "Assets/Prefabs/Sandbox/Procedural Hot Sand.prefab", "BlackholeChaos/Blackhole", "BlackholeChaos/Whitehole", "Assets/Prefabs/Levels/Obstacles/Grinders.prefab", "Assets/Prefabs/Levels/Obstacles/EnergyBeamHuge.prefab", "Assets/Prefabs/Levels/Obstacles/Fan.prefab", "Assets/Prefabs/Levels/Decorations/Metro Chair.prefab",
				"Assets/Prefabs/Levels/Decorations/Metro Chair Double.prefab", "Assets/Prefabs/Levels/Decorations/Metro Light.prefab", "Assets/Prefabs/Levels/Decorations/Metro Light Ground.prefab", "Assets/Prefabs/Levels/Decorations/Pipes.prefab", "Assets/Prefabs/Levels/Decorations/PipeMulch.prefab", "Assets/Prefabs/Levels/Decorations/Skeleton.prefab", "Assets/Prefabs/Levels/Decorations/SkeletonStake.prefab", "Assets/Prefabs/Levels/Decorations/Speaker (Noise).prefab", "Assets/Prefabs/Levels/Decorations/SpiralPillar.prefab", "Assets/Prefabs/Levels/Decorations/Streetlight.prefab",
				"Assets/Prefabs/Levels/Decorations/Bed.prefab", "Assets/Prefabs/Levels/Decorations/CeilingLantern.prefab", "Assets/Prefabs/Levels/Decorations/CandlePile.prefab", "Assets/Prefabs/Levels/Decorations/Arch.prefab", "Assets/Prefabs/Levels/Decorations/Chair.prefab", "Assets/Prefabs/Levels/Decorations/Furnace.prefab", "Assets/Prefabs/Levels/Decorations/Tree 1.prefab", "Assets/Prefabs/Levels/Decorations/Tree 2.prefab", "Assets/Prefabs/Levels/Decorations/Tree 3.prefab", "Assets/Prefabs/Levels/Decorations/Tree 1 Off.prefab",
				"Assets/Prefabs/Levels/Decorations/Tree 2 Off.prefab", "Assets/Prefabs/Levels/Decorations/Tree 3 Off.prefab", "Assets/Prefabs/Levels/Decorations/TreeFake 1.prefab", "Assets/Prefabs/Levels/Decorations/TreeFake 2.prefab", "Assets/Prefabs/Levels/Decorations/TreeFake 1.prefab", "Assets/Prefabs/Levels/Decorations/Vent.prefab", "Assets/Prefabs/Levels/Decorations/Clock.prefab", "Assets/Prefabs/Levels/Decorations/Crane.prefab", "Assets/Prefabs/Levels/Decorations/GrossHand.prefab", "Assets/Prefabs/Levels/Decorations/HarborLight.prefab",
				"Assets/Prefabs/Levels/Decorations/SuicideTree1.prefab", "Assets/Prefabs/Levels/Decorations/SuicideTree2.prefab", "Assets/Prefabs/Levels/Decorations/SuicideTree3.prefab", "Assets/Prefabs/Levels/Decorations/SuicideTreeHungry.prefab(Active)", "Assets/Prefabs/Levels/Decorations/Water Well.prefab", "ImCloudingIt", "Assets/Models/Enemies/Centaur/CentaurFull/Midpoly/Centaur_MidPoly.fbx", "Assets/Prefabs/Levels/Decorations/BigGas.prefab", "Assets/Particles/Environment/GasParticleSquare.prefab", "Assets/Particles/Environment/GasParticle.prefab",
				"Assets/Particles/Fire.prefab", "Assets/Prefabs/Levels/Doors/Barrier.prefab", "Assets/Prefabs/Levels/Doors/BunkerDoor.prefab", "Assets/Prefabs/Levels/Doors/Door (Large) With Controllers.prefab", "Assets/Prefabs/Levels/Doors/DoorGreed.prefab", "Assets/Prefabs/Levels/Doors/DoorLust.prefab", "Assets/Prefabs/Levels/Doors/DoorMouth.prefab", "Assets/Prefabs/Levels/Doors/FerryDoor.prefab", "Assets/Prefabs/Levels/Doors/GardenDoor.prefab", "Assets/Prefabs/Levels/Doors/GardenDoorBig.prefab",
				"Assets/Prefabs/Levels/Doors/GothicDoor.prefab", "Assets/Prefabs/Levels/Doors/Limbo Large Door.prefab", "Assets/Prefabs/Levels/Doors/Limbo Large Door Smaller.prefab", "Assets/Prefabs/Levels/Doors/Limbo Large Door Smallest.prefab", "Assets/Prefabs/Levels/Doors/MetroBlockDoor.prefab", "Assets/Prefabs/Levels/Doors/Underwater Tunnel.prefab", "Assets/Prefabs/Levels/Doors/ViolenceHallDoor.prefab", "Assets/Prefabs/Levels/Doors/Wrath Circular Door.prefab", "Assets/Prefabs/Levels/Doors/Hellgate 1.prefab", "Assets/Prefabs/Levels/Special Rooms/FinalRoom.prefab",
				"Assets/Prefabs/Levels/Checkpoint.prefab", "Bonus", "Assets/Prefabs/Levels/BonusDualWield Variant.prefab", "Assets/Prefabs/Levels/BonusSuperCharge.prefab", "Assets/Prefabs/Levels/DualWieldPowerup.prefab"
			});
		}
	}
	public class Billboard : MonoBehaviour
	{
		public static List<Billboard> billboards = new List<Billboard>();

		public static Sprite entitySprite = null;

		public static Sprite activateArena = null;

		public static Sprite activateNextWave = null;

		public static Sprite activateObject = null;

		public static Sprite deathzone = null;

		public static Sprite hudMessageObject = null;

		public static Sprite levelInfoObject = null;

		public static Sprite light = null;

		public static Sprite musicObject = null;

		public static Sprite teleportObject = null;

		public static Sprite checkpoint = null;

		public static Sprite cubeTilingAnimator = null;

		public static Sprite animator = null;

		public static Sprite sfxObject = null;

		public static Sprite skullTrigger = null;

		public static Sprite bookObject = null;

		public static Component[] lastComponents = Array.Empty<Component>();

		private static Shader shader = Shader.Find("Sprites/Default");

		public static List<(Sprite, Material, Vector3)> materials = new List<(Sprite, Material, Vector3)>();

		public GameObject target;

		public SphereCollider col;

		public static void DeleteAll()
		{
			foreach (Billboard item in billboards.ToList())
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)item).gameObject);
				}
			}
			billboards.Clear();
		}

		public static void UpdateBillboards()
		{
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			if (Preferences.GetInt("Billboards", 1) == 0)
			{
				DeleteAll();
				return;
			}
			if ((Object)(object)entitySprite == (Object)null)
			{
				entitySprite = BundlesManager.editorBundle.LoadAsset<Sprite>("entity");
				activateArena = BundlesManager.editorBundle.LoadAsset<Sprite>("ActivateArena");
				activateNextWave = BundlesManager.editorBundle.LoadAsset<Sprite>("ActivateNextWave");
				Billboard.activateObject = BundlesManager.editorBundle.LoadAsset<Sprite>("ActivateObject");
				deathzone = BundlesManager.editorBundle.LoadAsset<Sprite>("deathzone");
				hudMessageObject = BundlesManager.editorBundle.LoadAsset<Sprite>("hudMessageObject");
				Billboard.levelInfoObject = BundlesManager.editorBundle.LoadAsset<Sprite>("info");
				light = BundlesManager.editorBundle.LoadAsset<Sprite>("light");
				Billboard.musicObject = BundlesManager.editorBundle.LoadAsset<Sprite>("music");
				checkpoint = BundlesManager.editorBundle.LoadAsset<Sprite>("checkpoint");
				Billboard.cubeTilingAnimator = BundlesManager.editorBundle.LoadAsset<Sprite>("cubeTilingAnimator");
				animator = BundlesManager.editorBundle.LoadAsset<Sprite>("animator");
				sfxObject = BundlesManager.editorBundle.LoadAsset<Sprite>("sfxObject");
				skullTrigger = BundlesManager.editorBundle.LoadAsset<Sprite>("skullTrigger");
				Billboard.bookObject = BundlesManager.editorBundle.LoadAsset<Sprite>("book");
			}
			Component[] array = Object.FindObjectsOfType<Component>(true);
			if (lastComponents == array)
			{
				return;
			}
			lastComponents = array;
			DeleteAll();
			Component[] array2 = array;
			foreach (Component val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Vector3 position = val.transform.position;
				Component val2 = val;
				Component val3 = val2;
				if (!(val3 is PrefabObject prefabObject))
				{
					ActivateArena val4 = (ActivateArena)(object)((val3 is ActivateArena) ? val3 : null);
					if (val4 == null)
					{
						ActivateNextWave val5 = (ActivateNextWave)(object)((val3 is ActivateNextWave) ? val3 : null);
						if (val5 == null)
						{
							if (!(val3 is ActivateObject))
							{
								DeathZone val6 = (DeathZone)(object)((val3 is DeathZone) ? val3 : null);
								if (val6 == null)
								{
									if (!(val3 is HUDMessageObject))
									{
										if (!(val3 is LevelInfoObject))
										{
											Light val7 = (Light)(object)((val3 is Light) ? val3 : null);
											if (val7 == null)
											{
												if (!(val3 is MusicObject))
												{
													if (!(val3 is TeleportObject))
													{
														if (!(val3 is CheckpointObject))
														{
															if (!(val3 is CubeTilingAnimator))
															{
																if (!(val3 is MovingPlatformAnimator))
																{
																	if (!(val3 is SFXObject))
																	{
																		if (!(val3 is SkullActivatorObject))
																		{
																			if (val3 is BookObject)
																			{
																				NewBillboard(Billboard.bookObject, position, val.gameObject);
																			}
																		}
																		else
																		{
																			NewBillboard(skullTrigger, position, val.gameObject);
																		}
																	}
																	else
																	{
																		NewBillboard(sfxObject, position, val.gameObject);
																	}
																}
																else
																{
																	NewBillboard(animator, position, val.gameObject);
																}
															}
															else
															{
																NewBillboard(Billboard.cubeTilingAnimator, position, val.gameObject);
															}
														}
														else
														{
															NewBillboard(checkpoint, position, val.gameObject);
														}
													}
													else
													{
														NewBillboard(Billboard.teleportObject, position, val.gameObject);
													}
												}
												else
												{
													NewBillboard(Billboard.musicObject, position, val.gameObject);
												}
											}
											else if ((Object)(object)((Component)val7).GetComponent<SavableObject>() != (Object)null && (Object)(object)((Component)val7).GetComponent<PrefabObject>() == (Object)null)
											{
												NewBillboard(light, position, val.gameObject);
											}
										}
										else
										{
											NewBillboard(Billboard.levelInfoObject, position, val.gameObject);
										}
									}
									else
									{
										NewBillboard(hudMessageObject, position, val.gameObject);
									}
								}
								else if ((Object)(object)((Component)val6).GetComponent<SavableObject>() != (Object)null)
								{
									NewBillboard(deathzone, position, val.gameObject);
								}
							}
							else
							{
								NewBillboard(Billboard.activateObject, position, val.gameObject);
							}
						}
						else
						{
							NewBillboard(activateNextWave, position, val.gameObject);
						}
					}
					else
					{
						NewBillboard(activateArena, position, val.gameObject);
					}
				}
				else if (prefabObject.PrefabAsset.StartsWith("Assets/Prefabs/Enemies/"))
				{
					NewBillboard(entitySprite, position, val.gameObject);
				}
			}
		}

		public static void NewBillboard(Sprite spr, Vector3 pos, GameObject target)
		{
			//IL_019b: 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_008c: Expected O, but got Unknown
			//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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			val.AddComponent<Billboard>();
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			Renderer component = val.GetComponent<Renderer>();
			if (!Object.op_Implicit((Object)(object)shader))
			{
				Debug.LogError((object)"Sprites/Default shader not found");
				return;
			}
			(Sprite, Material, Vector3) tuple = materials.FirstOrDefault(((Sprite, Material, Vector3) x) => (Object)(object)x.Item1 == (Object)(object)spr);
			if ((Object)(object)tuple.Item2 == (Object)null)
			{
				Material val2 = new Material(shader);
				val2.mainTexture = (Texture)(object)spr.texture;
				Rect rect = spr.rect;
				Texture texture = (Texture)(object)spr.texture;
				val2.mainTextureScale = new Vector2(((Rect)(ref rect)).width / (float)texture.width, ((Rect)(ref rect)).height / (float)texture.height);
				val2.mainTextureOffset = new Vector2(((Rect)(ref rect)).x / (float)texture.width, ((Rect)(ref rect)).y / (float)texture.height);
				component.material = val2;
				float num = ((Rect)(ref rect)).width / spr.pixelsPerUnit;
				float num2 = ((Rect)(ref rect)).height / spr.pixelsPerUnit;
				val.transform.localScale = new Vector3(num, num2, 1f);
				materials.Add((spr, val2, val.transform.localScale));
			}
			else
			{
				component.material = tuple.Item2;
				val.transform.localScale = tuple.Item3;
			}
			val.transform.position = pos;
			val.GetComponent<Billboard>().target = target;
			val.GetComponent<Billboard>().Update();
		}

		public void Awake()
		{
			col = ((Component)this).gameObject.AddComponent<SphereCollider>();
			col.radius = 1f;
			billboards.Add(this);
		}

		public void Update()
		{
			//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_0095: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)EditorManager.Instance == (Object)null)
			{
				DeleteAll();
			}
			if (!EditorManager.Instance.editorCanvas.activeInHierarchy)
			{
				DeleteAll();
			}
			if ((Object)(object)target == (Object)null)
			{
				return;
			}
			Camera editorCamera = EditorManager.Instance.editorCamera;
			if ((Object)(object)editorCamera == (Object)null)
			{
				return;
			}
			((Component)this).transform.LookAt(((Component)editorCamera).transform);
			Renderer component = ((Component)this).GetComponent<Renderer>();
			Color color = component.material.color;
			float num = Math.Clamp(Vector3.Distance(((Component)editorCamera).transform.position, ((Component)this).transform.position) - 1f, 0f, 5f) / (target.activeInHierarchy ? 5f : 20f);
			component.material.color = new Color(color.r, color.g, color.b, num);
			if (Input.GetMouseButtonDown(0) && ((Behaviour)EditorManager.Instance.cameraSelector).enabled && EditorManager.Instance.cameraSelector.selectionMode == CameraSelector.SelectionMode.Cursor)
			{
				Ray val = editorCamera.ScreenPointToRay(Input.mousePosition);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2) && (Object)(object)((RaycastHit)(ref val2)).transform == (Object)(object)((Component)this).transform)
				{
					EditorManager.Instance.cameraSelector.SelectObject(target);
					EditorManager.Instance.lastHierarchy = Array.Empty<GameObject>();
				}
			}
		}
	}
	public static class BundlesManager
	{
		public static AssetBundle editorBundle;

		public static GameObject editorCanvas;

		public static GameObject levelCanvas;

		public static GameObject exploreLevelsCanvas;

		public static GameObject welcomeCanvas;

		public static Shader ghostDottedOutline;

		public static GameObject cloudPrefab;

		public static GameObject pyramidMesh;

		public static GameObject duvizPlushPrefab;

		public static GameObject duvizPlushFixedPrefab;

		public static void Load()
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UltraEditor.Assets.editorcanvas.bundle");
			AssetBundleCreateRequest request = AssetBundle.LoadFromStreamAsync(manifestResourceStream);
			((AsyncOperation)request).completed += delegate
			{
				editorBundle = request.assetBundle;
				if ((Object)(object)editorBundle == (Object)null)
				{
					Plugin.LogError("Failed to load AssetBundle from memory!");
				}
				else
				{
					LoadAssets();
					Plugin.LogInfo("Loaded embedded AssetBundle!");
				}
			};
		}

		public static void LoadAssets()
		{
			editorCanvas = editorBundle.LoadAsset<GameObject>("Assets/Prefabs/EditorCanvas.prefab");
			exploreLevelsCanvas = editorBundle.LoadAsset<GameObject>("ExploreLevelsCanvas");
			welcomeCanvas = editorBundle.LoadAsset<GameObject>("WelcomeCanvas");
			levelCanvas = editorBundle.LoadAsset<GameObject>("OpenLevelCanvas");
			ghostDottedOutline = editorBundle.LoadAsset<Shader>("GhostDottedOutline");
			cloudPrefab = editorBundle.LoadAsset<GameObject>("Cloud");
			pyramidMesh = editorBundle.LoadAsset<GameObject>("PyramidMesh");
			duvizPlushPrefab = editorBundle.LoadAsset<GameObject>("DuvizPlush");
			duvizPlushFixedPrefab = editorBundle.LoadAsset<GameObject>("DuvizPlushFixed");
		}
	}
	public class CameraMovement : MonoBehaviour
	{
		public float movementSpeed = 30f;

		public float mouseSensitivity = 2f;

		public float shiftMultiplier = 3f;

		private (int x, int y) savedMousePos = (x: 0, y: 0);

		public Light unlitLight = null;

		public bool moving()
		{
			return Input.GetMouseButton(1) && Plugin.CanMove() && !EditorManager.Instance.blocker.activeSelf;
		}

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: 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)
			GameObject val = new GameObject("CameraLight");
			val.transform.parent = ((Component)this).transform;
			val.transform.localPosition = Vector3.zero;
			val.transform.localEulerAngles = Vector3.zero;
			unlitLight = val.AddComponent<Light>();
			unlitLight.range = 500f;
			unlitLight.renderMode = (LightRenderMode)1;
			unlitLight.type = (LightType)2;
			((Behaviour)unlitLight).enabled = false;
		}

		public void Update()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.CanMove() && !EditorManager.Instance.blocker.activeSelf)
			{
				float num = movementSpeed * (Input.GetKey((KeyCode)304) ? shiftMultiplier : 1f) * Mathf.Min(Time.unscaledDeltaTime, 0.1f);
				float num2 = Input.GetAxisRaw("Horizontal") * num;
				float num3 = Input.GetAxisRaw("Vertical") * num;
				float num4 = (float)(Input.GetKey((KeyCode)101) ? 1 : (-(Input.GetKey((KeyCode)113) ? 1 : 0))) * num;
				((Component)this).transform.Translate(new Vector3(num2, num4, num3));
				if (Input.GetMouseButtonDown(1))
				{
					savedMousePos = MouseController.GetMousePos();
					Cursor.visible = false;
				}
				if (Input.GetMouseButton(1))
				{
					float num5 = Input.GetAxisRaw("Mouse X") * mouseSensitivity * (EditorManager.sensitivity / 50f);
					float num6 = Input.GetAxisRaw("Mouse Y") * mouseSensitivity * (EditorManager.sensitivity / 50f);
					((Component)this).transform.Rotate(Vector3.up, num5, (Space)0);
					((Component)this).transform.Rotate(Vector3.right, 0f - num6, (Space)1);
					MouseController.SetCursorPos(savedMousePos.x, savedMousePos.y);
				}
			}
		}

		public void setUnlit(bool unlit)
		{
			((Behaviour)unlitLight).enabled = unlit;
		}
	}
	public class CameraSelector : MonoBehaviour
	{
		public enum SelectionMode
		{
			Cursor,
			Move,
			Scale,
			Rotate
		}

		private struct MeshEntry
		{
			public Mesh mesh;

			public Matrix4x4 localToRoot;

			public Material mat;
		}

		public Camera camera;

		public GameObject selectedObject;

		public Material highlightMaterial;

		private GameObject arrowHolder;

		private bool globalArrows = false;

		private SelectionMode _selectionMode = SelectionMode.Cursor;

		private List<MeshEntry> meshes = new List<MeshEntry>();

		public Material ghostMaterial;

		public Material ghostMaterial2;

		private bool objectActive = false;

		private GameObject hoveredObject;

		private Dictionary<GameObject, Material> originalMaterials = new Dictionary<GameObject, Material>();

		private Transform[] moveArrows;

		public bool dragging = false;

		private int draggingAxis = -1;

		private Vector3 dragStartPos;

		private Vector3 objectStartPos;

		private Vector3 objectStartScale;

		private Vector3 objectStartEuler;

		private (int x, int y) savedMousePos = (x: 0, y: 0);

		private Vector2 realMousePos = Vector2.zero;

		public Vector3 startPos;

		private float timeToUpdate = 0.1f;

		private float scaleMultiplier = 1f;

		private Vector3 currentArrowRot = Vector3.zero;

		public SelectionMode selectionMode
		{
			get
			{
				return _selectionMode;
			}
			set
			{
				if (value == SelectionMode.Cursor)
				{
					DeleteArrows();
				}
				if (value != SelectionMode.Cursor)
				{
					ClearHover();
				}
				_selectionMode = value;
				ModeButton.UpdateButtons();
			}
		}

		private void CacheMeshes()
		{
			meshes.Clear();
			if (!((Object)(object)selectedObject == (Object)null))
			{
				CacheRecursive(selectedObject.transform, selectedObject.transform);
			}
		}

		private void CacheRecursive(Transform t, Transform root)
		{
			//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_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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0127: 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_0214: Expected O, but got Unknown
			//IL_0226: 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_022e: 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_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			MeshFilter component = ((Component)t).GetComponent<MeshFilter>();
			MeshRenderer component2 = ((Component)t).GetComponent<MeshRenderer>();
			Material mat = ghostMaterial;
			if (((Component)t).gameObject.layer == LayerMask.NameToLayer("Invisible"))
			{
				mat = ghostMaterial;
			}
			if (!((Component)t).gameObject.activeInHierarchy)
			{
				mat = ghostMaterial2;
			}
			if ((Object)(object)((Component)t).GetComponent<PrefabObject>() != (Object)null && ((Component)t).GetComponent<PrefabObject>().PrefabAsset.StartsWith("Assets/Prefabs/Enemies/"))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component.sharedMesh) && (!((Component)t).gameObject.activeInHierarchy || ((Component)t).gameObject.layer == LayerMask.NameToLayer("Invisible")))
			{
				float num = 1f;
				Bounds bounds = component.sharedMesh.bounds;
				Vector3 lossyScale = t.lossyScale;
				Vector3 val = Vector3.Scale(((Bounds)(ref bounds)).size, lossyScale);
				if (Mathf.Max(new float[3] { val.x, val.y, val.z }) > 100f && new Func<SavableObject>(((Component)t).GetComponent<SavableObject>) == null)
				{
					num = 0.01f;
				}
				meshes.Add(new MeshEntry
				{
					mesh = component.sharedMesh,
					localToRoot = root.worldToLocalMatrix * t.localToWorldMatrix * Matrix4x4.Scale(Vector3.one * num),
					mat = mat
				});
			}
			SkinnedMeshRenderer component3 = ((Component)t).GetComponent<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.sharedMesh) && (!((Component)t).gameObject.activeInHierarchy || ((Component)t).gameObject.layer == LayerMask.NameToLayer("Invisible")))
			{
				Mesh val2 = new Mesh();
				component3.BakeMesh(val2);
				float num2 = 1f;
				Bounds bounds2 = val2.bounds;
				Vector3 lossyScale2 = t.lossyScale;
				Vector3 val3 = Vector3.Scale(((Bounds)(ref bounds2)).size, lossyScale2);
				if (Mathf.Max(new float[3] { val3.x, val3.y, val3.z }) > 100f && new Func<SavableObject>(((Component)t).GetComponent<SavableObject>) == null)
				{
					num2 = 0.01f;
				}
				meshes.Add(new MeshEntry
				{
					mesh = val2,
					localToRoot = root.worldToLocalMatrix * t.localToWorldMatrix * Matrix4x4.Scale(Vector3.one * num2),
					mat = mat
				});
			}
			for (int i = 0; i < t.childCount; i++)
			{
				CacheRecursive(t.GetChild(i), root);
			}
		}

		private static Bounds TransformBounds(Bounds b, Matrix4x4 m)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0017: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_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_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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0072: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00c8: 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_00df: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Matrix4x4)(ref m)).MultiplyPoint3x4(((Bounds)(ref b)).center);
			Vector3 extents = ((Bounds)(ref b)).extents;
			Vector3 val2 = ((Matrix4x4)(ref m)).MultiplyVector(new Vector3(extents.x, 0f, 0f));
			Vector3 val3 = ((Matrix4x4)(ref m)).MultiplyVector(new Vector3(0f, extents.y, 0f));
			Vector3 val4 = ((Matrix4x4)(ref m)).MultiplyVector(new Vector3(0f, 0f, extents.z));
			extents.x = Mathf.Abs(val2.x) + Mathf.Abs(val3.x) + Mathf.Abs(val4.x);
			extents.y = Mathf.Abs(val2.y) + Mathf.Abs(val3.y) + Mathf.Abs(val4.y);
			extents.z = Mathf.Abs(val2.z) + Mathf.Abs(val3.z) + Mathf.Abs(val4.z);
			return new Bounds(val, extents * 2f);
		}

		public void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)camera))
			{
				camera = ((Component)this).GetComponent<Camera>();
			}
			arrowHolder = new GameObject("MoveArrow_Holder");
			highlightMaterial = new Material(MonoSingleton<DefaultReferenceManager>.Instance.blankMaterial);
			highlightMaterial.color = new Color(0.5f, 0.5f, 1f);
			ghostMaterial = CreateGhostMaterial(new Color(0.25f, 0.25f, 1f));
			ghostMaterial2 = CreateGhostMaterial(new Color(0.25f, 0.25f, 0.25f));
			ModeButton.UpdateButtons();
		}

		private Material CreateGhostMaterial(Color color, float thickness = 30f)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Shader ghostDottedOutline = BundlesManager.ghostDottedOutline;
			Material val = new Material(ghostDottedOutline);
			val.SetColor("_Color", color);
			val.SetFloat("_Thickness", 0.02f);
			val.SetFloat("_DotScale", thickness);
			val.SetFloat("_DotCutoff", 0f);
			val.SetFloat("_Offset", 0f);
			return val;
		}

		public void Update()
		{
			//IL_0001: 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_002d: 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)
			if (Input.GetKeyDown(Plugin.SelectCursorKey))
			{
				selectionMode = SelectionMode.Cursor;
			}
			if (Input.GetKeyDown(Plugin.SelectMoveKey))
			{
				selectionMode = SelectionMode.Move;
			}
			if (Input.GetKeyDown(Plugin.SelectScaleKey))
			{
				selectionMode = SelectionMode.Scale;
			}
			if (Input.GetKeyDown(Plugin.SelectRotationKey))
			{
				selectionMode = SelectionMode.Rotate;
			}
			if (selectionMode == SelectionMode.Cursor)
			{
				HandleCursor