Decompiled source of TheEnd v0.1.4

TheEndMod.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.GameOver;
using EntityStates.ImpMonster;
using KinematicCharacterController;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TheEndMod.Awakening;
using TheEndMod.Dragon;
using TheEndMod.Enderman;
using TheEndMod.Items;
using TheEndMod.Mobs;
using TheEndMod.Skins;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace TheEndMod
{
	internal static class Assets
	{
		private static Shader hgStandard;

		public static Shader HGStandard
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)hgStandard))
				{
					return hgStandard = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion();
				}
				return hgStandard;
			}
		}

		public static T Load<T>(string address) where T : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<T>((object)address).WaitForCompletion();
		}

		public static Material Lit(string name, Texture2D albedo, Color tint, float smoothness = 0.1f, Texture2D emission = null, Color? emissionColor = null, float emissionPower = 0f)
		{
			//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_0012: Expected O, but got Unknown
			//IL_0024: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(HGStandard)
			{
				name = name
			};
			val.SetTexture("_MainTex", (Texture)(object)albedo);
			val.SetColor("_Color", tint);
			val.SetFloat("_Smoothness", smoothness);
			val.SetFloat("_SpecularStrength", smoothness * 0.5f);
			if (Object.op_Implicit((Object)(object)emission) || emissionColor.HasValue)
			{
				val.EnableKeyword("_EMISSION");
				val.SetTexture("_EmTex", (Texture)(object)(Object.op_Implicit((Object)(object)emission) ? emission : PixelTextures.White));
				val.SetColor("_EmColor", (Color)(((??)emissionColor) ?? Color.white));
				val.SetFloat("_EmPower", emissionPower);
			}
			return val;
		}
	}
	public static class DevCommands
	{
		private static CharacterBody FindDragon()
		{
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && ((Object)readOnlyInstances).name.StartsWith("EnderDragonBody"))
				{
					return readOnlyInstances;
				}
			}
			return null;
		}

		public static string DragonStatus()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = FindDragon();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no dragon";
			}
			DragonController component = ((Component)val).GetComponent<DragonController>();
			return $"dragon pos={val.transform.position:F0} hp={val.healthComponent.combinedHealth:F0}/{val.healthComponent.fullCombinedHealth:F0} mode={component.mode} crystals={EndCrystals.AliveCount} level={val.level}";
		}

		public static string SpawnDragonHere()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no player";
			}
			if (!Object.op_Implicit((Object)(object)DragonBody.Spawn(val.transform.position + val.transform.forward * 50f + Vector3.up * 30f, Quaternion.LookRotation(-val.transform.forward), val.transform.position)))
			{
				return "failed";
			}
			return "spawned";
		}

		public static string DamageDragon(string fraction)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			CharacterBody val = FindDragon();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no dragon";
			}
			float num = float.Parse(fraction, CultureInfo.InvariantCulture);
			val.healthComponent.TakeDamage(new DamageInfo
			{
				damage = val.healthComponent.fullCombinedHealth * num,
				position = val.corePosition,
				damageType = DamageTypeCombo.op_Implicit((DamageType)66),
				procCoefficient = 0f
			});
			return DragonStatus();
		}

		public static string KillCrystals()
		{
			//IL_0024: 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)
			int num = 0;
			foreach (CharacterBody item in EndCrystals.Alive.ToList())
			{
				item.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
				num++;
			}
			return "killed " + num;
		}

		public static string SpawnEndermen(string count)
		{
			return "spawned " + EndermanWaves.SpawnWave(int.Parse(count), "THEEND_ENDERMEN_WAVE1") + " endermen; " + EndermanStatus();
		}

		public static string EndermanStatus()
		{
			IEnumerable<string> values = (from m in EndermanWaves.alive
				select (!Object.op_Implicit((Object)(object)m)) ? null : m.GetBody() into b
				where Object.op_Implicit((Object)(object)b)
				select b).Select(delegate(CharacterBody b)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)b).gameObject, "Weapon");
				return string.Format("{0:F0} hp={1:F0} state={2}", b.transform.position, b.healthComponent.combinedHealth, Object.op_Implicit((Object)(object)val) ? ((object)val.state).GetType().Name : "?");
			});
			return "endermen alive=" + EndermanWaves.alive.Count + " [" + string.Join("; ", values) + "]";
		}

		public static string GiveEgg(string count)
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.inventory))
			{
				return "no player";
			}
			val.inventory.GiveItem(DragonEgg.itemDef, int.Parse(count));
			return "eggs=" + val.inventory.GetItemCountEffective(DragonEgg.itemDef) + " hatchling=" + ((Object)(object)((Component)val).GetComponent<DragonHatchling>() != (Object)null);
		}

		public static string PortalStatus()
		{
			IEnumerable<string> values = Object.FindObjectsOfType<GenericInteraction>().Select(delegate(GenericInteraction g)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				string name = ((Object)g).name;
				Vector3 position = ((Component)g).transform.position;
				return name + "@" + ((Vector3)(ref position)).ToString("F0");
			});
			SceneDef val = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.nextStageScene : null);
			IEnumerable<string> values2 = Object.FindObjectsOfType<GenericPickupController>().Select(delegate(GenericPickupController p)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				PickupIndex pickupIndex = p.pickupIndex;
				return ((PickupIndex)(ref pickupIndex)).GetPickupNameToken();
			});
			int num = Object.FindObjectsOfType<PickupDropletController>().Length;
			return "portals=[" + string.Join(", ", values) + "] next=" + (Object.op_Implicit((Object)(object)val) ? val.cachedName : "null") + " pickups=[" + string.Join(", ", values2) + "] droplets=" + num;
		}

		public static string ForceMode(string mode)
		{
			CharacterBody val = FindDragon();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no dragon";
			}
			((Component)val).GetComponent<DragonController>().DebugForceMode((DragonController.Mode)Enum.Parse(typeof(DragonController.Mode), mode));
			return DragonStatus();
		}

		public static string TeleportPlayer(string xyz)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no player";
			}
			float[] array = (from x in xyz.Split(',')
				select float.Parse(x, CultureInfo.InvariantCulture)).ToArray();
			TeleportHelper.TeleportBody(val, new Vector3(array[0], array[1], array[2]), false);
			return "teleported";
		}

		public static string DumpPrefab(string address)
		{
			GameObject val = Assets.Load<GameObject>(address);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "not found: " + address;
			}
			StringBuilder stringBuilder = new StringBuilder();
			Dump(val.transform, 0, stringBuilder);
			File.WriteAllText(Path.Combine(Paths.BepInExRootPath, "devout", "prefab_" + ((Object)val).name + ".txt"), stringBuilder.ToString());
			return "dumped " + ((Object)val).name;
		}

		private static void Dump(Transform t, int depth, StringBuilder sb)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			string text = new string(' ', depth * 2);
			sb.AppendLine(string.Format("{0}{1} layer={2} pos={3:F2} scale={4:F2}{5}", text, ((Object)t).name, LayerMask.LayerToName(((Component)t).gameObject.layer), t.localPosition, t.localScale, ((Component)t).gameObject.activeSelf ? "" : " (inactive)"));
			Component[] components = ((Component)t).GetComponents<Component>();
			foreach (Component val in components)
			{
				if (!Object.op_Implicit((Object)(object)val) || val is Transform)
				{
					continue;
				}
				sb.Append(text).Append("  - ").AppendLine(((object)val).GetType().FullName);
				if (!(val is MonoBehaviour))
				{
					continue;
				}
				FieldInfo[] fields = ((object)val).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
				foreach (FieldInfo fieldInfo in fields)
				{
					object value;
					try
					{
						value = fieldInfo.GetValue(val);
					}
					catch
					{
						continue;
					}
					Object val2 = (Object)((value is Object) ? value : null);
					string value2 = ((val2 == null) ? ((value is Array array) ? ("[" + string.Join(", ", array.Cast<object>().Take(8).Select(delegate(object x)
					{
						Object val3 = (Object)((x is Object) ? x : null);
						if (val3 == null)
						{
							return x?.ToString();
						}
						return (!Object.op_Implicit(val3)) ? "null" : val3.name;
					})) + ((array.Length > 8) ? ", ..." : "") + "]") : value?.ToString()) : (Object.op_Implicit(val2) ? (val2.name + " (" + ((object)val2).GetType().Name + ")") : "null"));
					sb.Append(text).Append("      ").Append(fieldInfo.Name)
						.Append(" = ")
						.AppendLine(value2);
				}
			}
			for (int num = 0; num < t.childCount; num++)
			{
				Dump(t.GetChild(num), depth + 1, sb);
			}
		}
	}
	public static class DevCommandsEnd
	{
		private static GameObject devMusic;

		private static CharacterBody Player
		{
			get
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser == null)
				{
					return null;
				}
				return firstLocalUser.cachedBody;
			}
		}

		public static string CrystalProbe()
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (!Object.op_Implicit((Object)(object)readOnlyInstances) || (!((Object)readOnlyInstances).name.StartsWith("EndCrystalBody") && !((Object)readOnlyInstances).name.StartsWith("SummoningCrystalBody")))
				{
					continue;
				}
				Transform vis = null;
				Transform[] componentsInChildren = ((Component)readOnlyInstances).GetComponentsInChildren<Transform>();
				foreach (Transform val in componentsInChildren)
				{
					if (((Object)val).name == "Outer" || ((Object)val).name == "Core")
					{
						vis = val;
						break;
					}
				}
				List<HurtBox> list2 = (from h in ((Component)readOnlyInstances).GetComponentsInChildren<HurtBox>()
					where Object.op_Implicit((Object)(object)h.collider) && h.collider.enabled
					select h).ToList();
				string text = (Object.op_Implicit((Object)(object)vis) ? string.Join("/", list2.Select(delegate(HurtBox h)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_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)
					Bounds bounds = h.collider.bounds;
					return Vector3.Distance(((Bounds)(ref bounds)).center, vis.position).ToString("F2");
				})) : "no visual");
				list.Add(string.Format("{0} at {1:F0}: {2} hurtbox(es), offset {3} m", ((Object)readOnlyInstances).name.Replace("(Clone)", ""), readOnlyInstances.transform.position, list2.Count, text));
			}
			return list.Count + " crystals: " + string.Join(" | ", list);
		}

		public static string AwakenStatus()
		{
			if (!Object.op_Implicit((Object)(object)EndAwakening.instance))
			{
				return "no awakening controller";
			}
			return EndAwakening.instance.Status();
		}

		public static string AwakenStep()
		{
			if (!Object.op_Implicit((Object)(object)EndAwakening.instance))
			{
				return "no awakening controller";
			}
			return EndAwakening.instance.DevStep() + "; " + AwakenStatus();
		}

		public static string SkipAwakening()
		{
			if (!Object.op_Implicit((Object)(object)EndAwakening.instance))
			{
				return "no awakening controller";
			}
			EndAwakening.instance.DevShatterAll();
			return "shattering all; " + AwakenStatus();
		}

		public static string SpawnMob(string arg)
		{
			//IL_0059: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return "no player";
			}
			string[] array = (arg ?? "").Split(' ');
			int num = ((array.Length <= 1) ? 1 : int.Parse(array[1]));
			Vector3 val = (Object.op_Implicit((Object)(object)player.inputBank) ? player.inputBank.aimDirection : player.transform.forward);
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
			Vector3 center = player.footPosition + val * 18f;
			int num2 = 0;
			for (int i = 0; i < num; i++)
			{
				CharacterMaster val2 = null;
				if (array[0].ToLowerInvariant() == "warden")
				{
					EndSpawner.FindGround(center, 0f, 10f, out var pos, (HullClassification)0);
					val2 = Warden.SpawnBoss(pos, player.footPosition);
				}
				else
				{
					GameObject masterPrefab = ((array[0].ToLowerInvariant() == "shulker") ? Shulker.masterPrefab : ((array[0].ToLowerInvariant() == "endermite") ? Endermite.masterPrefab : EndermanBody.masterPrefab));
					EndSpawner.FindGround(center, 0f, 8f, out var pos2, (HullClassification)0);
					val2 = EndSpawner.Spawn(masterPrefab, pos2, player.footPosition, null, 1f, 6u, (TeamIndex)2);
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					num2++;
				}
			}
			return $"spawned {num2} {array[0]}; " + MobStatus();
		}

		public static string MobStatus()
		{
			IEnumerable<string> values = CharacterBody.readOnlyInstancesList.Where((CharacterBody b) => Object.op_Implicit((Object)(object)b) && (((Object)b).name.StartsWith("Shulker") || ((Object)b).name.StartsWith("Endermite") || ((Object)b).name.StartsWith("ObsidianWarden") || ((Object)b).name.StartsWith("EndermanBody"))).Select(delegate(CharacterBody b)
			{
				//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
				EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)b).gameObject, "Weapon");
				EntityStateMachine val2 = EntityStateMachine.FindByCustomName(((Component)b).gameObject, "Body");
				BaseAI val3 = (Object.op_Implicit((Object)(object)b.master) ? ((Component)b.master).GetComponent<BaseAI>() : null);
				string text = (Object.op_Implicit((Object)(object)val3) ? string.Format(" ai[enemy={0} los={1} driver={2} state={3} move={4:F2}]", (val3.currentEnemy != null && Object.op_Implicit((Object)(object)val3.currentEnemy.characterBody)) ? ((Object)val3.currentEnemy.characterBody).name.Replace("(Clone)", "") : "none", val3.currentEnemy != null && val3.currentEnemy.hasLoS, Object.op_Implicit((Object)(object)val3.skillDriverEvaluation.dominantSkillDriver) ? val3.skillDriverEvaluation.dominantSkillDriver.customName : "none", (Object.op_Implicit((Object)(object)val3.stateMachine) && val3.stateMachine.state != null) ? ((object)val3.stateMachine.state).GetType().Name : "?", Object.op_Implicit((Object)(object)b.inputBank) ? ((Vector3)(ref b.inputBank.moveVector)).magnitude : 0f) : "");
				string text2 = string.Join(",", from i in Enumerable.Range(0, BuffCatalog.buffCount)
					where b.HasBuff((BuffIndex)i)
					select ((Object)BuffCatalog.GetBuffDef((BuffIndex)i)).name);
				return string.Format("{0} lvl={1:F0} hp={2:F0}/{3:F0} armor={4:F0} elite={5} body={6} weapon={7} @{8:F0} buffs=[{9}]{10}", ((Object)b).name.Replace("(Clone)", ""), b.level, b.healthComponent.combinedHealth, b.healthComponent.fullCombinedHealth, b.armor, b.isElite, Object.op_Implicit((Object)(object)val2) ? ((object)val2.state).GetType().Name : "?", Object.op_Implicit((Object)(object)val) ? ((object)val.state).GetType().Name : "?", b.footPosition, text2, text);
			});
			return "mobs [" + string.Join("; ", values) + "]";
		}

		public static string MobProbe()
		{
			IEnumerable<string> values = (from b in CharacterBody.readOnlyInstancesList
				where Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)b.healthComponent) && b.healthComponent.alive && (((Object)b).name.StartsWith("Shulker") || ((Object)b).name.StartsWith("Endermite") || ((Object)b).name.StartsWith("ObsidianWarden") || ((Object)b).name.StartsWith("EndermanBody"))
				group b by ((Object)b).name.Replace("(Clone)", "")).Select(delegate(IGrouping<string, CharacterBody> g)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				CharacterBody val = g.First();
				float foot = val.footPosition.y;
				List<MeshRenderer> list = (from r in ((Component)val).GetComponentsInChildren<MeshRenderer>()
					where ((Renderer)r).enabled
					select r).ToList();
				string text = ((list.Count > 0) ? $"{list.Min(delegate(MeshRenderer r)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					Bounds bounds = ((Renderer)r).bounds;
					return ((Bounds)(ref bounds)).min.y;
				}) - foot:F1}..{list.Max(delegate(MeshRenderer r)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					Bounds bounds = ((Renderer)r).bounds;
					return ((Bounds)(ref bounds)).max.y;
				}) - foot:F1}" : "none");
				IEnumerable<string> values2 = (from h in ((Component)val).GetComponentsInChildren<HurtBox>()
					where Object.op_Implicit((Object)(object)h.collider)
					select h).Select(delegate(HurtBox h)
				{
					//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_0032: Unknown result type (might be due to invalid IL or missing references)
					//IL_0051: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Unknown result type (might be due to invalid IL or missing references)
					//IL_0078: Unknown result type (might be due to invalid IL or missing references)
					//IL_0097: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a7: 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)
					object[] obj = new object[5]
					{
						h.isBullseye ? "main" : "hb",
						null,
						null,
						null,
						null
					};
					Bounds bounds = h.collider.bounds;
					obj[1] = ((Bounds)(ref bounds)).min.y - foot;
					bounds = h.collider.bounds;
					obj[2] = ((Bounds)(ref bounds)).max.y - foot;
					obj[3] = ((Component)h).transform.position.y - foot;
					Vector3 position = ((Component)h).transform.position;
					bounds = h.collider.bounds;
					obj[4] = Vector3.Distance(position, ((Bounds)(ref bounds)).center);
					return string.Format("{0} y {1:F1}..{2:F1} aim {3:F1} off {4:F2}", obj);
				});
				return string.Format("{0} x{1} hp={2:F0} lvl={3:F0} model y {4} core {5:F1} [{6}]", g.Key, g.Count(), val.maxHealth, val.level, text, val.corePosition.y - foot, string.Join(", ", values2));
			});
			return "probe: " + string.Join(" | ", values);
		}

		public static string MusicList()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			List<SceneDef> scenes = ((IEnumerable<SceneDef>)(object)SceneCatalog.allSceneDefs).Where((SceneDef s) => Object.op_Implicit((Object)(object)s)).ToList();
			return string.Join(" | ", ContentManager.musicTrackDefs.Where((MusicTrackDef t) => Object.op_Implicit((Object)(object)t)).Select(delegate(MusicTrackDef t)
			{
				string text = string.Join(",", from s in scenes
					where (Object)(object)s.mainTrack == (Object)(object)t
					select s.cachedName);
				string text2 = string.Join(",", from s in scenes
					where (Object)(object)s.bossTrack == (Object)(object)t
					select s.cachedName);
				return t.cachedName + " '" + t.comment + "'" + ((text != "") ? (" main:" + text) : "") + ((text2 != "") ? (" boss:" + text2) : "");
			}));
		}

		public static string PlayMusic(string name)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)devMusic))
			{
				Object.Destroy((Object)(object)devMusic);
			}
			string text = DateTime.Now.ToString("HH:mm:ss.fff");
			if (name == "none")
			{
				return "music override off at " + text;
			}
			string[] array = name.Split(':');
			SceneDef val = ((array.Length == 2) ? SceneCatalog.FindSceneDef(array[1]) : null);
			MusicTrackDef val2 = ((array.Length != 2) ? EndMusic.Find(name) : ((!Object.op_Implicit((Object)(object)val)) ? null : ((array[0] == "boss") ? val.bossTrack : val.mainTrack)));
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return "no track " + name;
			}
			name = name + " (" + val2.cachedName + ")";
			devMusic = new GameObject("DevMusicOverride");
			MusicTrackOverride obj = devMusic.AddComponent<MusicTrackOverride>();
			obj.track = val2;
			obj.priority = 1000;
			return "playing " + name + " at " + text;
		}

		public static string MusicStatus()
		{
			MusicController instance = MusicController.Instance;
			MusicTrackDef val = (MusicTrackDef)(Object.op_Implicit((Object)(object)instance) ? /*isinst with value type is only supported in some contexts*/: null);
			return string.Format("music: {0} at {1:HH:mm:ss.fff}", Object.op_Implicit((Object)(object)val) ? val.cachedName : "none", DateTime.Now);
		}

		public static string KillMobs()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (CharacterBody item in CharacterBody.readOnlyInstancesList.ToList())
			{
				if (Object.op_Implicit((Object)(object)item) && (int)item.teamComponent.teamIndex == 2 && !((Object)item).name.StartsWith("EnderDragonBody") && item.healthComponent.alive)
				{
					item.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
					num++;
				}
			}
			return "killed " + num;
		}

		public static string HitNearest(string arg)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			CharacterBody u = Player;
			if (!Object.op_Implicit((Object)(object)u))
			{
				return "no player";
			}
			string[] array = (arg ?? "1").Split(' ');
			int num = int.Parse(array[0]);
			float num2 = ((array.Length > 1) ? float.Parse(array[1], CultureInfo.InvariantCulture) : 0.01f);
			CharacterBody val = (from b in CharacterBody.readOnlyInstancesList
				where Object.op_Implicit((Object)(object)b) && (int)b.teamComponent.teamIndex == 2 && b.healthComponent.alive && !((Object)b).name.StartsWith("EnderDragonBody")
				orderby Vector3.Distance(b.corePosition, u.corePosition)
				select b).FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no target";
			}
			for (int num3 = 0; num3 < num; num3++)
			{
				if (!val.healthComponent.alive)
				{
					break;
				}
				DamageInfo val2 = new DamageInfo
				{
					attacker = ((Component)u).gameObject,
					inflictor = ((Component)u).gameObject,
					damage = val.healthComponent.fullCombinedHealth * num2,
					position = val.corePosition,
					procCoefficient = 1f,
					crit = false,
					damageColorIndex = (DamageColorIndex)0
				};
				val.healthComponent.TakeDamage(val2);
				GlobalEventManager.instance.OnHitEnemy(val2, ((Component)val).gameObject);
				GlobalEventManager.instance.OnHitAll(val2, ((Component)val).gameObject);
			}
			return $"hit {((Object)val).name} x{num}; " + ProjectileCount();
		}

		public static string HurtPlayer(string count)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return "no player";
			}
			CharacterBody val = ((IEnumerable<CharacterBody>)CharacterBody.readOnlyInstancesList).FirstOrDefault((Func<CharacterBody, bool>)((CharacterBody b) => Object.op_Implicit((Object)(object)b) && (int)b.teamComponent.teamIndex == 2 && b.healthComponent.alive));
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "no monster to attack with";
			}
			Vector3 footPosition = player.footPosition;
			int blinksThisRun = ChorusFruit.blinksThisRun;
			for (int num = 0; num < int.Parse(count); num++)
			{
				player.healthComponent.TakeDamage(new DamageInfo
				{
					attacker = ((Component)val).gameObject,
					inflictor = ((Component)val).gameObject,
					damage = 1f,
					position = player.corePosition,
					procCoefficient = 0f
				});
			}
			return $"blinks={ChorusFruit.blinksThisRun - blinksThisRun} moved={Vector3.Distance(footPosition, player.footPosition):F1}m cripple={player.HasBuff(Buffs.Cripple)}";
		}

		public static string Levitate()
		{
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return "no player";
			}
			player.AddTimedBuff(Levitation.buff, 1.6f);
			return "levitating; " + PlayerStatus();
		}

		public static string ProjectileCount()
		{
			IEnumerable<string> values = from p in Object.FindObjectsOfType<ProjectileController>()
				select ((Object)p).name.Replace("(Clone)", "") into n
				group n by n into g
				select g.Key + "x" + g.Count();
			return "projectiles [" + string.Join(", ", values) + "]";
		}

		public static string GiveEndItem(string arg)
		{
			//IL_0093: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)player.inventory))
			{
				return "no player";
			}
			string[] array = (arg ?? "").Split(' ');
			int num = ((array.Length <= 1) ? 1 : int.Parse(array[1]));
			if (array[0] == "EnderPearl")
			{
				player.inventory.SetEquipmentIndex(EnderPearl.equipmentDef.equipmentIndex, false);
				return "equipment=" + ((object)player.inventory.GetEquipmentIndex()/*cast due to .constrained prefix*/).ToString();
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(array[0]));
			if (!Object.op_Implicit((Object)(object)itemDef))
			{
				return "unknown item " + array[0];
			}
			player.inventory.GiveItemPermanent(itemDef, num);
			return $"{((Object)itemDef).name}={player.inventory.GetItemCountEffective(itemDef)}";
		}

		public static string DropEndItems()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return "no player";
			}
			Vector3 forward = player.transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			PickupIndex[] array = (PickupIndex[])(object)new PickupIndex[5]
			{
				PickupCatalog.FindPickupIndex(Elytra.itemDef.itemIndex),
				PickupCatalog.FindPickupIndex(ShulkerShell.itemDef.itemIndex),
				PickupCatalog.FindPickupIndex(DragonsBreath.itemDef.itemIndex),
				PickupCatalog.FindPickupIndex(ChorusFruit.itemDef.itemIndex),
				PickupCatalog.FindPickupIndex(EnderPearl.equipmentDef.equipmentIndex)
			};
			for (int i = 0; i < array.Length; i++)
			{
				PickupDropletController.CreatePickupDroplet(new UniquePickup(array[i]), player.corePosition + forward * 7f + val * (float)(i - 2) * 3f + Vector3.up * 2f, Vector3.up * 5f);
			}
			return "dropped " + array.Length;
		}

		public static string UseEquipment()
		{
			//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_0057: 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)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)player.equipmentSlot))
			{
				return "no player";
			}
			Vector3 footPosition = player.footPosition;
			bool flag = player.equipmentSlot.ExecuteIfReady();
			return $"executed={flag} teleports={EnderPearl.teleports} last={EnderPearl.lastTeleport:F0} from={footPosition:F0}";
		}

		public static string GlideTest(string arg)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody player = Player;
			if (!Object.op_Implicit((Object)(object)player))
			{
				return "no player";
			}
			string[] array = (arg ?? "40 6").Split(' ');
			float num = float.Parse(array[0], CultureInfo.InvariantCulture);
			float num2 = ((array.Length > 1) ? float.Parse(array[1], CultureInfo.InvariantCulture) : 6f);
			TeleportHelper.TeleportBody(player, player.footPosition + Vector3.up * num, false);
			Elytra.forceGlideUntil = Time.time + num2;
			return "lifted " + num + "m, gliding for " + num2 + "s";
		}

		public static string PlayerStatus()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody u = Player;
			if (!Object.op_Implicit((Object)(object)u))
			{
				return "no player";
			}
			CharacterMotor characterMotor = u.characterMotor;
			string text = string.Join(",", from i in Enumerable.Range(0, BuffCatalog.buffCount)
				where u.HasBuff((BuffIndex)i)
				select ((Object)BuffCatalog.GetBuffDef((BuffIndex)i)).name);
			return string.Format("{0} pos={1:F1} vel={2:F1} grounded={3} speed={4:F1} buffs=[{5}] elytra={6} chorusBlinks={7} pearlTeleports={8}", ((Object)u).name.Replace("(Clone)", ""), u.footPosition, Object.op_Implicit((Object)(object)characterMotor) ? characterMotor.velocity : Vector3.zero, Object.op_Implicit((Object)(object)characterMotor) && characterMotor.isGrounded, u.moveSpeed, text, (Object)(object)((Component)u).GetComponent<ElytraBehavior>() != (Object)null, ChorusFruit.blinksThisRun, EnderPearl.teleports);
		}

		public static string TeleportNear(string what)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody u = Player;
			if (!Object.op_Implicit((Object)(object)u))
			{
				return "no player";
			}
			Vector3 center;
			if ((what ?? "").ToLowerInvariant() == "site")
			{
				EndAwakening instance = EndAwakening.instance;
				if (!Object.op_Implicit((Object)(object)instance))
				{
					return "no awakening";
				}
				center = instance.SitePositions.OrderBy((Vector3 p) => Vector3.Distance(p, u.footPosition)).First();
			}
			else
			{
				center = EndIsland.Origin;
			}
			EndSpawner.FindGround(center, 12f, 18f, out var pos, (HullClassification)0);
			TeleportHelper.TeleportBody(u, pos, false);
			return "teleported to " + ((Vector3)(ref pos)).ToString("F0");
		}
	}
	internal static class EndCrystals
	{
		public static GameObject crystalBodyPrefab;

		public static GameObject crystalMasterPrefab;

		public const float CoreHeight = 1.2f;

		internal static readonly List<CharacterBody> crystals = new List<CharacterBody>();

		public static int AliveCount => crystals.Count((CharacterBody c) => Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)c.healthComponent) && c.healthComponent.alive);

		public static IEnumerable<CharacterBody> Alive => crystals.Where((CharacterBody c) => Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)c.healthComponent) && c.healthComponent.alive);

		public static void Init()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			crystalBodyPrefab = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/ExplosivePotDestructible/ExplosivePotDestructibleBody.prefab"), "EndCrystalBody", true);
			CharacterBody component = crystalBodyPrefab.GetComponent<CharacterBody>();
			component.baseNameToken = "THEEND_CRYSTAL_NAME";
			component.baseMaxHealth = 220f;
			component.levelMaxHealth = 66f;
			component.autoCalculateLevelStats = false;
			ModelLocator component2 = crystalBodyPrefab.GetComponent<ModelLocator>();
			Transform val = (Object.op_Implicit((Object)(object)component2) ? component2.modelTransform : null);
			SummoningCrystal.HidePot(crystalBodyPrefab);
			if (Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject("EndCrystalVisual");
				val2.transform.SetParent(val, false);
				val2.AddComponent<EndCrystalVisual>();
				CharacterModel component3 = ((Component)val).GetComponent<CharacterModel>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					component3.baseRendererInfos = (RendererInfo[])(object)new RendererInfo[0];
				}
				SummoningCrystal.AddCoreHurtBox(crystalBodyPrefab, val, 1.2f, 2.2f);
			}
			Rigidbody component4 = crystalBodyPrefab.GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				component4.isKinematic = true;
				component4.useGravity = false;
				component4.constraints = (RigidbodyConstraints)126;
			}
			ContentAddition.AddBody(crystalBodyPrefab);
			LanguageAPI.Add("THEEND_CRYSTAL_NAME", "End Crystal");
		}

		public static void SpawnAll()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			foreach (EndIsland.Pillar pillar in EndIsland.pillars)
			{
				SpawnOne(pillar.crystalPos);
			}
		}

		public static CharacterBody SpawnOne(Vector3 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return null;
			}
			GameObject obj = Object.Instantiate<GameObject>(crystalBodyPrefab, pos, Quaternion.identity);
			NetworkServer.Spawn(obj);
			return obj.GetComponent<CharacterBody>();
		}
	}
	internal class EndCrystalVisual : MonoBehaviour
	{
		private Transform inner;

		private Transform outer;

		private LineRenderer beam;

		private static Material crystalMat;

		private static Material beamMat;

		private float t;

		private CharacterBody body;

		private void OnEnable()
		{
			body = ((Component)this).GetComponentInParent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)body) && !EndCrystals.crystals.Contains(body))
			{
				EndCrystals.crystals.Add(body);
			}
		}

		private void OnDisable()
		{
			EndCrystals.crystals.Remove(body);
		}

		private void Start()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)crystalMat))
			{
				crystalMat = Assets.Lit("matEndCrystal", PixelTextures.Crystal, Color.white, 0.8f, PixelTextures.Crystal, (Color?)new Color(1f, 0.6f, 1f), 2.5f);
				beamMat = Assets.Lit("matEndBeam", PixelTextures.White, Color.black, 0f, PixelTextures.White, (Color?)new Color(1f, 0.5f, 1f), 6f);
			}
			Transform val = (Object.op_Implicit((Object)(object)body) ? body.transform : ((Component)this).transform.parent);
			if (Object.op_Implicit((Object)(object)val))
			{
				((Component)this).transform.SetPositionAndRotation(val.position, val.rotation);
			}
			Vector3 val2 = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? ((Component)this).transform.parent.lossyScale : Vector3.one);
			((Component)this).transform.localScale = new Vector3(1f / Mathf.Max(0.001f, val2.x), 1f / Mathf.Max(0.001f, val2.y), 1f / Mathf.Max(0.001f, val2.z));
			outer = MakeCube("Outer", 2.6f);
			inner = MakeCube("Inner", 1.5f);
			Light obj = ((Component)this).gameObject.AddComponent<Light>();
			obj.color = new Color(1f, 0.45f, 1f);
			obj.range = 22f;
			obj.intensity = 3f;
			beam = ((Component)this).gameObject.AddComponent<LineRenderer>();
			((Renderer)beam).material = beamMat;
			beam.startWidth = 0.6f;
			beam.endWidth = 0.4f;
			beam.positionCount = 2;
			((Renderer)beam).enabled = false;
		}

		private Transform MakeCube(string name, float size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			MeshUtil.BoxBuilder boxBuilder = new MeshUtil.BoxBuilder(1f / size);
			boxBuilder.Box(Vector3.zero, Vector3.one * size);
			val.AddComponent<MeshFilter>().sharedMesh = boxBuilder.ToMesh("mesh" + name);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = crystalMat;
			return val.transform;
		}

		private void Update()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			t += Time.deltaTime;
			outer.localRotation = Quaternion.Euler(t * 40f, t * 60f, 0f);
			inner.localRotation = Quaternion.Euler((0f - t) * 70f, 0f, t * 50f);
			Transform obj = outer;
			Transform obj2 = inner;
			Vector3 localPosition = default(Vector3);
			((Vector3)(ref localPosition))..ctor(0f, 1.2f + Mathf.Sin(t * 2f) * 0.3f, 0f);
			obj2.localPosition = localPosition;
			obj.localPosition = localPosition;
			CharacterBody currentHealer = EndCrystalHealing.currentHealer;
			bool flag = Object.op_Implicit((Object)(object)currentHealer) && (Object)(object)currentHealer == (Object)(object)body && Object.op_Implicit((Object)(object)EndCrystalHealing.dragonBody);
			((Renderer)beam).enabled = flag;
			if (flag)
			{
				beam.SetPosition(0, outer.position);
				beam.SetPosition(1, EndCrystalHealing.dragonBody.corePosition);
			}
		}
	}
	internal class EndCrystalHealing : MonoBehaviour
	{
		public static CharacterBody currentHealer;

		public static CharacterBody dragonBody;

		public const float HealFractionPerSecond = 0.012f;

		public const float Range = 160f;

		private bool hadCrystals;

		private bool shieldBroken;

		private void FixedUpdate()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = dragonBody;
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive)
			{
				currentHealer = null;
				return;
			}
			CharacterBody val2 = null;
			float num = 160f;
			foreach (CharacterBody item in EndCrystals.Alive)
			{
				float num2 = Vector3.Distance(item.transform.position, val.corePosition);
				if (num2 < num)
				{
					num = num2;
					val2 = item;
				}
			}
			currentHealer = val2;
			if (NetworkServer.active)
			{
				if (Object.op_Implicit((Object)(object)val2))
				{
					val.healthComponent.Heal(val.healthComponent.fullHealth * 0.012f * Time.fixedDeltaTime, default(ProcChainMask), false);
				}
				UpdateShield(val);
			}
		}

		private void UpdateShield(CharacterBody dragon)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			bool flag = EndCrystals.AliveCount > 0;
			hadCrystals |= flag;
			int num = (flag ? 1 : 0);
			if (dragon.GetBuffCount(Buffs.Immune) != num)
			{
				dragon.SetBuffCount(Buffs.Immune.buffIndex, num);
			}
			if (!flag && hadCrystals && !shieldBroken)
			{
				shieldBroken = true;
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "THEEND_SHIELD_DOWN"
				});
			}
		}
	}
	internal static class EndEncounter
	{
		public static GameObject endPortalPrefab;

		public static GameObject exitPortalPrefab;

		public static GameObject gatewayPrefab;

		public static GameEndingDef ending;

		private static readonly Vector3 EntranceStart = new Vector3(-38f, 78f, 258f);

		private static readonly Vector3[] EntrancePath = (Vector3[])(object)new Vector3[5]
		{
			new Vector3(-11f, 42f, 74f),
			new Vector3(0f, 24f, 0f),
			new Vector3(6f, 30f, -48f),
			new Vector3(11f, 48f, -78f),
			new Vector3(20f, 66f, -130f)
		};

		public const int EntrancePassIndex = 1;

		public static void Init()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			endPortalPrefab = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/PortalShop/PortalShop.prefab"), "PortalTheEnd", true);
			SceneExitController component = endPortalPrefab.GetComponent<SceneExitController>();
			component.useRunNextStageScene = false;
			component.destinationScene = EndStage.sceneDef;
			component.portalUsedAfterTeleporterEventFinish = false;
			GenericInteraction component2 = endPortalPrefab.GetComponent<GenericInteraction>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.contextToken = "THEEND_PORTAL_CONTEXT";
			}
			DragonAssets.Recolor(endPortalPrefab, new Color(0.25f, 0.05f, 0.4f));
			exitPortalPrefab = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/PortalShop/PortalShop.prefab"), "PortalTheEndExit", true);
			Object.DestroyImmediate((Object)(object)exitPortalPrefab.GetComponent<SceneExitController>());
			GenericInteraction component3 = exitPortalPrefab.GetComponent<GenericInteraction>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.contextToken = "THEEND_EXIT_CONTEXT";
			}
			Renderer[] componentsInChildren = exitPortalPrefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Light[] componentsInChildren2 = exitPortalPrefab.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Behaviour)componentsInChildren2[i]).enabled = false;
			}
			exitPortalPrefab.AddComponent<EndExitPool>();
			gatewayPrefab = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/PortalShop/PortalShop.prefab"), "PortalTheEndGateway", true);
			SceneExitController component4 = gatewayPrefab.GetComponent<SceneExitController>();
			component4.useRunNextStageScene = true;
			component4.destinationScene = null;
			component4.portalUsedAfterTeleporterEventFinish = false;
			GenericInteraction component5 = gatewayPrefab.GetComponent<GenericInteraction>();
			if (Object.op_Implicit((Object)(object)component5))
			{
				component5.contextToken = "THEEND_GATEWAY_CONTEXT";
			}
			DragonAssets.Recolor(gatewayPrefab, new Color(0.85f, 0.3f, 1f));
			componentsInChildren2 = gatewayPrefab.GetComponentsInChildren<Light>(true);
			foreach (Light obj in componentsInChildren2)
			{
				obj.intensity *= 0.3f;
			}
			_ = GameEndings.MainEnding;
			ending = ScriptableObject.CreateInstance<GameEndingDef>();
			((Object)ending).name = "TheEndDragonEnding";
			ending.endingTextToken = "THEEND_ENDING_TEXT";
			ending.backgroundColor = new Color(0.12f, 0.03f, 0.2f, 0.9f);
			ending.foregroundColor = new Color(0.85f, 0.5f, 1f);
			ending.isWin = true;
			ending.showCredits = true;
			ending.lunarCoinReward = 10u;
			ending.gameOverControllerState = new SerializableEntityStateType(typeof(FinishEndingContent));
			ContentAddition.AddGameEndingDef(ending);
			LanguageAPI.Add("THEEND_PORTAL_CONTEXT", "Enter the portal to The End");
			LanguageAPI.Add("THEEND_EXIT_CONTEXT", "Leave The End (end the run in victory)");
			LanguageAPI.Add("THEEND_GATEWAY_CONTEXT", "Enter the End Gateway (continue the run)");
			LanguageAPI.Add("THEEND_PORTAL_OPEN", "<style=cWorldEvent>An ancient portal hums open... something waits at The End.</style>");
			LanguageAPI.Add("THEEND_SHIELD_UP", "<style=cWorldEvent>The End Crystals shield the dragon. Destroy them all before it can be hurt!</style>");
			LanguageAPI.Add("THEEND_SHIELD_DOWN", "<style=cWorldEvent>The last End Crystal shatters... the dragon is vulnerable!</style>");
			LanguageAPI.Add("THEEND_DRAGON_SLAIN", "<style=cWorldEvent>The dragon is slain! Leave through the fountain to end the run in victory, or step into the End Gateway to keep going.</style>");
			LanguageAPI.Add("THEEND_ENDING_TEXT", "...and the dream ended.");
			TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterCharged;
			Stage.onServerStageBegin += OnServerStageBegin;
		}

		private static void OnTeleporterCharged(TeleporterInteraction tp)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00cb: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !TheEndPlugin.portalAfterStage5.Value)
			{
				return;
			}
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && mostRecentSceneDef.stageOrder == 5)
			{
				Vector3 val = ((Component)tp).transform.position + ((Component)tp).transform.right * 14f;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val + Vector3.up * 20f, Vector3.down, ref val2, 60f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
				{
					val = ((RaycastHit)(ref val2)).point;
				}
				NetworkServer.Spawn(Object.Instantiate<GameObject>(endPortalPrefab, val, Quaternion.LookRotation(-((Component)tp).transform.right)));
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "THEEND_PORTAL_OPEN"
				});
			}
		}

		private static void OnServerStageBegin(Stage stage)
		{
			if (!((Object)(object)stage.sceneDef != (Object)(object)EndStage.sceneDef) && Object.op_Implicit((Object)(object)EndIsland.root))
			{
				((MonoBehaviour)stage).StartCoroutine(RunFight());
			}
		}

		private static IEnumerator RunFight()
		{
			yield return (object)new WaitForSeconds(3f);
			EndAwakening.Begin();
		}

		public static CharacterMaster SpawnDragon(bool entrance = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 dropPosition = EndIsland.PerchPoint + Vector3.up * 3f;
			if (entrance)
			{
				Vector3 val = EndIsland.Origin + EntranceStart;
				CharacterMaster val2 = DragonBody.Spawn(val, Quaternion.LookRotation(EndIsland.Origin + EntrancePath[0] - val), dropPosition, OnDragonDefeated);
				CharacterBody val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetBody() : null);
				DragonController dragonController = (Object.op_Implicit((Object)(object)val3) ? ((Component)val3).GetComponent<DragonController>() : null);
				if (Object.op_Implicit((Object)(object)dragonController))
				{
					dragonController.BeginEntrance(Array.ConvertAll(EntrancePath, (Vector3 p) => EndIsland.Origin + p), 1);
				}
				return val2;
			}
			return DragonBody.Spawn(EndIsland.Origin + new Vector3(0f, 55f, EndIsland.IslandRadius * 0.55f), Quaternion.LookRotation(Vector3.back), dropPosition, OnDragonDefeated);
		}

		private static void OnDragonDefeated()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "THEEND_DRAGON_SLAIN"
			});
			if (Object.op_Implicit((Object)(object)EndAwakening.instance))
			{
				EndAwakening.instance.OnDragonDefeatedServer();
			}
			GameObject obj = Object.Instantiate<GameObject>(exitPortalPrefab, EndIsland.PortalCenter + Vector3.up * 0.5f, Quaternion.identity);
			NetworkServer.Spawn(obj);
			((UnityEvent<Interactor>)(object)obj.GetComponent<GenericInteraction>().onActivation).AddListener((UnityAction<Interactor>)delegate
			{
				if (Object.op_Implicit((Object)(object)Run.instance) && !Run.instance.isGameOverServer)
				{
					GrantEndRewards();
					Run.instance.BeginGameOver(ending);
				}
			});
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				Run.instance.PickNextStageSceneFromCurrentSceneDestinations();
			}
			Vector3 val = EndIsland.Origin + new Vector3(0f, 0f, 26f);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 40f, Vector3.down, ref val2, 80f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			NetworkServer.Spawn(Object.Instantiate<GameObject>(gatewayPrefab, val, Quaternion.LookRotation(Vector3.back)));
		}

		private static void GrantEndRewards()
		{
			DragonSkins.GrantUnlock();
		}
	}
	internal class EndExitPool : MonoBehaviour
	{
		private Material mat;

		private float t;

		private void Start()
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ExitPoolSurface");
			val.transform.position = EndIsland.PortalCenter;
			MeshUtil.BoxBuilder boxBuilder = new MeshUtil.BoxBuilder(0.25f);
			float num = 10.4f;
			boxBuilder.Box(Vector3.zero, new Vector3(num, 0.1f, num));
			val.AddComponent<MeshFilter>().sharedMesh = boxBuilder.ToMesh("ExitPool");
			mat = Assets.Lit("matExitPool", PixelTextures.White, Color.black, 0f, PixelTextures.PortalStars, Color.white, 4f);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
			val.transform.SetParent(((Component)this).transform, true);
			Light obj = val.AddComponent<Light>();
			obj.color = new Color(0.4f, 1f, 0.8f);
			obj.range = 14f;
			obj.intensity = 1.2f;
		}

		private void Update()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			t += Time.deltaTime;
			if (Object.op_Implicit((Object)(object)mat))
			{
				mat.SetTextureOffset("_EmTex", new Vector2(t * 0.02f, t * 0.013f));
			}
		}
	}
	internal static class EndIsland
	{
		private enum Block : byte
		{
			Air,
			EndStone,
			Obsidian,
			Bedrock,
			CryingObsidian
		}

		public struct Pillar
		{
			public Vector3 basePos;

			public Vector3 crystalPos;

			public float radius;
		}

		private struct Stair
		{
			public Vector3 center;

			public float innerR;

			public float topY;

			public float startAngle;
		}

		public const float B = 2f;

		public const int R = 48;

		private const int Depth = 28;

		private const int Height = 40;

		private const int PillarCount = 10;

		private const int Seed = 1337;

		public static readonly int[] SummonPillars = new int[4] { 0, 3, 6, 8 };

		public static Vector3 Origin = Vector3.zero;

		public static readonly List<Pillar> pillars = new List<Pillar>();

		private static readonly List<Stair> stairs = new List<Stair>();

		public static GameObject root;

		private const int N = 51;

		private static Block[,,] vox;

		private const float StairRise = 0.5f;

		private const float StairTread = 1f;

		private const float StairWidth = 3.4f;

		private const float StairSlab = 0.6f;

		private static readonly Vector3Int[] Dirs = (Vector3Int[])(object)new Vector3Int[6]
		{
			new Vector3Int(1, 0, 0),
			new Vector3Int(-1, 0, 0),
			new Vector3Int(0, 1, 0),
			new Vector3Int(0, -1, 0),
			new Vector3Int(0, 0, 1),
			new Vector3Int(0, 0, -1)
		};

		private static readonly Vector3[][] FaceCorners = new Vector3[6][]
		{
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(1f, 0f, 0f),
				new Vector3(1f, 1f, 0f),
				new Vector3(1f, 1f, 1f),
				new Vector3(1f, 0f, 1f)
			},
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, 0f, 1f),
				new Vector3(0f, 1f, 1f),
				new Vector3(0f, 1f, 0f),
				new Vector3(0f, 0f, 0f)
			},
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, 1f, 0f),
				new Vector3(0f, 1f, 1f),
				new Vector3(1f, 1f, 1f),
				new Vector3(1f, 1f, 0f)
			},
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, 0f, 1f),
				new Vector3(0f, 0f, 0f),
				new Vector3(1f, 0f, 0f),
				new Vector3(1f, 0f, 1f)
			},
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(1f, 0f, 1f),
				new Vector3(1f, 1f, 1f),
				new Vector3(0f, 1f, 1f),
				new Vector3(0f, 0f, 1f)
			},
			(Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, 0f, 0f),
				new Vector3(0f, 1f, 0f),
				new Vector3(1f, 1f, 0f),
				new Vector3(1f, 0f, 0f)
			}
		};

		private static readonly Vector2[] FaceUV = (Vector2[])(object)new Vector2[4]
		{
			new Vector2(0f, 0f),
			new Vector2(0f, 1f),
			new Vector2(1f, 1f),
			new Vector2(1f, 0f)
		};

		public static Vector3 PerchPoint => Origin + new Vector3(1f, 8f, 1f);

		public static Vector3 PortalCenter => Origin + new Vector3(1f, -1.1f, 1f);

		public static float IslandRadius => 96f;

		public static float BottomY => Origin.y - 56f;

		private static Block Get(int x, int y, int z)
		{
			int num = x + 51;
			int num2 = y + 28;
			int num3 = z + 51;
			if (num < 0 || num2 < 0 || num3 < 0 || num >= vox.GetLength(0) || num2 >= vox.GetLength(1) || num3 >= vox.GetLength(2))
			{
				return Block.Air;
			}
			return vox[num, num2, num3];
		}

		private static void Set(int x, int y, int z, Block b)
		{
			int num = x + 51;
			int num2 = y + 28;
			int num3 = z + 51;
			if (num >= 0 && num2 >= 0 && num3 >= 0 && num < vox.GetLength(0) && num2 < vox.GetLength(1) && num3 < vox.GetLength(2))
			{
				vox[num, num2, num3] = b;
			}
		}

		public static GameObject Build()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Stopwatch stopwatch = Stopwatch.StartNew();
			vox = new Block[103, 69, 103];
			pillars.Clear();
			stairs.Clear();
			GenerateTerrain(new PixelTextures.Rng(1337));
			GeneratePillars();
			GenerateFountain();
			root = new GameObject("EndIsland");
			root.transform.position = Origin;
			BuildMesh(root.transform);
			vox = null;
			BuildStairs(root.transform);
			BuildSky(root.transform);
			BuildLighting(root.transform);
			BuildSpawnPoints(root.transform);
			BuildNavigation(root.transform);
			BuildOutOfBounds(root.transform);
			TheEndPlugin.log.LogInfo((object)$"End island generated in {stopwatch.ElapsedMilliseconds} ms");
			return root;
		}

		private static float Noise2(float x, float y, int seed)
		{
			int num = Mathf.FloorToInt(x);
			int num2 = Mathf.FloorToInt(y);
			float num3 = x - (float)num;
			float num4 = y - (float)num2;
			float num5 = num3 * num3 * (3f - 2f * num3);
			float num6 = num4 * num4 * (3f - 2f * num4);
			float num7 = Hash(num, num2, seed);
			float num8 = Hash(num + 1, num2, seed);
			float num9 = Hash(num, num2 + 1, seed);
			float num10 = Hash(num + 1, num2 + 1, seed);
			return Mathf.Lerp(Mathf.Lerp(num7, num8, num5), Mathf.Lerp(num9, num10, num5), num6);
		}

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

		private static void GenerateTerrain(PixelTextures.Rng rng)
		{
			for (int i = -51; i <= 51; i++)
			{
				for (int j = -51; j <= 51; j++)
				{
					float num = Mathf.Sqrt((float)(i * i + j * j));
					float num2 = Mathf.Atan2((float)j, (float)i);
					float num3 = 48f * (0.88f + 0.12f * Noise2(Mathf.Cos(num2) * 3f + 10f, Mathf.Sin(num2) * 3f + 10f, 1337));
					if (!(num >= num3))
					{
						float num4 = num / num3;
						int num5 = Mathf.Clamp(Mathf.RoundToInt(3f + 25f * (1f - Mathf.Pow(num4, 1.5f)) * (0.75f + 0.5f * Noise2((float)i * 0.15f, (float)j * 0.15f, 1338))), 2, 28);
						int num6 = -1;
						if (num4 > 0.93f && Hash(i, j, 1339) < 0.5f)
						{
							num6 = -2;
						}
						for (int k = -num5; k <= num6; k++)
						{
							Set(i, k, j, Block.EndStone);
						}
					}
				}
			}
			for (int l = 0; l < 9; l++)
			{
				float num7 = rng.Range(0f, MathF.PI * 2f);
				float num8 = rng.Range(14f, 40f);
				int num9 = Mathf.RoundToInt(Mathf.Cos(num7) * num8);
				int num10 = Mathf.RoundToInt(Mathf.Sin(num7) * num8);
				if ((float)num10 < -28.800001f && Mathf.Abs(num9) < 12)
				{
					continue;
				}
				float num11 = rng.Range(2.5f, 5.5f);
				int num12 = rng.Range(1, 3);
				for (int m = num9 - 6; m <= num9 + 6; m++)
				{
					for (int n = num10 - 6; n <= num10 + 6; n++)
					{
						float num13 = Mathf.Sqrt((float)((m - num9) * (m - num9) + (n - num10) * (n - num10)));
						if (Get(m, -1, n) == Block.EndStone)
						{
							int num14 = ((num13 < num11 * 0.55f) ? num12 : ((num13 < num11) ? 1 : 0));
							for (int num15 = 0; num15 < num14; num15++)
							{
								Set(m, num15, n, Block.EndStone);
							}
						}
					}
				}
			}
		}

		private static void GeneratePillars()
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0171: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			float num = 27.84f;
			for (int i = 0; i < 10; i++)
			{
				float num2 = (float)i * MathF.PI * 2f / 10f + 0.15f;
				int num3 = Mathf.RoundToInt(Mathf.Cos(num2) * num);
				int num4 = Mathf.RoundToInt(Mathf.Sin(num2) * num);
				int num5 = 2 + i * 7 % 4;
				int num6 = 14 + num5 * 4 + i % 3 * 2;
				num6 = Mathf.Min(num6, 37);
				ClearAbove(num3, num4, (float)num5 + 3f);
				for (int j = num3 - num5 - 1; j <= num3 + num5 + 1; j++)
				{
					for (int k = num4 - num5 - 1; k <= num4 + num5 + 1; k++)
					{
						if (!(Mathf.Sqrt((float)((j - num3) * (j - num3) + (k - num4) * (k - num4))) > (float)num5 + 0.35f))
						{
							for (int l = -4; l < num6; l++)
							{
								Set(j, l, k, (l >= 0 && Hash(j * 31 + l * 7, k * 17 - l, 1342) < 0.06f) ? Block.CryingObsidian : Block.Obsidian);
							}
						}
					}
				}
				Set(num3, num6, num4, Block.Bedrock);
				Vector3 val = Origin + new Vector3(((float)num3 + 0.5f) * 2f, 0f, ((float)num4 + 0.5f) * 2f);
				pillars.Add(new Pillar
				{
					basePos = val,
					crystalPos = Origin + new Vector3(((float)num3 + 0.5f) * 2f, (float)(num6 + 1) * 2f + 0.1f, ((float)num4 + 0.5f) * 2f),
					radius = ((float)num5 + 0.5f) * 2f
				});
				stairs.Add(new Stair
				{
					center = val,
					innerR = ((float)num5 + 0.3f) * 2f,
					topY = Origin.y + (float)num6 * 2f,
					startAngle = num2 + MathF.PI
				});
			}
		}

		private static void ClearAbove(int cx, int cz, float radius)
		{
			int num = Mathf.CeilToInt(radius);
			for (int i = cx - num; i <= cx + num; i++)
			{
				for (int j = cz - num; j <= cz + num; j++)
				{
					if (!((float)((i - cx) * (i - cx) + (j - cz) * (j - cz)) > radius * radius))
					{
						for (int k = 0; k <= 40; k++)
						{
							Set(i, k, j, Block.Air);
						}
					}
				}
			}
		}

		private static void BuildStairs(Transform parent)
		{
			//IL_0012: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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_0344: Unknown result type (might be due to invalid IL or missing references)
			Material mat = Assets.Lit("matEndStairs", PixelTextures.Purpur, Color.white, 0.4f);
			Material mat2 = Assets.Lit("matEndBaluster", PixelTextures.Obsidian, Color.white, 0.6f);
			SurfaceDef surface = Assets.Load<SurfaceDef>("RoR2/Base/Common/sdStone.asset");
			for (int i = 0; i < stairs.Count; i++)
			{
				Stair st = stairs[i];
				float num = st.topY - st.center.y;
				int num2 = Mathf.Max(1, Mathf.CeilToInt(num / 0.5f));
				float num3 = num / (float)num2;
				float innerR = st.innerR;
				float ro = st.innerR + 3.4f;
				float num4 = (innerR + ro) * 0.5f;
				float num5 = 1f / num4;
				MeshUtil.BoxBuilder boxBuilder = new MeshUtil.BoxBuilder();
				MeshUtil.BoxBuilder boxBuilder2 = new MeshUtil.BoxBuilder();
				for (int j = 1; j <= num2; j++)
				{
					float num6 = st.startAngle + ((float)j - 0.5f) * num5;
					float num7 = st.center.y + (float)j * num3;
					Quaternion value = Quaternion.Euler(0f, (0f - num6) * 57.29578f, 0f);
					boxBuilder.Box(st.center + Dir(num6) * num4 + Vector3.up * (num7 - 0.3f) - parent.position, new Vector3(3.4f, 0.6f, 1f * (ro / num4) * 1.08f), value);
					if (j % 2 == 0)
					{
						boxBuilder2.Box(st.center + Dir(num6) * (ro - 0.25f) + Vector3.up * (num7 + 0.5f) - parent.position, new Vector3(0.3f, 1f, 0.3f), value);
					}
				}
				AddRenderer(parent, "Stairs" + i, boxBuilder.ToMesh("mshStairs" + i), mat);
				AddRenderer(parent, "StairPosts" + i, boxBuilder2.ToMesh("mshStairPosts" + i), mat2);
				List<Vector3> ramp = new List<Vector3>();
				List<Vector3> band = new List<Vector3>();
				Ring(st.startAngle - num5, st.center.y, innerR);
				for (int k = 1; k <= num2; k++)
				{
					Ring(st.startAngle + ((float)k - 0.5f) * num5, st.center.y + (float)k * num3, innerR - 1.5f);
				}
				Ring(st.startAngle + ((float)num2 + 1.5f) * num5, st.topY, innerR - 2.5f);
				AddCollider(parent, "StairRamp" + i, Strip(ramp, "mshStairRamp" + i), surface);
				AddCollider(parent, "StairGuard" + i, Strip(band, "mshStairGuard" + i), surface);
				void Ring(float a, float y, float rIn)
				{
					//IL_0007: 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_001c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0031: Unknown result type (might be due to invalid IL or missing references)
					//IL_0036: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0041: Unknown result type (might be due to invalid IL or missing references)
					//IL_0052: 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_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0070: 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_0086: Unknown result type (might be due to invalid IL or missing references)
					//IL_0088: Unknown result type (might be due to invalid IL or missing references)
					//IL_009a: Unknown result type (might be due to invalid IL or missing references)
					//IL_009f: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00da: Unknown result type (might be due to invalid IL or missing references)
					//IL_00df: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = st.center - parent.position;
					ramp.Add(val + Dir(a) * rIn + Vector3.up * y);
					ramp.Add(val + Dir(a) * ro + Vector3.up * y);
					band.Add(val + Dir(a) * (ro - 0.1f) + Vector3.up * (y - 0.3f));
					band.Add(val + Dir(a) * (ro - 0.1f) + Vector3.up * (y + 1.1f));
				}
			}
			static Vector3 Dir(float a)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(Mathf.Cos(a), 0f, Mathf.Sin(a));
			}
		}

		private static Mesh Strip(List<Vector3> pairs, string name)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_009f: Expected O, but got Unknown
			List<int> list = new List<int>();
			for (int i = 0; i + 3 < pairs.Count; i += 2)
			{
				int num = i;
				int num2 = i + 1;
				int num3 = i + 2;
				int num4 = i + 3;
				list.AddRange(new int[6] { num, num3, num4, num, num4, num2 });
				list.AddRange(new int[6] { num, num4, num3, num, num2, num4 });
			}
			Mesh val = new Mesh
			{
				name = name
			};
			val.SetVertices(pairs);
			val.SetTriangles(list, 0);
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}

		private static void AddRenderer(Transform parent, string name, Mesh mesh, Material mat)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = LayerIndex.world.intVal
			};
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = mat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
		}

		private static void AddCollider(Transform parent, string name, Mesh mesh, SurfaceDef surface)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = LayerIndex.world.intVal
			};
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshCollider>().sharedMesh = mesh;
			val.AddComponent<SurfaceDefProvider>().surfaceDef = surface;
		}

		private static void GenerateFountain()
		{
			for (int i = -5; i <= 5; i++)
			{
				for (int j = -5; j <= 5; j++)
				{
					float num = Mathf.Sqrt((float)(i * i + j * j));
					if (num < 2.6f)
					{
						Set(i, -1, j, Block.Air);
						Set(i, -2, j, Block.Bedrock);
					}
					else if (num < 3.6f)
					{
						Set(i, -1, j, Block.Bedrock);
						Set(i, 0, j, Block.Bedrock);
					}
					else if (num < 4.6f)
					{
						Set(i, -1, j, Block.Bedrock);
					}
					for (int k = 1; k < 8; k++)
					{
						Set(i, k, j, Block.Air);
					}
				}
			}
			for (int l = -2; l <= 3; l++)
			{
				Set(0, l, 0, Block.Bedrock);
			}
		}

		private static void BuildMesh(Transform parent)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			Material[] array = (Material[])(object)new Material[5]
			{
				default(Material),
				Assets.Lit("matEndStone", PixelTextures.EndStone, Color.white, 0.05f),
				Assets.Lit("matObsidian", PixelTextures.Obsidian, Color.white, 0.6f),
				Assets.Lit("matBedrock", PixelTextures.Bedrock, Color.white, 0.05f),
				Assets.Lit("matCryingObsidian", PixelTextures.CryingObsidian, Color.white, 0.6f, PixelTextures.CryingObsidian, (Color?)new Color(0.8f, 0.45f, 1f), 1.6f)
			};
			for (int i = -51; i <= 51; i += 16)
			{
				for (int j = -51; j <= 51; j += 16)
				{
					List<Vector3> list = new List<Vector3>();
					List<Vector3> list2 = new List<Vector3>();
					List<Vector2> list3 = new List<Vector2>();
					List<int>[] array2 = new List<int>[array.Length];
					for (int k = 1; k < array.Length; k++)
					{
						array2[k] = new List<int>();
					}
					for (int l = i; l < i + 16 && l <= 51; l++)
					{
						for (int m = j; m < j + 16 && m <= 51; m++)
						{
							for (int n = -28; n <= 40; n++)
							{
								Block block = Get(l, n, m);
								if (block == Block.Air)
								{
									continue;
								}
								for (int num = 0; num < 6; num++)
								{
									Vector3Int val = Dirs[num];
									if (Get(l + ((Vector3Int)(ref val)).x, n + ((Vector3Int)(ref val)).y, m + ((Vector3Int)(ref val)).z) == Block.Air)
									{
										int count = list.Count;
										for (int num2 = 0; num2 < 4; num2++)
										{
											list.Add((new Vector3((float)l, (float)n, (float)m) + FaceCorners[num][num2]) * 2f);
											list2.Add(Vector3Int.op_Implicit(val));
											list3.Add(FaceUV[num2]);
										}
										List<int> obj = array2[(uint)block];
										obj.Add(count);
										obj.Add(count + 1);
										obj.Add(count + 2);
										obj.Add(count);
										obj.Add(count + 2);
										obj.Add(count + 3);
									}
								}
							}
						}
					}
					if (list.Count == 0)
					{
						continue;
					}
					Mesh val2 = new Mesh
					{
						name = $"EndChunk_{i}_{j}",
						indexFormat = (IndexFormat)1
					};
					val2.SetVertices(list);
					val2.SetNormals(list2);
					val2.SetUVs(0, list3);
					List<Material> list4 = new List<Material>();
					List<List<int>> list5 = new List<List<int>>();
					for (int num3 = 1; num3 < array.Length; num3++)
					{
						if (array2[num3].Count > 0)
						{
							list4.Add(array[num3]);
							list5.Add(array2[num3]);
						}
					}
					val2.subMeshCount = list5.Count;
					for (int num4 = 0; num4 < list5.Count; num4++)
					{
						val2.SetTriangles(list5[num4], num4);
					}
					val2.RecalculateBounds();
					val2.RecalculateTangents();
					GameObject val3 = new GameObject(((Object)val2).name)
					{
						layer = LayerIndex.world.intVal
					};
					val3.transform.SetParent(parent, false);
					val3.AddComponent<MeshFilter>().sharedMesh = val2;
					MeshRenderer obj2 = val3.AddComponent<MeshRenderer>();
					((Renderer)obj2).sharedMaterials = list4.ToArray();
					((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)1;
					val3.AddComponent<MeshCollider>().sharedMesh = val2;
					val3.AddComponent<SurfaceDefProvider>().surfaceDef = Assets.Load<SurfaceDef>("RoR2/Base/Common/sdStone.asset");
				}
			}
		}

		private static void BuildSky(Transform parent)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			GameObject val = new GameObject("EndSky");
			val.transform.SetParent(parent, false);
			Mesh sharedMesh = MeshUtil.Sphere(24, 48, inward: true);
			val.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			Material sharedMaterial = Assets.Lit("matEndSky", PixelTextures.White, Color.black, 0f, PixelTextures.StarSky, Color.white, 3f);
			((Renderer)obj).sharedMaterial = sharedMaterial;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			val.transform.localScale = Vector3.one * 520f;
		}

		private static void BuildLighting(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			Light obj = new GameObject("EndLight").AddComponent<Light>();
			((Component)obj).transform.SetParent(parent, false);
			((Component)obj).transform.rotation = Quaternion.Euler(62f, 35f, 0f);
			obj.type = (LightType)1;
			obj.color = new Color(0.9f, 0.86f, 1f);
			obj.intensity = 1.2f;
			obj.shadows = (LightShadows)2;
			Light obj2 = new GameObject("EndRimLight").AddComponent<Light>();
			((Component)obj2).transform.SetParent(parent, false);
			((Component)obj2).transform.rotation = Quaternion.Euler(-30f, 215f, 0f);
			obj2.type = (LightType)1;
			obj2.color = new Color(0.65f, 0.45f, 0.95f);
			obj2.intensity = 0.8f;
			obj2.shadows = (LightShadows)0;
			RenderSettings.ambientMode = (AmbientMode)3;
			RenderSettings.ambientLight = new Color(0.46f, 0.41f, 0.58f);
			RenderSettings.fog = true;
			RenderSettings.fogMode = (FogMode)1;
			RenderSettings.fogColor = new Color(0.05f, 0.02f, 0.08f);
			RenderSettings.fogStartDistance = 250f;
			RenderSettings.fogEndDistance = 1300f;
		}

		private static void BuildSpawnPoints(Transform parent)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 4; i++)
			{
				GameObject val = new GameObject("SpawnPoint" + i);
				val.transform.SetParent(parent, false);
				val.transform.localPosition = new Vector3(((float)i - 1.5f) * 4f, 0.5f, -69.12f);
				val.transform.rotation = Quaternion.LookRotation(Vector3.forward);
				val.AddComponent<SpawnPoint>();
			}
		}

		private static void BuildNavigation(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to