using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCasino; using LethalCasino.Custom; using LethalCasinoTweaks.Components; using LethalCasinoTweaks.Extensions; using LethalCasinoTweaks.Patches; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using confusingus.LethalCasinoTweaks.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("mrgrm7.LethalCasino")] [assembly: AssemblyCompany("confusingus.LethalCasinoTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+dcec165c20f339b14e60db12d288dc054ddcfcde")] [assembly: AssemblyProduct("LethalCasinoTweaks")] [assembly: AssemblyTitle("confusingus.LethalCasinoTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalCasinoTweaks { [BepInPlugin("confusingus.LethalCasinoTweaks", "LethalCasinoTweaks", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LethalCasinoTweaks : BaseUnityPlugin { public class LcCasinoTweaksInputActions : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction? DoubleDownKey { get; set; } } public static LethalCasinoTweaks Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } internal static LcCasinoTweaksInputActions? InputActions { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; InputActions = new LcCasinoTweaksInputActions(); Patch(); AttachNetworkBridgeToPrefab(); AttachDoubleDownFeature(); Logger.LogInfo((object)"confusingus.LethalCasinoTweaks v1.3.0 has loaded!"); } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("confusingus.LethalCasinoTweaks"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } internal static void AttachNetworkBridgeToPrefab() { GameObject val = Plugin.Prefabs["Blackjack"]; val.AddComponent(); } internal static void AttachDoubleDownFeature() { GameObject val = Plugin.Prefabs["Blackjack"]; val.AddComponent(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "confusingus.LethalCasinoTweaks"; public const string PLUGIN_NAME = "LethalCasinoTweaks"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace LethalCasinoTweaks.Patches { [HarmonyPatch(typeof(Blackjack), "JoinGameServerRpc")] public class BlackjackJoinGameServerRpcPatch { private static readonly FieldInfo FRpcExecStage = AccessTools.Field(typeof(NetworkBehaviour), "__rpc_exec_stage"); private static readonly FieldInfo FGameInProgressField = AccessTools.Field(typeof(Blackjack), "gameInProgress"); private static readonly MethodInfo MIsUnableToPlaceBet = AccessTools.Method(typeof(BlackjackExtensions), "IsUnableToPlaceBet", (Type[])null, (Type[])null); private static readonly MethodInfo MServerSuccessfullyPlacedBet = AccessTools.Method(typeof(BlackjackExtensions), "ServerSuccessfullyPlacedBet", (Type[])null, (Type[])null); public static int? LastOriginalPlayerIdx; private static IEnumerable Transpiler(IEnumerable instructions) { LethalCasinoTweaks.Logger.LogDebug((object)"[JoinGameServerRpc] Generating reverse patch code"); bool successfullyReplaced = false; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldfld && instruction.operand is FieldInfo fieldInfo && fieldInfo == FGameInProgressField) { LethalCasinoTweaks.Logger.LogDebug((object)"[JoinGameServerRpc] Successfully patched gameInProgress field"); yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)MIsUnableToPlaceBet); successfullyReplaced = true; } else if (instruction.opcode == OpCodes.Ret) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)MServerSuccessfullyPlacedBet); yield return instruction; } else { yield return instruction; } } if (!successfullyReplaced) { LethalCasinoTweaks.Logger.LogWarning((object)"[JoinGameServerRpc] Failed to generate reverse patch code"); } } [HarmonyPrefix] private static void JoinGameServerRpcPrefix(out int __state, Blackjack __instance, NetworkBehaviourReference playerRef, ref int playerIdx) { __state = (int)FRpcExecStage.GetValue(__instance); if (((NetworkBehaviour)__instance).IsServer && __state == 1) { LastOriginalPlayerIdx = playerIdx; if (playerIdx < 0) { playerIdx += BlackjackDoubleDownFeature.MagicPlayerIndexOffset; } } } [HarmonyPostfix] private static void JoinGameServerRpcPostfix(int __state, Blackjack __instance, NetworkBehaviourReference playerRef, int playerIdx) { if (((NetworkBehaviour)__instance).IsServer && __state == 1) { LastOriginalPlayerIdx = null; } } } [HarmonyPatch(typeof(Blackjack))] public class BlackjackPatch { public static readonly int FullDeckSize = 52; public static readonly float FDeckCardYOffset = 0.001f; public static float FInitialDeckLocalYPos = 0.9462f; public static float FEmptyDeckLocalYPos = FInitialDeckLocalYPos - FDeckCardYOffset * (float)FullDeckSize; public static List? InstanceCardsInPlay = null; [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(Blackjack __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Transform cardDeckTransform = GetCardDeckTransform(__instance); if ((Object)(object)cardDeckTransform != (Object)null) { FInitialDeckLocalYPos = ((Component)cardDeckTransform).transform.localPosition.y; FEmptyDeckLocalYPos = FInitialDeckLocalYPos - FDeckCardYOffset * (float)FullDeckSize; } else { LethalCasinoTweaks.Logger.LogDebug((object)"Failed to find card deck on start, using default position"); } } [HarmonyPatch("ShuffleDeck")] [HarmonyPrefix] public static void ShuffleDeckPrefix(List ts) { if (InstanceCardsInPlay == null) { LethalCasinoTweaks.Logger.LogDebug((object)"Skipping shuffle deck behavior, InstanceCardsInPlay is null"); return; } LethalCasinoTweaks.Logger.LogDebug((object)$"Dropping {InstanceCardsInPlay.Count} in-play cards from new deck"); List list = new List(); foreach (Card card in ts) { int num = InstanceCardsInPlay.FindIndex((Card x) => x.suit == card.suit && x.face == card.face); if (num != -1) { InstanceCardsInPlay.RemoveAt(num); } else { list.Add(card); } } ts.Clear(); ts.AddRange(list); } [HarmonyPatch("CreateDeck")] [HarmonyPrefix] private static bool CreateDeckPrefix(Blackjack __instance, out bool __state) { if (!ShouldCreateDeck(__instance)) { LethalCasinoTweaks.Logger.LogDebug((object)"Skipping create deck while non-empty"); __state = false; return false; } LethalCasinoTweaks.Logger.LogDebug((object)"Storing cards in play before creating/shuffling deck"); __state = true; InstanceCardsInPlay = __instance.playerCards.SelectMany((List c) => c).ToList(); return true; } [HarmonyPatch("CreateDeck")] [HarmonyPostfix] private static void CreateDeckPostfix(Blackjack __instance, bool __state) { BlackjackGameStateRpcBridge componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogDebug((object)"Failed to find RPC bridge"); return; } if (__state) { LethalCasinoTweaks.Logger.LogDebug((object)"Playing shuffle sound for all clients"); componentInParent.OnShuffleClientRpc(); } else { LethalCasinoTweaks.Logger.LogDebug((object)"Didn't create a deck, skipping shuffle sound"); } InstanceCardsInPlay = null; } [HarmonyPatch("DealCard")] [HarmonyPrefix] private static void DealCardPrefix(Blackjack __instance) { if (ShouldCreateDeck(__instance)) { LethalCasinoTweaks.Logger.LogDebug((object)"Reshuffling empty deck before dealing"); __instance.CreateDeck(); } } [HarmonyPatch("DealCard")] [HarmonyPostfix] private static void DealCardPostfix(Blackjack __instance) { BlackjackGameStateRpcBridge componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogDebug((object)"Failed to find RPC bridge"); } else { componentInParent.UpdateDeckCountClientRpc(__instance.deck.Count); } } [HarmonyPatch("ResetGameState")] [HarmonyPostfix] private static void ResetGameStatePostfix(Blackjack __instance) { BlackjackDoubleDownFeature componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogWarning((object)"Failed to find DoubleDownFeature"); } else { componentInParent.ResetDoubleDownState(); } } private static bool ShouldCreateDeck(Blackjack instance) { if (instance.deck != null) { return instance.deck.Count == 0; } return true; } private static Transform? GetCardDeckTransform(Blackjack instance) { return ((Component)instance).transform.Find("CardDeck"); } } [HarmonyPatch(typeof(Blackjack), "StartGameClientRpc")] public static class BlackjackStartGameClientRpcPatch { private static readonly MethodInfo MPlayOneShot = AccessTools.Method(typeof(AudioSource), "PlayOneShot", new Type[2] { typeof(AudioClip), typeof(float) }, (Type[])null); private static readonly FieldInfo FAudioSource = AccessTools.Field(typeof(Blackjack), "audioSource"); private static IEnumerable Transpiler(IEnumerable instructions) { LethalCasinoTweaks.Logger.LogDebug((object)"[StartGameClientRpc] Generating reverse patch code"); List list = instructions.ToList(); int num = -1; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (num == -1) { int num3 = i + 1; if (list[i].opcode == OpCodes.Ldarg_0 && num3 < list.Count && list[num3].opcode == OpCodes.Ldfld && (FieldInfo)list[num3].operand == FAudioSource) { num = i; } } else if (list[i].opcode == OpCodes.Callvirt && (MethodInfo)list[i].operand == MPlayOneShot) { num2 = i; } } if (num > -1 && num2 > -1) { LethalCasinoTweaks.Logger.LogDebug((object)$"[StartGameClientRpc] Found instructions to patch, removing: [{num}, {num2}]"); list.RemoveRange(num, num2 - num + 1); } else { LethalCasinoTweaks.Logger.LogWarning((object)$"[StartGameClientRpc] Failed to find audioSource call to patch: [{num}, {num2}]"); } return list.AsEnumerable(); } } } namespace LethalCasinoTweaks.Extensions { public static class BlackjackExtensions { public static void SetCardDeckLocalYPosition(this Blackjack instance, float yPos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)instance).transform.Find("CardDeck"); if ((Object)(object)val != (Object)null) { Vector3 localPosition = val.localPosition; val.localPosition = new Vector3(localPosition.x, yPos, localPosition.z); } else { LethalCasinoTweaks.Logger.LogWarning((object)"[BlackjackExtensions] Failed to find CardDeck transform"); } } public static bool IsUnableToPlaceBet(this Blackjack instance, NetworkBehaviourReference playerRef, int playerIdx) { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackExtensions] Calling CanAttemptToPlaceBet"); PlayerControllerB playerController = default(PlayerControllerB); if (!((NetworkBehaviourReference)(ref playerRef)).TryGet(ref playerController, (NetworkManager)null)) { LethalCasinoTweaks.Logger.LogWarning((object)"[BlackjackExtensions] Failed to extract player controller"); return instance.gameInProgress; } if (instance.gameInProgress) { BlackjackDoubleDownFeature componentInParent = ((Component)instance).GetComponentInParent(); return !componentInParent.ShouldAllowGameInProgressBet(playerController, playerIdx); } return instance.gameInProgress; } public static void ServerSuccessfullyPlacedBet(this Blackjack instance, NetworkBehaviourReference playerRef, int playerIdx) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackExtensions] Calling ServerSuccessfullyPlacedBet"); BlackjackDoubleDownFeature componentInParent = ((Component)instance).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.ServerPostDoubleDownSuccess(instance, playerRef, playerIdx); } } } } namespace LethalCasinoTweaks.Components { public class BlackjackDoubleDownFeature : NetworkBehaviour { public static readonly int MagicPlayerIndexOffset = 1000; private static readonly Regex PlayerHandPositionRegex = new Regex("^Player([1-4])HandPosition$", RegexOptions.Compiled); private bool[] _doubleDownState = new bool[4]; private void Awake() { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Awake"); if (LethalCasinoTweaks.InputActions?.DoubleDownKey != null) { LethalCasinoTweaks.InputActions.DoubleDownKey.performed += OnActivateDoubleDown; } else { LethalCasinoTweaks.Logger.LogWarning((object)"[BlackjackDoubleDownFeature] DoubleDown input action not ready"); } UpdateKeyBindTooltipHint(); } public void UpdateKeyBindTooltipHint() { Blackjack componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Failed to find blackjack sibling component"); return; } InteractTrigger hitPrefabTrigger = GetHitPrefabTrigger(); if (Object.op_Implicit((Object)(object)hitPrefabTrigger)) { hitPrefabTrigger.hoverTip = FormatHoverTip(); } else { LethalCasinoTweaks.Logger.LogWarning((object)"[BlackjackDoubleDownFeature] Failed to find hit prefab trigger"); } } private void OnActivateDoubleDown(CallbackContext ctx) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) try { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!Object.op_Implicit((Object)(object)localPlayerController)) { LethalCasinoTweaks.Logger.LogWarning((object)"[BlackjackDoubleDownFeature] Missing local player controller"); return; } Blackjack componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Failed to find blackjack sibling component"); return; } int localPlayerIndex = GetLocalPlayerIndex(componentInParent, localPlayerController); if (localPlayerIndex == -1) { LethalCasinoTweaks.Logger.LogDebug((object)"No player index"); return; } if (!IsHoveringBetControls(componentInParent, localPlayerController)) { LethalCasinoTweaks.Logger.LogDebug((object)"Not hovering bet controls"); return; } LethalCasinoTweaks.LcCasinoTweaksInputActions? inputActions = LethalCasinoTweaks.InputActions; if (inputActions != null) { InputAction? doubleDownKey = inputActions.DoubleDownKey; if (((doubleDownKey != null) ? new bool?(doubleDownKey.triggered) : null).GetValueOrDefault()) { DoubleDownServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)localPlayerController), localPlayerIndex); } } } catch (Exception arg) { LethalCasinoTweaks.Logger.LogError((object)$"[BlackjackDoubleDownFeature] Error applying double down feature: {arg}"); } } public bool ShouldAllowGameInProgressBet(PlayerControllerB playerController, int playerIdx) { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Calling ShouldAllowGameInProgressBet"); if (IsMatchingMagicPlayerIndex(playerIdx) && !HasPlayerDoubledDown(playerIdx)) { return true; } return false; } public bool HasPlayerDoubledDown(int playerIdx) { if ((playerIdx < 0 || playerIdx > 3) ? true : false) { throw new ArgumentException("playerIdx must be between 0 and 3"); } return _doubleDownState[playerIdx]; } public void ResetDoubleDownState() { _doubleDownState = new bool[4]; } public void ServerPostDoubleDownSuccess(Blackjack instance, NetworkBehaviourReference playerRef, int playerIdx) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) LethalCasinoTweaks.Logger.LogDebug((object)"[JoinGameSuccessfulClientRpcPatch] Calling ServerPostDoubleDownSuccess"); if (!IsMatchingMagicPlayerIndex(playerIdx)) { LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Skipping non-double down success"); return; } SetHasPlayerDoubledDown(playerIdx, hasDoubledDown: true); instance.DestroyBetControlsClientRpc(playerIdx); instance.TakeTurnAsPlayerServerRpc(playerRef, playerIdx, "hit"); instance.TakeTurnAsPlayerServerRpc(playerRef, playerIdx, "stand"); instance.ShowWarningMessageClientRpc(playerRef, "You doubled down!", "", false); } private void SetHasPlayerDoubledDown(int playerIdx, bool hasDoubledDown) { if ((playerIdx < 0 || playerIdx > 3) ? true : false) { throw new ArgumentException("playerIdx must be between 0 and 3"); } _doubleDownState[playerIdx] = hasDoubledDown; } [ServerRpc(RequireOwnership = false)] private void DoubleDownServerRpc(NetworkBehaviourReference playerRef, int playerIdx) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2323124059u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref playerRef, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, playerIdx); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2323124059u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Calling DoubleDownServerRpc"); Blackjack componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogError((object)"[BlackjackDoubleDownFeature] Failed to find blackjack sibling component"); return; } PlayerControllerB val3 = default(PlayerControllerB); if (!((NetworkBehaviourReference)(ref playerRef)).TryGet(ref val3, (NetworkManager)null)) { LethalCasinoTweaks.Logger.LogError((object)"[BlackjackDoubleDownFeature] Missing remote player controller"); return; } if (HasPlayerDoubledDown(playerIdx)) { componentInParent.ShowWarningMessageClientRpc(playerRef, "Cannot double down", "You've already doubled down", true); return; } GrabbableObject val4 = val3.ItemSlots[val3.currentItemSlot]; if (!Object.op_Implicit((Object)(object)val4)) { componentInParent.ShowWarningMessageClientRpc(playerRef, "Cannot double down", "You're not holding an item", true); return; } CustomScrapController component = ((Component)val4).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { componentInParent.ShowWarningMessageClientRpc(playerRef, "Cannot double down", "You're not holding an item", true); return; } int num = componentInParent.gambledScrap[playerIdx].Sum((GrabbableObject scrap) => ((Component)scrap).GetComponent()?.originalScrapValue ?? 0); if (val4.scrapValue > num) { componentInParent.ShowWarningMessageClientRpc(playerRef, "Cannot double down", "The extra bet must be of equal or lesser value than your wager", true); return; } List list = componentInParent.playerCards[playerIdx]; if (list.Count != 2) { componentInParent.ShowWarningMessageClientRpc(playerRef, "Cannot double down", "You must have exactly two cards", true); return; } LethalCasinoTweaks.Logger.LogDebug((object)"[BlackjackDoubleDownFeature] Submitting double down wager"); componentInParent.JoinGameServerRpc(new NetworkBehaviourReference((NetworkBehaviour)(object)val3), playerIdx - MagicPlayerIndexOffset); } private static bool IsMatchingMagicPlayerIndex(int playerIdx) { int? lastOriginalPlayerIdx = BlackjackJoinGameServerRpcPatch.LastOriginalPlayerIdx; if (lastOriginalPlayerIdx.HasValue) { return lastOriginalPlayerIdx == playerIdx - MagicPlayerIndexOffset; } return false; } private static int GetLocalPlayerIndex(Blackjack instance, PlayerControllerB localPlayerController) { if (!Object.op_Implicit((Object)(object)localPlayerController) || !Object.op_Implicit((Object)(object)localPlayerController.hoveringOverTrigger)) { return -1; } GameObject gameObject = ((Component)localPlayerController.hoveringOverTrigger).gameObject; Transform val = gameObject.transform; while (Object.op_Implicit((Object)(object)val)) { Match match = PlayerHandPositionRegex.Match(((Object)val).name); if (match.Success && int.TryParse(match.Groups[1].Value, out var result)) { return result - 1; } val = val.parent; } return -1; } private static bool IsHoveringBetControls(Blackjack instance, PlayerControllerB localPlayerController) { if (!Object.op_Implicit((Object)(object)localPlayerController) || !Object.op_Implicit((Object)(object)localPlayerController.hoveringOverTrigger)) { return false; } GameObject gameObject = ((Component)localPlayerController.hoveringOverTrigger).gameObject; return ((Object)gameObject).name.Contains("Hit"); } private static InteractTrigger? GetHitPrefabTrigger() { Transform val = Plugin.Prefabs["BlackjackBetControls"].transform.Find("Hit"); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).gameObject.GetComponent(); } private static (InputAction?, InputAction?) GetInputActions() { InputAction item = LethalCasinoTweaks.InputActions?.DoubleDownKey; InputAction item2 = InputSystem.actions.FindAction("Interact", false); return (item2, item); } private static string FormatHoverTip() { //IL_002e: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) string text = "Not Bound"; string text2 = "Not Bound"; (InputAction?, InputAction?) inputActions = GetInputActions(); InputAction item = inputActions.Item1; InputAction item2 = inputActions.Item2; InputBinding? val = ((item != null) ? new InputBinding?(((IEnumerable)(object)item.bindings).First()) : null); InputBinding value; if (val.HasValue) { value = val.Value; text2 = ((InputBinding)(ref value)).ToDisplayString((DisplayStringOptions)0, (InputControl)null); } InputBinding? val2 = ((item2 != null) ? new InputBinding?(((IEnumerable)(object)item2.bindings).First()) : null); if (val2.HasValue) { value = val2.Value; text = ((InputBinding)(ref value)).ToDisplayString((DisplayStringOptions)0, (InputControl)null); } return "Hit : [" + text2 + "]\nDouble Down : [" + text + "]"; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2323124059u, new RpcReceiveHandler(__rpc_handler_2323124059), "DoubleDownServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2323124059(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: 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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference playerRef = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref playerRef, default(ForNetworkSerializable)); int playerIdx = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerIdx); target.__rpc_exec_stage = (__RpcExecStage)1; ((BlackjackDoubleDownFeature)(object)target).DoubleDownServerRpc(playerRef, playerIdx); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "BlackjackDoubleDownFeature"; } } public class BlackjackGameStateRpcBridge : NetworkBehaviour { private void Awake() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } [ClientRpc] public void UpdateDeckCountClientRpc(int count) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(396620961u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, count); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 396620961u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; Blackjack componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogWarning((object)"Failed to find blackjack sibling component"); return; } float yPos; if (count == 0) { LethalCasinoTweaks.Logger.LogDebug((object)"Adjusting CardDeck transform: deck is empty, resetting position"); yPos = BlackjackPatch.FInitialDeckLocalYPos; } else { LethalCasinoTweaks.Logger.LogDebug((object)$"Adjusting CardDeck transform: {count}"); yPos = BlackjackPatch.FEmptyDeckLocalYPos + (float)count * BlackjackPatch.FDeckCardYOffset; } LethalCasinoTweaks.Logger.LogDebug((object)"Adjusting CardDeck transform for shuffle"); componentInParent.SetCardDeckLocalYPosition(yPos); } [ClientRpc] public void OnShuffleClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3155747470u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3155747470u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Blackjack componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { LethalCasinoTweaks.Logger.LogWarning((object)"Failed to find blackjack sibling component"); return; } LethalCasinoTweaks.Logger.LogDebug((object)"Adjusting CardDeck transform for shuffle"); componentInParent.SetCardDeckLocalYPosition(BlackjackPatch.FInitialDeckLocalYPos); componentInParent.audioSource.PlayOneShot(Plugin.Sounds["ShuffleDeck"], 1f); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(396620961u, new RpcReceiveHandler(__rpc_handler_396620961), "UpdateDeckCountClientRpc"); ((NetworkBehaviour)this).__registerRpc(3155747470u, new RpcReceiveHandler(__rpc_handler_3155747470), "OnShuffleClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_396620961(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int count = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref count); target.__rpc_exec_stage = (__RpcExecStage)1; ((BlackjackGameStateRpcBridge)(object)target).UpdateDeckCountClientRpc(count); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3155747470(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((BlackjackGameStateRpcBridge)(object)target).OnShuffleClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "BlackjackGameStateRpcBridge"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace confusingus.LethalCasinoTweaks.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }