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 RepoMarketHub v0.1.7
BepInEx/plugins/RepoMarketHub/RepoMarketHub.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using Platforms; using RepoMarketHub.Crypto; using RepoMarketHub.Data; using RepoMarketHub.Drones; using RepoMarketHub.Localization; using RepoMarketHub.Networking; using RepoMarketHub.Patches; using RepoMarketHub.Services; using RepoMarketHub.Testing; using RepoMarketHub.UI; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Localization; using UnityEngine.Localization.Settings; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyMetadata("BuildStamp", "02.12 13:48")] [assembly: AssemblyCompany("RepoMarketHub")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.5.0")] [assembly: AssemblyInformationalVersion("0.1.5")] [assembly: AssemblyProduct("RepoMarketHub")] [assembly: AssemblyTitle("RepoMarketHub")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 RepoMarketHub { [BepInPlugin("com.pavel.repomarkethub", "RepoMarketHub", "0.1.5")] public sealed class Plugin : BaseUnityPlugin { public const string ModGuid = "com.pavel.repomarkethub"; public const string ModName = "RepoMarketHub"; public const string ModVersion = "0.1.5"; private Harmony? _harmony; private GameObject? _runtimeHost; public static string BuildStamp { get; } = typeof(Plugin).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault((AssemblyMetadataAttribute a) => a.Key == "BuildStamp")?.Value ?? "dev"; public static string BuildTag => "v0.1.5 [build " + BuildStamp + "]"; public static Plugin Instance { get; private set; } = null; public static ManualLogSource Log { get; private set; } = null; public ConfigEntry<int> BlackMarketUnlockCostK { get; private set; } public ConfigEntry<float> RareBoxUnlockChance { get; private set; } public ConfigEntry<float> HackBlackMarketKeyChance { get; private set; } public ConfigEntry<float> MinimumMarketMultiplier { get; private set; } public ConfigEntry<float> HubMicroTickIntervalSeconds { get; private set; } public ConfigEntry<float> HubMicroDriftRange { get; private set; } private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); InitRuntimeHost(); _harmony = new Harmony("com.pavel.repomarkethub"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)string.Format("{0} {1} initialized (Locale: {2}).", "RepoMarketHub", BuildTag, ModLocalization.CurrentLanguage)); } private void BindConfig() { BlackMarketUnlockCostK = ((BaseUnityPlugin)this).Config.Bind<int>("BlackMarket", "UnlockCostK", 200, "Cost in thousands ($K) to manually unlock the Black Market buyback tab for the current run."); RareBoxUnlockChance = ((BaseUnityPlugin)this).Config.Bind<float>("BlackMarket", "RareBoxUnlockChance", 0.2f, "Chance (0..1) that extracting a Rare (purple) cosmetic box unlocks the Black Market tab."); HackBlackMarketKeyChance = ((BaseUnityPlugin)this).Config.Bind<float>("BlackMarket", "HackBlackMarketKeyChance", 0.03f, "Chance (0..1) that hacking/inspecting an item yields a Black Market access key."); MinimumMarketMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Market", "MinimumMultiplier", 0.5f, "Lowest possible demand multiplier so saturated items never drop below this floor."); HubMicroTickIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Market", "HubMicroTickIntervalSeconds", 7f, "Interval in seconds between subtle live ticker updates and minor price drift inside the shop hub."); HubMicroDriftRange = ((BaseUnityPlugin)this).Config.Bind<float>("Market", "HubMicroDriftRange", 0.04f, "Maximum ± percentage drift applied while browsing the hub without leaving."); } private void InitRuntimeHost() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _runtimeHost = new GameObject("RepoMarketHub_Runtime"); Object.DontDestroyOnLoad((Object)(object)_runtimeHost); ((Object)_runtimeHost).hideFlags = (HideFlags)61; _runtimeHost.AddComponent<ModLocalization>(); _runtimeHost.AddComponent<MarketSync>(); _runtimeHost.AddComponent<MarketManager>(); if (SelfTestRunner.IsEnabled) { _runtimeHost.AddComponent<SelfTestRunner>(); } } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace RepoMarketHub.UI { public static class EmbeddedModelLoader { private const string ResourcePrefix = "RepoMarketHub.Assets."; private static Mesh? _cachedTerminalMesh; private static Material? _cachedTerminalMaterial; private static Mesh? _cachedCryptoCaseMesh; private static Material? _cachedCryptoCaseMaterial; public static bool TryGetTerminalVisuals(out Mesh? mesh, out Material? material) { return TryGetModelVisuals("terminal", "RepoMarketTerminal", 0.85f, 1.4f, ref _cachedTerminalMesh, ref _cachedTerminalMaterial, out mesh, out material); } public static bool TryGetCryptoCaseVisuals(out Mesh? mesh, out Material? material) { return TryGetModelVisuals("crypto_case", "RepoCryptoCase", 1f, 1.8f, ref _cachedCryptoCaseMesh, ref _cachedCryptoCaseMaterial, out mesh, out material); } private static bool TryGetModelVisuals(string assetPrefix, string objectLabel, float bumpScale, float emissionIntensity, ref Mesh? cachedMesh, ref Material? cachedMaterial, out Mesh? mesh, out Material? material) { if ((Object)(object)cachedMesh != (Object)null && (Object)(object)cachedMaterial != (Object)null) { mesh = cachedMesh; material = cachedMaterial; return true; } try { string text = ReadEmbeddedText(assetPrefix + "_mesh.obj"); if (string.IsNullOrEmpty(text)) { mesh = null; material = null; return false; } cachedMesh = ParseObjToUnityMesh(text, objectLabel + "_Mesh"); cachedMaterial = BuildPbrMaterial(assetPrefix, objectLabel + "_Mat", bumpScale, emissionIntensity); if ((Object)(object)cachedMesh != (Object)null) { Object.DontDestroyOnLoad((Object)(object)cachedMesh); } if ((Object)(object)cachedMaterial != (Object)null) { Object.DontDestroyOnLoad((Object)(object)cachedMaterial); } mesh = cachedMesh; material = cachedMaterial; return (Object)(object)mesh != (Object)null && (Object)(object)material != (Object)null; } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to load embedded Blender model '{objectLabel}': {arg}"); mesh = null; material = null; return false; } } private static Material BuildPbrMaterial(string assetPrefix, string matName, float bumpScale, float emissionIntensity) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0099: 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_012f: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Sprites/Default"); Material val2 = new Material(val) { name = matName }; Texture2D val3 = LoadEmbeddedTexture(assetPrefix + "_albedo.png", linear: false, isNormalMap: false); Texture2D val4 = LoadEmbeddedTexture(assetPrefix + "_metallic_gloss.png", linear: true, isNormalMap: false); Texture2D val5 = LoadEmbeddedTexture(assetPrefix + "_normal.png", linear: true, isNormalMap: true); Texture2D val6 = LoadEmbeddedTexture(assetPrefix + "_emission.png", linear: false, isNormalMap: false); if ((Object)(object)val3 != (Object)null) { val2.SetTexture("_MainTex", (Texture)(object)val3); val2.color = Color.white; } if ((Object)(object)val4 != (Object)null) { val2.SetTexture("_MetallicGlossMap", (Texture)(object)val4); val2.EnableKeyword("_METALLICGLOSSMAP"); val2.SetFloat("_GlossMapScale", 1f); } if ((Object)(object)val5 != (Object)null) { val2.SetTexture("_BumpMap", (Texture)(object)val5); val2.EnableKeyword("_NORMALMAP"); val2.SetFloat("_BumpScale", bumpScale); } if ((Object)(object)val6 != (Object)null) { val2.SetTexture("_EmissionMap", (Texture)(object)val6); val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", Color.white * emissionIntensity); } return val2; } private static Texture2D? LoadEmbeddedTexture(string fileName, bool linear, bool isNormalMap) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) byte[] array = ReadEmbeddedBytes(fileName); if (array == null || array.Length == 0) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear); if (!ImageConversion.LoadImage(val, array, !isNormalMap)) { Object.Destroy((Object)(object)val); return null; } if (isNormalMap) { Color32[] pixels = val.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { Color32 val2 = pixels[i]; pixels[i] = new Color32(byte.MaxValue, val2.g, byte.MaxValue, val2.r); } val.SetPixels32(pixels); val.Apply(true, true); } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Object.DontDestroyOnLoad((Object)(object)val); return val; } private static string? ReadEmbeddedText(string fileName) { byte[] array = ReadEmbeddedBytes(fileName); if (array == null) { return null; } return Encoding.UTF8.GetString(array); } private static byte[]? ReadEmbeddedBytes(string fileName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = "RepoMarketHub.Assets." + fileName; using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream == null) { Plugin.Log.LogWarning((object)("Embedded resource not found: " + text)); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } private static Mesh ParseObjToUnityMesh(string objText, string meshName) { //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(8192); List<Vector2> list2 = new List<Vector2>(8192); List<Vector3> list3 = new List<Vector3>(8192); List<Vector3> list4 = new List<Vector3>(8192); List<Vector2> list5 = new List<Vector2>(8192); List<Vector3> list6 = new List<Vector3>(8192); List<int> list7 = new List<int>(16384); Dictionary<(int, int, int), int> cache = new Dictionary<(int, int, int), int>(8192); using StringReader stringReader = new StringReader(objText); string text; while ((text = stringReader.ReadLine()) != null) { if (text.Length < 3) { continue; } if (text.StartsWith("v ", StringComparison.Ordinal)) { string[] array = SplitSpaces(text); if (array.Length >= 4) { float num = 0f - ParseFloat(array[1]); float num2 = ParseFloat(array[2]); float num3 = ParseFloat(array[3]); list.Add(new Vector3(num, num2, num3)); } } else if (text.StartsWith("vt ", StringComparison.Ordinal)) { string[] array2 = SplitSpaces(text); if (array2.Length >= 3) { list2.Add(new Vector2(ParseFloat(array2[1]), ParseFloat(array2[2]))); } } else if (text.StartsWith("vn ", StringComparison.Ordinal)) { string[] array3 = SplitSpaces(text); if (array3.Length >= 4) { float num4 = 0f - ParseFloat(array3[1]); float num5 = ParseFloat(array3[2]); float num6 = ParseFloat(array3[3]); list3.Add(new Vector3(num4, num5, num6)); } } else { if (!text.StartsWith("f ", StringComparison.Ordinal)) { continue; } string[] array4 = SplitSpaces(text); if (array4.Length >= 4) { int item = ResolveVertex(array4[1], list, list2, list3, list4, list5, list6, cache); for (int i = 2; i < array4.Length - 1; i++) { int item2 = ResolveVertex(array4[i], list, list2, list3, list4, list5, list6, cache); int item3 = ResolveVertex(array4[i + 1], list, list2, list3, list4, list5, list6, cache); list7.Add(item); list7.Add(item3); list7.Add(item2); } } } } Mesh val = new Mesh { name = meshName }; if (list4.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(list4); if (list5.Count == list4.Count) { val.SetUVs(0, list5); } if (list6.Count == list4.Count) { val.SetNormals(list6); } else { val.RecalculateNormals(); } val.SetTriangles(list7, 0); val.RecalculateTangents(); val.RecalculateBounds(); return val; } private static int ResolveVertex(string token, List<Vector3> rawV, List<Vector2> rawVt, List<Vector3> rawVn, List<Vector3> outV, List<Vector2> outVt, List<Vector3> outVn, Dictionary<(int, int, int), int> cache) { //IL_0091: 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_00b3: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) string[] array = token.Split('/'); int num = ParseObjIndex(array[0], rawV.Count); int num2 = ((array.Length > 1 && array[1].Length > 0) ? ParseObjIndex(array[1], rawVt.Count) : (-1)); int num3 = ((array.Length > 2 && array[2].Length > 0) ? ParseObjIndex(array[2], rawVn.Count) : (-1)); (int, int, int) key = (num, num2, num3); if (cache.TryGetValue(key, out var value)) { return value; } int count = outV.Count; outV.Add((num >= 0 && num < rawV.Count) ? rawV[num] : Vector3.zero); outVt.Add((num2 >= 0 && num2 < rawVt.Count) ? rawVt[num2] : Vector2.zero); outVn.Add((num3 >= 0 && num3 < rawVn.Count) ? rawVn[num3] : Vector3.up); cache[key] = count; return count; } private static int ParseObjIndex(string s, int count) { int num = int.Parse(s, CultureInfo.InvariantCulture); if (num <= 0) { return count + num; } return num - 1; } private static float ParseFloat(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } private static string[] SplitSpaces(string line) { return line.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); } } public static class HubFontHelper { private const string CyrillicSample = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя"; private static readonly string[] PreferredOsFontFamilies = new string[7] { "Segoe UI", "Arial", "Tahoma", "Calibri", "DejaVu Sans", "Liberation Sans", "Noto Sans" }; private static TMP_FontAsset? _nativeGameFont; private static TMP_FontAsset? _cyrillicFont; private static bool _attemptedOsFontLoad; public static TMP_FontAsset? GetFontForCurrentLanguage() { if ((Object)(object)_nativeGameFont == (Object)null) { _nativeGameFont = FindNativeGameFont(); } if ((Object)(object)_nativeGameFont != (Object)null) { AttachFallbackFont(_nativeGameFont); } if (ModLocalization.CurrentLanguage == ModLanguage.English) { return _nativeGameFont ?? GetOrCreateDynamicFallbackFont(); } if ((Object)(object)_nativeGameFont != (Object)null && SupportsCyrillic(_nativeGameFont)) { return _nativeGameFont; } return GetOrCreateDynamicFallbackFont() ?? _nativeGameFont; } public static void AttachFallbackFont(TMP_FontAsset? target) { if ((Object)(object)target == (Object)null) { return; } if (target.fallbackFontAssetTable == null) { List<TMP_FontAsset> list = (target.fallbackFontAssetTable = new List<TMP_FontAsset>()); } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); foreach (TMP_FontAsset val in array) { if (!((Object)(object)val == (Object)null) && val != target && !((Object)val).name.StartsWith("RepoMarketHub_", StringComparison.Ordinal) && (((Object)val).name.IndexOf("Cyrillic", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val).name.IndexOf("Noto", StringComparison.OrdinalIgnoreCase) >= 0) && !target.fallbackFontAssetTable.Contains(val)) { target.fallbackFontAssetTable.Add(val); } } TMP_FontAsset orCreateDynamicFallbackFont = GetOrCreateDynamicFallbackFont(); if ((Object)(object)orCreateDynamicFallbackFont != (Object)null && target != orCreateDynamicFallbackFont && !target.fallbackFontAssetTable.Contains(orCreateDynamicFallbackFont)) { target.fallbackFontAssetTable.Add(orCreateDynamicFallbackFont); } } private static TMP_FontAsset? GetOrCreateDynamicFallbackFont() { EnsureCyrillicFontLoaded(); return _cyrillicFont; } private static void EnsureCyrillicFontLoaded() { if ((Object)(object)_cyrillicFont != (Object)null || _attemptedOsFontLoad) { return; } _attemptedOsFontLoad = true; try { HashSet<string> hashSet = new HashSet<string>(Font.GetOSInstalledFontNames() ?? Array.Empty<string>(), StringComparer.OrdinalIgnoreCase); string[] preferredOsFontFamilies = PreferredOsFontFamilies; foreach (string text in preferredOsFontFamilies) { if (hashSet.Count <= 0 || hashSet.Contains(text)) { TMP_FontAsset val = TMP_FontAsset.CreateFontAsset(text, "Regular", 34); if ((Object)(object)val != (Object)null) { ((Object)val).name = "RepoMarketHub_" + text.Replace(" ", string.Empty) + "_OS"; Object.DontDestroyOnLoad((Object)(object)val); _cyrillicFont = val; break; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failed to build dynamic OS TMP font: " + ex.Message)); } } private static TMP_FontAsset? FindNativeGameFont() { if ((Object)(object)ShopCostUI.instance != (Object)null) { TextMeshProUGUI component = ((Component)ShopCostUI.instance).GetComponent<TextMeshProUGUI>(); if ((Object)(object)((component != null) ? ((TMP_Text)component).font : null) != (Object)null) { return ((TMP_Text)component).font; } } if ((Object)(object)CurrencyUI.instance != (Object)null) { TextMeshProUGUI componentInChildren = ((Component)CurrencyUI.instance).GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)((componentInChildren != null) ? ((TMP_Text)componentInChildren).font : null) != (Object)null) { return ((TMP_Text)componentInChildren).font; } } MapShopScreen val = Object.FindFirstObjectByType<MapShopScreen>(); object obj; if (val == null) { obj = null; } else { TextMeshPro text = val.text; obj = ((text != null) ? ((TMP_Text)text).font : null); } if ((Object)obj != (Object)null) { return ((TMP_Text)val.text).font; } TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); TMP_FontAsset val2 = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null && !((Object)f).name.StartsWith("RepoMarketHub_", StringComparison.Ordinal) && ((Object)f).name.IndexOf("Teko", StringComparison.OrdinalIgnoreCase) >= 0)); if ((Object)(object)val2 != (Object)null) { return val2; } TMP_FontAsset val3 = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null && !((Object)f).name.StartsWith("RepoMarketHub_", StringComparison.Ordinal) && (int)f.atlasPopulationMode == 1 && ((Object)f).name.IndexOf("Fallback", StringComparison.OrdinalIgnoreCase) < 0)); if ((Object)(object)val3 != (Object)null) { return val3; } return ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null && !((Object)f).name.StartsWith("RepoMarketHub_", StringComparison.Ordinal))); } internal static bool SupportsCyrillic(TMP_FontAsset font) { try { uint[] array = default(uint[]); return font.HasCharacters("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя", ref array, true, true); } catch { return false; } } } public sealed class HubScreenButton : MonoBehaviour { private Image? _background; private BoxCollider? _collider; private Color _normalColor; private Color _hoverColor; private Color _disabledColor; private Action? _onClick; private Action<bool>? _onHover; private bool _interactable = true; private bool _hovered; private bool _remoteHovered; private float _flashTimer; public int SyncId { get; set; } = -1; public bool IsScrollableCardButton { get; private set; } public bool AllowHoverWhenDisabled { get; set; } public bool IsInteractable => _interactable; internal bool IsRemoteHovered => _remoteHovered; public void Initialize(Image background, BoxCollider collider, Color normalColor, Color hoverColor, Color disabledColor, bool isScrollableCardButton = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) _background = background; _collider = collider; _normalColor = normalColor; _hoverColor = hoverColor; _disabledColor = disabledColor; IsScrollableCardButton = isScrollableCardButton; ApplyVisual(); } public void Configure(Action? onClick, bool interactable = true, Color? overrideNormal = null, Color? overrideDisabled = null, Action<bool>? onHover = null) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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) _onClick = onClick; _interactable = interactable; _onHover = onHover; if (overrideNormal.HasValue) { _normalColor = overrideNormal.Value; _hoverColor = Color.Lerp(_normalColor, Color.white, 0.28f); } if (overrideDisabled.HasValue) { _disabledColor = overrideDisabled.Value; } if ((Object)(object)_collider != (Object)null) { ((Collider)_collider).enabled = (interactable || AllowHoverWhenDisabled) && ((Component)this).gameObject.activeInHierarchy; } ApplyVisual(); } public void SetInteractable(bool interactable) { if (_interactable != interactable) { _interactable = interactable; if ((Object)(object)_collider != (Object)null) { ((Collider)_collider).enabled = (interactable || AllowHoverWhenDisabled) && ((Component)this).gameObject.activeInHierarchy; } ApplyVisual(); } } public void SetHovered(bool hovered) { if (_hovered != hovered) { _hovered = hovered; ApplyVisual(); _onHover?.Invoke(hovered); } } public void SetRemoteHovered(bool remoteHovered) { if (_remoteHovered != remoteHovered) { _remoteHovered = remoteHovered; ApplyVisual(); } } public void TriggerClick() { if (_interactable && _onClick != null) { _flashTimer = 0.12f; ApplyVisual(); _onClick(); } } private void Update() { if (_flashTimer > 0f) { _flashTimer -= Time.deltaTime; if (_flashTimer <= 0f) { ApplyVisual(); } } } private void ApplyVisual() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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 (!((Object)(object)_background == (Object)null)) { if (!_interactable) { ((Graphic)_background).color = (((_hovered || _remoteHovered) && AllowHoverWhenDisabled) ? Color.Lerp(_disabledColor, Color.white, 0.16f) : _disabledColor); } else if (_flashTimer > 0f) { ((Graphic)_background).color = Color.white; } else if (_hovered) { ((Graphic)_background).color = _hoverColor; } else if (_remoteHovered) { ((Graphic)_background).color = Color.Lerp(_normalColor, new Color(1f, 0.8f, 0.28f, 1f), 0.36f); } else { ((Graphic)_background).color = _normalColor; } } } } public enum TerminalTab { Warehouse, LiveMarket, BlackMarket, Expeditions } internal enum ExpeditionInspectKind { None, NextRunNode, EscalationStep } internal sealed class ExpeditionNodeRefs { public HubScreenButton Button; public Image AccentBar; public TextMeshProUGUI TitleText; public TextMeshProUGUI TierText; public TextMeshProUGUI SummaryText; public TextMeshProUGUI CostText; } internal sealed class EscalationStepRefs { public int Step; public HubScreenButton Button; public Image AccentBar; public TextMeshProUGUI TitleText; public TextMeshProUGUI BonusText; public TextMeshProUGUI CostText; } internal sealed class WarehouseCardRefs { public RectTransform Root; public Image AccentBar; public Image IconImage; public RectTransform ConditionFill; public Image ConditionFillImage; public TextMeshProUGUI TitleText; public TextMeshProUGUI MetaText; public TextMeshProUGUI PriceText; public HubScreenButton SellButton; public TextMeshProUGUI SellLabel; public HubScreenButton HackButton; public TextMeshProUGUI HackLabel; public string BoundPrefabKey = string.Empty; } internal sealed class CategoryCardRefs { public ItemCategory Category; public Image Background; public TextMeshProUGUI NameText; public TextMeshProUGUI MultiplierText; public TextMeshProUGUI StatusText; } internal sealed class BoardTileRefs { public ItemCategory Category; public Image Background; public TextMeshProUGUI NameText; public TextMeshProUGUI PercentText; public TextMeshProUGUI MultText; } internal sealed class BlackMarketCardRefs { public RectTransform Root; public Image IconImage; public TextMeshProUGUI TitleText; public TextMeshProUGUI OwnedText; public TextMeshProUGUI PriceText; public HubScreenButton BuyButton; public TextMeshProUGUI BuyLabel; public Item? BoundItem; } internal sealed class RemotePointerRefs { public RectTransform Root; public Image DotImage; public RectTransform NameTagRoot; public TextMeshProUGUI NameText; public int BoundActorNumber; public float DisplayX; public float DisplayY; public bool HasDisplayPos; public string LastMeasuredName = string.Empty; public TMP_FontAsset? LastMeasuredFont; } public sealed class HubTerminalController : MonoBehaviour { private const float MaxInteractDistance = 4.6f; private const float DragThresholdPx = 14f; private const float WarehouseViewportHeightPx = 410f; private const float BlackMarketViewportHeightPx = 450f; private const float HackAllArmDurationSeconds = 4.5f; internal Collider ScreenPlaneCollider; internal RectTransform ScreenCanvasRect; internal RectTransform AimDot; internal Image AimDotImage; internal readonly List<TextMeshProUGUI> AllTextElements = new List<TextMeshProUGUI>(); internal TextMeshProUGUI HeaderTitleText; internal TextMeshProUGUI HeaderCashText; internal TextMeshProUGUI HeaderStockText; internal TextMeshProUGUI FooterTickerText; internal TextMeshProUGUI FooterHintText; internal HubScreenButton TabWarehouseBtn; internal TextMeshProUGUI TabWarehouseLabel; internal HubScreenButton TabMarketBtn; internal TextMeshProUGUI TabMarketLabel; internal HubScreenButton TabBlackMarketBtn; internal TextMeshProUGUI TabBlackMarketLabel; internal GameObject WarehousePanel; internal HubScreenButton SellAllBtn; internal TextMeshProUGUI SellAllLabel; internal HubScreenButton SellProfitBtn; internal TextMeshProUGUI SellProfitLabel; internal HubScreenButton SortDefaultBtn; internal TextMeshProUGUI SortDefaultLabel; internal HubScreenButton SortCoeffBtn; internal TextMeshProUGUI SortCoeffLabel; internal HubScreenButton SortPriceBtn; internal TextMeshProUGUI SortPriceLabel; internal HubScreenButton SortHackBtn; internal TextMeshProUGUI SortHackLabel; internal HubScreenButton HackAllBtn; internal TextMeshProUGUI HackAllLabel; internal TextMeshProUGUI WarehouseScrollInfoText; internal HubScreenButton WarehouseScrollUpBtn; internal TextMeshProUGUI WarehouseScrollUpLabel; internal HubScreenButton WarehouseScrollDownBtn; internal TextMeshProUGUI WarehouseScrollDownLabel; internal RectTransform WarehouseViewport; internal RectTransform WarehouseContent; internal RectTransform WarehouseScrollTrack; internal RectTransform WarehouseScrollThumb; internal TextMeshProUGUI WarehouseEmptyText; internal readonly List<WarehouseCardRefs> WarehouseCards = new List<WarehouseCardRefs>(); internal GameObject HackOverlay; internal TextMeshProUGUI HackOverlayTitle; internal TextMeshProUGUI HackOverlayItemText; internal RectTransform HackProgressFill; internal Collider OverlayShieldCollider; internal GameObject HackResultOverlay; internal Image HackResultAccentBar; internal TextMeshProUGUI HackResultTitleText; internal TextMeshProUGUI HackResultItemPriceText; internal TextMeshProUGUI HackResultStoryText; internal HubScreenButton HackResultOkBtn; internal TextMeshProUGUI HackResultOkLabel; internal GameObject MarketPanel; internal TextMeshProUGUI MarketCategoriesHeader; internal TextMeshProUGUI MarketFeedHeader; internal TextMeshProUGUI MarketFeedText; internal readonly List<CategoryCardRefs> CategoryCards = new List<CategoryCardRefs>(); internal GameObject BlackMarketPanel; internal GameObject BlackMarketLockedRoot; internal TextMeshProUGUI BlackMarketLockedTitle; internal TextMeshProUGUI BlackMarketLockedHint; internal HubScreenButton BlackMarketUnlockBtn; internal TextMeshProUGUI BlackMarketUnlockLabel; internal GameObject BlackMarketCatalogRoot; internal TextMeshProUGUI BlackMarketHintText; internal HubScreenButton BlackMarketScrollUpBtn; internal TextMeshProUGUI BlackMarketScrollUpLabel; internal HubScreenButton BlackMarketScrollDownBtn; internal TextMeshProUGUI BlackMarketScrollDownLabel; internal RectTransform BlackMarketViewport; internal RectTransform BlackMarketContent; internal RectTransform BlackMarketScrollTrack; internal RectTransform BlackMarketScrollThumb; internal readonly List<BlackMarketCardRefs> BlackMarketCards = new List<BlackMarketCardRefs>(); internal HubScreenButton TabExpeditionsBtn; internal TextMeshProUGUI TabExpeditionsLabel; internal GameObject ExpeditionsPanel; internal TextMeshProUGUI ExpBlueprintTitleText; internal TextMeshProUGUI ExpBlueprintTagText; internal Image ExpIsometricRoomImage; internal ExpeditionNodeRefs ExpExtractionsNode; internal ExpeditionNodeRefs ExpMonstersNode; internal Image ExpInspectorAccent; internal TextMeshProUGUI ExpSummaryText; internal TextMeshProUGUI ExpInspectTitleText; internal TextMeshProUGUI ExpInspectCostText; internal TextMeshProUGUI ExpInspectBodyText; internal TextMeshProUGUI ExpEscalationHeaderText; internal TextMeshProUGUI ExpEscalationStatsText; internal RectTransform ExpEscalationFill; internal readonly List<EscalationStepRefs> EscalationSteps = new List<EscalationStepRefs>(); internal TextMeshProUGUI BoardTitleText; internal TextMeshProUGUI BoardTickerText; internal readonly List<BoardTileRefs> BoardTiles = new List<BoardTileRefs>(); internal readonly List<RemotePointerRefs> RemotePointers = new List<RemotePointerRefs>(); private readonly Dictionary<int, HubScreenButton> _buttonsBySyncId = new Dictionary<int, HubScreenButton>(); internal bool IsUiInitialized; private TerminalTab _activeTab; private HubScreenButton? _hoveredButton; private int _lastCurrencySeen = -1; private string? _lastHackItemId; private string? _dismissedHackResultId; private string? _lastPlayedResultId; private float _hackAnimTimer; private float _boardCycleTimer; private int _boardTickerIdx; private ExpeditionInspectKind _expInspectKind; private ExpeditionNodeType _expInspectNode; private int _expInspectStep = 1; private bool _localOwnsInspect; private WarehouseSortMode _warehouseSortMode; private bool _hackAllArmed; private float _hackAllArmExpiresAt; private bool _localOwnsHackAllArm; private string _armedCandidateSignature = string.Empty; private bool _applyingRemoteUi; private float _localCursorX; private float _localCursorY; private bool _localCursorActive; private float _lastSentCursorX; private float _lastSentCursorY; private bool _lastSentCursorActive; private int _lastSentHoveredSyncId = -1; private float _nextPointerSendTime; private float _nextPointerHeartbeatTime; private float _nextScrollSendTime; private bool _warehouseScrollDirty; private bool _blackMarketScrollDirty; private float _lastSentWarehouseScrollY; private float _lastSentBlackMarketScrollY; private float? _pendingRemoteWarehouseScrollY; private float? _pendingRemoteBlackMarketScrollY; private float _warehouseLocalScrollLeaseUntil; private float _blackMarketLocalScrollLeaseUntil; private bool _pointerSyncDirty; private bool _pointerSyncPendingReliable; private AudioClip? _clickClip; private AudioClip? _successClip; private AudioClip? _dudClip; private float _warehouseScrollY; private float _warehouseVisualScrollY; private float _warehouseMaxScrollY; private float _blackMarketScrollY; private float _blackMarketVisualScrollY; private float _blackMarketMaxScrollY; private float _scrollVelocity; private bool _pointerDownOnScreen; private bool _pointerDownUsedInteract; private bool _pointerDownStartedInViewport; private bool _isDraggingScroll; private float _pointerDownCanvasY; private float _dragStartCanvasY; private float _dragStartScrollY; private HubScreenButton? _pointerDownButton; private static readonly Color ColTabActive = new Color(0.1f, 0.36f, 0.45f, 1f); private static readonly Color ColTabInactive = new Color(0.08f, 0.14f, 0.19f, 1f); private static readonly Color ColSellNormal = new Color(0.12f, 0.42f, 0.24f, 1f); private static readonly Color ColScrapNormal = new Color(0.32f, 0.17f, 0.17f, 1f); private static readonly Color ColHackNormal = new Color(0.45f, 0.3f, 0.08f, 1f); private static readonly Color ColReticleNormal = new Color(0.28f, 0.96f, 1f, 0.92f); private static readonly Color ColReticleHover = new Color(0.42f, 1f, 0.68f, 1f); private static readonly Color ColReticleDrag = new Color(1f, 0.82f, 0.32f, 1f); internal TerminalTab ActiveTab => _activeTab; internal WarehouseSortMode WarehouseSortMode => _warehouseSortMode; internal bool HackAllArmed => _hackAllArmed; internal float WarehouseScrollY => _warehouseScrollY; internal float BlackMarketScrollY => _blackMarketScrollY; internal string? DismissedHackResultId => _dismissedHackResultId; internal ExpeditionInspectKind CurrentInspectKind => _expInspectKind; internal ExpeditionNodeType CurrentInspectNode => _expInspectNode; internal int CurrentInspectStep => _expInspectStep; internal bool IsDraggingScrollForTest => _isDraggingScroll; internal void RegisterButton(HubScreenButton btn) { if ((Object)(object)btn != (Object)null && btn.SyncId >= 0) { _buttonsBySyncId[btn.SyncId] = btn; } } internal HubScreenButton? FindButtonBySyncId(int syncId) { if (!_buttonsBySyncId.TryGetValue(syncId, out HubScreenButton value)) { return null; } return value; } internal void InvokeResetPointerForTest() { ResetPointerState(); } internal void InvokeHydrateOneIconForTest() { HydrateOneMissingIconPerFrame(); } internal void InvokeUpdateRemotePointersForTest() { UpdateRemotePointerVisuals(); } internal void InvokeSetInspectForTest(ExpeditionInspectKind kind, ExpeditionNodeType node, int step) { _expInspectKind = kind; _expInspectNode = node; _expInspectStep = step; RefreshExpeditionInspector(); } internal void InvokeMouseWheelStepForTest(float wheelY) { ApplyWheelScrollDelta(wheelY); } internal void InvokeBeginDragScrollForTest(float startY) { _pointerDownOnScreen = true; _pointerDownStartedInViewport = true; _isDraggingScroll = true; _pointerDownCanvasY = startY; _dragStartCanvasY = startY; _dragStartScrollY = GetActiveScrollY(); } internal void InvokeEndDragScrollForTest() { _pointerDownOnScreen = false; _pointerDownStartedInViewport = false; _isDraggingScroll = false; _pointerDownButton = null; } internal void InvokeClearLocalScrollLeaseForTest() { _warehouseLocalScrollLeaseUntil = 0f; _blackMarketLocalScrollLeaseUntil = 0f; _scrollVelocity = 0f; _isDraggingScroll = false; _pointerDownOnScreen = false; } private void Awake() { _clickClip = CreateToneClip("RepoMarketHub_Click", 1150f, 750); _successClip = CreateToneClip("RepoMarketHub_Success", 1480f, 3200); _dudClip = CreateToneClip("RepoMarketHub_Dud", 320f, 4400); } private void OnEnable() { if ((Object)(object)MarketSync.Instance != (Object)null) { MarketSync.Instance.SnapshotUpdated += OnSnapshotUpdated; MarketSync.Instance.OnTerminalUiDeltaReceived += HandleRemoteTerminalUiDelta; MarketSync.Instance.OnTerminalUiEpochReset += HandleRemoteTerminalUiEpochReset; } ModLocalization.LanguageChanged += OnLanguageChanged; if (IsUiInitialized) { ApplyFonts(); RefreshAll(); } } private void Start() { if (!((Object)(object)MarketSync.Instance == (Object)null)) { if (SemiFunc.IsMasterClientOrSingleplayer()) { MarketSync.Instance.BroadcastCurrentTerminalUiOnSpawn(); ApplyTerminalUiFromSync(UiSyncMask.All); } else { ApplyTerminalUiFromSync(UiSyncMask.All); } } } private void OnDisable() { if ((Object)(object)MarketSync.Instance != (Object)null) { MarketSync.Instance.SnapshotUpdated -= OnSnapshotUpdated; MarketSync.Instance.OnTerminalUiDeltaReceived -= HandleRemoteTerminalUiDelta; MarketSync.Instance.OnTerminalUiEpochReset -= HandleRemoteTerminalUiEpochReset; } ModLocalization.LanguageChanged -= OnLanguageChanged; } private void Update() { if (IsUiInitialized) { UpdateRaycastAndTouchScroll(); UpdateScrollInertia(); UpdateSmoothVisualScroll(); FlushPendingUiSync(); UpdateRemotePointerVisuals(); UpdateCurrencyWatch(); UpdateHackAnimation(); UpdateHackAllArmTimeout(); UpdateBoardTickerCycle(); HydrateOneMissingIconPerFrame(); } } private void UpdateHackAllArmTimeout() { if (_hackAllArmed && !(Time.unscaledTime < _hackAllArmExpiresAt)) { DisarmHackAll(broadcastIfOwned: true); RefreshAll(); } } private void DisarmHackAll(bool broadcastIfOwned) { if (_hackAllArmed) { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _armedCandidateSignature = string.Empty; bool flag = broadcastIfOwned && !_applyingRemoteUi && (_localOwnsHackAllArm || SemiFunc.IsMasterClientOrSingleplayer()); _localOwnsHackAllArm = false; if (flag) { BroadcastUiState(UiSyncMask.HackAllArm, reliable: true); } else if ((Object)(object)MarketSync.Instance != (Object)null) { MarketSync.Instance.TerminalUi.HackAllArmed = false; } } } private void OnSnapshotUpdated(HubSnapshot _) { RefreshAll(); } private void OnLanguageChanged(ModLanguage _) { ApplyFonts(); RefreshAll(); } private void UpdateCurrencyWatch() { int num = SemiFunc.StatGetRunCurrency(); if (num != _lastCurrencySeen) { _lastCurrencySeen = num; RefreshAll(); } } private void UpdateHackAnimation() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) string activeHackId = MarketSync.Instance?.CurrentState.ActiveHackItemId; if (activeHackId != _lastHackItemId) { _lastHackItemId = activeHackId; _hackAnimTimer = 0f; RefreshHackOverlay(); } if (string.IsNullOrEmpty(activeHackId)) { return; } _hackAnimTimer += Time.deltaTime; float num = Mathf.Clamp01(_hackAnimTimer / 2f); if ((Object)(object)HackProgressFill != (Object)null) { HackProgressFill.sizeDelta = new Vector2(560f * num, 24f); } if ((Object)(object)HackOverlayTitle != (Object)null) { bool isRu = ModLocalization.CurrentLanguage == ModLanguage.Russian; HackKind kind = (MarketSync.Instance?.CurrentState.Warehouse.FirstOrDefault((WarehouseItem x) => x.Id == activeHackId))?.HackKind ?? HackKind.Hack; ((TMP_Text)HackOverlayTitle).text = GetProcessingStepText(kind, num, isRu); } } private void UpdateBoardTickerCycle() { List<TickerEntry> list = MarketSync.Instance?.CurrentState.Ticker; if (list != null && list.Count != 0) { _boardCycleTimer += Time.deltaTime; if (_boardCycleTimer >= 4f) { _boardCycleTimer = 0f; _boardTickerIdx = (_boardTickerIdx + 1) % Mathf.Min(5, list.Count); UpdateBoardTickerLine(list); } } } private void HydrateOneMissingIconPerFrame() { if (_activeTab == TerminalTab.Warehouse) { foreach (WarehouseCardRefs warehouseCard in WarehouseCards) { if (((Component)warehouseCard.Root).gameObject.activeSelf && !string.IsNullOrEmpty(warehouseCard.BoundPrefabKey) && (!((Object)(object)warehouseCard.IconImage.sprite != (Object)null) || !((Object)(object)warehouseCard.IconImage.sprite != (Object)(object)ShopTerminalBuilder.GetFallbackIconSprite())) && !ItemIconProvider.IsValuableIconFailed(warehouseCard.BoundPrefabKey)) { if (ItemIconProvider.TryHydrateValuableIcon(warehouseCard.BoundPrefabKey, out Sprite sprite, out bool didRenderWork) && (Object)(object)sprite != (Object)null) { warehouseCard.IconImage.sprite = sprite; } if (didRenderWork) { break; } } } return; } if (_activeTab != TerminalTab.BlackMarket) { return; } MarketSync instance = MarketSync.Instance; if (instance == null || !instance.CurrentState.BlackMarketUnlocked) { return; } foreach (BlackMarketCardRefs blackMarketCard in BlackMarketCards) { if (((Component)blackMarketCard.Root).gameObject.activeSelf && !((Object)(object)blackMarketCard.BoundItem == (Object)null) && (!((Object)(object)blackMarketCard.IconImage.sprite != (Object)null) || !((Object)(object)blackMarketCard.IconImage.sprite != (Object)(object)ShopTerminalBuilder.GetFallbackIconSprite())) && !ItemIconProvider.IsShopItemIconFailed(((Object)blackMarketCard.BoundItem).name)) { if (ItemIconProvider.TryHydrateShopItemIcon(blackMarketCard.BoundItem, out Sprite sprite2, out bool didRenderWork2) && (Object)(object)sprite2 != (Object)null) { blackMarketCard.IconImage.sprite = sprite2; } if (didRenderWork2) { break; } } } } private void UpdateRaycastAndTouchScroll() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00f1: 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_0104: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: 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_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Object)(object)MenuManager.instance != (Object)null && (Object)(object)MenuManager.instance.currentMenuPage != (Object)null) || !SemiFunc.NoTextInputsActive(); Camera main = Camera.main; if ((Object)(object)main == (Object)null || flag) { ResetPointerState(); if ((Object)(object)AimDot != (Object)null) { ((Component)AimDot).gameObject.SetActive(false); } return; } Ray val = main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); RaycastHit val2 = default(RaycastHit); if ((Object)(object)ScreenPlaneCollider == (Object)null || !ScreenPlaneCollider.Raycast(val, ref val2, 4.6f)) { ResetPointerState(); if ((Object)(object)AimDot != (Object)null) { ((Component)AimDot).gameObject.SetActive(false); } return; } Vector3 val3 = ((Transform)ScreenCanvasRect).InverseTransformPoint(((RaycastHit)(ref val2)).point); ((Component)AimDot).gameObject.SetActive(true); AimDot.anchoredPosition3D = new Vector3(val3.x, val3.y, -14f); _localCursorX = val3.x; _localCursorY = val3.y; _localCursorActive = true; RectTransform activeScrollViewport = GetActiveScrollViewport(); bool flag2 = (Object)(object)activeScrollViewport != (Object)null && IsPointInsideRect(activeScrollViewport, ((RaycastHit)(ref val2)).point); bool flag3 = ((Object)(object)HackOverlay != (Object)null && HackOverlay.activeSelf) || ((Object)(object)HackResultOverlay != (Object)null && HackResultOverlay.activeSelf); if (!flag3 && (Object)(object)activeScrollViewport != (Object)null && Mouse.current != null && ((Object)(object)PhysGrabber.instance == (Object)null || !PhysGrabber.instance.grabbed)) { float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y; if (Mathf.Abs(y) > 0.01f) { ApplyWheelScrollDelta(y); } } HubScreenButton hubScreenButton = null; RaycastHit[] array = Physics.RaycastAll(val, 4.6f, -1, (QueryTriggerInteraction)2); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; HubScreenButton hubScreenButton2 = default(HubScreenButton); for (int num = 0; num < array2.Length; num++) { RaycastHit val4 = array2[num]; if (!((Object)(object)((RaycastHit)(ref val4)).collider == (Object)(object)ScreenPlaneCollider)) { if ((Object)(object)((RaycastHit)(ref val4)).collider == (Object)(object)OverlayShieldCollider) { break; } if (((Component)((RaycastHit)(ref val4)).collider).TryGetComponent<HubScreenButton>(ref hubScreenButton2) && (!hubScreenButton2.IsScrollableCardButton || flag2)) { hubScreenButton = hubScreenButton2; break; } } } SetHoveredButton(_isDraggingScroll ? null : hubScreenButton); bool flag4 = !_lastSentCursorActive || Mathf.Abs(_localCursorX - _lastSentCursorX) >= 3f || Mathf.Abs(_localCursorY - _lastSentCursorY) >= 3f || (_hoveredButton?.SyncId ?? (-1)) != _lastSentHoveredSyncId; bool flag5 = _lastSentCursorActive && Time.unscaledTime >= _nextPointerHeartbeatTime; if (flag4) { _pointerSyncDirty = true; if (!_lastSentCursorActive) { _pointerSyncPendingReliable = true; } } else if (flag5) { _pointerSyncDirty = true; } bool flag6 = (Object)(object)hubScreenButton != (Object)null && hubScreenButton.IsInteractable; float num2 = (_isDraggingScroll ? 1.35f : (flag6 ? 1.24f : (((Object)(object)hubScreenButton != (Object)null) ? 1.12f : 1f))); ((Transform)AimDot).localScale = Vector3.Lerp(((Transform)AimDot).localScale, Vector3.one * num2, Time.deltaTime * 18f); if ((Object)(object)AimDotImage != (Object)null) { ((Graphic)AimDotImage).color = (_isDraggingScroll ? ColReticleDrag : (flag6 ? ColReticleHover : ColReticleNormal)); } bool flag7 = SemiFunc.InputDown((InputKey)2); bool flag8 = Mouse.current != null && Mouse.current.leftButton.wasPressedThisFrame && ((Object)(object)PhysGrabber.instance == (Object)null || !PhysGrabber.instance.grabbed); if (!_pointerDownOnScreen && (flag7 || flag8)) { _pointerDownOnScreen = true; _pointerDownUsedInteract = flag7; _pointerDownStartedInViewport = flag2; _isDraggingScroll = false; _pointerDownCanvasY = val3.y; _dragStartCanvasY = val3.y; _dragStartScrollY = GetActiveScrollY(); _pointerDownButton = hubScreenButton; _scrollVelocity = 0f; } if (!_pointerDownOnScreen) { return; } bool num3; if (!_pointerDownUsedInteract) { if (Mouse.current == null || !Mouse.current.leftButton.isPressed) { goto IL_05da; } if ((Object)(object)PhysGrabber.instance == (Object)null) { goto IL_04f8; } num3 = !PhysGrabber.instance.grabbed; } else { num3 = SemiFunc.InputHold((InputKey)2); } if (num3) { goto IL_04f8; } goto IL_05da; IL_04f8: float num4 = val3.y - _pointerDownCanvasY; if (!_isDraggingScroll && !flag3 && _pointerDownStartedInViewport && (Object)(object)activeScrollViewport != (Object)null && Mathf.Abs(num4) >= 14f) { _isDraggingScroll = true; _dragStartCanvasY = val3.y; _dragStartScrollY = GetActiveScrollY(); SetHoveredButton(null); } if (_isDraggingScroll) { float num5 = Mathf.Clamp(Time.unscaledDeltaTime, 0.002f, 0.05f); float activeScrollY = GetActiveScrollY(); SetActiveScrollY(_dragStartScrollY + (val3.y - _dragStartCanvasY), immediateVisual: true); float num6 = GetActiveScrollY() - activeScrollY; float num7 = Mathf.Clamp(num6 / num5, -2200f, 2200f); _scrollVelocity = Mathf.Lerp(_scrollVelocity, num7, 0.45f); } return; IL_05da: if (!_isDraggingScroll && (Object)(object)_pointerDownButton != (Object)null && (Object)(object)_pointerDownButton == (Object)(object)hubScreenButton) { PlayClickSound(); _pointerDownButton.TriggerClick(); } _pointerDownOnScreen = false; _pointerDownStartedInViewport = false; _isDraggingScroll = false; _pointerDownButton = null; } private void UpdateScrollInertia() { if (!_isDraggingScroll && !(Mathf.Abs(_scrollVelocity) < 1f)) { float num = Mathf.Clamp(Time.unscaledDeltaTime, 0.001f, 0.05f); float activeScrollY = GetActiveScrollY(); SetActiveScrollY(activeScrollY + _scrollVelocity * num, immediateVisual: false); float num2 = Mathf.Abs(GetActiveScrollY() - activeScrollY); _scrollVelocity *= Mathf.Exp(-7.5f * num); if (Mathf.Abs(_scrollVelocity) < 5f || num2 < 0.01f) { _scrollVelocity = 0f; } } } private void UpdateSmoothVisualScroll() { float num = Mathf.Clamp(Time.unscaledDeltaTime, 0.001f, 0.05f); float num2 = 1f - Mathf.Exp(-15f * num); if ((Object)(object)WarehouseContent != (Object)null) { float num3 = ((_activeTab == TerminalTab.Warehouse && _isDraggingScroll) ? _warehouseScrollY : Mathf.Lerp(_warehouseVisualScrollY, _warehouseScrollY, num2)); if (Mathf.Abs(_warehouseScrollY - num3) < 0.2f) { num3 = _warehouseScrollY; } if (Mathf.Abs(num3 - _warehouseVisualScrollY) > 0.02f) { _warehouseVisualScrollY = num3; ApplyScrollPosition(WarehouseContent, WarehouseScrollTrack, WarehouseScrollThumb, _warehouseVisualScrollY, _warehouseMaxScrollY, 410f); } } if ((Object)(object)BlackMarketContent != (Object)null) { float num4 = ((_activeTab == TerminalTab.BlackMarket && _isDraggingScroll) ? _blackMarketScrollY : Mathf.Lerp(_blackMarketVisualScrollY, _blackMarketScrollY, num2)); if (Mathf.Abs(_blackMarketScrollY - num4) < 0.2f) { num4 = _blackMarketScrollY; } if (Mathf.Abs(num4 - _blackMarketVisualScrollY) > 0.02f) { _blackMarketVisualScrollY = num4; ApplyScrollPosition(BlackMarketContent, BlackMarketScrollTrack, BlackMarketScrollThumb, _blackMarketVisualScrollY, _blackMarketMaxScrollY, 450f); } } } private void FlushPendingUiSync(bool allowPointer = true) { if (_applyingRemoteUi) { return; } float unscaledTime = Time.unscaledTime; if (allowPointer && _pointerSyncDirty && (unscaledTime >= _nextPointerSendTime || unscaledTime >= _nextPointerHeartbeatTime)) { bool pointerSyncPendingReliable = _pointerSyncPendingReliable; _pointerSyncDirty = false; _pointerSyncPendingReliable = false; BroadcastUiState(UiSyncMask.Pointer, pointerSyncPendingReliable); } if (((_warehouseScrollDirty ? 2 : 0) | (_blackMarketScrollDirty ? 4 : 0)) != 0 && ((!_isDraggingScroll && Mathf.Abs(_scrollVelocity) < 1f) || !(unscaledTime < _nextScrollSendTime))) { bool flag = _warehouseScrollDirty && Mathf.Abs(_warehouseScrollY - _lastSentWarehouseScrollY) >= 0.25f; bool flag2 = _blackMarketScrollDirty && Mathf.Abs(_blackMarketScrollY - _lastSentBlackMarketScrollY) >= 0.25f; if (!flag && !flag2) { _warehouseScrollDirty = false; _blackMarketScrollDirty = false; return; } UiSyncMask mask = (UiSyncMask)((flag ? 2 : 0) | (flag2 ? 4 : 0)); _warehouseScrollDirty = false; _blackMarketScrollDirty = false; _lastSentWarehouseScrollY = _warehouseScrollY; _lastSentBlackMarketScrollY = _blackMarketScrollY; _nextScrollSendTime = unscaledTime + 0.065f; BroadcastUiState(mask, reliable: true); } } private void ResetPointerState() { bool flag = _localCursorActive || (Object)(object)_hoveredButton != (Object)null; _localCursorActive = false; _localCursorX = 0f; _localCursorY = 0f; _pointerSyncDirty = false; _pointerSyncPendingReliable = false; if ((Object)(object)AimDot != (Object)null && ((Component)AimDot).gameObject.activeSelf) { ((Component)AimDot).gameObject.SetActive(false); } if ((Object)(object)_hoveredButton != (Object)null) { _hoveredButton.SetHovered(hovered: false); _hoveredButton = null; } bool flag2 = false; if (_localOwnsInspect && _expInspectKind != ExpeditionInspectKind.None) { _localOwnsInspect = false; _expInspectKind = ExpeditionInspectKind.None; RefreshExpeditionInspector(); flag2 = true; } _pointerDownOnScreen = false; _pointerDownStartedInViewport = false; _isDraggingScroll = false; _pointerDownButton = null; FlushPendingUiSync(allowPointer: false); if (!_applyingRemoteUi && (flag || flag2)) { UiSyncMask mask = (UiSyncMask)(0x20 | (flag2 ? 16 : 0)); BroadcastUiState(mask, reliable: true); } } private void HandleRemoteTerminalUiEpochReset() { _warehouseLocalScrollLeaseUntil = 0f; _blackMarketLocalScrollLeaseUntil = 0f; _warehouseScrollDirty = false; _blackMarketScrollDirty = false; _pendingRemoteWarehouseScrollY = null; _pendingRemoteBlackMarketScrollY = null; _scrollVelocity = 0f; _isDraggingScroll = false; _pointerDownOnScreen = false; _pointerDownStartedInViewport = false; _pointerDownButton = null; _localOwnsInspect = false; _warehouseSortMode = WarehouseSortMode.Default; _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; } private void MarkActiveScrollDirty() { if (!_applyingRemoteUi) { if (_activeTab == TerminalTab.Warehouse) { _warehouseScrollDirty = true; } else if (_activeTab == TerminalTab.BlackMarket) { _blackMarketScrollDirty = true; } } } private void BroadcastUiState(UiSyncMask mask, bool reliable) { if (_applyingRemoteUi || mask == UiSyncMask.None) { return; } MarketSync instance = MarketSync.Instance; if (!((Object)(object)instance == (Object)null)) { if ((mask & UiSyncMask.WarehouseScroll) != UiSyncMask.None) { _warehouseScrollDirty = false; _lastSentWarehouseScrollY = _warehouseScrollY; } if ((mask & UiSyncMask.BlackMarketScroll) != UiSyncMask.None) { _blackMarketScrollDirty = false; _lastSentBlackMarketScrollY = _blackMarketScrollY; } int num = (((Object)(object)_hoveredButton != (Object)null) ? _hoveredButton.SyncId : (-1)); instance.SendTerminalUiAction(mask, (int)_activeTab, _warehouseScrollY, _blackMarketScrollY, _dismissedHackResultId ?? string.Empty, (int)_expInspectKind, (int)_expInspectNode, _expInspectStep, num, _localCursorX, _localCursorY, _localCursorActive, reliable, (int)_warehouseSortMode, _hackAllArmed); if ((mask & UiSyncMask.Pointer) != UiSyncMask.None) { _pointerSyncDirty = false; _pointerSyncPendingReliable = false; _lastSentCursorX = _localCursorX; _lastSentCursorY = _localCursorY; _lastSentCursorActive = _localCursorActive; _lastSentHoveredSyncId = num; _nextPointerSendTime = Time.unscaledTime + 0.05f; _nextPointerHeartbeatTime = Time.unscaledTime + 1.5f; } } } private void HandleRemoteTerminalUiDelta(UiSyncMask deltaMask) { if (IsUiInitialized && !((Object)(object)this == (Object)null) && ((Component)this).gameObject.activeInHierarchy && deltaMask != UiSyncMask.None) { if ((deltaMask & ~UiSyncMask.Pointer) == 0) { UpdateRemotePointerVisuals(); } else { ApplyTerminalUiFromSync(deltaMask); } } } private void ApplyTerminalUiFromSync(UiSyncMask mask) { MarketSync instance = MarketSync.Instance; if ((Object)(object)instance == (Object)null) { return; } TerminalUiSnapshot terminalUi = instance.TerminalUi; int localActorNumber = MarketSync.GetLocalActorNumber(); bool applyingRemoteUi = _applyingRemoteUi; _applyingRemoteUi = true; try { bool flag = false; if ((mask & UiSyncMask.Tab) != UiSyncMask.None) { TerminalTab terminalTab = (TerminalTab)Mathf.Clamp(terminalUi.ActiveTab, 0, 3); if (_activeTab != terminalTab) { _activeTab = terminalTab; _scrollVelocity = 0f; _isDraggingScroll = false; _pointerDownOnScreen = false; flag = true; } if (_activeTab != TerminalTab.Warehouse && _hackAllArmed) { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; terminalUi.HackAllArmed = false; flag = true; } } if ((mask & UiSyncMask.WarehouseSort) != UiSyncMask.None) { WarehouseSortMode warehouseSortMode = (WarehouseSortMode)Mathf.Clamp(terminalUi.WarehouseSortMode, 0, 3); if (_warehouseSortMode != warehouseSortMode) { _warehouseSortMode = warehouseSortMode; if ((mask & UiSyncMask.WarehouseScroll) == 0) { _warehouseScrollY = 0f; _warehouseVisualScrollY = 0f; _scrollVelocity = 0f; _lastSentWarehouseScrollY = 0f; _warehouseScrollDirty = false; } flag = true; } if (_hackAllArmed && (mask & UiSyncMask.HackAllArm) == 0) { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; flag = true; } } if ((mask & UiSyncMask.WarehouseScroll) != UiSyncMask.None && (terminalUi.LastUpdatedByActor == localActorNumber || ((_activeTab != TerminalTab.Warehouse || !_isDraggingScroll) && (_activeTab != TerminalTab.Warehouse || !(Mathf.Abs(_scrollVelocity) > 2f)) && !(Time.unscaledTime < _warehouseLocalScrollLeaseUntil) && !instance.HasPendingLocalWarehouseScroll))) { _pendingRemoteWarehouseScrollY = ((terminalUi.WarehouseScrollY > _warehouseMaxScrollY + 0.25f && _warehouseMaxScrollY <= 1f) ? new float?(terminalUi.WarehouseScrollY) : ((float?)null)); float num = Mathf.Clamp(terminalUi.WarehouseScrollY, 0f, _warehouseMaxScrollY); if (Mathf.Abs(_warehouseScrollY - num) > 0.25f) { _warehouseScrollY = num; _lastSentWarehouseScrollY = num; _warehouseScrollDirty = false; if (terminalUi.LastUpdatedByActor != localActorNumber) { _scrollVelocity = 0f; } UpdateScrollButtonStates(); } else { _lastSentWarehouseScrollY = num; _warehouseScrollDirty = false; } } if ((mask & UiSyncMask.BlackMarketScroll) != UiSyncMask.None && (terminalUi.LastUpdatedByActor == localActorNumber || ((_activeTab != TerminalTab.BlackMarket || !_isDraggingScroll) && (_activeTab != TerminalTab.BlackMarket || !(Mathf.Abs(_scrollVelocity) > 2f)) && !(Time.unscaledTime < _blackMarketLocalScrollLeaseUntil) && !instance.HasPendingLocalBlackMarketScroll))) { _pendingRemoteBlackMarketScrollY = ((terminalUi.BlackMarketScrollY > _blackMarketMaxScrollY + 0.25f && _blackMarketMaxScrollY <= 1f) ? new float?(terminalUi.BlackMarketScrollY) : ((float?)null)); float num2 = Mathf.Clamp(terminalUi.BlackMarketScrollY, 0f, _blackMarketMaxScrollY); if (Mathf.Abs(_blackMarketScrollY - num2) > 0.25f) { _blackMarketScrollY = num2; _lastSentBlackMarketScrollY = num2; _blackMarketScrollDirty = false; if (terminalUi.LastUpdatedByActor != localActorNumber) { _scrollVelocity = 0f; } UpdateScrollButtonStates(); } else { _lastSentBlackMarketScrollY = num2; _blackMarketScrollDirty = false; } } if ((mask & UiSyncMask.DismissHack) != UiSyncMask.None && !string.IsNullOrEmpty(terminalUi.DismissedHackResultId) && _dismissedHackResultId != terminalUi.DismissedHackResultId) { _dismissedHackResultId = terminalUi.DismissedHackResultId; flag = true; } if ((mask & UiSyncMask.Inspect) != UiSyncMask.None) { ExpeditionInspectKind expeditionInspectKind = (ExpeditionInspectKind)Mathf.Clamp(terminalUi.ExpInspectKind, 0, 2); ExpeditionNodeType expInspectNode = (ExpeditionNodeType)terminalUi.ExpInspectNode; int num3 = Mathf.Clamp(terminalUi.ExpInspectStep, 1, 6); if (_expInspectKind != expeditionInspectKind || _expInspectNode != expInspectNode || _expInspectStep != num3) { _localOwnsInspect = false; _expInspectKind = expeditionInspectKind; _expInspectNode = expInspectNode; _expInspectStep = num3; if (!flag) { RefreshExpeditionInspector(); } } } if ((mask & UiSyncMask.HackAllArm) != UiSyncMask.None) { bool flag2 = terminalUi.HackAllArmed && _activeTab == TerminalTab.Warehouse; if (_hackAllArmed != flag2) { _hackAllArmed = flag2; _hackAllArmExpiresAt = (flag2 ? (Time.unscaledTime + 4.5f) : 0f); if (!flag2) { _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; } flag = true; } } if (flag) { RefreshAll(); } if ((mask & UiSyncMask.Pointer) != UiSyncMask.None || mask == UiSyncMask.All) { UpdateRemotePointerVisuals(); } } finally { _applyingRemoteUi = applyingRemoteUi; } } private void UpdateRemotePointerVisuals() { //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) MarketSync instance = MarketSync.Instance; if ((Object)(object)instance == (Object)null) { return; } int localActorNumber = MarketSync.GetLocalActorNumber(); float unscaledTime = Time.unscaledTime; HashSet<int> hashSet = new HashSet<int>(); int num = 0; float num2 = Mathf.Clamp(Time.unscaledDeltaTime, 0.001f, 0.05f); float num3 = 1f - Mathf.Exp(-24f * num2); foreach (RemotePointerState value in instance.TerminalUi.RemotePointers.Values) { if (value.ActorNumber == localActorNumber || !value.CursorActive || unscaledTime - value.LastSeenUnscaledTime > 4f) { continue; } if (value.HoveredButtonSyncId >= 0) { hashSet.Add(value.HoveredButtonSyncId); } if (num < RemotePointers.Count) { RemotePointerRefs remotePointerRefs = RemotePointers[num++]; bool flag = !((Component)remotePointerRefs.Root).gameObject.activeSelf; if (flag) { ((Component)remotePointerRefs.Root).gameObject.SetActive(true); remotePointerRefs.LastMeasuredName = string.Empty; } if (remotePointerRefs.BoundActorNumber != value.ActorNumber) { remotePointerRefs.BoundActorNumber = value.ActorNumber; remotePointerRefs.HasDisplayPos = false; remotePointerRefs.LastMeasuredName = string.Empty; } if (flag || !remotePointerRefs.HasDisplayPos) { remotePointerRefs.DisplayX = value.CursorX; remotePointerRefs.DisplayY = value.CursorY; remotePointerRefs.HasDisplayPos = true; } else { remotePointerRefs.DisplayX = Mathf.Lerp(remotePointerRefs.DisplayX, value.CursorX, num3); remotePointerRefs.DisplayY = Mathf.Lerp(remotePointerRefs.DisplayY, value.CursorY, num3); } remotePointerRefs.Root.anchoredPosition3D = new Vector3(remotePointerRefs.DisplayX, remotePointerRefs.DisplayY, -15f); string text = SanitizeRemoteDisplayName(value.ActorName); if (string.IsNullOrEmpty(text)) { text = $"P{value.ActorNumber}"; } UpdateRemotePointerNameBadge(remotePointerRefs, text, value.ActorNumber); if ((Object)(object)remotePointerRefs.NameTagRoot != (Object)null && ((Component)remotePointerRefs.NameTagRoot).gameObject.activeSelf) { float x = remotePointerRefs.NameTagRoot.sizeDelta.x; float num4 = ((remotePointerRefs.DisplayX + 4f + x > 548f) ? (-6f - x) : 15f); float num5 = ((remotePointerRefs.DisplayY + 32f > 332f) ? (-24f) : 16f); remotePointerRefs.NameTagRoot.anchoredPosition3D = new Vector3(num4, num5, -1f); } } } for (int i = num; i < RemotePointers.Count; i++) { RemotePointerRefs remotePointerRefs2 = RemotePointers[i]; remotePointerRefs2.HasDisplayPos = false; remotePointerRefs2.BoundActorNumber = 0; if (((Component)remotePointerRefs2.Root).gameObject.activeSelf) { ((Component)remotePointerRefs2.Root).gameObject.SetActive(false); } } foreach (KeyValuePair<int, HubScreenButton> item in _buttonsBySyncId) { item.Value.SetRemoteHovered(hashSet.Contains(item.Key)); } } private static string SanitizeRemoteDisplayName(string? rawName) { if (string.IsNullOrEmpty(rawName)) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(rawName.Length); foreach (char c in rawName) { if (!char.IsControl(c) && (c < '\u200b' || c > '\u200f') && (c < '\u202a' || c > '\u202e') && (c < '\u2060' || c > '\u206f') && c != '\ufeff') { stringBuilder.Append(c); } } return stringBuilder.ToString().Trim(); } private static void UpdateRemotePointerNameBadge(RemotePointerRefs slot, string displayName, int actorNumber) { //IL_00aa: 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_01be: 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_0226: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)slot.NameText == (Object)null || (Object)(object)slot.NameTagRoot == (Object)null) { return; } string text = SanitizeRemoteDisplayName(displayName); if (string.IsNullOrEmpty(text)) { text = $"P{actorNumber}"; } if (string.Equals(slot.LastMeasuredName, text, StringComparison.Ordinal) && slot.LastMeasuredFont == ((TMP_Text)slot.NameText).font && ((Component)slot.NameTagRoot).gameObject.activeSelf) { return; } HubFontHelper.AttachFallbackFont(((TMP_Text)slot.NameText).font); ((TMP_Text)slot.NameText).richText = false; ((TMP_Text)slot.NameText).overflowMode = (TextOverflowModes)0; slot.NameTagRoot.sizeDelta = new Vector2(380f, 32f); ((TMP_Text)slot.NameText).rectTransform.sizeDelta = new Vector2(364f, 32f); ((Component)slot.NameTagRoot).gameObject.SetActive(true); ((Component)slot.NameText).gameObject.SetActive(true); LayoutRebuilder.ForceRebuildLayoutImmediate(slot.NameTagRoot); ((TMP_Text)slot.NameText).text = text; ((Graphic)slot.NameText).SetAllDirty(); ((TMP_Text)slot.NameText).ForceMeshUpdate(true, true); bool flag = HasAnyVisibleGlyph(slot.NameText); if (!flag) { string text2 = $"P{actorNumber}"; if (!string.Equals(text, text2, StringComparison.Ordinal)) { ((TMP_Text)slot.NameText).text = text2; ((TMP_Text)slot.NameText).ForceMeshUpdate(true, true); flag = HasAnyVisibleGlyph(slot.NameText); } } if (!flag) { ((Component)slot.NameTagRoot).gameObject.SetActive(false); slot.LastMeasuredName = text; slot.LastMeasuredFont = ((TMP_Text)slot.NameText).font; return; } float x = ((TMP_Text)slot.NameText).GetPreferredValues(((TMP_Text)slot.NameText).text, 364f, 32f).x; float num = ComputeMeasuredTextWidth(slot.NameText); float num2 = Mathf.Max(x, num); float num3 = Mathf.Clamp(num2 + 24f, 52f, 300f); slot.NameTagRoot.sizeDelta = new Vector2(num3, 32f); ((TMP_Text)slot.NameText).rectTransform.sizeDelta = new Vector2(num3 - 14f, 32f); LayoutRebuilder.ForceRebuildLayoutImmediate(slot.NameTagRoot); ((TMP_Text)slot.NameText).overflowMode = (TextOverflowModes)(num2 > 284f); ((Graphic)slot.NameText).SetAllDirty(); ((TMP_Text)slot.NameText).ForceMeshUpdate(true, true); slot.LastMeasuredName = text; slot.LastMeasuredFont = ((TMP_Text)slot.NameText).font; } private static float ComputeMeasuredTextWidth(TextMeshProUGUI tmp) { //IL_0007: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00d0: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) float renderedWidth = ((TMP_Text)tmp).renderedWidth; Bounds textBounds = ((TMP_Text)tmp).textBounds; float num = Mathf.Max(renderedWidth, ((Bounds)(ref textBounds)).size.x); TMP_TextInfo textInfo = ((TMP_Text)tmp).textInfo; if (textInfo == null || textInfo.characterCount <= 0) { return num; } int num2 = Math.Min(textInfo.characterCount, textInfo.characterInfo.Length); float num3 = float.MaxValue; float num4 = float.MinValue; for (int i = 0; i < num2; i++) { TMP_CharacterInfo val = textInfo.characterInfo[i]; if (val.isVisible || char.IsWhiteSpace(val.character)) { if (val.bottomLeft.x < num3) { num3 = val.bottomLeft.x; } if (val.origin < num3) { num3 = val.origin; } if (val.topRight.x > num4) { num4 = val.topRight.x; } if (val.xAdvance > num4) { num4 = val.xAdvance; } } } if (num4 > num3 && num3 < float.MaxValue) { num = Mathf.Max(num, num4 - num3); } return num; } private static bool HasAnyVisibleGlyph(TextMeshProUGUI tmp) { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) TMP_TextInfo textInfo = ((TMP_Text)tmp).textInfo; if (textInfo == null || textInfo.characterCount <= 0) { return false; } int num = Math.Min(textInfo.characterCount, textInfo.characterInfo.Length); for (int i = 0; i < num; i++) { TMP_CharacterInfo val = textInfo.characterInfo[i]; if (val.isVisible && !char.IsWhiteSpace(val.character) && val.scale > 0f) { return true; } } return false; } private RectTransform? GetActiveScrollViewport() { switch (_activeTab) { case TerminalTab.Warehouse: return WarehouseViewport; case TerminalTab.BlackMarket: { MarketSync instance = MarketSync.Instance; if (instance != null && instance.CurrentState.BlackMarketUnlocked) { return BlackMarketViewport; } break; } } return null; } private float GetActiveScrollY() { if (_activeTab != TerminalTab.Warehouse) { return _blackMarketScrollY; } return _warehouseScrollY; } private void SetActiveScrollY(float y, bool immediateVisual) { if (_activeTab == TerminalTab.Warehouse) { if (!_applyingRemoteUi) { _pendingRemoteWarehouseScrollY = null; _warehouseLocalScrollLeaseUntil = Time.unscaledTime + 0.45f; } _warehouseScrollY = Mathf.Clamp(y, 0f, _warehouseMaxScrollY); if (immediateVisual) { _warehouseVisualScrollY = _warehouseScrollY; ApplyScrollPosition(WarehouseContent, WarehouseScrollTrack, WarehouseScrollThumb, _warehouseVisualScrollY, _warehouseMaxScrollY, 410f); } } else if (_activeTab == TerminalTab.BlackMarket) { if (!_applyingRemoteUi) { _pendingRemoteBlackMarketScrollY = null; _blackMarketLocalScrollLeaseUntil = Time.unscaledTime + 0.45f; } _blackMarketScrollY = Mathf.Clamp(y, 0f, _blackMarketMaxScrollY); if (immediateVisual) { _blackMarketVisualScrollY = _blackMarketScrollY; ApplyScrollPosition(BlackMarketContent, BlackMarketScrollTrack, BlackMarketScrollThumb, _blackMarketVisualScrollY, _blackMarketMaxScrollY, 450f); } } UpdateScrollButtonStates(); MarkActiveScrollDirty(); } private void AdjustActiveScroll(float deltaY) { SetActiveScrollY(GetActiveScrollY() + deltaY, immediateVisual: false); } private void ApplyWheelScrollDelta(float wheelY) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if (!(Mathf.Abs(wheelY) <= 0.01f)) { float num = (((int)Application.platform != 2 && (int)Application.platform != 7 && !(Mathf.Abs(wheelY) > 10f)) ? Mathf.Clamp(wheelY, -4f, 4f) : Mathf.Clamp(wheelY / 120f, -4f, 4f)); float deltaY = (0f - num) * 96f; float activeScrollY = GetActiveScrollY(); _scrollVelocity = 0f; AdjustActiveScroll(deltaY); if (_isDraggingScroll) { _dragStartScrollY += GetActiveScrollY() - activeScrollY; } } } private void UpdateScrollButtonStates() { if ((Object)(object)WarehouseScrollUpBtn != (Object)null) { WarehouseScrollUpBtn.SetInteractable(_warehouseScrollY > 1f); } if ((Object)(object)WarehouseScrollDownBtn != (Object)null) { WarehouseScrollDownBtn.SetInteractable(_warehouseScrollY < _warehouseMaxScrollY - 1f); } if ((Object)(object)BlackMarketScrollUpBtn != (Object)null) { BlackMarketScrollUpBtn.SetInteractable(_blackMarketScrollY > 1f); } if ((Object)(object)BlackMarketScrollDownBtn != (Object)null) { BlackMarketScrollDownBtn.SetInteractable(_blackMarketScrollY < _blackMarketMaxScrollY - 1f); } } private static void ApplyScrollPosition(RectTransform content, RectTransform track, RectTransform thumb, float scrollY, float maxScrollY, float viewportHeightPx) { //IL_0015: 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_0097: 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) if ((Object)(object)content != (Object)null) { content.anchoredPosition3D = new Vector3(0f, scrollY, -1f); } if (!((Object)(object)track == (Object)null) && !((Object)(object)thumb == (Object)null)) { float num = track.sizeDelta.y - 4f; if (maxScrollY <= 1f) { ((Component)thumb).gameObject.SetActive(false); return; } ((Component)thumb).gameObject.SetActive(true); float num2 = viewportHeightPx + maxScrollY; float num3 = Mathf.Clamp(num * (viewportHeightPx / num2), 38f, num); float num4 = scrollY / maxScrollY; float num5 = 2f + num4 * (num - num3); thumb.sizeDelta = new Vector2(16f, num3); thumb.anchoredPosition3D = new Vector3(2f, 0f - num5, -2f); } } private static bool IsPointInsideRect(RectTransform rt, Vector3 worldPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0035: 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) Vector3 val = ((Transform)rt).InverseTransformPoint(worldPoint); if (val.x >= 0f && val.x <= rt.sizeDelta.x && val.y <= 0f) { return val.y >= 0f - rt.sizeDelta.y; } return false; } private void SetHoveredButton(HubScreenButton? next) { if (!((Object)(object)_hoveredButton == (Object)(object)next)) { if ((Object)(object)_hoveredButton != (Object)null) { _hoveredButton.SetHovered(hovered: false); } _hoveredButton = next; if ((Object)(object)_hoveredButton != (Object)null) { _hoveredButton.SetHovered(hovered: true); } if (!_applyingRemoteUi) { _pointerSyncDirty = true; _pointerSyncPendingReliable = true; } } } public void SwitchTab(TerminalTab tab) { if (_activeTab != tab || _expInspectKind != ExpeditionInspectKind.None) { UiSyncMask uiSyncMask = UiSyncMask.None; if (tab != TerminalTab.Warehouse && _hackAllArmed) { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; uiSyncMask = UiSyncMask.HackAllArm; } _activeTab = tab; _scrollVelocity = 0f; _expInspectKind = ExpeditionInspectKind.None; RefreshAll(); if (!_applyingRemoteUi) { BroadcastUiState(UiSyncMask.Tab | UiSyncMask.Inspect | UiSyncMask.Pointer | uiSyncMask, reliable: true); } } } public void SwitchWarehouseSort(WarehouseSortMode mode) { UiSyncMask uiSyncMask = UiSyncMask.None; if (_hackAllArmed) { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; uiSyncMask = UiSyncMask.HackAllArm; } _warehouseSortMode = mode; _warehouseScrollY = 0f; _warehouseVisualScrollY = 0f; _scrollVelocity = 0f; _lastSentWarehouseScrollY = 0f; _warehouseScrollDirty = false; RefreshAll(); if (!_applyingRemoteUi) { BroadcastUiState(UiSyncMask.WarehouseScroll | UiSyncMask.Pointer | UiSyncMask.WarehouseSort | uiSyncMask, reliable: true); } } public void ApplyFonts() { if (!IsUiInitialized) { return; } TMP_FontAsset fontForCurrentLanguage = HubFontHelper.GetFontForCurrentLanguage(); if ((Object)(object)fontForCurrentLanguage == (Object)null) { return; } foreach (TextMeshProUGUI allTextElement in AllTextElements) { if ((Object)(object)allTextElement != (Object)null && (Object)(object)((TMP_Text)allTextElement).font != (Object)(object)fontForCurrentLanguage) { ((TMP_Text)allTextElement).font = fontForCurrentLanguage; } } } public void RefreshAll() { //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_0249: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) if (!IsUiInitialized) { return; } HubSnapshot hubSnapshot = MarketSync.Instance?.CurrentState; if (hubSnapshot != null) { bool flag = ModLocalization.CurrentLanguage == ModLanguage.Russian; int num = SemiFunc.StatGetRunCurrency(); int num2 = Math.Max(0, hubSnapshot.PendingDollars); int totalWarehouseSellValueDollars = MarketManager.Instance.GetTotalWarehouseSellValueDollars(); ((TMP_Text)HeaderTitleText).text = ModLocalization.Get("hub.title"); ((TMP_Text)HeaderCashText).text = ((num2 > 0) ? string.Format("{0}: ${1}K <color=#FFD166>(+{2})</color>", ModLocalization.Get("header.cash"), num, MarketManager.FormatDollars(num2)) : string.Format("{0}: ${1}K", ModLocalization.Get("header.cash"), num)); ((TMP_Text)HeaderStockText).text = string.Format("{0}: {1} ({2})", ModLocalization.Get("header.stock"), MarketManager.FormatDollars(totalWarehouseSellValueDollars), hubSnapshot.Warehouse.Count); ((TMP_Text)TabWarehouseLabel).text = string.Format("{0} ({1})", ModLocalization.Get("tab.warehouse"), hubSnapshot.Warehouse.Count); ((TMP_Text)TabMarketLabel).text = ModLocalization.Get("tab.market"); string text = (hubSnapshot.BlackMarketUnlocked ? ModLocalization.Get("tab.open_tag") : ModLocalization.Get("tab.locked_tag")); ((TMP_Text)TabBlackMarketLabel).text = ModLocalization.Get("tab.blackmarket") + " " + text; int num3 = Math.Clamp(hubSnapshot.Expeditions?.EscalationLevel ?? 0, 0, 6); ((TMP_Text)TabExpeditionsLabel).text = ((num3 > 0) ? string.Format("{0} [+{1}]", ModLocalization.Get("tab.expeditions"), num3) : ModLocalization.Get("tab.expeditions")); TabWarehouseBtn.Configure(delegate { SwitchTab(TerminalTab.Warehouse); }, interactable: true, (_activeTab == TerminalTab.Warehouse) ? ColTabActive : ColTabInactive); TabMarketBtn.Configure(delegate { SwitchTab(TerminalTab.LiveMarket); }, interactable: true, (_activeTab == TerminalTab.LiveMarket) ? ColTabActive : ColTabInactive); TabBlackMarketBtn.Configure(delegate { SwitchTab(TerminalTab.BlackMarket); }, interactable: true, (Color)((_activeTab != TerminalTab.BlackMarket) ? ColTabInactive : (hubSnapshot.BlackMarketUnlocked ? new Color(0.42f, 0.25f, 0.08f, 1f) : ColTabActive))); TabExpeditionsBtn.Configure(delegate { SwitchTab(TerminalTab.Expeditions); }, interactable: true, (Color)((_activeTab == TerminalTab.Expeditions) ? new Color(0.14f, 0.34f, 0.48f, 1f) : ColTabInactive)); WarehousePanel.SetActive(_activeTab == TerminalTab.Warehouse); MarketPanel.SetActive(_activeTab == TerminalTab.LiveMarket); BlackMarketPanel.SetActive(_activeTab == TerminalTab.BlackMarket); ExpeditionsPanel.SetActive(_activeTab == TerminalTab.Expeditions); RefreshWarehouseTab(hubSnapshot, num, totalWarehouseSellValueDollars, flag); RefreshMarketTab(hubSnapshot, flag); RefreshBlackMarketTab(hubSnapshot, num, flag); RefreshExpeditionsTab(hubSnapshot, num, flag); RefreshHackOverlay(); RefreshHackResultOverlay(hubSnapshot, flag); RefreshOverheadBoard(hubSnapshot, flag); ((TMP_Text)FooterHintText).text = (flag ? ("Тап [E/ЛКМ] | Скролл <color=#5CCAE0>" + Plugin.BuildTag + "</color>") : ("Tap [E/LMB] | Scroll <color=#5CCAE0>" + Plugin.BuildTag + "</color>")); if (hubSnapshot.Ticker.Count > 0) { TickerEntry tickerEntry = hubSnapshot.Ticker[0]; ((TMP_Text)FooterTickerText).text = "* " + (flag ? tickerEntry.MessageRu : tickerEntry.MessageEn); } else { ((TMP_Text)FooterTickerText).text = "* ..."; } } } private void RefreshWarehouseTab(HubSnapshot state, int cashK, int stockValueDollars, bool isRu) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0313: 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_0350: 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_038d: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_08c2: Unknown result type (might be due to invalid IL or missing references) //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_0860: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0959: Unknown result type (might be due to invalid IL or missing references) //IL_0de6: Unknown result type (might be due to invalid IL or missing references) //IL_0dce: Unknown result type (might be due to invalid IL or missing references) //IL_0dc7: Unknown result type (might be due to invalid IL or missing references) //IL_0dac: Unknown result type (might be due to invalid IL or missing references) //IL_0e90: Unknown result type (might be due to invalid IL or missing references) //IL_0eab: Unknown result type (might be due to invalid IL or missing references) //IL_0ec6: Unknown result type (might be due to invalid IL or missing references) //IL_0e42: Unknown result type (might be due to invalid IL or missing references) //IL_0e5d: Unknown result type (might be due to invalid IL or missing references) //IL_0e78: Unknown result type (might be due to invalid IL or missing references) //IL_0d91: Unknown result type (might be due to invalid IL or missing references) //IL_0d76: Unknown result type (might be due to invalid IL or missing references) //IL_0d58: Unknown result type (might be due to invalid IL or missing references) //IL_0f11: Unknown result type (might be due to invalid IL or missing references) //IL_0f84: Unknown result type (might be due to invalid IL or missing references) //IL_0f7d: Unknown result type (might be due to invalid IL or missing references) //IL_100e: Unknown result type (might be due to invalid IL or missing references) if (_activeTab != TerminalTab.Warehouse) { return; } List<WarehouseItem> sortedWarehouseItems = MarketManager.Instance.GetSortedWarehouseItems(_warehouseSortMode); bool flag = !string.IsNullOrEmpty(state.ActiveHackItemId); int sellAllPayoutDollars = MarketManager.Instance.GetSellAllPayoutDollars(); ((TMP_Text)SellAllLabel).text = ModLocalization.Get("action.sell_all_bulk") + " (+" + MarketManager.FormatDollars(sellAllPayoutDollars) + ")"; SellAllBtn.Configure(delegate { MarketSync.Instance.SendToMaster(MarketNetOp.RequestSellAll); }, sellAllPayoutDollars > 0 && !flag); var (num, dollars) = MarketManager.Instance.GetSellProfitablePayoutInfo(); ((TMP_Text)SellProfitLabel).text = ((num > 0) ? string.Format("{0} ({1}) +{2}", ModLocalization.Get("action.sell_profitable"), num, MarketManager.FormatDollars(dollars)) : (ModLocalization.Get("action.sell_profitable") + " (0)")); SellProfitBtn.Configure(delegate { MarketSync.Instance.SendToMaster(MarketNetOp.RequestSellProfitable); }, num > 0 && !flag, ColSellNormal); int dollars2 = Math.Max(0, state.PendingDollars); ((TMP_Text)WarehouseScrollInfoText).text = $"<color=#FFD166>{MarketManager.FormatDollars(dollars2)}/$1K</color> | {sortedWarehouseItems.Count}"; ((TMP_Text)WarehouseScrollUpLabel).text = "▲"; ((TMP_Text)WarehouseScrollDownLabel).text = "▼"; WarehouseScrollUpBtn.Configure(delegate { AdjustActiveScroll(-178f); }, _warehouseScrollY > 1f); WarehouseScrollDownBtn.Configure(delegate { AdjustActiveScroll(178f); }, _warehouseScrollY < _warehouseMaxScrollY - 1f); int num2 = sortedWarehouseItems.Count((WarehouseItem x) => x.IsHackable && x.HackStatus == HackStatus.Unhacked); ((TMP_Text)SortDefaultLabel).text = ModLocalization.Get("sort.default"); ((TMP_Text)SortCoeffLabel).text = ModLocalization.Get("sort.coeff"); ((TMP_Text)SortPriceLabel).text = ModLocalization.Get("sort.price"); ((TMP_Text)SortHackLabel).text = string.Format("{0} ({1})", ModLocalization.Get("sort.hackable"), num2); SortDefaultBtn.Configure(delegate { SwitchWarehouseSort(WarehouseSortMode.Default); }, interactable: true, (_warehouseSortMode == WarehouseSortMode.Default) ? ColTabActive : ColTabInactive); SortCoeffBtn.Configure(delegate { SwitchWarehouseSort(WarehouseSortMode.CoeffDesc); }, interactable: true, (_warehouseSortMode == WarehouseSortMode.CoeffDesc) ? ColTabActive : ColTabInactive); SortPriceBtn.Configure(delegate { SwitchWarehouseSort(WarehouseSortMode.PriceDesc); }, interactable: true, (_warehouseSortMode == WarehouseSortMode.PriceDesc) ? ColTabActive : ColTabInactive); SortHackBtn.Configure(delegate { SwitchWarehouseSort(WarehouseSortMode.HackableFirst); }, interactable: true, (_warehouseSortMode == WarehouseSortMode.HackableFirst) ? ColTabActive : ColTabInactive); List<string> list = new List<string>(); int num3 = 0; for (int num4 = 0; num4 < sortedWarehouseItems.Count; num4++) { WarehouseItem warehouseItem = sortedWarehouseItems[num4]; if (!warehouseItem.IsSealedCryptoCase && warehouseItem.IsHackable && warehouseItem.HackStatus == HackStatus.Unhacked) { int hackCostK = MarketManager.Instance.GetHackCostK(warehouseItem); if (cashK - num3 >= hackCostK) { num3 += hackCostK; list.Add(warehouseItem.Id); } } } string text = string.Format("{0}|{1}|{2}", flag ? "1" : "0", string.Join(",", list), num3); if (_hackAllArmed) { if (flag || list.Count == 0 || (!string.IsNullOrEmpty(_armedCandidateSignature) && _armedCandidateSignature != text)) { DisarmHackAll(broadcastIfOwned: true); } else if (string.IsNullOrEmpty(_armedCandidateSignature)) { _armedCandidateSignature = text; } } bool canHackAll = !flag && list.Count > 0; if (_hackAllArmed && canHackAll) { ((TMP_Text)HackAllLabel).text = string.Format("{0} ({1}): -${2}K", ModLocalization.Get("action.hack_all_confirm"), list.Count, num3); } else { ((TMP_Text)HackAllLabel).text = ((list.Count > 0) ? string.Format("{0} ({1}): -${2}K", ModLocalization.Get("action.hack_all"), list.Count, num3) : (ModLocalization.Get("action.hack_all") + " (0)")); } string capturedBatchPayload = string.Join(",", list); string capturedSig = text; HackAllBtn.Configure(delegate { if (canHackAll) { if (!_hackAllArmed) { _hackAllArmed = true; _hackAllArmExpiresAt = Time.unscaledTime + 4.5f; _localOwnsHackAllArm = true; _armedCandidateSignature = capturedSig; RefreshAll(); BroadcastUiState(UiSyncMask.Pointer | UiSyncMask.HackAllArm, reliable: true); } else { _hackAllArmed = false; _hackAllArmExpiresAt = 0f; _localOwnsHackAllArm = false; _armedCandidateSignature = string.Empty; BroadcastUiState(UiSyncMask.Pointer | UiSyncMask.HackAllArm, reliable: true); MarketSync.Instance.SendToMaster(MarketNetOp.RequestHackAll, capturedBatchPayload); RefreshAll(); } } }, canHackAll, (Color)((_hackAllArmed && canHackAll) ? new Color(0.72f, 0.22f, 0.08f, 1f) : ColHackNormal)); ((TMP_Text)WarehouseEmptyText).text = ModLocalization.Get("warehouse.empty"); ((Component)WarehouseEmptyText).gameObject.SetActive(sortedWarehouseItems.Count == 0); while (WarehouseCards.Count < sortedWarehouseItems.Count) { WarehouseCards.Add(ShopTerminalBuilder.CreateWarehouseCard(this, WarehouseContent, WarehouseCards.Count)); } ApplyFonts(); int num5 = Mathf.CeilToInt((float)sortedWarehouseItems.Count / 2f); float num6 = Mathf.Max(410f, (float)num5 * 180f + 8f); WarehouseContent.sizeDelta = new Vector2(1