Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of CasinoTracker v1.0.1
CasinoTracker.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using CasinoTracker; using HarmonyLib; using Il2CppScheduleOne.Casino; using Il2CppSystem; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API.PhoneApp; using S1API.UI; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(MyMod), "CasinoTracker", "1.0.0", "Hideshi", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CasinoTracker")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CasinoTracker")] [assembly: AssemblyTitle("CasinoTracker")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CasinoTracker { public class BlackjackStats { public int total_plays; public int total_wins; public int total_losses; public int total_pushes; public int total_profit; public int total_spent; public float profit_per_play; private static string SavePath => Path.Combine(MelonEnvironment.ModsDirectory, "CasinoTracker", "BlackjackStats.json"); public static void SaveFromFields() { BlackjackStats blackjackStats = new BlackjackStats { total_plays = BlackJack.total_plays, total_wins = BlackJack.total_wins, total_losses = BlackJack.total_losses, total_pushes = BlackJack.total_pushes, total_profit = BlackJack.total_profit, total_spent = BlackJack.total_spent, profit_per_play = BlackJack.profit_per_play }; string contents = JsonConvert.SerializeObject((object)blackjackStats, (Formatting)1); File.WriteAllText(SavePath, contents); } public static void LoadToFields() { if (File.Exists(SavePath)) { string text = File.ReadAllText(SavePath); BlackjackStats blackjackStats = JsonConvert.DeserializeObject<BlackjackStats>(text); if (blackjackStats != null) { BlackJack.total_plays = blackjackStats.total_plays; BlackJack.total_wins = blackjackStats.total_wins; BlackJack.total_losses = blackjackStats.total_losses; BlackJack.total_pushes = blackjackStats.total_pushes; BlackJack.total_profit = blackjackStats.total_profit; BlackJack.total_spent = blackjackStats.total_spent; BlackJack.profit_per_play = blackjackStats.profit_per_play; } } } } public class BlackJack : MelonMod { [HarmonyPatch(typeof(BlackjackGameController), "GetPayout")] public static class BlackjackGameController_GetPayout_Patch { public static void Postfix(float bet, EPayoutType payout, float __result) { UpdateTracker(((object)(EPayoutType)(ref payout)).ToString(), (int)bet); GamblerApp.UpdateBlackJackStatsText(); } public static void UpdateTracker(string outcome, int BetAmount) { switch (outcome) { case "Win": total_plays++; total_wins++; total_profit += BetAmount * 2 - BetAmount; total_spent += BetAmount; break; case "Push": total_plays++; total_pushes++; total_profit += BetAmount - BetAmount; total_spent += BetAmount; break; case "None": total_plays++; total_losses++; total_profit -= BetAmount; total_spent += BetAmount; break; default: MelonLogger.Warning("Unknown outcome: " + outcome); break; } win_rate = ((total_plays > 0) ? ((float)total_wins / (float)total_plays * 100f) : 0f); win_rate = (float)Math.Round(win_rate, 2); profit_per_play = ((total_plays > 0) ? ((float)total_profit / (float)total_plays) : 0f); profit_per_play = (float)Math.Round(profit_per_play, 2); BlackjackStats.SaveFromFields(); } } public static int total_wins; public static int total_plays; public static int total_losses; public static int total_pushes; public static int total_spent; public static int total_profit; public static float win_rate; public static float profit_per_play; } public class MyMod : MelonMod { public override void OnInitializeMelon() { MelonLogger.Msg("Initialized CasinoTracker."); MelonLogger.Msg("Attempting to load stats from JSON files"); RideTheBusStats.LoadToFields(); BlackjackStats.LoadToFields(); SlotStats.LoadToFields(); } public override void OnDeinitializeMelon() { MelonLogger.Msg("Deinitialized CasinoTracker."); } } public class GamblerApp : PhoneApp { private string iconPath = Path.Combine(MelonEnvironment.ModsDirectory, "CasinoTracker/assets", "app_icon.png"); private static Text slots_total_wins_text; private static Text slots_total_spins_text; private static Text slots_total_losses_text; private static Text slots_total_spent_text; private static Text slots_total_profit_text; private static Text slots_win_rate_text; private static Text slots_profit_per_spin_text; private static Text slots_total_mini_wins_text; private static Text slots_total_small_wins_text; private static Text slots_total_big_wins_text; private static Text slots_total_jackpots_text; private static Text blackjack_total_wins_text; private static Text blackjack_total_pushes_text; private static Text blackjack_total_plays_text; private static Text blackjack_total_losses_text; private static Text blackjack_total_spent_text; private static Text blackjack_total_profit_text; private static Text blackjack_win_rate_text; private static Text blackjack_profit_per_play_text; private static Text rtb_total_plays_text; private static Text rtb_total_spent_text; private static Text rtb_total_profit_text; private static Text rtb_profit_per_play_text; private static Text rtb_times_at_r1_text; private static Text rtb_times_at_r2_text; private static Text rtb_times_at_r3_text; private static Text rtb_times_at_r4_text; protected override string AppName => "GamblerApp"; protected override string AppTitle => "Casino Stats"; protected override string IconLabel => "Casino Stats"; protected override string IconFileName => iconPath; protected override void OnCreated() { ((PhoneApp)this).OnCreated(); MelonLogger.Msg("[GamblerApp] OnCreated called."); } protected override void OnCreatedUI(GameObject container) { //IL_000c: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_092d: Unknown result type (might be due to invalid IL or missing references) //IL_094b: Unknown result type (might be due to invalid IL or missing references) //IL_095a: Unknown result type (might be due to invalid IL or missing references) //IL_096e: Unknown result type (might be due to invalid IL or missing references) //IL_098c: Unknown result type (might be due to invalid IL or missing references) //IL_099b: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09cd: Unknown result type (might be due to invalid IL or missing references) //IL_09dc: Unknown result type (might be due to invalid IL or missing references) //IL_09f0: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_0a1d: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a4f: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_0a72: Unknown result type (might be due to invalid IL or missing references) //IL_0a90: Unknown result type (might be due to invalid IL or missing references) //IL_0a9f: Unknown result type (might be due to invalid IL or missing references) //IL_0ab3: Unknown result type (might be due to invalid IL or missing references) //IL_0ad1: Unknown result type (might be due to invalid IL or missing references) //IL_0ae0: Unknown result type (might be due to invalid IL or missing references) //IL_0af4: Unknown result type (might be due to invalid IL or missing references) //IL_0da7: Unknown result type (might be due to invalid IL or missing references) //IL_0db6: Unknown result type (might be due to invalid IL or missing references) //IL_0dca: Unknown result type (might be due to invalid IL or missing references) //IL_0de8: Unknown result type (might be due to invalid IL or missing references) //IL_0df7: Unknown result type (might be due to invalid IL or missing references) //IL_0e0b: Unknown result type (might be due to invalid IL or missing references) //IL_0e29: Unknown result type (might be due to invalid IL or missing references) //IL_0e38: Unknown result type (might be due to invalid IL or missing references) //IL_0e4c: Unknown result type (might be due to invalid IL or missing references) //IL_0e6a: Unknown result type (might be due to invalid IL or missing references) //IL_0e79: Unknown result type (might be due to invalid IL or missing references) //IL_0e8d: Unknown result type (might be due to invalid IL or missing references) //IL_0eab: Unknown result type (might be due to invalid IL or missing references) //IL_0eba: Unknown result type (might be due to invalid IL or missing references) //IL_0ece: Unknown result type (might be due to invalid IL or missing references) //IL_0eec: Unknown result type (might be due to invalid IL or missing references) //IL_0efb: Unknown result type (might be due to invalid IL or missing references) //IL_0f0f: Unknown result type (might be due to invalid IL or missing references) //IL_0f2d: Unknown result type (might be due to invalid IL or missing references) //IL_0f3c: Unknown result type (might be due to invalid IL or missing references) //IL_0f50: Unknown result type (might be due to invalid IL or missing references) //IL_0f6e: Unknown result type (might be due to invalid IL or missing references) //IL_0f7d: Unknown result type (might be due to invalid IL or missing references) //IL_0f91: Unknown result type (might be due to invalid IL or missing references) //IL_0faf: Unknown result type (might be due to invalid IL or missing references) //IL_0fbe: Unknown result type (might be due to invalid IL or missing references) //IL_0fd2: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("Background", container.transform, Color.gray, (Vector2?)null, (Vector2?)null, true); GameObject val2 = UIFactory.Panel("TopBar", val.transform, Color.black, (Vector2?)new Vector2(0f, 0.9f), (Vector2?)new Vector2(1f, 1f), false); GameObject val3 = UIFactory.Panel("FarLeftSeparator", val.transform, Color.black, (Vector2?)new Vector2(0f, 0f), (Vector2?)new Vector2(0.01f, 0.9f), false); GameObject val4 = UIFactory.Panel("LeftSeparator", val.transform, Color.black, (Vector2?)new Vector2(0.32f, 0f), (Vector2?)new Vector2(0.34f, 0.9f), false); GameObject val5 = UIFactory.Panel("RightSeparator", val.transform, Color.black, (Vector2?)new Vector2(0.66f, 0f), (Vector2?)new Vector2(0.68f, 0.9f), false); GameObject val6 = UIFactory.Panel("FarRightSeparator", val.transform, Color.black, (Vector2?)new Vector2(0.99f, 0f), (Vector2?)new Vector2(1f, 0.9f), false); GameObject val7 = UIFactory.Panel("SlotsSection", val.transform, Color.clear, (Vector2?)new Vector2(0.04f, 0f), (Vector2?)new Vector2(0.29f, 1f), false); GameObject val8 = UIFactory.Panel("BlackjackSection", val.transform, Color.clear, (Vector2?)new Vector2(0.37f, 0f), (Vector2?)new Vector2(0.63f, 1f), false); GameObject val9 = UIFactory.Panel("RTBSection", val.transform, Color.clear, (Vector2?)new Vector2(0.71f, 0f), (Vector2?)new Vector2(0.96f, 1f), false); GameObject val10 = UIFactory.Panel("SlotsTitlePanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.34f, 0.8f), (Vector2?)new Vector2(0.66f, 0.85f), false); GameObject val11 = UIFactory.Panel("SlotsStatsTotalWinsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.7f), (Vector2?)new Vector2(0.8f, 0.7f), false); GameObject val12 = UIFactory.Panel("SlotsStatsTotalSpinsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.65f), (Vector2?)new Vector2(0.8f, 0.65f), false); GameObject val13 = UIFactory.Panel("SlotsStatsTotalLossesPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.6f), (Vector2?)new Vector2(0.8f, 0.6f), false); GameObject val14 = UIFactory.Panel("SlotsStatsTotalSpentPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.55f), (Vector2?)new Vector2(0.8f, 0.55f), false); GameObject val15 = UIFactory.Panel("SlotsStatsTotalProfitPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.5f), (Vector2?)new Vector2(0.8f, 0.5f), false); GameObject val16 = UIFactory.Panel("SlotsStatsWinRatePanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.45f), (Vector2?)new Vector2(0.8f, 0.45f), false); GameObject val17 = UIFactory.Panel("SlotsStatsProfitPerSpinPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.4f), (Vector2?)new Vector2(0.8f, 0.4f), false); GameObject val18 = UIFactory.Panel("SlotsStatsTotalMiniWinsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.35f), (Vector2?)new Vector2(0.8f, 0.35f), false); GameObject val19 = UIFactory.Panel("SlotsStatsTotalSmallWinsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.3f), (Vector2?)new Vector2(0.8f, 0.3f), false); GameObject val20 = UIFactory.Panel("SlotsStatsTotalBigWinsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.25f), (Vector2?)new Vector2(0.8f, 0.25f), false); GameObject val21 = UIFactory.Panel("SlotsStatsTotalJackpotsPanel", val7.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.2f), (Vector2?)new Vector2(0.8f, 0.2f), false); slots_total_wins_text = UIFactory.Text("SlotsTotalWinsText", $"Total Wins: {Slots.total_wins}", val11.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_spins_text = UIFactory.Text("SlotsTotalSpinsText", $"Total Spins: {Slots.total_spins}", val12.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_losses_text = UIFactory.Text("SlotsTotalLossesText", $"Total Losses: {Slots.total_losses}", val13.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_spent_text = UIFactory.Text("SlotsTotalSpentText", $"Total Spent: {Slots.total_spent}", val14.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_profit_text = UIFactory.Text("SlotsTotalProfitText", $"Total Profit: {Slots.total_profit}", val15.transform, 20, (TextAnchor)4, (FontStyle)0); slots_win_rate_text = UIFactory.Text("SlotsWinRateText", $"Win Rate: {Slots.win_rate}%", val16.transform, 20, (TextAnchor)4, (FontStyle)0); slots_profit_per_spin_text = UIFactory.Text("SlotsProfitPerSpinText", $"Average Profit/Spin: ${Slots.profit_per_spin}", val17.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_mini_wins_text = UIFactory.Text("SlotsTotalMiniWinsText", $"Total Mini Wins: {Slots.total_mini_wins}", val18.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_small_wins_text = UIFactory.Text("SlotsTotalSmallWinsText", $"Total Small Wins: {Slots.total_small_wins}", val19.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_big_wins_text = UIFactory.Text("SlotsTotalBigWinsText", $"Total Big Wins: {Slots.total_big_wins}", val20.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_jackpots_text = UIFactory.Text("SlotsTotalJackpotsText", $"Total Jackpots: {Slots.total_jackpots}", val21.transform, 20, (TextAnchor)4, (FontStyle)0); slots_total_wins_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_spins_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_losses_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_spent_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_profit_text.horizontalOverflow = (HorizontalWrapMode)1; slots_win_rate_text.horizontalOverflow = (HorizontalWrapMode)1; slots_profit_per_spin_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_mini_wins_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_small_wins_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_big_wins_text.horizontalOverflow = (HorizontalWrapMode)1; slots_total_jackpots_text.horizontalOverflow = (HorizontalWrapMode)1; GameObject val22 = UIFactory.Panel("BlackJackTitlePanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.34f, 0.8f), (Vector2?)new Vector2(0.66f, 0.85f), false); GameObject val23 = UIFactory.Panel("BlackJackStatsTotalWinsPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.7f), (Vector2?)new Vector2(0.8f, 0.7f), false); GameObject val24 = UIFactory.Panel("BlackJackStatsTotalPushesPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.65f), (Vector2?)new Vector2(0.8f, 0.65f), false); GameObject val25 = UIFactory.Panel("BlackJackStatsTotalPlaysPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.6f), (Vector2?)new Vector2(0.8f, 0.6f), false); GameObject val26 = UIFactory.Panel("BlackJackStatsTotalLossesPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.55f), (Vector2?)new Vector2(0.8f, 0.55f), false); GameObject val27 = UIFactory.Panel("BlackJackStatsTotalSpentPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.5f), (Vector2?)new Vector2(0.8f, 0.5f), false); GameObject val28 = UIFactory.Panel("BlackJackStatsTotalProfitPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.45f), (Vector2?)new Vector2(0.8f, 0.45f), false); GameObject val29 = UIFactory.Panel("BlackJackStatsWinRatePanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.4f), (Vector2?)new Vector2(0.8f, 0.4f), false); GameObject val30 = UIFactory.Panel("BlackJackStatsProfitPerPlayPanel", val8.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.35f), (Vector2?)new Vector2(0.8f, 0.35f), false); blackjack_total_wins_text = UIFactory.Text("BlackJackTotalWinsText", $"Total Wins: {BlackJack.total_wins}", val23.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_pushes_text = UIFactory.Text("BlackJackTotalPushesText", $"Total Pushes: {BlackJack.total_pushes}", val24.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_plays_text = UIFactory.Text("BlackJackTotalPlaysText", $"Total Plays: {BlackJack.total_plays}", val25.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_losses_text = UIFactory.Text("BlackJackTotalLossesText", $"Total Losses: {BlackJack.total_losses}", val26.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_spent_text = UIFactory.Text("BlackJackTotalSpentText", $"Total Spent: {BlackJack.total_spent}", val27.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_profit_text = UIFactory.Text("BlackJackTotalProfitText", $"Total Profit: {BlackJack.total_profit}", val28.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_win_rate_text = UIFactory.Text("BlackJackWinRateText", $"Win Rate: {BlackJack.win_rate}%", val29.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_profit_per_play_text = UIFactory.Text("BlackJackProfitPerPlayText", $"Average Profit/Play: ${BlackJack.profit_per_play}", val30.transform, 20, (TextAnchor)4, (FontStyle)0); blackjack_total_wins_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_total_pushes_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_total_plays_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_total_losses_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_total_spent_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_total_profit_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_win_rate_text.horizontalOverflow = (HorizontalWrapMode)1; blackjack_profit_per_play_text.horizontalOverflow = (HorizontalWrapMode)1; GameObject val31 = UIFactory.Panel("SlotsTitlePanel", val9.transform, Color.clear, (Vector2?)new Vector2(0.34f, 0.8f), (Vector2?)new Vector2(0.66f, 0.85f), false); GameObject val32 = UIFactory.Panel("SlotsStatsTotalSpinsPanel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.7f), (Vector2?)new Vector2(0.8f, 0.7f), false); GameObject val33 = UIFactory.Panel("SlotsStatsTotalSpentPanel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.65f), (Vector2?)new Vector2(0.8f, 0.65f), false); GameObject val34 = UIFactory.Panel("SlotsStatsTotalProfitPanel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.6f), (Vector2?)new Vector2(0.8f, 0.6f), false); GameObject val35 = UIFactory.Panel("SlotsStatsProfitPerSpinPanel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.55f), (Vector2?)new Vector2(0.8f, 0.55f), false); GameObject val36 = UIFactory.Panel("SlotsStatsTimesAtR1Panel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.5f), (Vector2?)new Vector2(0.8f, 0.5f), false); GameObject val37 = UIFactory.Panel("SlotsStatsTimesAtR2Panel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.45f), (Vector2?)new Vector2(0.8f, 0.45f), false); GameObject val38 = UIFactory.Panel("SlotsStatsTimesAtR3Panel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.4f), (Vector2?)new Vector2(0.8f, 0.4f), false); GameObject val39 = UIFactory.Panel("SlotsStatsTimesAtR4Panel", val9.transform, Color.clear, (Vector2?)new Vector2(0.2f, 0.35f), (Vector2?)new Vector2(0.8f, 0.35f), false); rtb_total_plays_text = UIFactory.Text("TotalSpinsText", $"Total Spins: {RideTheBus.total_plays}", val32.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_total_spent_text = UIFactory.Text("TotalSpentText", $"Total Spent: {RideTheBus.total_spent}", val33.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_total_profit_text = UIFactory.Text("TotalProfitText", $"Total Profit: {RideTheBus.total_profit}", val34.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_profit_per_play_text = UIFactory.Text("ProfitPerSpinText", $"Average Profit/Play: ${RideTheBus.profit_per_play}", val35.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_times_at_r1_text = UIFactory.Text("TimesAtR1Text", $"Times Finished at R1: {RideTheBus.times_finished_at_r1}", val36.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_times_at_r2_text = UIFactory.Text("TimesAtR2Text", $"Times Finished at R2: {RideTheBus.times_finished_at_r2}", val37.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_times_at_r3_text = UIFactory.Text("TimesAtR3Text", $"Times Finished at R3: {RideTheBus.times_finished_at_r3}", val38.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_times_at_r4_text = UIFactory.Text("TimesAtR4Text", $"Times Finished at R4: {RideTheBus.times_finished_at_r4}", val39.transform, 20, (TextAnchor)4, (FontStyle)0); rtb_total_plays_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_total_spent_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_total_profit_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_profit_per_play_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_times_at_r1_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_times_at_r2_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_times_at_r3_text.horizontalOverflow = (HorizontalWrapMode)1; rtb_times_at_r4_text.horizontalOverflow = (HorizontalWrapMode)1; Text val40 = UIFactory.Text("SlotsTitle", "Slots", val10.transform, 26, (TextAnchor)4, (FontStyle)0); Text val41 = UIFactory.Text("BlackjackTitle", "Blackjack", val22.transform, 23, (TextAnchor)4, (FontStyle)0); Text val42 = UIFactory.Text("RTBTitle", "Ride The Bus", val31.transform, 26, (TextAnchor)4, (FontStyle)0); } public static void UpdateSlotsStatsText() { slots_total_wins_text.text = $"Total Wins: {Slots.total_wins}"; slots_total_spins_text.text = $"Total Spins: {Slots.total_spins}"; slots_total_losses_text.text = $"Total Losses: {Slots.total_losses}"; slots_total_spent_text.text = $"Total Spent: {Slots.total_spent}"; slots_total_profit_text.text = $"Total Profit: {Slots.total_profit}"; slots_win_rate_text.text = $"Win Rate: {Slots.win_rate}%"; slots_profit_per_spin_text.text = $"Average Profit/Spin: ${Slots.profit_per_spin}"; slots_total_mini_wins_text.text = $"Total Mini Wins: {Slots.total_mini_wins}"; slots_total_small_wins_text.text = $"Total Small Wins: {Slots.total_small_wins}"; slots_total_big_wins_text.text = $"Total Big Wins: {Slots.total_big_wins}"; slots_total_jackpots_text.text = $"Total Jackpots: {Slots.total_jackpots}"; } public static void UpdateBlackJackStatsText() { blackjack_total_wins_text.text = $"Total Wins: {BlackJack.total_wins}"; blackjack_total_plays_text.text = $"Total Plays: {BlackJack.total_plays}"; blackjack_total_losses_text.text = $"Total Losses: {BlackJack.total_losses}"; blackjack_total_spent_text.text = $"Total Spent: {BlackJack.total_spent}"; blackjack_total_profit_text.text = $"Total Profit: {BlackJack.total_profit}"; blackjack_win_rate_text.text = $"Win Rate: {BlackJack.win_rate}%"; blackjack_profit_per_play_text.text = $"Average Profit/Play: ${BlackJack.profit_per_play}"; } public static void UpdateRTBStatsText() { rtb_total_plays_text.text = $"Total Plays: {RideTheBus.total_plays}"; rtb_total_spent_text.text = $"Total Spent: {RideTheBus.total_spent}"; rtb_total_profit_text.text = $"Total Profit: {RideTheBus.total_profit}"; rtb_profit_per_play_text.text = $"Average Profit/Play: ${RideTheBus.profit_per_play}"; rtb_times_at_r1_text.text = $"Times Finished at R1: {RideTheBus.times_finished_at_r1}"; rtb_times_at_r2_text.text = $"Times Finished at R2: {RideTheBus.times_finished_at_r2}"; rtb_times_at_r3_text.text = $"Times Finished at R3: {RideTheBus.times_finished_at_r3}"; rtb_times_at_r4_text.text = $"Times Finished at R4: {RideTheBus.times_finished_at_r4}"; } } public class RideTheBusStats { public int total_plays; public int total_spent; public int total_profit; public float profit_per_play; public int times_finished_at_r1; public int times_finished_at_r2; public int times_finished_at_r3; public int times_finished_at_r4; private static string SavePath => Path.Combine(MelonEnvironment.ModsDirectory, "CasinoTracker", "RideTheBusStats.json"); public static void SaveFromFields() { RideTheBusStats rideTheBusStats = new RideTheBusStats { total_plays = RideTheBus.total_plays, total_spent = RideTheBus.total_spent, total_profit = RideTheBus.total_profit, profit_per_play = RideTheBus.profit_per_play, times_finished_at_r1 = RideTheBus.times_finished_at_r1, times_finished_at_r2 = RideTheBus.times_finished_at_r2, times_finished_at_r3 = RideTheBus.times_finished_at_r3, times_finished_at_r4 = RideTheBus.times_finished_at_r4 }; string contents = JsonConvert.SerializeObject((object)rideTheBusStats, (Formatting)1); File.WriteAllText(SavePath, contents); } public static void LoadToFields() { if (File.Exists(SavePath)) { string text = File.ReadAllText(SavePath); RideTheBusStats rideTheBusStats = JsonConvert.DeserializeObject<RideTheBusStats>(text); if (rideTheBusStats != null) { RideTheBus.total_plays = rideTheBusStats.total_plays; RideTheBus.total_spent = rideTheBusStats.total_spent; RideTheBus.total_profit = rideTheBusStats.total_profit; RideTheBus.profit_per_play = rideTheBusStats.profit_per_play; RideTheBus.times_finished_at_r1 = rideTheBusStats.times_finished_at_r1; RideTheBus.times_finished_at_r2 = rideTheBusStats.times_finished_at_r2; RideTheBus.times_finished_at_r3 = rideTheBusStats.times_finished_at_r3; RideTheBus.times_finished_at_r4 = rideTheBusStats.times_finished_at_r4; } } } } public class RideTheBus : MelonMod { [HarmonyPatch(typeof(RTBGameController), "Awake")] public static class RTBGameController_Awake_Patch { public static void Postfix(RTBGameController __instance) { __instance.onLocalPlayerCorrect += Action.op_Implicit((Action)delegate { lastRoundWasWin = true; currentStage++; }); __instance.onLocalPlayerIncorrect += Action.op_Implicit((Action)delegate { lastRoundWasWin = false; }); __instance.onLocalPlayerExitRound += Action.op_Implicit((Action)delegate { lastRoundWasWin = null; }); } } [HarmonyPatch(typeof(RTBGameController), "EndGame")] public static class RTBGameController_EndGame_Patch { public static void Postfix(RTBGameController __instance) { List<int> list = new List<int> { 2, 3, 4, 20 }; int num = (int)__instance.LocalPlayerBet; int num2 = (int)__instance.LocalPlayerBetMultiplier; int payout = 0; if (lastRoundWasWin.GetValueOrDefault()) { payout = num * num2; } else if (!lastRoundWasWin.HasValue) { if (currentStage > 0) { int index = currentStage - 1; payout = num * list[index]; num2 = list[index]; } } else { payout = 0; } UpdateTracker((list.IndexOf(num2) + 1).ToString(), num, payout); GamblerApp.UpdateRTBStatsText(); currentStage = 0; lastRoundWasWin = null; } public static void UpdateTracker(string outcome, int BetAmount, int Payout) { total_plays++; total_spent += BetAmount; total_profit += Payout - BetAmount; switch (outcome) { case "1": times_finished_at_r1++; break; case "2": times_finished_at_r2++; break; case "3": times_finished_at_r3++; break; case "4": times_finished_at_r4++; break; default: MelonLogger.Warning("Unknown outcome/round: " + outcome); break; } profit_per_play = ((total_plays > 0) ? ((float)total_profit / (float)total_plays) : 0f); profit_per_play = (float)Math.Round(profit_per_play, 2); RideTheBusStats.SaveFromFields(); } } public static int total_plays; public static int total_spent; public static int total_profit; public static float win_rate; public static float profit_per_play; public static int times_finished_at_r1; public static int times_finished_at_r2; public static int times_finished_at_r3; public static int times_finished_at_r4; private static bool? lastRoundWasWin; private static int currentStage; } public class SlotStats { public int total_wins; public int total_spins; public int total_losses; public int total_spent; public int total_profit; public float win_rate; public float profit_per_spin; public int total_mini_wins; public int total_small_wins; public int total_big_wins; public int total_jackpots; private static string SavePath => Path.Combine(MelonEnvironment.ModsDirectory, "CasinoTracker", "SlotStats.json"); public static void SaveFromFields() { SlotStats slotStats = new SlotStats { total_wins = Slots.total_wins, total_spins = Slots.total_spins, total_losses = Slots.total_losses, total_spent = Slots.total_spent, total_profit = Slots.total_profit, win_rate = Slots.win_rate, profit_per_spin = Slots.profit_per_spin, total_mini_wins = Slots.total_mini_wins, total_small_wins = Slots.total_small_wins, total_big_wins = Slots.total_big_wins, total_jackpots = Slots.total_jackpots }; MelonLogger.Msg("Attempting to save SlotStats to " + SavePath + "."); string contents = JsonConvert.SerializeObject((object)slotStats, (Formatting)1); File.WriteAllText(SavePath, contents); } public static void LoadToFields() { if (File.Exists(SavePath)) { string text = File.ReadAllText(SavePath); SlotStats slotStats = JsonConvert.DeserializeObject<SlotStats>(text); if (slotStats != null) { Slots.total_spins = slotStats.total_spins; Slots.total_spent = slotStats.total_spent; Slots.total_profit = slotStats.total_profit; Slots.total_wins = slotStats.total_wins; Slots.profit_per_spin = slotStats.profit_per_spin; } } } } public class Slots : MelonMod { [HarmonyPatch(typeof(SlotMachine), "HandleInteracted")] public static class SlotMachine_HandleInteracted_Patch { public static void Postfix(SlotMachine __instance) { total_spins++; } } [HarmonyPatch(typeof(SlotMachine), "EvaluateOutcome")] public static class Slotmachine_EvaluateOutcome_Patch { public static void Postfix(EOutcome __result, SlotMachine __instance) { int currentBetAmount = __instance.currentBetAmount; string outcome = ((object)(EOutcome)(ref __result)).ToString(); UpdateTracker(outcome, currentBetAmount); GamblerApp.UpdateSlotsStatsText(); } public static void UpdateTracker(string outcome, int BetAmount) { switch (outcome) { case "NoWin": total_losses++; total_profit -= BetAmount; total_spent += BetAmount; break; case "MiniWin": total_wins++; total_mini_wins++; total_profit += BetAmount * 2 - BetAmount; total_spent += BetAmount; break; case "SmallWin": total_wins++; total_small_wins++; total_profit += BetAmount * 10 - BetAmount; total_spent += BetAmount; break; case "BigWin": total_wins++; total_big_wins++; total_profit += BetAmount * 25 - BetAmount; total_spent += BetAmount; break; case "Jackpot": total_wins++; total_jackpots++; total_profit += BetAmount * 100 - BetAmount; total_spent += BetAmount; break; default: MelonLogger.Warning("Unknown outcome: " + outcome); break; } win_rate = ((total_spins > 0) ? ((float)total_wins / (float)total_spins * 100f) : 0f); win_rate = (float)Math.Round(win_rate, 2); profit_per_spin = ((total_spins > 0) ? ((float)total_profit / (float)total_spins) : 0f); profit_per_spin = (float)Math.Round(profit_per_spin, 2); SlotStats.SaveFromFields(); } } public static int total_wins; public static int total_spins; public static int total_losses; public static int total_spent; public static int total_profit; public static float win_rate; public static float profit_per_spin; public static int total_mini_wins; public static int total_small_wins; public static int total_big_wins; public static int total_jackpots; } }