Decompiled source of Blackjack v0.1.0
fishjack/fishjack.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.Mono; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [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("fishjack")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("fishjack")] [assembly: AssemblyTitle("fishjack")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 Fishjack { internal enum BlackjackPhase { Idle, PlayerTurn, DealerTurn, Result } internal readonly struct Card { public readonly byte Rank; public readonly byte Suit; public string RankText { get { if (Rank == 1) { return "A"; } if (Rank == 11) { return "J"; } if (Rank == 12) { return "Q"; } if (Rank == 13) { return "K"; } return Rank.ToString(); } } public string SuitText => Suit switch { 0 => "S", 1 => "H", 2 => "D", _ => "C", }; public bool Red { get { if (Suit != 1) { return Suit == 2; } return true; } } public Card(byte rank, byte suit) { Rank = rank; Suit = suit; } } internal static class Blackjack { private const float SitRange = 6.5f; private const float LeaveRange = 22f; private const float DealerPace = 0.45f; private static readonly List<Card> Shoe = new List<Card>(312); private static readonly List<Card> PlayerHand = new List<Card>(8); private static readonly List<Card> DealerHand = new List<Card>(8); private static readonly List<Item> HandItems = new List<Item>(16); private static readonly Random Rng = new Random(); private static bool _seated; private static bool _holeHidden = true; private static bool _bDown; private static bool _hDown; private static bool _jDown; private static bool _enterDown; private static bool _cursorHeld; private static CursorLockMode _prevLock; private static bool _prevVisible = true; private static float _dealerWait; private static bool _edgeClick; internal static Vector2 MousePos; internal static bool Clicked; internal static bool IsSeated => _seated; internal static bool IsPlaying { get { if (Phase != BlackjackPhase.PlayerTurn) { return Phase == BlackjackPhase.DealerTurn; } return true; } } internal static bool BlocksRoulette => _seated; internal static bool WantsCursor => false; internal static BlackjackPhase Phase { get; private set; } = BlackjackPhase.Idle; internal static string Banner { get; private set; } = "Put items on the table."; internal static string WinText { get; private set; } = ""; internal static float WinUntil { get; private set; } internal static float ResultUntil { get; private set; } internal static bool HoleHidden => _holeHidden; internal static IReadOnlyList<Card> PlayerCards => PlayerHand; internal static IReadOnlyList<Card> DealerCards => DealerHand; internal static int PlayerScore => Score(PlayerHand); internal static int DealerScore => Score(DealerHand); internal static int BetWorth => Casino.BetWorth((HandItems.Count > 0) ? HandItems : null); internal static int BoxWorth => Casino.BetWorth(); internal static bool CanDeal { get { if (_seated && !IsPlaying && Casino.IsGameServer()) { if (Phase != BlackjackPhase.Idle) { return Phase == BlackjackPhase.Result; } return true; } return false; } } internal static bool CanHit { get { if (_seated) { return Phase == BlackjackPhase.PlayerTurn; } return false; } } internal static bool CanStand => CanHit; internal static bool NearTable() { if (BlackjackWorld.Ready) { return BlackjackWorld.DistToViewer() <= 6.5f; } return false; } internal static void Tick() { PollMouse(); PollKeys(); if (_seated && !IsPlaying) { BlackjackWorld.PushBets(); } float num = BlackjackWorld.DistToViewer(); if (_seated && num > 22f && num < 60f) { if (IsPlaying) { InstantResolve(); } Leave(); } if (Phase != BlackjackPhase.DealerTurn) { return; } _dealerWait -= Time.unscaledDeltaTime; if (_dealerWait > 0f) { return; } _holeHidden = false; if (Score(DealerHand) < 17) { DealerHand.Add(DrawCard()); _dealerWait = 0.45f; if (Score(DealerHand) > 21) { Settle(); } } else { Settle(); } } internal static void Sit() { if (!_seated && BlackjackWorld.Ready) { _seated = true; Phase = BlackjackPhase.Idle; Banner = (Casino.IsGameServer() ? "Look at Deal and press E." : "Host only. You can watch, not deal."); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack sat " + BlackjackWorld.ViewerDump())); } } } internal static void Leave() { if (_seated) { if (IsPlaying) { InstantResolve(); } _seated = false; Phase = BlackjackPhase.Idle; PlayerHand.Clear(); DealerHand.Clear(); HandItems.Clear(); Casino.SetBettingGate(value: false); ReleaseCursor(); } } internal static void Deal() { if (!_seated || IsPlaying) { return; } if (!Casino.IsGameServer()) { Banner = "Host only."; return; } if (CasinoManager.IsBetting && Phase == BlackjackPhase.Idle) { Banner = "Roulette is spinning."; return; } CaptureItems(); if (HandItems.Count == 0 || Casino.BetWorth(HandItems) <= 0) { Banner = "Put items on the round table first."; return; } EnsureShoe(); PlayerHand.Clear(); DealerHand.Clear(); _holeHidden = true; Phase = BlackjackPhase.PlayerTurn; LockItems(interactable: false); Casino.SetBettingGate(value: true); PlayerHand.Add(DrawCard()); DealerHand.Add(DrawCard()); PlayerHand.Add(DrawCard()); DealerHand.Add(DrawCard()); bool flag = IsBlackjack(PlayerHand); bool flag2 = IsBlackjack(DealerHand); if (flag || flag2) { _holeHidden = false; if (flag && flag2) { Finish(0f, "Push. Both blackjack."); } else if (flag) { Finish(2.5f, "Blackjack. 3:2"); } else { Finish(-1f, "Dealer blackjack."); } } else { Banner = "Hit or stand."; } } internal static void Hit() { if (_seated && Phase == BlackjackPhase.PlayerTurn) { PlayerHand.Add(DrawCard()); int num = Score(PlayerHand); if (num > 21) { _holeHidden = false; Finish(-1f, "Bust."); } else if (num == 21) { Stand(); } else { Banner = "Hit or stand. " + num; } } } internal static void Stand() { if (_seated && Phase == BlackjackPhase.PlayerTurn) { Phase = BlackjackPhase.DealerTurn; _dealerWait = 0.45f; Banner = "Dealer plays."; } } private static void InstantResolve() { if (IsPlaying) { _holeHidden = false; while (Score(DealerHand) < 17) { DealerHand.Add(DrawCard()); } Settle(); } } private static void Settle() { _holeHidden = false; int num = Score(PlayerHand); int num2 = Score(DealerHand); if (num2 > 21) { Finish(2f, "Dealer bust."); } else if (num > num2) { Finish(2f, "You win."); } else if (num == num2) { Finish(0f, "Push."); } else { Finish(-1f, "Dealer wins."); } } private static void Finish(float multiplier, string text) { Phase = BlackjackPhase.Result; Banner = text; _holeHidden = false; ResultUntil = Time.unscaledTime + 3f; int num = Casino.BetWorth(HandItems); if (multiplier > 1f && num > 0) { WinText = "Win: +" + Mathf.Max(1, Mathf.RoundToInt((float)num * (multiplier - 1f))); WinUntil = Time.unscaledTime + 3f; } else { WinText = ""; WinUntil = 0f; } if (multiplier > 0f) { foreach (Item handItem in HandItems) { if (!((Object)(object)handItem == (Object)null)) { handItem.ToggleInteractable(true); handItem.AddBetMultiplier(multiplier); } } Casino.RecalcWorth(won: true); Flavor(won: true, text); } else if (multiplier < 0f) { foreach (Item handItem2 in HandItems) { if (handItem2 != null) { handItem2.DestroyItem((byte)0, byte.MaxValue); } } Casino.RecalcWorth(won: false); Flavor(won: false, text); } else { foreach (Item handItem3 in HandItems) { if (handItem3 != null) { handItem3.ToggleInteractable(true); } } Casino.RecalcWorth(won: false); } Casino.SetBettingGate(value: false); HandItems.Clear(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack " + text)); } } private static void CaptureItems() { HandItems.Clear(); List<Item> list = Casino.BetItems(); if (list == null) { return; } for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { HandItems.Add(list[i]); } } } private static void LockItems(bool interactable) { for (int i = 0; i < HandItems.Count; i++) { Item obj = HandItems[i]; if (obj != null) { obj.ToggleInteractable(interactable); } } } private static void EnsureShoe() { if (Shoe.Count >= 52) { return; } Shoe.Clear(); for (int i = 0; i < 6; i++) { for (byte b = 0; b < 4; b++) { for (byte b2 = 1; b2 <= 13; b2++) { Shoe.Add(new Card(b2, b)); } } } for (int num = Shoe.Count - 1; num > 0; num--) { int index = Rng.Next(num + 1); Card value = Shoe[num]; Shoe[num] = Shoe[index]; Shoe[index] = value; } } private static Card DrawCard() { EnsureShoe(); int index = Shoe.Count - 1; Card result = Shoe[index]; Shoe.RemoveAt(index); return result; } private static int Score(List<Card> hand) { int num = 0; int num2 = 0; for (int i = 0; i < hand.Count; i++) { byte rank = hand[i].Rank; if (rank == 1) { num2++; num += 11; } else { num += ((rank >= 10) ? 10 : rank); } } while (num > 21 && num2 > 0) { num -= 10; num2--; } return num; } private static bool IsBlackjack(List<Card> hand) { if (hand.Count == 2) { return Score(hand) == 21; } return false; } private static void PollKeys() { Keyboard current = Keyboard.current; bool num = Held((current != null) ? current.bKey : null, (KeyCode)98); bool flag = Held((current != null) ? current.hKey : null, (KeyCode)104); bool flag2 = Held((current != null) ? current.jKey : null, (KeyCode)106); bool flag3 = Held((current != null) ? current.enterKey : null, (KeyCode)13) || Held((current != null) ? current.numpadEnterKey : null, (KeyCode)271); if (num && !_bDown) { if (!_seated) { Sit(); } if (_seated && !IsPlaying) { BlackjackWorld.PushBets(); } if (CanDeal) { Deal(); } else if (!_seated) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack B ignored " + BlackjackWorld.ViewerDump())); } } } if (_seated && flag && !_hDown) { Hit(); } if (_seated && flag2 && !_jDown) { Stand(); } if (_seated && flag3 && !_enterDown) { BlackjackWorld.PushBets(); Deal(); } _bDown = num; _hDown = flag; _jDown = flag2; _enterDown = flag3; } private static bool Held(KeyControl key, KeyCode code) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (key != null && ((ButtonControl)key).isPressed) { return true; } try { return Input.GetKey(code); } catch { return false; } } private static void PollMouse() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current != null) { Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); MousePos = new Vector2(val.x, (float)Screen.height - val.y); if (current.leftButton.wasPressedThisFrame) { _edgeClick = true; } } Clicked = false; } internal static void ConsumeClick(bool repaint) { Clicked = repaint && _edgeClick; if (repaint) { _edgeClick = false; } } private static void GrabCursor() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!_cursorHeld) { _prevLock = Cursor.lockState; _prevVisible = Cursor.visible; _cursorHeld = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private static void ReleaseCursor() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_cursorHeld) { Cursor.lockState = _prevLock; Cursor.visible = _prevVisible; _cursorHeld = false; } } internal static void HoldCursor() { if (_cursorHeld) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private static void Flavor(bool won, string text) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) try { LocalCasino instance = LocalCasino.Instance; if (!((Object)(object)instance == (Object)null)) { Vector3 val = ((Component)instance).transform.position + Vector3.up * 1.2f; if (won) { AudioManager.PlayClipAt("Win", val, false, (AudioDistance)2, 1f, 0.1f); ParticleManager.Play("Confetti", val, Vector3.up); } else { AudioManager.PlayClipAt("Error", val, false, (AudioDistance)1, 0.5f, 0.1f); } WorldText worldTextPrefab = GameInfo.WorldTextPrefab; if (!((Object)(object)worldTextPrefab == (Object)null)) { WorldText obj = Object.Instantiate<WorldText>(worldTextPrefab, val, Quaternion.identity); obj.SetText(text, 0.2f); obj.FloatAndRemoveAnimation(); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("fishjack flavor: " + ex.Message)); } } } } internal static class BlackjackView { internal static void Render() { } } internal static class BlackjackWorld { private static bool _loggedCards; private static bool _loggedFrame; private static int _tableLayer; private const float TableGap = 0.2f; private const float TableAlong = -0.9f; private static float _feltLocalY = 1.02f; private static readonly FieldInfo HolderField = AccessTools.Field(typeof(LocalCasino), "_rouletteTableHolder"); private static readonly FieldInfo WheelField = AccessTools.Field(typeof(LocalCasino), "_wheel"); private static GameObject _root; private static Transform _felt; private static Bounds _feltBounds; private static readonly List<GameObject> _cards = new List<GameObject>(16); private static readonly List<Item> _feltItems = new List<Item>(16); private static readonly Collider[] _hits = (Collider[])(object)new Collider[64]; private static bool _loggedPos; private static int _scanLogs; internal static bool Ready => (Object)(object)_root != (Object)null; internal static Vector3 TablePosition { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root != (Object)null)) { return Vector3.zero; } return _root.transform.position; } } internal static Vector3 FeltCenter => ((Bounds)(ref _feltBounds)).center; internal static float DistToViewer() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return float.MaxValue; } Vector3 extents = ((Bounds)(ref _feltBounds)).extents; Vector3 table = ((((Vector3)(ref extents)).sqrMagnitude > 0.01f) ? ((Bounds)(ref _feltBounds)).center : _root.transform.position); float best = float.MaxValue; Consider(ref best, table, Camera.main); Camera[] allCameras = Camera.allCameras; for (int i = 0; i < allCameras.Length; i++) { Consider(ref best, table, allCameras[i]); } Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null) { if ((Object)(object)localPlayer.CurCam != (Object)null) { Consider(ref best, table, localPlayer.CurCam); } ConsiderPos(ref best, table, ((Component)localPlayer).transform.position); if ((Object)(object)localPlayer.Transform != (Object)null) { ConsiderPos(ref best, table, localPlayer.Transform.position); } if ((Object)(object)localPlayer.CamObject != (Object)null) { ConsiderPos(ref best, table, localPlayer.CamObject.position); } if ((Object)(object)localPlayer.Rigidbody != (Object)null) { ConsiderPos(ref best, table, localPlayer.Rigidbody.position); } } return best; } internal static string ViewerDump() { //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; Camera main = Camera.main; return "table=" + ((object)TablePosition/*cast due to .constrained prefix*/).ToString() + " felt=" + ((object)((Bounds)(ref _feltBounds)).center/*cast due to .constrained prefix*/).ToString() + " dist=" + DistToViewer().ToString("0.00") + " unity=" + (((Object)(object)localPlayer != (Object)null) ? ((object)((Component)localPlayer).transform.position/*cast due to .constrained prefix*/).ToString() : "null") + " body=" + (((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Transform != (Object)null) ? ((object)localPlayer.Transform.position/*cast due to .constrained prefix*/).ToString() : "null") + " cam=" + (((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.CurCam != (Object)null) ? ((object)((Component)localPlayer.CurCam).transform.position/*cast due to .constrained prefix*/).ToString() : "null") + " main=" + (((Object)(object)main != (Object)null) ? ((object)((Component)main).transform.position/*cast due to .constrained prefix*/).ToString() : "null"); } private static void Consider(ref float best, Vector3 table, Camera cam) { //IL_000a: 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) if ((Object)(object)cam != (Object)null) { ConsiderPos(ref best, table, ((Component)cam).transform.position); } } private static void ConsiderPos(ref float best, Vector3 table, Vector3 pos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) table.y = 0f; pos.y = 0f; float num = Vector3.Distance(table, pos); if (num < best) { best = num; } } internal static void Tick() { EnsureTable(); if (!((Object)(object)_root == (Object)null)) { FollowCasino(); PushBets(); SyncCards(); TableSigns.Tick(); TablePads.Tick(); TableDealer.Tick(); } } internal static void Dispose() { for (int i = 0; i < _cards.Count; i++) { if ((Object)(object)_cards[i] != (Object)null) { Object.Destroy((Object)(object)_cards[i]); } } _cards.Clear(); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _felt = null; TableSigns.Dispose(); TablePads.Dispose(); TableDealer.Dispose(); CardPack.Dispose(); CardVisual.Dispose(); TablePack.Dispose(); } private static void EnsureTable() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) if ((Object)(object)_root != (Object)null) { return; } LocalCasino instance = LocalCasino.Instance; if ((Object)(object)instance == (Object)null) { return; } TablePack.Ensure(); if (!TablePack.Ready) { return; } Vector3 val = CasinoAnchor(instance); if (Mathf.Abs(val.y) < 0.01f) { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 position = ((Component)localPlayer).transform.position; if (HorizontalDistance(position, ((Component)instance).transform.position) > 40f) { return; } val.y = position.y; } Vector3 pos = PlacePos(instance, val); SpawnRoot(instance, pos); } private unsafe static void SpawnRoot(LocalCasino src, Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0042: 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_0058: 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_0089: Expected O, but got Unknown //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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("FishjackTable"); Object.DontDestroyOnLoad((Object)(object)_root); _tableLayer = ((Component)src).gameObject.layer; _root.layer = _tableLayer; _root.transform.SetPositionAndRotation(pos, TableYaw(src)); _root.transform.localScale = Vector3.one; MeshRenderer val = null; Bounds bounds; foreach (KeyValuePair<string, Mesh> mesh in TablePack.Meshes) { GameObject val2 = new GameObject(mesh.Key); val2.layer = _tableLayer; val2.transform.SetParent(_root.transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; val2.AddComponent<MeshFilter>().sharedMesh = mesh.Value; MeshRenderer val3 = val2.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterial = TablePack.Material; MeshCollider obj = val2.AddComponent<MeshCollider>(); obj.sharedMesh = mesh.Value; obj.convex = false; if (mesh.Key == "top") { val = val3; BoxCollider obj2 = val2.AddComponent<BoxCollider>(); bounds = mesh.Value.bounds; obj2.center = ((Bounds)(ref bounds)).center; bounds = mesh.Value.bounds; obj2.size = ((Bounds)(ref bounds)).size + new Vector3(0f, 0.04f, 0f); } } _felt = (((Object)(object)val != (Object)null) ? ((Component)val).transform : _root.transform); _feltBounds = (Bounds)(((Object)(object)val != (Object)null) ? ((Renderer)val).bounds : new Bounds(pos + Vector3.up, Vector3.one * 2f)); if ((Object)(object)val != (Object)null) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { bounds = component.sharedMesh.bounds; _feltLocalY = ((Bounds)(ref bounds)).max.y + 0.05f; } } CardVisual.Ensure(); TableSigns.Spawn(_felt, _feltLocalY); TablePads.Spawn(_felt, _feltLocalY); TableDealer.Spawn(_root.transform); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack round table at " + ((object)(*(Vector3*)(&pos))/*cast due to .constrained prefix*/).ToString() + " felt " + ((object)Unsafe.As<Bounds, Bounds>(ref _feltBounds)/*cast due to .constrained prefix*/).ToString() + " localY " + _feltLocalY)); } } private unsafe static void FollowCasino() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) LocalCasino instance = LocalCasino.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)_root == (Object)null) { return; } Vector3 anchor = CasinoAnchor(instance); Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null) { Vector3 position = ((Component)localPlayer).transform.position; if (HorizontalDistance(position, ((Component)instance).transform.position) < 25f) { anchor.y = position.y; } } Vector3 val = PlacePos(instance, anchor); Vector3 position2 = _root.transform.position; Vector3 val2 = position2 - val; if (((Vector3)(ref val2)).sqrMagnitude < 0.05f) { return; } _root.transform.SetPositionAndRotation(val, TableYaw(instance)); if (_loggedPos) { return; } _loggedPos = true; ManualLogSource log = Plugin.Log; if (log != null) { string[] obj = new string[8] { "fishjack snapped ", ((object)(*(Vector3*)(&position2))/*cast due to .constrained prefix*/).ToString(), " -> ", ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(), " casino=", null, null, null }; val2 = ((Component)instance).transform.position; obj[5] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[6] = " player="; object obj2; if (!((Object)(object)localPlayer != (Object)null)) { obj2 = "null"; } else { val2 = ((Component)localPlayer).transform.position; obj2 = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); } obj[7] = (string)obj2; log.LogInfo((object)string.Concat(obj)); } } private static Vector3 CasinoAnchor(LocalCasino src) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) object? obj = HolderField?.GetValue(src); Transform val = (Transform)((obj is Transform) ? obj : null); if ((Object)(object)val != (Object)null) { return val.position; } object? obj2 = WheelField?.GetValue(src); Transform val2 = (Transform)((obj2 is Transform) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { return val2.position; } return ((Component)src).transform.position; } private static Vector3 PlacePos(LocalCasino src, Vector3 anchor) { //IL_004d: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0099: Unknown result type (might be due to invalid IL or missing references) if (!RouletteFrame(src, out var center, out var _, out var shortAxis, out var _, out var halfShort)) { Vector3 val = Flatten(((Component)src).transform.right); return new Vector3(anchor.x, anchor.y, anchor.z) - val * 2.2f; } Vector3 val2 = center + shortAxis * (halfShort + RoundRadius() + 0.2f); Vector3 val3 = Vector3.Cross(Vector3.up, shortAxis); if (((Vector3)(ref val3)).sqrMagnitude > 0.01f) { val2 += ((Vector3)(ref val3)).normalized * -0.9f; } val2.y = anchor.y; return val2; } private static Quaternion TableYaw(LocalCasino src) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) object? obj = HolderField?.GetValue(src); Transform val = (Transform)((obj is Transform) ? obj : null); return YawOf(((Object)(object)val != (Object)null) ? val : ((Component)src).transform); } private static Quaternion YawOf(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.ProjectOnPlane(t.forward, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return Quaternion.identity; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } private static float RoundRadius() { //IL_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (TablePack.Meshes != null && TablePack.Meshes.TryGetValue("top", out var value) && (Object)(object)value != (Object)null) { Bounds bounds = value.bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = value.bounds; return Mathf.Max(x, ((Bounds)(ref bounds)).extents.z); } return 1.22f; } private static bool RouletteFrame(LocalCasino src, out Vector3 center, out Vector3 longAxis, out Vector3 shortAxis, out float halfLong, out float halfShort) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) center = ((Component)src).transform.position; longAxis = Flatten(((Component)src).transform.forward); shortAxis = Flatten(((Component)src).transform.right); halfLong = 1.6f; halfShort = 0.65f; object? obj = HolderField?.GetValue(src); Transform val = (Transform)((obj is Transform) ? obj : null); object? obj2 = WheelField?.GetValue(src); Transform val2 = (Transform)((obj2 is Transform) ? obj2 : null); Transform obj3 = (((Object)(object)val != (Object)null) ? val : ((Component)src).transform); Vector3 position = obj3.position; Vector3 val3 = Flatten(obj3.right); Vector3 val4 = Flatten(obj3.forward); float minR = float.MaxValue; float maxR = float.MinValue; float minF = float.MaxValue; float maxF = float.MinValue; bool flag = false; MeshRenderer[] componentsInChildren = ((Component)obj3).GetComponentsInChildren<MeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Bounds bounds = ((Renderer)componentsInChildren[i]).bounds; float num = ((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.z; if (!(num < 0.04f) && !(num > 40f) && !(((Bounds)(ref bounds)).size.y > 6f)) { EncapsulateXz(bounds, position, val3, val4, ref minR, ref maxR, ref minF, ref maxF); flag = true; } } float num2 = 0.65f; float num3 = 1.6f; Vector3 val6; if (flag) { center = position + val3 * ((minR + maxR) * 0.5f) + val4 * ((minF + maxF) * 0.5f); num2 = (maxR - minR) * 0.5f; num3 = (maxF - minF) * 0.5f; if (num2 >= num3) { longAxis = val3; shortAxis = val4; halfLong = num2; halfShort = num3; } else { longAxis = val4; shortAxis = val3; halfLong = num3; halfShort = num2; } } else if ((Object)(object)val2 != (Object)null) { Vector3 val5 = Flatten(val2.position - position); if (((Vector3)(ref val5)).sqrMagnitude > 0.01f) { longAxis = val5; } val6 = Vector3.Cross(Vector3.up, longAxis); shortAxis = ((Vector3)(ref val6)).normalized; center = position; } if ((Object)(object)val2 != (Object)null) { Vector3 val7 = Flatten(val2.position - center); if (((Vector3)(ref val7)).sqrMagnitude > 0.01f) { longAxis = val7; } val6 = Vector3.Cross(Vector3.up, longAxis); shortAxis = ((Vector3)(ref val6)).normalized; } halfShort = Mathf.Abs(Vector3.Dot(shortAxis, val3)) * num2 + Mathf.Abs(Vector3.Dot(shortAxis, val4)) * num3; halfShort = Mathf.Clamp(halfShort, 0.45f, 1.4f); center.y = position.y; if (!_loggedFrame) { _loggedFrame = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack roulette center " + ((object)Unsafe.As<Vector3, Vector3>(ref center)/*cast due to .constrained prefix*/).ToString() + " long " + halfLong.ToString("0.00") + " short " + halfShort.ToString("0.00") + " side " + ((object)Unsafe.As<Vector3, Vector3>(ref shortAxis)/*cast due to .constrained prefix*/).ToString())); } } return true; } private static void EncapsulateXz(Bounds b, Vector3 origin, Vector3 right, Vector3 fwd, ref float minR, ref float maxR, ref float minF, ref float maxF) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref b)).center; Vector3 extents = ((Bounds)(ref b)).extents; float x = origin.x; float z = origin.z; for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { float num = center.x + (float)i * extents.x - x; float num2 = center.z + (float)j * extents.z - z; float num3 = num * right.x + num2 * right.z; float num4 = num * fwd.x + num2 * fwd.z; if (num3 < minR) { minR = num3; } if (num3 > maxR) { maxR = num3; } if (num4 < minF) { minF = num4; } if (num4 > maxF) { maxF = num4; } } } } private static float HorizontalDistance(Vector3 a, Vector3 b) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) a.y = 0f; b.y = 0f; return Vector3.Distance(a, b); } internal unsafe static void PushBets() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_felt == (Object)null || Blackjack.IsPlaying) { return; } _feltItems.Clear(); Vector3 val = ((Bounds)(ref _feltBounds)).center + Vector3.up * 0.35f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_felt != (Object)null) { val = _felt.position + Vector3.up * 1.1f; } int num = -1; try { num = LayerMask.op_Implicit(GameInfo.ItemLayer) | LayerMask.op_Implicit(GameInfo.ItemAndInHandLayer) | LayerMask.op_Implicit(GameInfo.InteractableLayer); if (num == 0) { num = -1; } } catch { num = -1; } int num2 = Physics.OverlapSphereNonAlloc(val, 1.55f, _hits, num, (QueryTriggerInteraction)2); for (int i = 0; i < num2; i++) { Collider val2 = _hits[i]; if (!((Object)(object)val2 == (Object)null)) { Item val3 = ItemManager.Get(val2); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)val2).GetComponentInParent<Item>(); } if (!((Object)(object)val3 == (Object)null) && !_feltItems.Contains(val3) && !((Object)(object)val3.DeadPlayer != (Object)null) && (!((Object)(object)val3.Creature != (Object)null) || val3.Creature.IsDead)) { _feltItems.Add(val3); } } } if (Blackjack.IsSeated) { Casino.SetBetItems(_feltItems); } if (_scanLogs < 4) { _scanLogs++; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack felt hits " + num2 + " items " + _feltItems.Count + " at " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString() + " seated=" + Blackjack.IsSeated)); } } } private static void SyncCards() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_felt == (Object)null) { return; } MeshRenderer component = ((Component)_felt).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { _feltBounds = ((Renderer)component).bounds; } IReadOnlyList<Card> dealerCards = Blackjack.DealerCards; IReadOnlyList<Card> playerCards = Blackjack.PlayerCards; int num = dealerCards.Count + playerCards.Count; EnsurePool(Mathf.Max(num, 8)); int num2 = 0; if (num > 0) { num2 += PlaceRow(dealerCards, dealer: true, Blackjack.HoleHidden, num2); num2 += PlaceRow(playerCards, dealer: false, hideHole: false, num2); } else { num2 += PlaceDeck(3, num2); } for (int i = num2; i < _cards.Count; i++) { if (_cards[i].activeSelf) { _cards[i].SetActive(false); } } } private static int PlaceRow(IReadOnlyList<Card> hand, bool dealer, bool hideHole, int slot) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_008f: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (hand.Count == 0) { return 0; } Vector3 val = Flatten(_root.transform.right); Vector3 val2 = FeltOrigin(Flatten(_root.transform.forward) * (dealer ? 0.82f : (-0.42f))); float num = 0.14f; float num2 = (float)(-(hand.Count - 1)) * 0.5f * num; for (int i = 0; i < hand.Count; i++) { bool hidden = hideHole && i == 1; GameObject go = _cards[slot + i]; Vector3 worldPos = val2 + val * (num2 + (float)i * num); PlaceCard(go, worldPos, hand[i], hidden); } return hand.Count; } private static int PlaceDeck(int count, int slot) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) Vector3 val = FeltOrigin(Flatten(_root.transform.forward) * 0.82f); CardVisual.Ensure(); for (int i = 0; i < count; i++) { PlaceCard(_cards[slot + i], val + Vector3.up * ((float)i * 0.004f), new Card(1, 0), hidden: true); } return count; } private static void PlaceCard(GameObject go, Vector3 worldPos, Card card, bool hidden) { //IL_0039: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) CardVisual.Ensure(); go.SetActive(true); Transform val = (((Object)(object)_felt != (Object)null) ? _felt : _root.transform); go.transform.SetParent(val, false); Vector3 localPosition = val.InverseTransformPoint(worldPos); localPosition.y = _feltLocalY; go.transform.localPosition = localPosition; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; go.GetComponent<MeshFilter>().sharedMesh = CardVisual.Quad; MeshRenderer component = go.GetComponent<MeshRenderer>(); ((Renderer)component).enabled = true; ((Renderer)component).sharedMaterial = CardVisual.For(card, hidden); if (!_loggedCards) { _loggedCards = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack card world " + ((object)go.transform.position/*cast due to .constrained prefix*/).ToString() + " local " + ((object)go.transform.localPosition/*cast due to .constrained prefix*/).ToString())); } } } private static Vector3 FeltOrigin(Vector3 depth) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Bounds)(ref _feltBounds)).center + depth; result.y = ((Bounds)(ref _feltBounds)).max.y + 0.06f; return result; } private static Vector3 Flatten(Vector3 v) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) v.y = 0f; if (!(((Vector3)(ref v)).sqrMagnitude < 0.0001f)) { return ((Vector3)(ref v)).normalized; } return Vector3.forward; } private static void EnsurePool(int count) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown while (_cards.Count < count) { GameObject val = new GameObject("FishjackCard" + _cards.Count); val.transform.SetParent(_root.transform, false); val.AddComponent<MeshFilter>(); MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = CardVisual.For(new Card(1, 0), hidden: true); ((Renderer)obj).enabled = true; val.layer = _tableLayer; val.SetActive(false); _cards.Add(val); } } } internal static class CardPack { internal static Dictionary<string, Mesh> Meshes; internal static Material Material; internal static bool Ready; internal static void Ensure() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (Ready) { return; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(directoryName, "playingCards.ncm"); string path2 = Path.Combine(directoryName, "playingCards.png"); if (!File.Exists(path) || !File.Exists(path2)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("fishjack missing card assets in " + directoryName)); } return; } Meshes = MeshPack.LoadNcm(File.ReadAllBytes(path)); Material = MeshPack.MakeUnlit(MeshPack.LoadPng(File.ReadAllBytes(path2), "fishjack.cards"), Color.white); Ready = Meshes != null && Meshes.Count > 0 && (Object)(object)Material != (Object)null; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("fishjack cards " + ((Meshes != null) ? Meshes.Count : 0) + " meshes")); } } internal static Mesh ForCard(Card card) { Ensure(); if (Meshes == null) { return null; } string key = SuitName(card.Suit) + card.Rank.ToString("00"); Meshes.TryGetValue(key, out var value); return value; } internal static void Dispose() { MeshPack.DestroyMeshes(Meshes); Meshes = null; if ((Object)(object)Material != (Object)null) { Object.Destroy((Object)(object)Material); } Material = null; Ready = false; } private static string SuitName(byte suit) { return suit switch { 0 => "spades", 1 => "hearts", 2 => "diamonds", _ => "clubs", }; } } internal static class CardVisual { private static Material[] _faces; private static Material _back; private static Mesh _quad; private static bool _ready; internal static Mesh Quad { get { Ensure(); return _quad; } } internal static Material For(Card card, bool hidden) { Ensure(); if (hidden || _faces == null) { return _back; } int num = card.Suit * 13 + (card.Rank - 1); if (num < 0 || num >= _faces.Length) { return _back; } return _faces[num]; } internal static void Ensure() { if (_ready) { return; } if ((Object)(object)TablePack.Material == (Object)null) { TablePack.Ensure(); } if ((Object)(object)TablePack.Material == (Object)null) { return; } _quad = MakeQuad(0.11f, 0.16f); _back = MakeMat(PaintBack(), "fishjack.back"); _faces = (Material[])(object)new Material[52]; for (byte b = 0; b < 4; b++) { for (byte b2 = 1; b2 <= 13; b2++) { _faces[b * 13 + (b2 - 1)] = MakeMat(PaintFace(new Card(b2, b)), "fishjack.face"); } } _ready = true; } internal static void Dispose() { if (_faces != null) { for (int i = 0; i < _faces.Length; i++) { DestroyMat(ref _faces[i]); } } _faces = null; DestroyMat(ref _back); if ((Object)(object)_quad != (Object)null) { Object.Destroy((Object)(object)_quad); } _quad = null; _ready = false; } private static Mesh MakeQuad(float w, float h) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0187: Unknown result type (might be due to invalid IL or missing references) float num = w * 0.5f; float num2 = h * 0.5f; Mesh val = new Mesh { name = "fishjack.quad", hideFlags = (HideFlags)61 }; val.vertices = (Vector3[])(object)new Vector3[8] { new Vector3(0f - num, 0f, 0f - num2), new Vector3(num, 0f, 0f - num2), new Vector3(0f - num, 0f, num2), new Vector3(num, 0f, num2), new Vector3(0f - num, 0.001f, 0f - num2), new Vector3(0f - num, 0.001f, num2), new Vector3(num, 0.001f, 0f - num2), new Vector3(num, 0.001f, num2) }; val.uv = (Vector2[])(object)new Vector2[8] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(1f, 0f), new Vector2(1f, 1f) }; val.triangles = new int[12] { 0, 2, 1, 2, 3, 1, 4, 6, 5, 5, 6, 7 }; val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static Material MakeMat(Texture2D tex, string name) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(TablePack.Material) { name = name, hideFlags = (HideFlags)61 }; val.mainTexture = (Texture)(object)tex; if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)tex); } if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)tex); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } if (val.HasProperty("_Color")) { val.color = Color.white; } return val; } private static Texture2D PaintFace(Card card) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0071: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00e3: Unknown result type (might be due to invalid IL or missing references) Texture2D obj = NewTex(96, 140); Fill(obj, new Color(0.96f, 0.95f, 0.9f, 1f)); RectPx(obj, 0, 0, 96, 140, new Color(0.12f, 0.12f, 0.12f, 1f), 3); Color ink = (card.Red ? new Color(0.78f, 0.12f, 0.14f, 1f) : new Color(0.1f, 0.1f, 0.12f, 1f)); DrawText(obj, 7, 8, card.RankText, ink, 3); DrawSuit(obj, 10, 36, card.Suit, ink, 16); DrawSuit(obj, 30, 54, card.Suit, ink, 36); DrawText(obj, 88 - TextWidth(card.RankText, 3), 110, card.RankText, ink, 3); obj.Apply(false, false); return obj; } private static Texture2D PaintBack() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_00ad: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewTex(96, 140); Fill(val, new Color(0.42f, 0.1f, 0.14f, 1f)); RectPx(val, 0, 0, 96, 140, new Color(0.82f, 0.64f, 0.22f, 1f), 4); RectPx(val, 8, 10, 80, 120, new Color(0.55f, 0.14f, 0.18f, 1f), 2); Color c = default(Color); ((Color)(ref c))..ctor(0.72f, 0.22f, 0.24f, 1f); for (int i = 18; i < 122; i += 10) { for (int j = 16; j < 80; j += 10) { Plot(val, j + ((i / 10) & 1) * 5, i, c); } } val.Apply(false, false); return val; } private static Texture2D NewTex(int w, int h) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new Texture2D(w, h, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; } private static void Fill(Texture2D tex, Color c) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) int num = ((Texture)tex).width * ((Texture)tex).height; Color[] array = (Color[])(object)new Color[num]; for (int i = 0; i < num; i++) { array[i] = c; } tex.SetPixels(array); } private static void RectPx(Texture2D tex, int x, int y, int w, int h, Color c, int t) { //IL_000f: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < w; i++) { for (int j = 0; j < t; j++) { Plot(tex, x + i, y + j, c); Plot(tex, x + i, y + h - 1 - j, c); } } for (int k = 0; k < h; k++) { for (int l = 0; l < t; l++) { Plot(tex, x + l, y + k, c); Plot(tex, x + w - 1 - l, y + k, c); } } } private static void DrawSuit(Texture2D tex, int x, int y, byte suit, Color ink, int size) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(8, size); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float u = ((float)j + 0.5f) / (float)num * 2f - 1f; float v = ((float)i + 0.5f) / (float)num * 2f - 1f; if (InSuit(suit, u, v)) { Plot(tex, x + j, y + i, ink); } } } } private static bool InSuit(byte suit, float u, float v) { return suit switch { 1 => Heart(u, 0f - v), 2 => Mathf.Abs(u) + Mathf.Abs(v) < 0.92f, 3 => Club(u, 0f - v), _ => Spade(u, 0f - v), }; } private static bool Heart(float u, float v) { u *= 1.15f; v = v * 1.15f + 0.1f; if (!(u * u + (v - 0.25f) * (v - 0.25f) < 0.45f) || (!(v > -0.15f) && !(Mathf.Abs(u) < (v + 0.95f) * 0.55f))) { if (v < 0.1f) { return Mathf.Abs(u) < 0.55f - v * 0.7f; } return false; } return true; } private static bool Spade(float u, float v) { if (v < -0.35f && Mathf.Abs(u) < 0.12f && v > -0.95f) { return true; } if (v < -0.55f && Mathf.Abs(u) < 0.32f + v * 0.15f) { return true; } return Heart(u, (0f - v) * 0.92f - 0.05f); } private static bool Club(float u, float v) { if (v < -0.4f && Mathf.Abs(u) < 0.12f && v > -0.95f) { return true; } bool num = u * u + (v - 0.28f) * (v - 0.28f) < 0.2f; bool flag = (u - 0.38f) * (u - 0.38f) + (v + 0.08f) * (v + 0.08f) < 0.18f; bool flag2 = (u + 0.38f) * (u + 0.38f) + (v + 0.08f) * (v + 0.08f) < 0.18f; return num || flag || flag2; } private static void DrawText(Texture2D tex, int x, int y, string text, Color ink, int scale) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) int num = x; for (int i = 0; i < text.Length; i++) { DrawGlyph(tex, num, y, text[i], ink, scale); num += 4 * scale; } } private static void DrawGlyph(Texture2D tex, int x, int y, char ch, Color ink, int scale) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) string[] array = Glyph(ch); if (array == null) { return; } for (int i = 0; i < array.Length; i++) { string text = array[i]; for (int j = 0; j < text.Length; j++) { if (text[j] != '#') { continue; } for (int k = 0; k < scale; k++) { for (int l = 0; l < scale; l++) { Plot(tex, x + j * scale + l, y + i * scale + k, ink); } } } } } private static string[] Glyph(char ch) { return ch switch { 'A' => new string[5] { ".#.", "#.#", "###", "#.#", "#.#" }, '2' => new string[5] { "###", "..#", "###", "#..", "###" }, '3' => new string[5] { "###", "..#", "###", "..#", "###" }, '4' => new string[5] { "#.#", "#.#", "###", "..#", "..#" }, '5' => new string[5] { "###", "#..", "###", "..#", "###" }, '6' => new string[5] { "###", "#..", "###", "#.#", "###" }, '7' => new string[5] { "###", "..#", "..#", "..#", "..#" }, '8' => new string[5] { "###", "#.#", "###", "#.#", "###" }, '9' => new string[5] { "###", "#.#", "###", "..#", "###" }, '0' => new string[5] { "###", "#.#", "#.#", "#.#", "###" }, '1' => new string[5] { ".#.", "##.", ".#.", ".#.", "###" }, 'J' => new string[5] { "###", "..#", "..#", "#.#", "###" }, 'Q' => new string[5] { "###", "#.#", "#.#", "###", "..#" }, 'K' => new string[5] { "#.#", "#.#", "##.", "#.#", "#.#" }, _ => null, }; } private static int TextWidth(string text, int scale) { return text.Length * 4 * scale; } private static void Plot(Texture2D tex, int x, int y, Color c) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((uint)x < (uint)((Texture)tex).width && (uint)y < (uint)((Texture)tex).height) { tex.SetPixel(x, ((Texture)tex).height - 1 - y, c); } } private static void DestroyMat(ref Material mat) { if ((Object)(object)mat != (Object)null) { if ((Object)(object)mat.mainTexture != (Object)null) { Object.Destroy((Object)(object)mat.mainTexture); } Object.Destroy((Object)(object)mat); } mat = null; } } internal static class Casino { private static readonly FieldInfo ItemsField = AccessTools.Field(typeof(CasinoManager), "_itemsToBet"); private static readonly MethodInfo SetItemsMethod = AccessTools.Method(typeof(CasinoManager), "SetBetItems", (Type[])null, (Type[])null); private static readonly MethodInfo CalculateWorth = AccessTools.Method(typeof(CasinoManager), "CalculateWorth", (Type[])null, (Type[])null); private static readonly MethodInfo SetIsBetting = AccessTools.PropertySetter(typeof(CasinoManager), "IsBetting"); internal static void Apply(Harmony harmony) { Patch(harmony, AccessTools.Method(typeof(CasinoBox), "FixedUpdate", (Type[])null, (Type[])null), "BoxPrefix"); Patch(harmony, AccessTools.Method(typeof(CasinoManager), "ServerStartBet", (Type[])null, (Type[])null), "StartPrefix"); } private static void Patch(Harmony harmony, MethodInfo method, string prefix) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (method == null) { Plugin.Log.LogError((object)("casino missing " + prefix)); return; } harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(Casino), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Log.LogInfo((object)("casino patched " + method.DeclaringType.Name + "." + method.Name)); } internal static bool IsGameServer() { Server instance = Server.Instance; if ((Object)(object)instance != (Object)null && ((NetworkBehaviour)instance).IsServerInitialized) { return true; } CasinoManager instance2 = CasinoManager.Instance; if ((Object)(object)instance2 != (Object)null) { return ((NetworkBehaviour)instance2).IsServerInitialized; } return false; } private static bool BoxPrefix() { return !Blackjack.IsSeated; } private static bool StartPrefix() { return !Blackjack.BlocksRoulette; } internal static List<Item> BetItems() { return ItemsField?.GetValue(null) as List<Item>; } internal static void SetBetItems(List<Item> items) { items = items ?? new List<Item>(); if (!(SetItemsMethod == null)) { if (SetItemsMethod.IsStatic) { SetItemsMethod.Invoke(null, new object[1] { items }); } else { SetItemsMethod.Invoke(CasinoManager.Instance, new object[1] { items }); } } } internal static int BetWorth(List<Item> items = null) { items = items ?? BetItems(); if (items == null) { return 0; } int num = 0; for (int i = 0; i < items.Count; i++) { if ((Object)(object)items[i] != (Object)null) { num += items[i].TotalWorth; } } return num; } internal static void SetBettingGate(bool value) { SetIsBetting?.Invoke(null, new object[1] { value }); } internal static void RecalcWorth(bool won) { CalculateWorth?.Invoke(null, new object[1] { won }); } } internal static class MeshPack { internal static Dictionary<string, Mesh> LoadNcm(byte[] bytes) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_016f: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown if (bytes == null || bytes.Length < 12 || Encoding.ASCII.GetString(bytes, 0, 6) != "NCARD1") { throw new InvalidDataException("bad mesh pack"); } Dictionary<string, Mesh> dictionary = new Dictionary<string, Mesh>(8); using MemoryStream input = new MemoryStream(bytes, 7, bytes.Length - 7, writable: false); using BinaryReader binaryReader = new BinaryReader(input); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { ushort count = binaryReader.ReadUInt16(); string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(count)); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; for (int j = 0; j < num2; j++) { float num4 = binaryReader.ReadSingle(); float num5 = binaryReader.ReadSingle(); float num6 = binaryReader.ReadSingle(); array[j] = new Vector3(0f - num4, num5, num6); } Vector2[] array2 = (Vector2[])(object)new Vector2[num2]; for (int k = 0; k < num2; k++) { array2[k] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array3 = new int[num3 * 2]; for (int l = 0; l < num3; l += 3) { int num7 = binaryReader.ReadInt32(); int num8 = binaryReader.ReadInt32(); int num9 = binaryReader.ReadInt32(); array3[l] = num7; array3[l + 1] = num8; array3[l + 2] = num9; array3[num3 + l] = num7; array3[num3 + l + 1] = num9; array3[num3 + l + 2] = num8; } Mesh val = new Mesh { name = "fishjack." + text, hideFlags = (HideFlags)61 }; val.vertices = array; val.uv = array2; val.triangles = array3; val.RecalculateNormals(); val.RecalculateBounds(); dictionary[text] = val; } return dictionary; } internal static Texture2D LoadPng(byte[] bytes, string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) //IL_002e: Expected O, but got Unknown //IL_0030: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = name, hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; ImageConversion.LoadImage(val, bytes, false); return val; } internal static Material MakeUnlit(Texture2D albedo, Color color) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Unlit/Texture") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Unlit/Transparent") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { return null; } Material val2 = new Material(val) { name = "fishjack.unlit", hideFlags = (HideFlags)61, renderQueue = 2000 }; if ((Object)(object)albedo != (Object)null) { val2.mainTexture = (Texture)(object)albedo; if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)albedo); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)albedo); } } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", color); } if (val2.HasProperty("_Color")) { val2.color = color; } if (val2.HasProperty("_Cull")) { val2.SetInt("_Cull", 0); } if (val2.HasProperty("_Surface")) { val2.SetFloat("_Surface", 0f); } if (val2.HasProperty("_Cutoff")) { val2.SetFloat("_Cutoff", 0f); } val2.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); val2.DisableKeyword("_ALPHATEST_ON"); val2.SetOverrideTag("RenderType", "Opaque"); val2.EnableKeyword("_RECEIVE_SHADOWS_OFF"); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("fishjack shader " + ((Object)val).name)); } return val2; } internal static void DestroyMeshes(Dictionary<string, Mesh> meshes) { if (meshes == null) { return; } foreach (Mesh value in meshes.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } meshes.Clear(); } } [BepInPlugin("fishjack.howtofish", "fishjack", "0.1.0")] [BepInProcess("How to Fish.exe")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "fishjack.howtofish"; public const string PluginName = "fishjack"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("fishjack.howtofish"); Casino.Apply(_harmony); Log.LogInfo((object)"fishjack loaded"); } private void Update() { BlackjackWorld.Tick(); Blackjack.Tick(); } private void OnGUI() { BlackjackView.Render(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } BlackjackWorld.Dispose(); } } internal static class TableDealer { private const byte CloneId = 253; private const float HueSpeed = 0.42f; private static readonly FieldRef<NPC, byte> NpcId = AccessTools.FieldRefAccess<NPC, byte>("_id"); private static readonly FieldRef<NPC, bool> ForShot = AccessTools.FieldRefAccess<NPC, bool>("_forScreenshot"); private static readonly FieldRef<PlayerUI, NpcUI> PlayerNpcUi = AccessTools.FieldRefAccess<PlayerUI, NpcUI>("_npcUI"); private static readonly FieldRef<NpcUI, TextMeshProUGUI> NpcTmp = AccessTools.FieldRefAccess<NpcUI, TextMeshProUGUI>("_npcText"); private static readonly FieldRef<NpcUI, Transform> NpcTarget = AccessTools.FieldRefAccess<NpcUI, Transform>("_npcTarget"); private static readonly FieldInfo PlayerUiInst = AccessTools.Field(typeof(PlayerUI), "_instance"); private static GameObject _npc; private static Transform _talkTarget; private static Transform _table; private static int _line = -1; private static bool _talking; private static float _hue; private static int _tries; private static readonly StringBuilder _sb = new StringBuilder(256); internal static void Spawn(Transform table) { Dispose(); _table = table; TryClone(); } internal static void Tick() { if ((Object)(object)_table == (Object)null) { return; } if ((Object)(object)_npc == (Object)null && _tries < 180) { _tries++; TryClone(); } if (!_talking || (Object)(object)_npc == (Object)null) { return; } if (!NpcUI.NPCDialougeOpen) { _talking = false; } else { if (_line != 0 && _line != 2) { return; } NpcUI val = Ui(); if ((Object)(object)val == (Object)null || (Object)(object)NpcTarget.Invoke(val) != (Object)(object)_talkTarget) { _talking = false; return; } _hue += Time.unscaledDeltaTime * 0.42f; TextMeshProUGUI val2 = NpcTmp.Invoke(val); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)val2).text = Build(_line, _hue); } } } internal static void Dispose() { _talking = false; _line = -1; _tries = 0; _talkTarget = null; _table = null; if ((Object)(object)_npc != (Object)null) { Object.Destroy((Object)(object)_npc); } _npc = null; } private static void TryClone() { //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_npc != (Object)null || (Object)(object)_table == (Object)null) { return; } NPC val = FindSource(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = null; try { val2 = Object.Instantiate<GameObject>(((Component)val).gameObject); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("fishjack dealer clone failed: " + ex.Message)); } return; } ((Object)val2).name = "FishjackDealer"; StripNetwork(val2); NPC component = val2.GetComponent<NPC>(); if ((Object)(object)component != (Object)null) { NpcId.Invoke(component) = 253; Object.Destroy((Object)(object)component); } Interactable[] componentsInChildren = val2.GetComponentsInChildren<Interactable>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } val2.transform.SetParent(_table, false); val2.transform.localPosition = new Vector3(0f, 0f, 1.38f); val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); val2.transform.localScale = ((Component)val).transform.lossyScale; CapsuleCollider obj = val2.AddComponent<CapsuleCollider>(); obj.center = new Vector3(0f, 0.9f, 0f); obj.radius = 0.28f; obj.height = 1.8f; obj.direction = 1; ((Collider)obj).enabled = true; _talkTarget = new GameObject("TalkTarget").transform; _talkTarget.SetParent(val2.transform, false); _talkTarget.localPosition = HeadLocal(val2); GameObject val3 = new GameObject("Talk"); val3.SetActive(false); val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = new Vector3(0f, 0.95f, 0.12f); try { val3.tag = "Interactable"; } catch { } CapsuleCollider val4 = val3.AddComponent<CapsuleCollider>(); val4.center = Vector3.zero; val4.radius = 0.45f; val4.height = 1.9f; val4.direction = 1; FishjackButton fishjackButton = val3.AddComponent<FishjackButton>(); fishjackButton.Prompt = "Talk"; fishjackButton.CanUse = () => true; fishjackButton.Use = Speak; TablePads.Bind(fishjackButton, (Collider)(object)val4); val3.SetActive(true); ((Interactable)fishjackButton).ToggleIsInteractable(true); _npc = val2; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("fishjack dealer from " + ((Object)val).name + " at " + ((object)val2.transform.position/*cast due to .constrained prefix*/).ToString())); } } private static void Speak() { _line = (_line + 1) % 3; _hue = 0f; _talking = true; Transform val = (((Object)(object)_talkTarget != (Object)null) ? _talkTarget : _npc.transform); PlayerUI.SetNpcText(Build(_line, _hue), val); } private static string Build(int line, float t) { return line switch { 0 => "hey. wanna " + Rainbow("gamble", t) + "?", 1 => "put any item on the desk, then hit the \"Deal\" button.", _ => "i hope you know " + Rainbow("blackjack", t) + " rules, i'm too lazy to explain them.", }; } private static string Rainbow(string word, float t) { //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_0042: Unknown result type (might be due to invalid IL or missing references) _sb.Length = 0; for (int i = 0; i < word.Length; i++) { Color val = Color.HSVToRGB(Mathf.Repeat(t + (float)i * 0.12f, 1f), 0.9f, 1f); _sb.Append("<color=#").Append(ColorUtility.ToHtmlStringRGB(val)).Append('>') .Append(word[i]) .Append("</color>"); } return _sb.ToString(); } private static NPC FindSource() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) NPC[] array; try { array = Object.FindObjectsByType<NPC>(); } catch { return null; } if (array == null || array.Length == 0) { return null; } Vector3 val = Origin(); NPC result = null; float num = 90f; foreach (NPC val2 in array) { if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy || ((Object)((Component)val2).gameObject).name.StartsWith("Fishjack")) { continue; } try { if (ForShot.Invoke(val2)) { continue; } } catch { } Vector3 position = ((Component)val2).transform.position; float num2 = position.x - val.x; float num3 = position.z - val.z; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("casino") || text.Contains("dealer") || text.Contains("suit") || text.Contains("bar") || text.Contains("gamble")) { num4 -= 20f; } if (num4 < num) { num = num4; result = val2; } } return result; } private static Vector3 Origin() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) LocalCasino instance = LocalCasino.Instance; if ((Object)(object)instance != (Object)null) { return ((Component)instance).transform.position; } if (!((Object)(object)_table != (Object)null)) { return Vector3.zero; } return _table.position; } private static Vector3 HeadLocal(GameObject clone) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Transform val = null; Transform[] componentsInChildren = clone.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { string text = ((Object)componentsInChildren[i]).name.ToLowerInvariant(); if (text.Contains("head") && !text.Contains("bead") && !text.Contains("ahead")) { val = componentsInChildren[i]; break; } } if ((Object)(object)val == (Object)null) { return new Vector3(0f, 1.72f, 0f); } Vector3 result = clone.transform.InverseTransformPoint(val.position); result.y += 0.18f; return result; } private static void StripNetwork(GameObject clone) { Type type = AccessTools.TypeByName("FishNet.Object.NetworkObject"); if (type != null) { Component[] componentsInChildren = clone.GetComponentsInChildren(type, true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } } Type type2 = AccessTools.TypeByName("FishNet.Object.NetworkBehaviour"); if (!(type2 == null)) { Component[] componentsInChildren = clone.GetComponentsInChildren(type2, true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } } } private static NpcUI Ui() { PlayerUI val = (PlayerUI)((PlayerUiInst != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val != (Object)null)) { return null; } return PlayerNpcUi.Invoke(val); } } internal static class TablePack { internal static Dictionary<string, Mesh> Meshes; internal static Material Material; internal static bool Ready; internal static void Ensure() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Ready) { return; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(directoryName, "roundTable.ncm"); if (!File.Exists(path)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)"fishjack missing roundTable.ncm"); } return; } Meshes = MeshPack.LoadNcm(File.ReadAllBytes(path)); Texture2D albedo = null; string path2 = Path.Combine(directoryName, "table.png"); if (File.Exists(path2)) { albedo = MeshPa