Decompiled source of CasinoPlus v0.8.7

CasinoPlusMono.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CasinoPlusMono;
using FishNet.Connection;
using HarmonyLib;
using MelonLoader;
using ScheduleOne.Casino;
using ScheduleOne.Casino.UI;
using ScheduleOne.DevUtilities;
using ScheduleOne.Map;
using ScheduleOne.Money;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
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(casino), "CasinoPlus", "0.8.5", "Sosa", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("CasinoPlusMono")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CasinoPlusMono")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f9cbbfaf-d3bc-4dd2-9cf0-f6a5416e362f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(AccessZone), "SetIsOpen")]
public static class ForceCasinoOpenPatch
{
	private static void Prefix(AccessZone __instance, ref bool open)
	{
		if (((Object)((Component)__instance).gameObject).name.Equals("Casino", StringComparison.OrdinalIgnoreCase) || ((Object)((Component)__instance).gameObject).name.Equals("Casino (Closed)", StringComparison.OrdinalIgnoreCase))
		{
			open = true;
		}
	}
}
[HarmonyPatch(typeof(TimedAccessZone), "Start")]
public static class TimedAccessZoneTimePatch
{
	private static void Postfix(TimedAccessZone __instance)
	{
		if (((Object)((Component)__instance).gameObject).name.Equals("Casino", StringComparison.OrdinalIgnoreCase) || ((Object)((Component)__instance).gameObject).name.Equals("Casino (Closed)", StringComparison.OrdinalIgnoreCase))
		{
			__instance.OpenTime = 600;
			__instance.CloseTime = 500;
		}
	}
}
namespace CasinoPlusMono;

[HarmonyPatch(typeof(BlackjackInterface))]
public static class BlackjackInterfacePatches
{
	public static GameObject doubleDownButton;

	private static TextMeshProUGUI doubleDownText;

	private static MethodInfo hitMethod;

	private static MethodInfo standMethod;

	private static FieldInfo playerHandField;

	private static MethodInfo refreshBetMethod;

	private static FieldInfo playerBetField;

	private static bool initialized;

	private static float originalBetBeforeDoubleDown;

	private static void MoveLabelUp(Transform label, float yOffset)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)label != (Object)null)
		{
			label.localPosition += new Vector3(0f, yOffset, 0f);
		}
	}

	[HarmonyPatch("GetBetFromSliderValue")]
	[HarmonyPrefix]
	public static bool GetBetFromSliderValuePrefix(ref float sliderVal, ref float __result)
	{
		__result = Mathf.Lerp(1000f, 25000f, sliderVal);
		return false;
	}

	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	public static void Initialize(BlackjackInterface __instance)
	{
		if (!initialized && !((Object)(object)__instance == (Object)null))
		{
			hitMethod = typeof(BlackjackInterface).GetMethod("HitClicked", BindingFlags.Instance | BindingFlags.NonPublic);
			standMethod = typeof(BlackjackInterface).GetMethod("StandClicked", BindingFlags.Instance | BindingFlags.NonPublic);
			playerHandField = typeof(BlackjackGameController).GetField("player1Hand", BindingFlags.Instance | BindingFlags.NonPublic);
			refreshBetMethod = typeof(BlackjackInterface).GetMethod("RefreshDisplayedBet", BindingFlags.Instance | BindingFlags.NonPublic);
			playerBetField = typeof(BlackjackGameController).GetField("<LocalPlayerBet>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!(hitMethod == null) && !(standMethod == null) && !(playerHandField == null) && !(refreshBetMethod == null) && !(playerBetField == null))
			{
				CreateDoubleDownButton(__instance);
				initialized = true;
			}
		}
	}

	private static void CreateDoubleDownButton(BlackjackInterface __instance)
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Expected O, but got Unknown
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.HitButton == (Object)null || (Object)(object)((Component)__instance.HitButton).gameObject == (Object)null)
		{
			return;
		}
		Transform val = ((Component)__instance.HitButton).transform.parent.Find("DoubleDownButton");
		if ((Object)(object)val != (Object)null)
		{
			doubleDownButton = ((Component)val).gameObject;
			return;
		}
		doubleDownButton = Object.Instantiate<GameObject>(((Component)__instance.HitButton).gameObject, ((Component)__instance.HitButton).transform.parent);
		((Object)doubleDownButton).name = "DoubleDownButton";
		RectTransform component = doubleDownButton.GetComponent<RectTransform>();
		RectTransform component2 = ((Component)__instance.HitButton).GetComponent<RectTransform>();
		component.anchoredPosition = new Vector2(component2.anchoredPosition.x, component2.anchoredPosition.y + component2.sizeDelta.y + 10f);
		Image component3 = doubleDownButton.GetComponent<Image>();
		((Graphic)component3).color = new Color(0.2f, 0.4f, 0.8f, 1f);
		doubleDownText = doubleDownButton.GetComponentInChildren<TextMeshProUGUI>();
		if ((Object)(object)doubleDownText != (Object)null)
		{
			((TMP_Text)doubleDownText).text = "DOUBLE DOWN";
			((TMP_Text)doubleDownText).fontSize = 24f;
			((TMP_Text)doubleDownText).fontStyle = (FontStyles)1;
		}
		Button component4 = doubleDownButton.GetComponent<Button>();
		((UnityEventBase)component4.onClick).RemoveAllListeners();
		((UnityEvent)component4.onClick).AddListener((UnityAction)delegate
		{
			OnDoubleDown(__instance);
		});
		RectTransform component5 = ((Component)__instance.InputContainerCanvasGroup).GetComponent<RectTransform>();
		if ((Object)(object)component5 != (Object)null)
		{
			component5.sizeDelta += new Vector2(0f, 60f);
		}
		TextMeshProUGUI playerScoreLabel = __instance.PlayerScoreLabel;
		MoveLabelUp((playerScoreLabel != null) ? ((TMP_Text)playerScoreLabel).transform : null, 30f);
		TextMeshProUGUI dealerScoreLabel = __instance.DealerScoreLabel;
		MoveLabelUp((dealerScoreLabel != null) ? ((TMP_Text)dealerScoreLabel).transform : null, 30f);
	}

	[HarmonyPatch("RefreshDisplayedBet")]
	[HarmonyPrefix]
	public static bool RefreshDisplayedBetPrefix(BlackjackInterface __instance)
	{
		try
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.CurrentGame == (Object)null || (Object)(object)__instance.BetAmount == (Object)null || (Object)(object)__instance.BetSlider == (Object)null)
			{
				return false;
			}
			float localPlayerBet = __instance.CurrentGame.LocalPlayerBet;
			string text = MoneyManager.FormatAmount(localPlayerBet, false, false);
			((TMP_Text)__instance.BetAmount).text = text;
			((TMP_Text)__instance.BetAmount).ForceMeshUpdate(false, false);
		}
		catch (Exception)
		{
		}
		return false;
	}

	[HarmonyPatch("Open")]
	[HarmonyPostfix]
	public static void OpenPostfix(BlackjackInterface __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.CurrentGame == (Object)null))
		{
			originalBetBeforeDoubleDown = __instance.CurrentGame.LocalPlayerBet;
			__instance.CurrentGame.SetLocalPlayerBet(1000f);
			__instance.BetSlider.minValue = 0f;
			__instance.BetSlider.maxValue = 1f;
			__instance.BetSlider.SetValueWithoutNotify(0f);
			refreshBetMethod?.Invoke(__instance, null);
			if ((Object)(object)__instance.HitButton != (Object)null)
			{
				((Component)__instance.HitButton).gameObject.SetActive(true);
			}
			if ((Object)(object)__instance.StandButton != (Object)null)
			{
				((Component)__instance.StandButton).gameObject.SetActive(true);
			}
			if ((Object)(object)doubleDownButton != (Object)null)
			{
				doubleDownButton.SetActive(true);
			}
			else
			{
				CreateDoubleDownButton(__instance);
			}
			UpdateTopBetUI(__instance);
			MelonCoroutines.Start(casino.Instance.FixPlayerScoreExplicitCoroutine());
			MelonCoroutines.Start(casino.Instance.FixDealerScoreExplicitCoroutine());
			MelonCoroutines.Start(casino.Instance.FixPayoutTextExplicitCoroutine());
		}
	}

	[HarmonyPatch("LocalPlayerReadyForInput")]
	[HarmonyPostfix]
	public static void EnableDoubleDownWhenAppropriate(BlackjackInterface __instance)
	{
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.CurrentGame == (Object)null)
		{
			return;
		}
		if ((Object)(object)doubleDownButton == (Object)null)
		{
			CreateDoubleDownButton(__instance);
			if ((Object)(object)doubleDownButton == (Object)null)
			{
				return;
			}
		}
		doubleDownButton.SetActive(true);
	}

	[HarmonyPatch("LocalPlayerExitRound")]
	[HarmonyPostfix]
	public static void HideDoubleDownBetweenRounds(BlackjackInterface __instance)
	{
		if ((Object)(object)doubleDownButton != (Object)null)
		{
			doubleDownButton.SetActive(false);
		}
		if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.CurrentGame != (Object)null && playerBetField != null)
		{
			playerBetField.SetValue(__instance.CurrentGame, originalBetBeforeDoubleDown);
			refreshBetMethod?.Invoke(__instance, null);
		}
		if ((Object)(object)__instance.HitButton != (Object)null)
		{
			((Component)__instance.HitButton).gameObject.SetActive(true);
		}
		if ((Object)(object)__instance.StandButton != (Object)null)
		{
			((Component)__instance.StandButton).gameObject.SetActive(true);
		}
		if ((Object)(object)__instance.BetSlider != (Object)null)
		{
			__instance.BetSlider.SetValueWithoutNotify(0f);
		}
		UpdateTopBetUI(__instance);
		MelonCoroutines.Start(casino.Instance.FixPlayerScoreExplicitCoroutine());
		MelonCoroutines.Start(casino.Instance.FixDealerScoreExplicitCoroutine());
		MelonCoroutines.Start(casino.Instance.FixPayoutTextExplicitCoroutine());
	}

	private static void OnDoubleDown(BlackjackInterface __instance)
	{
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.CurrentGame == (Object)null)
		{
			return;
		}
		float localPlayerBet = __instance.CurrentGame.LocalPlayerBet;
		if (localPlayerBet <= 0f)
		{
			return;
		}
		if ((Object)(object)doubleDownButton != (Object)null)
		{
			doubleDownButton.SetActive(false);
		}
		MoneyManager instance = NetworkSingleton<MoneyManager>.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		instance.ChangeCashBalance(0f - localPlayerBet, true, false);
		float num = localPlayerBet * 2f;
		if (playerBetField == null)
		{
			playerBetField = typeof(BlackjackGameController).GetField("<LocalPlayerBet>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
			if (playerBetField == null)
			{
				return;
			}
		}
		playerBetField.SetValue(__instance.CurrentGame, num);
		refreshBetMethod?.Invoke(__instance, null);
		UpdateTopBetUI(__instance);
		if ((Object)(object)__instance.InputContainerCanvasGroup != (Object)null)
		{
			__instance.InputContainerCanvasGroup.interactable = false;
		}
		if ((Object)(object)__instance.HitButton != (Object)null)
		{
			((Component)__instance.HitButton).gameObject.SetActive(false);
		}
		if ((Object)(object)__instance.StandButton != (Object)null)
		{
			((Component)__instance.StandButton).gameObject.SetActive(false);
		}
		((MonoBehaviour)__instance).StartCoroutine(RunDoubleDownActions(__instance));
	}

	private static void UpdateTopBetUI(BlackjackInterface instance)
	{
		if (!((Object)(object)instance != (Object)null))
		{
			return;
		}
		Transform val = ((Component)instance).transform.Find("Container/GameStatus/Container/PlayerDisplay/Players/Player/Container/Score");
		if ((Object)(object)val != (Object)null)
		{
			TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
			if ((Object)(object)component != (Object)null && (Object)(object)instance.CurrentGame != (Object)null)
			{
				float localPlayerBet = instance.CurrentGame.LocalPlayerBet;
				string text = MoneyManager.FormatAmount(localPlayerBet, false, false);
				((TMP_Text)component).text = text;
				((TMP_Text)component).ForceMeshUpdate(false, false);
			}
		}
	}

	private static IEnumerator RunDoubleDownActions(BlackjackInterface __instance)
	{
		yield return (object)new WaitForSeconds(0.2f);
		hitMethod.Invoke(__instance, null);
		yield return (object)new WaitForSeconds(1f);
		if ((Object)(object)EventSystem.current != (Object)null)
		{
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}
		if (standMethod != null)
		{
			standMethod.Invoke(__instance, null);
		}
		else
		{
			((CasinoGameController)__instance.CurrentGame).LocalPlayerData.SetData<float>("Action", 2f, true);
		}
		yield return (object)new WaitForEndOfFrame();
		if ((Object)(object)EventSystem.current != (Object)null)
		{
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}
	}
}
[HarmonyPatch(typeof(BlackjackGameController))]
public static class BlackjackGameControllerPatches
{
	[HarmonyPatch("SetLocalPlayerBet")]
	[HarmonyPrefix]
	public static void SetLocalPlayerBetPrefix(ref float bet)
	{
		bet = Mathf.Clamp(bet, 1000f, 25000f);
	}
}
public class casino : MelonMod
{
	public const float BJ_MIN_BET = 1000f;

	public const float BJ_MAX_BET = 25000f;

	public const float RTB_MIN_BET = 1000f;

	public const float RTB_MAX_BET = 25000f;

	public static readonly int[] SLOT_BET_AMOUNTS = new int[19]
	{
		100, 150, 200, 250, 300, 350, 400, 450, 500, 750,
		1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000
	};

	public static casino Instance { get; private set; }

	public override void OnInitializeMelon()
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Expected O, but got Unknown
		Instance = this;
		MelonLogger.Msg($"Casino Mod loaded - Blackjack: ${1000f}-${25000f}, RTB: ${1000f}-${25000f}, Slots: {SLOT_BET_AMOUNTS[0]}-{SLOT_BET_AMOUNTS[SLOT_BET_AMOUNTS.Length - 1]}");
		GameObject val = GameObject.Find("ScorePositionEnforcer");
		if ((Object)(object)val == (Object)null)
		{
			val = new GameObject("ScorePositionEnforcer");
			val.AddComponent<ScorePositionEnforcer>();
			Object.DontDestroyOnLoad((Object)(object)val);
		}
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name.Equals("Main", StringComparison.OrdinalIgnoreCase))
		{
			MelonCoroutines.Start(UpdateCasinoSignTextCoroutine());
		}
	}

	private IEnumerator UpdateCasinoSignTextCoroutine()
	{
		yield return (object)new WaitForSeconds(1f);
		string sceneName = "Main";
		string path1 = "Map/Container/Casino/casino/DoorWall/OpeningHoursSign/Name";
		string path2 = "Map/Container/Casino/casino/DoorWall (1)/OpeningHoursSign/Name";
		GameObject signObj1 = FindGameObjectInScene(sceneName, path1);
		if ((Object)(object)signObj1 != (Object)null)
		{
			TextMeshPro tmp1 = signObj1.GetComponent<TextMeshPro>();
			if ((Object)(object)tmp1 != (Object)null && ((TMP_Text)tmp1).text.Trim().Equals("4PM-5AM", StringComparison.OrdinalIgnoreCase))
			{
				((TMP_Text)tmp1).text = "OPEN 24/7";
				((TMP_Text)tmp1).ForceMeshUpdate(false, false);
			}
		}
		GameObject signObj2 = FindGameObjectInScene(sceneName, path2);
		if ((Object)(object)signObj2 != (Object)null)
		{
			TextMeshPro tmp2 = signObj2.GetComponent<TextMeshPro>();
			if ((Object)(object)tmp2 != (Object)null && ((TMP_Text)tmp2).text.Trim().Equals("4PM-5AM", StringComparison.OrdinalIgnoreCase))
			{
				((TMP_Text)tmp2).text = "OPEN 24/7";
				((TMP_Text)tmp2).ForceMeshUpdate(false, false);
			}
		}
	}

	private GameObject RecursiveFind(GameObject current, string[] segments, int index)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		if ((Object)(object)current == (Object)null || index >= segments.Length)
		{
			return null;
		}
		if (!((Object)current).name.Equals(segments[index], StringComparison.OrdinalIgnoreCase))
		{
			return null;
		}
		if (index == segments.Length - 1)
		{
			return current;
		}
		foreach (Transform item in current.transform)
		{
			Transform val = item;
			GameObject val2 = RecursiveFind(((Component)val).gameObject, segments, index + 1);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
		}
		return null;
	}

	private GameObject FindGameObjectInScene(string sceneName, string path)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		Scene sceneByName = SceneManager.GetSceneByName(sceneName);
		if (!((Scene)(ref sceneByName)).IsValid() || !((Scene)(ref sceneByName)).isLoaded)
		{
			return null;
		}
		string[] segments = path.Split(new char[1] { '/' });
		GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
		foreach (GameObject current in rootGameObjects)
		{
			GameObject val = RecursiveFind(current, segments, 0);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	public IEnumerator FixPlayerScoreExplicitCoroutine()
	{
		float timer = 0f;
		float timeout = 10f;
		string sceneName = "Main";
		string targetPath = "UI/CasinoGames/Blackjack/Container/ScoresContainer/Player/Score";
		while (timer < timeout)
		{
			GameObject playerScoreObj = FindGameObjectInScene(sceneName, targetPath);
			if ((Object)(object)playerScoreObj != (Object)null)
			{
				RectTransform playerRect = playerScoreObj.GetComponent<RectTransform>();
				if ((Object)(object)playerRect != (Object)null)
				{
					((Transform)playerRect).localPosition = new Vector3(75f, 0f, 0f);
					playerRect.anchoredPosition = new Vector2(75f, 0f);
					break;
				}
			}
			timer += Time.deltaTime;
			yield return null;
		}
	}

	public IEnumerator FixDealerScoreExplicitCoroutine()
	{
		float timer = 0f;
		float timeout = 10f;
		string sceneName = "Main";
		string targetPath = "UI/CasinoGames/Blackjack/Container/ScoresContainer/Dealer/Score";
		while (timer < timeout)
		{
			GameObject dealerScoreObj = FindGameObjectInScene(sceneName, targetPath);
			if ((Object)(object)dealerScoreObj != (Object)null)
			{
				RectTransform dealerRect = dealerScoreObj.GetComponent<RectTransform>();
				if ((Object)(object)dealerRect != (Object)null)
				{
					((Transform)dealerRect).localPosition = new Vector3(75f, 0f, 0f);
					dealerRect.anchoredPosition = new Vector2(75f, 0f);
					break;
				}
			}
			timer += Time.deltaTime;
			yield return null;
		}
	}

	public IEnumerator FixPayoutTextExplicitCoroutine()
	{
		float timer = 0f;
		float timeout = 10f;
		string sceneName = "Main";
		string targetPath = "UI/CasinoGames/Blackjack/Container/PositiveOutcome/Payout";
		while (timer < timeout)
		{
			GameObject payoutObj = FindGameObjectInScene(sceneName, targetPath);
			if ((Object)(object)payoutObj != (Object)null)
			{
				TMP_Text payoutText = payoutObj.GetComponent<TMP_Text>();
				if ((Object)(object)payoutText != (Object)null)
				{
					payoutText.textWrappingMode = (TextWrappingModes)0;
					payoutText.ForceMeshUpdate(false, false);
					break;
				}
			}
			timer += Time.deltaTime;
			yield return null;
		}
	}

	public IEnumerator FixRideTheBusPayoutTextExplicitCoroutine()
	{
		float timer = 0f;
		float timeout = 10f;
		string sceneName = "Main";
		string targetPath = "UI/CasinoGames/RideTheBus/Container/PositiveOutcome/Payout";
		while (timer < timeout)
		{
			GameObject payoutObj = FindGameObjectInScene(sceneName, targetPath);
			if ((Object)(object)payoutObj != (Object)null)
			{
				TMP_Text payoutText = payoutObj.GetComponent<TMP_Text>();
				if ((Object)(object)payoutText != (Object)null)
				{
					payoutText.textWrappingMode = (TextWrappingModes)0;
					payoutText.ForceMeshUpdate(false, false);
					break;
				}
			}
			timer += Time.deltaTime;
			yield return null;
		}
	}
}
public class ScorePositionEnforcer : MonoBehaviour
{
	private void LateUpdate()
	{
	}
}
[HarmonyPatch(typeof(RTBInterface))]
public static class RTBInterfacePatches
{
	[HarmonyPatch("GetBetFromSliderValue")]
	[HarmonyPrefix]
	public static bool GetBetFromSliderValuePrefix(ref float sliderVal, ref float __result)
	{
		__result = Mathf.Lerp(1000f, 25000f, sliderVal);
		return false;
	}

	[HarmonyPatch("RefreshDisplayedBet")]
	[HarmonyPrefix]
	public static bool RefreshDisplayedBetPrefix(RTBInterface __instance)
	{
		try
		{
			float localPlayerBet = __instance.CurrentGame.LocalPlayerBet;
			((TMP_Text)__instance.BetAmount).text = MoneyManager.FormatAmount(localPlayerBet, false, false);
			((TMP_Text)__instance.BetAmount).ForceMeshUpdate(false, false);
			float valueWithoutNotify = Mathf.InverseLerp(1000f, 25000f, localPlayerBet);
			__instance.BetSlider.SetValueWithoutNotify(valueWithoutNotify);
		}
		catch (Exception)
		{
		}
		return false;
	}

	[HarmonyPatch("Open")]
	[HarmonyPostfix]
	public static void OpenPostfix(RTBInterface __instance)
	{
		__instance.CurrentGame.SetLocalPlayerBet(1000f);
		typeof(RTBInterface).GetMethod("RefreshDisplayedBet", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(__instance, null);
		MelonCoroutines.Start(casino.Instance.FixRideTheBusPayoutTextExplicitCoroutine());
	}
}
[HarmonyPatch(typeof(RTBGameController))]
public static class RTBGameControllerPatches
{
	[HarmonyPatch("SetLocalPlayerBet")]
	[HarmonyPrefix]
	public static void SetLocalPlayerBetPrefix(ref float bet)
	{
		bet = Mathf.Clamp(bet, 1000f, 25000f);
	}
}
[HarmonyPatch(typeof(SlotMachine))]
public static class SlotMachinePatches
{
	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	public static void ModifyBetAmounts(SlotMachine __instance)
	{
		typeof(SlotMachine).GetField("BetAmounts", BindingFlags.Static | BindingFlags.Public)?.SetValue(null, casino.SLOT_BET_AMOUNTS);
		__instance.SetBetIndex((NetworkConnection)null, 0);
		FixTextDisplay(__instance.BetAmountLabel);
	}

	[HarmonyPatch("SetBetIndex")]
	[HarmonyPostfix]
	public static void AfterSetBetIndex(SlotMachine __instance)
	{
		FixTextDisplay(__instance.BetAmountLabel);
	}

	private static void FixTextDisplay(TextMeshPro textComponent)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)textComponent != (Object)null)
		{
			float fontSize = ((TMP_Text)textComponent).fontSize;
			Vector3 localPosition = textComponent.transform.localPosition;
			Vector2 sizeDelta = ((TMP_Text)textComponent).rectTransform.sizeDelta;
			((TMP_Text)textComponent).enableWordWrapping = false;
			((TMP_Text)textComponent).overflowMode = (TextOverflowModes)0;
			((TMP_Text)textComponent).alignment = (TextAlignmentOptions)514;
			((TMP_Text)textComponent).margin = new Vector4(0f, 0f, 0f, 0f);
			((TMP_Text)textComponent).enableAutoSizing = false;
			((TMP_Text)textComponent).fontSize = fontSize;
			textComponent.transform.localPosition = localPosition;
			((TMP_Text)textComponent).rectTransform.sizeDelta = sizeDelta;
			((TMP_Text)textComponent).ForceMeshUpdate(false, false);
			((TMP_Text)textComponent).rectTransform.ForceUpdateRectTransforms();
		}
	}
}