Decompiled source of MuckAscendant v4.0.0
BepInEx/plugins/MuckAscendant/MuckAscendant.dll
Decompiled 35 minutes 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.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 HarmonyLib; using Microsoft.CodeAnalysis; using MuckAscendant.Bosses; using MuckAscendant.Core; using MuckAscendant.Items; using MuckAscendant.Systems; using MuckAscendant.Systems.PostGame; using MuckAscendant.Systems.Save; using MuckAscendant.UI; using MuckAscendant.WorldGen; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Seyid Abdüsselam Kılıç")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 Seyid Abdüsselam Kılıç")] [assembly: AssemblyDescription("Muck Ascendant - end-game and boss overhaul for Muck")] [assembly: AssemblyFileVersion("4.0.0.0")] [assembly: AssemblyInformationalVersion("4.0.0+a1fac59b5e1a720b482847a8ded6346ebb61090a")] [assembly: AssemblyProduct("Muck Ascendant")] [assembly: AssemblyTitle("MuckAscendant")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Seyidkilic/MuckAscendant")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MuckAscendant.WorldGen { public static class AstralOre { [HarmonyPatch(typeof(LootExtra), "DropMobLoot")] private static class VoidiumDropPatch { private static void Postfix(Transform dropTransform) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)dropTransform == (Object)null) && !((Object)(object)AstralContent.VoidiumShard == (Object)null) && Session.Day >= ModConfig.AstralStartDay.Value && !(Random.value >= ModConfig.VoidiumDropChance.Value)) { Mob component = ((Component)dropTransform).GetComponent<Mob>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.mobType == (Object)null) && (int)component.mobType.behaviour != 0 && !((Object)(object)((Component)dropTransform).GetComponent<EliteMob>() != (Object)null)) { EliteLoot.Drop(AstralContent.VoidiumShard, 1, dropTransform.position); } } } catch (Exception e) { Log.PatchFailed("LootExtra.DropMobLoot (Voidium)", e); } } } private const int FirstId = 2000000; private const int MinimumPickaxeTier = 4; public const float FallSeconds = 2.2f; private const int MaxId = 3000000; private static int nextId = 2000000; private static Mesh nodeMesh; private static Material nodeMaterial; private static readonly Dictionary<int, Vector3> landed = new Dictionary<int, Vector3>(); public static void Init() { Session.Starting += delegate { nextId = 2000000; landed.Clear(); }; Session.Ended += landed.Clear; ModNet.OnClient(NetOp.OreSpawn, delegate(int sender, Packet packet) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) int id = NetRead.Int(packet, 2000000, 3000000, "node"); int hp = NetRead.Int(packet, 1, 100000000, "health"); Vector3 position = NetRead.Position(packet, "position"); float num = NetRead.Float(packet, -10f, 600f, "delay"); if (num < 0f) { Log.Guard("Astral Crystal", delegate { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Build(id, hp, position); }); } else { AstralShower.Begin(id, hp, position, num); } }); ModNet.PeerReady += Resync; SaveHooks.PlayerRestored += delegate(int client) { Resync(client, ModNet.PeerProtocol(client)); }; SaveHooks.Register("astralOre", CaptureSave, RestoreSave); } private static JsonObject CaptureSave() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) JsonArray jsonArray = new JsonArray(); ResourceManager instance = ResourceManager.Instance; if ((Object)(object)instance != (Object)null) { foreach (KeyValuePair<int, Vector3> item in landed) { if (instance.list.TryGetValue(item.Key, out var value) && !((Object)(object)value == (Object)null)) { Hitable component = value.GetComponent<Hitable>(); if (!((Object)(object)component == (Object)null) && component.hp > 0) { jsonArray.Add(new JsonObject().Set("id", item.Key).Set("hp", component.hp).Set("maxHp", component.maxHp) .Set("pos", SaveKeys.Vector(item.Value))); } } } } return new JsonObject().Set("nextId", nextId).Set("nodes", jsonArray); } private static void RestoreSave(JsonObject data) { //IL_00c2: 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) nextId = Mathf.Clamp(data.Int("nextId", 2000000), 2000000, 3000000); JsonArray jsonArray = data.Arr("nodes"); if (jsonArray == null || (Object)(object)ResourceManager.Instance == (Object)null) { return; } foreach (JsonNode item in jsonArray.Items) { if (!(item is JsonObject jsonObject) || !SaveKeys.ReadVector(jsonObject.Arr("pos"), out var value)) { continue; } int num = jsonObject.Int("id", -1); int num2 = jsonObject.Int("hp", 0); int num3 = jsonObject.Int("maxHp", num2); if (num < 2000000 || num >= 3000000 || num2 <= 0) { continue; } Build(num, num2, value); if (ResourceManager.Instance.list.TryGetValue(num, out var value2) && !((Object)(object)value2 == (Object)null)) { Hitable component = value2.GetComponent<Hitable>(); if ((Object)(object)component != (Object)null) { component.maxHp = Mathf.Max(num2, num3); } landed[num] = value; if (num >= nextId) { nextId = num + 1; } } } } public static void SpawnNode(Vector3 position, float delay) { //IL_0021: 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) if (nextId < 3000000) { int num = nextId++; landed[num] = position; Send(-1, num, ModConfig.AstralNodeHp.Value, position, delay); } } private static void Send(int client, int id, int hp, Vector3 position, float delay) { //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) Action<Packet> write = delegate(Packet p) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) p.Write(id); p.Write(hp); p.Write(position); p.Write(delay); }; if (client < 0) { ModNet.Broadcast(NetOp.OreSpawn, write); } else { ModNet.SendTo(client, NetOp.OreSpawn, write); } } private static void Resync(int client, int protocol) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LocalClient.instance == (Object)null || client == LocalClient.instance.myId || (Object)(object)ResourceManager.Instance == (Object)null) { return; } foreach (KeyValuePair<int, Vector3> item in landed) { if (ResourceManager.Instance.list.TryGetValue(item.Key, out var value) && !((Object)(object)value == (Object)null)) { Hitable component = value.GetComponent<Hitable>(); if ((Object)(object)component != (Object)null && component.hp > 0) { Send(client, item.Key, component.hp, item.Value, -1f); } } } } public static int CountNodes() { int num = 0; if ((Object)(object)ResourceManager.Instance == (Object)null) { return 0; } for (int i = 2000000; i < nextId; i++) { if (ResourceManager.Instance.list.ContainsKey(i)) { num++; } } return num; } public static void Build(int id, int hp, Vector3 position) { //IL_0049: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) ResourceManager instance = ResourceManager.Instance; if ((Object)(object)instance == (Object)null || instance.list == null || instance.list.ContainsKey(id) || (Object)(object)AstralContent.AstralCrystal == (Object)null) { return; } HitableRock val = FindTemplate(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, position, Quaternion.Euler(0f, (float)id * 77f % 360f, 0f)); ((Object)val2).name = "Astral Crystal Node"; val2.SetActive(true); HitableRock component = val2.GetComponent<HitableRock>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val2); return; } ((Hitable)component).entityName = "Astral Crystal"; ((Hitable)component).SetId(id); ((Hitable)component).hp = (((Hitable)component).maxHp = hp); ((HitableResource)component).compatibleItem = (ItemType)2; ((HitableResource)component).minTier = 4; ((HitableResource)component).dropItem = AstralContent.AstralCrystal; ((Hitable)component).dropTable = CreateLoot(); if ((Object)(object)nodeMesh == (Object)null) { MeshBuilder meshBuilder = AstralModels.Crystal(AstralModels.Astral, AstralModels.AstralLight, AstralModels.AstralDeep); nodeMesh = meshBuilder.ToMesh("AstralNode"); nodeMaterial = meshBuilder.ToMaterial("AstralNode", Shader.Find("Standard"), 0.6f); } Vector3 val3 = Vector3.one * 2.6f; val2.transform.localScale = val3; ((HitableResource)component).SetDefaultScale(val3); MeshFilter componentInChildren = val2.GetComponentInChildren<MeshFilter>(); MeshRenderer componentInChildren2 = val2.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.sharedMesh = nodeMesh; } if ((Object)(object)componentInChildren2 != (Object)null) { ((Renderer)componentInChildren2).sharedMaterial = nodeMaterial; } SphereCollider component2 = val2.GetComponent<SphereCollider>(); if ((Object)(object)component2 != (Object)null) { component2.center = new Vector3(0f, 0.2f, 0f); component2.radius = 0.75f; } val2.transform.position = position + Vector3.up * 1.2f; instance.AddObject(id, val2); Vfx.Beacon(position, AstralModels.Astral, 130f, 0.8f, 0.22f).transform.SetParent(val2.transform, true); } private static LootDrop CreateLoot() { //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_0042: 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_0066: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown float value = ModConfig.AstralYieldMultiplier.Value; LootDrop val = ScriptableObject.CreateInstance<LootDrop>(); val.loot = (LootItems[])(object)new LootItems[2] { new LootItems { item = AstralContent.AstralCrystal, amountMin = Mathf.Max(1, Mathf.RoundToInt(4f * value)), amountMax = Mathf.Max(1, Mathf.RoundToInt(8f * value)), dropChance = 1f }, new LootItems { item = AstralContent.VoidiumShard, amountMin = 1, amountMax = 2, dropChance = 0.5f } }; return val; } private static HitableRock FindTemplate() { //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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 HitableRock val = null; HitableRock[] array = Resources.FindObjectsOfTypeAll<HitableRock>(); foreach (HitableRock val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } Scene scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid() && !((Object)(object)((Component)val2).GetComponent<MeshFilter>() == (Object)null)) { if ((Object)(object)((HitableResource)val2).dropItem != (Object)null && string.Equals(((HitableResource)val2).dropItem.name, "Obamium Ore", StringComparison.Ordinal)) { return val2; } if ((int)((HitableResource)val2).compatibleItem == 2) { val = val2; } } } if ((Object)(object)val == (Object)null) { Log.Error("No ore prefab found, Astral Crystals cannot be created."); } return val; } } public sealed class AstralShower : MonoBehaviour { private sealed class Meteor { public int Id; public int Hp; public Vector3 Target; public Vector3 From; public float Start; public float NextTrail; } private static readonly List<Meteor> falling = new List<Meteor>(); private int lastDay; private void Awake() { Session.Starting += delegate { falling.Clear(); lastDay = 0; }; Session.Ended += falling.Clear; SaveHooks.Register("astralShower", () => new JsonObject().Set("lastDay", lastDay), delegate(JsonObject data) { lastDay = Mathf.Max(0, data.Int("lastDay", 0)); }); } public static void Begin(int id, int hp, Vector3 target, float delay) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_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) Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * 60f; falling.Add(new Meteor { Id = id, Hp = hp, Target = target, From = target + new Vector3(val.x, 160f, val.y), Start = Time.time + delay }); } private void Update() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (falling.Count > 0) { Animate(); } if (!Session.IsHost || !Session.InGame || SaveSession.Restoring || (int)GameManager.gameSettings.gameMode != 0) { return; } int day = Session.Day; if (day > lastDay) { lastDay = day; if (day >= ModConfig.AstralStartDay.Value) { Shower(); } } } public static void Shower() { //IL_0064: 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_0132: 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_00a4: 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_00cf: Unknown result type (might be due to invalid IL or missing references) float num = (float)ModConfig.AstralNodesPerDay.Value * ModConfig.AstralRarity.Value; int num2 = Mathf.FloorToInt(num) + ((Random.value < num - Mathf.Floor(num)) ? 1 : 0); num2 = Mathf.Min(num2, ModConfig.AstralMaxNodes.Value - AstralOre.CountNodes()); int num3 = 0; for (int i = 0; i < num2; i++) { PlayerManager val = GameRefs.RandomLivingPlayer(); if (GameRefs.TryFindSpawnPoint((i % 2 == 0 && (Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero, (i % 2 == 0) ? 60f : 0f, (i % 2 == 0) ? 260f : 1200f, out var point) && !Physics.CheckSphere(point + Vector3.up * 2f, 2f, 1 << GameRefs.ObjectLayer, (QueryTriggerInteraction)1)) { AstralOre.SpawnNode(point, 1.5f + (float)num3 * 1.2f); num3++; } } if (num3 != 0) { ServerSend.SendChatMessage(-1, "", "<color=#7fefff>" + num3 + ((num3 == 1) ? " star has" : " stars have") + " fallen. Follow the beams of light!"); Banners.Everyone("Starfall", "Astral Crystals have landed on the island", AstralModels.Astral); } } private static void Animate() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) for (int num = falling.Count - 1; num >= 0; num--) { Meteor meteor = falling[num]; float num2 = (Time.time - meteor.Start) / 2.2f; if (!(num2 < 0f)) { if (num2 < 1f) { if (!(Time.time < meteor.NextTrail)) { meteor.NextTrail = Time.time + 0.025f; Vector3 position = Vector3.Lerp(meteor.From, meteor.Target, num2 * num2); Vfx.Spark(position, Random.insideUnitSphere * 2f, AstralModels.Astral, 5f, 1.1f); Vfx.Spark(position, Random.insideUnitSphere, Color.white, 3f, 0.4f); } } else { falling.RemoveAt(num); Log.Guard("Astral Crystal", delegate { //IL_001c: Unknown result type (might be due to invalid IL or missing references) AstralOre.Build(meteor.Id, meteor.Hp, meteor.Target); }); Vfx.Explosion(meteor.Target, AstralModels.Astral, 7f); Sfx.Play("RockImpactLoud", meteor.Target, 1f, 0.8f, 160f); Vfx.Shake(meteor.Target, 70f, 0.5f); } } } } } public static class WorldGenSettings { private static bool overridden; private static float boss; private static float battle; private static float chest; public static float BossShrines { get { if (!overridden) { return ModConfig.BossShrineMultiplier.Value; } return boss; } } public static float BattleShrines { get { if (!overridden) { return ModConfig.BattleShrineMultiplier.Value; } return battle; } } public static float LootChests { get { if (!overridden) { return ModConfig.LootChestMultiplier.Value; } return chest; } } public static bool Overridden => overridden; public static void Init() { Session.Ended += Clear; } public static void Set(float bossShrines, float battleShrines, float lootChests) { overridden = true; boss = Mathf.Clamp(bossShrines, 1f, 20f); battle = Mathf.Clamp(battleShrines, 1f, 20f); chest = Mathf.Clamp(lootChests, 1f, 20f); } public static void Clear() { overridden = false; } public static string Encode(float bossShrines, float battleShrines, float lootChests) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; return bossShrines.ToString("R", invariantCulture) + ";" + battleShrines.ToString("R", invariantCulture) + ";" + lootChests.ToString("R", invariantCulture); } public static bool TryDecode(string text, out float bossShrines, out float battleShrines, out float lootChests) { bossShrines = (battleShrines = (lootChests = 1f)); if (string.IsNullOrEmpty(text)) { return false; } string[] array = text.Split(new char[1] { ';' }); CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, invariantCulture, out bossShrines) && !float.IsNaN(bossShrines) && float.TryParse(array[1], NumberStyles.Float, invariantCulture, out battleShrines) && !float.IsNaN(battleShrines) && float.TryParse(array[2], NumberStyles.Float, invariantCulture, out lootChests)) { return !float.IsNaN(lootChests); } return false; } } public static class StructureBoost { private enum Category { None, Boss, Battle, Chest, Guardian } private delegate GameObject SpawnTree(ResourceGenerator generator, Vector3 position); [HarmonyPatch(typeof(StructureSpawner), "Start")] private static class StructureSpawnerPatch { private static void Prefix(StructureSpawner __instance) { if (processed.Add(((Object)__instance).GetInstanceID())) { Log.Guard("StructureBoost", delegate { float num = Prepare(__instance.structurePrefabs, ((Object)__instance).name); __instance.nShrines = Mathf.RoundToInt((float)__instance.nShrines * num); }); } } } [HarmonyPatch(typeof(ResourceGenerator), "Start")] private static class ResourceGeneratorStartPatch { private static void Prefix(ResourceGenerator __instance) { if (spawnTree == null || randomGen == null || density == null || totalResources == null || !processed.Add(((Object)__instance).GetInstanceID())) { return; } Log.Guard("StructureBoost", delegate { float num = Prepare(__instance.resourcePrefabs, ((Object)__instance).name); if (num > 1.001f) { forestPasses[((Object)__instance).GetInstanceID()] = num; } }); } } [HarmonyPatch(typeof(ResourceGenerator), "GenerateForest")] private static class GenerateForestPatch { private static bool Prefix(ResourceGenerator __instance) { if ((Object)(object)__instance == (Object)null || !forestPasses.TryGetValue(((Object)__instance).GetInstanceID(), out var value)) { return true; } if ((Object)(object)__instance.mapGenerator == (Object)null || (Object)(object)__instance.drawChunks == (Object)null) { return true; } try { GenerateForest(__instance, value); } catch (Exception e) { Log.PatchFailed("ResourceGenerator.GenerateForest", e); return __instance.resources == null; } return false; } } private static readonly HashSet<int> processed = new HashSet<int>(); private static readonly Dictionary<int, float> forestPasses = new Dictionary<int, float>(); private static readonly SpawnTree spawnTree = CreateSpawnTree(); private static readonly FieldRef<ResourceGenerator, ConsistentRandom> randomGen = GameRefs.Field<ResourceGenerator, ConsistentRandom>("randomGen"); private static readonly FieldRef<ResourceGenerator, int> density = GameRefs.Field<ResourceGenerator, int>("density"); private static readonly FieldRef<ResourceGenerator, int> totalResources = GameRefs.Field<ResourceGenerator, int>("totalResources"); public static void Init() { Session.Starting += delegate { processed.Clear(); forestPasses.Clear(); }; WorldGenSettings.Init(); } private static SpawnTree CreateSpawnTree() { MethodInfo methodInfo = AccessTools.Method(typeof(ResourceGenerator), "SpawnTree", (Type[])null, (Type[])null); if (!(methodInfo == null)) { return AccessTools.MethodDelegate<SpawnTree>(methodInfo, (object)null, true); } return null; } private static Category Classify(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return Category.None; } if ((Object)(object)prefab.GetComponentInChildren<ShrineGuardian>(true) != (Object)null) { return Category.Guardian; } if ((Object)(object)prefab.GetComponentInChildren<ShrineBoss>(true) != (Object)null) { return Category.Boss; } if ((Object)(object)prefab.GetComponentInChildren<ShrineInteractable>(true) != (Object)null) { return Category.Battle; } if ((Object)(object)prefab.GetComponentInChildren<LootContainerInteract>(true) != (Object)null) { return Category.Chest; } return Category.None; } private static float MultiplierFor(Category category) { return category switch { Category.Boss => WorldGenSettings.BossShrines, Category.Battle => WorldGenSettings.BattleShrines, Category.Chest => WorldGenSettings.LootChests, _ => 1f, }; } private static float Prepare(WeightedSpawn[] list, string owner) { if (list == null || list.Length == 0) { return 1f; } float[] array = new float[list.Length]; float num = 0f; float num2 = 0f; bool flag = false; for (int i = 0; i < list.Length; i++) { Category category = Classify((list[i] != null) ? list[i].prefab : null); if (category == Category.Guardian) { return 1f; } flag = flag || category != Category.None; array[i] = MultiplierFor(category); if (list[i] != null) { num += Mathf.Max(0f, list[i].weight); num2 += Mathf.Max(0f, list[i].weight) * array[i]; } } if (!flag || num <= 0f || num2 <= 0f) { return 1f; } float num3 = num2 / num; if (num3 <= 1.001f) { return 1f; } for (int j = 0; j < list.Length; j++) { if (list[j] != null) { list[j].weight = Mathf.Max(0f, list[j].weight) * array[j]; } } Log.Debug("StructureBoost: " + owner + " x" + num3.ToString("0.##", CultureInfo.InvariantCulture)); return num3; } private static void GenerateForest(ResourceGenerator g, float passes) { int num = ((g.forceSeedOffset != -1) ? g.forceSeedOffset : ResourceManager.GetNextGenOffset()); float[,] array = g.mapGenerator.GeneratePerlinNoiseMap(GameManager.GetSeed()); float[,] noise = g.mapGenerator.GeneratePerlinNoiseMap(g.noiseData, GameManager.GetSeed() + num, g.useFalloffMap); g.width = array.GetLength(0); g.height = array.GetLength(1); float num2 = (float)(g.width - 1) / -2f; float num3 = (float)(g.height - 1) / 2f; AccessTools.PropertySetter(typeof(ResourceGenerator), "topLeftX").Invoke(g, new object[1] { num2 }); AccessTools.PropertySetter(typeof(ResourceGenerator), "topLeftZ").Invoke(g, new object[1] { num3 }); g.resources = new List<GameObject>[g.drawChunks.nChunks]; for (int i = 0; i < g.resources.Length; i++) { g.resources[i] = new List<GameObject>(); } int num4 = 0; try { int num5 = Mathf.Max(1, Mathf.FloorToInt(passes)); for (int j = 0; j < num5 || (num4 < g.minSpawnAmount && j < 100); j++) { num4 += Pass(g, array, noise, num2, num3, g.height); } float num6 = passes - Mathf.Floor(passes); if (num6 > 0.001f) { num4 += Pass(g, array, noise, num2, num3, Mathf.CeilToInt((float)g.height * num6)); } } catch (Exception ex) { Log.Error("Boosted world generation stopped early at '" + ((Object)g).name + "': " + ex); } totalResources.Invoke(g) = num4; g.drawChunks.InitChunks(g.resources); g.drawChunks.totalTrees = num4; } private static int Pass(ResourceGenerator g, float[,] heights, float[,] noise, float left, float top, int rows) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_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_0107: 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_0120: 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) ConsistentRandom val = randomGen.Invoke(g); int num = Mathf.Max(1, density.Invoke(g)); int num2 = 0; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < g.height && i < rows; i += num) { for (int j = 0; j < g.width; j += num) { if (heights[j, i] < g.minSpawnHeight || heights[j, i] > g.maxSpawnHeight || noise[j, i] < g.spawnThreshold) { continue; } float num3 = (noise[j, i] - g.spawnThreshold) / (1f - g.spawnThreshold); if (!(g.noiseDistribution.Evaluate((float)((Random)(object)val).NextDouble()) <= 1f - num3)) { Vector3 val2 = new Vector3(left + (float)j, 100f, top - (float)i) * g.worldScale; val2 += new Vector3((float)((Random)(object)val).Next(-g.randPos, g.randPos), 0f, (float)((Random)(object)val).Next(-g.randPos, g.randPos)); if (Physics.Raycast(val2, Vector3.down, ref val3, 1200f)) { val2.y = ((RaycastHit)(ref val3)).point.y; int num4 = Mathf.Min(g.drawChunks.FindChunk(j, i), g.drawChunks.nChunks - 1); g.resources[num4].Add(spawnTree(g, val2)); num2++; } } } } return num2; } } } namespace MuckAscendant.UI { public static class ArmorSlotFix { [HarmonyPatch(typeof(InventoryCell), "UpdateCell")] private static class UpdateCellPatch { private static void Postfix(InventoryCell __instance) { try { Apply(__instance); } catch (Exception e) { Log.PatchFailed("InventoryCell.UpdateCell", e); } } } private static readonly Dictionary<InventoryCell, Texture> silhouettes = new Dictionary<InventoryCell, Texture>(); private static Texture plain; public static void Init() { Session.Starting += Clear; Session.Ended += Clear; } private static void Clear() { silhouettes.Clear(); plain = null; } private static RawImage Background(InventoryCell cell) { if (!((Object)(object)cell != (Object)null)) { return null; } return ((Component)cell).GetComponent<RawImage>(); } private static Texture PlainSlot() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)plain != (Object)null) { return plain; } InventoryUI instance = InventoryUI.Instance; if ((Object)(object)instance == (Object)null || instance.cells == null) { return null; } foreach (InventoryCell cell in instance.cells) { if (!((Object)(object)cell == (Object)null) && !IsTagged(cell) && (int)cell.cellType == 0) { RawImage val = Background(cell); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.texture == (Object)null)) { plain = val.texture; break; } } } return plain; } private static bool IsTagged(InventoryCell cell) { if (cell.tags != null) { return cell.tags.Length != 0; } return false; } private static void Apply(InventoryCell cell) { if ((Object)(object)cell == (Object)null || !IsTagged(cell)) { return; } RawImage val = Background(cell); if (!((Object)(object)val == (Object)null)) { if (!silhouettes.TryGetValue(cell, out var value) || (Object)(object)value == (Object)null) { value = val.texture; silhouettes[cell] = value; } Texture val2 = (((Object)(object)cell.currentItem != (Object)null) ? PlainSlot() : null); val.texture = (((Object)(object)val2 != (Object)null) ? val2 : value); } } } public sealed class BossBarView : MonoBehaviour { private const float Width = 860f; private const float Height = 30f; private static readonly Color calm = new Color(0.62f, 0.22f, 1f); private static readonly Color angry = new Color(1f, 0.16f, 0.36f); private static readonly Color shielded = new Color(0.65f, 0.68f, 0.78f); private static readonly Color abyss = new Color(0.1f, 0.78f, 0.72f); private CanvasGroup group; private RectTransform fill; private RectTransform trail; private RectTransform marker; private Image fillImage; private Image frame; private TextMeshProUGUI title; private TextMeshProUGUI phase; private TextMeshProUGUI numbers; private CanvasGroup vanilla; private float trailValue = 1f; private float shownHp = -1f; private int shownState = -1; private EliteMob shownBoss; private static bool EnderShown { get { if ((Object)(object)RaidBoss.Current == (Object)null) { return (Object)(object)EnderBob.Current != (Object)null; } return false; } } public void Build(HudCanvas hud) { //IL_001a: 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_0038: 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_0080: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) RectTransform val = HudCanvas.Place(HudCanvas.Panel("Content", ((Component)this).transform), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -26f), new Vector2(860f, 100f)); group = ((Component)val).gameObject.AddComponent<CanvasGroup>(); group.alpha = 0f; title = hud.AddText("Name", (Transform)(object)val, 40f, Color.white, (TextAlignmentOptions)514); HudCanvas.Place(((TMP_Text)title).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(860f, 46f)); ((TMP_Text)title).fontStyle = (FontStyles)1; ((TMP_Text)title).characterSpacing = 8f; ((TMP_Text)title).outlineWidth = 0.16f; ((TMP_Text)title).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); RectTransform parent = HudCanvas.Place(HudCanvas.Panel("Bar", (Transform)(object)val), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -50f), new Vector2(860f, 30f)); frame = HudCanvas.AddImage("Frame", (Transform)(object)parent, calm); ((Graphic)frame).rectTransform.offsetMin = new Vector2(-4f, -4f); ((Graphic)frame).rectTransform.offsetMax = new Vector2(4f, 4f); HudCanvas.AddImage("Back", (Transform)(object)parent, new Color(0.07f, 0.04f, 0.11f, 1f)); trail = ((Graphic)HudCanvas.AddImage("Trail", (Transform)(object)parent, new Color(1f, 0.92f, 0.75f, 0.9f))).rectTransform; fillImage = HudCanvas.AddImage("Fill", (Transform)(object)parent, calm); fill = ((Graphic)fillImage).rectTransform; ((Graphic)HudCanvas.AddImage("Shine", (Transform)(object)parent, new Color(1f, 1f, 1f, 0.12f))).rectTransform.anchorMin = new Vector2(0f, 0.55f); marker = ((Graphic)HudCanvas.AddImage("Marker", (Transform)(object)parent, new Color(1f, 1f, 1f, 0.9f))).rectTransform; numbers = hud.AddText("Numbers", (Transform)(object)parent, 23f, Color.white, (TextAlignmentOptions)514); ((TMP_Text)numbers).fontStyle = (FontStyles)1; ((TMP_Text)numbers).outlineWidth = 0.12f; ((TMP_Text)numbers).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); phase = hud.AddText("Phase", (Transform)(object)val, 25f, Color.white, (TextAlignmentOptions)514); HudCanvas.Place(((TMP_Text)phase).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -86f), new Vector2(860f, 32f)); ((TMP_Text)phase).fontStyle = (FontStyles)1; ((TMP_Text)phase).outlineWidth = 0.1f; ((TMP_Text)phase).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); SetSpan(fill, 1f); SetSpan(trail, 1f); } private static void SetSpan(RectTransform rect, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0029: 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) rect.anchorMin = Vector2.zero; rect.anchorMax = new Vector2(Mathf.Clamp01(value), 1f); Vector2 offsetMin = (rect.offsetMax = Vector2.zero); rect.offsetMin = offsetMin; } private void Update() { //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) EliteMob eliteMob = RaidBoss.Current ?? EnderBob.Current; bool flag = (Object)(object)eliteMob != (Object)null && (Object)(object)eliteMob.Hitable != (Object)null; group.alpha = Mathf.MoveTowards(group.alpha, flag ? 1f : 0f, Time.unscaledDeltaTime * 2f); HideVanilla(flag); if (!flag) { shownState = -1; shownBoss = null; shownHp = -1f; return; } int num = (EnderShown ? ((int)(100 + EnderBob.State)) : ((int)RaidBoss.State)); if (num != shownState || (Object)(object)eliteMob != (Object)(object)shownBoss) { ShowState(eliteMob, num); } float num2 = Mathf.Clamp01((float)((Hitable)eliteMob.Hitable).hp / (float)Mathf.Max(1, ((Hitable)eliteMob.Hitable).maxHp)); SetSpan(fill, num2); trailValue = ((trailValue < num2) ? num2 : Mathf.MoveTowards(trailValue, num2, Time.deltaTime * Mathf.Max(0.04f, (trailValue - num2) * 1.5f))); SetSpan(trail, trailValue); if ((float)((Hitable)eliteMob.Hitable).hp != shownHp) { shownHp = ((Hitable)eliteMob.Hitable).hp; ((TMP_Text)numbers).text = ((Hitable)eliteMob.Hitable).hp.ToString("N0", CultureInfo.InvariantCulture) + " / " + ((Hitable)eliteMob.Hitable).maxHp.ToString("N0", CultureInfo.InvariantCulture); } if (EliteMob.IsImmune(eliteMob)) { ((Graphic)fillImage).color = Color.Lerp(shielded * 0.7f, shielded, 0.5f + 0.5f * Mathf.Sin(Time.time * 9f)); } } private void ShowState(EliteMob boss, int state) { //IL_00c6: 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_0066: 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_006b: 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_005f: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) if (shownState < 0 || (Object)(object)boss != (Object)(object)shownBoss) { trailValue = 1f; } shownState = state; shownBoss = boss; Color val; float num; if (EnderShown) { EnderBobState state2 = EnderBob.State; bool flag = state2 == EnderBobState.Enraged; val = (flag ? angry : ((state2 == EnderBobState.Abyss) ? Color.Lerp(abyss, calm, 0.45f) : abyss)); num = EnderBob.NextThreshold; ((TMP_Text)phase).text = ((state2 == EnderBobState.Shift) ? "IMMUNE - THE TIDE TURNS" : (flag ? "PHASE 3 - ENRAGED" : (state2 switch { EnderBobState.Intro => "AWAKENING", EnderBobState.Abyss => "PHASE 2 - THE ABYSS", _ => "PHASE 1", }))); } else { RaidState state3 = RaidBoss.State; bool flag = state3 == RaidState.Enraged; val = (flag ? angry : calm); num = (flag ? (-1f) : ModConfig.RaidBossEnrageThreshold.Value); ((TMP_Text)phase).text = ((state3 == RaidState.Transition) ? "IMMUNE - GET AWAY!" : (flag ? "ENRAGED" : ((state3 == RaidState.Intro) ? "AWAKENING" : "PHASE 1"))); } ((TMP_Text)title).text = boss.Def.Name.ToUpperInvariant(); ((Graphic)title).color = Color.Lerp(val, Color.white, 0.55f); ((Graphic)frame).color = Color.Lerp(val, Color.black, 0.25f); ((Graphic)fillImage).color = val; ((Graphic)phase).color = Color.Lerp(val, Color.white, 0.5f); ((Component)marker).gameObject.SetActive(num > 0f); if (!(num <= 0f)) { marker.anchorMin = new Vector2(num, 0f); marker.anchorMax = new Vector2(num, 1f); marker.offsetMin = new Vector2(-1.5f, -6f); marker.offsetMax = new Vector2(1.5f, 6f); } } private void HideVanilla(bool hide) { if ((Object)(object)vanilla == (Object)null) { if (!hide || (Object)(object)BossUI.Instance == (Object)null || (Object)(object)BossUI.Instance.layout == (Object)null) { return; } GameObject gameObject = ((Component)BossUI.Instance.layout).gameObject; vanilla = gameObject.GetComponent<CanvasGroup>(); if ((Object)(object)vanilla == (Object)null) { vanilla = gameObject.AddComponent<CanvasGroup>(); } } float num = (hide ? 0f : 1f); if (vanilla.alpha != num) { vanilla.alpha = num; } } } public sealed class ChestChoices : MonoBehaviour { public struct OfferMessage { public int Id; public int[] Powerups; public float Seconds; } private sealed class Offer { public int Id; public int Client; public Player Owner; public int[] Powerups; public Vector3 Position; public float Expires; } private sealed class Incoming { public int Id; public List<Powerup> Cards; public float Expires; } [HarmonyPatch(typeof(LootContainerInteract), "ServerExecute")] private static class LootContainerPatch { private static bool Prefix(LootContainerInteract __instance, int fromClient) { try { if (!ModConfig.PerkChoiceOnChests.Value || !LocalClient.serverOwner || (Object)(object)LocalClient.instance == (Object)null || (Object)(object)__instance == (Object)null || __instance.testPowerup || (Object)(object)ItemManager.Instance == (Object)null) { return true; } return !Open(__instance, fromClient); } catch (Exception e) { Log.PatchFailed("LootContainerInteract.ServerExecute", e); return true; } } } public const int Cards = 3; public const string Title = "Choose a Powerup"; public const float AnswerSeconds = 60f; public const float HostWaitSeconds = 75f; private const int MaxOpenPerPlayer = 4; private const int MaxQueued = 4; private static readonly Dictionary<int, Offer> offers = new Dictionary<int, Offer>(); private static readonly List<Offer> due = new List<Offer>(); private static readonly List<Incoming> queue = new List<Incoming>(); private static Incoming showing; private static int nextOfferId = 1; private float nextCheck; public static int OpenOffers => offers.Count; public static int Queued => queue.Count; public static void Init() { Session.Starting += ResetState; Session.Ended += ResetState; ModNet.OnClient(NetOp.ChestOffer, delegate(int sender, Packet packet) { int id = 0; try { Receive(ReadOffer(packet, out id)); } catch (NetFormatException) { if (id > 0) { Answer(id, -1); } throw; } }); ModNet.OnHost(NetOp.ChestPick, ReceivePick); } private static void ResetState() { offers.Clear(); queue.Clear(); showing = null; } public static void WriteOffer(Packet packet, int id, int[] powerups, float seconds) { packet.Write(id); packet.Write(powerups.Length); foreach (int num in powerups) { packet.Write(num); } packet.Write(seconds); } public static OfferMessage ReadOffer(Packet packet, out int id) { id = NetRead.Int(packet, 1, int.MaxValue, "offer"); OfferMessage result = new OfferMessage { Id = id }; int num = NetRead.Int(packet, 1, 3, "card count"); result.Powerups = new int[num]; for (int i = 0; i < num; i++) { result.Powerups[i] = NetRead.Int(packet, 0, 65535, "powerup"); } result.Seconds = NetRead.Float(packet, 5f, 600f, "answer time"); return result; } public static void WritePick(Packet packet, int id, int card) { packet.Write(id); packet.Write(card); } private static bool Open(LootContainerInteract chest, int fromClient) { //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_006d: Unknown result type (might be due to invalid IL or missing references) List<Powerup> list = RandomOptions(3, chest); if (list.Count == 0) { return false; } Vector3 position = ((Component)chest).transform.position; if (fromClient == LocalClient.instance.myId) { if ((Object)(object)PerkChoiceUI.Instance == (Object)null || !Session.LocalPlayerAlive) { return false; } return PerkChoiceUI.Instance.Show("Choose a Powerup", list, delegate(Powerup p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) PerkChoiceUI.DropPowerup(p.id, position); }); } return OfferTo(fromClient, list, position); } private static bool OfferTo(int client, List<Powerup> cards, Vector3 position) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Player val = ModNet.PlayerOf(client); if (val == null || ModNet.PeerProtocol(client) < 2) { return false; } int num = 0; foreach (Offer value in offers.Values) { if (value.Client == client) { num++; } } if (num >= 4) { return false; } Offer offer = new Offer { Id = nextOfferId++, Client = client, Owner = val, Position = position, Powerups = cards.ConvertAll((Powerup p) => p.id).ToArray(), Expires = Time.unscaledTime + 75f }; offers[offer.Id] = offer; if (!ModNet.SendTo(client, NetOp.ChestOffer, delegate(Packet p) { WriteOffer(p, offer.Id, offer.Powerups, 60f); })) { offers.Remove(offer.Id); return false; } Log.Debug("Chest choice " + offer.Id + " offered to " + val.username + ": " + string.Join(", ", offer.Powerups)); return true; } public static int OwedTo(int client) { int num = 0; foreach (Offer value in offers.Values) { if (value.Client == client) { num++; } } if ((Object)(object)LocalClient.instance != (Object)null && client == LocalClient.instance.myId && (Object)(object)PerkChoiceUI.Instance != (Object)null && PerkChoiceUI.Instance.Heading == "Choose a Powerup") { num++; } return num; } public static int OfferFresh(int client, int count, Vector3 position) { //IL_0094: 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_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_0089: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 0; i < count && i < 4; i++) { List<Powerup> list = RandomOptions(3, null); if (list.Count == 0) { break; } if ((Object)(object)LocalClient.instance != (Object)null && client == LocalClient.instance.myId) { Vector3 at = position; if (!((Object)(object)PerkChoiceUI.Instance != (Object)null) || !PerkChoiceUI.Instance.Show("Choose a Powerup", list, delegate(Powerup p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) PerkChoiceUI.DropPowerup(p.id, at); })) { PerkChoiceUI.DropPowerup(list[Random.Range(0, list.Count)].id, position); } } else if (!OfferTo(client, list, position)) { PerkChoiceUI.DropPowerup(list[Random.Range(0, list.Count)].id, position); } num++; } return num; } private static void ReceivePick(int sender, Packet packet) { int key = NetRead.Int(packet, 1, int.MaxValue, "offer"); int card = NetRead.Int(packet, -1, 2, "card"); if (!offers.TryGetValue(key, out var value)) { Log.Debug("Answer to chest choice " + key + " ignored: it was already settled."); return; } if (value.Client != sender) { throw new NetFormatException("chest choice " + key + " belongs to another player"); } offers.Remove(key); Settle(value, card); } private static void Settle(Offer offer, int card) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) bool flag = card >= 0 && card < offer.Powerups.Length; int powerupId = (flag ? offer.Powerups[card] : offer.Powerups[Random.Range(0, offer.Powerups.Length)]); if (!PerkChoiceUI.DropPowerup(powerupId, offer.Position)) { Log.Warn("Chest choice " + offer.Id + ": powerup " + powerupId + " could not be dropped."); } else { Log.Debug("Chest choice " + offer.Id + " settled with powerup " + powerupId + (flag ? " (chosen)." : " (random).")); } } public static void Tick(float now) { if (offers.Count == 0) { return; } due.Clear(); foreach (Offer value in offers.Values) { if (now >= value.Expires || ModNet.PlayerOf(value.Client) != value.Owner) { due.Add(value); } } foreach (Offer item in due) { offers.Remove(item.Id); Log.Info("Chest choice " + item.Id + " of player " + item.Client + " got no answer; a random card was dropped at the chest."); Settle(item, -1); } } public static List<Powerup> RandomOptions(int count, LootContainerInteract chest) { List<Powerup> list = new List<Powerup>(); ItemManager instance = ItemManager.Instance; if ((Object)(object)instance == (Object)null) { return list; } for (int i = 0; i < count * 8; i++) { if (list.Count >= count) { break; } Powerup val = (((Object)(object)chest != (Object)null) ? instance.GetRandomPowerup(chest.white, chest.blue, chest.gold) : null); if (!((Object)(object)val == (Object)null) && !CharmRegistry.IsCharm(val) && !list.Contains(val)) { list.Add(val); } } if (list.Count == count || instance.allPowerups == null) { return list; } List<Powerup> list2 = new List<Powerup>(); foreach (Powerup value in instance.allPowerups.Values) { if ((Object)(object)value != (Object)null && !CharmRegistry.IsCharm(value) && !list.Contains(value)) { list2.Add(value); } } while (list.Count < count && list2.Count > 0) { int index = Random.Range(0, list2.Count); list.Add(list2[index]); list2.RemoveAt(index); } return list; } private static void Receive(OfferMessage message) { List<Powerup> list = new List<Powerup>(message.Powerups.Length); ItemManager instance = ItemManager.Instance; int[] powerups = message.Powerups; foreach (int key in powerups) { if ((Object)(object)instance == (Object)null || instance.allPowerups == null || !instance.allPowerups.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { break; } list.Add(value); } if (list.Count != message.Powerups.Length || !Session.InGame || queue.Count >= 4) { Answer(message.Id, -1); return; } queue.Add(new Incoming { Id = message.Id, Cards = list, Expires = Time.unscaledTime + message.Seconds }); ShowNext(); } private static void ShowNext() { PerkChoiceUI instance = PerkChoiceUI.Instance; while (showing == null && queue.Count > 0 && (Object)(object)instance != (Object)null && !instance.IsOpen) { Incoming next = queue[0]; queue.RemoveAt(0); if (Time.unscaledTime >= next.Expires) { Answer(next.Id, -1); continue; } if (!instance.Show("Choose a Powerup", next.Cards, delegate(Powerup p) { Answer(next.Id, next.Cards.IndexOf(p)); }, delegate { Answer(next.Id, -1); })) { queue.Insert(0, next); break; } showing = next; } } private static void Answer(int id, int card) { if (showing != null && showing.Id == id) { showing = null; } ModNet.Request(NetOp.ChestPick, delegate(Packet p) { WritePick(p, id, card); }); } private void Update() { PerkChoiceUI instance = PerkChoiceUI.Instance; if (showing != null) { if ((Object)(object)instance != (Object)null && instance.IsOpen && Time.unscaledTime >= showing.Expires) { instance.Cancel(); } else if ((Object)(object)instance == (Object)null || !instance.IsOpen) { Answer(showing.Id, -1); } } for (int num = queue.Count - 1; num >= 0; num--) { if (!(Time.unscaledTime < queue[num].Expires)) { int id = queue[num].Id; queue.RemoveAt(num); Answer(id, -1); } } if (showing == null && queue.Count > 0) { ShowNext(); } if (!(Time.unscaledTime < nextCheck)) { nextCheck = Time.unscaledTime + 0.5f; if (LocalClient.serverOwner) { Tick(Time.unscaledTime); } } } } public sealed class ChoiceOption { public string Heading; public string Description; public Color Accent = Color.white; public string Locked; public Action Chosen; } public sealed class ChoiceWindow : MonoBehaviour { private const float OpenDelay = 0.4f; private const int MaxOptions = 3; private readonly List<ChoiceOption> options = new List<ChoiceOption>(); private string title; private string subtitle; private bool cancellable; private bool open; private Action onCancelled; private float openedAt; private GUIStyle titleStyle; private GUIStyle subtitleStyle; private GUIStyle headingStyle; private GUIStyle textStyle; private GUIStyle buttonStyle; private GUIStyle lockedStyle; private GUIStyle hintStyle; public static ChoiceWindow Instance { get; private set; } public bool IsOpen => open; private void Awake() { Instance = this; ((Behaviour)this).enabled = false; Session.Starting += Abort; Session.Ended += Abort; } public bool Show(string heading, string detail, IList<ChoiceOption> choices, bool canCancel, Action cancelled = null) { if (open || choices == null || choices.Count == 0 || ((Object)(object)PerkChoiceUI.Instance != (Object)null && PerkChoiceUI.Instance.IsOpen)) { return false; } options.Clear(); for (int i = 0; i < choices.Count && i < 3; i++) { options.Add(choices[i]); } title = heading; subtitle = detail; cancellable = canCancel; onCancelled = cancelled; bool flag = (((Behaviour)this).enabled = true); open = flag; openedAt = Time.unscaledTime; ModalLock.Acquire(this, freeze: true); return true; } private void Abort() { bool flag = (((Behaviour)this).enabled = false); open = flag; options.Clear(); onCancelled = null; } public void Cancel() { if (open) { Action action = onCancelled; Abort(); ModalLock.Release(this); if (action != null) { Log.Guard("Choice cancelled", action); } } } private void Update() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if (!open) { return; } if ((Object)(object)GameManager.instance == (Object)null || (int)GameManager.state != 1) { Cancel(); return; } ModalLock.FreeCursor(); if (cancellable && Input.GetKeyDown((KeyCode)27)) { Cancel(); } else if (Input.GetKeyDown((KeyCode)49) || Input.GetKeyDown((KeyCode)257)) { Choose(0); } else if (Input.GetKeyDown((KeyCode)50) || Input.GetKeyDown((KeyCode)258)) { Choose(1); } else if (Input.GetKeyDown((KeyCode)51) || Input.GetKeyDown((KeyCode)259)) { Choose(2); } } public void Choose(int index) { if (!open || index < 0 || index >= options.Count || Time.unscaledTime - openedAt < 0.4f) { return; } ChoiceOption choiceOption = options[index]; if (choiceOption != null && choiceOption.Locked == null) { Abort(); ModalLock.Release(this); if (choiceOption.Chosen != null) { Log.Guard("Choice '" + choiceOption.Heading + "'", choiceOption.Chosen); } } } private void OnGUI() { if (!open) { return; } try { Draw(); } catch (Exception e) { Log.PatchFailed("ChoiceWindow.OnGUI", e); } } private void Draw() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0319: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) EnsureStyles(); float num = Screen.width; float num2 = Screen.height; Fill(new Rect(0f, 0f, num, num2), new Color(0f, 0f, 0f, 0.7f)); GUI.Label(new Rect(0f, num2 * 0.08f, num, 60f), title, titleStyle); if (!string.IsNullOrEmpty(subtitle)) { GUI.Label(new Rect(num * 0.15f, num2 * 0.08f + 58f, num * 0.7f, 50f), subtitle, subtitleStyle); } int count = options.Count; float num3 = Mathf.Min(360f, (num - 120f - 34f * (float)(count - 1)) / (float)count); float num4 = Mathf.Min(360f, num2 * 0.55f); float num5 = (num - ((float)count * num3 + (float)(count - 1) * 34f)) / 2f; float num6 = num2 * 0.26f; Rect val2 = default(Rect); for (int i = 0; i < count; i++) { ChoiceOption choiceOption = options[i]; float num7 = num5 + (float)i * (num3 + 34f); bool num8 = choiceOption.Locked != null; Color val = (num8 ? Color.Lerp(choiceOption.Accent, Color.gray, 0.65f) : choiceOption.Accent); Fill(new Rect(num7 - 3f, num6 - 3f, num3 + 6f, num4 + 6f), val); Fill(new Rect(num7, num6, num3, num4), new Color(0.07f, 0.07f, 0.1f, 1f)); Fill(new Rect(num7, num6, num3, 6f), val); headingStyle.normal.textColor = Color.Lerp(val, Color.white, 0.35f); GUI.Label(new Rect(num7 + 18f, num6 + 18f + 6f, num3 - 36f, 70f), choiceOption.Heading, headingStyle); float num9 = num6 + 18f + 84f; GUI.Label(new Rect(num7 + 18f, num9, num3 - 36f, num6 + num4 - num9 - 50f - 36f), choiceOption.Description, textStyle); ((Rect)(ref val2))..ctor(num7 + 18f, num6 + num4 - 50f - 18f, num3 - 36f, 50f); if (num8) { GUI.Label(val2, choiceOption.Locked, lockedStyle); } else if (GUI.Button(val2, "Choose [" + (i + 1) + "]", buttonStyle)) { Choose(i); return; } } if (cancellable) { GUI.Label(new Rect(0f, num6 + num4 + 24f, num, 30f), "Esc - not yet", hintStyle); } } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003f: 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_0059: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_008e: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e2: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0140: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_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_01af: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if (titleStyle == null) { titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 38, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; titleStyle.normal.textColor = Color.white; subtitleStyle = new GUIStyle(GUI.skin.label) { fontSize = 19, alignment = (TextAnchor)1, wordWrap = true }; subtitleStyle.normal.textColor = new Color(0.85f, 0.85f, 0.9f); headingStyle = new GUIStyle(GUI.skin.label) { fontSize = 27, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, wordWrap = true }; textStyle = new GUIStyle(GUI.skin.label) { fontSize = 17, alignment = (TextAnchor)1, wordWrap = true, richText = true }; textStyle.normal.textColor = Color.white; buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 20, fontStyle = (FontStyle)1 }; lockedStyle = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = (FontStyle)2, alignment = (TextAnchor)4, wordWrap = true }; lockedStyle.normal.textColor = new Color(1f, 0.6f, 0.5f); hintStyle = new GUIStyle(GUI.skin.label) { fontSize = 16, alignment = (TextAnchor)4 }; hintStyle.normal.textColor = new Color(0.75f, 0.75f, 0.8f); } } private static void Fill(Rect rect, Color color) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } } public sealed class CooldownView : MonoBehaviour { private sealed class Slot { public RectTransform Root; public Image Ring; public Image Icon; public Image Sweep; public GameObject KeyBack; public TextMeshProUGUI Time; public TextMeshProUGUI Name; public TextMeshProUGUI Key; public TextMeshProUGUI Badge; public Cooldown Shown; public int ShownSeconds = -1; public int ShownBadge = -1; public bool WasReady; public float ReadyFlash; } private const int SlotCount = 3; private const float SlotSize = 78f; private const float SlotGap = 66f; private static Sprite disc; private static Sprite ring; private readonly Slot[] slots = new Slot[3]; private readonly Cooldown[] wanted = new Cooldown[3]; private bool ownsPhoenix; private float nextCharmCheck; public void Build(HudCanvas hud) { if ((Object)(object)disc == (Object)null) { CreateSprites(); } for (int i = 0; i < 3; i++) { slots[i] = CreateSlot(hud, i); } } private Slot CreateSlot(HudCanvas hud, int index) { //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_005c: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) Slot slot = new Slot(); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); slot.Root = HudCanvas.Place(HudCanvas.Panel("Slot" + index, ((Component)this).transform), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 46f), new Vector2(78f, 78f)); HudCanvas.AddImage("Back", (Transform)(object)slot.Root, new Color(0.06f, 0.05f, 0.1f, 0.85f), disc); slot.Icon = HudCanvas.AddImage("Icon", (Transform)(object)slot.Root, Color.white); HudCanvas.Place(((Graphic)slot.Icon).rectTransform, val, val, Vector2.zero, Vector2.one * 57.72f); slot.Icon.preserveAspect = true; slot.Sweep = HudCanvas.AddImage("Sweep", (Transform)(object)slot.Root, new Color(0f, 0f, 0f, 0.72f), disc); slot.Sweep.type = (Type)3; slot.Sweep.fillMethod = (FillMethod)4; slot.Sweep.fillOrigin = 2; slot.Sweep.fillClockwise = false; slot.Ring = HudCanvas.AddImage("Ring", (Transform)(object)slot.Root, Color.white, ring); slot.Time = hud.AddText("Time", (Transform)(object)slot.Root, 34f, Color.white, (TextAlignmentOptions)514); ((TMP_Text)slot.Time).outlineWidth = 0.2f; ((TMP_Text)slot.Time).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); slot.Name = hud.AddText("Name", (Transform)(object)slot.Root, 18f, Color.white, (TextAlignmentOptions)258); ((TMP_Text)slot.Name).outlineWidth = 0.18f; ((TMP_Text)slot.Name).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); HudCanvas.Place(((TMP_Text)slot.Name).rectTransform, new Vector2(0.5f, 0f), new Vector2(0.5f, 1f), new Vector2(0f, -3f), new Vector2(170f, 24f)); Image val2 = HudCanvas.AddImage("KeyBack", (Transform)(object)slot.Root, new Color(0.95f, 0.95f, 1f, 0.95f)); HudCanvas.Place(((Graphic)val2).rectTransform, new Vector2(0.5f, 1f), val, new Vector2(0f, 2f), new Vector2(44f, 20f)); slot.KeyBack = ((Component)val2).gameObject; slot.Key = hud.AddText("Key", ((Component)val2).transform, 16f, new Color(0.08f, 0.07f, 0.12f), (TextAlignmentOptions)514); slot.Badge = hud.AddText("Badge", (Transform)(object)slot.Root, 22f, Color.white, (TextAlignmentOptions)1028); ((TMP_Text)slot.Badge).outlineWidth = 0.25f; ((TMP_Text)slot.Badge).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); ((Component)slot.Root).gameObject.SetActive(false); return slot; } private void Update() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) int num = ((Session.LocalPlayerAlive && ModConfig.ShowCooldownHud.Value) ? Collect() : 0); float num2 = (float)num * 78f + (float)(num - 1) * 66f; for (int i = 0; i < 3; i++) { Slot slot = slots[i]; bool flag = i < num; if (((Component)slot.Root).gameObject.activeSelf != flag) { ((Component)slot.Root).gameObject.SetActive(flag); } if (!flag) { slot.Shown = null; continue; } slot.Root.anchoredPosition = new Vector2((0f - num2) * 0.5f + 39f + (float)i * 144f, 46f); Refresh(slot, wanted[i]); } } private int Collect() { if (Time.unscaledTime > nextCharmCheck) { nextCharmCheck = Time.unscaledTime + 0.5f; ownsPhoenix = CharmRegistry.Owned(CharmRegistry.PhoenixEmber) > 0; } int result = 0; Cooldown heldCooldown = WeaponAbilities.HeldCooldown; if (heldCooldown != null) { wanted[result++] = heldCooldown; } if (SetBonuses.AstralActive) { Cooldowns.Aegis.Badge = SetBonuses.Shield; wanted[result++] = Cooldowns.Aegis; } if (ownsPhoenix) { wanted[result++] = Cooldowns.Phoenix; } return result; } private static Sprite IconOf(Cooldown cooldown) { if (cooldown == Cooldowns.Cleaver) { return AstralContent.Cleaver.sprite; } if (cooldown == Cooldowns.Scepter) { return AstralContent.Scepter.sprite; } if (cooldown == Cooldowns.Eclipse) { return AstralContent.EclipseBlade.sprite; } if (cooldown == Cooldowns.Aegis) { return AstralContent.Armor[1].Item.sprite; } if (cooldown == Cooldowns.Wyrmfang) { if (!((Object)(object)EnderContent.Wyrmfang != (Object)null)) { return null; } return EnderContent.Wyrmfang.sprite; } return CharmRegistry.PhoenixEmber.sprite; } private static void Refresh(Slot slot, Cooldown cooldown) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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) if (slot.Shown != cooldown) { slot.Shown = cooldown; slot.Icon.sprite = IconOf(cooldown); ((TMP_Text)slot.Name).text = cooldown.Name; ((Graphic)slot.Name).color = Color.Lerp(cooldown.Accent, Color.white, 0.35f); ((TMP_Text)slot.Key).text = cooldown.Key; slot.KeyBack.SetActive(cooldown.Key.Length > 0); slot.ShownSeconds = (slot.ShownBadge = -1); slot.WasReady = cooldown.Ready; slot.ReadyFlash = 0f; } bool ready = cooldown.Ready; if (ready && !slot.WasReady) { slot.ReadyFlash = 1f; Sfx.PlayFlat("Armor", 0.25f, 1.7f); } slot.WasReady = ready; slot.ReadyFlash = Mathf.MoveTowards(slot.ReadyFlash, 0f, Time.unscaledDeltaTime * 2.5f); slot.Sweep.fillAmount = cooldown.Fraction; ((Graphic)slot.Ring).color = (Color)(ready ? Color.Lerp(cooldown.Accent, Color.white, slot.ReadyFlash) : new Color(0.42f, 0.42f, 0.48f, 0.9f)); ((Transform)slot.Root).localScale = Vector3.one * (1f + 0.18f * slot.ReadyFlash); int num = ((!ready) ? Mathf.CeilToInt(cooldown.Remaining) : 0); if (num != slot.ShownSeconds) { slot.ShownSeconds = num; ((TMP_Text)slot.Time).text = ((num > 0) ? num.ToString(CultureInfo.InvariantCulture) : ""); } if (cooldown.Badge != slot.ShownBadge) { slot.ShownBadge = cooldown.Badge; ((TMP_Text)slot.Badge).text = ((cooldown.Badge > 0) ? cooldown.Badge.ToString(CultureInfo.InvariantCulture) : ""); } } private static void CreateSprites() { //IL_00ea: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) Color[] array = (Color[])(object)new Color[16384]; Color[] array2 = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { Vector2 val = new Vector2((float)j - 63.5f, (float)i - 63.5f); float magnitude = ((Vector2)(ref val)).magnitude; array[i * 128 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(62f - magnitude)); array2[i * 128 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(63f - magnitude) * Mathf.Clamp01(magnitude - 55f)); } } disc = IconFactory.ToSprite("CooldownDisc", array, 128, 128, new Vector2(0.5f, 0.5f), 100f, Vector4.zero); ring = IconFactory.ToSprite("CooldownRing", array2, 128, 128, new Vector2(0.5f, 0.5f), 100f, Vector4.zero); } } public sealed class FloatingText : MonoBehaviour { private sealed class Entry { public TextMeshPro Text; public Transform Transform; public float Start; public Vector3 Origin; public float Size; public Color Color; } private const int PoolSize = 24; private const float Life = 1.15f; private static FloatingText instance; private readonly Entry[] pool = new Entry[24]; private int next; private TMP_FontAsset font; private void Awake() { instance = this; Session.Ended += HideAll; Session.Starting += HideAll; } private void HideAll() { Entry[] array = pool; foreach (Entry entry in array) { if (entry != null && (Object)(object)entry.Text != (Object)null) { ((Component)entry.Text).gameObject.SetActive(false); } } } public static void Show(Vector3 position, string message, Color color, float size = 1f) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) if (!((Object)(object)instance == (Object)null) && ModConfig.ShowFloatingText.Value && !((Object)(object)PlayerMovement.Instance == (Object)null)) { Vector3 val = ((Component)PlayerMovement.Instance).transform.position - position; if (!(((Vector3)(ref val)).sqrMagnitude > 8100f)) { instance.ShowInternal(position, message, color, size); } } } private void ShowInternal(Vector3 position, string message, Color color, float size) { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Entry entry = pool[next]; if (entry == null || (Object)(object)entry.Text == (Object)null) { entry = (pool[next] = Create(next)); } next = (next + 1) % 24; entry.Origin = position + Random.insideUnitSphere * 0.35f; entry.Start = Time.time; entry.Size = size; entry.Color = color; ((TMP_Text)entry.Text).text = message; ((Component)entry.Text).gameObject.SetActive(true); Animate(entry, 0f); } private Entry Create(int index) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text" + index); val.transform.SetParent(((Component)this).transform, false); TextMeshPro val2 = val.AddComponent<TextMeshPro>(); if ((Object)(object)font == (Object)null && (Object)(object)BossUI.Instance != (Object)null && (Object)(object)BossUI.Instance.bossName != (Object)null) { font = ((TMP_Text)BossUI.Instance.bossName).font; } if ((Object)(object)font != (Object)null) { ((TMP_Text)val2).font = font; } ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).fontSize = 5f; ((TMP_Text)val2).fontStyle = (FontStyles)1; ((TMP_Text)val2).outlineWidth = 0.12f; ((TMP_Text)val2).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); return new Entry { Text = val2, Transform = val.transform }; } private void LateUpdate() { float time = Time.time; for (int i = 0; i < 24; i++) { Entry entry = pool[i]; if (entry != null && !((Object)(object)entry.Text == (Object)null) && ((Component)entry.Text).gameObject.activeSelf) { float num = (time - entry.Start) / 1.15f; if (num >= 1f) { ((Component)entry.Text).gameObject.SetActive(false); } else { Animate(entry, num); } } } } private void Animate(Entry entry, float t) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_0083: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)PlayerMovement.Instance == (Object)null)) { Transform playerCam = PlayerMovement.Instance.playerCam; Vector3 val = entry.Origin + Vector3.up * (1.6f * (1f - (1f - t) * (1f - t))); float num = Vector3.Distance(playerCam.position, val); float num2 = ((t < 0.12f) ? Mathf.Lerp(0.4f, 1.15f, t / 0.12f) : 1f); entry.Transform.position = val; entry.Transform.rotation = playerCam.rotation; entry.Transform.localScale = Vector3.one * (entry.Size * num2 * Mathf.Clamp(num * 0.09f, 0.45f, 4f)); Color color = entry.Color; color.a = ((t < 0.6f) ? 1f : (1f - (t - 0.6f) / 0.4f)); ((Graphic)entry.Text).color = color; } } } public sealed class HudCanvas : MonoBehaviour { private static HudCanvas instance; private TMP_FontAsset heavy; public Canvas Canvas { get; private set; } public BannerView Banner { get; private set; } public CooldownView Cooldowns { get; private set; } public static HudCanvas Get() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)instance != (Object)null) { return instance; } if ((Object)(object)BossUI.Instance == (Object)null) { return null; } instance = new GameObject("MuckAscendant HUD", new Type[1] { typeof(RectTransform) }).AddComponent<HudCanvas>(); instance.Build(); return instance; } private void Build() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) Canvas = ((Component)this).gameObject.AddComponent<Canvas>(); Canvas.renderMode = (RenderMode)0; UiController val = UiController.Instance; Canvas.sortingOrder = (((Object)(object)val != (Object)null && (Object)(object)val.canvas != (Object)null) ? val.canvas.sortingOrder : 0) - 1; CanvasScaler obj = ((Component)this).gameObject.AddComponent<CanvasScaler>(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); obj.matchWidthOrHeight = 1f; heavy = (((Object)(object)BossUI.Instance.bossName != (Object)null) ? ((TMP_Text)BossUI.Instance.bossName).font : TMP_Settings.defaultFontAsset); Banner = ((Component)Panel("Banner", ((Component)this).transform)).gameObject.AddComponent<BannerView>(); Banner.Build(this); Cooldowns = ((Component)Panel("Cooldowns", ((Component)this).transform)).gameObject.AddComponent<CooldownView>(); Cooldowns.Build(this); ((Component)Panel("BossBar", ((Component)this).transform)).gameObject.AddComponent<BossBarView>().Build(this); } private void Update() { UiController val = UiController.Instance; bool flag = (Object)(object)val == (Object)null || (Object)(object)val.canvas == (Object)null || ((Behaviour)val.canvas).enabled; if (((Behaviour)Canvas).enabled != flag) { ((Behaviour)Canvas).enabled = flag; } } private void OnDestroy() { if ((Object)(object)instance == (Object)(object)this) { instance = null; } } public static RectTransform Panel(string name, Transform parent) { //IL_0014: 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_0032: 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_004a: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(parent, false); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; return component; } public static RectTransform Place(RectTransform rect, Vector2 anchor, Vector2 pivot, Vector2 position, Vector2 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 anchorMin = (rect.anchorMax = anchor); rect.anchorMin = anchorMin; rect.pivot = pivot; rect.anchoredPosition = position; rect.sizeDelta = size; return rect; } public static Image AddImage(string name, Transform parent, Color color, Sprite sprite = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) Image obj = ((Component)Panel(name, parent)).gameObject.AddComponent<Image>(); ((Graphic)obj).color = color; obj.sprite = sprite; ((Graphic)obj).raycastTarget = false; return obj; } public TextMeshProUGUI AddText(string name, Transform parent, float size, Color color, TextAlignmentOptions alignment) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)Panel(name, parent)).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)heavy != (Object)null) { ((TMP_Text)val).font = heavy; } ((TMP_Text)val).fontSize = size; ((Graphic)val).color = color; ((TMP_Text)val).alignment = alignment; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).enableWordWrapping = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; return val; } } public sealed class HudSpawner : MonoBehaviour { private float nextCheck; private void Update() { if (!(Time.unscaledTime < nextCheck)) { nextCheck = Time.unscaledTime + 1f; if (Session.InGame) { HudCanvas.Get(); } } } } public sealed class BannerView : MonoBehaviour { private const float SlideTime = 0.45f; private const float BarHeight = 92f; private RectTransform top; private RectTransform bottom; private RectTransform line; private Image lineImage; private CanvasGroup textGroup; private TextMeshProUGUI title; private TextMeshProUGUI subtitle; private float started; private float duration; private static Sprite softBand; public void Build(HudCanvas hud) { //IL_0048: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) top = Bar("Top", 1f); bottom = Bar("Bottom", 0f); RectTransform val = HudCanvas.Panel("Text", ((Component)this).transform); HudCanvas.Place(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 215f), new Vector2(1600f, 220f)); textGroup = ((Component)val).gameObject.AddComponent<CanvasGroup>(); HudCanvas.Place(((Graphic)HudCanvas.AddImage("Band", (Transform)(object)val, new Color(0f, 0f, 0f, 0.5f), SoftBand())).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 30f), new Vector2(1500f, 240f)); title = hud.AddText("Title", (Transform)(object)val, 74f, Color.white, (TextAlignmentOptions)514); HudCanvas.Place(((TMP_Text)title).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(1600f, 100f)); ((TMP_Text)title).fontStyle = (FontStyles)1; ((TMP_Text)title).characterSpacing = 6f; lineImage = HudCanvas.AddImage("Line", (Transform)(object)val, Color.white); line = HudCanvas.Place(((Graphic)lineImage).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 0.5f), new Vector2(0f, -112f), new Vector2(0f, 4f)); subtitle = hud.AddText("Subtitle", (Transform)(object)val, 32f, new Color(0.92f, 0.92f, 0.95f), (TextAlignmentOptions)514); HudCanvas.Place(((TMP_Text)subtitle).rectTransform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -126f), new Vector2(1600f, 50f)); ((Component)this).gameObject.SetActive(false); } private static Sprite SoftBand() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)softBand != (Object)null) { return softBand; } Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 128; j++) { array[i * 128 + j] = new Color(1f, 1f, 1f, Mathf.Sin(MathF.PI * ((float)j + 0.5f) / 128f) * Mathf.Sin(MathF.PI * ((float)i + 0.5f) / 32f)); } } return softBand = IconFactory.ToSprite("BannerBand", array, 128, 32, new Vector2(0.5f, 0.5f), 100f, Vector4.zero); } private RectTransform Bar(string name, float side) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing