Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BazaarCasino v1.11.1
plugins/BazaarCasino/BazaarCasino.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using KinematicCharacterController; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.UI; using Rewired; using RoR2; using RoR2.Artifacts; using RoR2.ConVar; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Animations; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BazaarCasino")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BazaarCasino")] [assembly: AssemblyTitle("BazaarCasino")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BazaarCasino { [BepInPlugin("local.gakon.bazaarcasino", "Bazaar Casino", "1.11.1")] public sealed class CasinoPlugin : BaseUnityPlugin { private sealed class Session { internal BlackjackRound hand; internal float nextAction; internal uint lastRequest; internal uint caseToken; internal int caseItem = -1; internal int caseSeed; internal float caseStarted; internal float caseReadyAt; internal bool casePending; internal bool caseCommand; internal int caseCost; internal int caseUnitPrice; internal int[] caseRewards = Array.Empty<int>(); } private ConfigEntry<bool> keepBazaarGold; internal static CasinoPlugin Instance; private readonly Dictionary<CharacterMaster, Session> sessions = new Dictionary<CharacterMaster, Session>(); private readonly HashSet<NetworkClient> clients = new HashSet<NetworkClient>(); private readonly Random rng = new Random(Guid.NewGuid().GetHashCode()); private ConfigEntry<int> minBet; private ConfigEntry<int> maxBet; private ConfigEntry<float> loungeBrightness; private ConfigEntry<KeyCode> openKey; private ConfigEntry<bool> scaledPrices; private ConfigEntry<int> requestMessageId; private readonly Dictionary<ItemTier, ConfigEntry<int>> salePrices = new Dictionary<ItemTier, ConfigEntry<int>>(); private CasinoUI ui; private bool serverRegistered; private Run previousRun; private bool wasBazaar; private uint requestCounter; private int serverMinimum; private int serverMaximum; internal CasinoState State; internal bool Waiting; private float requestStarted; private GameObject dealer; private float nextDealerAttempt; private ConfigEntry<bool> spawnDealer; private CasinoSoundtrack soundtrack; private ConfigEntry<bool> gachaEnabled; private ConfigEntry<bool> mirrorGreenPrice; private ConfigEntry<int> gachaBaseCost; private ConfigEntry<int> commonWeight; private ConfigEntry<int> uncommonWeight; private ConfigEntry<int> legendaryWeight; private ConfigEntry<float> gachaPriceMultiplier; private bool priceWarning; private readonly LoungeTravelGate loungeTravel = new LoungeTravelGate(); private SharedCrabRace crabRace = new SharedCrabRace(); private readonly Dictionary<uint, CharacterMaster> raceMasters = new Dictionary<uint, CharacterMaster>(); private ConfigEntry<int> raceStakeMultiplier; private int raceRevision; private float nextRaceBroadcast; private Coroutine preparingScene; private int preparedSceneHandle = -1; private bool sceneVisualWarmed; private readonly Dictionary<uint, Vector3> standingPositions = new Dictionary<uint, Vector3>(); private readonly Dictionary<uint, SeatAnchor> seatAnchors = new Dictionary<uint, SeatAnchor>(); private readonly Dictionary<uint, CasinoSeat> seatedBodies = new Dictionary<uint, CasinoSeat>(); private TableKind pendingTableExit; private float nextSeatExit; private SharedBlackjack blackjackTable = new SharedBlackjack(); private SharedRoulette rouletteTable = new SharedRoulette(); private readonly Dictionary<TableKind, WorldTable> worldTables = new Dictionary<TableKind, WorldTable>(); private CasinoLounge lounge; private uint slotSpinCounter; private readonly float[] slotReadyAt = new float[3]; private readonly float[] slotStartedAt = new float[3]; private readonly TableSnapshot[] slotDisplays = new TableSnapshot[3]; private readonly Dictionary<uint, TableKind> joinedTables = new Dictionary<uint, TableKind>(); internal readonly Dictionary<TableKind, TableSnapshot> tableStates = new Dictionary<TableKind, TableSnapshot>(); private int tableRevision; private float nextTableBroadcast; private float nextTableSpawn; private float nextPlacementWarning; private readonly Dictionary<TableKind, float> tableReceivedAt = new Dictionary<TableKind, float>(); private TablePhase oldBlackjackPhase; private TablePhase oldRoulettePhase; internal static bool InBazaar { get { if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)SceneInfo.instance) && Object.op_Implicit((Object)(object)SceneInfo.instance.sceneDef)) { return SceneInfo.instance.sceneDef.baseSceneName == "bazaar"; } return false; } } internal static CharacterMaster LocalMaster { get { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser == null) { return null; } return firstLocalUser.cachedMaster; } } internal float LoungeBrightness => loungeBrightness.Value; internal KeyCode OpenKey => openKey.Value; internal bool InLounge { get { //IL_003d: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (InBazaar && Object.op_Implicit((Object)(object)lounge) && Object.op_Implicit((Object)(object)val)) { return lounge.Contains(val.corePosition); } return false; } } private static uint LocalMasterId { get { //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) if (!Object.op_Implicit((Object)(object)LocalMaster) || !Object.op_Implicit((Object)(object)((Component)LocalMaster).GetComponent<NetworkIdentity>())) { return 0u; } NetworkInstanceId netId = ((Component)LocalMaster).GetComponent<NetworkIdentity>().netId; return ((NetworkInstanceId)(ref netId)).Value; } } internal int MinimumBet { get { if (NetworkServer.active || serverMinimum <= 0) { return WagerRules.ScaledMinimum(minBet.Value, CasePrice(), maxBet.Value); } return serverMinimum; } } internal int MaximumBet { get { if (NetworkServer.active || serverMaximum <= 0) { return Math.Max(minBet.Value, maxBet.Value); } return serverMaximum; } } private void ConfigureBazaarWallet() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown keepBazaarGold = ((BaseUnityPlugin)this).Config.Bind<bool>("Economy", "KeepGoldOnBazaarEntry", true, "Preserve run gold when travelling to the Bazaar, without converting it to XP. Bigger Bazaar may still manage its own transfer. Other stage exits retain native money conversion."); ConvertPlayerMoneyToExperience.FixedUpdate += new hook_FixedUpdate(PreserveBazaarGold); } private void PreserveBazaarGold(orig_FixedUpdate orig, ConvertPlayerMoneyToExperience self) { SceneExitController component = ((Component)self).GetComponent<SceneExitController>(); if (NetworkServer.active && keepBazaarGold.Value && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.destinationScene) && component.destinationScene.baseSceneName == "bazaar") { Object.Destroy((Object)(object)self); } else { orig.Invoke(self); } } private void StopBazaarWallet() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown ConvertPlayerMoneyToExperience.FixedUpdate -= new hook_FixedUpdate(PreserveBazaarGold); } private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown Instance = this; SceneDirector.onPrePopulateSceneServer += PrepareSceneDirector; SceneManager.sceneLoaded += PrepareLoadedScene; spawnDealer = ((BaseUnityPlugin)this).Config.Bind<bool>("Dealer", "Enabled", true, "Spawn an item broker inside the Casino Lounge."); Interactor.AttemptInteraction += new hook_AttemptInteraction(InteractWithDealer); PlayerCharacterMasterController.Update += new hook_Update(SuppressSeatUpdate); PlayerCharacterMasterController.FixedUpdate += new hook_FixedUpdate(SuppressSeatFixedUpdate); EntityStateMachine.ManagedUpdate += new hook_ManagedUpdate(SuppressSeatStateUpdate); EntityStateMachine.ManagedFixedUpdate += new hook_ManagedFixedUpdate(SuppressSeatStateFixedUpdate); TeleportHelper.TeleportGameObject_GameObject_Vector3_Vector3_Quaternion_bool_bool += new hook_TeleportGameObject_GameObject_Vector3_Vector3_Quaternion_bool_bool(GuardSeatTeleport); MapZone.TeleportBody += new hook_TeleportBody(GuardSeatMapZone); MPEventSystem.Update += new hook_Update(CasinoEventUpdate); minBet = ((BaseUnityPlugin)this).Config.Bind<int>("Economy", "MinimumBet", 10, new ConfigDescription("Floor for the live minimum wager. The minimum follows the current scaled Lunar Cache price, capped by MaximumBet.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10000), Array.Empty<object>())); maxBet = ((BaseUnityPlugin)this).Config.Bind<int>("Economy", "MaximumBet", 100000, new ConfigDescription("Maximum initial wager. Shared blackjack can reserve up to four times this amount with split and doubles.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000000), Array.Empty<object>())); scaledPrices = ((BaseUnityPlugin)this).Config.Bind<bool>("Selling", "ScaleWithDifficulty", true, "Scale sale prices with Run.GetDifficultyScaledCost, like gold shop costs."); ConfigureBazaarWallet(); CasinoText.Initialize(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Info.Location, ((BaseUnityPlugin)this).Logger); ConfigureGacha(); ConfigureRace(); ConfigureSoundtrack(); loungeBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "Brightness", 1.3f, new ConfigDescription("Local lounge ambient/fill brightness; no shadow cost. Applied only to lounge camera renders.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), Array.Empty<object>())); openKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "OpenCasino", (KeyCode)287, "Close the active casino interface. Open tables, slot machines and the broker with E."); requestMessageId = ((BaseUnityPlugin)this).Config.Bind<int>("Network", "MessageId", 28061, new ConfigDescription("Reserved request message ID; replies use ID+1. Same value required on all players. Change only if another mod conflicts.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1000, 32000), Array.Empty<object>())); Price((ItemTier)0, 8); Price((ItemTier)1, 20); Price((ItemTier)2, 100); Price((ItemTier)4, 50); Price((ItemTier)3, 30); Price((ItemTier)6, 10); Price((ItemTier)7, 25); Price((ItemTier)8, 120); Price((ItemTier)9, 60); Price((ItemTier)11, 30); Price((ItemTier)13, 40); Price((ItemTier)10, 4); Price((ItemTier)12, 20); ui = ((Component)this).gameObject.AddComponent<CasinoUI>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Bazaar Casino loaded. Use E on casino tables, slot machines and the broker; F6 closes the current interface. All transactions are server-authoritative."); } private unsafe void Price(ItemTier tier, int gold) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown salePrices[tier] = ((BaseUnityPlugin)this).Config.Bind<int>("Selling", ((object)(*(ItemTier*)(&tier))/*cast due to .constrained prefix*/).ToString(), gold, new ConfigDescription("Base sale value for one permanent item; 0 disables selling this tier.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000000), Array.Empty<object>())); } private void Update() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) if (InBazaar && Object.op_Implicit((Object)(object)lounge) && spawnDealer.Value && !Object.op_Implicit((Object)(object)dealer) && Time.unscaledTime >= nextDealerAttempt) { nextDealerAttempt = Time.unscaledTime + 2f; dealer = DealerNPC.Spawn(lounge); } if ((!InBazaar || !Object.op_Implicit((Object)(object)lounge) || !spawnDealer.Value) && Object.op_Implicit((Object)(object)dealer)) { Object.Destroy((Object)(object)dealer); dealer = null; } if (NetworkServer.active && !serverRegistered) { NetworkServer.RegisterHandler((short)requestMessageId.Value, new NetworkMessageDelegate(ReceiveRequest)); serverRegistered = true; } if (!NetworkServer.active) { serverRegistered = false; } foreach (NetworkClient allClient in NetworkClient.allClients) { if (allClient != null && clients.Add(allClient)) { allClient.RegisterHandler((short)(requestMessageId.Value + 1), new NetworkMessageDelegate(ReceiveReply)); allClient.RegisterHandler((short)(requestMessageId.Value + 2), new NetworkMessageDelegate(ReceiveTableReply)); } } clients.RemoveWhere((NetworkClient c) => !NetworkClient.allClients.Contains(c)); if ((Object)(object)previousRun != (Object)(object)Run.instance || (wasBazaar && !InBazaar)) { ClearTables((Object)(object)previousRun == (Object)(object)Run.instance && wasBazaar); sessions.Clear(); } UpdateTableExit(); UpdateTables(); UpdateCaseDrops(); UpdateRace(); previousRun = Run.instance; wasBazaar = InBazaar; if (!InBazaar) { ui.Close(); State = null; Waiting = false; serverMinimum = (serverMaximum = 0); } else if (Input.GetKeyDown(openKey.Value)) { ui.Toggle(); } if (Waiting && Time.unscaledTime - requestStarted > 6f) { Waiting = false; if (loungeTravel.Pending) { loungeTravel.Cancel(); ShowLoungeTravelError("Host did not confirm lounge travel. Check that every player uses Bazaar Casino 1.11.0 and the same network MessageId."); } ui.SharedRequestTimedOut(); ui.SlotTimedOut(); ui.CaseTimedOut(); ui.RaceTimedOut(); ui.Notify("Host did not respond. Install Bazaar Casino on the host and every player; check the network MessageId matches."); } } internal void Send(ActionKind action, int bet = 0, int choice = 0, int number = 0, RouletteBet[] bets = null, TableKind table = (TableKind)0, bool allIn = false) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) CharacterMaster localMaster = LocalMaster; if (!InBazaar || !Object.op_Implicit((Object)(object)localMaster) || Waiting) { return; } NetworkIdentity component = ((Component)localMaster).GetComponent<NetworkIdentity>(); if (!Object.op_Implicit((Object)(object)component)) { return; } CasinoRequest obj = new CasinoRequest { requestId = ++requestCounter }; NetworkInstanceId netId = component.netId; obj.masterId = ((NetworkInstanceId)(ref netId)).Value; obj.action = action; obj.wager = bet; obj.choice = choice; obj.number = number; obj.bets = bets; obj.table = (byte)table; obj.allIn = allIn; CasinoRequest casinoRequest = obj; BeginLoungeTravel(casinoRequest, localMaster); Waiting = true; requestStarted = Time.unscaledTime; if (NetworkServer.active) { Deliver(Process(localMaster, casinoRequest)); return; } NetworkClient val = ((IEnumerable<NetworkClient>)NetworkClient.allClients).FirstOrDefault((Func<NetworkClient, bool>)((NetworkClient c) => c.isConnected)); if (val == null) { Waiting = false; if (loungeTravel.Pending) { loungeTravel.Cancel(); ShowLoungeTravelError("No server connection for lounge travel."); } else { ui.Notify("No server connection."); } } else { val.Send((short)requestMessageId.Value, (MessageBase)(object)casinoRequest); } } private void InteractWithDealer(orig_AttemptInteraction orig, Interactor self, GameObject target) { if (Object.op_Implicit((Object)(object)ui) && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)LocalMaster) && (Object)(object)((Component)self).gameObject == (Object)(object)LocalMaster.GetBodyObject() && (ui.IsAnyCasinoOpen || ui.InteractionBlocked) && Object.op_Implicit((Object)(object)target) && (Object.op_Implicit((Object)(object)target.GetComponent<WorldSlotMachine>()) || Object.op_Implicit((Object)(object)target.GetComponent<WorldCaseMachine>()) || Object.op_Implicit((Object)(object)target.GetComponent<WorldCrabRace>()) || Object.op_Implicit((Object)(object)target.GetComponent<WorldTable>()) || Object.op_Implicit((Object)(object)target.GetComponent<DealerNPC>()) || Object.op_Implicit((Object)(object)target.GetComponent<CasinoLoungeDoor>()))) { return; } WorldSlotMachine worldSlotMachine = (Object.op_Implicit((Object)(object)target) ? target.GetComponent<WorldSlotMachine>() : null); WorldCaseMachine worldCaseMachine = (Object.op_Implicit((Object)(object)target) ? target.GetComponent<WorldCaseMachine>() : null); WorldCrabRace worldCrabRace = (Object.op_Implicit((Object)(object)target) ? target.GetComponent<WorldCrabRace>() : null); if (Object.op_Implicit((Object)(object)worldCrabRace)) { OpenRace(self, worldCrabRace); return; } if (Object.op_Implicit((Object)(object)worldCaseMachine)) { OpenCaseMachine(self, worldCaseMachine); return; } if (Object.op_Implicit((Object)(object)worldSlotMachine)) { OpenSlotMachine(self, worldSlotMachine); return; } CasinoLoungeDoor casinoLoungeDoor = (Object.op_Implicit((Object)(object)target) ? target.GetComponent<CasinoLoungeDoor>() : null); if (Object.op_Implicit((Object)(object)casinoLoungeDoor)) { UseLoungeDoor(self, casinoLoungeDoor); return; } WorldTable worldTable = (Object.op_Implicit((Object)(object)target) ? target.GetComponent<WorldTable>() : null); if (Object.op_Implicit((Object)(object)worldTable)) { OpenTable(self, worldTable); } else if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)target.GetComponent<DealerNPC>())) { OpenDealer(self, target); } else { orig.Invoke(self, target); } } internal void OpenDealer(Interactor activator, GameObject target) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)activator) && (Object)(object)((Component)activator).gameObject == (Object)(object)((Component)val).gameObject && InBazaar && Vector3.Distance(val.corePosition, target.transform.position) < 8f && ui.CanOpenInteraction) { ui.OpenBroker(); } } internal void OpenSlotMachine(Interactor actor, WorldSlotMachine machine) { //IL_0052: 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) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)actor) && (Object)(object)((Component)actor).gameObject == (Object)(object)((Component)val).gameObject && InBazaar && ui.CanOpenInteraction && Vector3.Distance(val.corePosition, ((Component)machine).transform.position) < 8f) { ui.OpenSlots(machine); } } private void ReceiveRequest(NetworkMessage message) { try { CasinoRequest request = message.ReadMessage<CasinoRequest>(); NetworkUser val = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)delegate(NetworkUser u) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)u) && ((NetworkBehaviour)u).connectionToClient == message.conn && Object.op_Implicit((Object)(object)u.master)) { NetworkInstanceId netId = ((Component)u.master).GetComponent<NetworkIdentity>().netId; return ((NetworkInstanceId)(ref netId)).Value == request.masterId; } return false; }); if (Object.op_Implicit((Object)(object)val)) { CasinoState casinoState = Process(val.master, request); message.conn.Send((short)(requestMessageId.Value + 1), (MessageBase)(object)new CasinoReply { json = JsonUtility.ToJson((object)casinoState) }); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Rejected invalid casino request: " + ex.Message)); } } private void ReceiveReply(NetworkMessage message) { try { Deliver(JsonUtility.FromJson<CasinoState>(message.ReadMessage<CasinoReply>().json)); } catch (Exception ex) { Waiting = false; if (loungeTravel.Pending) { loungeTravel.Cancel(); ShowLoungeTravelError("Invalid host response for lounge travel. Check matching casino versions."); } ((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid casino response: " + ex.Message)); } } private void Deliver(CasinoState state) { Waiting = false; if (state.minBet > 0 && state.maxBet >= state.minBet) { serverMinimum = state.minBet; serverMaximum = state.maxBet; ui.SetWagerLimits(state.minBet, state.maxBet); } if (state.loungeReply) { DeliverLoungeTravel(state); } else if (loungeTravel.Matches(state.requestId)) { loungeTravel.Cancel(); ShowLoungeTravelError("The host uses an older lounge travel protocol. Update Bazaar Casino to 1.11.0 on every player."); } else if (state.raceReply) { if (state.raceState != null && Object.op_Implicit((Object)(object)lounge) && Object.op_Implicit((Object)(object)lounge.Race)) { lounge.Race.Receive(state.raceState); } ui.RaceResponse(state.message); } else if (state.tableReply) { if (state.tableState != null) { ApplyTableSnapshot(state.tableState); } ui.TableResponse(state.message); } else { State = state; ui.Receive(state); } } internal int SalePrice(ItemDef def) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)def) || def.hidden || !def.canRemove || !salePrices.TryGetValue(def.tier, out var value) || value.Value <= 0) { return 0; } if (!scaledPrices.Value || !Object.op_Implicit((Object)(object)Run.instance)) { return value.Value; } return Math.Min(100000000, Run.instance.GetDifficultyScaledCost(value.Value)); } private SaleItem[] SaleList(CharacterMaster master) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)master.inventory)) { return Array.Empty<SaleItem>(); } return (from d in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs where Object.op_Implicit((Object)(object)d) && master.inventory.GetItemCountPermanent(d.itemIndex) > 0 && SalePrice(d) > 0 select new SaleItem { index = (int)d.itemIndex, count = master.inventory.GetItemCountPermanent(d.itemIndex), price = SalePrice(d) }).ToArray(); } private static void Credit(CharacterMaster master, int amount) { if (amount > 0) { master.money = (uint)Math.Min(4294967295uL, (ulong)(master.money + amount)); } } private CasinoState Process(CharacterMaster master, CasinoRequest request) { //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) CasinoState casinoState = new CasinoState { requestId = request.requestId, minBet = MinimumBet, maxBet = MaximumBet, loungeReply = IsLoungeAction(request.action), tableReply = ((int)request.action >= 8 && (int)request.action <= 17 && !IsLoungeAction(request.action)), raceReply = (request.action == ActionKind.RaceBet) }; if (!NetworkServer.active || !InBazaar || !Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.GetBody()) || !master.GetBody().healthComponent.alive || SceneExitController.isRunning) { casinoState.message = "Casino is only available while alive inside the Bazaar."; return casinoState; } if (!sessions.TryGetValue(master, out var value)) { value = (sessions[master] = new Session()); } string text = null; if (request.requestId <= value.lastRequest) { text = "Duplicate request ignored."; } else { value.lastRequest = request.requestId; if (request.action != ActionKind.State && Time.unscaledTime < value.nextAction) { text = "Please wait for the current action."; } else if ((int)request.action < 0 || (int)request.action > 19) { text = "Unknown action."; } else if (request.action == ActionKind.RaceBet) { casinoState.raceReply = true; text = ProcessRace(master, request); casinoState.raceState = MakeRaceSnapshot(); casinoState.message = text ?? "Race wager updated."; value.nextAction = Time.unscaledTime + 0.15f; } else if (request.action == ActionKind.LoungeEnter || request.action == ActionKind.LoungeExit) { text = ProcessLoungeDoor(master, request, casinoState); casinoState.message = text ?? ((request.action == ActionKind.LoungeEnter) ? "Welcome to the Casino Lounge." : "Returned to Bazaar."); value.nextAction = Time.unscaledTime + 0.4f; } else if ((int)request.action >= 8 && (int)request.action <= 17) { text = ProcessTable(master, request); casinoState.message = text ?? "Table updated."; if (worldTables.TryGetValue((TableKind)request.table, out var value2)) { casinoState.tableState = MakeSnapshot((TableKind)request.table, value2); } value.nextAction = Time.unscaledTime + 0.12f; } else if (request.action != ActionKind.State && request.action != ActionKind.Sell && HasTableStake(request.masterId)) { text = "Finish or cancel your shared table wager first."; } else if (request.action == ActionKind.CaseRedeem) { text = RedeemCase(master, value, casinoState, request); value.nextAction = Time.unscaledTime + 0.15f; } else { if (request.action == ActionKind.Slots) { string text2 = ValidateSlotMachine(master.GetBody(), request.number); if (text2 != null) { text = text2; goto IL_083a; } } if (request.action == ActionKind.Deal || request.action == ActionKind.Hit || request.action == ActionKind.Stand || request.action == ActionKind.Double || request.action == ActionKind.Roulette) { text = "Blackjack and roulette are played at the shared tables. Press E at a table."; } else if (request.action == ActionKind.Sell && (!Object.op_Implicit((Object)(object)dealer) || Vector3.Distance(master.GetBody().corePosition, dealer.transform.position) > 8f)) { text = "Talk to the Lunar Broker inside the lounge to sell items."; } else if (request.action == ActionKind.Sell) { ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)request.choice); int num = SalePrice(itemDef); if (!Object.op_Implicit((Object)(object)itemDef) || !Object.op_Implicit((Object)(object)master.inventory) || num <= 0 || master.inventory.GetItemCountPermanent(itemDef.itemIndex) < 1) { text = "This item cannot be sold."; } else if ((ulong)(master.money + num) > 4294967295uL) { text = "Gold wallet is full."; } else { master.inventory.GiveItemPermanent(itemDef.itemIndex, -1); casinoState.game = 4; Credit(master, num); casinoState.message = "Sold 1 " + Language.GetString(itemDef.nameToken) + " for " + num + " gold."; value.nextAction = Time.unscaledTime + 0.2f; } } else if (request.action == ActionKind.Hit || request.action == ActionKind.Stand || request.action == ActionKind.Double) { if (value.hand == null || !value.hand.active) { text = "No active blackjack hand."; } else if (request.action == ActionKind.Double && (value.hand.player.Count != 2 || master.money < value.hand.wager)) { text = "Double requires two cards and enough gold for the extra wager."; } else { if (request.action == ActionKind.Double) { master.money -= (uint)value.hand.wager; value.hand.Double(); } else if (request.action == ActionKind.Hit) { value.hand.Hit(); } else { value.hand.Stand(); } casinoState.game = 1; casinoState.wager = value.hand.wager; if (!value.hand.active) { Credit(master, value.hand.payout); casinoState.payout = value.hand.payout; } casinoState.message = (value.hand.active ? "Hit, Stand, or Double." : value.hand.result); value.nextAction = Time.unscaledTime + 0.2f; } } else if (request.action != ActionKind.State) { int total = request.wager; bool flag = request.action != ActionKind.Roulette || RouletteBets.Validate(request.bets, casinoState.minBet, casinoState.maxBet, master.money, out total); if (value.hand != null && value.hand.active) { text = "Finish your blackjack hand first."; } else if (!WagerRules.Valid(total, casinoState.minBet, casinoState.maxBet, master.money, request.allIn)) { text = "Wager outside the allowed range or insufficient gold."; } else if (!flag) { text = "Invalid roulette chips, total wager, or insufficient gold."; } else { master.money -= (uint)total; casinoState.wager = total; if (request.action == ActionKind.Deal) { value.hand = new BlackjackRound(rng, total); casinoState.game = 1; if (!value.hand.active) { casinoState.payout = value.hand.payout; Credit(master, casinoState.payout); } casinoState.message = (value.hand.active ? "Hit, Stand, or Double." : value.hand.result); value.nextAction = Time.unscaledTime + 0.2f; } else if (request.action == ActionKind.Roulette) { casinoState.game = 2; casinoState.spinSeed = rng.Next(); RouletteSpin rouletteSpin = new RouletteSpin(casinoState.spinSeed); casinoState.wheelNumber = rouletteSpin.number; casinoState.payout = RouletteBets.Payout(request.bets, rouletteSpin.number); Credit(master, casinoState.payout); casinoState.message = "Roulette: " + casinoState.wheelNumber + " — " + ((casinoState.payout > 0) ? "win" : "no win"); value.nextAction = Time.unscaledTime + rouletteSpin.duration; } else if (request.action == ActionKind.Slots) { casinoState.game = 3; casinoState.reels = new int[3] { Games.SlotSymbol(rng), Games.SlotSymbol(rng), Games.SlotSymbol(rng) }; casinoState.payout = total * Games.SlotMultiplier(casinoState.reels[0], casinoState.reels[1], casinoState.reels[2]); Credit(master, casinoState.payout); casinoState.message = ((casinoState.payout > 0) ? "Slots payout!" : "No match"); BroadcastSlotResult(request.number, casinoState.reels, casinoState.payout - total); value.nextAction = Time.unscaledTime + 3.8f; } } } } } goto IL_083a; IL_083a: if (value.hand != null) { BlackjackRound hand = value.hand; casinoState.handActive = hand.active; casinoState.canDouble = hand.active && hand.player.Count == 2 && master.money >= hand.wager; casinoState.handWager = hand.wager; casinoState.player = hand.player.ToArray(); casinoState.dealer = ((!hand.active) ? hand.dealer.ToArray() : new int[2] { hand.dealer[0], -1 }); casinoState.playerTotal = Games.Value(hand.player); casinoState.dealerTotal = ((!hand.active) ? Games.Value(hand.dealer) : 0); } casinoState.message = text ?? casinoState.message ?? "Welcome to the Bazaar Casino."; casinoState.gold = master.money; if (!casinoState.tableReply) { casinoState.items = SaleList(master); } FillCaseState(casinoState, value); return casinoState; } private void OnDestroy() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown SceneDirector.onPrePopulateSceneServer -= PrepareSceneDirector; SceneManager.sceneLoaded -= PrepareLoadedScene; StopBazaarWallet(); StopScenePreparation(); Interactor.AttemptInteraction -= new hook_AttemptInteraction(InteractWithDealer); PlayerCharacterMasterController.Update -= new hook_Update(SuppressSeatUpdate); PlayerCharacterMasterController.FixedUpdate -= new hook_FixedUpdate(SuppressSeatFixedUpdate); EntityStateMachine.ManagedUpdate -= new hook_ManagedUpdate(SuppressSeatStateUpdate); EntityStateMachine.ManagedFixedUpdate -= new hook_ManagedFixedUpdate(SuppressSeatStateFixedUpdate); TeleportHelper.TeleportGameObject_GameObject_Vector3_Vector3_Quaternion_bool_bool -= new hook_TeleportGameObject_GameObject_Vector3_Vector3_Quaternion_bool_bool(GuardSeatTeleport); MapZone.TeleportBody -= new hook_TeleportBody(GuardSeatMapZone); MPEventSystem.Update -= new hook_Update(CasinoEventUpdate); ClearTables(settle: false); if (Object.op_Implicit((Object)(object)dealer)) { Object.Destroy((Object)(object)dealer); } if (NetworkServer.active && serverRegistered) { NetworkServer.UnregisterHandler((short)requestMessageId.Value); } foreach (NetworkClient client in clients) { if (client != null) { client.UnregisterHandler((short)(requestMessageId.Value + 1)); client.UnregisterHandler((short)(requestMessageId.Value + 2)); } } if (Object.op_Implicit((Object)(object)ui)) { ui.Close(); } CasinoArt.ReleaseShared(); Instance = null; } private void ConfigureSoundtrack() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown soundtrack = ((Component)this).gameObject.AddComponent<CasinoSoundtrack>(); soundtrack.Configure(((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "Enabled", true, "Play the original casino lounge soundtrack while inside the lounge."), ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "MusicVolume", 0.4f, new ConfigDescription("Casino BGM volume multiplied by the game's current music volume; fades on entry/exit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()))); } private void ConfigureGacha() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown gachaEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Gacha", "Enabled", true, "Enable the Lunar Cache machine inside the lounge."); mirrorGreenPrice = ((BaseUnityPlugin)this).Config.Bind<bool>("Gacha", "MatchBiggerBazaarUncommon", true, "Mirror Bigger Bazaar's green gold-shop price if installed, including its difficulty/scaling settings."); gachaBaseCost = ((BaseUnityPlugin)this).Config.Bind<int>("Gacha", "BaseGoldCost", 50, new ConfigDescription("Fallback difficulty-scaled gold cost when Bigger Bazaar pricing is unavailable.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000000), Array.Empty<object>())); gachaPriceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gacha", "PriceMultiplier", 1f, new ConfigDescription("Multiplier applied after the scaled uncommon/fallback gold price.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 100f), Array.Empty<object>())); commonWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Gacha", "CommonWeight", 70, new ConfigDescription("Relative common chance; unavailable tiers are excluded.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); uncommonWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Gacha", "UncommonWeight", 27, new ConfigDescription("Relative uncommon chance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); legendaryWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Gacha", "LegendaryWeight", 3, new ConfigDescription("Relative legendary chance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); } internal int CasePrice() { int greenPrice = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.GetDifficultyScaledCost(gachaBaseCost.Value) : gachaBaseCost.Value); if (mirrorGreenPrice.Value && Object.op_Implicit((Object)(object)Run.instance) && Chainloader.PluginInfos.TryGetValue("com.MagnusMagnuson.BiggerBazaar", out var value) && Object.op_Implicit((Object)(object)value.Instance)) { try { Type type = ((object)value.Instance).GetType(); BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic; Type? type2 = type.Assembly.GetType("BiggerBazaar.ModConfig"); ConfigEntry<float> val = type2?.GetField("tier2Cost", bindingFlags | BindingFlags.Static)?.GetValue(null) as ConfigEntry<float>; ConfigEntry<bool> val2 = type2?.GetField("nextLevelChestPriceScaling", bindingFlags | BindingFlags.Static)?.GetValue(null) as ConfigEntry<bool>; if (val == null || val2 == null) { throw new MissingMemberException("Bigger Bazaar pricing settings changed."); } int num; if (val2.Value) { num = Run.instance.GetDifficultyScaledCost(25); } else { object obj = type.GetField("bazaar", bindingFlags | BindingFlags.Instance)?.GetValue(value.Instance); if (!(obj?.GetType().GetProperty("CurrentDifficultyCoefficient", bindingFlags | BindingFlags.Instance)?.GetValue(obj) is float num2) || num2 <= 0f) { throw new InvalidOperationException("Bigger Bazaar pricing is not ready."); } num = (int)Math.Min(100000000.0, 25.0 * (double)Mathf.Pow(num2, 1.25f)); } greenPrice = (int)Math.Max(1.0, Math.Min(100000000.0, (float)num * val.Value)); } catch (Exception ex) { if (!priceWarning) { priceWarning = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Gacha uses fallback difficulty pricing: " + ex.Message)); } } } return GachaRules.ScalePrice(greenPrice, gachaPriceMultiplier.Value); } private ItemDef[][] CasePool() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) ItemDef[][] array = new ItemDef[3][]; ItemTier[] array2 = (ItemTier[])(object)new ItemTier[3] { default(ItemTier), (ItemTier)1, (ItemTier)2 }; List<PickupIndex>[] array3 = new List<PickupIndex>[3] { Run.instance.availableTier1DropList, Run.instance.availableTier2DropList, Run.instance.availableTier3DropList }; for (int i = 0; i < 3; i++) { ItemTier tier = array2[i]; array[i] = (from p in array3[i] select PickupCatalog.GetPickupDef(p) into p where p != null select ItemCatalog.GetItemDef(p.itemIndex) into d where Object.op_Implicit((Object)(object)d) && !d.hidden && d.canRemove && d.tier == tier && GachaRules.NormalReward(((Object)d).name, d.ContainsTag((ItemTag)9), d.ContainsTag((ItemTag)25), d.ContainsTag((ItemTag)10), CommandArtifactManager.IsCommandArtifactEnabled && d.ContainsTag((ItemTag)27)) select d).Distinct().ToArray(); } return array; } private int[] CaseWeights(ItemDef[][] pools) { return new int[3] { (pools[0].Length != 0) ? commonWeight.Value : 0, (pools[1].Length != 0) ? uncommonWeight.Value : 0, (pools[2].Length != 0) ? legendaryWeight.Value : 0 }; } private string RedeemCase(CharacterMaster master, Session session, CasinoState state, CasinoRequest request) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected I4, but got Unknown if (!gachaEnabled.Value || !Object.op_Implicit((Object)(object)lounge) || !Object.op_Implicit((Object)(object)lounge.Cache)) { return "Lunar Cache is unavailable."; } if (Vector3.Distance(master.GetBody().corePosition, ((Component)lounge.Cache).transform.position) > 8f) { return "Move closer to the Lunar Cache machine."; } if (Time.unscaledTime < session.caseReadyAt) { return "Your case is still opening."; } if (session.casePending) { return "Your reward is dispensing."; } if (!Object.op_Implicit((Object)(object)master.inventory)) { return "Inventory is unavailable."; } int number = request.number; if (!CaseBatchRules.ValidCount(number)) { return "Choose 1x, 5x or 10x cases."; } int num = CasePrice(); int num2 = CaseBatchRules.Total(num, number); if (request.wager != num2) { return "Case price updated. Review the new price and open again."; } if (master.money < (uint)num2) { return "Not enough gold to open these cases."; } ItemDef[][] array = CasePool(); int[] weights = CaseWeights(array); int[] array2 = new int[number]; bool[] available = array.Select((ItemDef[] p) => p.Length != 0).ToArray(); for (int num3 = 0; num3 < number; num3++) { int num4 = GachaRules.ChooseTier(rng.NextDouble(), weights, available); if (num4 < 0) { return "No case rewards are available in this run."; } array2[num3] = (int)array[num4][rng.Next(array[num4].Length)].itemIndex; } master.money -= (uint)num2; session.caseToken++; session.caseRewards = array2; session.caseItem = array2[0]; session.caseSeed = rng.Next(); session.caseStarted = Time.unscaledTime; session.caseReadyAt = Time.unscaledTime + 5.2f; session.casePending = true; session.caseCost = num2; session.caseUnitPrice = num; session.caseCommand = CommandArtifactManager.IsCommandArtifactEnabled; state.game = 5; state.wager = num2; state.message = "Cases redeemed."; return null; } private void UpdateCaseDrops() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0108: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !InBazaar || SceneExitController.isRunning || !Object.op_Implicit((Object)(object)lounge) || !Object.op_Implicit((Object)(object)lounge.Cache)) { return; } foreach (KeyValuePair<CharacterMaster, Session> session in sessions) { Session value = session.Value; if (!value.casePending || Time.unscaledTime < value.caseReadyAt) { continue; } value.casePending = false; for (int i = 0; i < value.caseRewards.Length; i++) { try { Transform transform = ((Component)lounge.Cache).transform; float num = ((float)i - (float)(value.caseRewards.Length - 1) * 0.5f) * 0.24f; PickupDropletController.CreatePickupDroplet(new UniquePickup { pickupIndex = PickupCatalog.FindPickupIndex((ItemIndex)value.caseRewards[i]) }, transform.TransformPoint(new Vector3(num, 0.8f, -1.4f)), transform.TransformDirection(new Vector3(num * 1.4f, 5f + (float)(i % 3) * 0.2f, -2.5f)), false); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)session.Key)) { Credit(session.Key, value.caseUnitPrice); } ((BaseUnityPlugin)this).Logger.LogError((object)("Cache reward " + (i + 1) + " could not drop; its unit price was refunded: " + ex)); } } } } private void RefundPendingCases(bool settle) { foreach (KeyValuePair<CharacterMaster, Session> session in sessions) { if (settle && NetworkServer.active && Object.op_Implicit((Object)(object)session.Key) && session.Value.casePending) { Credit(session.Key, session.Value.caseCost); } session.Value.casePending = false; } } private void FillCaseState(CasinoState state, Session session) { state.caseEnabled = gachaEnabled.Value; state.casePrice = CasePrice(); if (state.tableReply || state.raceReply) { return; } ItemDef[][] array = CasePool(); state.caseWeights = CaseWeights(array); state.caseItems = array.SelectMany((ItemDef[] p) => p.Select((ItemDef d) => (int)d.itemIndex)).ToArray(); state.caseToken = session.caseToken; state.caseItem = session.caseItem; state.caseSeed = session.caseSeed; state.caseRewards = session.caseRewards; state.caseCommand = session.caseCommand; state.caseElapsed = Math.Max(0f, Time.unscaledTime - session.caseStarted); } internal void OpenCaseMachine(Interactor actor, WorldCaseMachine machine) { //IL_0052: 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) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)actor) && (Object)(object)((Component)actor).gameObject == (Object)(object)((Component)val).gameObject && InBazaar && ui.CanOpenInteraction && Vector3.Distance(val.corePosition, ((Component)machine).transform.position) < 8f) { ui.OpenCase(machine); } } private void CasinoEventUpdate(orig_Update original, MPEventSystem system) { if (!Object.op_Implicit((Object)(object)ui) || ui.EscapeConsumedFrame != Time.frameCount) { bool flag = Input.GetKeyDown((KeyCode)27) || (system.player != null && system.player.GetButtonDown(25)); if (Object.op_Implicit((Object)(object)ui) && ui.IsAnyCasinoOpen && flag) { ui.CloseFromEscape(); } else { original.Invoke(system); } } } private static bool IsLoungeAction(ActionKind action) { if (action != ActionKind.LoungeEnter) { return action == ActionKind.LoungeExit; } return true; } private void BeginLoungeTravel(CasinoRequest request, CharacterMaster master) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (IsLoungeAction(request.action)) { CharacterBody body = master.GetBody(); LoungeTravelGate loungeTravelGate = loungeTravel; uint requestId = request.requestId; int bodyId; NetworkInstanceId netId; if (!Object.op_Implicit((Object)(object)body)) { bodyId = 0; } else { netId = ((NetworkBehaviour)body).netId; bodyId = (int)((NetworkInstanceId)(ref netId)).Value; } int sceneId; if (!Object.op_Implicit((Object)(object)Stage.instance)) { sceneId = 0; } else { netId = ((NetworkBehaviour)Stage.instance).netId; sceneId = (int)((NetworkInstanceId)(ref netId)).Value; } loungeTravelGate.Begin(requestId, (uint)bodyId, (uint)sceneId); } } private void DeliverLoungeTravel(CasinoState state) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if (!loungeTravel.Matches(state.requestId)) { return; } CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); LoungeTravelGate loungeTravelGate = loungeTravel; uint requestId = state.requestId; uint loungeBodyId = state.loungeBodyId; uint loungeSceneId = state.loungeSceneId; int currentBody; NetworkInstanceId netId; if (!Object.op_Implicit((Object)(object)val)) { currentBody = 0; } else { netId = ((NetworkBehaviour)val).netId; currentBody = (int)((NetworkInstanceId)(ref netId)).Value; } int currentScene; if (!Object.op_Implicit((Object)(object)Stage.instance)) { currentScene = 0; } else { netId = ((NetworkBehaviour)Stage.instance).netId; currentScene = (int)((NetworkInstanceId)(ref netId)).Value; } if (loungeTravelGate.Complete(requestId, loungeBodyId, loungeSceneId, (uint)currentBody, (uint)currentScene, state.loungeMoved && Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive && InBazaar && !SceneExitController.isRunning && (NetworkServer.active || Util.HasEffectiveAuthority(((Component)val).gameObject)), state.loungeX, state.loungeY, state.loungeZ, state.loungeYaw)) { if (!NetworkServer.active && Util.HasEffectiveAuthority(((Component)val).gameObject)) { TeleportHelper.TeleportBody(val, new Vector3(state.loungeX, state.loungeY, state.loungeZ), false); if (Object.op_Implicit((Object)(object)val.characterMotor)) { val.characterMotor.velocity = Vector3.zero; } Quaternion val2 = Quaternion.Euler(0f, state.loungeYaw, 0f); if (Object.op_Implicit((Object)(object)val.characterDirection)) { val.characterDirection.forward = val2 * Vector3.forward; } else { ((Component)val).transform.rotation = val2; } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Lounge travel acknowledged for local player (request " + state.requestId + ").")); } else { ShowLoungeTravelError(state.loungeMoved ? "Lounge travel expired because your character or scene changed. Press E again." : state.message); } } private void ShowLoungeTravelError(string message) { message = message ?? "Lounge travel failed. Press E again."; ui.Notify(message); Chat.AddMessage("<color=#E8CD80>[Casino]</color> " + CasinoText.Get(message)); ((BaseUnityPlugin)this).Logger.LogWarning((object)("Lounge travel: " + message)); } private void ConfigureRace() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown raceStakeMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("CrabRace", "MinimumCachePriceMultiplier", 10, new ConfigDescription("High-stakes minimum: current difficulty-scaled Lunar Cache price times this value. Four equal-odds crabs; winner returns 4x stake including the wager.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>())); } private int RaceMinimum() { return Math.Max(MinimumBet, (int)Math.Min(MaximumBet, (long)CasePrice() * (long)raceStakeMultiplier.Value)); } private string ProcessRace(CharacterMaster master, CasinoRequest request) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)lounge) || !Object.op_Implicit((Object)(object)lounge.Race) || Vector3.Distance(master.GetBody().corePosition, lounge.Race.InteractionPosition) > 8f) { return "Move closer to the Hermit Derby betting desk."; } if (!lounge.Race.ModelsReady) { return "Native Hermit Crabs are still loading; try again shortly."; } if (!crabRace.CanBet) { return "The race is underway. Betting opens after the result."; } if (HasTableStake(request.masterId)) { return "Finish or cancel your table wager first."; } int wager = request.wager; int num = crabRace.Find(request.masterId)?.wager ?? 0; if (request.choice < 0 || request.choice >= 4 || !WagerRules.Valid(wager, RaceMinimum(), MaximumBet, (ulong)master.money + (ulong)(uint)num, request.allIn, refund: true)) { return "Review the scaled minimum and maximum stake. All In must use your entire available gold."; } if ((ulong)((long)master.money + (long)(uint)num) < (ulong)(uint)wager) { return "Not enough gold."; } if ((ulong)((long)master.money + (long)(uint)num - (uint)wager) > 4294967295uL) { return "Gold wallet is full; spend gold before refunding."; } if (!crabRace.SetBet(request.masterId, PlayerName(master), request.choice, wager, Time.unscaledTime)) { return "Betting is closed."; } master.money = (uint)((long)master.money + (long)(uint)num - (uint)wager); raceMasters[request.masterId] = master; raceRevision++; nextRaceBroadcast = 0f; return null; } private RaceSnapshot MakeRaceSnapshot() { return new RaceSnapshot { round = crabRace.round, phase = (int)crabRace.phase, seed = crabRace.seed, winner = crabRace.winner, elapsed = ((crabRace.phase == TablePhase.Betting) ? 0f : ((float)Math.Max(0.0, (double)Time.unscaledTime - crabRace.started))), remaining = (float)Math.Max(0.0, crabRace.deadline - (double)Time.unscaledTime), minimum = RaceMinimum(), maximum = MaximumBet, revision = raceRevision, tickets = crabRace.tickets.Select((RaceTicket t) => new RaceTicket { id = t.id, name = t.name, lane = t.lane, wager = t.wager, payout = t.payout, paid = t.paid }).ToArray() }; } private void PayRace() { foreach (RaceTicket item in crabRace.TakePayments()) { if (raceMasters.TryGetValue(item.id, out var value) && Object.op_Implicit((Object)(object)value)) { Credit(value, item.payout); } } } private void UpdateRace() { //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !InBazaar || SceneExitController.isRunning || !Object.op_Implicit((Object)(object)lounge) || !Object.op_Implicit((Object)(object)lounge.Race)) { return; } TablePhase phase = crabRace.phase; if (crabRace.CanBet) { RaceTicket[] array = crabRace.tickets.ToArray(); foreach (RaceTicket raceTicket in array) { if (!Object.op_Implicit((Object)(object)FindMaster(raceTicket.id))) { if (raceMasters.TryGetValue(raceTicket.id, out var value) && Object.op_Implicit((Object)(object)value)) { Credit(value, raceTicket.wager); } crabRace.SetBet(raceTicket.id, raceTicket.name, raceTicket.lane, 0, Time.unscaledTime); raceRevision++; } } } crabRace.Tick(Time.unscaledTime, (crabRace.CanBet && crabRace.deadline > 0.0 && (double)Time.unscaledTime >= crabRace.deadline) ? rng.Next() : 0); if (phase != crabRace.phase) { raceRevision++; nextRaceBroadcast = 0f; if (crabRace.CanBet) { raceMasters.Clear(); } } PayRace(); if (!(Time.unscaledTime < nextRaceBroadcast)) { nextRaceBroadcast = Time.unscaledTime + 0.25f; RaceSnapshot raceSnapshot = MakeRaceSnapshot(); lounge.Race.Receive(raceSnapshot); short num = (short)(requestMessageId.Value + 2); TableReply tableReply = new TableReply(); TableSnapshot obj = new TableSnapshot { kind = 3, race = raceSnapshot }; int sceneId; if (!Object.op_Implicit((Object)(object)Stage.instance)) { sceneId = 0; } else { NetworkInstanceId netId = ((NetworkBehaviour)Stage.instance).netId; sceneId = (int)((NetworkInstanceId)(ref netId)).Value; } obj.sceneId = (uint)sceneId; tableReply.json = JsonUtility.ToJson((object)obj); NetworkServer.SendToAll(num, (MessageBase)(object)tableReply); } } private void ClearRace(bool settle) { if (settle && NetworkServer.active) { if (crabRace.CanBet) { foreach (RaceTicket ticket in crabRace.tickets) { if (raceMasters.TryGetValue(ticket.id, out var value) && Object.op_Implicit((Object)(object)value)) { Credit(value, ticket.wager); } } } crabRace.Finish(Time.unscaledTime); PayRace(); } crabRace = new SharedCrabRace(); raceMasters.Clear(); raceRevision = 0; nextRaceBroadcast = 0f; } internal void OpenRace(Interactor actor, WorldCrabRace race) { //IL_0052: 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) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)actor) && (Object)(object)((Component)actor).gameObject == (Object)(object)((Component)val).gameObject && InBazaar && ui.CanOpenInteraction && Vector3.Distance(val.corePosition, race.InteractionPosition) < 8f) { ui.OpenRace(race); } } private void PrepareLoadedScene(Scene scene, LoadSceneMode mode) { if (!(((Scene)(ref scene)).name != "bazaar")) { preparedSceneHandle = -1; sceneVisualWarmed = false; if (InBazaar) { PrepareBazaarNow(); } if (preparingScene == null) { preparingScene = ((MonoBehaviour)this).StartCoroutine(PrepareWhenSceneReady()); } } } private void PrepareSceneDirector(SceneDirector director) { if (InBazaar) { PrepareBazaarNow(); if (preparingScene == null && worldTables.Count < 2) { preparingScene = ((MonoBehaviour)this).StartCoroutine(PrepareWhenSceneReady()); } } } private IEnumerator PrepareWhenSceneReady() { float until = Time.unscaledTime + 5f; while (Time.unscaledTime < until) { yield return null; Scene sceneByName = SceneManager.GetSceneByName("bazaar"); if (!Object.op_Implicit((Object)(object)Instance) || !((Scene)(ref sceneByName)).IsValid() || !((Scene)(ref sceneByName)).isLoaded) { break; } if (!InBazaar) { continue; } Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "bazaar")) { PrepareBazaarNow(); if (worldTables.Count == 2 && sceneVisualWarmed) { break; } } } preparingScene = null; } private void PrepareBazaarNow() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!InBazaar) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "bazaar") { return; } activeScene = SceneManager.GetActiveScene(); int handle = ((Scene)(ref activeScene)).handle; if ((Object)(object)previousRun != (Object)(object)Run.instance) { ClearTables(settle: false); sessions.Clear(); previousRun = Run.instance; } wasBazaar = true; if (preparedSceneHandle != handle) { preparedSceneHandle = handle; Stopwatch stopwatch = Stopwatch.StartNew(); CasinoArt.WarmAll(); NativeHermitAssets.Warm(); if (Object.op_Implicit((Object)(object)soundtrack)) { soundtrack.Warm(); } if (Object.op_Implicit((Object)(object)ui)) { ui.Prepare(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Bazaar scene preload: shared artwork and UI ready in " + stopwatch.ElapsedMilliseconds + "ms.")); } if (NetworkServer.active) { Physics.SyncTransforms(); if (worldTables.Count < 2) { nextTableSpawn = 0f; UpdateTables(); } if (Object.op_Implicit((Object)(object)lounge) && spawnDealer.Value && !Object.op_Implicit((Object)(object)dealer)) { dealer = DealerNPC.Spawn(lounge); } if (worldTables.Count == 2) { BroadcastTables(); } } WarmSceneVisuals(); } private void WarmSceneVisuals() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) if (sceneVisualWarmed || !Object.op_Implicit((Object)(object)lounge) || worldTables.Count < 2 || (Object.op_Implicit((Object)(object)lounge.Race) && !lounge.Race.ModelsReady && !lounge.Race.ModelsUnavailable)) { return; } sceneVisualWarmed = true; Stopwatch stopwatch = Stopwatch.StartNew(); GameObject val = null; RenderTexture val2 = null; try { TMP_Text[] componentsInChildren = ((Component)lounge).GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].ForceMeshUpdate(true, false); } foreach (WorldTable value in worldTables.Values) { componentsInChildren = ((Component)value).GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].ForceMeshUpdate(true, false); } } Canvas.ForceUpdateCanvases(); if (!Application.isBatchMode) { val = new GameObject("CasinoScenePreloadCamera"); Camera obj = val.AddComponent<Camera>(); ((Behaviour)obj).enabled = false; val2 = (obj.targetTexture = RenderTexture.GetTemporary(256, 256, 16)); obj.clearFlags = (CameraClearFlags)2; obj.backgroundColor = Color.black; obj.nearClipPlane = 0.1f; obj.farClipPlane = 100f; obj.fieldOfView = 85f; obj.cullingMask = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.defaultLayer)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask); ((Component)obj).transform.position = ((Component)lounge).transform.TransformPoint(new Vector3(0f, 9f, -25f)); ((Component)obj).transform.LookAt(((Component)lounge).transform.TransformPoint(new Vector3(0f, 2f, 8f))); obj.Render(); ((Component)obj).transform.position = ((Component)lounge.Entrance).transform.position - ((Component)lounge.Entrance).transform.forward * 5f + Vector3.up * 2.5f; ((Component)obj).transform.LookAt(((Component)lounge.Entrance).transform.position + Vector3.up * 2f); obj.Render(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Bazaar scene preload: lounge, tables, broker and first render ready in " + stopwatch.ElapsedMilliseconds + "ms.")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Casino render preload skipped: " + ex.Message)); } finally { if (Object.op_Implicit((Object)(object)val)) { val.GetComponent<Camera>().targetTexture = null; Object.Destroy((Object)(object)val); } if (Object.op_Implicit((Object)(object)val2)) { RenderTexture.ReleaseTemporary(val2); } } } private void StopScenePreparation() { if (preparingScene != null) { ((MonoBehaviour)this).StopCoroutine(preparingScene); preparingScene = null; } preparedSceneHandle = -1; } private void GuardSeatTeleport(orig_TeleportGameObject_GameObject_Vector3_Vector3_Quaternion_bool_bool orig, GameObject target, Vector3 position, Vector3 delta, Quaternion rotation, bool useRotation, bool authority) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) CasinoSeat casinoSeat = ((InBazaar && Object.op_Implicit((Object)(object)target)) ? target.GetComponent<CasinoSeat>() : null); if (Object.op_Implicit((Object)(object)casinoSeat) && casinoSeat.BlocksForeignTeleport) { casinoSeat.PinNow("foreign teleport blocked"); } else { orig.Invoke(target, position, delta, rotation, useRotation, authority); } } private void GuardSeatMapZone(orig_TeleportBody orig, MapZone zone, CharacterBody body) { CasinoSeat casinoSeat = ((InBazaar && Object.op_Implicit((Object)(object)body)) ? ((Component)body).GetComponent<CasinoSeat>() : null); if (Object.op_Implicit((Object)(object)casinoSeat) && casinoSeat.BlocksForeignTeleport) { casinoSeat.PinNow("map-zone teleport blocked"); } else { orig.Invoke(zone, body); } } private static bool PauseSeatedState(EntityStateMachine machine) { if (!InBazaar || !Object.op_Implicit((Object)(object)machine)) { return false; } CasinoSeat component = ((Component)machine).GetComponent<CasinoSeat>(); if (Object.op_Implicit((Object)(object)component)) { return component.PausesMovementState; } return false; } private void SuppressSeatStateUpdate(orig_ManagedUpdate orig, EntityStateMachine self) { if (!PauseSeatedState(self)) { orig.Invoke(self); } } private void SuppressSeatStateFixedUpdate(orig_ManagedFixedUpdate orig, EntityStateMachine self, float deltaTime) { if (!PauseSeatedState(self)) { orig.Invoke(self, deltaTime); } } private void SuppressSeatUpdate(orig_Update orig, PlayerCharacterMasterController self) { orig.Invoke(self); CharacterBody val = (Object.op_Implicit((Object)(object)self.master) ? self.master.GetBody() : null); CasinoSeat casinoSeat = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CasinoSeat>() : null); if (Object.op_Implicit((Object)(object)casinoSeat) && casinoSeat.IsSeated) { casinoSeat.ClearInput(); } else if (Object.op_Implicit((Object)(object)ui) && (ui.IsAnyCasinoOpen || ui.InteractionBlocked) && (Object)(object)self.master == (Object)(object)LocalMaster) { ClearSlotInput(val); } } private void SuppressSeatFixedUpdate(orig_FixedUpdate orig, PlayerCharacterMasterController self) { orig.Invoke(self); CharacterBody val = (Object.op_Implicit((Object)(object)self.master) ? self.master.GetBody() : null); CasinoSeat casinoSeat = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CasinoSeat>() : null); if (Object.op_Implicit((Object)(object)casinoSeat) && casinoSeat.IsSeated) { casinoSeat.ClearInput(); } else if (Object.op_Implicit((Object)(object)ui) && (ui.IsAnyCasinoOpen || ui.InteractionBlocked) && (Object)(object)self.master == (Object)(object)LocalMaster) { ClearSlotInput(val); } } private static void ClearSlotInput(CharacterBody body) { //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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inputBank)) { InputBankTest inputBank = body.inputBank; inputBank.moveVector = Vector3.zero; ((ButtonState)(ref inputBank.skill1)).PushState(false); ((ButtonState)(ref inputBank.skill2)).PushState(false); ((ButtonState)(ref inputBank.skill3)).PushState(false); ((ButtonState)(ref inputBank.skill4)).PushState(false); ((ButtonState)(ref inputBank.jump)).PushState(false); ((ButtonState)(ref inputBank.sprint)).PushState(false); ((ButtonState)(ref inputBank.interact)).PushState(false); ((ButtonState)(ref inputBank.activateEquipment)).PushState(false); ((ButtonState)(ref inputBank.activateKeyItem)).PushState(false); ((ButtonState)(ref inputBank.ping)).PushState(false); if (Object.op_Implicit((Object)(object)body.characterMotor)) { body.characterMotor.velocity = Vector3.zero; body.characterMotor.rootMotion = Vector3.zero; } RigidbodyMotor component = ((Component)body).GetComponent<RigidbodyMotor>(); if (Object.op_Implicit((Object)(object)component)) { component.moveVector = Vector3.zero; } } } internal void RequestTableExit(TableKind kind) { pendingTableExit = kind; nextSeatExit = 0f; ReleaseSeating(LocalMasterId, returnToFloor: true); } private void UpdateTableExit() { if (pendingTableExit != 0 && InBazaar && !Waiting && !(Time.unscaledTime < nextSeatExit)) { nextSeatExit = Time.unscaledTime + 0.35f; Send(ActionKind.TableLeave, 0, 0, 0, null, pendingTableExit); } } private void ApplySeating(TableSnapshot snapshot, WorldTable table) { //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) TableKind tableKind = (TableKind)snapshot.kind; KeyValuePair<uint, CasinoSeat>[] array = seatedBodies.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<uint, CasinoSeat> pair = array[i]; if (!Object.op_Implicit((Object)(object)pair.Value) || (pair.Value.Kind == tableKind && !snapshot.seats.Any((TableSeatState s) => s.id == pair.Key && s.seated))) { if (Object.op_Implicit((Object)(object)pair.Value)) { pair.Value.Release(returnToFloor: true); } seatedBodies.Remove(pair.Key); } } foreach (TableSeatState item in snapshot.seats.Where((TableSeatState s) => s.seated)) { if (item.id == LocalMasterId && (pendingTableExit == tableKind || !ui.IsSharedTableOpen(tableKind))) { continue; } CharacterMaster val = FindMaster(item.id); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBody() : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.healthComponent) || !val2.healthComponent.alive) { continue; } uint bodyId = item.bodyId; NetworkInstanceId netId = ((NetworkBehaviour)val2).netId; if (!SeatPlacement.Accept(bodyId, ((NetworkInstanceId)(ref netId)).Value, item.slot, item.returnRoot, item.returnX, item.returnY, item.returnZ) || !item.hasAnchor) { continue; } SeatAnchor assigned; try { assigned = new SeatAnchor(item.bodyId, item.slot, item.anchorX, item.anchorY, item.anchorZ, item.anchorYaw); } catch (ArgumentException) { continue; } if (seatedBodies.TryGetValue(item.id, out var value) && Object.op_Implicit((Object)(object)value)) { if ((Object)(object)value.Body == (Object)(object)val2 && value.Kind == tableKind) { continue; } value.Release(returnToFloor: false); seatedBodies.Remove(item.id); } CasinoSeat casinoSeat = ((Component)val2).gameObject.AddComponent<CasinoSeat>(); try { casinoSeat.Enter(val2, table, assigned, new Vector3(item.returnX, item.returnY, item.returnZ)); seatedBodies[item.id] = casinoSeat; } catch (Exception ex2) { Object.Destroy((Object)(object)casinoSeat); ((BaseUnityPlugin)this).Logger.LogError((object)("Could not apply casino seat to " + ((Object)val2).name + ": " + ex2)); if (item.id == LocalMasterId) { ui.Notify("Could not apply this seat. Your movement has been restored."); ui.CloseSharedTable(); } } } } private void ReleaseSeating(uint id, bool returnToFloor) { if (seatedBodies.TryGetValue(id, out var value)) { if (Object.op_Implicit((Object)(object)value)) { value.Release(returnToFloor); } seatedBodies.Remove(id); } } private void ClearSeating(bool returnToFloor) { foreach (CasinoSeat value in seatedBodies.Values) { if (Object.op_Implicit((Object)(object)value)) { value.Release(returnToFloor); } } seatedBodies.Clear(); standingPositions.Clear(); seatAnchors.Clear(); } private string ValidateSlotMachine(CharacterBody body, int number) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (number == 0) { return "Use E on a slot machine inside the Casino Lounge."; } if (!Object.op_Implicit((Object)(object)lounge) || number < 1 || number > lounge.Slots.Count) { return "Slot machine is unavailable."; } if (Vector3.Distance(body.corePosition, ((Component)lounge.Slots[number - 1]).transform.position) > 8f) { return "Move closer to the slot machine."; } if (Time.unscaledTime < slotReadyAt[number - 1]) { return "This machine is still spinning. Try again in a moment."; } return null; } private void BroadcastSlotResult(int number, int[] reels, int net) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (number >= 1 && number <= 3) { slotReadyAt[number - 1] = Time.unscaledTime + 3.8f; slotStartedAt[number - 1] = Time.unscaledTime; TableSnapshot obj = new TableSnapshot { machine = number, slotSpin = ++slotSpinCounter, slotReels = reels, slotNet = net }; int sceneId; if (!Object.op_Implicit((Object)(object)Stage.instance)) { sceneId = 0; } else { NetworkInstanceId netId = ((NetworkBehaviour)Stage.instance).netId; sceneId = (int)((NetworkInstanceId)(ref netId)).Value; } obj.sceneId = (uint)sceneId; TableSnapshot tableSnapshot = obj; slotDisplays[number - 1] = tableSnapshot; ApplyTableSnapshot(tableSnapshot); NetworkServer.SendToAll((short)(requestMessageId.Value + 2), (MessageBase)(object)new TableReply { json = JsonUtility.ToJson((object)tableSnapshot) }); } } internal WorldTable TableObject(TableKind kind) { if (!worldTables.TryGetValue(kind, out var value)) { return null; } return value; } internal TableSnapshot Snapshot(TableKind kind) { if (!tableStates.TryGetValue(kind, out var value)) { return null; } return value; } internal float TableTimeLeft(TableKind kind) { if (!tableStates.TryGetValue(kind, out var value) || !tableReceivedAt.TryGetValue(kind, out var value2)) { return 0f; } return Mathf.Max(0f, value.remaining - Time.unscaledTime + value2); } internal void UseLoungeDoor(Interactor actor, CasinoLoungeDoor door) { //IL_0055: 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) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)actor) && !((Object)(object)((Component)actor).gameObject != (Object)(object)((Component)val).gameObject) && Object.op_Implicit((Object)(object)door) && InBazaar && !Waiting && !(Vector3.Distance(val.corePosition, ((Component)door).transform.position) > 8f) && pendingTableExit == (TableKind)0) { ui.Close(); Send(door.IsExit ? ActionKind.LoungeExit : ActionKind.LoungeEnter); } } private string ProcessLoungeDoor(CharacterMaster master, CasinoRequest request, CasinoState state) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)lounge)) { return "Lounge is not available yet."; } if (joinedTables.ContainsKey(request.masterId)) { return "Stand up from your table first."; } CasinoLoungeDoor casinoLoungeDoor = ((request.action == ActionKind.LoungeExit) ? lounge.Exit : lounge.Entrance); CharacterBody body = master.GetBody(); if (Vector3.Distance(body.corePosition, ((Component)casinoLoungeDoor).transform.position) > 8f) { return "Move closer to the lounge door."; } Vector3 val = (casinoLoungeDoor.IsExit ? lounge.ReturnPosition() : lounge.Arrival); Vector3 val2 = (casinoLoungeDoor.IsExit ? (-((Component)casinoLoungeDoor).transform.forward) : ((Component)lounge).transform.forward); NetworkInstanceId netId = ((NetworkBehaviour)body).netId; state.loungeBodyId = ((NetworkInstanceId)(ref netId)).Value; int loungeSceneId; if (!Object.op_Implicit((Object)(object)Stage.instance)) { loungeSceneId = 0; } else { netId = ((NetworkBehaviour)Stage.instance).netId; loungeSceneId = (int)((NetworkInstanceId)(ref netId)).Value; } state.loungeSceneId = (uint)loungeSceneId; state.loungeX = val.x; state.loungeY = val.y; state.loungeZ = val.z; Quaternion val3 = Quaternion.LookRotation(val2); state.loungeYaw = ((Quaternion)(ref val3)).eulerAngles.y; TeleportHelper.TeleportBody(body, val, false); if (Object.op_Implicit((Object)(object)body.characterMotor)) { body.characterMotor.velocity = Vector3.zero; } if (Object.op_Implicit((Object)(object)body.characterDirection)) { body.characterDirection.forward = val2; } state.loungeMoved = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Authorized " + (casinoLoungeDoor.IsExit ? "lounge exit" : "lounge entry") + " for " + PlayerName(master) + " (request " + request.requestId + ").")); return null; } internal void OpenTable(Interactor actor, WorldTable table) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = (Object.op_Implicit((Object)(object)LocalMaster) ? LocalMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)actor) && !((Object)(object)((Component)actor).gameObject != (Object)(object)((Component)val).gameObject) && InBazaar && !(Vector3.Distance(val.corePosition, ((Component)table).transform.position) > 12f)) { if (pendingTableExit != 0) { ui.Notify("Leaving the previous seat; try again in a moment."); } else if (ui.CanOpenInteraction) { ui.OpenSharedTable(table.Kind); } } } private unsafe void UpdateTables() { //IL_0161: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !InBazaar) { return; } if (SceneExitController.isRunning) { if (worldTables.Count > 0 || Object.op_Implicit((Object)(object)lounge)) { ClearTables(settle: true); } return; } if (worldTables.Count < 2 && Time.unscaledTime >= nextTableSpawn) { nextTableSpawn = Time.unscaledTime + 2f; if (!Object.op_Implicit((Object)(object)lounge)) { try { lounge = CasinoLounge.TrySpawn(); if (Object.op_Implicit((Object)(object)lounge)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Casino lounge created: " + CasinoLounge.Diagnostic)); } } catch (Exception ex) { if (Time.unscaledTime >= nextPlacementWarning) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create casino lounge: " + ex)); } } if (!Object.op_Implicit((Object)(object)lounge)) { if (Time.unscaledTime >= nextPlacementWarning) { nextPlacementWarning = Time.unscaledTime + 20f; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Casino lounge placement: " + CasinoLounge.Diagnostic)); } return; } } TableKind[] array = new TableKind[2] { TableKind.Blackjack, TableKind.Roulette }; for (int i = 0; i < array.Length; i++) { TableKind tableKind = array[i]; if (worldTables.ContainsKey(tableKind)) { continue; } try { Vector3 val = lounge.TablePosition(tableKind); worldTables[tableKind] = WorldTable.Create(tableKind, val, lounge.TableRotation); tableRevision++; nextTableBroadcast = 0f; ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string text = tableKind.ToString(); Vector3 val2 = val; logger.LogInfo((object)("Shared " + text + " table placed at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString())); } catch (Exception ex2) { if (Time.unscaledTime >= nextPlacementWarning) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create " + tableKind.ToString() + " table: " + ex2)); } } } if (worldTables.Count < 2 && Time.unscaledTime >= nextPlacementWarning) { nextPlacementWarning = Time.unscaledTime + 20f; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Retrying missing lounge tables; found " + worldTables.Count + " of 2.")); } } double now = Time.unscaledTime; KeyValuePair<uint, TableKind>[] array2 = joinedTables.ToArray(); for (int i = 0; i < array2.Length; i++) { KeyValuePair<uint, TableKind> keyValuePair = array2[i]; CharacterMaster val3 = FindMaster(keyValuePair.Key); CharacterBody val4 = (Object.op_Implicit((Object)(object)val3) ? val3.GetBody() : null); if (!worldTables.TryGetValue(keyValuePair.Value, out var _)) { continue; } if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val4.healthComponent) && seatAnchors.TryGetValue(keyValuePair.Key, out var value2)) { SeatAnchor seatAnchor = value2; NetworkInstanceId netId = ((NetworkBehaviour)val4).netId; if (seatAnchor.Keeps(((NetworkInstanceId)(ref netId)).Value, connected: true, val4.healthComponent.alive, SceneExitController.isRunning)) { continue; } } LeaveSharedTable(keyValuePair.Key, keyValuePair.Value, now); } uint turn = blackjackTable.turn; int num = blackjackTable.Find(turn)?.activeHand ?? 0; blackjackTable.Tick(now, rng); rouletteTable.Tick(now, rng); PayTables(); if (blackjackTable.phase != oldBlackjackPhase || rouletteTable.phase != oldRoulettePhase || turn != blackjackTable.turn || num != (blackjackTable.Find(blackjackTable.turn)?.activeHand ?? 0)) { tableRevision++; nextTableBroadcast = 0f; oldBlackjackPhase = blackjackTable.phase; oldRoulettePhase = rouletteTable.phase; } if (blackjackTable.phase == TablePhase.Betting) { blackjackTable.seats.RemoveAll((SharedSeat s) => !joinedTables.TryGetValue(s.id, out var value3) || value3 != TableKind.Blackjack); } if (rouletteTable.phase == TablePhase.Betting) { rouletteTable.seats.RemoveAll((SharedSeat s) => !joinedTables.TryGetValue(s.id, out var value3) || value3 != TableKind.Roulette); } if (Time.unscaledTime >= nextTableBroadcast) { nextTableBroadcast = Time.unscaledTime + 0.5f; BroadcastTables(); } } private static CharacterMaster FindMaster(uint id) { NetworkUser? obj = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)delegate(NetworkUser u) { //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 (Object.op_Implicit((Object)(object)u) && Object.op_Implicit((Object)(object)u.master)) { NetworkInstanceId netId = ((Component)u.master).GetComponent<NetworkIdentity>().netId; return ((NetworkInstanceId)(ref netId)).Value == id; } return false; }); if (obj == null) { return null; } return obj.master; } private static string PlayerName(CharacterMaster master) { string text = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)((NetworkUser u) => Object.op_Implicit((Object)(object)u) && (Object)(object)u.master == (Object)(object)master))?.userName ?? "Survivor"; text = text.Replace("<", "").Replace(">", ""); if (text.Length <= 24) { return text; } return text.Substring(0, 24); } private bool HasTableStake(uint id) { SharedSeat sharedSeat = blackjackTable.Find(id); if (sharedSeat == null || sharedSeat.wager <= 0 || blackjackTable.phase == TablePhase.Results) { SharedSeat sharedSeat2 = rouletteTable.Find(id); if (sharedSeat2 != null && sharedSeat2.wager > 0) { return rouletteTable.phase != TablePhase.Results; } return false; } return true; } private void LeaveSharedTable(uint id, TableKind kind, double now) { int amount = ((kind == TableKind.Blackjack) ? blackjackTable.Leave(id, now) : rouletteTable.Leave(id)); CharacterMaster val = FindMaster(id); if (Object.op_Implicit((Object)(object)val)) { Credit(val, amount); } joinedTables.Remove(id); ReleaseSeating(id, returnToFloor: true); standingPositions.Remove(id); seatAnchors.Remove(id); tableRevision++; nextTableBroadcast = 0f; PayTables(); } private string ProcessTable(CharacterMaster master, CasinoRequest request) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) TableKind table = (TableKind)request.table; uint masterId = request.masterId; double now = Time.unscaledTime; if ((table != TableKind.Blackjack && table != TableKind.Roulette) || !worldTables.TryGetValue(table, out var value)) { return "Table is not available yet."; } if (request.action == ActionKind.TableLeave) { if (joinedTables.TryGetValue(masterId, out var value2) && value2 == table) { LeaveSharedTable(masterId, table, now); } BroadcastTables(); return null; } if ((!joinedTables.TryGetValue(masterId, out var value3) || value3 != table) && Vector3.Distance(master.GetBody().corePosition, ((Component)value).transform.position) > 14f) { return "Move closer to the table."; } NetworkInstanceId netId; if (joinedTables.ContainsKey(masterId) && seatAnchors.TryGetValue(masterId, out var value4)) { uint bodyId = value4.BodyId; netId = ((NetworkBehaviour)master.GetBody()).netId; if (bodyId != ((NetworkInstanceId)(ref netId)).Value) { return "Your character changed. Join the table again."; } } if (sessions.TryGetValue(master, out var value5)) { BlackjackRound hand = value5.hand; if (hand != null && hand.active) { return "Finish your private blackjack hand first."; } } if (request.action == ActionKind.TableJoin) { if (sessions.TryGetValue(master, out var value6)) { BlackjackRound hand2 = value6.hand; if (hand2 != null && hand2.active) { return "Finish your private blackjack hand first."; } } if (joinedTables.TryGetValue(masterId, out var value7) && value7 != table) { if (HasTableStake(masterId)) { return "Finish or cancel your wager at the other table first."; } LeaveSharedTable(masterId, value7, now); } if (!((table == TableKind.Blackjack) ? blackjackTable.Join(masterId, PlayerName(master)) : rouletteTable.Join(masterId, PlayerName(master)))) { return "Table is full or a round is in progress. Watch, then join the next round."; } if (!joinedTables.TryGetValue(masterId, out var value8) || value8 != table) { standingPositions[masterId] = ((Component)master.GetBody()).transform.position; CharacterBody body = master.GetBody(); SharedSeat sharedSeat = ((table == TableKind.Blackjack) ? blackjackTable.Find(masterId) : rouletteTable.Find(masterId)); Vector3 val = value.ChairFoot(sharedSeat.slot) + Vector3.up * CasinoSeat.Clearance(body); Dictionary<uint, SeatAnchor> dictionary = seatAnchors; netId = ((NetworkBehaviour)body).netId; uint value9 = ((NetworkInstanceId)(ref netId)).Value; int slot = sharedSeat.slot; float x = val.x; float y = val.y; float z = val.z; Quaternion val2 = value.ChairFacing(sharedSeat.slot); dictionary[masterId] = new SeatAnchor(value9, slot, x, y, z, ((Quaternion)(ref val2)).eulerAngles.y); } joinedTables[masterId] = table; } else { if (!joinedTables.TryGetValue(masterId, out var value10) || value10 != table) { return "Join this table first (E)."; } if (request.action == ActionKind.TableBet) { if (table == TableKind.Blackjack) { if (!blackjackTable.CanBet(masterId)) { return "Betting is closed."; } int wager = request.wager; int wager2 = blackjackTable.Find(masterId).wager; if (!WagerRules.Valid(wager, MinimumBet, MaximumBet, (ulong)master.money + (ulong)(uint)wager2, request.allIn, refund: true)) { return "Invalid wager or insufficient gold."; } AdjustReservedGold(master, wager2, wager); blackjackTable.Bet(masterId, wager, now); } else { if (!rouletteTable.CanBet(masterId)) { return "Betting is closed."; } int wager3 = rouletteTable.Find(masterId).wager; int total = 0; RouletteBet[] array = request.bets ?? Array.Empty<RouletteBet>();