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 CDEV StationUpgrade v0.1.1
plugins/CDEV.StationUpgrade/CDEV.StationUpgrade.dll
Decompiled 5 hours 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CDEV.StationUpgrade.Patches; using CDEV.StationUpgrade.UI; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("CDEV.StationUpgrade")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+efb24945142928ac03192750576c1d4fe797e026")] [assembly: AssemblyProduct("CDEV.StationUpgrade")] [assembly: AssemblyTitle("CDEV.StationUpgrade")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CDEV.StationUpgrade { internal static class ModConfig { internal static ConfigEntry<bool> ShowExtensionPieces; internal static ConfigEntry<bool> AllowBuildingExtensions; internal static ConfigEntry<bool> RefundOnDestroy; internal static ConfigEntry<bool> StarGlow; internal static ConfigEntry<bool> ShowNotice; internal static ConfigEntry<float> NoticeDistance; internal static void Bind(ConfigFile config) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown ShowExtensionPieces = config.Bind<bool>("General", "ShowExtensionPieces", false, new ConfigDescription("Show the station extensions (chopping block, tanning rack, forge cooler, ...) in the hammer's menu. Off: they are left out of it, and stations are upgraded from their window only. Extensions already built keep counting either way.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = 30 } })); AllowBuildingExtensions = config.Bind<bool>("General", "AllowBuildingExtensions", false, new ConfigDescription("Let players build the extensions with the hammer as in the game, besides upgrading from the station's window. Off: an extension shown in the hammer's menu cannot be placed, and its description says it is made in the station's window.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = 20 } })); RefundOnDestroy = config.Bind<bool>("General", "RefundOnDestroy", true, new ConfigDescription("A destroyed or torn down station drops what its paid upgrades cost (the recoverable materials, as the extension piece itself would drop them).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = 10 } })); StarGlow = config.Bind<bool>("Display", "StarGlow", true, "The level star of the crafting panel glows while an upgrade you can afford is waiting."); ShowNotice = config.Bind<bool>("Display", "ShowNotice", true, "A station with an upgrade you can afford says so above itself, the way Hugin talks."); NoticeDistance = config.Bind<float>("Display", "NoticeDistance", 10f, new ConfigDescription("How close (in metres) you have to be to a station to see its notice.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), Array.Empty<object>())); } } [BepInPlugin("cdev.stationupgrade", "CDEV.StationUpgrade", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class StationUpgradePlugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ModConfig.Bind(((BaseUnityPlugin)this).Config); ModConfig.ShowExtensionPieces.SettingChanged += delegate { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { localPlayer.UpdateAvailablePiecesList(); } }; _harmony = new Harmony("cdev.stationupgrade"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); } private void Update() { UpgradeService.Tick(); LevelStar.Tick(); UpgradeWindow.Tick(); StationNotice.Tick(); } private void OnDestroy() { UpgradeWindow.DestroyAll(); LevelStar.DestroyAll(); StationNotice.ClearAll(); ExtensionDescriptionPatch.DestroyAll(); UpgradeService.UnregisterAll(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal sealed class ExtensionDef { internal string Prefab; internal Piece Piece; internal StationExtension Extension; internal string StationName; } internal static class StationCatalog { private static readonly List<ExtensionDef> Empty = new List<ExtensionDef>(); private static readonly Dictionary<string, List<ExtensionDef>> ByStation = new Dictionary<string, List<ExtensionDef>>(); private static readonly Dictionary<string, ExtensionDef> ByPrefab = new Dictionary<string, ExtensionDef>(); private static readonly HashSet<Piece> Pieces = new HashSet<Piece>(); private static ObjectDB _db; private static int _itemCount = -1; internal static List<ExtensionDef> For(CraftingStation station) { Ensure(); if (!((Object)(object)station != (Object)null) || !ByStation.TryGetValue(station.m_name, out var value)) { return Empty; } return value; } internal static ExtensionDef Find(string prefab) { Ensure(); if (prefab == null || !ByPrefab.TryGetValue(prefab, out var value)) { return null; } return value; } internal static bool IsExtension(Piece piece) { Ensure(); if ((Object)(object)piece != (Object)null) { return Pieces.Contains(piece); } return false; } private static void Ensure() { ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null || ((Object)(object)instance == (Object)(object)_db && instance.m_items.Count == _itemCount)) { return; } _db = instance; _itemCount = instance.m_items.Count; ByStation.Clear(); ByPrefab.Clear(); Pieces.Clear(); foreach (GameObject item in instance.m_items) { ItemDrop val = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null); PieceTable val2 = (((Object)(object)val != (Object)null) ? val.m_itemData.m_shared.m_buildPieces : null); if ((Object)(object)val2 == (Object)null) { continue; } foreach (GameObject piece in val2.m_pieces) { if ((Object)(object)piece == (Object)null || ByPrefab.ContainsKey(((Object)piece).name)) { continue; } StationExtension component = piece.GetComponent<StationExtension>(); Piece component2 = piece.GetComponent<Piece>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null) && !((Object)(object)component.m_craftingStation == (Object)null)) { ExtensionDef extensionDef = new ExtensionDef { Prefab = ((Object)piece).name, Piece = component2, Extension = component, StationName = component.m_craftingStation.m_name }; ByPrefab[extensionDef.Prefab] = extensionDef; Pieces.Add(component2); if (!ByStation.TryGetValue(extensionDef.StationName, out var value)) { value = (ByStation[extensionDef.StationName] = new List<ExtensionDef>()); } value.Add(extensionDef); } } } } } internal static class StationNotice { private const float CheckInterval = 0.5f; private const float AboveTop = 0.6f; private static readonly HashSet<CraftingStation> Shown = new HashSet<CraftingStation>(); private static readonly List<CraftingStation> Gone = new List<CraftingStation>(); private static readonly Dictionary<CraftingStation, float> Heights = new Dictionary<CraftingStation, float>(); private static float _next; private static string _language; internal static void Tick() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.5f; Player localPlayer = Player.m_localPlayer; Chat instance = Chat.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || !ModConfig.ShowNotice.Value || ((Character)localPlayer).IsDead()) { ClearAll(); return; } string text = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null); if (text != _language) { ClearAll(); _language = text; } CraftingStation val = (InventoryGui.IsVisible() ? localPlayer.GetCurrentCraftingStation() : null); float value = ModConfig.NoticeDistance.Value; Vector3 position = ((Component)localPlayer).transform.position; foreach (CraftingStation allStation in CraftingStation.m_allStations) { if ((Object)(object)allStation == (Object)null) { continue; } int num; if ((Object)(object)allStation != (Object)(object)val) { Vector3 val2 = ((Component)allStation).transform.position - position; if (((Vector3)(ref val2)).sqrMagnitude <= value * value && StationCatalog.For(allStation).Count > 0) { num = (UpgradeService.HasReady(allStation, localPlayer) ? 1 : 0); goto IL_011a; } } num = 0; goto IL_011a; IL_011a: bool flag = (byte)num != 0; if (flag && !Shown.Contains(allStation)) { instance.SetNpcText(((Component)allStation).gameObject, Vector3.up * HeightOf(allStation), value + 10f, 0f, Translations.Text(allStation.m_name), Translations.Text("$cdev_su_notice") + "\n<size=80%>" + Translations.Text("$cdev_su_noticehint") + "</size>", false); Shown.Add(allStation); } else if (!flag && Shown.Remove(allStation)) { instance.ClearNpcText(((Component)allStation).gameObject); } } foreach (CraftingStation item in Shown) { if ((Object)(object)item == (Object)null) { Gone.Add(item); } } foreach (CraftingStation item2 in Gone) { Shown.Remove(item2); Heights.Remove(item2); } Gone.Clear(); } private static float HeightOf(CraftingStation station) { //IL_0017: 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_006b: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (Heights.TryGetValue(station, out var value)) { return value; } float num = ((Component)station).transform.position.y + 1.5f; bool flag = false; Renderer[] componentsInChildren = ((Component)station).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (val is MeshRenderer || val is SkinnedMeshRenderer) { Bounds bounds; float num2; if (!flag) { bounds = val.bounds; num2 = ((Bounds)(ref bounds)).max.y; } else { float num3 = num; bounds = val.bounds; num2 = Mathf.Max(num3, ((Bounds)(ref bounds)).max.y); } num = num2; flag = true; } } value = num - ((Component)station).transform.position.y + 0.6f; Heights[station] = value; return value; } internal static void ClearAll() { Chat instance = Chat.instance; foreach (CraftingStation item in Shown) { if ((Object)(object)instance != (Object)null && (Object)(object)item != (Object)null) { instance.ClearNpcText(((Component)item).gameObject); } } Shown.Clear(); Heights.Clear(); } } internal static class StationUpgrades { internal struct Entry { internal string Prefab; internal bool Paid; } private sealed class Cache { internal ZDO Zdo; internal uint Revision = uint.MaxValue; internal readonly List<Entry> Entries = new List<Entry>(); } internal static readonly int BoughtKey = StringExtensionMethods.GetStableHashCode("cdev.stationupgrade.bought"); private static readonly ConditionalWeakTable<CraftingStation, Cache> Caches = new ConditionalWeakTable<CraftingStation, Cache>(); private static readonly List<Entry> None = new List<Entry>(); private static ZDO ZdoOf(CraftingStation station) { ZNetView val = (((Object)(object)station != (Object)null) ? station.m_nview : null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return null; } return val.GetZDO(); } internal static List<Entry> Bought(CraftingStation station) { ZDO val = ZdoOf(station); if (val == null) { return None; } Cache orCreateValue = Caches.GetOrCreateValue(station); if (orCreateValue.Zdo == val && orCreateValue.Revision == val.DataRevision) { return orCreateValue.Entries; } orCreateValue.Zdo = val; orCreateValue.Revision = val.DataRevision; orCreateValue.Entries.Clear(); Parse(val.GetString(BoughtKey, ""), orCreateValue.Entries); return orCreateValue.Entries; } internal static void Parse(string raw, List<Entry> into) { if (!string.IsNullOrEmpty(raw)) { string[] array = raw.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { int num = text.LastIndexOf(':'); string prefab = ((num > 0) ? text.Substring(0, num) : text); into.Add(new Entry { Prefab = prefab, Paid = (num > 0 && text.Substring(num + 1) == "1") }); } } } internal static bool IsBought(CraftingStation station, string prefab) { List<Entry> list = Bought(station); for (int i = 0; i < list.Count; i++) { if (list[i].Prefab == prefab) { return true; } } return false; } internal static bool IsAttached(CraftingStation station, ExtensionDef def) { List<StationExtension> attachedExtensions = station.m_attachedExtensions; for (int i = 0; i < attachedExtensions.Count; i++) { StationExtension val = attachedExtensions[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.m_piece != (Object)null && val.m_piece.m_name == def.Piece.m_name) { return true; } } return false; } internal static bool IsInstalled(CraftingStation station, ExtensionDef def) { if (!IsBought(station, def.Prefab)) { return IsAttached(station, def); } return true; } internal static int ExtraLevels(CraftingStation station) { List<Entry> list = Bought(station); int num = 0; for (int i = 0; i < list.Count; i++) { ExtensionDef extensionDef = StationCatalog.Find(list[i].Prefab); if (extensionDef != null && extensionDef.StationName == station.m_name && !IsAttached(station, extensionDef)) { num++; } } return num; } internal static bool ApplyOnOwner(CraftingStation station, string prefab, bool paid) { ZDO val = ZdoOf(station); ExtensionDef extensionDef = StationCatalog.Find(prefab); if (val == null || !station.m_nview.IsOwner() || extensionDef == null || extensionDef.StationName != station.m_name || IsInstalled(station, extensionDef)) { return false; } StringBuilder stringBuilder = new StringBuilder(val.GetString(BoughtKey, "")); if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(prefab).Append(':').Append(paid ? '1' : '0'); val.Set(BoughtKey, stringBuilder.ToString()); Refresh(station); return true; } internal static bool RemoveOnOwner(CraftingStation station, string prefab, out bool paid) { paid = false; ZDO val = ZdoOf(station); if (val == null || !station.m_nview.IsOwner()) { return false; } List<Entry> list = new List<Entry>(); Parse(val.GetString(BoughtKey, ""), list); int num = list.FindIndex((Entry e) => e.Prefab == prefab); if (num < 0) { return false; } paid = list[num].Paid; list.RemoveAt(num); StringBuilder stringBuilder = new StringBuilder(); foreach (Entry item in list) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(item.Prefab).Append(':').Append(item.Paid ? '1' : '0'); } val.Set(BoughtKey, stringBuilder.ToString()); Refresh(station); return true; } internal static void Refresh(CraftingStation station) { if ((Object)(object)station != (Object)null) { station.m_updateExtensionTimer = 2f; station.GetExtensions(); } } } internal static class Translations { private const string Prefix = "$cdev_su_"; private static readonly string[] Keys = new string[21] { "upgraded", "failed", "levelword", "installed", "upgrade", "short", "needstation", "none", "notice", "noticehint", "free", "pending", "title", "back", "startip", "remove", "removed", "removefailed", "attached", "tipback", "buildnote" }; private static readonly Dictionary<string, string[]> Languages = new Dictionary<string, string[]> { ["English"] = new string[21] { "{0} upgraded: {1}", "Upgrade failed - materials returned", "Level", "Installed", "Upgrade", "Not enough materials", "Needs {0} nearby", "No upgrades yet: they unlock as you discover their materials", "Can be upgraded!", "Open it and click the level star", "Free", "Waiting...", "Station upgrades", "Back", "Click to open the station's upgrades", "Remove", "{0}: {1} removed", "Could not remove the upgrade", "Built next to it", "Click to go back to crafting", "Made in the station's window ({0}): click its level star" }, ["Russian"] = new string[21] { "{0} улучшен: {1}", "Улучшение не удалось - материалы возвращены", "Уровень", "Установлено", "Улучшить", "Не хватает материалов", "Нужен {0} рядом", "Улучшений пока нет: они откроются, когда вы найдёте их материалы", "Можно улучшить!", "Откройте и нажмите на звезду уровня", "Бесплатно", "Ожидание...", "Улучшения станка", "Назад", "Нажмите, чтобы открыть улучшения станка", "Убрать", "{0}: {1} убрано", "Не удалось убрать улучшение", "Пристройка рядом", "Нажмите, чтобы вернуться к созданию", "Делается в окне станции ({0}): нажмите на её звезду уровня" }, ["Ukrainian"] = new string[21] { "{0} покращено: {1}", "Покращення не вдалося - матеріали повернуто", "Рівень", "Встановлено", "Покращити", "Не вистачає матеріалів", "Потрібен {0} поруч", "Покращень поки немає: вони відкриються, коли ви знайдете їхні матеріали", "Можна покращити!", "Відкрийте та натисніть на зірку рівня", "Безкоштовно", "Очікування...", "Покращення станка", "Назад", "Натисніть, щоб відкрити покращення станка", "Прибрати", "{0}: {1} прибрано", "Не вдалося прибрати покращення", "Прибудова поруч", "Натисніть, щоб повернутися до створення", "Робиться у вікні станції ({0}): натисніть на її зірку рівня" }, ["German"] = new string[21] { "{0} verbessert: {1}", "Verbesserung fehlgeschlagen - Materialien zurückgegeben", "Stufe", "Installiert", "Verbessern", "Nicht genug Materialien", "Benötigt {0} in der Nähe", "Noch keine Verbesserungen: Sie werden freigeschaltet, sobald du ihre Materialien entdeckst", "Kann verbessert werden!", "Öffne sie und klicke auf den Stufenstern", "Kostenlos", "Warte...", "Stationsverbesserungen", "Zurück", "Klicken, um die Verbesserungen der Station zu öffnen", "Entfernen", "{0}: {1} entfernt", "Verbesserung konnte nicht entfernt werden", "Daneben gebaut", "Klicken, um zum Herstellen zurückzukehren", "Wird im Fenster der Station gebaut ({0}): auf ihren Stufenstern klicken" }, ["French"] = new string[21] { "{0} amélioré : {1}", "Échec de l'amélioration - matériaux rendus", "Niveau", "Installée", "Améliorer", "Matériaux insuffisants", "Nécessite {0} à proximité", "Aucune amélioration pour l'instant : elles se débloquent quand vous découvrez leurs matériaux", "Peut être amélioré !", "Ouvrez-le et cliquez sur l'étoile de niveau", "Gratuit", "En attente...", "Améliorations de la station", "Retour", "Cliquez pour ouvrir les améliorations de la station", "Retirer", "{0} : {1} retiré", "Impossible de retirer l'amélioration", "Construit à côté", "Cliquez pour revenir à la fabrication", "Se fait dans la fenêtre de la station ({0}) : cliquez sur son étoile de niveau" }, ["Spanish"] = new string[21] { "{0} mejorado: {1}", "Mejora fallida - materiales devueltos", "Nivel", "Instalada", "Mejorar", "Materiales insuficientes", "Requiere {0} cerca", "Aún no hay mejoras: se desbloquean al descubrir sus materiales", "¡Se puede mejorar!", "Ábrelo y haz clic en la estrella de nivel", "Gratis", "Esperando...", "Mejoras de la estación", "Volver", "Haz clic para abrir las mejoras de la estación", "Quitar", "{0}: se quitó {1}", "No se pudo quitar la mejora", "Construido al lado", "Haz clic para volver a la fabricación", "Se hace en la ventana de la estación ({0}): haz clic en su estrella de nivel" }, ["Italian"] = new string[21] { "{0} migliorato: {1}", "Miglioramento fallito - materiali restituiti", "Livello", "Installato", "Migliora", "Materiali insufficienti", "Serve {0} nelle vicinanze", "Ancora nessun miglioramento: si sbloccano quando scopri i loro materiali", "Si può migliorare!", "Aprilo e clicca sulla stella del livello", "Gratis", "In attesa...", "Miglioramenti della stazione", "Indietro", "Clicca per aprire i miglioramenti della stazione", "Rimuovi", "{0}: {1} rimosso", "Impossibile rimuovere il miglioramento", "Costruito accanto", "Clicca per tornare alla creazione", "Si fa nella finestra della stazione ({0}): clicca sulla sua stella del livello" }, ["Portuguese_Brazilian"] = new string[21] { "{0} melhorado: {1}", "A melhoria falhou - materiais devolvidos", "Nível", "Instalada", "Melhorar", "Materiais insuficientes", "Requer {0} por perto", "Nenhuma melhoria ainda: elas são liberadas quando você descobre seus materiais", "Pode ser melhorado!", "Abra e clique na estrela de nível", "Grátis", "Aguardando...", "Melhorias da estação", "Voltar", "Clique para abrir as melhorias da estação", "Remover", "{0}: {1} removido", "Não foi possível remover a melhoria", "Construído ao lado", "Clique para voltar à fabricação", "Feito na janela da estação ({0}): clique na estrela de nível dela" }, ["Portuguese_European"] = new string[21] { "{0} melhorado: {1}", "A melhoria falhou - materiais devolvidos", "Nível", "Instalada", "Melhorar", "Materiais insuficientes", "Requer {0} por perto", "Ainda não há melhorias: são desbloqueadas quando descobres os seus materiais", "Pode ser melhorado!", "Abre-o e clica na estrela de nível", "Grátis", "A aguardar...", "Melhorias da estação", "Voltar", "Clica para abrir as melhorias da estação", "Remover", "{0}: {1} removido", "Não foi possível remover a melhoria", "Construído ao lado", "Clica para voltar ao fabrico", "Feito na janela da estação ({0}): clique na estrela de nível dela" }, ["Polish"] = new string[21] { "Ulepszono {0}: {1}", "Ulepszenie nieudane - materiały zwrócone", "Poziom", "Zainstalowane", "Ulepsz", "Za mało materiałów", "Wymaga {0} w pobliżu", "Brak ulepszeń: odblokują się, gdy odkryjesz ich materiały", "Można ulepszyć!", "Otwórz i kliknij gwiazdkę poziomu", "Za darmo", "Oczekiwanie...", "Ulepszenia stanowiska", "Wróć", "Kliknij, aby otworzyć ulepszenia stanowiska", "Usuń", "{0}: usunięto {1}", "Nie udało się usunąć ulepszenia", "Zbudowane obok", "Kliknij, aby wrócić do wytwarzania", "Robi się w oknie stacji ({0}): kliknij jej gwiazdkę poziomu" }, ["Czech"] = new string[21] { "{0}: vylepšeno o {1}", "Vylepšení selhalo - materiál vrácen", "Úroveň", "Nainstalováno", "Vylepšit", "Nedostatek materiálu", "Vyžaduje {0} poblíž", "Zatím žádná vylepšení: odemknou se, až objevíte jejich materiály", "Lze vylepšit!", "Otevřete a klikněte na hvězdu úrovně", "Zdarma", "Čekání...", "Vylepšení stanice", "Zpět", "Kliknutím otevřete vylepšení stanice", "Odebrat", "{0}: odebráno {1}", "Vylepšení nelze odebrat", "Postaveno vedle", "Kliknutím se vrátíte k výrobě", "Dělá se v okně stanice ({0}): klikněte na její hvězdu úrovně" }, ["Slovak"] = new string[21] { "{0}: vylepšené o {1}", "Vylepšenie zlyhalo - materiál vrátený", "Úroveň", "Nainštalované", "Vylepšiť", "Nedostatok materiálu", "Vyžaduje {0} nablízku", "Zatiaľ žiadne vylepšenia: odomknú sa, keď objavíte ich materiály", "Dá sa vylepšiť!", "Otvorte a kliknite na hviezdu úrovne", "Zadarmo", "Čakanie...", "Vylepšenia stanice", "Späť", "Kliknutím otvoríte vylepšenia stanice", "Odobrať", "{0}: odobrané {1}", "Vylepšenie sa nepodarilo odobrať", "Postavené vedľa", "Kliknutím sa vrátite k výrobe", "Robí sa v okne stanice ({0}): kliknite na jej hviezdu úrovne" }, ["Hungarian"] = new string[21] { "{0} fejlesztve: {1}", "A fejlesztés nem sikerült - anyagok visszaadva", "Szint", "Telepítve", "Fejlesztés", "Nincs elég anyag", "Kell: {0} a közelben", "Még nincs fejlesztés: akkor nyílnak meg, amikor felfedezed az anyagaikat", "Fejleszthető!", "Nyisd meg, és kattints a szint csillagára", "Ingyenes", "Várakozás...", "Állomás fejlesztései", "Vissza", "Kattints az állomás fejlesztéseinek megnyitásához", "Eltávolítás", "{0}: {1} eltávolítva", "A fejlesztést nem sikerült eltávolítani", "Mellé építve", "Kattints a készítéshez való visszatéréshez", "Az állomás ablakában készül ({0}): kattints a szint csillagára" }, ["Dutch"] = new string[21] { "{0} verbeterd: {1}", "Verbeteren mislukt - materialen teruggegeven", "Niveau", "Geïnstalleerd", "Verbeteren", "Niet genoeg materialen", "Vereist {0} in de buurt", "Nog geen verbeteringen: ze worden ontgrendeld zodra je hun materialen ontdekt", "Kan verbeterd worden!", "Open het en klik op de niveauster", "Gratis", "Wachten...", "Verbeteringen van station", "Terug", "Klik om de verbeteringen van het station te openen", "Verwijderen", "{0}: {1} verwijderd", "Kon de verbetering niet verwijderen", "Ernaast gebouwd", "Klik om terug te gaan naar maken", "Wordt gemaakt in het venster van het station ({0}): klik op de niveauster" }, ["Swedish"] = new string[21] { "{0} uppgraderad: {1}", "Uppgraderingen misslyckades - material återlämnat", "Nivå", "Installerad", "Uppgradera", "Inte tillräckligt med material", "Kräver {0} i närheten", "Inga uppgraderingar än: de låses upp när du upptäcker deras material", "Kan uppgraderas!", "Öppna den och klicka på nivåstjärnan", "Gratis", "Väntar...", "Stationsuppgraderingar", "Tillbaka", "Klicka för att öppna stationens uppgraderingar", "Ta bort", "{0}: {1} borttagen", "Kunde inte ta bort uppgraderingen", "Byggd bredvid", "Klicka för att gå tillbaka till tillverkning", "Görs i stationens fönster ({0}): klicka på dess nivåstjärna" }, ["Norwegian"] = new string[21] { "{0} oppgradert: {1}", "Oppgradering mislyktes - materialer returnert", "Nivå", "Installert", "Oppgrader", "Ikke nok materialer", "Krever {0} i nærheten", "Ingen oppgraderinger ennå: de låses opp når du oppdager materialene deres", "Kan oppgraderes!", "Åpne den og klikk på nivåstjernen", "Gratis", "Venter...", "Stasjonsoppgraderinger", "Tilbake", "Klikk for å åpne stasjonens oppgraderinger", "Fjern", "{0}: {1} fjernet", "Kunne ikke fjerne oppgraderingen", "Bygget ved siden av", "Klikk for å gå tilbake til håndverk", "Lages i stasjonens vindu ({0}): klikk på nivåstjernen" }, ["Danish"] = new string[21] { "{0} opgraderet: {1}", "Opgradering mislykkedes - materialer returneret", "Niveau", "Installeret", "Opgradér", "Ikke nok materialer", "Kræver {0} i nærheden", "Ingen opgraderinger endnu: de låses op, når du opdager deres materialer", "Kan opgraderes!", "Åbn den og klik på niveaustjernen", "Gratis", "Venter...", "Stationsopgraderinger", "Tilbage", "Klik for at åbne stationens opgraderinger", "Fjern", "{0}: {1} fjernet", "Kunne ikke fjerne opgraderingen", "Bygget ved siden af", "Klik for at gå tilbage til fremstilling", "Laves i stationens vindue ({0}): klik på niveaustjernen" }, ["Finnish"] = new string[21] { "{0} päivitetty: {1}", "Päivitys epäonnistui - materiaalit palautettu", "Taso", "Asennettu", "Päivitä", "Materiaalit eivät riitä", "Vaatii lähelle: {0}", "Ei vielä päivityksiä: ne avautuvat, kun löydät niiden materiaalit", "Voidaan päivittää!", "Avaa se ja napsauta tason tähteä", "Ilmainen", "Odotetaan...", "Aseman päivitykset", "Takaisin", "Napsauta avataksesi aseman päivitykset", "Poista", "{0}: {1} poistettu", "Päivitystä ei voitu poistaa", "Rakennettu viereen", "Napsauta palataksesi valmistukseen", "Tehdään aseman ikkunassa ({0}): napsauta sen tasotähteä" }, ["Icelandic"] = new string[21] { "{0} uppfært: {1}", "Uppfærsla mistókst - efni skilað", "Stig", "Uppsett", "Uppfæra", "Ekki nóg efni", "Þarf {0} nálægt", "Engar uppfærslur enn: þær opnast þegar þú finnur efnin í þær", "Hægt að uppfæra!", "Opnaðu og smelltu á stigsstjörnuna", "Ókeypis", "Bíð...", "Uppfærslur stöðvar", "Til baka", "Smelltu til að opna uppfærslur stöðvarinnar", "Fjarlægja", "{0}: {1} fjarlægt", "Ekki tókst að fjarlægja uppfærsluna", "Byggt við hliðina", "Smelltu til að fara aftur í smíði", "Gert í glugga stöðvarinnar ({0}): smelltu á stigsstjörnuna" }, ["Turkish"] = new string[21] { "{0} yükseltildi: {1}", "Yükseltme başarısız - malzemeler iade edildi", "Seviye", "Kurulu", "Yükselt", "Yeterli malzeme yok", "Yakında {0} gerekli", "Henüz yükseltme yok: malzemelerini keşfettikçe açılırlar", "Yükseltilebilir!", "Aç ve seviye yıldızına tıkla", "Ücretsiz", "Bekleniyor...", "İstasyon yükseltmeleri", "Geri", "İstasyonun yükseltmelerini açmak için tıkla", "Kaldır", "{0}: {1} kaldırıldı", "Yükseltme kaldırılamadı", "Yanına inşa edilmiş", "Üretime dönmek için tıkla", "İstasyonun penceresinde yapılır ({0}): seviye yıldızına tıklayın" }, ["Romanian"] = new string[21] { "{0} îmbunătățit: {1}", "Îmbunătățirea a eșuat - materiale returnate", "Nivel", "Instalată", "Îmbunătățește", "Materiale insuficiente", "Necesită {0} în apropiere", "Încă nu există îmbunătățiri: se deblochează când le descoperi materialele", "Poate fi îmbunătățit!", "Deschide-l și apasă pe steaua de nivel", "Gratuit", "Se așteaptă...", "Îmbunătățirile stației", "Înapoi", "Apasă pentru a deschide îmbunătățirile stației", "Elimină", "{0}: {1} eliminat", "Îmbunătățirea nu a putut fi eliminată", "Construit alături", "Apasă pentru a reveni la meșteșugărit", "Se face în fereastra stației ({0}): faceți clic pe steaua de nivel" }, ["Bulgarian"] = new string[21] { "{0} подобрен: {1}", "Подобрението не успя - материалите са върнати", "Ниво", "Инсталирано", "Подобри", "Няма достатъчно материали", "Нужен е {0} наблизо", "Още няма подобрения: отключват се, когато откриете материалите им", "Може да се подобри!", "Отворете и натиснете звездата на нивото", "Безплатно", "Изчакване...", "Подобрения на станцията", "Назад", "Натиснете, за да отворите подобренията на станцията", "Премахни", "{0}: {1} премахнато", "Подобрението не можа да бъде премахнато", "Построено до него", "Натиснете, за да се върнете към изработването", "Прави се в прозореца на станцията ({0}): щракнете върху звездата на нивото" }, ["Macedonian"] = new string[21] { "{0} подобрен: {1}", "Подобрувањето не успеа - материјалите се вратени", "Ниво", "Инсталирано", "Подобри", "Нема доволно материјали", "Потребен е {0} во близина", "Сè уште нема подобрувања: се отклучуваат кога ќе ги откриете нивните материјали", "Може да се подобри!", "Отворете и кликнете на ѕвездата на нивото", "Бесплатно", "Се чека...", "Подобрувања на станицата", "Назад", "Кликнете за да ги отворите подобрувањата на станицата", "Отстрани", "{0}: {1} отстрането", "Подобрувањето не може да се отстрани", "Изградено до него", "Кликнете за да се вратите на изработката", "Се прави во прозорецот на станицата ({0}): кликнете на ѕвездата на нивото" }, ["Serbian"] = new string[21] { "{0} unapređen: {1}", "Unapređenje nije uspelo - materijali vraćeni", "Nivo", "Instalirano", "Unapredi", "Nema dovoljno materijala", "Potreban je {0} u blizini", "Još nema unapređenja: otključavaju se kada otkrijete njihove materijale", "Može da se unapredi!", "Otvorite i kliknite na zvezdu nivoa", "Besplatno", "Čekanje...", "Unapređenja stanice", "Nazad", "Kliknite da otvorite unapređenja stanice", "Ukloni", "{0}: {1} uklonjeno", "Unapređenje nije moguće ukloniti", "Izgrađeno pored", "Kliknite da se vratite izradi", "Pravi se u prozoru stanice ({0}): kliknite na zvezdu nivoa" }, ["Croatian"] = new string[21] { "{0} nadograđen: {1}", "Nadogradnja nije uspjela - materijali vraćeni", "Razina", "Ugrađeno", "Nadogradi", "Nema dovoljno materijala", "Potreban je {0} u blizini", "Još nema nadogradnji: otključavaju se kad otkrijete njihove materijale", "Može se nadograditi!", "Otvorite i kliknite na zvjezdicu razine", "Besplatno", "Čekanje...", "Nadogradnje stanice", "Natrag", "Kliknite za otvaranje nadogradnji stanice", "Ukloni", "{0}: {1} uklonjeno", "Nadogradnju nije moguće ukloniti", "Izgrađeno pokraj", "Kliknite za povratak na izradu", "Radi se u prozoru stanice ({0}): kliknite na zvjezdicu razine" }, ["Lithuanian"] = new string[21] { "{0} patobulinta: {1}", "Patobulinti nepavyko - medžiagos grąžintos", "Lygis", "Įrengta", "Patobulinti", "Nepakanka medžiagų", "Reikia {0} netoliese", "Patobulinimų dar nėra: jie atsiras, kai atrasite jų medžiagas", "Galima patobulinti!", "Atidarykite ir spustelėkite lygio žvaigždę", "Nemokamai", "Laukiama...", "Stoties patobulinimai", "Atgal", "Spustelėkite, kad atidarytumėte stoties patobulinimus", "Pašalinti", "{0}: {1} pašalinta", "Nepavyko pašalinti patobulinimo", "Pastatyta šalia", "Spustelėkite, kad grįžtumėte prie gamybos", "Daroma stoties lange ({0}): spustelėkite lygio žvaigždę" }, ["Latvian"] = new string[21] { "{0} uzlabots: {1}", "Uzlabošana neizdevās - materiāli atgriezti", "Līmenis", "Uzstādīts", "Uzlabot", "Nepietiek materiālu", "Nepieciešams {0} tuvumā", "Vēl nav uzlabojumu: tie atbloķējas, kad atklājat to materiālus", "Var uzlabot!", "Atveriet un noklikšķiniet uz līmeņa zvaigznes", "Bez maksas", "Gaida...", "Stacijas uzlabojumi", "Atpakaļ", "Noklikšķiniet, lai atvērtu stacijas uzlabojumus", "Noņemt", "{0}: {1} noņemts", "Neizdevās noņemt uzlabojumu", "Uzbūvēts blakus", "Noklikšķiniet, lai atgrieztos pie izgatavošanas", "Tiek veikts stacijas logā ({0}): noklikšķiniet uz līmeņa zvaigznes" }, ["Greek"] = new string[21] { "{0} αναβαθμίστηκε: {1}", "Η αναβάθμιση απέτυχε - τα υλικά επιστράφηκαν", "Επίπεδο", "Εγκατεστημένο", "Αναβάθμιση", "Δεν υπάρχουν αρκετά υλικά", "Απαιτείται {0} κοντά", "Δεν υπάρχουν ακόμη αναβαθμίσεις: ξεκλειδώνονται όταν ανακαλύπτεις τα υλικά τους", "Μπορεί να αναβαθμιστεί!", "Άνοιξέ το και κάνε κλικ στο αστέρι επιπέδου", "Δωρεάν", "Αναμονή...", "Αναβαθμίσεις σταθμού", "Πίσω", "Κάνε κλικ για να ανοίξεις τις αναβαθμίσεις του σταθμού", "Αφαίρεση", "{0}: αφαιρέθηκε {1}", "Δεν ήταν δυνατή η αφαίρεση της αναβάθμισης", "Χτισμένο δίπλα", "Κάνε κλικ για επιστροφή στην κατασκευή", "Γίνεται στο παράθυρο του σταθμού ({0}): κάντε κλικ στο αστέρι επιπέδου" }, ["Georgian"] = new string[21] { "{0} გაუმჯობესდა: {1}", "გაუმჯობესება ვერ მოხერხდა - მასალები დაბრუნდა", "დონე", "დაყენებულია", "გაუმჯობესება", "არ არის საკმარისი მასალა", "საჭიროა {0} ახლოს", "გაუმჯობესებები ჯერ არ არის: ისინი გაიხსნება, როცა მათ მასალებს აღმოაჩენთ", "შესაძლებელია გაუმჯობესება!", "გახსენით და დააწკაპუნეთ დონის ვარსკვლავზე", "უფასო", "ლოდინი...", "სადგურის გაუმჯობესებები", "უკან", "დააწკაპუნეთ სადგურის გაუმჯობესებების გასახსნელად", "მოხსნა", "{0}: {1} მოიხსნა", "გაუმჯობესების მოხსნა ვერ მოხერხდა", "გვერდით აშენებული", "დააწკაპუნეთ დამზადებაზე დასაბრუნებლად", "კეთდება სადგურის ფანჯარაში ({0}): დააჭირეთ დონის ვარსკვლავს" }, ["Chinese"] = new string[21] { "{0} 已升级:{1}", "升级失败 - 材料已退还", "等级", "已安装", "升级", "材料不足", "附近需要{0}", "暂无升级:发现所需材料后即可解锁", "可以升级!", "打开它并点击等级星标", "免费", "等待中...", "制作站升级", "返回", "点击打开制作站的升级", "移除", "{0}:已移除{1}", "无法移除升级", "已建在旁边", "点击返回制作", "在工作站窗口中制作({0}):点击其等级星标" }, ["Chinese_Trad"] = new string[21] { "{0} 已升級:{1}", "升級失敗 - 材料已退還", "等級", "已安裝", "升級", "材料不足", "附近需要{0}", "尚無升級:發現所需材料後即可解鎖", "可以升級!", "打開它並點擊等級星標", "免費", "等待中...", "製作站升級", "返回", "點擊打開製作站的升級", "移除", "{0}:已移除{1}", "無法移除升級", "已建在旁邊", "點擊返回製作", "在工作站視窗中製作({0}):點擊其等級星標" }, ["Japanese"] = new string[21] { "{0}を強化しました:{1}", "強化に失敗しました - 素材を返却しました", "レベル", "設置済み", "強化", "素材が足りません", "近くに{0}が必要です", "まだ強化はありません:素材を発見すると解放されます", "強化できます!", "開いてレベルの星をクリック", "無料", "待機中...", "設備の強化", "戻る", "クリックして設備の強化を開く", "外す", "{0}:{1}を外しました", "強化を外せませんでした", "隣に建設済み", "クリックしてクラフトに戻る", "作業台の画面で行います({0}):レベルの星をクリック" }, ["Korean"] = new string[21] { "{0} 업그레이드됨: {1}", "업그레이드 실패 - 재료가 반환되었습니다", "레벨", "설치됨", "업그레이드", "재료가 부족합니다", "근처에 {0} 필요", "아직 업그레이드가 없습니다: 재료를 발견하면 해금됩니다", "업그레이드 가능!", "열어서 레벨 별을 클릭하세요", "무료", "대기 중...", "작업장 업그레이드", "뒤로", "클릭하여 작업장 업그레이드 열기", "제거", "{0}: {1} 제거됨", "업그레이드를 제거할 수 없습니다", "옆에 건설됨", "클릭하여 제작으로 돌아가기", "작업대 창에서 합니다 ({0}): 레벨 별을 클릭하세요" }, ["Hindi"] = new string[21] { "{0} उन\u094dनत ह\u0941आ: {1}", "उन\u094dनयन व\u093fफल - स\u093eमग\u094dर\u0940 ल\u094cट\u093eई गई", "स\u094dतर", "स\u094dथ\u093eप\u093fत", "उन\u094dनत कर\u0947\u0902", "पर\u094dय\u093eप\u094dत स\u093eमग\u094dर\u0940 नह\u0940\u0902", "प\u093eस म\u0947\u0902 {0} च\u093eह\u093fए", "अभ\u0940 क\u094bई उन\u094dनयन नह\u0940\u0902: उनक\u0940 स\u093eमग\u094dर\u0940 ख\u094bजन\u0947 पर व\u0947 ख\u0941ल\u0947\u0902ग\u0947", "उन\u094dनत क\u093fय\u093e ज\u093e सकत\u093e ह\u0948!", "इस\u0947 ख\u094bल\u0947\u0902 और स\u094dतर क\u0947 त\u093eर\u0947 पर क\u094dल\u093fक कर\u0947\u0902", "म\u0941फ\u093c\u094dत", "प\u094dरत\u0940क\u094dष\u093e...", "स\u094dट\u0947शन उन\u094dनयन", "व\u093eपस", "स\u094dट\u0947शन क\u0947 उन\u094dनयन ख\u094bलन\u0947 क\u0947 ल\u093fए क\u094dल\u093fक कर\u0947\u0902", "हट\u093eए\u0901", "{0}: {1} हट\u093eय\u093e गय\u093e", "उन\u094dनयन हट\u093eय\u093e नह\u0940\u0902 ज\u093e सक\u093e", "प\u093eस म\u0947\u0902 बन\u093e ह\u0948", "न\u093fर\u094dम\u093eण पर ल\u094cटन\u0947 क\u0947 ल\u093fए क\u094dल\u093fक कर\u0947\u0902", "स\u094dट\u0947शन क\u0940 व\u093f\u0902ड\u094b म\u0947\u0902 बनत\u093e ह\u0948 ({0}): उसक\u0947 स\u094dतर व\u093eल\u0947 त\u093eर\u0947 पर क\u094dल\u093fक कर\u0947\u0902" }, ["Thai"] = new string[21] { "อ\u0e31ปเกรด{0}แล\u0e49ว: {1}", "อ\u0e31ปเกรดล\u0e49มเหลว - ค\u0e37นว\u0e31สด\u0e38แล\u0e49ว", "ระด\u0e31บ", "ต\u0e34ดต\u0e31\u0e49งแล\u0e49ว", "อ\u0e31ปเกรด", "ว\u0e31สด\u0e38ไม\u0e48พอ", "ต\u0e49องม\u0e35{0}ใกล\u0e49ๆ", "ย\u0e31งไม\u0e48ม\u0e35อ\u0e31ปเกรด: จะปลดล\u0e47อกเม\u0e37\u0e48อค\u0e38ณค\u0e49นพบว\u0e31สด\u0e38ของม\u0e31น", "อ\u0e31ปเกรดได\u0e49!", "เป\u0e34ดแล\u0e49วคล\u0e34กดาวระด\u0e31บ", "ฟร\u0e35", "กำล\u0e31งรอ...", "อ\u0e31ปเกรดสถาน\u0e35", "กล\u0e31บ", "คล\u0e34กเพ\u0e37\u0e48อเป\u0e34ดอ\u0e31ปเกรดของสถาน\u0e35", "ถอด", "{0}: ถอด{1}แล\u0e49ว", "ถอดอ\u0e31ปเกรดไม\u0e48ได\u0e49", "สร\u0e49างไว\u0e49ข\u0e49างๆ", "คล\u0e34กเพ\u0e37\u0e48อกล\u0e31บไปท\u0e35\u0e48การสร\u0e49าง", "ทำในหน\u0e49าต\u0e48างของสถาน\u0e35 ({0}): คล\u0e34กดาวระด\u0e31บ" } }; private static string _language; private static Dictionary<string, string> _table; internal static string Text(string key) { if (key != null && key.StartsWith("$cdev_su_")) { if (!Table().TryGetValue(key.Substring("$cdev_su_".Length), out var value)) { return key; } return value; } if (Localization.instance == null) { return key; } return Localization.instance.Localize(key); } private static Dictionary<string, string> Table() { string text = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : "English"); if (_table != null && text == _language) { return _table; } _language = text; string[] array = Languages["English"]; if (!Languages.TryGetValue(text, out var value)) { value = array; } _table = new Dictionary<string, string>(); for (int i = 0; i < Keys.Length; i++) { _table[Keys[i]] = ((i < value.Length) ? value[i] : array[i]); } return _table; } } internal enum UpgradeState { Installed, Ready, Short, Pending } internal sealed class UpgradeRow { internal ExtensionDef Def; internal UpgradeState State; internal bool Free; internal bool StationMissing; internal bool Bought; } internal static class UpgradeService { private sealed class Pending { internal ZDOID Station; internal string Prefab; internal string Spent; internal float Sent; internal bool Remove; } private const string RpcRequest = "CDEV_StationUpgrade_Request"; private const string RpcResult = "CDEV_StationUpgrade_Result"; private const string RpcRemove = "CDEV_StationUpgrade_Remove"; private const string RpcRemoveResult = "CDEV_StationUpgrade_RemoveResult"; private const float ReplyTimeout = 6f; private static readonly List<Pending> Waiting = new List<Pending>(); private static readonly List<Pending> Expired = new List<Pending>(); private static readonly HashSet<ZNetView> Registered = new HashSet<ZNetView>(); private static readonly int RefundedKey = StringExtensionMethods.GetStableHashCode("cdev.stationupgrade.refunded"); private static int _pruneAt = 256; private static readonly UpgradeRow Scratch = new UpgradeRow(); internal static void RegisterRpcs(CraftingStation station) { ZNetView val = (((Object)(object)station != (Object)null) ? station.m_nview : null); if ((Object)(object)val == (Object)null || val.GetZDO() == null || Registered.Contains(val)) { return; } val.Register<string, bool>("CDEV_StationUpgrade_Request", (Action<long, string, bool>)delegate(long sender, string prefab, bool paid) { OnRequest(station, sender, prefab, paid); }); val.Register<string, bool>("CDEV_StationUpgrade_Result", (Action<long, string, bool>)delegate(long sender, string prefab, bool ok) { OnResult(station, prefab, ok); }); val.Register<string>("CDEV_StationUpgrade_Remove", (Action<long, string>)delegate(long sender, string prefab) { OnRemoveRequest(station, sender, prefab); }); val.Register<string, bool, bool>("CDEV_StationUpgrade_RemoveResult", (Action<long, string, bool, bool>)delegate(long sender, string prefab, bool ok, bool paid) { OnRemoveResult(station, prefab, ok, paid); }); Registered.Add(val); if (Registered.Count >= _pruneAt) { Registered.RemoveWhere((ZNetView view) => (Object)(object)view == (Object)null); _pruneAt = Mathf.Max(256, Registered.Count * 2); } } internal static void UnregisterAll() { foreach (ZNetView item in Registered) { if ((Object)(object)item != (Object)null) { item.Unregister("CDEV_StationUpgrade_Request"); item.Unregister("CDEV_StationUpgrade_Result"); item.Unregister("CDEV_StationUpgrade_Remove"); item.Unregister("CDEV_StationUpgrade_RemoveResult"); } } Registered.Clear(); Waiting.Clear(); } internal static bool IsKnown(Player player, ExtensionDef def) { Piece piece = def.Piece; if (!piece.m_enabled) { return false; } if (piece.m_dlc.Length > 0 && ((Object)(object)DLCMan.instance == (Object)null || !DLCMan.instance.IsDLCInstalled(piece.m_dlc))) { return false; } if (!player.NoCostCheat()) { return player.IsRecipeKnown(piece.m_name); } return true; } internal static bool IsFree(Player player, ExtensionDef def) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!player.NoCostCheat()) { if ((Object)(object)ZoneSystem.instance != (Object)null) { return ZoneSystem.instance.GetGlobalKey(def.Piece.FreeBuildKey()); } return false; } return true; } internal static bool StationMissing(Player player, ExtensionDef def) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) CraftingStation craftingStation = def.Piece.m_craftingStation; if ((Object)(object)craftingStation != (Object)null && (Object)(object)CraftingStation.HaveBuildStationInRange(craftingStation.m_name, ((Component)player).transform.position) == (Object)null) { if ((Object)(object)ZoneSystem.instance != (Object)null) { return !ZoneSystem.instance.GetGlobalKey((GlobalKeys)27); } return true; } return false; } internal static bool IsPending(CraftingStation station, string prefab) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) ZDO val = (((Object)(object)station.m_nview != (Object)null) ? station.m_nview.GetZDO() : null); if (val == null) { return false; } for (int i = 0; i < Waiting.Count; i++) { if (Waiting[i].Station == val.m_uid && Waiting[i].Prefab == prefab) { return true; } } return false; } internal static void Fill(CraftingStation station, Player player, ExtensionDef def, UpgradeRow row) { row.Def = def; row.Bought = StationUpgrades.IsBought(station, def.Prefab); row.Free = IsFree(player, def); row.StationMissing = StationMissing(player, def); if (StationUpgrades.IsInstalled(station, def)) { row.State = UpgradeState.Installed; return; } if (IsPending(station, def.Prefab)) { row.State = UpgradeState.Pending; return; } bool flag = player.NoCostCheat() || player.HaveRequirements(def.Piece, (RequirementMode)0); row.State = (flag ? UpgradeState.Ready : UpgradeState.Short); } internal static void Evaluate(CraftingStation station, Player player, List<UpgradeRow> rows, List<UpgradeRow> pool) { RegisterRpcs(station); pool.AddRange(rows); rows.Clear(); foreach (ExtensionDef item in StationCatalog.For(station)) { if (StationUpgrades.IsInstalled(station, item) || IsKnown(player, item)) { UpgradeRow upgradeRow; if (pool.Count > 0) { upgradeRow = pool[pool.Count - 1]; pool.RemoveAt(pool.Count - 1); } else { upgradeRow = new UpgradeRow(); } Fill(station, player, item, upgradeRow); rows.Add(upgradeRow); } } } internal static bool HasReady(CraftingStation station, Player player) { if ((Object)(object)station == (Object)null || (Object)(object)player == (Object)null) { return false; } foreach (ExtensionDef item in StationCatalog.For(station)) { if (IsKnown(player, item)) { Fill(station, player, item, Scratch); if (Scratch.State == UpgradeState.Ready) { return true; } } } return false; } internal static void TryBuy(CraftingStation station, ExtensionDef def, Player player) { //IL_00e2: 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) if ((Object)(object)station == (Object)null || def == null || (Object)(object)player == (Object)null || (Object)(object)station.m_nview == (Object)null || station.m_nview.GetZDO() == null) { return; } RegisterRpcs(station); Fill(station, player, def, Scratch); if (Scratch.State == UpgradeState.Installed || Scratch.State == UpgradeState.Pending || !IsKnown(player, def)) { return; } if (Scratch.State != UpgradeState.Ready) { ((Character)player).Message((MessageType)2, "$msg_missingrequirement", 0, (Sprite)null, false); return; } bool free = Scratch.Free; string spent = (free ? "" : Consume(player, def)); if (station.m_nview.IsOwner()) { Finish(station, def.Prefab, StationUpgrades.ApplyOnOwner(station, def.Prefab, !free), spent); return; } Waiting.Add(new Pending { Station = station.m_nview.GetZDO().m_uid, Prefab = def.Prefab, Spent = spent, Sent = Time.time }); station.m_nview.InvokeRPC("CDEV_StationUpgrade_Request", new object[2] { def.Prefab, !free }); } private static string Consume(Player player, ExtensionDef def) { StringBuilder stringBuilder = new StringBuilder(); Requirement[] resources = def.Piece.m_resources; foreach (Requirement val in resources) { int num = (((Object)(object)val.m_resItem != (Object)null) ? val.GetAmount(0) : 0); if (num > 0) { if (stringBuilder.Length > 0) { stringBuilder.Append(','); } stringBuilder.Append(Utils.GetPrefabName(((Component)val.m_resItem).gameObject)).Append(':').Append(num); } } player.ConsumeResources(def.Piece.m_resources, 0, -1, 1); return stringBuilder.ToString(); } private static void OnRequest(CraftingStation station, long sender, string prefab, bool paid) { try { bool flag = StationUpgrades.ApplyOnOwner(station, prefab, paid); station.m_nview.InvokeRPC(sender, "CDEV_StationUpgrade_Result", new object[2] { prefab, flag }); } catch (Exception ex) { StationUpgradePlugin.Log.LogError((object)("Upgrade request failed: " + ex)); } } private static void OnResult(CraftingStation station, string prefab, bool ok) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ZDO val = (((Object)(object)station.m_nview != (Object)null) ? station.m_nview.GetZDO() : null); if (val == null) { return; } for (int i = 0; i < Waiting.Count; i++) { Pending pending = Waiting[i]; if (pending.Station == val.m_uid && pending.Prefab == prefab && !pending.Remove) { Waiting.RemoveAt(i); Finish(station, prefab, ok, pending.Spent); break; } } } private static void Finish(CraftingStation station, string prefab, bool ok, string spent) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; ExtensionDef extensionDef = StationCatalog.Find(prefab); if (ok) { StationUpgrades.Refresh(station); Piece val = extensionDef?.Piece; if (val != null) { EffectList placeEffect = val.m_placeEffect; if (placeEffect != null) { placeEffect.Create(((Component)station).transform.position, ((Component)station).transform.rotation, (Transform)null, 1f, -1, ZDOID.None); } } if ((Object)(object)localPlayer != (Object)null && extensionDef != null) { ((Character)localPlayer).Message((MessageType)2, string.Format(Translations.Text("$cdev_su_upgraded"), Translations.Text(station.m_name), Translations.Text(extensionDef.Piece.m_name)), 0, (Sprite)null, false); localPlayer.AddKnownStation(station); } } else if ((Object)(object)localPlayer != (Object)null) { GiveBack(localPlayer, spent); ((Character)localPlayer).Message((MessageType)2, Translations.Text("$cdev_su_failed"), 0, (Sprite)null, false); } } internal static void Tick() { //IL_00bd: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if (Waiting.Count == 0) { return; } float time = Time.time; foreach (Pending item in Waiting) { if (time - item.Sent >= 6f) { Expired.Add(item); } } foreach (Pending pending in Expired) { Waiting.Remove(pending); if (pending.Remove) { StationUpgradePlugin.Log.LogWarning((object)$"No reply to removing {pending.Prefab} from station {pending.Station}; nothing returned."); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Translations.Text("$cdev_su_removefailed"), 0, (Sprite)null, false); } continue; } ZDO val = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(pending.Station) : null); if (val == null) { StationUpgradePlugin.Log.LogWarning((object)$"No reply to an upgrade of a station that no longer exists ({pending.Station}); nothing returned."); continue; } List<StationUpgrades.Entry> list = new List<StationUpgrades.Entry>(); StationUpgrades.Parse(val.GetString(StationUpgrades.BoughtKey, ""), list); bool flag = list.Exists((StationUpgrades.Entry e) => e.Prefab == pending.Prefab); GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(pending.Station) : null); CraftingStation val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<CraftingStation>() : null); if (flag && (Object)(object)val3 != (Object)null) { Finish(val3, pending.Prefab, ok: true, pending.Spent); } else if (!flag && (Object)(object)Player.m_localPlayer != (Object)null) { GiveBack(Player.m_localPlayer, pending.Spent); ((Character)Player.m_localPlayer).Message((MessageType)2, Translations.Text("$cdev_su_failed"), 0, (Sprite)null, false); } } Expired.Clear(); } private static void GiveBack(Player player, string spent) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = ((Humanoid)player).GetInventory(); foreach (KeyValuePair<GameObject, int> item in Parse(spent)) { ItemDrop component = item.Key.GetComponent<ItemDrop>(); int num = ((!((Object)(object)component != (Object)null)) ? 1 : Mathf.Max(1, component.m_itemData.m_shared.m_maxStackSize)); int num2 = item.Value; while (num2 > 0) { int num3 = Mathf.Min(num2, num); if (!inventory.CanAddItem(item.Key, num3) || !inventory.AddItem(item.Key, num3)) { break; } num2 -= num3; } if (num2 > 0) { SpawnDrops(item.Key, num2, ((Component)player).transform.position + Vector3.up); } } } internal static void TryRemove(CraftingStation station, ExtensionDef def, Player player) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)station == (Object)null) && def != null && !((Object)(object)player == (Object)null) && !((Object)(object)station.m_nview == (Object)null) && station.m_nview.GetZDO() != null && StationUpgrades.IsBought(station, def.Prefab) && !IsPending(station, def.Prefab)) { RegisterRpcs(station); if (station.m_nview.IsOwner()) { bool paid; bool ok = StationUpgrades.RemoveOnOwner(station, def.Prefab, out paid); FinishRemove(station, def.Prefab, ok, paid); return; } Waiting.Add(new Pending { Station = station.m_nview.GetZDO().m_uid, Prefab = def.Prefab, Sent = Time.time, Remove = true }); station.m_nview.InvokeRPC("CDEV_StationUpgrade_Remove", new object[1] { def.Prefab }); } } private static void OnRemoveRequest(CraftingStation station, long sender, string prefab) { try { bool paid; bool flag = StationUpgrades.RemoveOnOwner(station, prefab, out paid); station.m_nview.InvokeRPC(sender, "CDEV_StationUpgrade_RemoveResult", new object[3] { prefab, flag, paid }); } catch (Exception ex) { StationUpgradePlugin.Log.LogError((object)("Remove request failed: " + ex)); } } private static void OnRemoveResult(CraftingStation station, string prefab, bool ok, bool paid) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ZDO val = (((Object)(object)station.m_nview != (Object)null) ? station.m_nview.GetZDO() : null); if (val == null) { return; } for (int i = 0; i < Waiting.Count; i++) { Pending pending = Waiting[i]; if (pending.Station == val.m_uid && pending.Prefab == prefab && pending.Remove) { Waiting.RemoveAt(i); FinishRemove(station, prefab, ok, paid); break; } } } private static void FinishRemove(CraftingStation station, string prefab, bool ok, bool paid) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; ExtensionDef extensionDef = StationCatalog.Find(prefab); if (!ok || extensionDef == null) { if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Translations.Text("$cdev_su_removefailed"), 0, (Sprite)null, false); } return; } StationUpgrades.Refresh(station); if (!((Object)(object)localPlayer == (Object)null)) { bool flag = (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey(extensionDef.Piece.FreeBuildKey()); if (paid && !flag) { GiveBack(localPlayer, Recoverable(extensionDef)); } ((Character)localPlayer).Message((MessageType)2, string.Format(Translations.Text("$cdev_su_removed"), Translations.Text(station.m_name), Translations.Text(extensionDef.Piece.m_name)), 0, (Sprite)null, false); } } internal static string Recoverable(ExtensionDef def) { StringBuilder stringBuilder = new StringBuilder(); Requirement[] resources = def.Piece.m_resources; foreach (Requirement val in resources) { int num = (((Object)(object)val.m_resItem != (Object)null && val.m_recover) ? val.GetAmount(0) : 0); if (num > 0) { if (stringBuilder.Length > 0) { stringBuilder.Append(','); } stringBuilder.Append(Utils.GetPrefabName(((Component)val.m_resItem).gameObject)).Append(':').Append(num); } } return stringBuilder.ToString(); } internal static Requirement[] RefundRequirements(Piece piece) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0122: Expected O, but got Unknown CraftingStation val = (((Object)(object)piece != (Object)null) ? ((Component)piece).GetComponent<CraftingStation>() : null); if (!ModConfig.RefundOnDestroy.Value || (Object)(object)val == (Object)null || (Object)(object)piece.m_nview == (Object)null || piece.m_nview.GetZDO() == null) { return null; } ZDO zDO = piece.m_nview.GetZDO(); List<StationUpgrades.Entry> list = StationUpgrades.Bought(val); if (list.Count == 0 || zDO.GetBool(RefundedKey, false)) { return null; } List<Requirement> list2 = new List<Requirement>(piece.m_resources); int count = list2.Count; foreach (StationUpgrades.Entry item in list) { ExtensionDef extensionDef = (item.Paid ? StationCatalog.Find(item.Prefab) : null); if (extensionDef == null) { continue; } Requirement[] resources = extensionDef.Piece.m_resources; foreach (Requirement val2 in resources) { if ((Object)(object)val2.m_resItem != (Object)null && val2.m_recover && val2.GetAmount(0) > 0) { list2.Add(new Requirement { m_resItem = val2.m_resItem, m_amount = val2.GetAmount(0), m_recover = true }); } } } if (list2.Count == count) { return null; } if (piece.m_nview.IsOwner()) { zDO.Set(RefundedKey, true); } return list2.ToArray(); } private static void SpawnDrops(GameObject prefab, int amount, Vector3 at) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) ItemDrop component = prefab.GetComponent<ItemDrop>(); int num = ((!((Object)(object)component != (Object)null)) ? 1 : Mathf.Max(1, component.m_itemData.m_shared.m_maxStackSize)); while (amount > 0) { int num2 = Mathf.Min(amount, num); amount -= num2; GameObject val = Object.Instantiate<GameObject>(prefab, at + Random.insideUnitSphere * 0.3f, Quaternion.identity); ItemDrop component2 = val.GetComponent<ItemDrop>(); if ((Object)(object)component2 != (Object)null) { component2.SetStack(num2); ItemDrop.OnCreateNew(component2, false); } } } private static Dictionary<GameObject, int> Parse(string spent) { Dictionary<GameObject, int> dictionary = new Dictionary<GameObject, int>(); if (string.IsNullOrEmpty(spent) || (Object)(object)ObjectDB.instance == (Object)null) { return dictionary; } string[] array = spent.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { int num = text.LastIndexOf(':'); if (num > 0 && int.TryParse(text.Substring(num + 1), out var result) && result > 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text.Substring(0, num)); if ((Object)(object)itemPrefab == (Object)null) { StationUpgradePlugin.Log.LogWarning((object)("Material '" + text + "' has no item prefab; not returned.")); continue; } dictionary.TryGetValue(itemPrefab, out var value); dictionary[itemPrefab] = value + result; } } return dictionary; } } internal static class BuildInfo { public const string Name = "CDEV.StationUpgrade"; public const string Guid = "cdev.stationupgrade"; public const string Version = "0.1.1"; } } namespace CDEV.StationUpgrade.UI { internal static class LevelStar { private const float ReadyCheckInterval = 0.25f; private const float TwinkleSpeed = 5f; private const float GlowSize = 104f; private const float GlowAlpha = 0.95f; private static readonly Color Bright = new Color(1f, 1f, 0.9f, 1f); private static readonly Color GlowColor = new Color(1f, 0.8f, 0.36f, 1f); private static Image _glow; private static Texture2D _glowTexture; private static Sprite _glowSprite; private static TMP_Text _number; private static Color _numberColor; private static InventoryGui _gui; private static GameObject _hit; private static Image _star; private static Color _starColor; private static UITooltip _tooltip; private static string _tooltipText; private static bool _tinted; private static CraftingStation _checkedFor; private static bool _ready; private static float _nextCheck; internal static bool Hovered; internal static void Tick() { //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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) InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)instance != (Object)null && (Object)(object)localPlayer != (Object)null && InventoryGui.IsVisible()) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)val == (Object)null || (Object)(object)instance.m_craftingStationLevelRoot == (Object)null || StationCatalog.For(val).Count == 0) { Hide(); } else { if (((Object)(object)_gui != (Object)(object)instance || (Object)(object)_hit == (Object)null) && !Build(instance)) { return; } SetActive(_hit, active: true); if ((Object)(object)_tooltip != (Object)null && ((Behaviour)_tooltip).enabled) { ((Behaviour)_tooltip).enabled = false; } if ((Object)(object)val != (Object)(object)_checkedFor || Time.unscaledTime >= _nextCheck) { _checkedFor = val; _nextCheck = Time.unscaledTime + 0.25f; _ready = UpgradeService.HasReady(val, localPlayer); } if (Hovered) { string title = Translations.Text("$cdev_su_levelword") + " " + val.GetLevel(false); string text = (UpgradeWindow.IsOpen ? Translations.Text("$cdev_su_tipback") : ((_ready ? ("<color=#7fd36a>" + Translations.Text("$cdev_su_notice") + "</color>\n") : "") + Translations.Text("$cdev_su_startip"))); StarTip.Show(instance, instance.m_craftingStationLevelRoot, title, text); } else { StarTip.Hide(); } if ((Object)(object)_star == (Object)null) { return; } float num; if (_ready && ModConfig.StarGlow.Value && !UpgradeWindow.IsOpen) { num = 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 5f); } else { if (!UpgradeWindow.IsOpen && !Hovered) { RestoreColor(); return; } num = 0.6f; } ((Graphic)_star).color = Color.Lerp(_starColor, Bright, num); if ((Object)(object)_number != (Object)null) { ((Graphic)_number).color = Color.Lerp(_numberColor, Color.white, num); } if ((Object)(object)_glow != (Object)null) { SetActive(((Component)_glow).gameObject, active: true); Center(instance.m_craftingStationLevelRoot, ((Graphic)_glow).rectTransform); Color glowColor = GlowColor; glowColor.a = 0.95f * num; ((Graphic)_glow).color = glowColor; } _tinted = true; } } private static void RestoreColor() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_tinted && (Object)(object)_star != (Object)null) { ((Graphic)_star).color = _starColor; } if (_tinted && (Object)(object)_number != (Object)null) { ((Graphic)_number).color = _numberColor; } SetActive(((Object)(object)_glow != (Object)null) ? ((Component)_glow).gameObject : null, active: false); _tinted = false; } private static void Hide() { SetActive(_hit, active: false); StarTip.Hide(); RestoreColor(); Hovered = false; _checkedFor = null; } private static bool Build(InventoryGui gui) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) DestroyAll(); RectTransform craftingStationLevelRoot = gui.m_craftingStationLevelRoot; _gui = gui; _star = ((Component)craftingStationLevelRoot).GetComponent<Image>(); if ((Object)(object)_star != (Object)null) { _starColor = ((Graphic)_star).color; } _number = gui.m_craftingStationLevel; if ((Object)(object)_number != (Object)null) { _numberColor = ((Graphic)_number).color; } BuildGlow(craftingStationLevelRoot); _tooltip = ((Component)craftingStationLevelRoot).GetComponent<UITooltip>(); _tooltipText = (((Object)(object)_tooltip != (Object)null) ? _tooltip.m_text : null); _hit = new GameObject("CDEV_StationUpgrade_StarHit", new Type[1] { typeof(RectTransform) }); RectTransform val = (RectTransform)_hit.transform; ((Transform)val).SetParent((Transform)(object)craftingStationLevelRoot, false); ((Transform)val).SetAsLastSibling(); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; _hit.AddComponent<LayoutElement>().ignoreLayout = true; Image val2 = _hit.AddComponent<Image>(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0f); ((Graphic)val2).raycastTarget = true; _hit.AddComponent<StarHit>(); return true; } private static void BuildGlow(RectTransform root) { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Transform)root).parent == (Object)null) { return; } if ((Object)(object)_glowSprite == (Object)null) { _glowTexture = new Texture2D(128, 128, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, name = "CDEV_StationUpgrade_Glow" }; Color32[] array = (Color32[])(object)new Color32[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = ((float)j + 0.5f) / 128f * 2f - 1f; float num2 = ((float)i + 0.5f) / 128f * 2f - 1f; float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2)); float num4 = 1f - Mathf.SmoothStep(0f, 1f, num3); array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(255f * num4 * num4)); } } _glowTexture.SetPixels32(array); _glowTexture.Apply(false, true); _glowSprite = Sprite.Create(_glowTexture, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f); } GameObject val = new GameObject("CDEV_StationUpgrade_StarLight", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Transform)root).parent, false); val.transform.SetSiblingIndex(((Transform)root).GetSiblingIndex()); val.AddComponent<LayoutElement>().ignoreLayout = true; _glow = val.AddComponent<Image>(); _glow.sprite = _glowSprite; ((Graphic)_glow).raycastTarget = false; Center(root, ((Graphic)_glow).rectTransform); val.SetActive(false); } private static void Center(RectTransform root, RectTransform glow) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) glow.anchorMin = root.anchorMin; glow.anchorMax = root.anchorMax; glow.pivot = new Vector2(0.5f, 0.5f); Rect rect = root.rect; Vector2 size = ((Rect)(ref rect)).size; glow.anchoredPosition = root.anchoredPosition + new Vector2((0.5f - root.pivot.x) * size.x, (0.5f - root.pivot.y) * size.y); glow.sizeDelta = new Vector2(104f, 104f); } internal static void DestroyAll() { RestoreColor(); if ((Object)(object)_tooltip != (Object)null) { ((Behaviour)_tooltip).enabled = true; if (_tooltipText != null) { _tooltip.m_text = _tooltipText; } } StarTip.DestroyAll(); if ((Object)(object)_hit != (Object)null) { Object.Destroy((Object)(object)_hit); } if ((Object)(object)_glow != (Object)null) { Object.Destroy((Object)(object)((Component)_glow).gameObject); } if ((Object)(object)_glowSprite != (Object)null) { Object.Destroy((Object)(object)_glowSprite); Object.Destroy((Object)(object)_glowTexture); } _glow = null; _glowSprite = null; _glowTexture = null; _number = null; _hit = null; _star = null; _tooltip = null; _tooltipText = null; _gui = null; _checkedFor = null; Hovered = false; } private static void SetActive(GameObject go, bool active) { if ((Object)(object)go != (Object)null && go.activeSelf != active) { go.SetActive(active); } } } internal sealed class StarHit : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { public void OnPointerEnter(PointerEventData eventData) { LevelStar.Hovered = true; } public void OnPointerExit(PointerEventData eventData) { LevelStar.Hovered = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (UpgradeWindow.IsOpen) { UpgradeWindow.Close(); } else if ((Object)(object)val != (Object)null) { UpgradeWindow.Open(val); } } } private void OnDisable() { LevelStar.Hovered = false; } } internal static class StarTip { private const float PadX = 10f; private const float PadY = 6f; private const float Gap = 8f; private const float MaxTextWidth = 380f; private static readonly Color DefaultGold = new Color(1f, 0.713f, 0.361f, 1f); private static GameObject _root; private static TMP_Text _title; private static TMP_Text _text; private static string _shownTitle; private static string _shownText; internal static void Show(InventoryGui gui, RectTransform anchor, string title, string text) { //IL_008c: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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) if ((Object)(object)_root == (Object)null && !Build(gui)) { return; } if (!_root.activeSelf) { _root.SetActive(true); } _root.transform.SetAsLastSibling(); if (title != _shownTitle || text != _shownText) { _shownTitle = title; _shownText = text; _title.text = title; _text.text = text; _text.textWrappingMode = (TextWrappingModes)0; Vector2 preferredValues = _text.GetPreferredValues(text); if (preferredValues.x > 380f) { _text.textWrappingMode = (TextWrappingModes)1; preferredValues = _text.GetPreferredValues(text, 380f, 0f); preferredValues.x = 380f; } ((RectTransform)_text.transform).sizeDelta = new Vector2(-20f, preferredValues.y + 4f); float num = Mathf.Max(_title.preferredWidth, preferredValues.x) + 20f; float num2 = _title.preferredHeight + preferredValues.y + 12f; ((RectTransform)_root.transform).sizeDelta = new Vector2(Mathf.Ceil(num), Mathf.Ceil(num2)); } RectTransform val = (RectTransform)_root.transform; Rect rect = anchor.rect; val.pivot = new Vector2(1f, 0f); _root.transform.position = ((Transform)anchor).TransformPoint(new Vector3(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax + 8f, 0f)); } internal static void Hide() { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } } internal static void DestroyAll() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _shownTitle = null; _shownText = null; } private static bool Build(InventoryGui gui) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_018d: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_028a: 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_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_crafting == (Object)null || (Object)(object)((Transform)gui.m_crafting).parent == (Object)null) { return false; } Transform val = ((Transform)gui.m_crafting).parent.Find("CDEV_StationUpgrade_Tip"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } _root = new GameObject("CDEV_StationUpgrade_Tip", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)_root.transform; ((Transform)val2).SetParent(((Transform)gui.m_crafting).parent, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(1f, 0f); GameObject val4 = ((gui.m_recipeRequirementList != null && gui.m_recipeRequirementList.Length != 0) ? gui.m_recipeRequirementList[0] : null); Image val5 = (((Object)(object)val4 != (Object)null) ? val4.GetComponent<Image>() : null); Image val6 = _root.AddComponent<Image>(); val6.sprite = (((Object)(object)val5 != (Object)null) ? val5.sprite : null); val6.type = (Type)1; ((Graphic)val6).color = new Color(0.85f, 0.62f, 0.3f, 0.55f); ((Graphic)val6).raycastTarget = false; GameObject val7 = new GameObject("Fill", new Type[1] { typeof(RectTransform) }); RectTransform val8 = (RectTransform)val7.transform; ((Transform)val8).SetParent((Transform)(object)val2, false); val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.offsetMin = new Vector2(1f, 1f); val8.offsetMax = new Vector2(-1f, -1f); Image val9 = val7.AddComponent<Image>(); val9.sprite = val6.sprite; val9.type = (Type)1; ((Graphic)val9).color = new Color(0.07f, 0.055f, 0.04f, 0.94f); ((Graphic)val9).raycastTarget = false; object obj; if (!((Object)(object)val4 != (Object)null)) { obj = null; } else { Transform obj2 = val4.transform.Find("res_name"); obj = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); } TMP_Text val10 = (TMP_Text)obj; _title = Text("Title", val2, gui.m_containerName, 17f, 6f); ((Graphic)_title).color = (((Object)(object)gui.m_minStationLevelIcon != (Object)null && ((Graphic)gui.m_minStationLevelIcon).color.a > 0f) ? ((Graphic)gui.m_minStationLevelIcon).color : DefaultGold); _text = Text("Text", val2, ((Object)(object)val10 != (Object)null) ? val10 : gui.m_containerName, 15f, 26f); ((Graphic)_text).color = new Color(0.9f, 0.88f, 0.84f); _root.SetActive(false); return true; } private static TMP_Text Text(string name, RectTransform parent, TMP_Text style, float size, float top) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0039: 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_0063: 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_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)parent, false); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.sizeDelta = new Vector2(0f, size + 4f); val2.anchoredPosition = new Vector2(0f, 0f - top); TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)style != (Object)null) { ((TMP_Text)val3).font = style.font; ((TMP_Text)val3).fontSharedMaterial = style.fontSharedMaterial; } ((TMP_Text)val3).fontSize = size; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).alignment = (TextAlignmentOptions)514; ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; ((Graphic)val3).raycastTarget = false; return (TMP_Text)(object)val3; } } internal static class UpgradeWindow { private sealed class Row { internal GameObject Root; internal Image Icon; internal TMP_Text Name; internal TMP_Text Status; internal Button Buy; internal Button Remove; internal readonly List<Transform> Reqs = new List<Transform>(); internal ExtensionDef Def; } private sealed class Hidden { internal CanvasGroup Group; internal bool Added; internal float Alpha; internal bool Blocks; internal bool Interactable; } [CompilerGenerated] private static class <>O { public static UnityAction <0>__Close; } private const float HeaderHeight = 66f; private const float Side = 10f; private const float TopBarHeight = 34f; private const float RowHeight = 96f; private const float RowGap = 6f; private const float IconSize = 60f; private const float ReqHeight = 56f; private const float ReqGap = 4f; private const float ButtonWidth = 150f; private const float ButtonHeight = 40f; private const float BackWidth = 110f; private const float BarWidth = 10f; private const float BarGap = 4f; private const float EvaluateInterval = 0.2f; private static readonly Color Done = new Color(0.55f, 0.85f, 0.45f); private static readonly Color Short = new Color(1f, 0.32f, 0.27f); private static readonly Color Note = new Color(0.8f, 0.68f, 0.5f); private const string ValueColor = "#ffcb6b"; private static readonly HashSet<string> Keep = new HashSet<string> { "Darken", "selected_frame", "Bkg", "topic", "TitlePanel", "station_icon" }; private static InventoryGui _gui; private static GameObject _page; private static TMP_Text _caption; private static Button _back; private static TMP_Text _empty; private static RectTransform _content; private static ScrollRect _scroll; private static TMP_Text _bodyFont; private static TMP_Text _titleFont; private static Image _rowStyle; private static GameObject _reqTemplate; private static Vector2 _reqSize; private static readonly List<Row> Rows = new List<Row>(); private static readonly List<UpgradeRow> States = new List<UpgradeRow>(); private static readonly List<UpgradeRow> StatePool = new List<UpgradeRow>(); private static readonly List<Hidden> HiddenParts = new List<Hidden>(); private static CraftingStation _station; private static float _nextEvaluate; internal static bool IsOpen { get { if ((Object)(object)_page != (Object)null) { return _page.activeSelf; } return false; } } internal static void Open(CraftingStation station) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)station == (Object)null) && ((!((Object)(object)_gui != (Object)(object)instance) && !((Object)(object)_page == (Object)null)) || Build(instance))) { _station = station; HideVanilla(); _page.SetActive(true); _page.transform.SetAsLastSibling(); _nextEvaluate = 0f; Refresh(Player.m_localPlayer); _scroll.StopMovement(); _content.anchoredPosition = Vector2.zero; } } internal static void Close() { SetActive(_page, active: false); RestoreVanilla(); _station = null; } internal static void Tick() { if (!IsOpen) { return; } InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)instance != (Object)(object)_gui || (Object)(object)localPlayer == (Object)null || !InventoryGui.IsVisible() || (Object)(object)_station == (Object)null || (Object)(object)localPlayer.GetCurrentCraftingStation() != (Object)(object)_station || !((Component)instance.m_crafting).gameObject.activeInHierarchy) { Close(); return; } if (Time.unscaledTime >= _nextEvaluate) { HideVanilla(); Refresh(localPlayer); } for (int i = 0; i < States.Count && i < Rows.Count; i++) { FillRequirements(Rows[i], States[i], localPlayer); } } private static void HideVanilla() { RectTransform crafting = _gui.m_crafting; for (int i = 0; i < ((Transform)crafting).childCount; i++) { Transform child = ((Transform)crafting).GetChild(i); if (!Keep.Contains(((Object)child).name) && !((Object)(object)child == (Object)(object)_gui.m_craftingStationLevelRoot) && !((Object)child).name.StartsWith("CDEV_StationUpgrade") && !IsHidden(child)) { CanvasGroup val = ((Component)child).GetComponent<CanvasGroup>(); Hidden hidden = new Hidden { Group = val, Added = ((Object)(object)val == (Object)null) }; if ((Object)(object)val == (Object)null) { val = (hidden.Group = ((Component)child).gameObject.AddComponent<CanvasGroup>()); } else { hidden.Alpha = val.alpha; hidden.Blocks = val.blocksRaycasts; hidden.Interactable = val.interactable; } val.alpha = 0f; val.blocksRaycasts = false; val.interactable = false; HiddenParts.Add(hidden); } } } private static bool IsHidden(Transform child) { foreach (Hidden hiddenPart in HiddenParts) { if ((Object)(object)hiddenPart.Group != (Object)null && (Object)(object)((Component)hiddenPart.Group).transform == (Object)(object)child) { return true; } } return false; } private static void RestoreVanilla() { foreach (Hidden hiddenPart in HiddenParts) { if (!((Object)(object)hiddenPart.Group == (Object)null)) { if (hiddenPart.Added) { Object.Destroy((Object)(object)hiddenPart.Group); continue; } hiddenPart.Group.alpha = hiddenPart.Alpha; hiddenPart.Group.blocksRaycasts = hiddenPart.Blocks; hiddenPart.Group.interactable = hiddenPart.Interactable; } } HiddenParts.Clear(); } private static void Refresh(Player player) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)_station == (Object)null)) { _nextEvaluate = Time.unscaledTime + 0.2f; UpgradeService.Evaluate(_station, player, States, StatePool); if ((Object)(object)_back != (Object)null) { SetLabel(_back, Translations.Text("$cdev_su_back")); } _caption.text = Translations.Text("$cdev_su_title") + " " + Translations.Text("$cdev_su_levelword") + " <color=#ffcb6b>" + _station.GetLevel(false) + "</color>"; for (int i = 0; i < States.Count; i++) { FillRow(RowAt(i), States[i], player); } for (int j = 0; j < Rows.Count; j++) { SetActive(Rows[j].Root, j < States.Count); } _empty.text = Translations.Text("$cdev_su_none"); SetActive(((Component)_empty).gameObject, States.Count == 0); float num = ((States.Count == 0) ? 0f : ((float)States.Count * 96f + (float)(States.Count - 1) * 6f)); _content.sizeDelta = new Vector2(0f, num); for (int k = 0; k < States.Count; k++) { ((RectTransform)Rows[k].Root.transform).anchoredPosition = new Vector2(0f, (float)(-k) * 102f); } }