Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TheEnd v0.1.0
TheEndMod.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; 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 TheEndMod.Dragon; using TheEndMod.Enderman; using TheEndMod.Items; 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); } } } internal static class EndCrystals { public static GameObject crystalBodyPrefab; public static GameObject crystalMasterPrefab; 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) 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); Renderer[] componentsInChildren = crystalBodyPrefab.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } 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]; } } Collider[] componentsInChildren2 = crystalBodyPrefab.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)((Component)val3).GetComponent<HurtBox>())) { SphereCollider val4 = (SphereCollider)(object)((val3 is SphereCollider) ? val3 : null); if (val4 != null) { val4.radius = Mathf.Max(val4.radius, 2.2f); } } } ContentAddition.AddBody(crystalBodyPrefab); LanguageAPI.Add("THEEND_CRYSTAL_NAME", "End Crystal"); } public static void SpawnAll() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } foreach (EndIsland.Pillar pillar in EndIsland.pillars) { NetworkServer.Spawn(Object.Instantiate<GameObject>(crystalBodyPrefab, pillar.crystalPos, Quaternion.identity)); } } } 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_00d8: 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_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) 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); } 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.5f, 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 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) 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 (Object.op_Implicit((Object)(object)val2) && NetworkServer.active) { val.healthComponent.Heal(val.healthComponent.fullHealth * 0.012f * Time.fixedDeltaTime, default(ProcChainMask), false); } } } internal static class EndEncounter { public static GameObject endPortalPrefab; public static GameObject exitPortalPrefab; public static GameObject gatewayPrefab; public static GameEndingDef ending; 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_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); EndCrystals.SpawnAll(); yield return (object)new WaitForSeconds(4f); SpawnDragon(); EndIsland.root.AddComponent<EndermanWaves>(); } public static CharacterMaster SpawnDragon() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) return DragonBody.Spawn(EndIsland.Origin + new Vector3(0f, 55f, EndIsland.IslandRadius * 0.55f), dropPosition: EndIsland.PerchPoint + Vector3.up * 3f, rotation: Quaternion.LookRotation(Vector3.back), onDefeated: 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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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) Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "THEEND_DRAGON_SLAIN" }); 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 } public struct Pillar { public Vector3 basePos; public Vector3 crystalPos; public float radius; } 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 Vector3 Origin = Vector3.zero; public static readonly List<Pillar> pillars = new List<Pillar>(); public static GameObject root; private const int N = 51; private static Block[,,] vox; 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); vox = new Block[103, 69, 103]; pillars.Clear(); GenerateTerrain(new PixelTextures.Rng(1337)); GeneratePillars(); GenerateFountain(); root = new GameObject("EndIsland"); root.transform.position = Origin; BuildMesh(root.transform); vox = null; 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) float num = 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); 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, Block.Obsidian); } } } } Set(num3, num6, num4, Block.Bedrock); pillars.Add(new Pillar { basePos = Origin + new Vector3(((float)num3 + 0.5f) * 2f, 0f, ((float)num4 + 0.5f) * 2f), crystalPos = Origin + new Vector3(((float)num3 + 0.5f) * 2f, (float)(num6 + 1) * 2f + 1.6f, ((float)num4 + 0.5f) * 2f), radius = ((float)num5 + 0.5f) * 2f }); } } 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) Material[] array = (Material[])(object)new Material[4] { 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) }; 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>[4] { null, new List<int>(), new List<int>(), new List<int>() }; for (int k = i; k < i + 16 && k <= 51; k++) { for (int l = j; l < j + 16 && l <= 51; l++) { for (int m = -28; m <= 40; m++) { Block block = Get(k, m, l); if (block == Block.Air) { continue; } for (int n = 0; n < 6; n++) { Vector3Int val = Dirs[n]; if (Get(k + ((Vector3Int)(ref val)).x, m + ((Vector3Int)(ref val)).y, l + ((Vector3Int)(ref val)).z) == Block.Air) { int count = list.Count; for (int num = 0; num < 4; num++) { list.Add((new Vector3((float)k, (float)m, (float)l) + FaceCorners[n][num]) * 2f); list2.Add(Vector3Int.op_Implicit(val)); list3.Add(FaceUV[num]); } 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 num2 = 1; num2 < 4; num2++) { if (array2[num2].Count > 0) { list4.Add(array[num2]); list5.Add(array2[num2]); } } val2.subMeshCount = list5.Count; for (int num3 = 0; num3 < list5.Count; num3++) { val2.SetTriangles(list5[num3], num3); } 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 invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0165: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) MapNodeGroup val = new GameObject("GroundNodes").AddComponent<MapNodeGroup>(); ((Component)val).transform.SetParent(parent, false); val.graphType = (GraphType)0; MapNodeGroup val2 = new GameObject("AirNodes").AddComponent<MapNodeGroup>(); ((Component)val2).transform.SetParent(parent, false); val2.graphType = (GraphType)1; int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask); RaycastHit val3 = default(RaycastHit); for (float num2 = 0f - IslandRadius; num2 <= IslandRadius; num2 += 7f) { for (float num3 = 0f - IslandRadius; num3 <= IslandRadius; num3 += 7f) { if (Physics.Raycast(Origin + new Vector3(num2, 85f, num3), Vector3.down, ref val3, 136f, num) && !(((RaycastHit)(ref val3)).point.y > Origin.y + 5f) && !(((RaycastHit)(ref val3)).normal.y < 0.7f)) { val.AddNode(((RaycastHit)(ref val3)).point + Vector3.up * 0.5f); } } } for (float num4 = 0f - IslandRadius; num4 <= IslandRadius; num4 += 13f) { for (float num5 = 0f - IslandRadius; num5 <= IslandRadius; num5 += 13f) { if (num4 * num4 + num5 * num5 > IslandRadius * IslandRadius) { continue; } for (float num6 = 14f; num6 <= 70f; num6 += 12f) { Vector3 val4 = Origin + new Vector3(num4, num6, num5); if (!Physics.CheckSphere(val4, 3f, num)) { val2.AddNode(val4); } } } } val.UpdateNoCeilingMasks(); val.UpdateTeleporterMasks(); NodeGraph val5 = ScriptableObject.CreateInstance<NodeGraph>(); NodeGraph val6 = ScriptableObject.CreateInstance<NodeGraph>(); val.Bake(val5); val2.Bake(val6); val.nodeGraph = val5; val2.nodeGraph = val6; GameObject val7 = new GameObject("SceneInfo"); val7.SetActive(false); val7.transform.SetParent(parent, false); SceneInfo obj = val7.AddComponent<SceneInfo>(); obj.groundNodeGroup = val; obj.airNodeGroup = val2; obj.groundNodesAsset = val5; obj.airNodesAsset = val6; val7.SetActive(true); if (!Object.op_Implicit((Object)(object)DirectorCore.instance)) { ((Component)new GameObject("DirectorCore").AddComponent<DirectorCore>()).transform.SetParent(parent, false); } if (!Object.op_Implicit((Object)(object)GlobalEventManager.instance)) { GameObject val8 = new GameObject("GlobalEventManager"); val8.transform.SetParent(parent, false); val8.AddComponent<GlobalEventManager>(); } } private static void BuildOutOfBounds(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_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_003c: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OutOfBoundsZone") { layer = LayerIndex.collideWithCharacterHullOnly.intVal }; val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(0f, -126f, 0f); BoxCollider obj = val.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = new Vector3(6000f, 60f, 6000f); MapZone obj2 = val.AddComponent<MapZone>(); obj2.triggerType = (TriggerType)1; obj2.zoneType = (ZoneType)0; } } internal static class MeshUtil { public class BoxBuilder { private readonly List<Vector3> verts = new List<Vector3>(); private readonly List<Vector3> norms = new List<Vector3>(); private readonly List<Vector2> uvs = new List<Vector2>(); private readonly List<int> tris = new List<int>(); private readonly float uvPerMetre; public bool Empty => verts.Count == 0; public BoxBuilder(float uvPerMetre = 0.5f) { this.uvPerMetre = uvPerMetre; } public void Box(Vector3 center, Vector3 size, Quaternion? rot = null) { //IL_0014: 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_0019: 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_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: 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_0050: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Quaternion q = (Quaternion)(((??)rot) ?? Quaternion.identity); Vector3 val = size * 0.5f; Face(center, q, Vector3.right, Vector3.up, Vector3.forward, val.x, val.y, val.z); Face(center, q, Vector3.left, Vector3.up, Vector3.back, val.x, val.y, val.z); Face(center, q, Vector3.up, Vector3.forward, Vector3.right, val.y, val.z, val.x); Face(center, q, Vector3.down, Vector3.back, Vector3.right, val.y, val.z, val.x); Face(center, q, Vector3.forward, Vector3.up, Vector3.left, val.z, val.y, val.x); Face(center, q, Vector3.back, Vector3.up, Vector3.right, val.z, val.y, val.x); } public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001e: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(b - a, d - a); Vector3 normalized = ((Vector3)(ref val)).normalized; val = b - a; float magnitude = ((Vector3)(ref val)).magnitude; val = d - a; AddQuad(a, b, c, d, normalized, magnitude, ((Vector3)(ref val)).magnitude); Vector3 n = -normalized; val = b - a; float magnitude2 = ((Vector3)(ref val)).magnitude; val = d - a; AddQuad(d, c, b, a, n, magnitude2, ((Vector3)(ref val)).magnitude); } private void Face(Vector3 c, Quaternion q, Vector3 n, Vector3 up, Vector3 right, float hn, float hu, float hr) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = c + q * (n * hn); Vector3 val2 = q * (up * hu); Vector3 val3 = q * (right * hr); AddQuad(val - val3 - val2, val - val3 + val2, val + val3 + val2, val + val3 - val2, q * n, hr * 2f, hu * 2f); } private void AddQuad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 n, float w, float h) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0047: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) int count = verts.Count; verts.Add(a); verts.Add(b); verts.Add(c); verts.Add(d); for (int i = 0; i < 4; i++) { norms.Add(n); } float num = Mathf.Max(1f, Mathf.Round(w * uvPerMetre)); float num2 = Mathf.Max(1f, Mathf.Round(h * uvPerMetre)); uvs.Add(new Vector2(0f, 0f)); uvs.Add(new Vector2(0f, num2)); uvs.Add(new Vector2(num, num2)); uvs.Add(new Vector2(num, 0f)); tris.Add(count); tris.Add(count + 1); tris.Add(count + 2); tris.Add(count); tris.Add(count + 2); tris.Add(count + 3); } public Mesh ToMesh(string name) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(verts); val.SetNormals(norms); val.SetUVs(0, uvs); val.SetTriangles(tris, 0); val.RecalculateBounds(); val.RecalculateTangents(); return val; } } public static Mesh Sphere(int rings, int segments, bool inward = false) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); Vector3 val = default(Vector3); for (int i = 0; i <= rings; i++) { float num = (float)i / (float)rings; float num2 = num * MathF.PI; for (int j = 0; j <= segments; j++) { float num3 = (float)j / (float)segments; float num4 = num3 * MathF.PI * 2f; ((Vector3)(ref val))..ctor(Mathf.Sin(num2) * Mathf.Cos(num4), Mathf.Cos(num2), Mathf.Sin(num2) * Mathf.Sin(num4)); list.Add(val); list2.Add(inward ? (-val) : val); list3.Add(new Vector2(num3, 1f - num)); } } for (int k = 0; k < rings; k++) { for (int l = 0; l < segments; l++) { int num5 = k * (segments + 1) + l; int num6 = num5 + segments + 1; if (inward) { list4.Add(num5); list4.Add(num5 + 1); list4.Add(num6); list4.Add(num5 + 1); list4.Add(num6 + 1); list4.Add(num6); } else { list4.Add(num5); list4.Add(num6); list4.Add(num5 + 1); list4.Add(num5 + 1); list4.Add(num6); list4.Add(num6 + 1); } } } Mesh val2 = new Mesh { name = "Sphere" }; val2.SetVertices(list); val2.SetNormals(list2); val2.SetUVs(0, list3); val2.SetTriangles(list4, 0); val2.RecalculateBounds(); return val2; } } internal static class PixelTextures { private delegate Color Pixel(int x, int y, Rng r); internal class Rng { private uint s; public Rng(int seed) { s = (uint)(seed * -1640531535 + 1); } public uint Next() { s ^= s << 13; s ^= s >> 17; s ^= s << 5; return s; } public float Range(float a, float b) { return a + (b - a) * (float)(Next() & 0xFFFFFF) / 16777216f; } public int Range(int a, int b) { return a + (int)(Next() % (uint)(b - a)); } } private static Texture2D endStone; private static Texture2D obsidian; private static Texture2D bedrock; private static Texture2D dragonScales; private static Texture2D portalStars; private static Texture2D starSky; private static Texture2D crystal; private static Texture2D white; private static Texture2D endermanSkin; private static Texture2D dragonEgg; public static Texture2D EndStone { get { if (!Object.op_Implicit((Object)(object)endStone)) { return endStone = Make(16, 101, delegate(int x, int y, Rng r) { //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_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_0073: 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_00a5: 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) float num = r.Range(0f, 1f); Color val = Color32.op_Implicit(new Color32((byte)221, (byte)223, (byte)165, byte.MaxValue)); if (num < 0.12f) { return Color32.op_Implicit(new Color32((byte)181, (byte)180, (byte)128, byte.MaxValue)); } if (num < 0.3f) { return Color32.op_Implicit(new Color32((byte)205, (byte)206, (byte)148, byte.MaxValue)); } return (num > 0.93f) ? Color32.op_Implicit(new Color32((byte)236, (byte)238, (byte)186, byte.MaxValue)) : val; }, (FilterMode)0); } return endStone; } } public static Texture2D Obsidian { get { if (!Object.op_Implicit((Object)(object)obsidian)) { return obsidian = Make(16, 202, delegate(int x, int y, Rng r) { //IL_0024: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) float num = r.Range(0f, 1f); if (num < 0.08f) { return Color32.op_Implicit(new Color32((byte)72, (byte)52, (byte)110, byte.MaxValue)); } if (num < 0.25f) { return Color32.op_Implicit(new Color32((byte)38, (byte)28, (byte)58, byte.MaxValue)); } return (num > 0.95f) ? Color32.op_Implicit(new Color32((byte)100, (byte)76, (byte)140, byte.MaxValue)) : Color32.op_Implicit(new Color32((byte)24, (byte)17, (byte)38, byte.MaxValue)); }, (FilterMode)0); } return obsidian; } } public static Texture2D Bedrock { get { if (!Object.op_Implicit((Object)(object)bedrock)) { return bedrock = Make(16, 303, delegate(int x, int y, Rng r) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) float num = r.Range(0f, 1f); byte num2 = (byte)((num < 0.3f) ? 40 : ((num < 0.6f) ? 85 : ((num < 0.85f) ? 120 : 160))); return Color32.op_Implicit(new Color32(num2, num2, num2, byte.MaxValue)); }, (FilterMode)0); } return bedrock; } } public static Texture2D DragonScales { get { if (!Object.op_Implicit((Object)(object)dragonScales)) { return dragonScales = Make(16, 404, delegate(int x, int y, Rng r) { //IL_0032: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) float num = r.Range(0f, 1f); if (y % 4 == 0 || (x + y / 4 * 2) % 8 == 0) { return Color32.op_Implicit(new Color32((byte)24, (byte)22, (byte)28, byte.MaxValue)); } if (num < 0.2f) { return Color32.op_Implicit(new Color32((byte)78, (byte)74, (byte)88, byte.MaxValue)); } return (num > 0.9f) ? Color32.op_Implicit(new Color32((byte)104, (byte)98, (byte)118, byte.MaxValue)) : Color32.op_Implicit(new Color32((byte)52, (byte)49, (byte)60, byte.MaxValue)); }, (FilterMode)0); } return dragonScales; } } public static Texture2D PortalStars { get { if (!Object.op_Implicit((Object)(object)portalStars)) { return portalStars = Make(64, 505, delegate(int x, int y, Rng r) { //IL_0028: 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_0045: Unknown result type (might be due to invalid IL or missing references) float num = r.Range(0f, 1f); if (num > 0.985f) { return new Color(0.75f, 1f, 0.9f); } return (num > 0.96f) ? new Color(0.2f, 0.45f, 0.4f) : new Color(0.02f, 0.03f, 0.05f); }, (FilterMode)0); } return portalStars; } } public static Texture2D StarSky { get { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_00b8: 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_00c2: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)starSky)) { return starSky; } Rng rng = new Rng(606); Texture2D val = new Texture2D(1024, 512, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; Color[] array = (Color[])(object)new Color[524288]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.2f, 0.09f, 0.3f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.045f, 0.022f, 0.08f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.05f, 0.022f, 0.085f); for (int i = 0; i < 512; i++) { float num = ((float)i + 0.5f) / 512f; float num2 = Mathf.Abs(num - 0.5f) * 2f; Color val5 = Color.Lerp(val2, (num > 0.5f) ? val3 : val4, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num2 / 0.55f))); for (int j = 0; j < 1024; j++) { float num3 = Cloud((float)j / 64f, (float)i / 64f, 16) * 0.65f + Cloud((float)j / 24f, (float)i / 24f, 42) * 0.35f; Color val6 = val5 + new Color(0.06f, 0.02f, 0.09f) * Mathf.Clamp01(num3 * 1.6f - 0.6f) * (1f - num2 * 0.6f); float num4 = rng.Range(0f, 1f); if (num4 > 0.9988f) { ((Color)(ref val6))..ctor(1f, 1f, 1f); } else if (num4 > 0.9965f) { ((Color)(ref val6))..ctor(0.6f, 0.52f, 0.8f); } array[i * 1024 + j] = val6; } } val.SetPixels(array); val.Apply(false, true); return starSky = val; } } public static Texture2D DragonEgg { get { if (!Object.op_Implicit((Object)(object)dragonEgg)) { return dragonEgg = Make(16, 909, delegate(int x, int y, Rng r) { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = r.Range(0f, 1f); if (num > 0.93f) { return Color32.op_Implicit(new Color32((byte)150, (byte)70, (byte)200, byte.MaxValue)); } if (num > 0.82f) { return Color32.op_Implicit(new Color32((byte)84, (byte)36, (byte)120, byte.MaxValue)); } return (num < 0.2f) ? Color32.op_Implicit(new Color32((byte)10, (byte)6, (byte)14, byte.MaxValue)) : Color32.op_Implicit(new Color32((byte)22, (byte)14, (byte)30, byte.MaxValue)); }, (FilterMode)0); } return dragonEgg; } } public static Texture2D EndermanSkin { get { if (!Object.op_Implicit((Object)(object)endermanSkin)) { return endermanSkin = Make(16, 808, delegate(int x, int y, Rng r) { //IL_0024: 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_0058: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) float num = r.Range(0f, 1f); if (num < 0.15f) { return Color32.op_Implicit(new Color32((byte)16, (byte)14, (byte)20, byte.MaxValue)); } return (num > 0.88f) ? Color32.op_Implicit(new Color32((byte)48, (byte)42, (byte)58, byte.MaxValue)) : Color32.op_Implicit(new Color32((byte)30, (byte)27, (byte)36, byte.MaxValue)); }, (FilterMode)0); } return endermanSkin; } } public static Texture2D Crystal { get { if (!Object.op_Implicit((Object)(object)crystal)) { return crystal = Make(16, 707, delegate(int x, int y, Rng r) { //IL_003a: 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_0076: 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_007b: Unknown result type (might be due to invalid IL or missing references) bool num = x == 0 || y == 0 || x == 15 || y == 15; float num2 = r.Range(0f, 1f); return num ? Color32.op_Implicit(new Color32(byte.MaxValue, (byte)214, byte.MaxValue, byte.MaxValue)) : Color32.op_Implicit((num2 < 0.5f) ? new Color32((byte)220, (byte)120, (byte)230, byte.MaxValue) : new Color32((byte)180, (byte)80, (byte)200, byte.MaxValue)); }, (FilterMode)0); } return crystal; } } public static Texture2D White { get { if (!Object.op_Implicit((Object)(object)white)) { return white = Make(4, 1, (int x, int y, Rng r) => Color.white, (FilterMode)0); } return white; } } private static float Cloud(float x, float y, int period) { 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); return Mathf.Lerp(Mathf.Lerp(H(num, num2), H(num + 1, num2), num5), Mathf.Lerp(H(num, num2 + 1), H(num + 1, num2 + 1), num5), num6); float H(int a, int b) { a = (a % period + period) % period; int num7 = a * 374761393 + b * 668265263 + 777; int num8 = (num7 ^ (num7 >>> 13)) * 1274126177; return (float)(uint)((num8 ^ (num8 >>> 16)) & 0xFFFF) / 65535f; } } private static Texture2D Make(int size, int seed, Pixel f, FilterMode filter = (FilterMode)0) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //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) Rng r = new Rng(seed); Texture2D val = new Texture2D(size, size, (TextureFormat)4, true) { filterMode = filter, wrapMode = (TextureWrapMode)0, anisoLevel = 4 }; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { array[i * size + j] = f(j, i, r); } } val.SetPixels(array); val.Apply(true, true); return val; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.jerelo.theend", "TheEnd", "0.1.0")] public class TheEndPlugin : BaseUnityPlugin { public const string GUID = "com.jerelo.theend"; public const string NAME = "TheEnd"; public const string VERSION = "0.1.0"; internal static TheEndPlugin instance; internal static ManualLogSource log; internal static ConfigEntry<bool> portalAfterStage5; private void Awake() { instance = this; log = ((BaseUnityPlugin)this).Logger; portalAfterStage5 = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PortalAfterStage5", true, "Open a portal to The End next to the teleporter once it is charged on a stage-5 map."); EndStage.Init(); DragonBody.Init(); DragonEgg.Init(); EndermanBody.Init(); EndCrystals.Init(); EndEncounter.Init(); DragonSkins.Init(); } } internal static class EndStage { public const string SceneName = "space"; private const string SpaceSceneGuid = "5d8ea33392b43b94daac86dcf06740ab"; public static SceneDef sceneDef; public static void Init() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) sceneDef = ScriptableObject.CreateInstance<SceneDef>(); sceneDef.cachedName = "space"; sceneDef.sceneAddress = new AssetReferenceScene("5d8ea33392b43b94daac86dcf06740ab"); sceneDef.sceneType = (SceneType)1; sceneDef.stageOrder = 6; sceneDef.nameToken = "THEEND_STAGE_NAME"; sceneDef.subtitleToken = "THEEND_STAGE_SUBTITLE"; sceneDef.loreToken = "THEEND_STAGE_LORE"; sceneDef.environmentColor = new Color(0.45f, 0.2f, 0.6f); sceneDef.validForRandomSelection = false; sceneDef.shouldIncludeInLogbook = false; sceneDef.blockOrbitalSkills = true; sceneDef.destinationsGroup = Assets.Load<SceneCollection>("RoR2/Base/SceneGroups/loopSgStage1.asset"); SceneDef val = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/Base/moon2/moon2.asset").WaitForCompletion(); if (Object.op_Implicit((Object)(object)val)) { sceneDef.mainTrack = val.mainTrack; sceneDef.bossTrack = val.bossTrack; sceneDef.portalMaterial = val.portalMaterial; } ContentAddition.AddSceneDef(sceneDef); SceneManager.sceneLoaded += OnSceneLoaded; LanguageAPI.Add("THEEND_STAGE_NAME", "The End"); LanguageAPI.Add("THEEND_STAGE_SUBTITLE", "Where the Void Sleeps"); LanguageAPI.Add("THEEND_STAGE_LORE", "An island of pale stone, adrift in an endless dark."); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name != "space") { return; } try { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { rootGameObjects[i].SetActive(false); } EndIsland.Build(); } catch (Exception ex) { TheEndPlugin.log.LogError((object)("Failed to build The End: " + ex)); } } } } namespace TheEndMod.Skins { public static class DragonSkins { private sealed class Pending { public Material placeholder; public AssetReferenceT<Material> address; public Material direct; public Material source; public readonly List<Texture2D> generated = new List<Texture2D>(); public bool done; } private sealed class Job { public SurvivorDef survivor; public GameObject model; public ModelSkinController controller; public SkinDef defaultSkin; public SkinDefParams defaultParams; public AsyncOperationHandle<SkinDefParams> paramsHandle; } public const string UnlockableName = "Skins.TheEnd.EnderDragon"; public const string NameToken = "THEEND_SKIN_ENDERDRAGON_NAME"; public const string UnlockNameToken = "THEEND_SKIN_ENDERDRAGON_UNLOCK_NAME"; public const string UnlockDescToken = "THEEND_SKIN_ENDERDRAGON_UNLOCK_DESC"; public static UnlockableDef unlockable; public static Sprite icon; private static readonly Color Purple = new Color(0.72f, 0.25f, 1f); private static readonly Color LightColor = new Color(0.75f, 0.35f, 1f); private const bool TintFx = true; private static bool initialized; private static bool prepared; private static readonly HashSet<SkinDef> ourSkins = new HashSet<SkinDef>(); private static readonly Dictionary<SkinDef, List<Pending>> pendingBySkin = new Dictionary<SkinDef, List<Pending>>(); private static readonly Dictionary<object, Pending> pendingBySource = new Dictionary<object, Pending>(); private static readonly List<AsyncOperationHandle<Material>> heldMaterials = new List<AsyncOperationHandle<Material>>(); private static readonly List<AsyncOperationHandle<SkinDefParams>> paramHandles = new List<AsyncOperationHandle<SkinDefParams>>(); private static readonly List<string> skipped = new List<string>(); private static int converted; private static int failed; private static Texture2D fxRamp; private static GameObject display; private static Texture2D FxRamp { get { //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_002a: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00d5: 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_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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_0080: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)fxRamp)) { return fxRamp; } Texture2D val = new Texture2D(256, 8, (TextureFormat)4, false) { name = "texEnderDragonFxRamp", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags