Decompiled source of LeCruik v1.0.0

QuotaJackpot.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("QuotaJackpot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuotaJackpot")]
[assembly: AssemblyTitle("QuotaJackpot")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuotaJackpotMod
{
	[BepInPlugin("markj.quotajackpot", "LeCruik", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "markj.quotajackpot";

		public const string Name = "LeCruik";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigFile Cfg;

		internal static ConfigEntry<string> Bets;

		internal static ConfigEntry<int> SkullDamage;

		internal static ConfigEntry<int> JackpotSeed;

		internal static ConfigEntry<float> JackpotShare;

		internal static ConfigEntry<int> JackpotKeys;

		internal static ConfigEntry<int> JackpotPot;

		internal static ConfigEntry<float> MachineScale;

		internal static ConfigEntry<string> SpinKey;

		internal static ConfigEntry<string> BetKey;

		internal static ConfigEntry<string> MoveKey;

		internal static ConfigEntry<string> Placement;

		private void Awake()
		{
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Cfg = ((BaseUnityPlugin)this).Config;
			Bets = ((BaseUnityPlugin)this).Config.Bind<string>("Gameplay", "BetAmounts", "10,25,50,100", "Bet sizes you can cycle through with the bet key. (Host's setting counts.)");
			SkullDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "SkullZapDamage", 25, "Damage you take when 5+ dynamite touch and blow up. 0 = no damage.");
			JackpotSeed = ((BaseUnityPlugin)this).Config.Bind<int>("Jackpot", "StartingPot", 500, "What the jackpot resets to after someone wins it. (Host's setting counts.)");
			JackpotShare = ((BaseUnityPlugin)this).Config.Bind<float>("Jackpot", "ShareOfEachBet", 0.05f, "Share of every bet added to the jackpot (0.05 = 5%). (Host's setting counts.)");
			JackpotKeys = ((BaseUnityPlugin)this).Config.Bind<int>("Jackpot", "GoldKeysNeeded", 7, "Gold keys anywhere on the starting board needed to win the jackpot. 7 is about 1 in 900 spins, 8 about 1 in 5300.");
			JackpotPot = ((BaseUnityPlugin)this).Config.Bind<int>("Jackpot", "CurrentPot", 0, "The jackpot right now. The host's game keeps this up to date, so it carries over between sessions.");
			MachineScale = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "MachineSize", 1f, "Size of the machine. Lower it (e.g. 0.9) if it pokes through the ship's ceiling.");
			SpinKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "PullLeverKey", "E", "Key to spin while looking at the machine.");
			BetKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "ChangeBetKey", "B", "Key to change your bet while looking at the machine.");
			MoveKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "MoveMachineKey", "F8", "HOST ONLY: press while standing in the ship to move the machine in front of you.");
			Placement = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "ShipPosition", "", "Where the machine stands in the ship (set automatically, or by the host's move key). Leave empty for automatic.");
			new Harmony("markj.quotajackpot").PatchAll(typeof(Patches));
			Log.LogInfo((object)"LeCruik 1.0.0 loaded.");
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartOfRoundStart(StartOfRound __instance)
		{
			try
			{
				SlotMachine.Spawn(__instance);
				SlotNet.Register();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Couldn't set up the slot machine: " + ex));
			}
		}
	}
	public class SlotMachine : MonoBehaviour
	{
		public static SlotMachine Instance;

		private const float UseDistance = 2.6f;

		private Transform _ship;

		private BoxCollider _collider;

		private AudioSource _audio;

		private Transform _leverPivot;

		private readonly List<Renderer> _lights = new List<Renderer>();

		private Renderer _spinButton;

		private Renderer _plate;

		private Transform _screenRoot;

		private Vector3 _buttonRest;

		private Image _pip;

		private TMP_Text _bubbleText;

		private GameObject _bubble;

		private Sprite _pipIdle;

		private Sprite _pipHappy;

		private Sprite _pipShocked;

		private string _pipMood = "idle";

		private float _pipMoodUntil;

		private float _bubbleUntil;

		private float _nextChatter;

		private static readonly Vector2 PipPos = new Vector2(-150f, -432f);

		private static readonly string[] IdleLines = new string[7] { "Feeling lucky?", "The Company won't miss\na few credits...", "Keys... I love keys.", "Go on. One spin.", "Shiny things only, please.", "Seven keys. That's all\nit takes.", "Psst. Spin it." };

		private static readonly string[] LoseLines = new string[4] { "Bah. Again!", "The house always wins...", "One more. Just one more.", "That spin was rigged.\n(It wasn't.)" };

		private static readonly Random PipRng = new Random();

		private TMP_Text _potText;

		private Image _potFrame;

		private int _pot;

		private static readonly Color Brass = new Color(0.6f, 0.46f, 0.24f);

		private static readonly Color WarmGold = new Color(0.95f, 0.78f, 0.42f);

		private static readonly Color WinCell = new Color(0.62f, 0.46f, 0.2f);

		private readonly Image[] _cells = (Image[])(object)new Image[30];

		private readonly TMP_Text[] _coinLabels = (TMP_Text[])(object)new TMP_Text[30];

		private readonly Image[] _cellBacks = (Image[])(object)new Image[30];

		private TMP_Text _bigWin;

		private const float CellSize = 84f;

		private const float CellGap = 6f;

		private static readonly Vector2 GridCenter = new Vector2(0f, 20f);

		private TMP_Text _status;

		private TMP_Text _sign;

		private TMP_FontAsset _font;

		private MaterialPropertyBlock _mpb;

		private GameObject _promptCanvas;

		private TMP_Text _prompt;

		private Coroutine _spinRoutine;

		private int _betIndex = 1;

		private bool _spinning;

		private float _jackpotUntil;

		private Key _spinKey;

		private Key _betKey;

		private Key _moveKey;

		private static AudioClip _leverClip;

		private static AudioClip _tickClip;

		private static AudioClip _winClip;

		private static AudioClip _jackpotClip;

		private static AudioClip _zapClip;

		private static Sprite _rounded;

		private static readonly Color CellIdle = new Color(0.14f, 0.11f, 0.085f);

		public static void Spawn(StartOfRound sor)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			Instance = new GameObject("LeCruikMachine").AddComponent<SlotMachine>();
			Instance.Build(sor);
		}

		private void Build(StartOfRound sor)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//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_004d: 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_0064: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_07af: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_083b: Unknown result type (might be due to invalid IL or missing references)
			_ship = sor.elevatorTransform;
			((Component)this).transform.SetParent(_ship, false);
			_mpb = new MaterialPropertyBlock();
			_spinKey = ParseKey(Plugin.SpinKey.Value, (Key)19);
			_betKey = ParseKey(Plugin.BetKey.Value, (Key)16);
			_moveKey = ParseKey(Plugin.MoveKey.Value, (Key)101);
			_betIndex = Mathf.Min(1, SlotNet.BetOptions().Length - 1);
			Material baseMat = FindLitMaterial(sor);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.07f, 0.07f, 0.08f);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(0.16f, 0.16f, 0.18f);
			Color color3 = default(Color);
			((Color)(ref color3))..ctor(1f, 0.08f, 0.05f);
			Color color4 = default(Color);
			((Color)(ref color4))..ctor(0.03f, 0.03f, 0.04f);
			Box("Pedestal", new Vector3(0f, 0.06f, 0.04f), new Vector3(0.74f, 0.12f, 0.8f), color, baseMat);
			Box("Body", new Vector3(0f, 0.57f, -0.02f), new Vector3(0.72f, 0.9f, 0.6f), color, baseMat);
			_lights.Add(Box("PanelFrameT", new Vector3(0f, 0.86f, 0.285f), new Vector3(0.46f, 0.025f, 0.012f), color3, baseMat));
			_lights.Add(Box("PanelFrameB", new Vector3(0f, 0.36f, 0.285f), new Vector3(0.46f, 0.025f, 0.012f), color3, baseMat));
			_lights.Add(Box("PanelFrameL", new Vector3(-0.23f, 0.61f, 0.285f), new Vector3(0.025f, 0.5f, 0.012f), color3, baseMat));
			_lights.Add(Box("PanelFrameR", new Vector3(0.23f, 0.61f, 0.285f), new Vector3(0.025f, 0.5f, 0.012f), color3, baseMat));
			_plate = Box("PanelPlate", new Vector3(0f, 0.61f, 0.282f), new Vector3(0.43f, 0.47f, 0.006f), new Color(0.05f, 0.08f, 0.25f), baseMat);
			Transform transform = new GameObject("Deck").transform;
			transform.SetParent(((Component)this).transform, false);
			transform.localPosition = new Vector3(0f, 1.05f, 0.18f);
			transform.localRotation = Quaternion.Euler(14f, 0f, 0f);
			Prim((PrimitiveType)3, "DeckTop", transform, new Vector3(0f, 0f, 0f), new Vector3(0.8f, 0.07f, 0.42f), color2, baseMat);
			_lights.Add(Prim((PrimitiveType)3, "DeckLED", transform, new Vector3(0f, -0.01f, 0.215f), new Vector3(0.82f, 0.03f, 0.015f), color3, baseMat));
			Transform transform2 = new GameObject("SpinButton").transform;
			transform2.SetParent(transform, false);
			transform2.localPosition = new Vector3(-0.18f, 0.04f, 0.06f);
			_leverPivot = transform2;
			_buttonRest = transform2.localPosition;
			_spinButton = Prim((PrimitiveType)2, "SpinCap", transform2, Vector3.zero, new Vector3(0.11f, 0.015f, 0.11f), new Color(0.15f, 0.9f, 0.3f), baseMat);
			for (int i = 0; i < 4; i++)
			{
				_lights.Add(Prim((PrimitiveType)2, "Btn" + i, transform, new Vector3(0.2f - (float)i * 0.075f, 0.04f, 0.1f), new Vector3(0.045f, 0.01f, 0.045f), new Color(0.2f, 0.4f, 1f), baseMat));
			}
			_screenRoot = new GameObject("ScreenRoot").transform;
			_screenRoot.SetParent(((Component)this).transform, false);
			_screenRoot.localPosition = new Vector3(0f, 1.9f, -0.18f);
			_screenRoot.localRotation = Quaternion.Euler(-6f, 0f, 0f);
			Prim((PrimitiveType)3, "Housing", _screenRoot, Vector3.zero, new Vector3(0.78f, 1.5f, 0.16f), color, baseMat);
			Prim((PrimitiveType)3, "Glass", _screenRoot, new Vector3(0f, 0f, 0.081f), new Vector3(0.74f, 1.44f, 0.004f), color4, baseMat);
			_lights.Add(Prim((PrimitiveType)3, "LEDScreenL", _screenRoot, new Vector3(-0.395f, 0f, 0.07f), new Vector3(0.02f, 1.52f, 0.03f), color3, baseMat));
			_lights.Add(Prim((PrimitiveType)3, "LEDScreenR", _screenRoot, new Vector3(0.395f, 0f, 0.07f), new Vector3(0.02f, 1.52f, 0.03f), color3, baseMat));
			_lights.Add(Box("LEDBodyL", new Vector3(-0.37f, 0.55f, 0.27f), new Vector3(0.02f, 0.85f, 0.03f), color3, baseMat));
			_lights.Add(Box("LEDBodyR", new Vector3(0.37f, 0.55f, 0.27f), new Vector3(0.02f, 0.85f, 0.03f), color3, baseMat));
			Box("Topper", new Vector3(0f, 2.74f, -0.24f), new Vector3(0.7f, 0.14f, 0.2f), color, baseMat);
			_lights.Add(Box("TopperLED", new Vector3(0f, 2.67f, -0.135f), new Vector3(0.72f, 0.02f, 0.02f), color3, baseMat));
			_lights.Add(Box("TopperBlue", new Vector3(0f, 2.75f, -0.135f), new Vector3(0.2f, 0.05f, 0.01f), new Color(0.3f, 0.5f, 1f), baseMat));
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audio.spatialBlend = 1f;
			_audio.rolloffMode = (AudioRolloffMode)1;
			_audio.maxDistance = 30f;
			_audio.playOnAwake = false;
			FindSounds();
			BuildScreen();
			_collider = ((Component)this).gameObject.AddComponent<BoxCollider>();
			_collider.center = new Vector3(0f, 1.41f, 0.04f);
			_collider.size = new Vector3(0.82f, 2.82f, 0.82f);
			((Component)this).transform.localScale = Vector3.one * Mathf.Clamp(Plugin.MachineScale.Value, 0.5f, 1.5f);
			((Collider)_collider).enabled = false;
			if ((Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.IsServer)
			{
				if (!TryLoadPlacement(out var pos, out var yaw))
				{
					AutoPlace(sor, out pos, out yaw);
				}
				SetPlacement(pos, yaw, save: false);
			}
			else
			{
				AutoPlace(sor, out var localPos, out var yaw2);
				SetPlacement(localPos, yaw2, save: false);
			}
			Plugin.Log.LogInfo((object)"Slot machine built on the ship.");
		}

		private void BuildScreen()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			_font = (((Object)(object)HUDManager.Instance != (Object)null) ? (from t in ((Component)HUDManager.Instance).GetComponentsInChildren<TextMeshProUGUI>(true)
				select ((TMP_Text)t).font).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null)) : null);
			RectTransform val = WorldCanvas("Screen", _screenRoot, new Vector3(0f, 0f, 0.0835f), new Vector2(560f, 1090f));
			Image val2 = Panel(val, "Backdrop", Vector2.zero, new Vector2(560f, 1090f), new Color(0.08f, 0.06f, 0.045f));
			Sprite val3 = Symbols.LoadEmbedded("bg");
			if ((Object)(object)val3 != (Object)null)
			{
				val2.sprite = val3;
				((Graphic)val2).color = Color.white;
			}
			_potFrame = Panel(val, "PotFrame", new Vector2(0f, 455f), new Vector2(528f, 128f), Brass);
			Panel(val, "PotBox", new Vector2(0f, 455f), new Vector2(516f, 116f), new Color(0.05f, 0.04f, 0.03f, 0.9f));
			Text(val, "PotLabel", new Vector2(0f, 492f), new Vector2(500f, 34f), "PROGRESSIVE JACKPOT", 24f, Brass);
			_potText = Text(val, "PotValue", new Vector2(0f, 445f), new Vector2(500f, 70f), "", 62f, WarmGold);
			_potText.fontStyle = (FontStyles)1;
			Text(val, "PotRule", new Vector2(0f, 405f), new Vector2(500f, 26f), $"{Plugin.JackpotKeys.Value}+ GOLD KEYS ANYWHERE WINS IT ALL", 21f, new Color(0.7f, 0.58f, 0.38f));
			Panel(val, "TitlePlate", new Vector2(0f, 320f), new Vector2(420f, 86f), new Color(0f, 0f, 0f, 0.5f));
			_sign = Text(val, "Title", new Vector2(0f, 320f), new Vector2(540f, 90f), "LE CRUIK", 74f, new Color(0.86f, 0.68f, 0.36f));
			_sign.fontStyle = (FontStyles)1;
			float num = 546f;
			float num2 = 456f;
			Panel(val, "GridFrame", GridCenter, new Vector2(num + 10f, num2 + 10f), Brass);
			Panel(val, "Grid", GridCenter, new Vector2(num, num2), new Color(0.07f, 0.055f, 0.045f));
			Random rng = new Random();
			for (int num3 = 0; num3 < 6; num3++)
			{
				for (int num4 = 0; num4 < 5; num4++)
				{
					int num5 = Symbols.Index(num3, num4);
					Vector2 val4 = CellPos(num3, num4);
					_cellBacks[num5] = Panel(val, $"Cell{num3}_{num4}", val4, new Vector2(84f, 84f), CellIdle);
					Image val5 = new GameObject($"Sym{num3}_{num4}", new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
					((Component)val5).transform.SetParent((Transform)(object)val, false);
					((Graphic)val5).rectTransform.anchoredPosition = val4;
					((Graphic)val5).rectTransform.sizeDelta = new Vector2(78f, 78f);
					val5.preserveAspect = true;
					((Graphic)val5).raycastTarget = false;
					_cells[num5] = val5;
					_coinLabels[num5] = Text(val, $"Coin{num3}_{num4}", val4, new Vector2(84f, 84f), "", 30f, new Color(0.35f, 0.2f, 0.02f));
					SetCell(num5, Symbols.RandomDisplayCell(rng));
				}
			}
			Panel(val, "StatusFrame", new Vector2(0f, -285f), new Vector2(528f, 62f), Brass);
			Panel(val, "StatusBar", new Vector2(0f, -285f), new Vector2(518f, 52f), new Color(0.05f, 0.04f, 0.03f));
			_status = Text(val, "Status", new Vector2(0f, -285f), new Vector2(510f, 52f), "", 32f, Color.white);
			BuildPip(val);
			_bigWin = Text(val, "BigWin", GridCenter, new Vector2(540f, 240f), "", 72f, WarmGold);
			_bigWin.fontStyle = (FontStyles)1;
			RectTransform parent = WorldCanvas("LowerPanel", ((Component)this).transform, new Vector3(0f, 0.61f, 0.2855f), new Vector2(400f, 440f));
			Text(parent, "LowerTitle", new Vector2(0f, 150f), new Vector2(390f, 70f), "LE\nCRUIK", 56f, new Color(0.55f, 0.7f, 1f)).fontStyle = (FontStyles)1;
			Text(parent, "Rules", new Vector2(0f, -60f), new Vector2(380f, 260f), $"5+ TOUCHING PAYS\nWINS CASCADE\nGOLD COINS MULTIPLY\n{Plugin.JackpotKeys.Value}+ KEYS = JACKPOT", 26f, new Color(0.75f, 0.85f, 1f));
			SetPot(SlotNet.Pot());
			ShowIdle();
		}

		private void BuildPip(RectTransform rt)
		{
			//IL_006c: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			_pipIdle = Symbols.LoadEmbedded("pip_idle");
			_pipHappy = Symbols.LoadEmbedded("pip_happy") ?? _pipIdle;
			_pipShocked = Symbols.LoadEmbedded("pip_shocked") ?? _pipIdle;
			if (!((Object)(object)_pipIdle == (Object)null))
			{
				_pip = new GameObject("Pip", new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
				((Component)_pip).transform.SetParent((Transform)(object)rt, false);
				_pip.sprite = _pipIdle;
				_pip.preserveAspect = true;
				((Graphic)_pip).raycastTarget = false;
				((Graphic)_pip).rectTransform.anchoredPosition = PipPos;
				((Graphic)_pip).rectTransform.sizeDelta = new Vector2(200f, 225f);
				Image val = Panel(rt, "Bubble", new Vector2(95f, -415f), new Vector2(310f, 124f), new Color(0.95f, 0.91f, 0.82f, 0.96f));
				val.sprite = RoundedSprite();
				val.type = (Type)1;
				Image obj = Panel(rt, "BubbleTail", new Vector2(-62f, -440f), new Vector2(26f, 26f), new Color(0.95f, 0.91f, 0.82f, 0.96f));
				((Transform)((Graphic)obj).rectTransform).localRotation = Quaternion.Euler(0f, 0f, 45f);
				((Component)obj).transform.SetParent(((Component)val).transform, true);
				_bubbleText = Text(rt, "BubbleText", new Vector2(95f, -415f), new Vector2(290f, 112f), "", 26f, new Color(0.15f, 0.1f, 0.06f));
				_bubbleText.transform.SetParent(((Component)val).transform, true);
				_bubble = ((Component)val).gameObject;
				Say("Name's Pip.\nLet's rob the Company.", "idle", 6f);
			}
		}

		private void Say(string line, string mood, float seconds)
		{
			if (!((Object)(object)_pip == (Object)null))
			{
				_pipMood = mood;
				_pipMoodUntil = Time.time + seconds;
				_bubbleUntil = Time.time + seconds;
				_bubbleText.text = line;
				_bubble.SetActive(true);
				_pip.sprite = ((mood == "happy") ? _pipHappy : ((mood == "shocked") ? _pipShocked : _pipIdle));
				_nextChatter = Time.time + 10f + (float)PipRng.NextDouble() * 8f;
			}
		}

		private void AnimatePip()
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_pip == (Object)null))
			{
				float time = Time.time;
				if (time > _pipMoodUntil && _pipMood != "idle")
				{
					_pipMood = "idle";
					_pip.sprite = _pipIdle;
				}
				if (time > _bubbleUntil && _bubble.activeSelf)
				{
					_bubble.SetActive(false);
				}
				if (!_spinning && time > _nextChatter)
				{
					Say(IdleLines[PipRng.Next(IdleLines.Length)], "idle", 4f);
				}
				Vector2 val = default(Vector2);
				if (_pipMood == "happy")
				{
					((Vector2)(ref val))..ctor(0f, Mathf.Abs(Mathf.Sin(time * 9f)) * 22f);
				}
				else if (_pipMood == "shocked")
				{
					((Vector2)(ref val))..ctor(Mathf.Sin(time * 70f) * 5f, 0f);
				}
				else if (_spinning)
				{
					((Vector2)(ref val))..ctor(0f, Mathf.Abs(Mathf.Sin(time * 14f)) * 5f);
				}
				else
				{
					((Vector2)(ref val))..ctor(0f, Mathf.Sin(time * 2f) * 4f);
				}
				((Graphic)_pip).rectTransform.anchoredPosition = PipPos + val;
			}
		}

		private static Sprite RoundedSprite()
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_010b: 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)
			//IL_013a: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rounded != (Object)null)
			{
				return _rounded;
			}
			Texture2D val = new Texture2D(48, 48, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[2304];
			for (int i = 0; i < 48; i++)
			{
				for (int j = 0; j < 48; j++)
				{
					float num = Mathf.Clamp((float)j + 0.5f, 16f, 32f);
					float num2 = Mathf.Clamp((float)i + 0.5f, 16f, 32f);
					float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num2));
					array[i * 48 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(16f - num3) * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			_rounded = Sprite.Create(val, new Rect(0f, 0f, 48f, 48f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(17f, 17f, 17f, 17f));
			return _rounded;
		}

		public void SetPot(int pot)
		{
			_pot = pot;
			if ((Object)(object)_potText != (Object)null)
			{
				_potText.text = pot.ToString("N0", CultureInfo.InvariantCulture);
			}
		}

		private RectTransform WorldCanvas(string name, Transform parent, Vector3 localPos, Vector2 size)
		{
			//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_0026: 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_003d: 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_0045: 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_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			val.AddComponent<Canvas>().renderMode = (RenderMode)2;
			RectTransform val2 = (RectTransform)val.transform;
			val2.sizeDelta = size;
			((Transform)val2).localScale = Vector3.one * 0.0013f;
			((Transform)val2).localPosition = localPos;
			((Transform)val2).localRotation = Quaternion.Euler(0f, 180f, 0f);
			return val2;
		}

		private void UpdateTiers(int lightUpTo = -1)
		{
		}

		private static Vector2 CellPos(int c, int r)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			float num = ((float)c - 2.5f) * 90f;
			float num2 = ((float)r - 2f) * 90f;
			return GridCenter + new Vector2(num, num2);
		}

		private void SetCell(int i, byte v)
		{
			//IL_001b: 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)
			_cells[i].sprite = Symbols.Get(v);
			((Graphic)_cells[i]).color = Color.white;
			((Transform)((Graphic)_cells[i]).rectTransform).localScale = Vector3.one;
			_coinLabels[i].text = (Symbols.IsCoin(v) ? ("x" + Symbols.CoinValue(v)) : "");
		}

		private void Update()
		{
			try
			{
				Tick();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Slot machine update failed: " + ex));
				((Behaviour)this).enabled = false;
			}
		}

		private void Tick()
		{
			//IL_005d: 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_00fd: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			AnimateBulbs();
			AnimatePip();
			PlayerControllerB val = FindLocal();
			RaycastHit val2 = default(RaycastHit);
			bool flag = (Object)(object)val != (Object)null && !val.isPlayerDead && (Object)(object)val.gameplayCamera != (Object)null && (Object)(object)_collider != (Object)null && ((Collider)_collider).enabled && ((Collider)_collider).Raycast(new Ray(((Component)val.gameplayCamera).transform.position, ((Component)val.gameplayCamera).transform.forward), ref val2, 2.6f);
			int num2;
			if ((Object)(object)val != (Object)null)
			{
				object obj = R.Get(val, "isTypingChat");
				bool flag2 = default(bool);
				int num;
				if (obj is bool)
				{
					flag2 = (bool)obj;
					num = 1;
				}
				else
				{
					num = 0;
				}
				num2 = ((((uint)num & (flag2 ? 1u : 0u)) != 0 || val.inTerminalMenu) ? 1 : 0);
			}
			else
			{
				num2 = 0;
			}
			bool flag3 = (byte)num2 != 0;
			int[] array = SlotNet.BetOptions();
			_betIndex = Mathf.Clamp(_betIndex, 0, array.Length - 1);
			int num3 = array[_betIndex];
			SetPrompt((flag && !flag3) ? $"[{KeyName(_spinKey)}] Spin  -  bet {num3} credits\n[{KeyName(_betKey)}] Change bet" : null);
			Keyboard current = Keyboard.current;
			if (!(current == null || (Object)(object)val == (Object)null || flag3))
			{
				if (flag && ((ButtonControl)current[_betKey]).wasPressedThisFrame && !_spinning)
				{
					_betIndex = (_betIndex + 1) % array.Length;
					UpdateTiers();
					ShowIdle();
				}
				if (flag && ((ButtonControl)current[_spinKey]).wasPressedThisFrame && !_spinning)
				{
					SlotNet.RequestSpin(val, num3);
				}
				if (((ButtonControl)current[_moveKey]).wasPressedThisFrame && (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && val.isInHangarShipRoom)
				{
					Vector3 val3 = Vector3.ProjectOnPlane(((Component)val).transform.forward, Vector3.up);
					Vector3 normalized = ((Vector3)(ref val3)).normalized;
					Vector3 val4 = ((Component)val).transform.position + normalized * 1.3f;
					Quaternion val5 = Quaternion.LookRotation(-normalized, Vector3.up);
					Vector3 localPos = _ship.InverseTransformPoint(val4);
					Quaternion val6 = Quaternion.Inverse(_ship.rotation) * val5;
					float y = ((Quaternion)(ref val6)).eulerAngles.y;
					SetPlacement(localPos, y, save: true);
					SlotNet.BroadcastPlacement(localPos, y);
					HUDManager.Instance.DisplayTip("Le Cruik", "Machine moved. This spot is saved for next time.", false, false, "LC_Tip1");
				}
			}
		}

		private void AnimateBulbs()
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_0081: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Time.time < _jackpotUntil;
			float time = Time.time;
			for (int i = 0; i < _lights.Count; i++)
			{
				if (!((Object)(object)_lights[i] == (Object)null))
				{
					Color c = (flag ? (Color.HSVToRGB((time * 1.5f + (float)i * 0.09f) % 1f, 0.85f, 1f) * 14f) : ((!_spinning) ? (new Color(1f, 0.1f, 0.05f) * (2.5f + 1.5f * (0.5f + 0.5f * Mathf.Sin(time * 2f)))) : (new Color(1f, 0.1f, 0.05f) * (2.5f + 4f * (0.5f + 0.5f * Mathf.Sin(time * 18f + (float)i))))));
					if (((Object)_lights[i]).name.StartsWith("Btn") || ((Object)_lights[i]).name == "TopperBlue")
					{
						c = new Color(0.25f, 0.45f, 1f) * (flag ? 12f : 5f);
					}
					SetEmission(_lights[i], c);
				}
			}
			SetEmission(_plate, new Color(0.15f, 0.25f, 1f) * (2.5f + 0.8f * Mathf.Sin(time * 1.5f)));
			SetEmission(_spinButton, new Color(0.2f, 1f, 0.35f) * (_spinning ? 2f : (4f + 3f * (0.5f + 0.5f * Mathf.Sin(time * 4f)))));
		}

		internal void PlaySpin(PlayerControllerB who, int bet, Symbols.SpinResult res)
		{
			if (_spinRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_spinRoutine);
			}
			_spinRoutine = ((MonoBehaviour)this).StartCoroutine(SpinRoutine(who, bet, res));
		}

		private IEnumerator SpinRoutine(PlayerControllerB who, int bet, Symbols.SpinResult res)
		{
			_spinning = true;
			bool mine = (Object)(object)who != (Object)null && (Object)(object)who == (Object)(object)FindLocal();
			_bigWin.text = "";
			Image[] cellBacks = _cellBacks;
			for (int i = 0; i < cellBacks.Length; i++)
			{
				((Graphic)cellBacks[i]).color = CellIdle;
			}
			UpdateTiers();
			SetStatus(string.Format("{0}  -  BET {1}", ((Object)(object)who != (Object)null) ? who.playerUsername : "?", bet), Color.white);
			Say("Come on, come on...", "idle", 2f);
			Play(_leverClip, 0.9f);
			Random rng = new Random();
			float start = Time.time;
			bool[] landed = new bool[6];
			float nextTick = 0f;
			while (Time.time - start < 1.4f)
			{
				float num = Time.time - start;
				float num2 = ((num < 0.15f) ? (num / 0.15f) : Mathf.Clamp01(1f - (num - 0.15f) / 0.4f));
				_leverPivot.localPosition = _buttonRest - Vector3.up * (0.012f * num2);
				for (int j = 0; j < 6; j++)
				{
					bool flag = num >= 0.5f + (float)j * 0.15f;
					if (flag && !landed[j])
					{
						landed[j] = true;
						for (int k = 0; k < 5; k++)
						{
							SetCell(Symbols.Index(j, k), res.Grids[0][Symbols.Index(j, k)]);
						}
						Play(_tickClip, 0.8f);
					}
					else if (!flag && Time.frameCount % 3 == 0)
					{
						for (int l = 0; l < 5; l++)
						{
							SetCell(Symbols.Index(j, l), Symbols.RandomDisplayCell(rng));
						}
					}
				}
				if (num >= nextTick)
				{
					nextTick = num + 0.1f;
					Play(_tickClip, 0.2f);
				}
				yield return null;
			}
			_leverPivot.localPosition = _buttonRest;
			for (int m = 0; m < 30; m++)
			{
				SetCell(m, res.Grids[0][m]);
			}
			if (res.Jackpot)
			{
				_jackpotUntil = Time.time + 8f;
				for (int n = 0; n < 30; n++)
				{
					if (res.Grids[0][n] == 5)
					{
						((Graphic)_cellBacks[n]).color = WarmGold;
						((Transform)((Graphic)_cells[n]).rectTransform).localScale = Vector3.one * 1.15f;
					}
				}
				SetPot(res.JackpotWin);
				Say("JACKPOT!!!\nGrab it and RUN!", "happy", 7f);
				_bigWin.text = $"JACKPOT!\n+{res.JackpotWin:N0}";
				SetStatus("JACKPOT!!!", WarmGold);
				Play(_jackpotClip ?? _winClip, 1f);
				float j2 = Time.time;
				while (Time.time - j2 < 2.5f)
				{
					bool flag2 = (int)((Time.time - j2) * 8f) % 2 == 0;
					((Graphic)_potFrame).color = (flag2 ? WarmGold : Brass);
					yield return null;
				}
				((Graphic)_potFrame).color = Brass;
				_bigWin.text = "";
				for (int num3 = 0; num3 < 30; num3++)
				{
					((Graphic)_cellBacks[num3]).color = CellIdle;
					((Transform)((Graphic)_cells[num3]).rectTransform).localScale = Vector3.one;
				}
			}
			SetPot(res.PotAfter);
			int running = 0;
			for (int step = 0; step < res.Steps; step++)
			{
				ulong mask = res.WinMasks[step];
				running += res.StepWins[step];
				SetStatus((running > 0) ? $"WIN {running}" : "DYNAMITE!", (running > 0) ? new Color(0.5f, 1f, 0.55f) : new Color(1f, 0.35f, 0.3f));
				Play((running > 0) ? _winClip : _zapClip, 0.7f);
				float j2 = Time.time;
				while (Time.time - j2 < 1.2f)
				{
					float num4 = Time.time - j2;
					for (int num5 = 0; num5 < 30; num5++)
					{
						if ((mask & (ulong)(1L << num5)) != 0L)
						{
							if (num4 < 0.6f)
							{
								float num6 = 1f + 0.18f * Mathf.Sin(num4 * 25f);
								((Transform)((Graphic)_cells[num5]).rectTransform).localScale = Vector3.one * num6;
								((Graphic)_cellBacks[num5]).color = WinCell;
							}
							else if (num4 < 0.85f)
							{
								float num7 = 1f - (num4 - 0.6f) / 0.25f;
								((Transform)((Graphic)_cells[num5]).rectTransform).localScale = Vector3.one * Mathf.Max(0.01f, num7);
								((Graphic)_cells[num5]).color = new Color(1f, 1f, 1f, num7);
							}
						}
					}
					if (num4 >= 0.85f && num4 - Time.deltaTime < 0.85f)
					{
						byte[] array = res.Grids[step + 1];
						for (int num8 = 0; num8 < 30; num8++)
						{
							SetCell(num8, array[num8]);
							((Graphic)_cellBacks[num8]).color = CellIdle;
						}
						Play(_tickClip, 0.8f);
					}
					yield return null;
				}
				byte[] array2 = res.Grids[step + 1];
				for (int num9 = 0; num9 < 30; num9++)
				{
					SetCell(num9, array2[num9]);
					((Graphic)_cellBacks[num9]).color = CellIdle;
				}
			}
			if (res.CoinMultiplier > 0 && res.Payout > 0)
			{
				byte[] array3 = res.Grids[res.Grids.Count - 1];
				for (int num10 = 0; num10 < 30; num10++)
				{
					if (Symbols.IsCoin(array3[num10]))
					{
						((Graphic)_cellBacks[num10]).color = WinCell;
						((Transform)((Graphic)_cells[num10]).rectTransform).localScale = Vector3.one * 1.2f;
					}
				}
				_bigWin.text = $"x{res.CoinMultiplier}";
				Play(_winClip, 1f);
				yield return (object)new WaitForSeconds(1.2f);
			}
			float num11 = ((bet > 0) ? ((float)res.Payout / (float)bet) : 0f);
			if (res.Zap && mine)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				int num12 = Mathf.Max(0, Plugin.SkullDamage.Value);
				if (num12 > 0)
				{
					R.Call(who, "DamagePlayer", num12, true, true, (object)(CauseOfDeath)11);
				}
			}
			int lightUpTo = ((!(num11 >= 100f)) ? ((num11 >= 50f) ? 1 : ((num11 >= 20f) ? 2 : ((num11 >= 10f) ? 3 : (-1)))) : 0);
			UpdateTiers(lightUpTo);
			if (res.Jackpot)
			{
				_jackpotUntil = Time.time + 5f;
				_bigWin.text = $"JACKPOT!\n+{res.Payout:N0}";
				HUDManager.Instance.DisplayTip("JACKPOT!!!", mine ? $"You won the jackpot: {res.Payout} credits!" : $"{who?.playerUsername} won the jackpot: {res.Payout} credits!", false, false, "LC_Tip1");
			}
			else if (num11 >= 20f)
			{
				_jackpotUntil = Time.time + 5f;
				_bigWin.text = ((num11 >= 50f) ? $"MEGA HEIST!\n+{res.Payout}" : $"BIG HEIST!\n+{res.Payout}");
				Play(_jackpotClip ?? _winClip, 1f);
				HUDManager.Instance.DisplayTip("BIG HEIST!", mine ? $"You won {res.Payout} credits!" : $"{who?.playerUsername} just won {res.Payout} credits!", false, false, "LC_Tip1");
			}
			else if (res.Payout > 0)
			{
				_bigWin.text = "";
				if (mine)
				{
					HUDManager.Instance.DisplayTip("Le Cruik", $"You won {res.Payout} credits (bet {bet}).", false, false, "LC_Tip1");
				}
			}
			else if (mine && res.Zap)
			{
				HUDManager.Instance.DisplayTip("Le Cruik", "Dynamite! The machine blows up in your face.", true, false, "LC_Tip1");
			}
			SetStatus((res.Payout > 0) ? $"WIN {res.Payout}" : (res.Zap ? "ZAPPED!" : $"NO LUCK  -{bet}"), (res.Payout > 0) ? new Color(0.5f, 1f, 0.55f) : new Color(0.8f, 0.7f, 0.7f));
			if (res.Jackpot)
			{
				Say("We're never working\nagain. Ever.", "happy", 5f);
			}
			else if (res.Zap)
			{
				Say("MY FEATHERS!!", "shocked", 3.5f);
			}
			else if (num11 >= 20f)
			{
				Say("WE'RE RICH!!", "happy", 4.5f);
			}
			else if (res.Payout > bet)
			{
				Say((res.CoinMultiplier > 1) ? $"x{res.CoinMultiplier} coins!\nNice haul!" : "Nice haul!", "happy", 3f);
			}
			else if (res.Payout > 0)
			{
				Say("Well... it's\nsomething.", "idle", 3f);
			}
			else
			{
				Say(LoseLines[PipRng.Next(LoseLines.Length)], "idle", 3f);
			}
			_spinning = false;
			yield return (object)new WaitForSeconds(3f);
			if (!_spinning)
			{
				_bigWin.text = "";
				ShowIdle();
			}
		}

		public (Vector3, float) CurrentPlacement()
		{
			//IL_0006: 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)
			return (((Component)this).transform.localPosition, ((Component)this).transform.localEulerAngles.y);
		}

		public void SetPlacement(Vector3 localPos, float yaw, bool save)
		{
			//IL_0006: 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_005b: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localPosition = localPos;
			((Component)this).transform.localRotation = Quaternion.Euler(0f, yaw, 0f);
			if ((Object)(object)_collider != (Object)null)
			{
				((Collider)_collider).enabled = true;
			}
			if (save)
			{
				Plugin.Placement.Value = string.Format(CultureInfo.InvariantCulture, "{0:0.###},{1:0.###},{2:0.###},{3:0.#}", localPos.x, localPos.y, localPos.z, yaw);
				Plugin.Cfg.Save();
			}
		}

		private static bool TryLoadPlacement(out Vector3 pos, out float yaw)
		{
			//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_006c: 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)
			pos = Vector3.zero;
			yaw = 0f;
			string[] array = Plugin.Placement.Value.Split(',');
			if (array.Length != 4)
			{
				return false;
			}
			float[] array2 = new float[4];
			for (int i = 0; i < 4; i++)
			{
				if (!float.TryParse(array[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out array2[i]))
				{
					return false;
				}
			}
			pos = new Vector3(array2[0], array2[1], array2[2]);
			yaw = array2[3];
			return true;
		}

		private void AutoPlace(StartOfRound sor, out Vector3 localPos, out float yaw)
		{
			//IL_0027: 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_0036: 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_0062: 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_0071: 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_007d: 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_00a0: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_012b: 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_014f: 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)
			//IL_015a: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((sor.playerSpawnPositions != null && sor.playerSpawnPositions.Length != 0 && (Object)(object)sor.playerSpawnPositions[0] != (Object)null) ? sor.playerSpawnPositions[0].position : _ship.position);
			int num = ((R.Get(sor, "collidersAndRoomMaskAndDefault") is int num2) ? num2 : (-1));
			Vector3 val2 = val + Vector3.up * 1f;
			Vector3 val3 = _ship.forward;
			float num3 = float.MaxValue;
			float num4 = 2f;
			RaycastHit val5 = default(RaycastHit);
			for (int i = 0; i < 16; i++)
			{
				Vector3 val4 = Quaternion.AngleAxis((float)i * 22.5f, Vector3.up) * _ship.forward;
				if (Physics.Raycast(val2, val4, ref val5, 8f, num, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val5)).distance < 1.4f))
				{
					float num5 = Mathf.Abs(((RaycastHit)(ref val5)).distance - 2.2f);
					if (num5 < num3)
					{
						num3 = num5;
						val3 = val4;
						num4 = ((RaycastHit)(ref val5)).distance;
					}
				}
			}
			Vector3 val6 = val2 + val3 * (num4 - 0.45f);
			RaycastHit val7 = default(RaycastHit);
			if (Physics.Raycast(val6, Vector3.down, ref val7, 3f, num, (QueryTriggerInteraction)1))
			{
				val6 = ((RaycastHit)(ref val7)).point;
			}
			else
			{
				val6.y = val.y;
			}
			Quaternion val8 = Quaternion.LookRotation(-val3, Vector3.up);
			localPos = _ship.InverseTransformPoint(val6);
			Quaternion val9 = Quaternion.Inverse(_ship.rotation) * val8;
			yaw = ((Quaternion)(ref val9)).eulerAngles.y;
		}

		private static PlayerControllerB FindLocal()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null)
			{
				return null;
			}
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
				{
					return val;
				}
			}
			if (!((Object)(object)GameNetworkManager.Instance != (Object)null))
			{
				return null;
			}
			return GameNetworkManager.Instance.localPlayerController;
		}

		private void ShowIdle()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int[] array = SlotNet.BetOptions();
			_betIndex = Mathf.Clamp(_betIndex, 0, array.Length - 1);
			SetStatus($"BET {array[_betIndex]}  -  PRESS SPIN", new Color(0.9f, 0.9f, 1f));
		}

		private void SetStatus(string s, Color c)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_status == (Object)null))
			{
				_status.text = s;
				((Graphic)_status).color = c;
			}
		}

		private void SetPrompt(string text)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0099: 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_00be: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (text == null)
			{
				if ((Object)(object)_promptCanvas != (Object)null && _promptCanvas.activeSelf)
				{
					_promptCanvas.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_promptCanvas == (Object)null)
			{
				_promptCanvas = new GameObject("LeCruikPrompt");
				_promptCanvas.transform.SetParent(((Component)this).transform, false);
				Canvas obj = _promptCanvas.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 55;
				CanvasScaler obj2 = _promptCanvas.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 1f;
				RectTransform parent = (RectTransform)_promptCanvas.transform;
				_prompt = Text(parent, "Prompt", Vector2.zero, new Vector2(900f, 90f), "", 26f, Color.white);
				RectTransform rectTransform = _prompt.rectTransform;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 0.3f);
				rectTransform.anchorMax = val;
				rectTransform.anchorMin = val;
			}
			if (!_promptCanvas.activeSelf)
			{
				_promptCanvas.SetActive(true);
			}
			_prompt.text = text;
		}

		private TMP_Text Text(RectTransform parent, string name, Vector2 pos, Vector2 size, string text, float fontSize, Color color)
		{
			//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_0057: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)_font != (Object)null)
			{
				((TMP_Text)val2).font = _font;
			}
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = fontSize;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).rectTransform.anchoredPosition = pos;
			((TMP_Text)val2).rectTransform.sizeDelta = size;
			return (TMP_Text)(object)val2;
		}

		private static Image Panel(RectTransform parent, string name, Vector2 pos, Vector2 size, Color color)
		{
			//IL_0014: 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_003d: 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)
			Image obj = new GameObject(name, new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
			((Component)obj).transform.SetParent((Transform)(object)parent, false);
			((Graphic)obj).rectTransform.anchoredPosition = pos;
			((Graphic)obj).rectTransform.sizeDelta = size;
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private Renderer Box(string name, Vector3 pos, Vector3 size, Color color, Material baseMat)
		{
			//IL_0008: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			return Prim((PrimitiveType)3, name, ((Component)this).transform, pos, size, color, baseMat);
		}

		private static Renderer Prim(PrimitiveType type, string name, Transform parent, Vector3 pos, Vector3 size, Color color, Material baseMat)
		{
			//IL_0000: 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_003e: 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_0071: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(type);
			Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
			((Object)obj).name = name;
			obj.layer = 0;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = pos;
			obj.transform.localScale = size;
			MeshRenderer component = obj.GetComponent<MeshRenderer>();
			if ((Object)(object)baseMat != (Object)null)
			{
				Material val = new Material(baseMat)
				{
					name = "QJ_" + name
				};
				string[] array = new string[4] { "_BaseColorMap", "_NormalMap", "_MaskMap", "_EmissiveColorMap" };
				foreach (string text in array)
				{
					if (val.HasProperty(text))
					{
						val.SetTexture(text, (Texture)null);
					}
				}
				val.DisableKeyword("_NORMALMAP");
				val.DisableKeyword("_MASKMAP");
				val.SetColor("_BaseColor", color);
				if (val.HasProperty("_Metallic"))
				{
					val.SetFloat("_Metallic", 0.35f);
				}
				if (val.HasProperty("_Smoothness"))
				{
					val.SetFloat("_Smoothness", 0.6f);
				}
				((Renderer)component).sharedMaterial = val;
			}
			return (Renderer)(object)component;
		}

		private void SetEmission(Renderer r, Color c)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)r == (Object)null))
			{
				r.GetPropertyBlock(_mpb);
				_mpb.SetColor("_EmissiveColor", c);
				r.SetPropertyBlock(_mpb);
			}
		}

		private static Material FindLitMaterial(StartOfRound sor)
		{
			foreach (Item items in sor.allItemsList.itemsList)
			{
				if (!((Object)(object)items == (Object)null) && !((Object)(object)items.spawnPrefab == (Object)null))
				{
					MeshRenderer componentInChildren = items.spawnPrefab.GetComponentInChildren<MeshRenderer>(true);
					if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null && ((Renderer)componentInChildren).sharedMaterial.HasProperty("_BaseColor"))
					{
						return ((Renderer)componentInChildren).sharedMaterial;
					}
				}
			}
			Plugin.Log.LogWarning((object)"Couldn't find a vanilla material to copy; the machine may look pink.");
			return null;
		}

		private static void FindSounds()
		{
			AudioClip[] clips;
			if (!((Object)(object)_tickClip != (Object)null) && !((Object)(object)_winClip != (Object)null))
			{
				clips = Resources.FindObjectsOfTypeAll<AudioClip>();
				_leverClip = Find(new string[3] { "lever", "switch", "button" });
				_tickClip = Find(new string[3] { "click", "tick", "beep" });
				_winClip = Find(new string[5] { "cash", "register", "chaching", "coin", "reward" });
				_jackpotClip = Find(new string[4] { "jackpot", "fanfare", "horn", "airhorn" });
				_zapClip = Find(new string[3] { "zap", "shock", "electric" });
				ManualLogSource log = Plugin.Log;
				string[] obj = new string[10] { "Machine sounds: lever=", null, null, null, null, null, null, null, null, null };
				AudioClip leverClip = _leverClip;
				obj[1] = ((leverClip != null) ? ((Object)leverClip).name : null);
				obj[2] = ", tick=";
				AudioClip tickClip = _tickClip;
				obj[3] = ((tickClip != null) ? ((Object)tickClip).name : null);
				obj[4] = ", win=";
				AudioClip winClip = _winClip;
				obj[5] = ((winClip != null) ? ((Object)winClip).name : null);
				obj[6] = ", jackpot=";
				AudioClip jackpotClip = _jackpotClip;
				obj[7] = ((jackpotClip != null) ? ((Object)jackpotClip).name : null);
				obj[8] = ", zap=";
				AudioClip zapClip = _zapClip;
				obj[9] = ((zapClip != null) ? ((Object)zapClip).name : null);
				log.LogInfo((object)string.Concat(obj));
			}
			AudioClip Find(params string[] keys)
			{
				return keys.Select((string k) => ((IEnumerable<AudioClip>)clips).FirstOrDefault((Func<AudioClip, bool>)((AudioClip a) => (Object)(object)a != (Object)null && ((Object)a).name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0 && a.length < 6f))).FirstOrDefault<AudioClip>((Func<AudioClip, bool>)((AudioClip a) => (Object)(object)a != (Object)null));
			}
		}

		private void Play(AudioClip clip, float vol)
		{
			if ((Object)(object)clip != (Object)null && (Object)(object)_audio != (Object)null)
			{
				_audio.PlayOneShot(clip, vol);
			}
		}

		private static Key ParseKey(string s, Key fallback)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!Enum.TryParse<Key>(s?.Trim(), ignoreCase: true, out Key result) || (int)result == 0)
			{
				return fallback;
			}
			return result;
		}

		private unsafe static string KeyName(Key k)
		{
			return ((object)(*(Key*)(&k))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant();
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}
	}
	internal static class R
	{
		private static readonly HashSet<string> Warned = new HashSet<string>();

		public static object Get(object obj, string name)
		{
			if (obj == null)
			{
				return null;
			}
			FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), name);
			if (fieldInfo != null)
			{
				return fieldInfo.GetValue(obj);
			}
			PropertyInfo propertyInfo = AccessTools.Property(obj.GetType(), name);
			if (propertyInfo != null && propertyInfo.CanRead)
			{
				return propertyInfo.GetValue(obj);
			}
			if (Warned.Add(obj.GetType().Name + "." + name))
			{
				Plugin.Log.LogWarning((object)("Game member not found: " + obj.GetType().Name + "." + name));
			}
			return null;
		}

		public static void Call(object obj, string name, params object[] args)
		{
			if (obj == null)
			{
				return;
			}
			try
			{
				MethodInfo methodInfo = AccessTools.GetDeclaredMethods(obj.GetType()).FirstOrDefault((MethodInfo m) => m.Name == name && m.GetParameters().Length >= args.Length && m.GetParameters().Skip(args.Length).All((ParameterInfo pi) => pi.HasDefaultValue));
				if (methodInfo == null)
				{
					Plugin.Log.LogWarning((object)("Game method not found: " + obj.GetType().Name + "." + name));
					return;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				object[] array = new object[parameters.Length];
				for (int num = 0; num < parameters.Length; num++)
				{
					array[num] = ((num < args.Length) ? args[num] : parameters[num].DefaultValue);
				}
				methodInfo.Invoke(obj, array);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)(obj.GetType().Name + "." + name + "() threw: " + (ex.InnerException?.Message ?? ex.Message)));
			}
		}
	}
	internal static class SlotNet
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnSpinRequest;

			public static HandleNamedMessageDelegate <1>__OnSpinResult;

			public static HandleNamedMessageDelegate <2>__OnFail;

			public static HandleNamedMessageDelegate <3>__OnPlace;

			public static HandleNamedMessageDelegate <4>__OnPlaceAsk;
		}

		private const string SpinRequest = "ScrapHeist_Spin";

		private const string SpinResult = "ScrapHeist_Result";

		private const string FailMsg = "ScrapHeist_Fail";

		private const string PlaceMsg = "ScrapHeist_Place";

		private const string PlaceAsk = "ScrapHeist_PlaceAsk";

		private static readonly Random Rng = new Random();

		private static bool _serverSpinning;

		public unsafe static void Register()
		{
			//IL_0074: 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_007f: Expected O, but got Unknown
			//IL_009a: 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_00a5: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null);
			if (val == null)
			{
				return;
			}
			string[] array = new string[5] { "ScrapHeist_Spin", "ScrapHeist_Result", "ScrapHeist_Fail", "ScrapHeist_Place", "ScrapHeist_PlaceAsk" };
			foreach (string text in array)
			{
				val.UnregisterNamedMessageHandler(text);
			}
			object obj = <>O.<0>__OnSpinRequest;
			if (obj == null)
			{
				HandleNamedMessageDelegate val2 = OnSpinRequest;
				<>O.<0>__OnSpinRequest = val2;
				obj = (object)val2;
			}
			val.RegisterNamedMessageHandler("ScrapHeist_Spin", (HandleNamedMessageDelegate)obj);
			object obj2 = <>O.<1>__OnSpinResult;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val3 = OnSpinResult;
				<>O.<1>__OnSpinResult = val3;
				obj2 = (object)val3;
			}
			val.RegisterNamedMessageHandler("ScrapHeist_Result", (HandleNamedMessageDelegate)obj2);
			object obj3 = <>O.<2>__OnFail;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val4 = OnFail;
				<>O.<2>__OnFail = val4;
				obj3 = (object)val4;
			}
			val.RegisterNamedMessageHandler("ScrapHeist_Fail", (HandleNamedMessageDelegate)obj3);
			object obj4 = <>O.<3>__OnPlace;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val5 = OnPlace;
				<>O.<3>__OnPlace = val5;
				obj4 = (object)val5;
			}
			val.RegisterNamedMessageHandler("ScrapHeist_Place", (HandleNamedMessageDelegate)obj4);
			object obj5 = <>O.<4>__OnPlaceAsk;
			if (obj5 == null)
			{
				HandleNamedMessageDelegate val6 = OnPlaceAsk;
				<>O.<4>__OnPlaceAsk = val6;
				obj5 = (object)val6;
			}
			val.RegisterNamedMessageHandler("ScrapHeist_PlaceAsk", (HandleNamedMessageDelegate)obj5);
			_serverSpinning = false;
			if (!NetworkManager.Singleton.IsServer)
			{
				FastBufferWriter val7 = default(FastBufferWriter);
				((FastBufferWriter)(ref val7))..ctor(4, (Allocator)2, -1);
				try
				{
					val.SendNamedMessage("ScrapHeist_PlaceAsk", 0uL, val7, (NetworkDelivery)2);
				}
				finally
				{
					((IDisposable)(*(FastBufferWriter*)(&val7))/*cast due to .constrained prefix*/).Dispose();
				}
			}
			Plugin.Log.LogInfo((object)"Slot machine networking ready.");
		}

		public static int Pot()
		{
			int value = Plugin.JackpotPot.Value;
			if (value <= 0)
			{
				return Mathf.Max(0, Plugin.JackpotSeed.Value);
			}
			return value;
		}

		private static void SavePot(int pot)
		{
			Plugin.JackpotPot.Value = pot;
			try
			{
				Plugin.Cfg.Save();
			}
			catch
			{
			}
		}

		public static int[] BetOptions()
		{
			int result;
			int[] array = (from v in (from s in Plugin.Bets.Value.Split(',')
					select int.TryParse(s.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result) ? result : 0 into v
					where v > 0
					select v).Distinct()
				orderby v
				select v).ToArray();
			if (array.Length == 0)
			{
				return new int[1] { 25 };
			}
			return array;
		}

		public unsafe static void RequestSpin(PlayerControllerB me, int bet)
		{
			//IL_0035: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			int idx = (int)me.playerClientId;
			if (singleton.IsServer)
			{
				ServerSpin(idx, bet, singleton.LocalClientId);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref idx, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref bet, default(ForPrimitives));
				singleton.CustomMessagingManager.SendNamedMessage("ScrapHeist_Spin", 0uL, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void OnSpinRequest(ulong sender, FastBufferReader r)
		{
			//IL_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				int idx = default(int);
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref idx, default(ForPrimitives));
				int bet = default(int);
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref bet, default(ForPrimitives));
				ServerSpin(idx, bet, sender);
			}
		}

		private unsafe static void ServerSpin(int idx, int bet, ulong sender)
		{
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (idx < 0 || idx >= allPlayerScripts.Length)
			{
				return;
			}
			PlayerControllerB val = allPlayerScripts[idx];
			if (val.actualClientId != sender || !val.isPlayerControlled || val.isPlayerDead)
			{
				return;
			}
			if (_serverSpinning)
			{
				Fail(sender, "The reels are already spinning!");
				return;
			}
			if (!BetOptions().Contains(bet))
			{
				bet = BetOptions()[0];
			}
			Terminal val2 = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val2 == (Object)null)
			{
				Fail(sender, "Couldn't find the ship's credits.");
				return;
			}
			if (val2.groupCredits < bet)
			{
				Fail(sender, $"Not enough credits. You need {bet}.");
				return;
			}
			Symbols.SpinResult spinResult = Symbols.Spin(Rng, bet, Mathf.Max(1, Plugin.JackpotKeys.Value));
			int num = Pot();
			num += Mathf.Max(1, Mathf.RoundToInt((float)bet * Mathf.Clamp01(Plugin.JackpotShare.Value)));
			if (spinResult.Jackpot)
			{
				spinResult.JackpotWin = num;
				spinResult.Payout += num;
				num = Mathf.Max(0, Plugin.JackpotSeed.Value);
			}
			spinResult.PotAfter = num;
			SavePot(num);
			_serverSpinning = true;
			SetCredits(val2, val2.groupCredits - bet);
			Plugin.Log.LogInfo((object)$"{val.playerUsername} bet {bet}: {spinResult.Steps} cascade(s), coins x{spinResult.CoinMultiplier}, zap={spinResult.Zap} -> {spinResult.Payout}");
			List<ulong> list = NetworkManager.Singleton.ConnectedClientsIds.Where((ulong id) => id != 0).ToList();
			if (list.Count > 0)
			{
				FastBufferWriter val3 = default(FastBufferWriter);
				((FastBufferWriter)(ref val3))..ctor(64 + spinResult.Grids.Count * 30 + spinResult.Steps * 12, (Allocator)2, -1);
				try
				{
					Write(val3, idx, bet, spinResult);
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ScrapHeist_Result", (IReadOnlyList<ulong>)list, val3, (NetworkDelivery)2);
				}
				finally
				{
					((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose();
				}
			}
			SlotMachine.Instance?.PlaySpin(val, bet, spinResult);
			float wait = Symbols.AnimationLength(spinResult.Steps, spinResult.CoinMultiplier > 0 && spinResult.Payout - spinResult.JackpotWin > 0, spinResult.Jackpot);
			SlotMachine instance = SlotMachine.Instance;
			if (instance != null)
			{
				((MonoBehaviour)instance).StartCoroutine(PayLater(val2, spinResult.Payout, wait));
			}
		}

		private static void Write(FastBufferWriter w, int idx, int bet, Symbols.SpinResult res)
		{
			//IL_0006: 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_001e: 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_0038: 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_0098: 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_00b9: 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_00df: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_0155: 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)
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref idx, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref bet, default(ForPrimitives));
			byte b = (byte)res.Steps;
			((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			foreach (byte[] grid in res.Grids)
			{
				((FastBufferWriter)(ref w)).WriteBytesSafe(grid, 30, 0);
			}
			for (int i = 0; i < res.Steps; i++)
			{
				ulong num = res.WinMasks[i];
				((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref num, default(ForPrimitives));
				int num2 = res.StepWins[i];
				((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
			}
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref res.CoinMultiplier, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref res.Payout, default(ForPrimitives));
			b = (res.Zap ? ((byte)1) : ((byte)0));
			((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			b = (res.Jackpot ? ((byte)1) : ((byte)0));
			((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref res.JackpotWin, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref res.PotAfter, default(ForPrimitives));
		}

		private static Symbols.SpinResult Read(FastBufferReader r, out int idx, out int bet)
		{
			//IL_000b: 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_001d: 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_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_007a: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			Symbols.SpinResult spinResult = new Symbols.SpinResult();
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref idx, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref bet, default(ForPrimitives));
			byte b = default(byte);
			((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
			for (int i = 0; i <= b; i++)
			{
				byte[] item = new byte[30];
				((FastBufferReader)(ref r)).ReadBytesSafe(ref item, 30, 0);
				spinResult.Grids.Add(item);
			}
			ulong item2 = default(ulong);
			int item3 = default(int);
			for (int j = 0; j < b; j++)
			{
				((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref item2, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref item3, default(ForPrimitives));
				spinResult.WinMasks.Add(item2);
				spinResult.StepWins.Add(item3);
			}
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref spinResult.CoinMultiplier, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref spinResult.Payout, default(ForPrimitives));
			byte b2 = default(byte);
			((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b2, default(ForPrimitives));
			spinResult.Zap = b2 != 0;
			byte b3 = default(byte);
			((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b3, default(ForPrimitives));
			spinResult.Jackpot = b3 != 0;
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref spinResult.JackpotWin, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref spinResult.PotAfter, default(ForPrimitives));
			return spinResult;
		}

		private static IEnumerator PayLater(Terminal terminal, int payout, float wait)
		{
			yield return (object)new WaitForSeconds(wait);
			if ((Object)(object)terminal != (Object)null && payout > 0)
			{
				SetCredits(terminal, terminal.groupCredits + payout);
			}
			_serverSpinning = false;
		}

		private static void OnSpinResult(ulong sender, FastBufferReader r)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (sender == 0L)
			{
				int idx;
				int bet;
				Symbols.SpinResult res = Read(r, out idx, out bet);
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				if (idx >= 0 && idx < allPlayerScripts.Length)
				{
					SlotMachine.Instance?.PlaySpin(allPlayerScripts[idx], bet, res);
				}
			}
		}

		private static void SetCredits(Terminal t, int credits)
		{
			t.groupCredits = Mathf.Max(0, credits);
			try
			{
				MethodInfo methodInfo = AccessTools.GetDeclaredMethods(typeof(Terminal)).FirstOrDefault((MethodInfo m) => m.Name == "SyncGroupCreditsClientRpc" && m.GetParameters().Length == 2);
				if (methodInfo != null)
				{
					int num = ((AccessTools.Field(typeof(Terminal), "numberOfItemsInDropship")?.GetValue(t) is int num2) ? num2 : 0);
					methodInfo.Invoke(t, new object[2] { t.groupCredits, num });
				}
				else
				{
					Plugin.Log.LogWarning((object)"Terminal.SyncGroupCreditsClientRpc not found; other players may see old credits until the next purchase.");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Credit sync failed: " + (ex.InnerException?.Message ?? ex.Message)));
			}
		}

		private unsafe static void Fail(ulong client, string reason)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (client == NetworkManager.Singleton.LocalClientId)
			{
				ShowFail(reason);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(512, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(reason, false);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ScrapHeist_Fail", client, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void OnFail(ulong sender, FastBufferReader r)
		{
			if (sender == 0L)
			{
				string reason = default(string);
				((FastBufferReader)(ref r)).ReadValueSafe(ref reason, false);
				ShowFail(reason);
			}
		}

		private static void ShowFail(string reason)
		{
			HUDManager.Instance.DisplayTip("Le Cruik", reason, true, false, "LC_Tip1");
		}

		public unsafe static void BroadcastPlacement(Vector3 localPos, float yaw)
		{
			//IL_0060: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00be: 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)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			List<ulong> list = NetworkManager.Singleton.ConnectedClientsIds.Where((ulong id) => id != 0).ToList();
			if (list.Count == 0)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(24, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref localPos.x, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref localPos.y, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref localPos.z, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref yaw, default(ForPrimitives));
				int num = Pot();
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ScrapHeist_Place", (IReadOnlyList<ulong>)list, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private unsafe static void OnPlaceAsk(ulong sender, FastBufferReader r)
		{
			//IL_0025: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_007b: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer || (Object)(object)SlotMachine.Instance == (Object)null)
			{
				return;
			}
			var (val, num) = SlotMachine.Instance.CurrentPlacement();
			FastBufferWriter val2 = default(FastBufferWriter);
			((FastBufferWriter)(ref val2))..ctor(24, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref val.x, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref val.y, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref val.z, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref num, default(ForPrimitives));
				int num2 = Pot();
				((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("ScrapHeist_Place", sender, val2, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void OnPlace(ulong sender, FastBufferReader r)
		{
			//IL_000a: 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_001d: 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_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_0043: 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_0056: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			if (sender == 0L)
			{
				float num = default(float);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref num, default(ForPrimitives));
				float num2 = default(float);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref num2, default(ForPrimitives));
				float num3 = default(float);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref num3, default(ForPrimitives));
				float yaw = default(float);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref yaw, default(ForPrimitives));
				int pot = default(int);
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref pot, default(ForPrimitives));
				SlotMachine.Instance?.SetPot(pot);
				SlotMachine.Instance?.SetPlacement(new Vector3(num, num2, num3), yaw, save: false);
			}
		}
	}
	internal static class Symbols
	{
		public class SpinResult
		{
			public List<byte[]> Grids = new List<byte[]>();

			public List<ulong> WinMasks = new List<ulong>();

			public List<int> StepWins = new List<int>();

			public int CoinMultiplier;

			public int Payout;

			public bool Zap;

			public bool Jackpot;

			public int JackpotWin;

			public int PotAfter;

			public int Steps => WinMasks.Count;
		}

		public const int Cols = 6;

		public const int Rows = 5;

		public const int Cells = 30;

		public const int Rope = 0;

		public const int Jars = 1;

		public const int Bottles = 2;

		public const int Lantern = 3;

		public const int Revolver = 4;

		public const int GoldKey = 5;

		public const int Dynamite = 6;

		public const int Coin = 7;

		public const int SpriteCount = 8;

		private const int Bolt = 0;

		private const int Cog = 1;

		private const int Battery = 2;

		private const int Core = 3;

		private const int Horn = 4;

		private const int GoldBar = 5;

		private const int Skull = 6;

		public const byte CoinBase = 100;

		public static readonly string[] Names = new string[7] { "Rope", "Jar Crate", "Bottle Crate", "Lantern", "Revolver", "Gold Key", "Dynamite" };

		private static readonly int[] Weights = new int[7] { 26, 22, 18, 14, 10, 6, 8 };

		private const int CoinWeight = 3;

		private static readonly int[] CoinValues = new int[4] { 2, 3, 5, 10 };

		private static readonly int[] CoinWeights = new int[4] { 50, 30, 15, 5 };

		public static readonly float[] BasePay = new float[7] { 0.28f, 0.42f, 0.7f, 1.1f, 2.2f, 4.2f, 0f };

		private static Sprite[] _sprites;

		private const int N = 96;

		private static readonly Color32 Clear = new Color32((byte)0, (byte)0, (byte)0, (byte)0);

		public static float SizeFactor(int n)
		{
			if (n >= 12)
			{
				return 12f;
			}
			return n switch
			{
				5 => 1f, 
				6 => 1.5f, 
				7 => 2f, 
				8 => 3f, 
				9 => 4f, 
				10 => 6f, 
				11 => 8f, 
				_ => 0f, 
			};
		}

		public static bool IsCoin(byte v)
		{
			return v >= 100;
		}

		public static int CoinValue(byte v)
		{
			return v - 100;
		}

		public static int Index(int col, int row)
		{
			return col * 5 + row;
		}

		private static byte RollCell(Random rng)
		{
			int num = 3;
			int[] weights = Weights;
			foreach (int num2 in weights)
			{
				num += num2;
			}
			int num3 = rng.Next(num);
			for (int j = 0; j < Weights.Length; j++)
			{
				if (num3 < Weights[j])
				{
					return (byte)j;
				}
				num3 -= Weights[j];
			}
			int num4 = 0;
			weights = CoinWeights;
			foreach (int num5 in weights)
			{
				num4 += num5;
			}
			int num6 = rng.Next(num4);
			for (int k = 0; k < CoinValues.Length; k+