Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BiomeGenerator v1.6.4
BiomeGenerator.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Json; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BiomeGenerator; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using SoftReferenceableAssets; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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; } } } public class FuelInteract : MonoBehaviour, Hoverable, Interactable { public string m_name = "$bg_msg_125"; public string m_fuelItemName = "$item_coal"; public float m_maxFuel = 10f; private ZNetView m_nview; private void Awake() { m_nview = ((Component)this).GetComponentInParent<ZNetView>(); } private float GetFuel() { if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid()) { return 0f; } return m_nview.GetZDO().GetFloat("fuel", 0f); } public string GetHoverName() { return Localization.instance.Localize(m_name); } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return Localization.instance.Localize($"{m_name} ({GetFuel():0.#}/{m_maxFuel})\n" + Loc.Text("bg_msg_126")); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } ItemData item = user.GetInventory().GetItem(m_fuelItemName, -1, false); if (item == null) { ((Character)user).Message((MessageType)2, Loc.Text("bg_msg_127"), 0, (Sprite)null, false); return false; } return AddFuel(user, item); } public bool UseItem(Humanoid user, ItemData item) { if (item.m_shared.m_name != m_fuelItemName) { return false; } return AddFuel(user, item); } private bool AddFuel(Humanoid user, ItemData item) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return false; } if (GetFuel() >= m_maxFuel) { ((Character)user).Message((MessageType)2, Loc.Text("bg_msg_128"), 0, (Sprite)null, false); return false; } user.GetInventory().RemoveItem(item.m_shared.m_name, 1, -1, true); m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>()); ((Character)user).Message((MessageType)2, Loc.Text("bg_msg_129"), 0, (Sprite)null, false); return true; } } namespace BiomeGenerator { internal static class BiomeDiscovery { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__Execute; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleOptionsFetcher <>9__5_0; internal List<string> <RegisterCommand>b__5_0() { return new List<string> { "explorer" }; } } internal static bool Explorer { get; private set; } internal static bool IsAvailable(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((int)biome <= 8) { if (biome - 1 <= 1 || (int)biome == 4 || (int)biome == 8) { goto IL_0032; } } else if ((int)biome <= 32) { if ((int)biome == 16 || (int)biome == 32) { goto IL_0032; } } else if ((int)biome == 64 || (int)biome == 512) { goto IL_0032; } return false; IL_0032: if ((Object)(object)Player.m_localPlayer != (Object)null) { if (!Explorer) { return Player.m_localPlayer.IsBiomeKnown(ShieldGeneratorBiomeChanger.GetSectorFor(biome)); } return true; } return false; } internal static void RegisterCommand() { //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_002a: Expected O, but got Unknown //IL_0052: 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_004f: Expected O, but got Unknown string text = Loc.Text("bg_msg_000"); object obj = <>O.<0>__Execute; if (obj == null) { ConsoleEvent val = Execute; <>O.<0>__Execute = val; obj = (object)val; } object obj2 = <>c.<>9__5_0; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => new List<string> { "explorer" }; <>c.<>9__5_0 = val2; obj2 = (object)val2; } new ConsoleCommand("biomeGenerator", text, (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); } private static void Execute(ConsoleEventArgs args) { if (args.Length != 2 || !string.Equals(args[1], "explorer", StringComparison.OrdinalIgnoreCase)) { args.Context.AddString(Loc.Text("bg_msg_001")); return; } if ((Object)(object)Player.m_localPlayer == (Object)null) { args.Context.AddString(Loc.Text("bg_msg_002")); return; } Explorer = true; args.Context.AddString(Loc.Text("bg_msg_003")); } internal static void ResetSession() { Explorer = false; } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] internal static class BiomeDiscoverySessionEnd { private static void Prefix() { BiomeDiscovery.ResetSession(); } } internal static class BiomeLocalizationRegistration { internal static void Register() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string[] languages = Loc.Languages; for (int i = 0; i < languages.Length; i++) { string language = languages[i]; localization.AddTranslation(ref language, Loc.Catalog(language)); } } } internal static class DomeRegistry { public struct Entry { public Vector3 Center; public float Radius; public Biome Biome; public bool Active; } public static readonly Dictionary<long, Entry> Domes = new Dictionary<long, Entry>(); private static float s_nextSync; public static void Sync() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < s_nextSync) { return; } s_nextSync = Time.unscaledTime + 0.5f; List<ShieldGeneratorBiomeChanger> all = ShieldGeneratorBiomeChanger.All; for (int i = 0; i < all.Count; i++) { ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger = all[i]; if (!((Object)(object)shieldGeneratorBiomeChanger == (Object)null) && shieldGeneratorBiomeChanger.DomeKey != 0L) { Domes[shieldGeneratorBiomeChanger.DomeKey] = new Entry { Center = shieldGeneratorBiomeChanger.DomeCenter, Radius = shieldGeneratorBiomeChanger.DomeRadius, Biome = shieldGeneratorBiomeChanger.SelectedBiome, Active = shieldGeneratorBiomeChanger.DomeActive }; } } } public static void Remove(long key) { if (key != 0L) { Domes.Remove(key); } } public static void Clear() { Domes.Clear(); } } public class BiomeMapGraphic : MaskableGraphic { private RawImage m_mapImage; private bool m_isSmall; private Rect m_lastUv; private float m_timer; private static readonly Dictionary<Biome, Color> s_biomeTints = new Dictionary<Biome, Color> { { (Biome)1, new Color(0.62f, 0.78f, 0.45f) }, { (Biome)8, new Color(0.34f, 0.51f, 0.32f) }, { (Biome)2, new Color(0.44f, 0.41f, 0.28f) }, { (Biome)4, new Color(0.79f, 0.81f, 0.83f) }, { (Biome)16, new Color(0.8f, 0.73f, 0.45f) }, { (Biome)512, new Color(0.4f, 0.38f, 0.46f) }, { (Biome)32, new Color(0.7f, 0.28f, 0.22f) }, { (Biome)64, new Color(0.86f, 0.89f, 0.93f) } }; public static BiomeMapGraphic LargeInstance { get; private set; } public static BiomeMapGraphic SmallInstance { get; private set; } public static void EnsureGraphic(Minimap minimap) { //IL_0074: 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) if (!((Object)(object)minimap == (Object)null)) { if ((Object)(object)minimap.m_mapImageLarge != (Object)null && ((Object)(object)LargeInstance == (Object)null || (Object)(object)((Component)LargeInstance).gameObject == (Object)null)) { Transform val = ((Component)minimap.m_mapImageLarge).transform.Find("BiomeGen_MapGraphic_Large"); GameObject val2 = (GameObject)(((Object)(object)val != (Object)null) ? ((object)((Component)val).gameObject) : ((object)new GameObject("BiomeGen_MapGraphic_Large", new Type[1] { typeof(RectTransform) }))); val2.transform.SetParent(((Component)minimap.m_mapImageLarge).transform, false); ResetRect(val2.GetComponent<RectTransform>()); LargeInstance = val2.GetComponent<BiomeMapGraphic>() ?? val2.AddComponent<BiomeMapGraphic>(); LargeInstance.Init(minimap.m_mapImageLarge, isSmall: false); val2.transform.SetAsLastSibling(); } if ((Object)(object)minimap.m_mapImageSmall != (Object)null && ((Object)(object)SmallInstance == (Object)null || (Object)(object)((Component)SmallInstance).gameObject == (Object)null)) { Transform val3 = ((Component)minimap.m_mapImageSmall).transform.Find("BiomeGen_MapGraphic_Small"); GameObject val4 = (GameObject)(((Object)(object)val3 != (Object)null) ? ((object)((Component)val3).gameObject) : ((object)new GameObject("BiomeGen_MapGraphic_Small", new Type[1] { typeof(RectTransform) }))); val4.transform.SetParent(((Component)minimap.m_mapImageSmall).transform, false); ResetRect(val4.GetComponent<RectTransform>()); SmallInstance = val4.GetComponent<BiomeMapGraphic>() ?? val4.AddComponent<BiomeMapGraphic>(); SmallInstance.Init(minimap.m_mapImageSmall, isSmall: true); val4.transform.SetAsLastSibling(); } } } private static void ResetRect(RectTransform rt) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.pivot = new Vector2(0.5f, 0.5f); rt.sizeDelta = Vector2.zero; rt.anchoredPosition = Vector2.zero; } } private void Init(RawImage mapImage, bool isSmall) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) m_mapImage = mapImage; m_isSmall = isSmall; ((Graphic)this).raycastTarget = false; ((Graphic)this).color = Color.white; } private void Update() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0060: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Minimap.instance == (Object)null) && !((Object)(object)m_mapImage == (Object)null) && (m_isSmall ? ((int)Minimap.instance.m_mode == 1) : ((int)Minimap.instance.m_mode == 2))) { DomeRegistry.Sync(); m_timer += Time.unscaledDeltaTime; if (m_mapImage.uvRect != m_lastUv || m_timer >= 0.09f) { m_timer = 0f; m_lastUv = m_mapImage.uvRect; ((Graphic)this).SetVerticesDirty(); } } } protected override void OnPopulateMesh(VertexHelper vh) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) vh.Clear(); if ((Object)(object)Minimap.instance == (Object)null || (Object)(object)m_mapImage == (Object)null || (m_isSmall && (int)Minimap.instance.m_mode != 1) || (!m_isSmall && (int)Minimap.instance.m_mode != 2)) { return; } Rect uvRect = m_mapImage.uvRect; Rect rect = ((Graphic)this).rectTransform.rect; if (((Rect)(ref uvRect)).width < 1E-05f || ((Rect)(ref uvRect)).height < 1E-05f || ((Rect)(ref rect)).width < 4f || ((Rect)(ref rect)).height < 4f) { return; } Minimap instance = Minimap.instance; if (instance.m_pixelSize <= 0f || instance.m_textureSize <= 0) { return; } float num = ((Rect)(ref rect)).width / (((Rect)(ref uvRect)).width * instance.m_pixelSize * (float)instance.m_textureSize); if (num <= 0f) { return; } Color col2 = default(Color); Color col3 = default(Color); foreach (KeyValuePair<long, DomeRegistry.Entry> dome in DomeRegistry.Domes) { DomeRegistry.Entry value = dome.Value; Vector2 val = WorldToLocal(value.Center, uvRect, rect); float num2 = Mathf.Max(2f, value.Radius * num); if (!(val.x + num2 * 1.4f < ((Rect)(ref rect)).xMin) && !(val.x - num2 * 1.4f > ((Rect)(ref rect)).xMax) && !(val.y + num2 * 1.4f < ((Rect)(ref rect)).yMin) && !(val.y - num2 * 1.4f > ((Rect)(ref rect)).yMax)) { float num3 = dome.Key % 7; float num4 = 0.55f + 0.45f * Mathf.Sin(Time.unscaledTime * 2.6f + num3); Color col = TintFor(value.Biome); float num5 = (value.Active ? 0.3f : 0.1f); AddBand(vh, val, 0f, num5, num2 * 0.8f, num5, col, num2); AddBand(vh, val, num2 * 0.8f, num5, num2 * 1.06f, 0f, col, num2); if (value.Active) { ((Color)(ref col2))..ctor(0.3f, 0.75f, 1f, 1f); AddBand(vh, val, 0f, num4 * 0.12f, num2 * 0.45f, num4 * 0.25f, col2, num2); AddBand(vh, val, num2 * 0.45f, num4 * 0.25f, num2 * 0.82f, num4 * 0.8f, col2, num2); AddBand(vh, val, num2 * 0.82f, num4 * 0.8f, num2 * 1.2f, 0f, col2, num2); } else { ((Color)(ref col3))..ctor(0.55f, 0.6f, 0.66f, 1f); AddBand(vh, val, num2 * 0.6f, 0f, num2 * 0.9f, 0.35f, col3, num2); AddBand(vh, val, num2 * 0.9f, 0.35f, num2 * 1.12f, 0f, col3, num2); } } } } private static Color TintFor(Biome biome) { //IL_0005: 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_001e: Unknown result type (might be due to invalid IL or missing references) if (!s_biomeTints.TryGetValue(biome, out var value)) { return new Color(0.6f, 0.6f, 0.6f); } return value; } private Vector2 WorldToLocal(Vector3 world, Rect uvRect, Rect rect) { //IL_000f: 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_0087: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; int num = instance.m_textureSize / 2; float num2 = (world.x / instance.m_pixelSize + (float)num) / (float)instance.m_textureSize; float num3 = (world.z / instance.m_pixelSize + (float)num) / (float)instance.m_textureSize; float num4 = (num2 - ((Rect)(ref uvRect)).xMin) / ((Rect)(ref uvRect)).width; float num5 = (num3 - ((Rect)(ref uvRect)).yMin) / ((Rect)(ref uvRect)).height; return new Vector2(((Rect)(ref rect)).xMin + num4 * ((Rect)(ref rect)).width, ((Rect)(ref rect)).yMin + num5 * ((Rect)(ref rect)).height); } private static void AddBand(VertexHelper vh, Vector2 c, float rIn, float aIn, float rOut, float aOut, Color col, float refR) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d1: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!(rOut <= 0.25f) && (!(aIn <= 0.001f) || !(aOut <= 0.001f))) { rIn = Mathf.Max(0f, rIn); int num = Mathf.Clamp(Mathf.CeilToInt(refR * 0.7f), 20, 72); int currentVertCount = vh.currentVertCount; Vector2 val = default(Vector2); for (int i = 0; i < num; i++) { float num2 = (float)i / (float)num * MathF.PI * 2f; ((Vector2)(ref val))..ctor(Mathf.Cos(num2), Mathf.Sin(num2)); vh.AddVert(Vector2.op_Implicit(c + val * rIn), Color32.op_Implicit(new Color(col.r, col.g, col.b, aIn)), Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(c + val * rOut), Color32.op_Implicit(new Color(col.r, col.g, col.b, aOut)), Vector4.op_Implicit(Vector2.zero)); } for (int j = 0; j < num; j++) { int num3 = (j + 1) % num; int num4 = currentVertCount + j * 2; int num5 = currentVertCount + num3 * 2; vh.AddTriangle(num4, num5, num4 + 1); vh.AddTriangle(num4 + 1, num5, num5 + 1); } } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class BiomeMenuEscapeGuard { private static bool Prefix() { if (BiomeMenuState.IsOpen && Input.GetKeyDown((KeyCode)27)) { BiomeRadialMenu.Close(); } return !BiomeMenuState.BlocksInput; } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class BiomeMenuPlayerInput { private static bool Prefix(ref bool __result) { if (!BiomeMenuState.BlocksInput) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class BiomeMenuControllerInput { private static bool Prefix(ref bool __result) { if (!BiomeMenuState.BlocksInput) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class BiomeMenuAttackInput { private static bool Prefix(Humanoid __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !BiomeMenuState.BlocksCombat) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "PlayerAttackInput")] internal static class BiomeMenuQueuedAttackInput { private static bool Prefix(Player __instance, ref float ___m_queuedAttackTimer, ref float ___m_queuedSecondAttackTimer) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !BiomeMenuState.BlocksCombat) { return true; } ___m_queuedAttackTimer = 0f; ___m_queuedSecondAttackTimer = 0f; return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class BiomeMenuCursor { private static bool Prefix() { if (!BiomeMenuState.IsOpen) { return true; } ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] internal static class BiomeMenuCamera { private static bool Prefix() { return !BiomeMenuState.IsOpen; } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] internal static class BiomeMenuMouse { private static bool Prefix(ref Vector2 __result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!BiomeMenuState.BlocksInput) { return true; } __result = Vector2.zero; return false; } } [HarmonyPatch(typeof(ZInput), "GetJoyRightStick")] internal static class BiomeMenuStick { private static bool Prefix(ref Vector2 __result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!BiomeMenuState.BlocksInput) { return true; } __result = Vector2.zero; return false; } } public static class BiomeMenuState { public static bool IsOpen; public static ShieldGeneratorBiomeChanger Dome; private static int ClosedFrame = -100; private static bool ConsumeCombat; private static int ReleasedFrame = -1; public static bool BlocksInput { get { if (!IsOpen) { return Time.frameCount <= ClosedFrame + 1; } return true; } } public static bool BlocksCombat { get { if (BlocksInput) { ConsumeCombat = true; ReleasedFrame = -1; return true; } if (!ConsumeCombat) { return false; } if (Input.GetMouseButton(0) || Input.GetMouseButton(1) || ZInput.GetButton("Attack") || ZInput.GetButton("SecondaryAttack") || ZInput.GetButton("JoyAttack") || ZInput.GetButton("JoySecondaryAttack")) { ReleasedFrame = -1; return true; } if (ReleasedFrame < 0) { ReleasedFrame = Time.frameCount; } if (Time.frameCount <= ReleasedFrame + 1) { return true; } ConsumeCombat = false; return false; } } internal static void MarkClosed() { ClosedFrame = Time.frameCount; ConsumeCombat = true; ReleasedFrame = -1; } } internal static class DomeSpawnRules { public static bool Validate(SpawnData spawn, ref Vector3 p) { //IL_0001: 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_0018: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (!ShieldGeneratorBiomeChanger.TryOverrideBiome(p, out var biome)) { return false; } if ((spawn.m_biome & biome) == 0) { return false; } Vector3 val = default(Vector3); Biome val2 = default(Biome); BiomeArea val3 = default(BiomeArea); Heightmap val4 = default(Heightmap); ZoneSystem.instance.GetGroundData(ref p, ref val, ref val2, ref val3, ref val4); ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger = ShieldGeneratorBiomeChanger.FindDome(p); if ((Object)(object)shieldGeneratorBiomeChanger == (Object)null || !shieldGeneratorBiomeChanger.SpawnCreatures) { return false; } float num = Mathf.Cos(MathF.PI / 180f * spawn.m_maxTilt); float num2 = Mathf.Cos(MathF.PI / 180f * spawn.m_minTilt); if (val.y < num || val.y > num2) { return false; } if (ZoneSystem.instance.IsBlocked(p)) { return false; } float num3 = p.y - 30f; if (num3 < spawn.m_minAltitude || num3 > spawn.m_maxAltitude) { return false; } if (Player.IsPlayerInRange(p, 6f)) { return false; } return true; } } [HarmonyPatch(typeof(Heightmap), "GetBiome")] internal static class Heightmap_GetBiome_Patch { private static bool Prefix(Vector3 __0, ref Biome __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected I4, but got Unknown if (ShieldGeneratorBiomeChanger.TryOverrideBiome(__0, out var biome)) { __result = (Biome)(int)biome; return false; } return true; } } [HarmonyPatch(typeof(WorldGenerator), "GetBiome", new Type[] { typeof(Vector3) })] internal static class WorldGenerator_GetBiome_Patch { private static bool Prefix(Vector3 __0, ref Biome __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected I4, but got Unknown if (ShieldGeneratorBiomeChanger.TryOverrideBiome(__0, out var biome)) { __result = (Biome)(int)biome; return false; } return true; } } [HarmonyPatch(typeof(WorldGenerator), "GetBiomeSector", new Type[] { typeof(Vector3), typeof(bool) })] internal static class WorldGenerator_GetBiomeSector_Patch { private static bool Prefix(Vector3 __0, ref BiomeSector __result) { //IL_0000: 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) if (ShieldGeneratorBiomeChanger.TryOverrideBiome(__0, out var biome)) { __result = ShieldGeneratorBiomeChanger.GetSectorFor(biome); return false; } return true; } } [HarmonyPatch(typeof(Heightmap), "HaveBiome")] internal static class Heightmap_HaveBiome_Patch { private static void Postfix(Heightmap __instance, ref bool __result, Biome biome) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!__result && ShieldGeneratorBiomeChanger.AnyDomeOnHeightmap(__instance, biome)) { __result = true; } } } [HarmonyPatch(typeof(Switch), "Interact")] internal static class Switch_Interact_Patch { private static bool Prefix(Switch __instance, Humanoid character, bool hold, bool alt, ref bool __result) { if ((Object)(object)character == (Object)(object)Player.m_localPlayer && (Object)(object)((Component)__instance).GetComponentInParent<ShieldGeneratorBiomeChanger>() != (Object)null) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(ShieldGenerator), "GetHoverText")] internal static class ShieldGenerator_GetHoverText_Patch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "com.custom.shieldgeneratorcustomizer" })] private static void Postfix(ShieldGenerator __instance, ref string __result) { ShieldGeneratorBiomeChanger component = ((Component)__instance).GetComponent<ShieldGeneratorBiomeChanger>(); if (!((Object)(object)component == (Object)null)) { if (BiomeMenuState.IsOpen) { __result = ""; } else { __result = Localization.instance.Localize(__instance.m_name) + "\n" + component.GetInteractionHint(); } } } } [HarmonyPatch(typeof(ShieldGenerator), "Interact")] internal static class ShieldGenerator_Interact_Patch { private static bool Prefix(ShieldGenerator __instance, Humanoid user, bool repeat, bool alt, ref bool __result) { if ((Object)(object)((Component)__instance).GetComponent<ShieldGeneratorBiomeChanger>() == (Object)null) { return true; } if ((Object)(object)user == (Object)(object)Player.m_localPlayer) { __result = true; return false; } __result = false; return false; } } [HarmonyPatch(typeof(ShieldGenerator), "UseItem")] internal static class ShieldGenerator_UseItem_Patch { private static bool Prefix(ShieldGenerator __instance, Humanoid user, ItemData item, ref bool __result) { if ((Object)(object)((Component)__instance).GetComponent<ShieldGeneratorBiomeChanger>() == (Object)null) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Heightmap), "RebuildRenderMesh")] internal static class Heightmap_RebuildRenderMesh_Patch { private static readonly FieldInfo s_renderMesh = AccessTools.Field(typeof(Heightmap), "m_renderMesh"); private static void Postfix(Heightmap __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_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_008b: Unknown result type (might be due to invalid IL or missing references) if (!ShieldGeneratorBiomeChanger.HasActiveDomes) { return; } Mesh val = (Mesh)(s_renderMesh?.GetValue(__instance)); if ((Object)(object)val == (Object)null) { return; } Color32[] colors = val.colors32; Vector3[] vertices = val.vertices; if (colors.Length == 0 || colors.Length != vertices.Length) { return; } Vector3 position = ((Component)__instance).transform.position; bool flag = false; for (int i = 0; i < vertices.Length; i++) { if (ShieldGeneratorBiomeChanger.TryOverrideBiome(position + vertices[i], out var biome, out var blend)) { colors[i] = Color32.Lerp(colors[i], Heightmap.GetBiomeColor(biome), blend); flag = true; } } if (flag) { val.SetColors(colors); } } } [HarmonyPatch(typeof(Heightmap), "IsLava")] internal static class Heightmap_IsLava_Patch { private static bool Prefix(Vector3 __0, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (ShieldGeneratorBiomeChanger.InsideAnyDomeXZ(__0)) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Heightmap), "GetLava")] internal static class Heightmap_GetLava_Patch { private static bool Prefix(Vector3 __0, ref float __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (ShieldGeneratorBiomeChanger.InsideAnyDomeXZ(__0)) { __result = 0f; return false; } return true; } } [HarmonyPatch(typeof(Heightmap), "GetHeightOffset")] internal static class Heightmap_GetHeightOffset_Patch { private static bool Prefix(Vector3 __0, ref float __result) { //IL_0000: 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_000d: Invalid comparison between Unknown and I4 if (ShieldGeneratorBiomeChanger.TryOverrideBiome(__0, out var biome) && (int)biome == 32) { __result = 0.1f; return false; } return true; } } [HarmonyPatch(typeof(SpawnSystem), "FindBaseSpawnPoint")] internal static class SpawnSystem_FindBaseSpawnPoint_Patch { private static readonly Func<SpawnSystem, Vector3, float, bool> InsideZone = AccessTools.MethodDelegate<Func<SpawnSystem, Vector3, float, bool>>(AccessTools.Method(typeof(SpawnSystem), "InsideZone", (Type[])null, (Type[])null), (object)null, true); private static bool Prefix(SpawnSystem __instance, SpawnData spawn, List<Player> allPlayers, out Vector3 spawnCenter, out Player targetPlayer, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) spawnCenter = Vector3.zero; targetPlayer = null; if (allPlayers == null || allPlayers.Count == 0) { return true; } List<ShieldGeneratorBiomeChanger> all = ShieldGeneratorBiomeChanger.All; Vector3 p = default(Vector3); for (int i = 0; i < all.Count; i++) { ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger = all[i]; if ((Object)(object)shieldGeneratorBiomeChanger == (Object)null || !shieldGeneratorBiomeChanger.DomeActive || !shieldGeneratorBiomeChanger.SpawnCreatures) { continue; } for (int j = 0; j < allPlayers.Count; j++) { Player val = allPlayers[j]; if ((Object)(object)val == (Object)null || Vector3.Distance(((Component)val).transform.position, shieldGeneratorBiomeChanger.DomeCenter) > shieldGeneratorBiomeChanger.DomeRadius + 90f) { continue; } for (int k = 0; k < 20; k++) { Vector2 val2 = Random.insideUnitCircle * Mathf.Max(2f, shieldGeneratorBiomeChanger.DomeRadius - 2f); ((Vector3)(ref p))..ctor(shieldGeneratorBiomeChanger.DomeCenter.x + val2.x, 0f, shieldGeneratorBiomeChanger.DomeCenter.z + val2.y); if (InsideZone(__instance, p, 0f) && DomeSpawnRules.Validate(spawn, ref p)) { spawnCenter = p; targetPlayer = val; __result = true; return false; } } } } return true; } } [HarmonyPatch(typeof(SpawnSystem), "Spawn")] internal static class DomeCreatureSpawnGuard { private static bool Prefix(Vector3 spawnPoint) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ShieldGeneratorBiomeChanger.AllowsCreatureSpawn(spawnPoint); } } [HarmonyPatch(typeof(SpawnSystem), "IsSpawnPointGood")] internal static class SpawnSystem_IsSpawnPointGood_Patch { private static bool Prefix(SpawnData spawn, ref Vector3 spawnPoint, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!ShieldGeneratorBiomeChanger.InsideAnyDomeXZ(spawnPoint)) { return true; } __result = DomeSpawnRules.Validate(spawn, ref spawnPoint); return false; } } [HarmonyPatch(typeof(WearNTear), "CanHaveSnow", new Type[] { typeof(bool), typeof(bool) })] internal static class WearNTear_CanHaveSnow_Patch { private static void Prefix(WearNTear __instance, ref bool __0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (__0 && ShieldGeneratorBiomeChanger.HasDeepNorthDomeAt(((Component)__instance).transform.position)) { __0 = false; } } } [HarmonyPatch(typeof(EnvMan), "GetEnvironmentOverride")] internal static class EnvMan_GetEnvironmentOverride_Patch { private static void Postfix(ref string __result) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); Vector3 position; if ((Object)(object)mainCamera != (Object)null) { position = ((Component)mainCamera).transform.position; } else { if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return; } position = ((Component)Player.m_localPlayer).transform.position; } EnvSetup environment; if ((Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InInterior()) { if (DomeInteriorEnvironment.TryGet(((Component)Player.m_localPlayer).transform.position, out var environmentName)) { __result = environmentName; } } else if (DomeWeather.TryGetEnvironment(position, out environment)) { __result = environment.m_name; } } } [HarmonyPatch(typeof(ZNetScene), "Destroy", new Type[] { typeof(GameObject) })] internal static class ZNetScene_Destroy_Patch { private static void Prefix(GameObject go) { if (!((Object)(object)go == (Object)null)) { ShieldGeneratorBiomeChanger component = go.GetComponent<ShieldGeneratorBiomeChanger>(); if ((Object)(object)component != (Object)null) { component.NotifyDestroyedByScene(); DomeRegistry.Remove(component.DomeKey); } } } } [HarmonyPatch(typeof(Minimap), "Start")] internal static class Minimap_Start_Patch { private static void Postfix(Minimap __instance) { DomeRegistry.Clear(); BiomeMapGraphic.EnsureGraphic(__instance); } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] internal static class Minimap_SetMapMode_Patch { private static void Postfix(Minimap __instance) { BiomeMapGraphic.EnsureGraphic(__instance); } } public class BiomeRadialMenu : MonoBehaviour { private class MenuItem { public Biome Biome; public string Name; public Sprite Icon; public Sprite LockedIcon; public float Angle; public GameObject Root; public Image GlowImage; public Image FillImage; public Image BorderImage; public Image IconImage; public Text LabelText; } private const float ItemRadius = 210f; private const float ButtonSize = 88f; private const float LabelOffset = 58f; private const float DeadZone = 30f; private const float OpenGrace = 0.3f; private const float MaxDistance = 12f; private readonly List<MenuItem> m_items = new List<MenuItem>(); private MenuItem m_selected; private bool m_active; private float m_openedAt = -10f; private float m_statusTimer; private Canvas m_canvas; private Text m_titleText; private Text m_descText; private Text m_hintText; private static readonly Color GoldColor = new Color(1f, 0.83f, 0.35f, 1f); private static readonly Color BorderIdle = new Color(0.78f, 0.75f, 0.68f, 0.55f); private static readonly Color FillColor = new Color(0.04f, 0.04f, 0.04f, 0.88f); private static readonly Color LabelIdle = new Color(0.93f, 0.91f, 0.86f, 0.92f); private static readonly Color GlowIdle = new Color(0.65f, 0.75f, 0.8f, 0.22f); private static readonly Color GlowSel = new Color(1f, 0.83f, 0.35f, 0.55f); private static readonly Color SelectedBorder = new Color(1f, 0.83f, 0.35f, 0.9f); private static Font s_font; private static Sprite s_circle; private static Sprite s_ring; private static Sprite s_buttonRing; private static Sprite s_glow; private static Sprite s_vignette; public static BiomeRadialMenu Instance { get; private set; } public static bool IsOpen { get { if ((Object)(object)Instance != (Object)null) { return Instance.m_active; } return false; } } private static Sprite CircleSprite { get { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_circle != (Object)null) { return s_circle; } int num = 512; float num2 = (float)(num - 1) * 0.5f; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) - num2; float num4 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-2f, 0f, num3)); array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } val.SetPixels32(array); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; s_circle = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num); return s_circle; } } private static Sprite RingSprite => s_ring ?? (s_ring = CreateRing(0.0035f)); private static Sprite ButtonRingSprite => s_buttonRing ?? (s_buttonRing = CreateRing(0.016f)); private static Sprite GlowSprite { get { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_glow != (Object)null) { return s_glow; } int num = 128; float num2 = (float)(num - 1) * 0.5f; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) / num2; float num4 = Mathf.Clamp01(1f - num3); num4 = num4 * num4 * num4; array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } val.SetPixels32(array); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; s_glow = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num); return s_glow; } } private static Sprite VignetteSprite { get { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00d3: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_vignette != (Object)null) { return s_vignette; } int num = 128; float num2 = (float)(num - 1) * 0.5f; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) / num2; float num4 = Mathf.SmoothStep(0.25f, 1f, num3) * 0.5f; array[i * num + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num4 * 255f)); } } val.SetPixels32(array); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; s_vignette = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num); return s_vignette; } } private static void BuildBiomeList(List<(Biome b, float a, string icon, Color32 fb)> list) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) list.Add(((Biome)1, 90f, "Meadows.png", new Color32((byte)120, (byte)190, (byte)90, byte.MaxValue))); list.Add(((Biome)8, 45f, "Forest.png", new Color32((byte)60, (byte)120, (byte)60, byte.MaxValue))); list.Add(((Biome)2, 0f, "Swamp.png", new Color32((byte)110, (byte)120, (byte)60, byte.MaxValue))); list.Add(((Biome)4, -45f, "Mountain.png", new Color32((byte)180, (byte)190, (byte)200, byte.MaxValue))); list.Add(((Biome)16, -90f, "Plains.png", new Color32((byte)190, (byte)190, (byte)90, byte.MaxValue))); list.Add(((Biome)512, -135f, "Mistlands.png", new Color32((byte)120, (byte)120, (byte)130, byte.MaxValue))); list.Add(((Biome)32, 180f, "Ashlands.png", new Color32((byte)190, (byte)80, (byte)50, byte.MaxValue))); list.Add(((Biome)64, 135f, "DeepNorth.png", new Color32((byte)220, (byte)230, (byte)240, byte.MaxValue))); } private static Font GetFont() { if ((Object)(object)s_font != (Object)null) { return s_font; } try { s_font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } catch { try { s_font = Resources.GetBuiltinResource<Font>("Arial.ttf"); } catch { } } return s_font ?? Font.CreateDynamicFontFromOSFont("Arial", 14); } private void Awake() { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BuildUI(); ((Component)this).gameObject.SetActive(false); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } BiomeMenuState.IsOpen = false; BiomeMenuState.Dome = null; BiomeMenuState.MarkClosed(); } public static void Show(ShieldGeneratorBiomeChanger dome) { //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_001d: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { GameObject val = new GameObject("BiomeRadialMenuSystem"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<BiomeRadialMenu>(); } if (!((Object)(object)Instance == (Object)null)) { BiomeMenuState.Dome = dome; BiomeMenuState.IsOpen = true; Instance.m_active = true; Instance.m_openedAt = Time.unscaledTime; Instance.ResetSelection(); Instance.RefreshCurrentHighlight(); Instance.UpdateCenterText(); ((Component)Instance).gameObject.SetActive(true); } } public static void Close() { if (!((Object)(object)Instance == (Object)null)) { Instance.m_active = false; ((Component)Instance).gameObject.SetActive(false); BiomeMenuState.IsOpen = false; BiomeMenuState.MarkClosed(); BiomeMenuState.Dome = null; } } private void BuildUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0064: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a1: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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_0339: Unknown result type (might be due to invalid IL or missing references) //IL_034a: 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) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Root"); val.AddComponent<RectTransform>(); val.transform.SetParent(((Component)this).transform, false); m_canvas = val.AddComponent<Canvas>(); m_canvas.renderMode = (RenderMode)0; m_canvas.sortingOrder = 500; CanvasScaler obj = val.AddComponent<CanvasScaler>(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1600f, 1000f); obj.matchWidthOrHeight = 0.5f; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; StretchFull(((Graphic)MakeImage(val.transform, "Vignette", VignetteSprite, Color.white)).rectTransform); Place(((Graphic)MakeImage(val.transform, "Disc", CircleSprite, new Color(0.025f, 0.035f, 0.045f, 0.94f))).rectTransform, Vector2.zero, new Vector2(274f, 274f)); Place(((Graphic)MakeImage(val.transform, "DiscEdge", RingSprite, new Color(1f, 1f, 1f, 0.12f))).rectTransform, Vector2.zero, new Vector2(280f, 280f)); Place(((Graphic)MakeImage(val.transform, "Ring", RingSprite, new Color(0.65f, 0.75f, 0.8f, 0.22f))).rectTransform, Vector2.zero, new Vector2(680f, 680f)); Place(((Graphic)MakeImage(val.transform, "Ring2", RingSprite, new Color(1f, 0.83f, 0.35f, 0.1f))).rectTransform, Vector2.zero, new Vector2(660f, 660f)); m_titleText = MakeText(val.transform, "Title", 24, Color.white); Place(((Graphic)m_titleText).rectTransform, new Vector2(0f, 38f), new Vector2(260f, 36f)); m_descText = MakeText(val.transform, "Desc", 15, new Color(0.86f, 0.86f, 0.86f, 0.95f)); Place(((Graphic)m_descText).rectTransform, new Vector2(0f, -20f), new Vector2(260f, 60f)); m_hintText = MakeText(val.transform, "Hint", 12, new Color(0.7f, 0.7f, 0.7f, 0.75f)); m_hintText.text = Loc.Text("bg_msg_004"); Place(((Graphic)m_hintText).rectTransform, new Vector2(0f, -88f), new Vector2(280f, 40f)); List<(Biome, float, string, Color32)> list = new List<(Biome, float, string, Color32)>(); BuildBiomeList(list); foreach (var (biome, angle, iconName, fallbackColor) in list) { AddItem(biome, angle, iconName, fallbackColor); } } private unsafe void AddItem(Biome biome, float angle, string iconName, Color32 fallbackColor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) MenuItem menuItem = new MenuItem { Biome = biome, Name = Loc.BiomeName(biome), Icon = LoadEmbeddedIcon(iconName, fallbackColor), Angle = angle }; menuItem.LockedIcon = CreateGrayscaleIcon(menuItem.Icon); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Mathf.Cos(angle * (MathF.PI / 180f)), Mathf.Sin(angle * (MathF.PI / 180f))); GameObject val2 = new GameObject("Item_" + ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString()); val2.AddComponent<RectTransform>(); val2.transform.SetParent(((Component)m_canvas).transform, false); Place(val2.GetComponent<RectTransform>(), val * 210f, Vector2.zero); Image val3 = MakeImage(val2.transform, "Glow", GlowSprite, GlowIdle); Place(((Graphic)val3).rectTransform, Vector2.zero, new Vector2(140.8f, 140.8f)); Image val4 = MakeImage(val2.transform, "Fill", CircleSprite, FillColor); Place(((Graphic)val4).rectTransform, Vector2.zero, new Vector2(88f, 88f)); Image val5 = MakeImage(val2.transform, "Border", ButtonRingSprite, BorderIdle); Place(((Graphic)val5).rectTransform, Vector2.zero, new Vector2(88f, 88f)); Image val6 = MakeImage(val2.transform, "Icon", menuItem.Icon, Color.white); val6.preserveAspect = true; Place(((Graphic)val6).rectTransform, Vector2.zero, new Vector2(84.479996f, 84.479996f)); Text val7 = MakeText(val2.transform, "Label", 15, LabelIdle); val7.text = menuItem.Name; float num = ((val.y > 0.1f && Mathf.Abs(val.x) > 0.1f) ? (val.x * 28f) : 0f); Place(((Graphic)val7).rectTransform, new Vector2(num, -58f), new Vector2(200f, 28f)); menuItem.Root = val2; menuItem.GlowImage = val3; menuItem.FillImage = val4; menuItem.BorderImage = val5; menuItem.IconImage = val6; menuItem.LabelText = val7; m_items.Add(menuItem); } private void Update() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (!m_active) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { Close(); return; } if ((Object)(object)BiomeMenuState.Dome == (Object)null || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)BiomeMenuState.Dome).transform.position) > 12f) { Close(); return; } if (Time.unscaledTime - m_openedAt > 0.3f && (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(1) || Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)103))) { Close(); return; } m_statusTimer -= Time.unscaledDeltaTime; if (m_statusTimer <= 0f) { m_statusTimer = 0.25f; RefreshCurrentHighlight(); UpdateCenterText(); } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); Vector2 diff = (Vector2.op_Implicit(Input.mousePosition) - val) / m_canvas.scaleFactor; HandleSelection(diff); if (Input.GetMouseButtonDown(0) && m_selected != null) { ConfirmSelection(); } } private void HandleSelection(Vector2 diff) { //IL_001d: 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) if (((Vector2)(ref diff)).magnitude < 30f) { if (m_selected != null) { ResetSelection(); } return; } float num = Mathf.Atan2(diff.y, diff.x) * 57.29578f; MenuItem menuItem = null; float num2 = 999f; foreach (MenuItem item in m_items) { float num3 = Mathf.Abs(Mathf.DeltaAngle(num, item.Angle)); if (num3 < num2) { num2 = num3; menuItem = item; } } if (menuItem != m_selected) { if (m_selected != null) { UpdateVisual(m_selected, selected: false); } m_selected = menuItem; if (m_selected != null) { UpdateVisual(m_selected, selected: true); } UpdateCenterText(); } } private void ConfirmSelection() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ShieldGeneratorBiomeChanger dome = BiomeMenuState.Dome; if ((Object)(object)dome == (Object)null) { Close(); } else if (!BiomeDiscovery.IsAvailable(m_selected.Biome)) { UpdateCenterText(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Loc.Text("bg_msg_005"), 0, (Sprite)null, false); } } else { dome.ApplyBiome(m_selected.Biome); Close(); } } private void ResetSelection() { if (m_selected != null) { UpdateVisual(m_selected, selected: false); } m_selected = null; } private void UpdateVisual(MenuItem item, bool selected) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0143: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) bool flag = BiomeDiscovery.IsAvailable(item.Biome); bool flag2 = (Object)(object)BiomeMenuState.Dome != (Object)null && BiomeMenuState.Dome.SelectedBiome == item.Biome; Color val = default(Color); ((Color)(ref val))..ctor(0.52f, 0.55f, 0.58f, 0.85f); if ((Object)(object)item.IconImage != (Object)null) { item.IconImage.sprite = (flag ? item.Icon : item.LockedIcon); ((Graphic)item.IconImage).color = (Color)(flag ? Color.white : new Color(0.72f, 0.72f, 0.72f, 0.9f)); } if ((Object)(object)item.BorderImage != (Object)null) { ((Graphic)item.BorderImage).color = ((!flag) ? val : (selected ? GoldColor : (flag2 ? SelectedBorder : BorderIdle))); } if ((Object)(object)item.GlowImage != (Object)null) { ((Graphic)item.GlowImage).color = (Color)((flag && selected) ? GlowSel : new Color(1f, 1f, 1f, flag ? 0.12f : 0.04f)); } if ((Object)(object)item.LabelText != (Object)null) { ((Graphic)item.LabelText).color = ((!flag) ? val : (selected ? GoldColor : LabelIdle)); } if ((Object)(object)item.Root != (Object)null) { item.Root.transform.localScale = Vector3.one * (selected ? 1.08f : 1f); } } private void RefreshCurrentHighlight() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) foreach (MenuItem item in m_items) { item.Name = Loc.BiomeName(item.Biome); if ((Object)(object)item.LabelText != (Object)null) { item.LabelText.text = item.Name; } UpdateVisual(item, item == m_selected); } } private void UpdateCenterText() { //IL_0045: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ShieldGeneratorBiomeChanger dome = BiomeMenuState.Dome; if ((Object)(object)dome == (Object)null) { return; } if ((Object)(object)m_titleText != (Object)null) { if (m_selected != null) { m_titleText.text = m_selected.Name; } else { m_titleText.text = Loc.BiomeName(dome.SelectedBiome); } } if ((Object)(object)m_descText != (Object)null) { bool flag = m_selected != null && !BiomeDiscovery.IsAvailable(m_selected.Biome); ((Graphic)m_descText).color = (flag ? new Color(0.65f, 0.67f, 0.7f) : new Color(0.86f, 0.86f, 0.86f, 0.95f)); m_descText.text = (flag ? Loc.Text("bg_msg_006") : (dome.DomeActive ? Loc.Format("bg_msg_007", dome.DomeRadius) : Loc.Text("bg_msg_008"))); m_hintText.text = (flag ? Loc.Text("bg_msg_009") : Loc.Text("bg_msg_010")); } } private static Image MakeImage(Transform parent, string name, Sprite sprite, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.AddComponent<RectTransform>(); val.transform.SetParent(parent, false); Image obj = val.AddComponent<Image>(); obj.sprite = sprite; ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = false; return obj; } private static Text MakeText(Transform parent, string name, int size, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.AddComponent<RectTransform>(); val.transform.SetParent(parent, false); Text obj = val.AddComponent<Text>(); obj.font = GetFont(); obj.fontSize = size; ((Graphic)obj).color = color; obj.alignment = (TextAnchor)4; ((Graphic)obj).raycastTarget = false; obj.horizontalOverflow = (HorizontalWrapMode)0; obj.verticalOverflow = (VerticalWrapMode)1; return obj; } private static void Place(RectTransform rt, Vector2 pos, Vector2 size) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.anchoredPosition = pos; rt.sizeDelta = size; } private static void StretchFull(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; Vector2 offsetMin = (rt.offsetMax = Vector2.zero); rt.offsetMin = offsetMin; } private static Sprite CreateRing(float thickness) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_011a: 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_004e: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) float num = 511.5f; float num2 = 491.52f; float num3 = 1024f * thickness * 0.5f; Texture2D val = new Texture2D(1024, 1024, (TextureFormat)4, true); Color32[] array = (Color32[])(object)new Color32[1048576]; for (int i = 0; i < 1024; i++) { for (int j = 0; j < 1024; j++) { float num4 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num, num)); float num5 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(num3 - 1f, num3 + 1f, Mathf.Abs(num4 - num2))); array[i * 1024 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f)); } } val.SetPixels32(array); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; val.Apply(true, true); return Sprite.Create(val, new Rect(0f, 0f, 1024f, 1024f), new Vector2(0.5f, 0.5f), 1024f, 0u, (SpriteMeshType)0); } private static Sprite LoadEmbeddedIcon(string fileName, Color32 fallbackColor) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0142: 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_00c7: Unknown result type (might be due to invalid IL or missing references) try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = null; string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text2 in manifestResourceNames) { if (text2.EndsWith(fileName, StringComparison.OrdinalIgnoreCase) && (text == null || text2.Length < text.Length)) { text = text2; } } if (text != null) { using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream != null) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (ImageConversion.LoadImage(val, array)) { ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)Loc.Format("bg_msg_011", fileName, ex.Message)); } } ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)Loc.Format("bg_msg_012", fileName)); } return CreateColoredIcon(fallbackColor); } private static Sprite CreateGrayscaleIcon(Sprite icon) { //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_001b: 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_0052: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) Texture2D texture = icon.texture; Color32[] pixels = texture.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { Color32 val = pixels[i]; byte b = (byte)((float)(int)val.r * 0.2126f + (float)(int)val.g * 0.7152f + (float)(int)val.b * 0.0722f); pixels[i] = new Color32(b, b, b, val.a); } Texture2D val2 = new Texture2D(((Texture)texture).width, ((Texture)texture).height, (TextureFormat)4, true); val2.SetPixels32(pixels); ((Texture)val2).wrapMode = (TextureWrapMode)1; ((Texture)val2).filterMode = (FilterMode)2; val2.Apply(true, true); return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } private static Sprite CreateColoredIcon(Color32 color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0070: Unknown result type (might be due to invalid IL or missing references) int num = 64; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num2 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num / 2f - 0.5f, (float)num / 2f - 0.5f)); array[i * num + j] = (Color32)((num2 < (float)num * 0.36f) ? color : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); } } val.SetPixels32(array); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num); } } public static class BiomeSnowdrifts { private const string PrefabName = "biomegen_snowdrift"; private const string kTag = "biomegen_drift"; private const string kDome = "biomegen_driftdome"; private const float GeneratorClearMargin = 4.5f; private const float PlayerClearMargin = 2.5f; private const float MinSpacing = 2.3f; private const float MaxSlopeDeg = 30f; internal static readonly bool kSpawnDriftObjects = false; public static ConfigEntry<bool> SnowEnabled; private static GameObject s_driftPrefab; private static bool s_prefabFailed; private static readonly List<ShieldGeneratorBiomeChanger> s_pendingSpawn = new List<ShieldGeneratorBiomeChanger>(); private static readonly HashSet<long> s_spawnedKeys = new HashSet<long>(); private const float HeightMult = 18f; private const float RadialMult = 4f; private const float Density = 0.04f; private const int MinCount = 20; private const int MaxCount = 150; private static GameObject s_gcRoot; private static bool s_gcSpawned; private static float s_nextGcCheck; private static int s_gcCount; private static readonly MethodInfo GetBiomeHeightMethod = AccessTools.Method(typeof(WorldGenerator), "GetBiomeHeight", new Type[6] { typeof(Biome), typeof(float), typeof(float), typeof(Color).MakeByRefType(), typeof(bool), typeof(bool) }, (Type[])null); internal static bool Enabled { get { if (SnowEnabled != null) { return SnowEnabled.Value; } return true; } } public static void Setup() { } internal static void UpdatePending() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } for (int num = s_pendingSpawn.Count - 1; num >= 0; num--) { ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger = s_pendingSpawn[num]; if ((Object)(object)shieldGeneratorBiomeChanger == (Object)null || !Enabled || !shieldGeneratorBiomeChanger.DomeActive || (int)shieldGeneratorBiomeChanger.SelectedBiome != 64) { s_pendingSpawn.RemoveAt(num); } else if (IsSpawned(shieldGeneratorBiomeChanger) || EnsureSpawned(shieldGeneratorBiomeChanger)) { s_pendingSpawn.RemoveAt(num); } } } private static void UpdateGroundcover() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 if (Time.time < s_nextGcCheck) { return; } s_nextGcCheck = Time.time + 0.5f; if (!Enabled) { if (s_gcSpawned) { ClearGroundcover(); } return; } ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger = null; for (int i = 0; i < ShieldGeneratorBiomeChanger.All.Count; i++) { ShieldGeneratorBiomeChanger shieldGeneratorBiomeChanger2 = ShieldGeneratorBiomeChanger.All[i]; if ((Object)(object)shieldGeneratorBiomeChanger2 != (Object)null && shieldGeneratorBiomeChanger2.DomeActive && (int)shieldGeneratorBiomeChanger2.SelectedBiome == 64) { shieldGeneratorBiomeChanger = shieldGeneratorBiomeChanger2; break; } } if ((Object)(object)shieldGeneratorBiomeChanger == (Object)null || !shieldGeneratorBiomeChanger.RadiusSettled) { if (s_gcSpawned) { ClearGroundcover(); } } else if (!s_gcSpawned) { SpawnGroundcover(shieldGeneratorBiomeChanger); } } private static void SpawnGroundcover(ShieldGeneratorBiomeChanger dome) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0299: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: 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_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) try { Mesh val = null; Material val2 = null; if ((Object)(object)ClutterSystem.instance != (Object)null) { foreach (Clutter item in ClutterSystem.instance.m_clutter) { if (item != null && !((Object)(object)item.m_prefab == (Object)null) && ((Object)item.m_prefab).name.Contains("groundcover_snow")) { InstanceRenderer component = item.m_prefab.GetComponent<InstanceRenderer>(); if ((Object)(object)component != (Object)null) { object? obj = AccessTools.Field(typeof(InstanceRenderer), "m_mesh")?.GetValue(component); val = (Mesh)((obj is Mesh) ? obj : null); object? obj2 = AccessTools.Field(typeof(InstanceRenderer), "m_material")?.GetValue(component); val2 = (Material)((obj2 is Material) ? obj2 : null); } break; } } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)Loc.Text("bg_msg_013")); return; } Plugin.Log.LogInfo((object)(Loc.Format("bg_msg_132", ((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "NULL") + Loc.Format("bg_msg_133", ((Object)(object)val2 != (Object)null && (Object)(object)val2.shader != (Object)null) ? ((Object)val2.shader).name : "—"))); if ((Object)(object)val2 == (Object)null) { val2 = CreateSnowMaterial(); } Vector3 domeCenter = dome.DomeCenter; float domeTargetRadius = dome.DomeTargetRadius; Vector3 position = ((Component)dome).transform.position; float num = domeTargetRadius - 1f; float num2 = Mathf.Cos(0.61086524f); int num3 = ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetSeed() : 0) ^ (int)(domeCenter.x * 4271f) ^ (int)(domeCenter.z * 9187f) ^ (int)(dome.DomeKey & 0x7FFFFFFF); State state = Random.state; Random.InitState(num3); int num4 = Mathf.Clamp(Mathf.RoundToInt(MathF.PI * domeTargetRadius * domeTargetRadius * 0.04f), 20, 150); s_gcRoot = new GameObject("biomegen_snow_layer"); Object.DontDestroyOnLoad((Object)(object)s_gcRoot); List<Vector3> list = new List<Vector3>(); int num5 = 0; int num6 = 0; int num7 = num4 * 8; Vector3 val4 = default(Vector3); Vector3 val5 = default(Vector3); Biome val6 = default(Biome); BiomeArea val7 = default(BiomeArea); Heightmap val8 = default(Heightmap); while (num5 < num4 && num6 < num7) { num6++; Vector2 val3 = Random.insideUnitCircle * num; ((Vector3)(ref val4))..ctor(domeCenter.x + val3.x, 0f, domeCenter.z + val3.y); if (Vector2.Distance(new Vector2(val4.x, val4.z), new Vector2(position.x, position.z)) < 4.5f) { continue; } bool flag = false; for (int i = 0; i < list.Count; i++) { float num8 = val4.x - list[i].x; float num9 = val4.z - list[i].z; if (num8 * num8 + num9 * num9 < 5.29f) { flag = true; break; } } if (flag) { continue; } ZoneSystem.instance.GetGroundData(ref val4, ref val5, ref val6, ref val7, ref val8); if (val5.y < num2 || ZoneSystem.instance.IsBlocked(val4)) { continue; } List<Player> allPlayers = Player.GetAllPlayers(); bool flag2 = false; if (allPlayers != null) { for (int j = 0; j < allPlayers.Count; j++) { Player val9 = allPlayers[j]; if (!((Object)(object)val9 == (Object)null) && !((Character)val9).IsDead()) { float num10 = val4.x - ((Component)val9).transform.position.x; float num11 = val4.z - ((Component)val9).transform.position.z; if (num10 * num10 + num11 * num11 < 6.25f) { flag2 = true; break; } } } } if (!flag2) { float worldgenSnowDepth = GetWorldgenSnowDepth(val4.x, val4.z); float num12 = Mathf.Lerp(9f, 18f, worldgenSnowDepth); float num13 = Random.Range(0.8f, 1.6f); float num14 = Random.Range(0f, 360f); GameObject val10 = new GameObject("snow_gc"); val10.transform.SetParent(s_gcRoot.transform, false); val4.y -= 0.15f; val10.transform.position = val4; val10.transform.rotation = Quaternion.Euler(0f, num14, 0f); val10.transform.localScale = new Vector3(num13 * 4f, num13 * num12, num13 * 4f); val10.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val10.AddComponent<MeshRenderer>()).sharedMaterial = val2; list.Add(val4); num5++; } } Random.state = state; s_gcSpawned = true; s_gcCount = num5; ManualLogSource log = Plugin.Log; string text = Loc.Format("bg_msg_014", num5); object[] obj3 = new object[4] { ((Object)val).name, null, null, null }; Bounds bounds = val.bounds; obj3[1] = ((Bounds)(ref bounds)).size; obj3[2] = 18f; obj3[3] = domeCenter; log.LogInfo((object)(text + Loc.Format("bg_msg_015", obj3))); } catch (Exception ex) { Plugin.Log.LogError((object)(Loc.Text("bg_msg_016") + ex)); } } private static void ClearGroundcover() { if ((Object)(object)s_gcRoot != (Object)null) { Object.Destroy((Object)(object)s_gcRoot); s_gcRoot = null; } s_gcSpawned = false; Plugin.Log.LogInfo((object)Loc.Format("bg_msg_017", s_gcCount)); } private static float GetWorldgenSnowDepth(float x, float z) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) try { if (WorldGenerator.instance == null || GetBiomeHeightMethod == null) { return 0.5f; } object[] array = new object[6] { (object)(Biome)64, x, z, (object)default(Color), false, true }; GetBiomeHeightMethod.Invoke(WorldGenerator.instance, array); return Mathf.Clamp01(((Color)array[3]).g); } catch { return 0.5f; } } public static void OnDomeStateChanged(ShieldGeneratorBiomeChanger dome, bool biomeChanged) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 if ((biomeChanged || !dome.DomeActive || (int)dome.SelectedBiome != 64) && s_gcSpawned) { ClearGroundcover(); } if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } if (!Enabled || !dome.DomeActive || (int)dome.SelectedBiome != 64) { ClearDrifts(dome); return; } if (biomeChanged) { ClearDrifts(dome); } if (!IsSpawned(dome) && !EnsureSpawned(dome)) { s_pendingSpawn.Add(dome); } } public static void OnDomeDestroyed(ShieldGeneratorBiomeChanger dome) { if (s_gcSpawned) { ClearGroundcover(); } ClearDrifts(dome); } private static bool EnsureSpawned(ShieldGeneratorBiomeChanger dome) { if (s_prefabFailed) { MarkSpawned(dome); return true; } if (!kSpawnDriftObjects) { if (CountOwned(dome) > 0) { ClearDrifts(dome); } MarkSpawned(dome); return true; } if (dome.DomeKey == 0L || !dome.RadiusSettled) { return false; } if (CountOwned(dome) > 0) { MarkSpawned(dome); return true; } return TrySpawnDrifts(dome); } private static bool TrySpawnDrifts(ShieldGeneratorBiomeChanger dome) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) if (s_prefabFailed || (Object)(object)s_driftPrefab == (Object)null) { return false; } if ((Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null || WorldGenerator.instance == null) { return false; } Vector3 domeCenter = dome.DomeCenter; float num = Mathf.Max(2f, dome.DomeTargetRadius); long domeKey = dome.DomeKey; if (domeKey == 0L) { return false; } Vector2s zone = ZoneSystem.GetZone(domeCenter); int num2 = Mathf.CeilToInt((num + 32f) / 64f); for (int i = -num2; i <= num2; i++) { for (int j = -num2; j <= num2; j++) { if (!ZoneSystem.instance.IsZoneLoaded(ZoneSystem.GetZonePos(new Vector2s(zone.x + j, zone.y + i)))) { return fal