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.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using CryptoMod; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.Avatar; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.Core.Avatar; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Levelling; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.Persistence.Datas; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.State; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Compass; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.Messages; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: MelonInfo(typeof(Core), "Crypto Trader", "1.1.2", "WykwintnyBocian", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : System.Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class NullableAttribute : System.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(/*Could not decode attribute arguments.*/)] internal sealed class NullableContextAttribute : System.Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class RefSafetyRulesAttribute : System.Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CryptoMod { public struct ComputerInfo { public int Id; public Vector3 Position; public float Yaw; public string Property; public bool InUse; } public static class CryptoTraderApi { public const string Version = "1.1.2"; private static Core C => Core.Instance; public static bool IsReady => C != null && C.ApiReady; public static string SaveFolder => (C != null) ? C.ApiSaveFolder : null; public static int ComputerCount => IsReady ? C.ApiComputers().Count : 0; public static bool IsPlacingComputer => IsReady && C.ApiPlacing; public static bool IsUsingComputer => IsReady && C.ApiUsing; public static string[] CoinSymbols => (C != null) ? C.ApiSymbols() : new string[0]; public static bool EventsEnabled { get { return C != null && C.ApiEventsOn; } set { if (C != null) { C.ApiEventsOn = value; } } } public static string[] PartIds { get { Hardware.Init(); return Hardware.All.ConvertAll((Converter)((PartDef d) => d.Id)).ToArray(); } } public static float MiningSpeed { get { return (C != null) ? C.MiningSpeed : 1f; } set { if (C != null) { C.MiningSpeed = Mathf.Clamp(value, 1f, 1000f); } } } public static float MinedWalletUsd => IsReady ? C.ApiWalletUsd() : 0f; public static Vector3 HeldBoxOffset { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Core.HeldOffset; } set { //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) Core.HeldOffset = value; } } public static float HeldBoxPitch { get { return Core.HeldPitch; } set { Core.HeldPitch = value; } } public static float HeldBoxYaw { get { return Core.HeldYaw; } set { Core.HeldYaw = value; } } public static string MeetingState => (C != null) ? C.ApiMeetState() : "mod not loaded"; public static int MeetSpotCount => Core.MeetSpots.Count; public static string ByteChatState => (C != null) ? C.ApiByteState() : "mod not loaded"; public static string SupplierName => "Byte"; public static bool IsSupplierSpawned => C != null && C.SupplierSpawned; public static string SupplierLog => (C != null) ? C.SupplierLog : ""; public static Texture2D SupplierPortrait { get { Sprite val = ((C != null) ? C.SupplierPicture() : null); return ((Object)(object)val != (Object)null) ? val.texture : null; } } public static bool HasSupplierPhoto => C != null && C.HasSupplierPhoto; public static bool SupplierPhotoBusy => C != null && C.SupplierPhotoBusy; public static float PhotoDistance { get { return Core.PhotoDistance; } set { Core.PhotoDistance = Mathf.Clamp(value, 0.5f, 3f); } } public static float PhotoFov { get { return Core.PhotoFov; } set { Core.PhotoFov = Mathf.Clamp(value, 8f, 40f); } } public static float PhotoYaw { get { return Core.PhotoYaw; } set { Core.PhotoYaw = Mathf.Clamp(value, -60f, 60f); } } public static float PhotoLift { get { return Core.PhotoLift; } set { Core.PhotoLift = Mathf.Clamp(value, -0.3f, 0.3f); } } public static float PhotoLight { get { return Core.PhotoLight; } set { Core.PhotoLight = Mathf.Clamp(value, 0f, 8f); } } public static string[] SupplierOutfitSlots => Core.SupSlots; public static string[] SupplierColorNames => Core.SupColorNames; public static string[] SupplierSkinNames => Core.SupSkinNames; public static int SupplierSkin { get { return (C != null) ? C.SupSkin : 0; } set { if (C != null) { int num = Core.SupSkinNames.Length; C.SupSkin = (value % num + num) % num; } } } public static float SupplierBuild { get { return (C != null) ? C.SupWeight : 0f; } set { if (C != null) { C.SupWeight = Mathf.Clamp01(value); } } } public static string SupplierLook { get { return (C != null) ? C.SupLookString() : ""; } set { if (C != null) { C.SupLoadLookString(value); } } } public static List GetComputers() { return IsReady ? C.ApiComputers() : new List(); } public static bool StartPlacingComputer() { return IsReady && C.ApiStartPlacing(); } public static bool MoveComputer(int id) { return IsReady && C.ApiMove(id); } public static bool OpenComputer(int id) { return IsReady && C.ApiOpen(id); } public static bool RemoveComputer(int id) { return IsReady && C.ApiRemove(id); } public static int RemoveAllComputers() { return IsReady ? C.ApiRemoveAll() : 0; } public static void RebuildComputerModels() { if (IsReady) { C.ApiRebuildModels(); } } public static float GetPrice(string symbol) { return (C != null) ? C.ApiPrice(symbol) : 0f; } public static float GetOwned(string symbol) { return IsReady ? C.ApiOwned(symbol) : 0f; } public static bool GiveCoins(string symbol, float units) { return IsReady && C.ApiGive(symbol, units); } public static bool TriggerMarketEvent() { return IsReady && C.ApiEvent(); } public static void FastForwardMarket(int minutes) { if (IsReady) { C.ApiFastForward(minutes); } } public static string PartName(string id) { PartDef partDef = Hardware.Get(id); return (partDef != null) ? partDef.Name : id; } public static string PartKindName(string id) { PartDef partDef = Hardware.Get(id); return (partDef != null) ? Hardware.KindName(partDef.Kind) : ""; } public static Texture2D PartIcon(string id) { PartDef partDef = Hardware.Get(id); Sprite val = ((partDef != null) ? Hardware.Icon(partDef) : null); return ((Object)(object)val != (Object)null) ? val.texture : null; } public static void GivePart(string id, int count) { if (IsReady) { C.ApiGivePart(id, count); } } public static int PartsBoxCount(string id) { return IsReady ? C.ApiBoxCount(id) : 0; } public static void ClearPartsBox() { if (IsReady) { C.ApiClearBox(); } } public static void SimulateMining(int minutes) { if (IsReady) { C.ApiSimulateMining(minutes); } } public static string GetRigSummary(int computerId) { return IsReady ? C.ApiRigSummary(computerId) : ""; } public static void MeetNow(int spot) { if (C != null) { C.ApiMeetNow(spot); } } public static void CancelMeeting() { if (C != null) { C.ApiMeetCancel(); } } public static Vector3 GetMeetSpot(int i) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) return (i >= 0 && i < Core.MeetSpots.Count) ? Core.MeetSpots[i].Pos : Vector3.zero; } public static float GetMeetSpotYaw(int i) { return (i >= 0 && i < Core.MeetSpots.Count) ? Core.MeetSpots[i].Yaw : 0f; } public static void AddMeetSpotHere() { Core.ApiAddSpotHere(); } public static void RemoveMeetSpot(int i) { if (C != null) { C.ApiRemoveSpot(i); } } public static bool TeleportToMeetSpot(int i) { return Core.ApiTeleportToSpot(i); } public static bool SaveMeetSpots() { return Core.SaveMeetSpots(); } public static void ResetMeetSpots() { Core.ResetMeetSpots(); } public static bool GiveComputerBox() { return C != null && C.InvGive("pc"); } public static void ByteTextNow() { if (C != null) { C.ApiByteTextNow(); } } public static void ByteRestartChat() { if (C != null) { C.ApiByteRestart(); } } public static bool SpawnSupplier(Vector3 feet, float yaw) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return IsReady && C.SpawnSupplier(feet, yaw); } public static void DespawnSupplier() { if (C != null) { C.DespawnSupplier(); } } public static void RetakeSupplierPhoto() { if (IsReady) { C.EnsureSupplierPhoto(force: true); } } public static bool SavePhotoCameraAsDefault() { return Core.SavePhotoSettings(); } public static void ResetPhotoCamera() { Core.ResetPhotoSettings(); } public static string[] GetSupplierOutfitOptions(int slot) { return (slot >= 0 && slot < Core.SupOptions.Length) ? Core.SupOptions[slot] : new string[0]; } public static int GetSupplierOutfit(int slot) { return (C != null && slot >= 0 && slot < C.SupPick.Length) ? C.SupPick[slot] : 0; } public static void SetSupplierOutfit(int slot, int option) { if (C != null && slot >= 0 && slot < C.SupPick.Length) { int num = Core.SupOptions[slot].Length; C.SupPick[slot] = (option % num + num) % num; } } public static int GetSupplierColor(int slot) { return (C != null && slot >= 0 && slot < C.SupColor.Length) ? C.SupColor[slot] : 0; } public static void SetSupplierColor(int slot, int color) { if (C != null && slot >= 0 && slot < C.SupColor.Length) { int num = Core.SupColorNames.Length; C.SupColor[slot] = (color % num + num) % num; } } public static float GetBankBalance() { return IsReady ? C.ApiBalance() : 0f; } public static void AddBankMoney(float amount, string note) { if (IsReady) { C.ApiAddMoney(amount, note); } } } public class Core : MelonMod { internal enum ByteStage { NotMet, Asking, Ignored, Closing, Introduced } private struct ByteLine { public bool Player; public string Text; public bool End; } private class MarketCard { public GameObject root; public Image bg; public Image bar; public Image icon; public Image star; public Text letter; public Text sym; public Text name; public Text price; public Text ch1; public Text ch24; public LineGraphic spark; public float[] buf = new float[40]; } private class MarketRow { public GameObject root; public Image bg; public Image icon; public Image star; public Text letter; public Text name; public Text sym; public Text price; public Text c24; public Text c7; public LineGraphic spark; public float[] buf = new float[32]; } internal struct MeetSpot { public Vector3 Pos; public float Yaw; public MeetSpot(float x, float y, float z, float yaw) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Pos = new Vector3(x, y, z); Yaw = yaw; } } private class RigState { public string[] Gpu = new string[4]; public string Cpu; public string[] Asic = new string[2]; public string Psu; public string Cooler; public string[] Ram = new string[2]; public string Board; public string Ssd; public string Hdd; public string[] Fans = new string[10]; public bool On; public string ShaCoin = "BTC"; public string ScryptCoin = "LTC"; public float Temp = 26f; public bool Cooldown; public float TotalUsd; public float PowerUsd; public long UptimeMin; public float[] Hour = new float[24]; public int HourSlot = -1; public RigStatus Status; public float Throttle = 1f; public float CaseLoad; public float WallWatts; public float UsdPerDay; public float CostPerDay; public bool CaseRunning; } private class PcData { public int Id; public Vector3 Pos; public float Yaw; public GameObject Root; public InteractableObject Io; public Transform CamPoint; public Canvas Screen; public GraphicRaycaster Raycaster; public Collider[] Cols; public GameObject LockLayer; public GameObject DesktopLayer; public GameObject Window; public GameObject PowerMenu; public Text LockClock; public Text LockDate; public Text TopClock; public Text WinTitle; public Text PickLabel; public Text WidgetTitle; public Text WidgetSub; public Image WidgetBar; public Image WinIcon; public float PickArm; public RigState Rig; public RectTransform WinContent; public Action WinRefresh; public int WinApp = -1; public int BoxPage; public int SelSlot = -1; public string SelBox; public Text WinMsg; public float WinMsgTimer; public RectTransform InsideRoot; public GameObject[] AsicObj; public PcCase3D Case; public List Chair; public Image WinBg; public Image WinMsgBg; public Text LockStatus; public Action DeskRefresh; public Action DeskAnim; public Action AppAnim; public List Log; public float[] TempHist; public float[] WattHist; public int HistTick; public int TempState; public int WalletSel = -1; public long LastShareMin; public List AppOwned = new List(); } private class Tween { public float T; public float Dur; public Action Step; public Action Done; } private class BuildLabel { public RectTransform Box; public RectTransform Line; public RectTransform Dot; public RectTransform Ring; public Image BoxImg; public Image Icon; public Image LineImg; public Image DotImg; public Image RingImg; public Text State; public Text Name; public RectTransform[] Edge; } private struct LabelInfo { public Vector3 World; public bool Fit; public string State; public string Name; public Sprite Icon; } private class CtmObj { public string Name; public Vector3 Pivot; public Mesh Mesh; public string[] Mats; } private class PcCase3D { public Transform Root; public Transform Interior; public readonly Dictionary Parts = new Dictionary(); public readonly List Rotors = new List(); public readonly List RotorAxis = new List(); public Transform Board; public string BoardId; public readonly Transform[] Fan = (Transform[])(object)new Transform[10]; public readonly string[] FanId = new string[10]; public readonly Transform[] Vis = (Transform[])(object)new Transform[24]; public readonly string[] VisId = new string[24]; public Vector3 BasePos; public Collider Use; public bool InteriorOn = true; } private class KitPart { public string Name; public Mesh Mesh; public Material[] Mats; public Matrix4x4 M; } private enum GlowKind { Outline, Solid, Fan, Dot, Interior } private class KitGlow { public string Name; public Vector3 Pos; public Quaternion Rot; public Vector2 Size; public GlowKind Kind; public Color Col; } private class PcKit { public readonly List Parts = new List(); public readonly List Glows = new List(); public Vector3 CamPos; public Vector3 ScrPos; public Vector3 ScrPivot; public Vector3 PromptPos; public Quaternion CamRot; public Quaternion ScrRot; public Vector2 ScrSize; public Vector3 ScrScale; public Bounds Desk; public Bounds Chair; public Bounds All; public Bounds Computer; public bool HasChair; public float TableTop; public Mesh Cube; public Mesh Cylinder; public int UseLayer; public bool WoodFromGame; public Material AsicMat; public Material AsicDark; public int ChairStart = -1; public bool Case3D; public bool Alive() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (Parts.Count == 0 || (Object)(object)Cube == (Object)null || (Object)(object)Cylinder == (Object)null) { return false; } Enumerator enumerator = Parts.GetEnumerator(); try { while (enumerator.MoveNext()) { KitPart current = enumerator.Current; if ((Object)(object)current.Mesh == (Object)null || current.Mats == null || (Object)(object)current.Mats[0] == (Object)null) { return false; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return true; } } private class HoldRow { public GameObject root; public Image icon; public Text letter; public Text sym; public Text val; public RectTransform fill; public int coin = -1; } private class FavRow { public GameObject root; public Image icon; public Text letter; public Text name; public Text sym; public Text price; public Text chg; public LineGraphic spark; public float[] buf = new float[40]; public int coin = -1; } private class ShopItem { public string Id; public string Name; public string Sub; public int Tier; public float Price; public Sprite Icon; public int Tab; } [CompilerGenerated] private sealed class d__1071 : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.IDisposable, System.Collections.IEnumerator { private int <>1__state; private string <>2__current; private int <>l__initialThreadId; private RigState r; public RigState <>3__r; private string[] <>s__1; private int <>s__2; private string 5__3; string System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1071(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = r.Board; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = r.Ssd; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = r.Hdd; <>1__state = 3; return true; case 3: <>1__state = -1; <>s__1 = r.Fans; <>s__2 = 0; break; case 4: <>1__state = -1; 5__3 = null; <>s__2++; break; } if (<>s__2 < <>s__1.Length) { 5__3 = <>s__1[<>s__2]; <>2__current = 5__3; <>1__state = 4; return true; } <>s__1 = null; return false; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { d__1071 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__1071(0); } d__.r = <>3__r; return d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__673 : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator, System.IDisposable, System.Collections.IEnumerator { private int <>1__state; private PartDef <>2__current; private int <>l__initialThreadId; private RigState r; public RigState <>3__r; private PartDef 5__1; private string[] <>s__2; private int <>s__3; private string 5__4; private PartDef 5__5; private string[] <>s__6; private int <>s__7; private string 5__8; private PartDef 5__9; PartDef System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__673(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__2 = r.Gpu; <>s__3 = 0; goto IL_00bd; case 1: <>1__state = -1; goto IL_00a0; case 2: <>1__state = -1; goto IL_0113; case 3: { <>1__state = -1; goto IL_017c; } IL_00bd: if (<>s__3 < <>s__2.Length) { 5__4 = <>s__2[<>s__3]; 5__5 = Hardware.Get(5__4); if (5__5 != null) { <>2__current = 5__5; <>1__state = 1; return true; } goto IL_00a0; } <>s__2 = null; 5__1 = Hardware.Get(r.Cpu); if (5__1 != null) { <>2__current = 5__1; <>1__state = 2; return true; } goto IL_0113; IL_00a0: 5__5 = null; 5__4 = null; <>s__3++; goto IL_00bd; IL_017c: 5__9 = null; 5__8 = null; <>s__7++; goto IL_0199; IL_0113: <>s__6 = r.Ram; <>s__7 = 0; goto IL_0199; IL_0199: if (<>s__7 < <>s__6.Length) { 5__8 = <>s__6[<>s__7]; 5__9 = Hardware.Get(5__8); if (5__9 != null) { <>2__current = 5__9; <>1__state = 3; return true; } goto IL_017c; } <>s__6 = null; return false; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { d__673 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__673(0); } d__.r = <>3__r; return d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__404 : System.Collections.Generic.IEnumerator, System.IDisposable, System.Collections.IEnumerator { private int <>1__state; private object <>2__current; public bool applyToMarket; public Core <>4__this; private StringBuilder 5__1; private UnityWebRequest 5__2; private Enumerator <>s__3; private Coin 5__4; private string 5__5; private int 5__6; private string 5__7; private Enumerator <>s__8; private Coin 5__9; private Match 5__10; private float 5__11; private System.Exception 5__12; object System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__404(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = new StringBuilder(); <>s__3 = <>4__this.coins.GetEnumerator(); try { while (<>s__3.MoveNext()) { 5__4 = <>s__3.Current; if (5__1.Length > 0) { 5__1.Append(','); } 5__1.Append(5__4.GeckoId); 5__4 = null; } } finally { ((System.IDisposable)<>s__3/*cast due to .constrained prefix*/).Dispose(); } <>s__3 = default(Enumerator); 5__2 = UnityWebRequest.Get("https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=" + (object)5__1); 5__2.timeout = 12; 5__2.SetRequestHeader("Accept", "application/json"); <>2__current = 5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; try { if ((int)5__2.result != 1) { 5__5 = ((5__2.responseCode == 429) ? "rate limit reached, try again later" : (5__2.error ?? "no connection")); <>4__this.refStatus = (<>4__this.refLive ? "Using saved prices. " : "Using built-in prices. ") + "Download failed: " + 5__5; ((MelonBase)<>4__this).LoggerInstance.Msg("Reference prices not updated (" + 5__5 + ")."); 5__5 = null; } else { 5__6 = 0; 5__7 = 5__2.downloadHandler.text ?? ""; <>s__8 = <>4__this.coins.GetEnumerator(); try { while (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; 5__10 = Regex.Match(5__7, "\"" + Regex.Escape(5__9.GeckoId) + "\"\\s*:\\s*\\{\\s*\"usd\"\\s*:\\s*([0-9eE\\.\\-\\+]+)"); if (((Group)5__10).Success && float.TryParse(((Capture)5__10.Groups[1]).Value, (NumberStyles)167, (IFormatProvider)(object)Inv, ref 5__11) && 5__11 > 0f) { <>4__this.refPrices[5__9.Symbol] = 5__11; 5__6++; } 5__10 = null; 5__9 = null; } } finally { ((System.IDisposable)<>s__8/*cast due to .constrained prefix*/).Dispose(); } <>s__8 = default(Enumerator); if (5__6 > 0) { <>4__this.refFetched = System.DateTime.UtcNow; <>4__this.refLive = true; <>4__this.SaveRefCache(); <>4__this.refStatus = string.Concat(new string[5] { "CoinGecko prices from ", <>4__this.refFetched.ToLocalTime().ToString("dd MMM HH:mm", (IFormatProvider)(object)Inv), " (", 5__6.ToString(), " coins)" }); ((MelonBase)<>4__this).LoggerInstance.Msg("Downloaded real-world reference prices for " + 5__6 + " coins."); if (applyToMarket && <>4__this.sessionLoaded) { <>4__this.ApplyReferenceToMarket(); } } else { <>4__this.refStatus = "Download returned no prices, keeping current ones"; } 5__7 = null; } } catch (System.Exception ex) { 5__12 = ex; <>4__this.refStatus = "Price download failed"; ((MelonBase)<>4__this).LoggerInstance.Warning("Reference price download failed: " + 5__12.Message); } finally { <>4__this.refFetching = false; 5__2.Dispose(); <>4__this.forceRefresh = true; } return false; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1334 : System.Collections.Generic.IEnumerator, System.IDisposable, System.Collections.IEnumerator { private int <>1__state; private object <>2__current; public Core <>4__this; private GameObject 5__1; private GameObject 5__2; private RenderTexture 5__3; private StringBuilder 5__4; private int 5__5; private Avatar 5__6; private float 5__7; private Texture2D 5__8; private string 5__9; private System.Exception 5__10; private Transform 5__11; private Vector3 5__12; private Vector3 5__13; private Camera 5__14; private RenderTexture 5__15; private Texture2D 5__16; private Animator 5__17; private System.Exception 5__18; private System.Exception 5__19; object System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1334(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void System.IDisposable.Dispose() { } private bool MoveNext() { //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_0799: 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_0043: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Expected O, but got Unknown //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Expected O, but got Unknown //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = new StringBuilder(); try { 5__1 = <>4__this.BuildSupplierBody(PhotoSpot, 0f, 5__4); } catch (System.Exception ex) { 5__10 = ex; 5__4.Append(5__10.Message); } if ((Object)(object)5__1 == (Object)null) { ((MelonBase)<>4__this).LoggerInstance.Warning("Byte's photo: no character to copy yet. " + ((object)5__4).ToString().Replace("\n", " ")); <>4__this.supplierPhotoBusy = false; return false; } ((Object)5__1).name = "CryptoTrader_BytePhoto"; 5__5 = LayerMask.NameToLayer("RuntimePreviewGeneration"); if (5__5 < 0) { 5__5 = 31; } 5__6 = 5__1.GetComponent(); KeepAwake(5__6, 5__1); SetLayer(5__1, 5__5); 5__7 = Time.realtimeSinceStartup + 0.7f; break; case 1: <>1__state = -1; if ((Object)(object)5__1 == (Object)null) { <>4__this.supplierPhotoBusy = false; return false; } KeepAwake(5__6, 5__1); SetLayer(5__1, 5__5); break; } if (Time.realtimeSinceStartup < 5__7) { <>2__current = null; <>1__state = 1; return true; } KeepAwake(5__6, 5__1); 5__8 = null; try { 5__11 = null; try { if ((Object)(object)5__6 != (Object)null && (Object)(object)5__6.LookController != (Object)null) { 5__11 = 5__6.LookController.HeadBone; } } catch { } if ((Object)(object)5__11 == (Object)null) { 5__17 = 5__1.GetComponentInChildren(); if ((Object)(object)5__17 != (Object)null && 5__17.isHuman) { 5__11 = 5__17.GetBoneTransform((HumanBodyBones)10); } 5__17 = null; } if ((Object)(object)5__11 != (Object)null) { 5__12 = 5__11.position + Vector3.up * PhotoLift; } else { 5__12 = PhotoSpot + Vector3.up * 1.65f; } 5__13 = Quaternion.Euler(0f, PhotoYaw, 0f) * 5__1.transform.forward; 5__2 = new GameObject("CryptoTrader_PhotoRig"); 5__2.transform.position = 5__12 + 5__13 * PhotoDistance + Vector3.up * 0.02f; 5__2.transform.LookAt(5__12); 5__14 = 5__2.AddComponent(); ((Behaviour)5__14).enabled = false; 5__14.cullingMask = 1 << 5__5; 5__14.clearFlags = (CameraClearFlags)2; 5__14.backgroundColor = new Color(1f, 0f, 1f, 0f); 5__14.fieldOfView = PhotoFov; 5__14.nearClipPlane = 0.05f; 5__14.farClipPlane = 10f; 5__14.allowHDR = false; 5__14.allowMSAA = false; AddPhotoLight(5__2.transform, new Vector3(-0.7f, 0.5f, 0.2f), PhotoLight, 5__5); AddPhotoLight(5__2.transform, new Vector3(0.8f, 0.1f, 0.1f), PhotoLight * 0.45f, 5__5); AddPhotoLight(5__2.transform, new Vector3(0f, 0.9f, -1.6f), PhotoLight * 0.35f, 5__5); 5__3 = new RenderTexture(1024, 1024, 24, (RenderTextureFormat)0); 5__3.antiAliasing = 1; 5__3.Create(); 5__14.targetTexture = 5__3; 5__14.Render(); 5__15 = RenderTexture.active; RenderTexture.active = 5__3; 5__16 = new Texture2D(1024, 1024, (TextureFormat)4, false); 5__16.ReadPixels(new Rect(0f, 0f, 1024f, 1024f), 0, 0); 5__16.Apply(); RenderTexture.active = 5__15; 5__14.targetTexture = null; 5__8 = Downsample(5__16, 512); Object.Destroy((Object)(object)5__16); 5__11 = null; 5__12 = default(Vector3); 5__13 = default(Vector3); 5__14 = null; 5__15 = null; 5__16 = null; } catch (System.Exception ex) { 5__18 = ex; ((MelonBase)<>4__this).LoggerInstance.Warning("Byte's photo failed: " + 5__18.Message); } if ((Object)(object)5__2 != (Object)null) { Object.Destroy((Object)(object)5__2); } if ((Object)(object)5__1 != (Object)null) { Object.Destroy((Object)(object)5__1); } if ((Object)(object)5__3 != (Object)null) { 5__3.Release(); Object.Destroy((Object)(object)5__3); } <>4__this.supplierPhotoBusy = false; 5__9 = <>4__this.PhotoKey; if ((Object)(object)5__8 == (Object)null || IsEmptyPhoto(5__8)) { ((MelonBase)<>4__this).LoggerInstance.Warning("Byte's photo came out empty; keeping the drawn picture."); return false; } try { File.WriteAllBytes(PhotoFile, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)ImageConversion.EncodeToPNG(5__8))); File.WriteAllText(PhotoKeyFile, 5__9); } catch (System.Exception ex) { 5__19 = ex; ((MelonBase)<>4__this).LoggerInstance.Warning("Could not keep Byte's photo: " + 5__19.Message); } ((Texture)5__8).wrapMode = (TextureWrapMode)1; <>4__this.supplierPhoto = Sprite.Create(5__8, new Rect(0f, 0f, (float)((Texture)5__8).width, (float)((Texture)5__8).height), new Vector2(0.5f, 0.5f), 100f); <>4__this.photoKeyInUse = 5__9; <>4__this.photoCheckedKey = 5__9; ((MelonBase)<>4__this).LoggerInstance.Msg("Byte's photo taken (" + PhotoFile + ")."); try { if (<>4__this.SupplierPhotoChanged != null) { <>4__this.SupplierPhotoChanged.Invoke(); } } catch { } return false; } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } } public const string ModVersion = "1.1.2"; private const string ByteConvId = "cryptotrader_byte"; private const int ByteLogMax = 30; private ByteStage byteStage = ByteStage.NotMet; private bool byteKnown; private bool byteRead = true; private long byteNextMin = -1L; private readonly List byteLog = new List(); private MSGConversation byteConv; private SendableMessage byteSendable; private readonly List> byteQueue = new List>(); private float byteQueueClock; private float byteRetry; private bool byteForce; private const int ByteFirstDelayMin = 15; private const float ByteUnlockSpent = 300f; private float cryptoSpent = -1f; private float byteUnlockCheck; private bool byteUnlocked; private const int ByteRetryDelayMin = 1440; private float bytePhotoRetry = 30f; private Quest meetQuest; private float meetQuestTimer; private string meetQuestTitle = "Meet Byte"; private const string MeetQuestName = "CryptoTrader_MeetByteQuest"; public static Core Instance; public const int MaxPoints = 20160; public const int Pts1H = 60; public const int Pts24H = 1440; public const int Pts7D = 10080; private const int StripCards = 3; private const int PortRows = 6; private const int HistRows = 9; private const int MarketRows = 9; private const int MaxCatchUp = 2880; private const float FontScale = 1f; private const int EventCooldown = 360; private const float EventMeanExtra = 1960f; private const int EventMaxGap = 5760; private const int EventsPerDayMax = 2; public const string SaveFileName = "CryptoTrader.txt"; private const string GeckoUrl = "https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids="; private const double RefCacheHours = 12.0; private static readonly Color cBg = new Color(0.031f, 0.035f, 0.047f, 1f); private static readonly Color cPanel = new Color(0.11f, 0.122f, 0.153f, 1f); private static readonly Color cPanel2 = new Color(0.078f, 0.086f, 0.11f, 1f); private static readonly Color cRowSel = new Color(0.09f, 0.15f, 0.25f, 1f); private static readonly Color cBorder = new Color(1f, 1f, 1f, 0.09f); private static readonly Color cAccent = new Color(0.122f, 0.561f, 1f, 1f); private static readonly Color cAccentSoft = new Color(0.122f, 0.561f, 1f, 0.22f); private static readonly Color cText = new Color(0.97f, 0.97f, 1f, 1f); private static readonly Color cDim = new Color(0.541f, 0.588f, 0.698f, 1f); private static readonly Color cUp = new Color(0.184f, 0.827f, 0.541f, 1f); private static readonly Color cDown = new Color(1f, 0.361f, 0.424f, 1f); private static readonly Color cGold = new Color(1f, 0.83f, 0.3f, 1f); private static readonly Color cBuy = new Color(0.122f, 0.561f, 1f, 1f); private static readonly Color cSell = new Color(0.78f, 0.25f, 0.31f, 1f); private static readonly Color cCardBlue = new Color(0.36f, 0.78f, 1f, 1f); private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; private const int PDash = 0; private const int PMarket = 1; private const int PPort = 2; private const int PHist = 3; private const int PSet = 4; private const int PHome = 5; private static readonly string[] PageNames = new string[6] { "Coin", "Market", "Wallet", "History", "Settings", "Home" }; private readonly List coins = new List(); private readonly List history = new List(); private readonly List news = new List(); private readonly int[] rigCount = new int[3]; private float[] pending; private float minedUsd; private float realized; private int mineCoin; private string currentSavePath; private bool sessionLoaded; private string pendingSnapshot; private string pendingSnapshotPath; private bool saveHooks; private static bool cleanupPatched; private readonly List favs = new List(); private bool candleMode; private bool eventsOn = true; private readonly Dictionary refPrices = new Dictionary(); private System.DateTime refFetched = System.DateTime.MinValue; private bool refLive; private bool refFetching; private string refStatus = "Built-in reference prices"; private System.Type timeType; private int lastDaily = -1; private long totalGameMin; private long nextEventMin = -1L; private long lastEventMin = -100000L; private long eventDayIdx = -1L; private int eventsToday; private int timeMode; private float timeFailTimer; private float realTickTimer; private bool lastEventWasCrash; private bool catchUpEventFired; private MethodInfo miTo24; private MethodInfo miTo12; private int sel; private int page; private int rangeSel = 1; private int stripScroll; private int histScroll; private int portScroll; private int marketScroll; private int unread; private int sortKey = 3; private int viewSpan = 1440; private int viewOffset; private bool sortDesc; private float panRemainder; private bool favOnly; private bool buyMode = true; private bool newsOpen; private string search = ""; private float qty; private float mQty; private float iconTimer; private float uiTimer; private float toastTimer; private float resetArm; private float flash; private float lastShownPrice; private float chartFade; private bool flashIsUp; private bool sparkDirty = true; private readonly List shown = new List(); private readonly List marketOrder = new List(); private GameObject appIcon; private GameObject appRoot; private RectTransform rootRT; private int refLayer; private bool isOpen; private bool uiBuilt; private bool exitRegistered; private bool forceRefresh; private bool chartDirty; private bool warnedOnce; private System.Type phoneType; private System.Type appsCanvasType; private Font uiFont; private Camera overlayCam; private Sprite iconSprite; private Sprite roundSprite; private float U = 5f; private float cornerMult = 1f; private float borderW = 1f; private Transform cp; private GameObject pageDash; private GameObject pageMarket; private GameObject pagePort; private GameObject pageHist; private GameObject pageSet; private GameObject newsPanel; private GameObject searchBox; private GameObject favBtnGo; private Image[] navBg; private Image[] navIcon; private Image[] navBar; private Text[] navLabel; private Text hdrTitle; private Text bellCount; private Image bellBadge; private Image favFilterImg; private Image toastBg; private Text toastText; private InputField searchField; private InputField qtyField; private InputField mQtyField; private MarketCard[] cards; private PointerZone stripZone; private PointerZone chartZone; private PointerZone histZone; private PointerZone portZone; private PointerZone marketZone; private Text stripEmpty; private Image ctIcon; private Image ctStarImg; private Image chartBg; private Image tagImg; private Image hoverTagImg; private Image sideBuyImg; private Image sideSellImg; private Image actionImg; private Image liveImg; private Text ctLetter; private Text ctName; private Text ctTicker; private Text ctPrice; private Text ctChange; private Text actionLabel; private Text totalTxt; private Text balTxt; private Text ownedTxt; private Text tipL1; private Text tipL2; private Text tipL3; private Text hoverTagText; private Image[] rangeImg = (Image[])(object)new Image[4]; private Image[] styleImg = (Image[])(object)new Image[2]; private Text[] yLabels = (Text[])(object)new Text[5]; private Text[] xLabels = (Text[])(object)new Text[5]; private LineGraphic line; private ChartGraphic candleChart; private RectTransform tagRT; private RectTransform tipRT; private RectTransform crossV; private RectTransform crossH; private RectTransform crossDot; private RectTransform hoverTagRT; private Text tagText; private readonly float[] lineBuf = new float[240]; private List viewCandles = new List(); private int vStart; private int vN; private int vBuckets; private float vLo; private float vHi; private int lastHoverKey = -2147483648; private MarketRow[] mRows; private Text[] sortLabels = (Text[])(object)new Text[5]; private Image[] sortArrows = (Image[])(object)new Image[5]; private Text mEmpty; private Text mCount; private Image mdIcon; private Image mdStar; private Text mdLetter; private Text mdName; private Text mdSym; private Text mdPrice; private Text mdOwned; private Text mdValue; private Text mdPl; private Text mdTotal; private Text[] mdChg = (Text[])(object)new Text[3]; private Image[] mdChgBg = (Image[])(object)new Image[3]; private LineGraphic mdSpark; private readonly float[] mdBuf = new float[96]; private Text rTotal; private Text rPl; private Text rCash; private Text rHold; private Text dCenter1; private Text dCenter2; private Text rNewsEmpty; private Image[] legDot = (Image[])(object)new Image[4]; private Text[] legSym = (Text[])(object)new Text[4]; private Text[] legPct = (Text[])(object)new Text[4]; private Image[] rNewsDot = (Image[])(object)new Image[3]; private Text[] rNewsTxt = (Text[])(object)new Text[3]; private Text[] rNewsTime = (Text[])(object)new Text[3]; private Image cardIcon0; private Text[] cardVal = (Text[])(object)new Text[4]; private Text[] cardSub = (Text[])(object)new Text[4]; private Text[] newsTexts; private Text[] newsTimes; private Image[] newsDots; private Text newsEmpty; private Text[] pCardVal = (Text[])(object)new Text[4]; private GameObject[] pRow = (GameObject[])(object)new GameObject[6]; private Image[] pIcon = (Image[])(object)new Image[6]; private Text[][] pTxt = new Text[6][]; private Text pEmpty; private Text pCount; private Image[] pRowBg = (Image[])(object)new Image[6]; private readonly List portOrder = new List(); private int portSel = -1; private float pSellQty; private InputField pSellField; private Image pSellIcon; private Text pSellName; private Text pSellOwned; private Text pSellTotal; private Text pSellHint; private Text pSellBtnLabel; private GameObject[] pSellParts; private Transform pSellPctRoot; private GameObject[] hRow = (GameObject[])(object)new GameObject[9]; private Image[] hKindBg = (Image[])(object)new Image[9]; private Text[][] hTxt = new Text[9][]; private Text hEmpty; private Image[] setStyleImg = (Image[])(object)new Image[2]; private Image[] setEvImg = (Image[])(object)new Image[2]; private Text resetLabel; private Text refLabel; private Button[] navBtn = (Button[])(object)new Button[5]; private readonly HashSet uiWarned = new HashSet(); private object hookedPhone; private Action closeAppsHandler; private Action closeAppsIl; private ExitDelegate exitIl; private System.Delegate exitDelegate; private const BindingFlags AnyInst = (BindingFlags)52; private const BindingFlags AnyStatic = (BindingFlags)56; private static readonly Dictionary memberCache = new Dictionary(); public const string ItemPrefix = "cryptotrader_"; private readonly Dictionary itemDefs = new Dictionary(); private GameObject boxEquipPrefab; private float itemCheckTimer; private bool itemsLogged; private bool itemsFailedLogged; private static Dictionary pkgSizes; private static readonly Dictionary pkgAtlas = new Dictionary(); private static readonly Dictionary pkgMats = new Dictionary(); private static readonly Dictionary pkgIcons = new Dictionary(); internal const string PcItemId = "pc"; internal const string PcItemName = "Mining Computer"; internal const float PcItemPrice = 950f; private StoredItem genericStored; private bool storedSearched; internal const float BoxGlow = 0.22f; private static readonly Dictionary modelMeshes = new Dictionary(); private static Mesh boxMesh; internal static Vector3 HeldOffset = new Vector3(0f, -0.26f, 0f); internal static float HeldPitch = 12f; internal static float HeldYaw = -14f; private Equippable heldEq; private HeldBoxView heldView; private bool heldWarned; private static readonly MeetSpot[] BuiltInSpots = new MeetSpot[7] { new MeetSpot(71.89f, -4.53f, 27.4f, 45f), new MeetSpot(92.02f, 5.22f, -129.59f, 359f), new MeetSpot(136.51f, 0.97f, 30.47f, 330f), new MeetSpot(-12.82f, -3.16f, 164.2f, 108f), new MeetSpot(-57.74f, -4.03f, 166.85f, 2f), new MeetSpot(-55.05f, -1.54f, -85.19f, 59f), new MeetSpot(-97.88f, -1.53f, -36.17f, 251f) }; internal static readonly List MeetSpots = new List((System.Collections.Generic.IEnumerable)BuiltInSpots); private static readonly Vector3 SewerSpot = new Vector3(71.85f, -4.53f, 27.37f); private const float SewerChance = 0.25f; private const int MeetLeadMin = 20; private const int MeetLeadMax = 40; private const int MeetWait = 120; private const int MeetEarly = 10; private const int CooldownAfterDeal = 180; private const int CooldownNoShow = 1440; private const int CooldownCancel = 360; private int meetStage; private int meetSpot = -1; private long meetStart = -1L; private long meetEnd = -1L; private long meetCooldownUntil = -1L; private int meetLastSpot = -1; private int meetDeals; private GameObject meetMarker; private GameObject meetPoiGo; private Element meetCompass; private bool meetByteHere; private float meetAwakeTimer; private float meetFaceTimer; private SendableMessage sendNeedParts; private SendableMessage sendWhere; private SendableMessage sendCancel; private const float MeetFarSpot = 80f; private const float MeetSeeRange = 70f; private const float RoomTemp = 26f; private const float ThrottleTemp = 82f; private const float MaxTemp = 100f; private const float RestartTemp = 68f; private const float BaseSystemWatts = 40f; private Dictionary partsBoxData; private float powerDebt; private float powerBillTimer; internal float MiningSpeed = 1f; private const int SlotCount = 24; internal const int SlotBoard = 11; internal const int SlotSsd = 12; internal const int SlotHdd = 13; internal const int SlotFan0 = 14; private const string PcUiName = "CryptoTrader_PC"; private List pcs; private PcKit kit; private bool pcsSpawned; private bool kitFailedLogged; private float pcSpawnTimer; private float pcClockTimer; private int pcNextId = 1; private PcData usingPc; private MonoState useState; private MonoState placeState; private GameObject stateGo; private bool statesTried; private bool placing; private bool placeValid; private bool placeCommitted; private PcData placeTarget; private GameObject ghost; private float placeYaw; private float placeDelay; private bool placeYawSet; private Vector3 placeOrigPos; private float placeOrigYaw; private Transform placeOrigParent; private GameObject hintCanvas; private Text hintMain; private Text hintStatus; private GameObject hintKeys; private CanvasGroup hintPlaceKey; private float noticeTimer; private MaterialPropertyBlock tintBlock; private float pendingMoveTimer = -1f; private PcData pendingMove; private bool placeFromBox; internal float placeEndedAt = -10f; private bool pendingNew; private PcData ghostData; private static System.Type playerType; private static readonly string[] AppTitles = new string[4] { "Miner", "Hardware", "Statistics", "Wallet" }; private static readonly Color rowBg = new Color(1f, 1f, 1f, 0.045f); private static readonly Color hwOff = new Color(1f, 1f, 1f, 0.14f); private static readonly Color hwWarm = new Color(1f, 0.6f, 0.25f, 1f); private static readonly Color hwSel = new Color(0.6f, 0.46f, 1f, 0.32f); private const string BuildUiName = "CryptoTrader_Build"; private const float SlideOut = 0.42f; private float buildSlide = 0.42f; private static readonly string[] BuildTabs = new string[9] { "All", "Board", "CPU", "Cooling", "RAM", "Storage", "GPU", "Power", "Fans" }; private const int TilesPerPage = 12; private readonly List tweens = new List(); private MonoState buildState; private PcData buildPc; private GameObject buildCanvas; private Transform buildPanel; private Text buildHint; private Text buildMsgText; private string buildMsg = ""; private Color buildMsgCol = Color.white; private readonly bool[] buildHide = new bool[24]; private bool panelOff; private bool backOff; private bool backView; private int screwsOut; private int buildTab; private int buildPage; private string buildSel; private string buildHover; private bool dragging; private Transform dragVis; private string dragId; private Vector3 dragCenter; private float dragStartY; private readonly List ghosts = new List(); private readonly List ghostSlot = new List(); private int ghostHot = -1; private Material ghostMat; private Material ghostHotMat; private readonly Dictionary restPose = new Dictionary(); private const float FrameLeft = 0.26f; private const float FrameRight = 0.985f; private const float CaseHalfW = 0.275f; private static bool roomWarned; private string roomBlocker = ""; private static readonly int[] RemoveOrder; private static readonly Color bInk; private static readonly Color bPaper; private static readonly Color bYellow; private static readonly Color bDim; private static readonly Color bGreen; private static readonly Color bRed; private static readonly string[] BuildSteps; private int buildStepSel = -1; private float buildErrTimer; private RectTransform buildCard; private Text detailName; private Text detailSpec; private Text detailFit; private RectTransform buildOverlay; private readonly List buildLabels = new List(); private RectTransform buildImpact; private Text impTitle; private Text impName; private Text impPow; private Text impCool; private Text impEarn; private Text impWarn; private Image impPowBar; private Image impPowNew; private Image impCoolBar; private Image impCoolNew; private Image impIcon; private float buildOverlayTimer; private readonly List buildTargetRings = new List(); private static readonly Color lblOk; private static readonly Color lblFit; private bool argbNear; private static readonly Vector3 CaseKitPos; private static readonly Dictionary> ctmCache; private Dictionary pcMats; private Dictionary pcMatDefs; private Dictionary pcLay; private readonly Dictionary pcTex = new Dictionary(); private bool pcAssetsTried; private bool pcAssetsOk; private float caseLodTimer; private const string CasePreviewName = "Case3DPreview"; internal static readonly Bounds CaseLocalBox; private const float DeskW = 1.4f; private const float DeskD = 0.72f; private const float DeskH = 0.75f; private const float TopT = 0.035f; private const float ScrW = 0.6f; private const float ScrH = 0.3375f; private const float MonZ = -0.21f; private const float MonY = 1.075f; private const float CanvasPx = 1600f; private static readonly Color RgbCyan; private static readonly Color RgbViolet; private static readonly Color RgbPink; private static readonly Color FanGrey; private static readonly Color TrimGreen; private Material litBase; private Sprite fanSprite; private Sprite outlineSprite; private Sprite interiorSprite; private static readonly Vector3[] AsicSpots; internal const int FanSlots = 10; internal static readonly string[] StockSet; private static readonly Color osPanel; private static readonly Color osBar; private Sprite wallpaper; private static readonly Color tGreen; private static readonly Color tGreenDim; private static readonly Color tGreenFaint; private static readonly Color tBg; private static readonly Color tAmber; private static readonly Color tRed; private static readonly Color tCyan; private static readonly Color tYellow; private static readonly Color tClear; private Font monoFont; private static Texture2D scanTex; private static Texture2D vignetteTex; private static Texture2D diagTex; private static readonly Dictionary gradCache; private static Texture2D gridTex; private List walletLog = new List(); private float[] walletSnap; private long walletHour = -1L; private bool hudHidden; private static readonly Color rackSel; private static Sprite fullRing; private const int TraceW = 640; private const int TraceH = 112; private Color32[] traceBuf; private static readonly Color cNavDim; private static readonly Color cSpark; private static readonly Color cToggleOn; private Transform scr; private GameObject pageHome; private int prevPage = 5; private readonly int[] navPages; private Text hBalance; private Text hChange; private Text hCoinsTotal; private Text hFavTitle; private Text hNoCoins; private HoldRow[] hHold; private const int FavRows = 7; private FavRow[] hFav; private int favScroll; private PointerZone favZone; private readonly List favOrder; private Text cStats; private Text cWorth; private Text modeOwnLabel; private readonly Text[] pSellAllLabel; private float sellAllArm; private int sellAllCoin; internal static readonly string[] CurSigns; internal static readonly string[] CurCodes; private static int curIdx; private static readonly float[] AlertSteps; private int alertIdx; private bool homeMine; private readonly Dictionary alertedAt; private Image[] setCurImg; private Image[] setAlertImg; private Image[] setHomeImg; private Image[] setLangImg; private int pendingLang; private const string ShopUiName = "CryptoTrader_ByteShop"; private const int ShopPerPage = 15; private const int ShopMaxQty = 10; private MonoState shopState; private bool shopOpen; private GameObject shopCanvas; private Transform shopPanel; private int shopTab; private int shopPage; private string shopWarn; private string shopInfo; private readonly Dictionary shopCart; private readonly List shopCartOrder; private static readonly string[] ShopTabs; private static Texture2D brickTex; private static Texture2D plankTex; private RectTransform shopHover; private Text shopHoverName; private Text shopHoverSpec; private Transform shopHoverStars; private static Texture2D shadowTex; public const string SupplierName = "Byte"; public const string SupplierUnknownName = "Unknown"; private static readonly Color SupSkinCol; internal static readonly string[] SupSlots; internal static readonly bool[] SupNatural; internal static readonly string[][] SupOptions; internal readonly int[] SupPick; internal static readonly string[] SupColorNames; internal static readonly Color[] SupColorValues; internal readonly int[] SupColor; internal static readonly string[] SupSkinNames; internal static readonly Color[] SupSkinValues; internal int SupSkin; internal const string DefaultSupplierLook = "Hair=Bowl Cut/Navy;Facial hair=None/Default;Face=Neutral Face/Default;Eye detail=None/Default;Hat=None/Black;Glasses=None/Black;Face wear=None/Default;Jacket=Open Vest/Black;Top=T-Shirt/Navy;Bottom=Cargo Pants/Dark grey;Shoes=None/Tan;Hands=Gloves/Black;Neck=Chain/Default;Waist=None/Black;Wrist=Polex/Default;Full body=Hazmat Suit/Charcoal;Skin=Medium;Build=0.31"; internal float SupWeight; private GameObject supplier; private Sprite supplierPortrait; private string supplierLog; private const int ShoesSlot = 10; private const int FullBodySlot = 15; private Sprite supplierPhoto; private bool supplierPhotoBusy; [CompilerGenerated] [DebuggerBrowsable(/*Could not decode attribute arguments.*/)] private Action m_SupplierPhotoChanged; internal static float PhotoFov; internal static float PhotoDistance; internal static float PhotoYaw; internal static float PhotoLift; internal static float PhotoLight; private const int PhotoRender = 1024; private const int PhotoSize = 512; private static readonly Vector3 PhotoSpot; private string photoKeyInUse; private string photoCheckedKey; internal const float DefPhotoFov = 11.25f; internal const float DefPhotoDistance = 1.73f; internal const float DefPhotoYaw = 0f; internal const float DefPhotoLift = 0.1f; internal const float DefPhotoLight = 3f; internal bool ApiReady => sessionLoaded; internal string ApiSaveFolder => currentSavePath; internal bool ApiPlacing => placing; internal bool ApiUsing => usingPc != null; internal bool ApiEventsOn { get { return eventsOn; } set { eventsOn = value; SaveSettings(); forceRefresh = true; } } internal float CryptoSpent { get { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (cryptoSpent < 0f) { float num = 0f; Enumerator enumerator = history.GetEnumerator(); try { while (enumerator.MoveNext()) { TradeRecord current = enumerator.Current; if (current.Kind == "BUY") { num += current.Total; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } cryptoSpent = num; } return cryptoSpent; } } private string DataDir => MelonEnvironment.UserDataDirectory; private string SettingsPath => Path.Combine(DataDir, "CryptoTraderSettings.txt"); private string RefCachePath => Path.Combine(DataDir, "CryptoReferencePrices.txt"); private bool MeetInSewers => meetSpot >= 0 && meetSpot < MeetSpots.Count && IsSewerSpot(MeetSpots[meetSpot].Pos); private static string SpotsFile => Path.Combine(MelonEnvironment.UserDataDirectory, "CryptoTrader_MeetSpots.txt"); private Dictionary partsBox { get { if (partsBoxData == null) { partsBoxData = new Dictionary(); } return partsBoxData; } } private List Pcs { get { if (pcs == null) { pcs = new List(); } return pcs; } } private bool BuildBusy => tweens.Count > 0; private bool CaseOpen => backView ? backOff : panelOff; private static Quaternion FaceFront => Quaternion.Euler(0f, 180f, 0f); private static Quaternion FaceUp => Quaternion.Euler(90f, 0f, 0f); private static Quaternion FaceLeft => Quaternion.Euler(0f, 90f, 0f); private static bool CurSuffix => curIdx == 3; internal bool SupplierSpawned => (Object)(object)supplier != (Object)null; internal string SupplierLog => supplierLog ?? ""; private bool WearsHazmat => SupOptions[15][Mathf.Clamp(SupPick[15], 0, SupOptions[15].Length - 1)] == "Hazmat Suit"; private bool WearsFootwear => WearsHazmat || SupOptions[10][Mathf.Clamp(SupPick[10], 0, SupOptions[10].Length - 1)] != "None"; private static string PhotoFile => Path.Combine(MelonEnvironment.UserDataDirectory, "CryptoTrader_BytePhoto.png"); private static string PhotoKeyFile => Path.Combine(MelonEnvironment.UserDataDirectory, "CryptoTrader_BytePhoto.txt"); private string PhotoKey => string.Concat(new string[12] { SupLookString(), "|", PhotoFov.ToString(), "|", PhotoDistance.ToString(), "|", PhotoYaw.ToString(), "|", PhotoLift.ToString(), "|", PhotoLight.ToString(), "|v2" }); internal bool HasSupplierPhoto => ((Object)(object)supplierPhoto != (Object)null && photoKeyInUse == PhotoKey) || LoadSupplierPhoto(); private static string PhotoSettingsFile => Path.Combine(MelonEnvironment.UserDataDirectory, "CryptoTrader_PhotoCamera.txt"); internal bool SupplierPhotoBusy => supplierPhotoBusy; internal event Action SupplierPhotoChanged { [CompilerGenerated] add { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Action val = this.m_SupplierPhotoChanged; Action val2; do { val2 = val; Action val3 = (Action)System.Delegate.Combine((System.Delegate)(object)val2, (System.Delegate)(object)value); val = Interlocked.CompareExchange(ref this.m_SupplierPhotoChanged, val3, val2); } while (val != val2); } [CompilerGenerated] remove { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Action val = this.m_SupplierPhotoChanged; Action val2; do { val2 = val; Action val3 = (Action)System.Delegate.Remove((System.Delegate)(object)val2, (System.Delegate)(object)value); val = Interlocked.CompareExchange(ref this.m_SupplierPhotoChanged, val3, val2); } while (val != val2); } } internal List ApiComputers() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) List val = new List(); Enumerator enumerator = Pcs.GetEnumerator(); try { while (enumerator.MoveNext()) { PcData current = enumerator.Current; ComputerInfo computerInfo = new ComputerInfo { Id = current.Id, Position = current.Pos, Yaw = current.Yaw, InUse = (current == usingPc) }; GameOwnedPropertyName(current.Pos, out computerInfo.Property); val.Add(computerInfo); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return val; } private static void GameOwnedPropertyName(Vector3 p, out string name) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) name = ""; try { Property val = PropertyAt(p); if ((Object)(object)val != (Object)null) { name = val.PropertyName; } } catch { } } private PcData FindPc(int id) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = Pcs.GetEnumerator(); try { while (enumerator.MoveNext()) { PcData current = enumerator.Current; if (current.Id == id) { return current; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return null; } internal bool ApiStartPlacing() { if (placing || usingPc != null) { return false; } StartPlacement(); return true; } internal bool ApiMove(int id) { PcData pcData = FindPc(id); if (pcData == null || (Object)(object)pcData.Root == (Object)null || placing) { return false; } if (usingPc != null) { LeavePc(); } pendingNew = false; pendingMove = pcData; pendingMoveTimer = 0.3f; return true; } internal bool ApiOpen(int id) { PcData pcData = FindPc(id); if (pcData == null || (Object)(object)pcData.Root == (Object)null || placing || usingPc != null) { return false; } OpenPcView(pcData); return usingPc == pcData; } internal bool ApiRemove(int id) { PcData pcData = FindPc(id); if (pcData == null) { return false; } if (placing && ghostData == pcData) { FinishPlacement(commit: false); } if (usingPc == pcData) { LeavePc(); } Pcs.Remove(pcData); if ((Object)(object)pcData.Root != (Object)null) { Object.Destroy((Object)(object)pcData.Root); } return true; } internal int ApiRemoveAll() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) List val = new List(); Enumerator enumerator = Pcs.GetEnumerator(); try { while (enumerator.MoveNext()) { PcData current = enumerator.Current; val.Add(current.Id); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } Enumerator enumerator2 = val.GetEnumerator(); try { while (enumerator2.MoveNext()) { int current2 = enumerator2.Current; ApiRemove(current2); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } return val.Count; } internal void ApiRebuildModels() { //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) if (placing) { FinishPlacement(commit: false); } if (usingPc != null) { LeavePc(); } Enumerator enumerator = Pcs.GetEnumerator(); try { while (enumerator.MoveNext()) { PcData current = enumerator.Current; if ((Object)(object)current.Root != (Object)null) { Object.Destroy((Object)(object)current.Root); current.Root = null; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } kit = null; kitFailedLogged = false; pcsSpawned = false; pcSpawnTimer = 0.1f; } internal string[] ApiSymbols() { string[] array = new string[coins.Count]; for (int i = 0; i < coins.Count; i++) { array[i] = coins[i].Symbol; } return array; } internal float ApiPrice(string sym) { int num = IndexOf(sym); return (num >= 0) ? coins[num].Price : 0f; } internal float ApiOwned(string sym) { int num = IndexOf(sym); return (num >= 0) ? coins[num].Owned : 0f; } internal bool ApiGive(string sym, float units) { int num = IndexOf(sym); if (num < 0 || units <= 0f) { return false; } Coin coin = coins[num]; coin.Owned += units; coin.Invested += units * coin.Price; forceRefresh = true; return true; } internal bool ApiEvent() { SpawnEvent(); forceRefresh = true; chartDirty = true; sparkDirty = true; return true; } internal void ApiFastForward(int minutes) { RunTicks(minutes); forceRefresh = true; chartDirty = true; sparkDirty = true; } internal void ApiGivePart(string id, int n) { for (int i = 0; i < n; i++) { GiveSpare(id); } RefreshOpenApp(); } internal int ApiBoxCount(string id) { return SpareCount(id); } internal void ApiClearBox() { partsBox.Clear(); RefreshOpenApp(); } internal float ApiWalletUsd() { return PendingUsd(); } internal void ApiSimulateMining(int minutes) { minutes = Mathf.Clamp(minutes, 0, 10080); for (int i = 0; i < minutes; i++) { totalGameMin++; MineMinute(); } totalGameMin -= minutes; RefreshOpenApp(); } internal string ApiRigSummary(int id) { PcData pcData = FindPc(id); if (pcData == null) { return ""; } RigState rigState = RigOf(pcData); EvaluateRig(rigState, advance: false); return string.Concat(new string[9] { StatusText(rigState.Status), ", ", rigState.Temp.ToString("0", (IFormatProvider)(object)Inv), " C, $", rigState.UsdPerDay.ToString("N0", (IFormatProvider)(object)Inv), "/day, ", rigState.WallWatts.ToString("0", (IFormatProvider)(object)Inv), " W, mined $", rigState.TotalUsd.ToString("N2", (IFormatProvider)(object)Inv) }); } private void RefreshOpenApp() { if (usingPc != null && usingPc.WinApp >= 0) { try { OpenPcWindow(usingPc, usingPc.WinApp); } catch { } } } internal float ApiBalance() { return GetBalance(); } internal void ApiAddMoney(float amount, string note) { AddBalance(amount, string.IsNullOrEmpty(note) ? "Developer" : note); } internal void NoteCryptoBuy(float cost) { cryptoSpent = CryptoSpent + cost; } private static bool RankAtLeastHoodlum() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 try { if (!NetworkSingleton.InstanceExists) { return false; } return (int)NetworkSingleton.Instance.Rank >= 1; } catch { return false; } } private bool ByteUnlocked(float dt) { if (byteUnlocked) { return true; } byteUnlockCheck -= dt; if (byteUnlockCheck > 0f) { return false; } byteUnlockCheck = 2f; byteUnlocked = RankAtLeastHoodlum() && CryptoSpent >= 300f; return byteUnlocked; } private void ByteUpdate(float dt) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!EnsureByteConversation(dt)) { return; } byteQueueClock += dt; while (byteQueue.Count > 0 && byteQueue[0].Key <= byteQueueClock) { Action value = byteQueue[0].Value; byteQueue.RemoveAt(0); try { value.Invoke(); } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Byte message failed: " + ex.Message); } } if (byteQueue.Count > 0) { return; } if (byteStage == ByteStage.NotMet || byteStage == ByteStage.Ignored) { if (byteStage == ByteStage.NotMet && !byteForce && !ByteUnlocked(dt)) { return; } if (byteForce) { byteForce = false; byteNextMin = totalGameMin; } if (byteNextMin < 0) { byteNextMin = totalGameMin + ((byteStage == ByteStage.NotMet) ? 15 : 1440); } if (totalGameMin >= byteNextMin) { ByteOpening(); } } if (byteConv != null) { byteRead = byteConv.Read; } bytePhotoRetry -= dt; if (bytePhotoRetry <= 0f) { bytePhotoRetry = 30f; EnsureSupplierPhoto(); } } private bool EnsureByteConversation(float dt) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown if (byteConv != null) { return true; } byteRetry -= dt; if (byteRetry > 0f) { return false; } byteRetry = 1f; try { if (!NetworkSingleton.InstanceExists || !PlayerSingleton.InstanceExists) { return false; } MessagingManager instance = NetworkSingleton.Instance; MSGConversation val = default(MSGConversation); if (instance.TryGetConversation("cryptotrader_byte", ref val) && val != null) { DropConversation(val); } EnsureSupplierPhoto(); SupplierPhotoChanged -= new Action(ByteRefreshPicture); SupplierPhotoChanged += new Action(ByteRefreshPicture); MessageContactInfo val2 = new MessageContactInfo("Byte", "cryptotrader_byte", SupplierPicture(), false, false); byteConv = new MSGConversation(val2, "cryptotrader_byte"); MSGConversation obj = byteConv; List obj2 = new List(); obj2.Add((EConversationCategory)1); obj.SetCategories(Compat.GL(obj2)); byteConv.SetIsKnown(byteKnown); Enumerator enumerator = byteLog.GetEnumerator(); try { while (enumerator.MoveNext()) { ByteLine current = enumerator.Current; byteConv.SendMessage(new Message(Lang.T(current.Text), (ESenderType)(!current.Player), current.End, -1), false, false); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (byteLog.Count > 0) { byteConv.SetEntryVisibility(true); } byteConv.SetRead(byteRead); byteSendable = byteConv.CreateSendableMessage(Lang.T("Ok, what have you got?")); byteSendable.ShouldShowCheck = Check([CompilerGenerated] (SendableMessage m) => byteStage == ByteStage.Ignored); byteSendable.disableDefaultSendBehaviour = false; byteSendable.onSent = Compat.GA((Action)([CompilerGenerated] () => { if (byteStage == ByteStage.Ignored) { byteStage = ByteStage.Asking; byteNextMin = -1L; ByteLog(player: true, "Ok, what have you got?", end: true); ByteWhatParts(); } })); ByteAddMeetingTexts(); ByteResumeResponses(); ((MelonBase)this).LoggerInstance.Msg(string.Concat(new string[5] { "Byte's chat is ready (", byteLog.Count.ToString(), " messages, stage ", ((object)byteStage/*cast due to .constrained prefix*/).ToString(), ")." })); return true; } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not create Byte's chat yet: " + ex.Message); byteConv = null; byteRetry = 5f; return false; } } private static void DropConversation(MSGConversation c) { try { MessagesApp.Conversations.Remove(c); MessagesApp.ActiveConversations.Remove(c); string[] array = new string[2] { "entry", "container" }; foreach (string name in array) { object obj = Compat.Get(c, name); RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } if (NetworkSingleton.InstanceExists) { NetworkSingleton.Instance._senderIdConversationMap?.Remove("cryptotrader_byte"); } } catch { } } private void ByteRefreshPicture() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (byteConv == null) { return; } try { Compat.Set(byteConv, "_sender", (object)new MessageContactInfo("Byte", "cryptotrader_byte", SupplierPicture(), false, false)); byteConv.SetIsKnown(byteKnown); } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not update Byte's picture: " + ex.Message); } } private void ByteOpening() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown byteNextMin = -1L; if (byteStage == ByteStage.NotMet) { ByteSay("yo. heard you're into crypto.", 0f); ByteSay("trading on your phone is small money. mining is where it's at.", 2.5f); ByteSay("i can get you a mining rig and parts. cheap. no receipts.", 2.5f, endOfGroup: true); } else { ByteSay("still mining on stock parts?", 0f); ByteSay("offer's still open.", 2f, endOfGroup: true); } ByteThen((Action)([CompilerGenerated] () => { byteStage = ByteStage.Asking; ByteResumeResponses(); })); } private void ByteWhoIsThis() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ByteSay("friend of a friend.", 1.5f); ByteSay("call me Byte.", 2f, endOfGroup: true); ByteThen(new Action(ByteReveal)); ByteTerms(); } private void ByteWhatParts() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown ByteSay("full mining computers. graphics cards. processors. ASIC miners.", 1.5f); ByteSay("stuff that fell off a truck, if you know what i mean.", 2.5f); ByteSay("name's Byte.", 2f, endOfGroup: true); ByteThen(new Action(ByteReveal)); ByteTerms(); } private void ByteNotInterested() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ByteSay("your call.", 1.5f); ByteSay("you'll think about me when the power bill comes.", 2.5f, endOfGroup: true); ByteThen((Action)([CompilerGenerated] () => { byteStage = ByteStage.Ignored; byteNextMin = totalGameMin + 1440; })); } private void ByteTerms() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown ByteSay("i don't do shops. i don't do deliveries.", 3f); ByteSay("we meet in person. you bring cash, you get the box.", 3f); ByteSay("text me when you need something.", 2.5f, endOfGroup: true); ByteThen((Action)([CompilerGenerated] () => { byteStage = ByteStage.Closing; ByteResumeResponses(); })); } private void ByteReveal() { byteKnown = true; if (byteConv != null) { byteConv.SetIsKnown(true); } } private void ByteResumeResponses() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown if (byteConv == null) { return; } List val = new List(); if (byteStage == ByteStage.Asking) { val.Add(ByteReply("Who is this?", new Action(ByteWhoIsThis))); val.Add(ByteReply("What kind of parts?", new Action(ByteWhatParts))); val.Add(ByteReply("Not interested.", new Action(ByteNotInterested))); } else if (byteStage == ByteStage.Closing) { val.Add(ByteReply("Deal.", (Action)([CompilerGenerated] () => { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ByteSay("good.", 1.5f, endOfGroup: true); ByteThen((Action)([CompilerGenerated] () => { byteStage = ByteStage.Introduced; })); }))); val.Add(ByteReply("Sounds shady.", (Action)([CompilerGenerated] () => { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ByteSay("it is. that's why it's cheap.", 2f, endOfGroup: true); ByteThen((Action)([CompilerGenerated] () => { byteStage = ByteStage.Introduced; })); }))); } if (val.Count > 0) { byteConv.ShowResponses(Compat.GL(val), 0.4f, false); } } private Response ByteReply(string text, Action then) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown return new Response(Lang.T(text), "byte_" + text, Compat.GA((Action)delegate { ByteLog(player: true, text, end: true); then.Invoke(); }), false); } private static BoolCheck Check(Func f) { return DelegateSupport.ConvertDelegate((System.Delegate)(object)f); } private void ByteLanguageChanged() { if (byteConv != null) { byteConv = null; byteRetry = 0f; } if (!((Object)(object)supplier == (Object)null)) { InteractableObject component = supplier.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetMessage(Lang.T(meetByteHere ? "Buy from Byte" : "Talk to Byte")); } } } private void ByteSay(string text, float delay, bool endOfGroup = false) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown ByteThen((Action)delegate { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown ByteLog(player: false, text, endOfGroup); if (byteConv != null) { byteConv.SendMessage(new Message(Lang.T(text), (ESenderType)1, endOfGroup, -1), true, false); } }, delay); } private void ByteThen(Action a, float delay = 0f) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) float num = ((byteQueue.Count > 0) ? byteQueue[byteQueue.Count - 1].Key : byteQueueClock); byteQueue.Add(new KeyValuePair(Mathf.Max(num, byteQueueClock) + delay, a)); } private void ByteLog(bool player, string text, bool end) { byteLog.Add(new ByteLine { Player = player, Text = text, End = end }); while (byteLog.Count > 30) { byteLog.RemoveAt(0); } } private void ByteAppendSave(StringBuilder sb) { //IL_008e: 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) ByteStage byteStage = this.byteStage; sb.Append("BYT;").Append((int)byteStage).Append(';') .Append(byteKnown ? 1 : 0) .Append(';') .Append(byteNextMin) .Append(';') .Append(byteRead ? 1 : 0) .Append(';') .Append(CryptoSpent.ToString("0.##", (IFormatProvider)(object)Inv)) .Append('\n'); Enumerator enumerator = byteLog.GetEnumerator(); try { while (enumerator.MoveNext()) { ByteLine current = enumerator.Current; sb.Append("BYM;").Append((!current.Player) ? 1 : 0).Append(';') .Append(current.End ? 1 : 0) .Append(';') .Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(current.Text))) .Append('\n'); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } private void ByteParseLine(string[] f) { if (f[0] == "BYT" && f.Length >= 5) { int num = int.Parse(f[1], (IFormatProvider)(object)Inv); byteStage = (ByteStage)Mathf.Clamp(num, 0, 4); byteKnown = f[2] == "1"; byteNextMin = long.Parse(f[3], (IFormatProvider)(object)Inv); byteRead = f[4] == "1"; float num2 = default(float); if (f.Length >= 6 && float.TryParse(f[5], (NumberStyles)167, (IFormatProvider)(object)Inv, ref num2)) { cryptoSpent = num2; } } else if (f[0] == "BYM" && f.Length >= 4) { string text = Encoding.UTF8.GetString(Convert.FromBase64String(f[3])); ByteLog(f[1] == "0", text, f[2] == "1"); } } private void ByteReset() { byteStage = ByteStage.NotMet; byteKnown = false; byteRead = true; byteNextMin = -1L; byteLog.Clear(); byteQueue.Clear(); byteQueueClock = 0f; byteRetry = 0f; byteForce = false; cryptoSpent = -1f; byteUnlocked = false; byteUnlockCheck = 0f; if (byteConv != null) { DropConversation(byteConv); } byteConv = null; byteSendable = null; } internal void ApiByteTextNow() { if (byteStage == ByteStage.NotMet || byteStage == ByteStage.Ignored) { byteForce = true; } } internal void ApiByteRestart() { bool flag = sessionLoaded; ByteReset(); if (flag) { byteRetry = 0f; } } internal string ApiByteState() { string text = string.Concat(new string[6] { "stage: ", ((object)byteStage/*cast due to .constrained prefix*/).ToString(), byteKnown ? ", known as Byte" : ", shown as Unknown", ", ", byteLog.Count.ToString(), " messages" }); if (byteNextMin >= 0) { text = text + ", next text in " + Mathf.Max(0f, (float)(byteNextMin - totalGameMin)) + " game min"; } if (byteConv == null) { text += " (chat not created yet)"; } return text; } private static bool IsMeetQuest(Quest x) { try { return (Object)(object)x != (Object)null && (Object)(object)((Component)x).gameObject != (Object)null && ((Object)((Component)x).gameObject).name == "CryptoTrader_MeetByteQuest"; } catch { return false; } } private bool MeetCreateQuest(Transform target) { //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)meetQuest != (Object)null) { MeetKillQuest(meetQuest); meetQuest = null; } MeetClearOldQuests(); Quest q = null; try { Quest val = QuestTemplate(); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = new GameObject("CryptoTrader_MeetByteQuest"); val2.SetActive(false); q = val2.AddComponent(); SetMember(q, "autoInitialize", false); q.IconPrefab = val.IconPrefab; q.PoIPrefab = val.PoIPrefab; q.TrackOnBegin = true; q.AutoStartFirstEntry = true; q.AutoCompleteOnAllEntriesComplete = false; q.PlayQuestCompleteSound = true; q.CompletionXP = 0; if (q.Entries == null) { q.Entries = Compat.GL(new List()); } FillEvents(q); val2.SetActive(true); meetQuestTitle = "Meet Byte"; q.InitializeQuest(Lang.T("Meet Byte"), Lang.T("Byte is waiting with his stock. Bring cash."), Il2CppReferenceArray.op_Implicit((QuestEntryData[])(object)new QuestEntryData[1] { new QuestEntryData(Lang.T("Be there before " + MeetClock(meetEnd) + (MeetInSewers ? " - in the sewers" : "")), (EQuestState)0) }), ((object)Guid.NewGuid()/*cast due to .constrained prefix*/).ToString()); if (q.Entries.Count == 0) { MeetKillQuest(q); return false; } Enumerator enumerator = q.Entries.GetEnumerator(); while (enumerator.MoveNext()) { QuestEntry current = enumerator.Current; FillEvents(current); } try { List saveables = Singleton.Instance.Saveables; for (int num = saveables.Count - 1; num >= 0; num--) { ISaveable val3 = saveables[num]; if (val3 != null && ((Il2CppObjectBase)val3).Pointer == ((Il2CppObjectBase)q).Pointer) { saveables.RemoveAt(num); } } } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Meeting quest save: " + ex.Message); } } catch (System.Exception ex2) { ((MelonBase)this).LoggerInstance.Warning("Meeting quest failed, using a plain marker: " + ex2.Message + " | " + Trace(ex2)); MeetKillQuest(q); return false; } QuestEntry e = q.Entries[0]; MeetStep("marker", (Action)delegate { e.PoILocation = target; e.AutoCreatePoI = true; e.AutoUpdatePoILocation = false; e.CreatePoI(); }); MeetStep("track", (Action)delegate { q.SetIsTracked(true); }); MeetStep("begin", (Action)delegate { q.Begin(false); }); MeetStep("entry", (Action)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if ((int)e.State != 1) { e.SetState((EQuestState)1, false); } }); meetQuest = q; meetQuestTimer = 0f; MeetUpdateQuest(1f); return true; } private void MeetStep(string what, Action a) { try { a.Invoke(); } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning(string.Concat(new string[6] { "Meeting quest (", what, "): ", ex.Message, " | ", Trace(ex) })); } } private static string Trace(System.Exception ex) { string text = (ex.StackTrace ?? "").Replace("\r", " ").Replace("\n", " ").Trim(); return (text.Length > 400) ? text.Substring(0, 400) : text; } private static void FillEvents(object o) { if (o == null) { return; } System.Type type = o.GetType(); while (type != (System.Type)null && type != typeof(MonoBehaviour)) { FieldInfo[] fields = type.GetFields((BindingFlags)54); foreach (FieldInfo val in fields) { try { if (typeof(UnityEventBase).IsAssignableFrom(val.FieldType) && !val.FieldType.IsAbstract && !val.FieldType.ContainsGenericParameters && val.GetValue(o) == null) { val.SetValue(o, Activator.CreateInstance(val.FieldType)); } } catch { } } type = type.BaseType; } System.Type type2 = o.GetType(); while (type2 != (System.Type)null && type2 != typeof(MonoBehaviour)) { PropertyInfo[] properties = type2.GetProperties((BindingFlags)22); foreach (PropertyInfo val2 in properties) { try { if (val2.GetIndexParameters().Length == 0 && val2.CanRead && val2.CanWrite && typeof(UnityEventBase).IsAssignableFrom(val2.PropertyType) && !val2.PropertyType.IsAbstract && !val2.PropertyType.ContainsGenericParameters && val2.GetValue(o, (object[])null) == null) { val2.SetValue(o, Activator.CreateInstance(val2.PropertyType), (object[])null); } } catch { } } type2 = type2.BaseType; } } private void MeetKillQuest(Quest q, bool ended = false) { if ((Object)(object)q == (Object)null) { return; } Component val = null; try { val = (Component)(object)q.hudUI; } catch { } if (!ended) { try { q.End(); } catch { } string[] array = new string[2] { "DestroyJournalEntry", "DestroyDetailDisplay" }; foreach (string text in array) { try { MethodInfo method = typeof(Quest).GetMethod(text, (BindingFlags)52); if (method != (MethodInfo)null) { ((MethodBase)method).Invoke((object)q, (object[])null); } } catch { } } } try { if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null) { Object.Destroy((Object)(object)val.gameObject); } } catch { } try { if (q.Entries != null) { Enumerator enumerator = q.Entries.GetEnumerator(); while (enumerator.MoveNext()) { QuestEntry current = enumerator.Current; if ((Object)(object)current != (Object)null && (Object)(object)current.PoI != (Object)null) { Object.Destroy((Object)(object)((Component)current.PoI).gameObject); } } } } catch { } try { Quest.Quests.Remove(q); Quest.ActiveQuests.Remove(q); } catch { } try { Object.Destroy((Object)(object)((Component)q).gameObject); } catch { } } private void MeetClearOldQuests() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) try { List val = new List(); Enumerator enumerator = Quest.Quests.GetEnumerator(); while (enumerator.MoveNext()) { Quest current = enumerator.Current; Quest val2 = (IsMeetQuest(current) ? Compat.As((object)current) : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)meetQuest) { val.Add(val2); } } System.Collections.Generic.IEnumerator enumerator2 = Object.FindObjectsOfType().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { Quest current2 = enumerator2.Current; if (IsMeetQuest(current2) && (Object)(object)current2 != (Object)(object)meetQuest && !val.Contains(current2)) { val.Add(current2); } } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } Enumerator enumerator3 = val.GetEnumerator(); try { while (enumerator3.MoveNext()) { Quest current3 = enumerator3.Current; MeetKillQuest(current3); } } finally { ((System.IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } } catch { } try { System.Collections.Generic.IEnumerator enumerator4 = Object.FindObjectsOfType().GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator4).MoveNext()) { QuestHUDUI current4 = enumerator4.Current; Quest val3 = null; try { val3 = current4.Quest; } catch { } if ((Object)(object)val3 == (Object)null || (IsMeetQuest(val3) && (Object)(object)val3 != (Object)(object)meetQuest)) { Object.Destroy((Object)(object)((Component)current4).gameObject); } } } finally { ((System.IDisposable)enumerator4)?.Dispose(); } } catch { } } private string MeetEntryTitle() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (meetSpot < 0 || meetSpot >= MeetSpots.Count) { return "Meet Byte"; } float num = FlatDist(MeetSpots[meetSpot].Pos, PlayerPosition()); string text = " (" + Mathf.RoundToInt(num) + "m)"; if (meetByteHere) { return "Byte is waiting - until " + MeetClock(meetEnd) + text; } return "Meet Byte before " + MeetClock(meetEnd) + (MeetInSewers ? " (sewers)" : "") + text; } private void MeetUpdateQuest(float dt) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)meetQuest == (Object)null || meetQuest.Entries == null || meetQuest.Entries.Count == 0) { return; } meetQuestTimer -= dt; if (meetQuestTimer > 0f) { return; } meetQuestTimer = 0.5f; try { float num = ((meetSpot >= 0 && meetSpot < MeetSpots.Count) ? FlatDist(MeetSpots[meetSpot].Pos, PlayerPosition()) : 999f); string text = "Meet Byte (" + Mathf.RoundToInt(num) + "m)"; string s = (meetByteHere ? ("Byte is waiting until " + MeetClock(meetEnd)) : ("Be there before " + MeetClock(meetEnd) + (MeetInSewers ? " - in the sewers" : ""))); bool flag = false; if (meetQuestTitle != text) { meetQuestTitle = text; flag = true; SetMember(meetQuest, "title", Lang.T(text)); } string text2 = Lang.T(s); if (meetQuest.Entries[0].Title != text2) { meetQuest.Entries[0].SetEntryTitle(text2); flag = true; } if (flag) { meetQuest.UpdateHUDUI(); } Component hudUI = (Component)(object)meetQuest.hudUI; if ((Object)(object)hudUI != (Object)null) { bool flag2 = (hudUI.gameObject.activeSelf ? (num >= 10f) : (num > 14f)); if (hudUI.gameObject.activeSelf != flag2) { hudUI.gameObject.SetActive(flag2); } } } catch { } } private void MeetEndQuest(bool done) { if ((Object)(object)meetQuest == (Object)null) { MeetClearOldQuests(); return; } Quest val = meetQuest; meetQuest = null; bool ended = false; try { if (done) { val.Complete(false); } else { val.Cancel(false); } ended = true; } catch { } MeetKillQuest(val, ended); MeetClearOldQuests(); } private void CreateCoins() { Add("Bitcoin", "BTC", "bitcoin", 81300f, 0.022f, 0.75f, 0.8f, 0.97f, 0.62f, 0.1f); Add("Ethereum", "ETH", "ethereum", 2360f, 0.03f, 0.75f, 1f, 0.5f, 0.58f, 0.98f); Add("Tether", "USDT", "tether", 1f, 0.0008f, 0f, 0f, 0.15f, 0.65f, 0.5f, stable: true); Add("XRP", "XRP", "ripple", 1.33f, 0.04f, 0.6f, 1.1f, 0.78f, 0.8f, 0.88f); Add("BNB", "BNB", "binancecoin", 750f, 0.025f, 0.65f, 0.9f, 0.95f, 0.75f, 0.15f); Add("Solana", "SOL", "solana", 102f, 0.045f, 0.65f, 1.2f, 0.22f, 0.88f, 0.65f); Add("USD Coin", "USDC", "usd-coin", 1f, 0.0008f, 0f, 0f, 0.2f, 0.5f, 0.88f, stable: true); Add("Dogecoin", "DOGE", "dogecoin", 0.08f, 0.06f, 0.5f, 1.5f, 0.9f, 0.78f, 0.25f); Add("Cardano", "ADA", "cardano", 0.206f, 0.042f, 0.6f, 1f, 0.32f, 0.48f, 0.95f); Add("TRON", "TRX", "tron", 0.33f, 0.02f, 0.4f, 0.7f, 0.92f, 0.22f, 0.25f); Add("Avalanche", "AVAX", "avalanche-2", 9.8f, 0.05f, 0.6f, 1.2f, 0.93f, 0.33f, 0.38f); Add("Chainlink", "LINK", "chainlink", 11.8f, 0.045f, 0.6f, 1.1f, 0.28f, 0.45f, 0.92f); Add("Stellar", "XLM", "stellar", 0.173f, 0.038f, 0.55f, 1f, 0.85f, 0.85f, 0.92f); Add("Sui", "SUI", "sui", 1.04f, 0.06f, 0.55f, 1.3f, 0.35f, 0.7f, 1f); Add("Toncoin", "TON", "the-open-network", 1.73f, 0.04f, 0.4f, 1f, 0.1f, 0.6f, 0.95f); Add("Polkadot", "DOT", "polkadot", 1.1f, 0.045f, 0.6f, 1.1f, 0.92f, 0.2f, 0.55f); Add("Litecoin", "LTC", "litecoin", 61.9f, 0.032f, 0.6f, 0.9f, 0.65f, 0.68f, 0.78f); Add("Bitcoin Cash", "BCH", "bitcoin-cash", 288f, 0.035f, 0.6f, 0.9f, 0.5f, 0.85f, 0.35f); Add("Shiba Inu", "SHIB", "shiba-inu", 5.4E-06f, 0.07f, 0.45f, 1.5f, 0.95f, 0.55f, 0.2f); Add("Uniswap", "UNI", "uniswap", 7.56f, 0.048f, 0.55f, 1.1f, 1f, 0.25f, 0.55f); Add("Cosmos", "ATOM", "cosmos", 1.76f, 0.046f, 0.5f, 1.1f, 0.55f, 0.55f, 0.75f); Add("NEAR Protocol", "NEAR", "near", 4.75f, 0.052f, 0.55f, 1.2f, 0.8f, 0.82f, 0.82f); Add("Aptos", "APT", "aptos", 0.646f, 0.055f, 0.55f, 1.2f, 0.25f, 0.8f, 0.7f); Add("Internet Computer", "ICP", "internet-computer", 3.03f, 0.052f, 0.5f, 1.1f, 0.62f, 0.3f, 0.8f); Add("Ethereum Classic", "ETC", "ethereum-classic", 8.36f, 0.04f, 0.55f, 1f, 0.3f, 0.72f, 0.35f); Add("Monero", "XMR", "monero", 599f, 0.03f, 0.3f, 0.8f, 0.98f, 0.45f, 0.15f); Add("Aave", "AAVE", "aave", 157f, 0.048f, 0.55f, 1.1f, 0.7f, 0.45f, 0.9f); Add("Filecoin", "FIL", "filecoin", 0.858f, 0.05f, 0.5f, 1.1f, 0.15f, 0.6f, 0.9f); Add("Algorand", "ALGO", "algorand", 0.0999f, 0.046f, 0.5f, 1f, 0.78f, 0.78f, 0.8f); Add("VeChain", "VET", "vechain", 0.00772f, 0.045f, 0.5f, 1f, 0.2f, 0.65f, 0.98f); Add("The Sandbox", "SAND", "the-sandbox", 0.0405f, 0.055f, 0.5f, 1.2f, 0.1f, 0.7f, 0.95f); Add("Decentraland", "MANA", "decentraland", 0.0755f, 0.055f, 0.5f, 1.2f, 1f, 0.35f, 0.35f); Add("Pepe", "PEPE", "pepe", 4.7E-06f, 0.095f, 0.35f, 1.8f, 0.4f, 0.75f, 0.3f); Add("Render", "RENDER", "render-token", 1.5f, 0.06f, 0.5f, 1.3f, 0.95f, 0.3f, 0.3f); Add("Injective", "INJ", "injective-protocol", 6.47f, 0.06f, 0.5f, 1.3f, 0.2f, 0.75f, 0.95f); Add("Optimism", "OP", "optimism", 0.107f, 0.058f, 0.55f, 1.2f, 1f, 0.2f, 0.25f); Add("Arbitrum", "ARB", "arbitrum", 0.171f, 0.056f, 0.55f, 1.2f, 0.2f, 0.55f, 0.95f); Add("Kaspa", "KAS", "kaspa", 0.0365f, 0.065f, 0.35f, 1.3f, 0.3f, 0.85f, 0.8f); Add("Polygon", "POL", "polygon-ecosystem-token", 0.0967f, 0.05f, 0.55f, 1.1f, 0.55f, 0.3f, 0.9f); Add("Hedera", "HBAR", "hedera-hashgraph", 0.0801f, 0.048f, 0.5f, 1.1f, 0.75f, 0.75f, 0.78f); pending = new float[coins.Count]; } private void Add(string name, string sym, string id, float price, float vol, float beta, float sens, float r, float g, float b, bool stable = false) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) coins.Add(new Coin(name, sym, id, price, vol, beta, sens, new Color(r, g, b, 1f), stable)); } public override void OnInitializeMelon() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Instance = this; CreateCoins(); SupLoadLookString("Hair=Bowl Cut/Navy;Facial hair=None/Default;Face=Neutral Face/Default;Eye detail=None/Default;Hat=None/Black;Glasses=None/Black;Face wear=None/Default;Jacket=Open Vest/Black;Top=T-Shirt/Navy;Bottom=Cargo Pants/Dark grey;Shoes=None/Tan;Hands=Gloves/Black;Neck=Chain/Default;Waist=None/Black;Wrist=Polex/Default;Full body=Hazmat Suit/Charcoal;Skin=Medium;Build=0.31"); LoadPhotoSettings(); LoadMeetSpots(); LoadSettings(); LoadRefCache(); TimeSpan val = System.DateTime.UtcNow - refFetched; if (((TimeSpan)(ref val)).TotalHours > 12.0) { FetchReferencePrices(applyToMarket: false); } ((MelonBase)this).LoggerInstance.Msg("Crypto Trader 1.1.2 for the normal (IL2CPP) branch loaded (" + coins.Count + " coins). Crypto data is stored per save file."); } public override void OnLateUpdate() { UpdateHeldBox(late: true); } public override void OnUpdate() { float unscaledDeltaTime = Time.unscaledDeltaTime; try { ShimHost.Tick(); } catch (System.Exception ex) { if (!warnedOnce) { warnedOnce = true; Warn("UI shim: " + ex.Message); } } UpdateItems(unscaledDeltaTime); ApplyPendingLanguage(); UpdateHeldBox(late: false); HookSaveSystem(); TrackActiveSave(); if (sessionLoaded) { UpdateMarketClock(unscaledDeltaTime); } iconTimer += unscaledDeltaTime; if (iconTimer >= 1f) { iconTimer = 0f; if (sessionLoaded) { TryAddPhoneIcon(); } } if (sessionLoaded) { HookPhoneEvents(); } if (sessionLoaded) { PcUpdate(unscaledDeltaTime); ByteUpdate(unscaledDeltaTime); MeetUpdate(unscaledDeltaTime); } if (!isOpen) { return; } if ((Object)(object)appRoot == (Object)null) { isOpen = false; return; } if (!PhoneIsOpen()) { SetAppOpen(open: false); return; } object obj = GetStatic(phoneType, "ActiveApp"); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)appRoot) { SoftClose(); return; } if (!exitRegistered && Input.GetKeyDown((KeyCode)27)) { SetAppOpen(open: false); return; } if (Input.GetMouseButtonDown(0) && HoveringPhoneButton()) { SetAppOpen(open: false); return; } try { UpdateUi(unscaledDeltaTime); } catch (System.Exception e) { UiWarn("screen", e); try { if ((Object)(object)newsPanel != (Object)null && newsPanel.activeSelf != newsOpen) { newsPanel.SetActive(newsOpen); } } catch { } } } private void UiWarn(string where, System.Exception e) { string text = string.Concat(new string[5] { where, ":", ((MemberInfo)e.GetType()).Name, ":", e.Message }); if (uiWarned.Count <= 50 && uiWarned.Add(text)) { ((MelonBase)this).LoggerInstance.Warning(string.Concat(new string[6] { "Phone app (", where, "): ", e.Message, " | ", Trace(e) })); } } private static string V(Vector3 v) { return string.Concat(new string[7] { "(", v.x.ToString("0.00", (IFormatProvider)(object)Inv), ",", v.y.ToString("0.00", (IFormatProvider)(object)Inv), ",", v.z.ToString("0.00", (IFormatProvider)(object)Inv), ")" }); } private static string ObjPath(Transform t) { string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return (text.Length > 160) ? ("..." + text.Substring(text.Length - 160)) : text; } private void HookSaveSystem() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (!cleanupPatched) { cleanupPatched = true; try { MethodInfo val = AccessTools.Method(typeof(SaveManager), "ClearBaseLevelOutdatedSaves", (System.Type[])null, (System.Type[])null); MethodInfo method = typeof(Core).GetMethod("CleanupPrefix", (BindingFlags)40); if (val != (MethodInfo)null && method != (MethodInfo)null) { ((MelonBase)this).HarmonyInstance.Patch((MethodBase)(object)val, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { ((MelonBase)this).LoggerInstance.Warning("Could not find the game's save clean-up method."); } } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Save clean-up patch failed: " + ex.Message); } } if (!saveHooks && Singleton.InstanceExists) { SaveManager instance = Singleton.Instance; instance.onSaveStart.AddListener(Compat.UA(new Action(OnGameSaveStart))); instance.onSaveComplete.AddListener(Compat.UA(new Action(OnGameSaveComplete))); saveHooks = true; } } private static void CleanupPrefix(SaveManager __instance) { try { List approvedBaseLevelPaths = __instance.ApprovedBaseLevelPaths; if (approvedBaseLevelPaths != null && !approvedBaseLevelPaths.Contains("CryptoTrader.txt")) { approvedBaseLevelPaths.Add("CryptoTrader.txt"); } } catch { } } private void OnGameSaveStart() { pendingSnapshot = null; if (!sessionLoaded || string.IsNullOrEmpty(currentSavePath)) { return; } try { pendingSnapshot = BuildSaveString(); pendingSnapshotPath = currentSavePath; } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not capture crypto data for saving: " + ex.Message); } } private void OnGameSaveComplete() { if (pendingSnapshot == null || string.IsNullOrEmpty(pendingSnapshotPath)) { return; } try { if (!Directory.Exists(pendingSnapshotPath)) { return; } string text = Path.Combine(pendingSnapshotPath, "CryptoTrader.txt"); string text2 = text + ".tmp"; File.WriteAllText(text2, pendingSnapshot); if (File.Exists(text)) { File.Delete(text); } File.Move(text2, text); ((MelonBase)this).LoggerInstance.Msg("Crypto data saved with the game (" + Path.GetFileName(pendingSnapshotPath) + ")."); } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not write crypto save file: " + ex.Message); } pendingSnapshot = null; } private void TrackActiveSave() { bool flag = false; string text = null; try { if (Singleton.InstanceExists) { LoadManager instance = Singleton.Instance; flag = instance.IsGameLoaded && PlayerSingleton.InstanceExists; text = instance.LoadedGameFolderPath; } } catch { flag = false; } if (!flag) { if (sessionLoaded) { ResetSession(); ((MelonBase)this).LoggerInstance.Msg("Left the save, crypto data unloaded."); } } else if (!sessionLoaded || !(text == currentSavePath)) { if (sessionLoaded) { ResetSession(); } currentSavePath = text; LoadSession(text); sessionLoaded = true; } } private void ResetSession() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) PcReset(); MiningReset(); MeetReset(); ByteReset(); if (isOpen) { try { SetAppOpen(open: false); } catch { } } isOpen = false; sessionLoaded = false; currentSavePath = null; pendingSnapshot = null; Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; current.Pts.Clear(); current.Owned = 0f; current.Invested = 0f; current.Trend = 0f; current.EventTicks = 0; current.EventDrift = 0f; current.VolBoostTicks = 0; current.VolBoost = 1f; current.Anchor = current.FallbackPrice; } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } for (int i = 0; i < pending.Length; i++) { pending[i] = 0f; } for (int j = 0; j < rigCount.Length; j++) { rigCount[j] = 0; } history.Clear(); news.Clear(); realized = 0f; minedUsd = 0f; mineCoin = 0; totalGameMin = 0L; nextEventMin = -1L; lastEventMin = -100000L; eventDayIdx = -1L; eventsToday = 0; lastEventWasCrash = false; lastDaily = -1; timeMode = 0; timeFailTimer = 0f; sel = 0; viewOffset = 0; unread = 0; qty = 0f; mQty = 0f; portSel = -1; pSellQty = 0f; appIcon = null; appRoot = null; uiBuilt = false; } private void LoadSession(string folder) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) bool flag = false; string text = (string.IsNullOrEmpty(folder) ? null : Path.Combine(folder, "CryptoTrader.txt")); try { if (text != null && File.Exists(text)) { flag = ParseSaveString(File.ReadAllLines(text)); if (flag) { ((MelonBase)this).LoggerInstance.Msg("Loaded crypto data for this save (" + Path.GetFileName(folder) + ")."); } else { ((MelonBase)this).LoggerInstance.Msg("Crypto data in this save belongs to an older game in the same slot, starting fresh."); } } } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not read crypto save file, starting fresh: " + ex.Message); flag = false; } if (!flag) { NewMarket(); ((MelonBase)this).LoggerInstance.Msg("No crypto data in this save yet: empty portfolio."); } Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; if (current.Pts.Count < 2) { List obj = new List(); obj.Add(current); SeedCoins(obj, 20160); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (nextEventMin < 0) { ScheduleNextEvent(totalGameMin); } SetRange(rangeSel); lastShownPrice = coins[sel].Price; forceRefresh = true; chartDirty = true; sparkDirty = true; } private void NewMarket() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; current.Anchor = RefPrice(current); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } SeedCoins(coins, 20160); Enumerator enumerator2 = coins.GetEnumerator(); try { while (enumerator2.MoveNext()) { Coin current2 = enumerator2.Current; ScaleHistory(current2, RefPrice(current2)); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } totalGameMin = 0L; nextEventMin = -1L; } private float RefPrice(Coin c) { float num = default(float); if (refPrices.TryGetValue(c.Symbol, ref num) && num > 0f) { return num; } return c.FallbackPrice; } private static string Esc(string s) { return (s ?? "").Replace(';', ',').Replace('\n', ' ').Replace('\r', ' '); } private string SaveIdentity() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) try { SaveInfo activeSaveInfo = Singleton.Instance.ActiveSaveInfo; if (activeSaveInfo != null) { DateTime dateCreated = activeSaveInfo.DateCreated; return ((DateTime)(ref dateCreated)).Ticks.ToString((IFormatProvider)(object)Inv) + ";" + Esc(activeSaveInfo.OrganisationName); } } catch { } return ""; } private static bool SameGame(string stored, string current) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(stored) || string.IsNullOrEmpty(current)) { return true; } string[] array = stored.Split(';', (StringSplitOptions)0); string[] array2 = current.Split(';', (StringSplitOptions)0); if (array.Length >= 2 && array2.Length >= 2 && array[1].Trim() != array2[1].Trim()) { return false; } long num = default(long); long num2 = default(long); if (long.TryParse(array[0], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num) && long.TryParse(array2[0], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num2)) { TimeSpan val = TimeSpan.FromTicks(num - num2); return Math.Abs(((TimeSpan)(ref val)).TotalHours) < 15.0; } return true; } private string BuildSaveString() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) StringBuilder val = new StringBuilder(coins.Count * 2000 * 9); val.Append("V;5\n"); val.Append("ID;").Append(SaveIdentity()).Append('\n'); val.Append("R;").Append(realized.ToString("R", (IFormatProvider)(object)Inv)).Append(';') .Append(minedUsd.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(mineCoin) .Append('\n'); val.Append("T;").Append(totalGameMin).Append(';') .Append(nextEventMin) .Append(';') .Append(lastEventMin) .Append(';') .Append(eventDayIdx) .Append(';') .Append(eventsToday) .Append(';') .Append(lastEventWasCrash ? 1 : 0) .Append('\n'); for (int i = 0; i < coins.Count; i++) { val.Append("C;").Append(coins[i].Symbol).Append(';') .Append(coins[i].Owned.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(coins[i].Invested.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(pending[i].ToString("R", (IFormatProvider)(object)Inv)) .Append('\n'); } PcAppendSave(val); MiningAppendSave(val); ByteAppendSave(val); MeetAppendSave(val); for (int j = 0; j < 3; j++) { val.Append("RIG;").Append(j).Append(';') .Append(rigCount[j]) .Append('\n'); } Enumerator enumerator = history.GetEnumerator(); try { while (enumerator.MoveNext()) { TradeRecord current = enumerator.Current; val.Append("H;").Append(Esc(current.Time)).Append(';') .Append(current.Kind) .Append(';') .Append(current.Symbol) .Append(';') .Append(current.Units.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current.Price.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current.Total.ToString("R", (IFormatProvider)(object)Inv)) .Append('\n'); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } for (int num = news.Count - 1; num >= 0; num--) { val.Append("N;").Append(news[num].Positive ? 1 : 0).Append(';') .Append(Esc(news[num].Time)) .Append(';') .Append(Esc(news[num].Text)) .Append('\n'); } Enumerator enumerator2 = coins.GetEnumerator(); try { while (enumerator2.MoveNext()) { Coin current2 = enumerator2.Current; int count = current2.Pts.Count; int num2 = Mathf.Max(0, count - 1440); val.Append("M;").Append(current2.Symbol).Append(';') .Append(current2.Anchor.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current2.Trend.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current2.EventDrift.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current2.EventTicks) .Append(';') .Append(current2.VolBoost.ToString("R", (IFormatProvider)(object)Inv)) .Append(';') .Append(current2.VolBoostTicks) .Append(';'); bool flag = true; for (int k = num2 % 60; k < num2; k += 60) { if (!flag) { val.Append(','); } val.Append(current2.Pts[k].ToString("G7", (IFormatProvider)(object)Inv)); flag = false; } val.Append(';').Append(num2 % 60).Append(';'); for (int l = num2; l < count; l++) { if (l > num2) { val.Append(','); } val.Append(current2.Pts[l].ToString("G7", (IFormatProvider)(object)Inv)); } val.Append('\n'); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } return ((object)val).ToString(); } private bool ParseSaveString(string[] lines) { string current = SaveIdentity(); foreach (string text in lines) { if (text.StartsWith("ID;") && !SameGame(text.Substring(3).Trim(), current)) { return false; } } int num = 0; foreach (string text2 in lines) { string[] array = text2.Split(';', (StringSplitOptions)0); try { if (array[0] == "R" && array.Length >= 4) { realized = float.Parse(array[1], (IFormatProvider)(object)Inv); minedUsd = float.Parse(array[2], (IFormatProvider)(object)Inv); mineCoin = Mathf.Clamp(int.Parse(array[3], (IFormatProvider)(object)Inv), 0, coins.Count - 1); } else if (array[0] == "T" && array.Length >= 6) { totalGameMin = long.Parse(array[1], (IFormatProvider)(object)Inv); nextEventMin = long.Parse(array[2], (IFormatProvider)(object)Inv); lastEventMin = long.Parse(array[3], (IFormatProvider)(object)Inv); eventDayIdx = long.Parse(array[4], (IFormatProvider)(object)Inv); eventsToday = int.Parse(array[5], (IFormatProvider)(object)Inv); if (array.Length >= 7) { lastEventWasCrash = array[6] == "1"; } } else if (array[0] == "C" && array.Length >= 5) { int num2 = IndexOf(array[1]); if (num2 >= 0) { coins[num2].Owned = Mathf.Max(0f, float.Parse(array[2], (IFormatProvider)(object)Inv)); coins[num2].Invested = Mathf.Max(0f, float.Parse(array[3], (IFormatProvider)(object)Inv)); pending[num2] = Mathf.Max(0f, float.Parse(array[4], (IFormatProvider)(object)Inv)); } } else if (array[0] == "RIG" && array.Length >= 3) { int num3 = int.Parse(array[1], (IFormatProvider)(object)Inv); if (num3 >= 0 && num3 < 3) { rigCount[num3] = Mathf.Max(0, int.Parse(array[2], (IFormatProvider)(object)Inv)); } } else if (array[0] == "PC" && array.Length >= 6) { PcParseLine(array); } else if (array[0] == "PCH" && array.Length >= 8) { RigParseLine(array); } else if (array[0] == "BOX" || array[0] == "PWR") { MiningParseLine(array); } else if (array[0] == "BYT" || array[0] == "BYM") { ByteParseLine(array); } else if (array[0] == "BMT") { MeetParseLine(array); } else if (array[0] == "H" && array.Length >= 7) { TradeRecord tradeRecord = new TradeRecord(); tradeRecord.Time = array[1]; tradeRecord.Kind = array[2]; tradeRecord.Symbol = array[3]; tradeRecord.Units = float.Parse(array[4], (IFormatProvider)(object)Inv); tradeRecord.Price = float.Parse(array[5], (IFormatProvider)(object)Inv); tradeRecord.Total = float.Parse(array[6], (IFormatProvider)(object)Inv); history.Add(tradeRecord); } else if (array[0] == "N" && array.Length >= 4) { NewsItem newsItem = new NewsItem(); newsItem.Positive = array[1] == "1"; newsItem.Time = array[2]; newsItem.Text = array[3]; news.Insert(0, newsItem); if (news.Count > 12) { news.RemoveAt(news.Count - 1); } } else if (array[0] == "M" && array.Length >= 11) { int num4 = IndexOf(array[1]); if (num4 >= 0 && RestoreMarket(coins[num4], array)) { num++; } } } catch { } } return true; } private bool RestoreMarket(Coin c, string[] f) { float num = float.Parse(f[2], (IFormatProvider)(object)Inv); if (num <= 0f) { return false; } List val = ParseList(f[8]); int num2 = int.Parse(f[9], (IFormatProvider)(object)Inv); List val2 = ParseList(f[10]); if (val2.Count < 2) { return false; } c.Anchor = num; c.Trend = float.Parse(f[3], (IFormatProvider)(object)Inv); c.EventDrift = float.Parse(f[4], (IFormatProvider)(object)Inv); c.EventTicks = int.Parse(f[5], (IFormatProvider)(object)Inv); c.VolBoost = float.Parse(f[6], (IFormatProvider)(object)Inv); c.VolBoostTicks = int.Parse(f[7], (IFormatProvider)(object)Inv); c.Pts.Clear(); List val3 = new List((System.Collections.Generic.IEnumerable)val); val3.Add(val2[0]); float sigma = c.DailyVol / 37.94733f; for (int i = 0; i < val3.Count - 1; i++) { AppendBridge(c.Pts, val3[i], val3[i + 1], 60, sigma); } c.Pts.AddRange((System.Collections.Generic.IEnumerable)val2); if (c.Pts.Count > 20160) { c.Pts.RemoveRange(0, c.Pts.Count - 20160); } return true; } private static void AppendBridge(List dst, float a, float b, int steps, float sigma) { float num = Mathf.Log(Mathf.Max(a, 1E-12f)); float num2 = Mathf.Log(Mathf.Max(b, 1E-12f)); float[] array = new float[steps + 1]; for (int i = 1; i <= steps; i++) { array[i] = array[i - 1] + Coin.Gauss() * sigma; } for (int j = 0; j < steps; j++) { float num3 = (float)j / (float)steps; float num4 = array[j] - num3 * array[steps]; dst.Add(Mathf.Exp(Mathf.Lerp(num, num2, num3) + num4)); } } private static List ParseList(string s) { List val = new List(); if (string.IsNullOrEmpty(s)) { return val; } string[] array = s.Split(',', (StringSplitOptions)0); float num = default(float); foreach (string text in array) { if (float.TryParse(text, (NumberStyles)167, (IFormatProvider)(object)Inv, ref num) && num > 0f) { val.Add(num); } } return val; } private void SaveSettings() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00af: 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) try { StringBuilder val = new StringBuilder(); val.Append("S;").Append(candleMode ? 1 : 0).Append(';') .Append(eventsOn ? 1 : 0) .Append(';') .Append(rangeSel) .Append(';') .Append(curIdx) .Append(';') .Append(alertIdx) .Append(';') .Append(homeMine ? 1 : 0) .Append(';') .Append(Lang.Es ? 1 : 0) .Append('\n'); Enumerator enumerator = favs.GetEnumerator(); try { while (enumerator.MoveNext()) { string current = enumerator.Current; val.Append("FAV;").Append(current).Append('\n'); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (!Directory.Exists(DataDir)) { Directory.CreateDirectory(DataDir); } File.WriteAllText(SettingsPath, ((object)val).ToString()); } catch { } } private void LoadSettings() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 try { Lang.Set((int)Application.systemLanguage == 34); if (!File.Exists(SettingsPath)) { return; } string[] array = File.ReadAllLines(SettingsPath); int num = default(int); foreach (string text in array) { string[] array2 = text.Split(';', (StringSplitOptions)0); if (array2[0] == "S" && array2.Length >= 4) { candleMode = array2[1] == "1"; eventsOn = true; if (int.TryParse(array2[3], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num)) { rangeSel = Mathf.Clamp(num, 0, 3); } if (array2.Length >= 7) { if (int.TryParse(array2[4], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num)) { curIdx = Mathf.Clamp(num, 0, CurSigns.Length - 1); } if (int.TryParse(array2[5], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num)) { alertIdx = Mathf.Clamp(num, 0, AlertSteps.Length - 1); } homeMine = array2[6] == "1"; } if (array2.Length >= 8) { Lang.Set(array2[7] == "1"); } } else if (array2[0] == "FAV" && array2.Length >= 2 && !favs.Contains(array2[1])) { favs.Add(array2[1]); } } } catch { } } private void LoadRefCache() { try { if (!File.Exists(RefCachePath)) { return; } string[] array = File.ReadAllLines(RefCachePath); long num = default(long); float num2 = default(float); foreach (string text in array) { string[] array2 = text.Split(';', (StringSplitOptions)0); if (array2[0] == "TIME" && array2.Length >= 2) { if (long.TryParse(array2[1], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num)) { refFetched = new System.DateTime(num, (DateTimeKind)1); } } else if (array2[0] == "P" && array2.Length >= 3 && float.TryParse(array2[2], (NumberStyles)167, (IFormatProvider)(object)Inv, ref num2) && num2 > 0f) { refPrices[array2[1]] = num2; } } if (refPrices.Count > 0) { refLive = true; refStatus = "CoinGecko prices from " + refFetched.ToLocalTime().ToString("dd MMM HH:mm", (IFormatProvider)(object)Inv); } } catch { } } private void SaveRefCache() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) try { StringBuilder val = new StringBuilder(); val.Append("TIME;").Append(refFetched.Ticks).Append('\n'); Enumerator enumerator = refPrices.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; val.Append("P;").Append(current.Key).Append(';') .Append(current.Value.ToString("R", (IFormatProvider)(object)Inv)) .Append('\n'); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (!Directory.Exists(DataDir)) { Directory.CreateDirectory(DataDir); } File.WriteAllText(RefCachePath, ((object)val).ToString()); } catch { } } private void FetchReferencePrices(bool applyToMarket) { if (!refFetching) { refFetching = true; refStatus = "Downloading prices from CoinGecko..."; MelonCoroutines.Start(FetchRoutine(applyToMarket)); } } [IteratorStateMachine(typeof(d__404))] private System.Collections.IEnumerator FetchRoutine(bool applyToMarket) { StringBuilder ids = new StringBuilder(); Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin c = enumerator.Current; if (ids.Length > 0) { ids.Append(','); } ids.Append(c.GeckoId); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } UnityWebRequest req = UnityWebRequest.Get("https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=" + (object)ids); req.timeout = 12; req.SetRequestHeader("Accept", "application/json"); yield return req.SendWebRequest(); try { if ((int)req.result != 1) { string why = ((req.responseCode == 429) ? "rate limit reached, try again later" : (req.error ?? "no connection")); refStatus = (refLive ? "Using saved prices. " : "Using built-in prices. ") + "Download failed: " + why; ((MelonBase)this).LoggerInstance.Msg("Reference prices not updated (" + why + ")."); yield break; } int found = 0; string body = req.downloadHandler.text ?? ""; Enumerator enumerator2 = coins.GetEnumerator(); try { float v = default(float); while (enumerator2.MoveNext()) { Coin c2 = enumerator2.Current; Match m = Regex.Match(body, "\"" + Regex.Escape(c2.GeckoId) + "\"\\s*:\\s*\\{\\s*\"usd\"\\s*:\\s*([0-9eE\\.\\-\\+]+)"); if (((Group)m).Success && float.TryParse(((Capture)m.Groups[1]).Value, (NumberStyles)167, (IFormatProvider)(object)Inv, ref v) && v > 0f) { refPrices[c2.Symbol] = v; found++; } } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } if (found > 0) { refFetched = System.DateTime.UtcNow; refLive = true; SaveRefCache(); refStatus = string.Concat(new string[5] { "CoinGecko prices from ", refFetched.ToLocalTime().ToString("dd MMM HH:mm", (IFormatProvider)(object)Inv), " (", found.ToString(), " coins)" }); ((MelonBase)this).LoggerInstance.Msg("Downloaded real-world reference prices for " + found + " coins."); if (applyToMarket && sessionLoaded) { ApplyReferenceToMarket(); } } else { refStatus = "Download returned no prices, keeping current ones"; } } catch (System.Exception ex) { System.Exception e = ex; refStatus = "Price download failed"; ((MelonBase)this).LoggerInstance.Warning("Reference price download failed: " + e.Message); } finally { refFetching = false; req.Dispose(); forceRefresh = true; } } private void ApplyReferenceToMarket() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = coins.GetEnumerator(); try { float num = default(float); while (enumerator.MoveNext()) { Coin current = enumerator.Current; if (!current.Stable && refPrices.TryGetValue(current.Symbol, ref num) && num > 0f) { current.Anchor = num; } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } Toast("Market will now drift toward real-world prices", cAccent); } private void UpdateMarketClock(float dt) { if (timeMode != 2) { if (TryReadDailyMinutes(out var minutes)) { if (timeMode != 1) { timeMode = 1; ((MelonBase)this).LoggerInstance.Msg("Market runs on the in-game clock."); } timeFailTimer = 0f; if (lastDaily < 0) { lastDaily = minutes; return; } int num = minutes - lastDaily; if (num != 0) { if (num < 0) { num += 1440; } lastDaily = minutes; RunTicks(num); } return; } timeFailTimer += dt; if (timeFailTimer < 8f) { return; } timeMode = 2; ((MelonBase)this).LoggerInstance.Warning("Could not read the in-game clock, using real time (1 market minute per second)."); } realTickTimer += dt; int num2 = 0; while (realTickTimer >= 1f && num2 < 5) { realTickTimer -= 1f; num2++; } if (num2 > 0) { RunTicks(num2); } } private void RunTicks(int n) { n = Mathf.Clamp(n, 0, 2880); catchUpEventFired = false; bool flag = n > 30; for (int i = 0; i < n; i++) { DoTick(flag); } if (flag) { ((MelonBase)this).LoggerInstance.Msg("Market caught up " + n + " in-game minutes."); } } private bool TryReadDailyMinutes(out int minutes) { minutes = 0; try { if (timeType == (System.Type)null) { Assembly assembly = typeof(HomeScreen).Assembly; timeType = assembly.GetType("Il2CppScheduleOne.GameTime.TimeManager"); if (timeType == (System.Type)null) { System.Type[] array = SafeTypes(assembly); foreach (System.Type type in array) { if (((MemberInfo)type).Name == "TimeManager" && type.Namespace != null && type.Namespace.StartsWith("Il2CppScheduleOne")) { timeType = type; break; } } } if (timeType == (System.Type)null) { return false; } } object networkSingleton = GetNetworkSingleton(timeType); if (networkSingleton == null) { return false; } object member = GetMember(networkSingleton, "DailyMinSum"); if (member == null) { return false; } minutes = Convert.ToInt32(member, (IFormatProvider)(object)Inv); return minutes >= 0 && minutes < 100000; } catch { return false; } } private string ClockAgo(int minutesAgo) { if (timeMode != 1 || lastDaily < 0 || timeType == (System.Type)null) { return null; } try { int num = (int)((((long)lastDaily - (long)minutesAgo) % 1440 + 1440) % 1440); if (miTo24 == (MethodInfo)null) { miTo24 = FindStatic(timeType, "Get24HourTimeFromMinSum", typeof(int)); } if (miTo12 == (MethodInfo)null) { miTo12 = FindStatic(timeType, "Get12HourTime", typeof(float)); } if (miTo24 == (MethodInfo)null || miTo12 == (MethodInfo)null) { return null; } object obj = InvokeStatic(miTo24, num); if (obj == null) { return null; } object obj2 = InvokeStatic(miTo12, Convert.ToSingle(obj, (IFormatProvider)(object)Inv)); return obj2 as string; } catch { return null; } } private string GameStamp() { string text = ClockAgo(0); long num = totalGameMin / 1440 + 1; if (text == null) { return "Day " + num; } return "Day " + num + ", " + text; } private void SeedCoins(List list, int n) { //IL_0003: 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_0092: 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) Enumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; current.Pts.Clear(); current.Trend = 0f; current.EventTicks = 0; current.VolBoostTicks = 0; current.Pts.Add(current.Anchor * (current.Stable ? 1f : Random.Range(0.88f, 1.12f))); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } for (int i = 0; i < n; i++) { float marketZ = Coin.Gauss(); Enumerator enumerator2 = list.GetEnumerator(); try { while (enumerator2.MoveNext()) { Coin current2 = enumerator2.Current; current2.Step(marketZ); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } private void DoTick(bool batch) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) float marketZ = Coin.Gauss(); Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; current.Step(marketZ); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } totalGameMin++; MineMinute(); if (viewOffset > 0) { viewOffset++; } CheckEvent(batch); if (!batch) { CheckPriceAlerts(); } chartDirty = true; sparkDirty = true; } private void ScheduleNextEvent(long from) { float num = Mathf.Clamp(Random.value, 0.0001f, 0.9999f); float num2 = 360f - Mathf.Log(num) * 1960f; num2 = Mathf.Min(num2, 5760f - Random.Range(0f, 600f)); nextEventMin = from + Mathf.Max(360, Mathf.RoundToInt(num2)); } private void CheckEvent(bool batch) { if (totalGameMin < nextEventMin) { return; } if (!eventsOn) { ScheduleNextEvent(totalGameMin); return; } long num = totalGameMin / 1440; if (num != eventDayIdx) { eventDayIdx = num; eventsToday = 0; } if (eventsToday >= 2) { nextEventMin = (num + 1) * 1440 + Random.Range(60, 720); return; } if (totalGameMin - lastEventMin < 360) { nextEventMin = lastEventMin + 360 + Random.Range(30, 240); return; } if (batch && catchUpEventFired) { ScheduleNextEvent(totalGameMin); return; } SpawnEvent(); eventsToday++; lastEventMin = totalGameMin; if (batch) { catchUpEventFired = true; } ScheduleNextEvent(totalGameMin); } private List Tradable() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) List val = new List(); Enumerator enumerator = coins.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; if (!current.Stable) { val.Add(current); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return val; } private void SpawnEvent() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown List val = Tradable(); Coin coin = val[Random.Range(0, val.Count)]; int num = Random.Range(0, 100); bool flag = false; if (lastEventWasCrash && num < 35) { float num2 = Random.Range(0.03f, 0.06f); Enumerator enumerator = val.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; Push(current, num2 * current.EventSens, Random.Range(480, 900)); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } AddNews("Market recovering after the sell-off", positive: true); } else if (num < 16) { float num3 = Random.Range(0.04f, 0.09f); Enumerator enumerator2 = val.GetEnumerator(); try { while (enumerator2.MoveNext()) { Coin current2 = enumerator2.Current; Push(current2, num3 * current2.EventSens * Random.Range(0.6f, 1.3f), Random.Range(240, 600)); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } AddNews("Bull run: crypto prices are climbing", positive: true); } else if (num < 29) { float num4 = Random.Range(0.06f, 0.13f); Enumerator enumerator3 = val.GetEnumerator(); try { while (enumerator3.MoveNext()) { Coin current3 = enumerator3.Current; Push(current3, (0f - num4) * current3.EventSens * Random.Range(0.6f, 1.3f), Random.Range(120, 360)); } } finally { ((System.IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } AddNews("Market crash: heavy selling across crypto", positive: false); flag = true; } else if (num < 49) { float totalMove = Random.Range(0.1f, 0.22f) * Mathf.Min(coin.EventSens, 1.4f); Push(coin, totalMove, Random.Range(120, 480)); AddNews(coin.Name + " hype: buyers pile in", positive: true); } else if (num < 66) { float num5 = Random.Range(0.08f, 0.16f) * Mathf.Min(coin.EventSens, 1.4f); Push(coin, 0f - num5, Random.Range(60, 300)); AddNews("Bad news hits " + coin.Name, positive: false); } else if (num < 77) { int volBoostTicks = Random.Range(240, 480); Enumerator enumerator4 = val.GetEnumerator(); try { while (enumerator4.MoveNext()) { Coin current4 = enumerator4.Current; current4.VolBoost = Random.Range(1.8f, 2.6f); current4.VolBoostTicks = volBoostTicks; } } finally { ((System.IDisposable)enumerator4/*cast due to .constrained prefix*/).Dispose(); } AddNews("Unexpected volatility shakes the market", positive: false); } else { List val2 = new List((System.Collections.Generic.IEnumerable)val); int num6 = Random.Range(3, 7); List val3 = new List(); for (int i = 0; i < num6; i++) { if (val2.Count <= 0) { break; } int num7 = Random.Range(0, val2.Count); val3.Add(val2[num7]); val2.RemoveAt(num7); } bool flag2 = Random.value < 0.55f; float num8 = Random.Range(0.05f, 0.12f); StringBuilder val4 = new StringBuilder(); for (int j = 0; j < val3.Count; j++) { Push(val3[j], (flag2 ? num8 : (0f - num8)) * val3[j].EventSens, Random.Range(180, 540)); if (j > 0) { val4.Append(", "); } val4.Append(val3[j].Symbol); } AddNews((flag2 ? "Altcoin rally: " : "Altcoins slide: ") + (object)val4, flag2); } lastEventWasCrash = flag; } private void Push(Coin c, float totalMove, int minutes) { totalMove = Mathf.Clamp(totalMove, -0.35f, 0.45f); c.EventDrift = Mathf.Log(1f + totalMove) / (float)Mathf.Max(1, minutes); c.EventTicks = minutes; } private void AddNews(string text, bool positive) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) NewsItem newsItem = new NewsItem(); newsItem.Text = text; newsItem.Positive = positive; newsItem.Time = GameStamp(); news.Insert(0, newsItem); if (news.Count > 12) { news.RemoveAt(news.Count - 1); } if (!newsOpen || !isOpen) { unread++; } if (isOpen && uiBuilt) { Toast(text, positive ? cUp : cDown); } ((MelonBase)this).LoggerInstance.Msg("Market event: " + text); forceRefresh = true; } private string MarketMood() { //IL_0010: 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) float num = 0f; List val = Tradable(); Enumerator enumerator = val.GetEnumerator(); try { while (enumerator.MoveNext()) { Coin current = enumerator.Current; num += current.ChangePct(1440); } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } num /= (float)Mathf.Max(1, val.Count); return (num > 2f) ? "Bullish" : ((num < -2f) ? "Bearish" : "Stable"); } private void InitTypes() { if (!(phoneType != (System.Type)null)) { Assembly assembly = typeof(HomeScreen).Assembly; phoneType = assembly.GetType("Il2CppScheduleOne.UI.Phone.Phone"); appsCanvasType = assembly.GetType("Il2CppScheduleOne.UI.Phone.AppsCanvas"); if (appsCanvasType == (System.Type)null) { appsCanvasType = FindTypeByName("AppsCanvas"); } } } private void ToggleApp() { SetAppOpen(!isOpen); } private void SetAppOpen(bool open) { if (open == isOpen) { return; } try { InitTypes(); if (!EnsureContainer()) { Warn("Could not find the phone's app area."); return; } object playerSingleton = GetPlayerSingleton(phoneType); object playerSingleton2 = GetPlayerSingleton(appsCanvasType); HomeScreen instance = PlayerSingleton.Instance; if (open) { object obj = GetStatic(phoneType, "ActiveApp"); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (!((Object)(object)val != (Object)null) || !((Object)(object)val != (Object)(object)appRoot)) { CallMethod(playerSingleton2, "SetIsOpen", true); appRoot.SetActive(true); if (!uiBuilt) { BuildUi(); } if ((Object)(object)instance != (Object)null) { instance.SetIsOpen(false); } CallMethod(playerSingleton, "SetIsHorizontal", true); CallMethod(playerSingleton, "SetLookOffsetMultiplier", 0.6f); SetStatic(phoneType, "ActiveApp", appRoot); isOpen = true; forceRefresh = true; chartDirty = true; sparkDirty = true; chartFade = 1f; } } else { isOpen = false; CallMethod(playerSingleton2, "SetIsOpen", false); if ((Object)(object)instance != (Object)null) { instance.SetIsOpen(true); } object obj2 = GetStatic(phoneType, "ActiveApp"); GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val2 == (Object)(object)appRoot) { SetStatic(phoneType, "ActiveApp", null); } CallMethod(playerSingleton, "SetIsHorizontal", false); CallMethod(playerSingleton, "SetLookOffsetMultiplier", 1f); if ((Object)(object)appRoot != (Object)null) { appRoot.SetActive(false); } } } catch (System.Exception ex) { Warn("Open/close failed: " + (object)ex); } } private void SoftClose() { isOpen = false; if ((Object)(object)appRoot != (Object)null) { appRoot.SetActive(false); } } private void HookPhoneEvents() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown try { InitTypes(); object playerSingleton = GetPlayerSingleton(phoneType); if (playerSingleton == null || playerSingleton == hookedPhone) { return; } Phone val = (Phone)((playerSingleton is Phone) ? playerSingleton : null); if (!((Object)(object)val == (Object)null)) { if ((Delegate)(object)closeAppsIl == (Delegate)null) { closeAppsIl = Compat.GA(new Action(OnPhoneCloseApps)); } Action val2 = val.closeApps; if ((Delegate)(object)val2 != (Delegate)null) { Delegate obj = Delegate.Remove((Delegate)(object)val2, (Delegate)(object)closeAppsIl); val2 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast() : null); } val.closeApps = (((Delegate)(object)val2 == (Delegate)null) ? closeAppsIl : ((Il2CppObjectBase)Delegate.Combine((Delegate)(object)val2, (Delegate)(object)closeAppsIl)).Cast()); hookedPhone = playerSingleton; } } catch { } } private void OnPhoneCloseApps() { if (isOpen) { SetAppOpen(open: false); } } private bool PhoneIsOpen() { object member = GetMember(GetPlayerSingleton(phoneType), "IsOpen"); return !(member is bool) || (bool)member; } private bool PhoneAcceptingInput() { object member = GetMember(GetPlayerSingleton(phoneType), "State"); object member2 = GetMember(member, "IsAcceptingInput"); return !(member2 is bool) || (bool)member2; } private bool HoveringPhoneButton() { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) try { int num = LayerMask.NameToLayer("Overlay"); if (num < 0) { return false; } if ((Object)(object)overlayCam == (Object)null) { Camera[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)Camera.allCameras); for (int i = 0; i < array.Length; i++) { if (array[i].cullingMask == 1 << num) { overlayCam = array[i]; break; } } if ((Object)(object)overlayCam == (Object)null) { for (int j = 0; j < array.Length; j++) { if ((array[j].cullingMask & (1 << num)) != 0) { overlayCam = array[j]; break; } } } } if ((Object)(object)overlayCam == (Object)null) { return false; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(overlayCam.ScreenPointToRay(Input.mousePosition), ref val, 2f, 1 << num)) { return ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name == "Button"; } } catch { } return false; } private void TryRegisterExit() { exitRegistered = false; try { if ((Delegate)(object)exitIl == (Delegate)null) { exitIl = DelegateSupport.ConvertDelegate((System.Delegate)(object)(Action)([CompilerGenerated] (ExitAction a) => { OnExitAction(a); })); } try { GameInput.DeregisterExitListener(exitIl); } catch { } GameInput.RegisterExitListener(exitIl, 1); exitRegistered = true; } catch (System.Exception ex) { ((MelonBase)this).LoggerInstance.Warning("ESC hook not available, using fallback: " + ex.Message); } } private void OnExitAction(object action) { try { if (isOpen && action != null && (!(GetMember(action, "Used") is int num) || num == 0) && PhoneAcceptingInput()) { SetMember(action, "Used", true); SetAppOpen(open: false); } } catch { } } private void TryAddPhoneIcon() { //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown if ((Object)(object)appIcon != (Object)null) { return; } try { HomeScreen instance = PlayerSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } object obj = Compat.Get(instance, "appIconContainer"); RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null); object obj2 = Compat.Get(instance, "appIconPrefab"); GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } appIcon = Object.Instantiate(val2, (Transform)(object)val); ((Object)appIcon).name = "CryptoTrader_AppIcon"; Transform val3 = appIcon.transform.Find("Label"); if ((Object)(object)val3 != (Object)null) { Text component = ((Component)val3).GetComponent(); if ((Object)(object)component != (Object)null) { component.text = Lang.T("Crypto"); if ((Object)(object)component.font != (Object)null) { uiFont = component.font; } } } if ((Object)(object)iconSprite == (Object)null) { iconSprite = MakeIcon(); } Transform val4 = appIcon.transform.Find("Mask/Image"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).GetComponent().sprite = iconSprite; } Transform val5 = appIcon.transform.Find("Notifications"); if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive(false); } for (int i = 0; i < appIcon.transform.childCount; i++) { Transform child = appIcon.transform.GetChild(i); string text = ((Object)child).name.ToLower(); if (text.Contains("notif") || text.Contains("badge") || text.Contains("bubble") || text.Contains("count")) { ((Component)child).gameObject.SetActive(false); } } Button component2 = appIcon.GetComponent