Decompiled source of CasinoMod v1.2.2

Plugins/CWSlotMachine/CWSlotMachine.dll

Decompiled 44 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using Zorro.Settings;

[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("CWSlotMachine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CWSlotMachine")]
[assembly: AssemblyTitle("CWSlotMachine")]
[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;
		}
	}
}
public class BetDownButton : Interactable
{
	private AudioSource m_audio;

	public override string hoverText
	{
		get
		{
			return "Decrease bet — now $" + SlotConfig.GetBet(SlotMachineController.BetIndex);
		}
		set
		{
		}
	}

	protected override void Awake()
	{
		((Interactable)this).Awake();
		m_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
		m_audio.spatialBlend = 1f;
		m_audio.minDistance = 2.5f;
		m_audio.maxDistance = 10f;
	}

	public override bool IsValid(Player player)
	{
		return true;
	}

	public override void Interact(Player player)
	{
		int num = ((SlotConfig.BetOptions == null) ? 1 : SlotConfig.BetOptions.Count);
		if (num > 0)
		{
			SlotMachineController.BetIndex = (SlotMachineController.BetIndex + num - 1) % num;
			Debug.Log((object)("[CWSlotMachine] bet down -> $" + SlotConfig.GetBet(SlotMachineController.BetIndex)));
			if (SlotConfig.EnableSounds && (Object)(object)m_audio != (Object)null)
			{
				m_audio.PlayOneShot(SlotSounds.Clack, Mathf.Clamp01(SlotConfig.SoundVolume));
			}
			if ((Object)(object)SlotMachineController.Instance != (Object)null)
			{
				SlotMachineController.Instance.RefreshHover();
			}
		}
	}
}
public class BetUpButton : Interactable
{
	private AudioSource m_audio;

	public override string hoverText
	{
		get
		{
			return "Increase bet — now $" + SlotConfig.GetBet(SlotMachineController.BetIndex);
		}
		set
		{
		}
	}

	protected override void Awake()
	{
		((Interactable)this).Awake();
		m_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
		m_audio.spatialBlend = 1f;
		m_audio.minDistance = 2.5f;
		m_audio.maxDistance = 10f;
	}

	public override bool IsValid(Player player)
	{
		return true;
	}

	public override void Interact(Player player)
	{
		int num = ((SlotConfig.BetOptions == null) ? 1 : SlotConfig.BetOptions.Count);
		if (num > 0)
		{
			SlotMachineController.BetIndex = (SlotMachineController.BetIndex + 1) % num;
			Debug.Log((object)("[CWSlotMachine] bet up -> $" + SlotConfig.GetBet(SlotMachineController.BetIndex)));
			if (SlotConfig.EnableSounds && (Object)(object)m_audio != (Object)null)
			{
				m_audio.PlayOneShot(SlotSounds.Clack, Mathf.Clamp01(SlotConfig.SoundVolume));
			}
			if ((Object)(object)SlotMachineController.Instance != (Object)null)
			{
				SlotMachineController.Instance.RefreshHover();
			}
		}
	}
}
[BepInPlugin("stuart.cwslotmachine", "Casino Mod", "1.2.2")]
public class CasinoModBepInExPlugin : BaseUnityPlugin
{
	private void Awake()
	{
		Harmony.CreateAndPatchAll(typeof(CasinoModBepInExPlugin).Assembly, (string)null);
		RuntimeHelpers.RunClassConstructor(typeof(CWSlotMachinePlugin).TypeHandle);
	}
}
public class PayTableSwitch : Interactable
{
	private AudioSource m_audio;

	public override string hoverText
	{
		get
		{
			return "Payouts — show / hide";
		}
		set
		{
		}
	}

	protected override void Awake()
	{
		((Interactable)this).Awake();
		m_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
		m_audio.spatialBlend = 1f;
		m_audio.minDistance = 2.5f;
		m_audio.maxDistance = 10f;
	}

	public override bool IsValid(Player player)
	{
		return true;
	}

	public override void Interact(Player player)
	{
		if ((Object)(object)SlotMachineController.Instance != (Object)null)
		{
			SlotMachineController.Instance.TogglePayTable();
		}
		if (SlotConfig.EnableSounds && (Object)(object)m_audio != (Object)null)
		{
			m_audio.PlayOneShot(SlotSounds.Clack, Mathf.Clamp01(SlotConfig.SoundVolume));
		}
	}
}
[ContentWarningPlugin("stuart.cwslotmachine", "1.2.2", false)]
public static class CWSlotMachinePlugin
{
	static CWSlotMachinePlugin()
	{
		Debug.Log((object)"[CWSlotMachine] v1.2.2 loaded. A slot machine will spawn next to the shop when a world loads.");
	}
}
public static class SlotConfig
{
	public static int[][] ReelWeights = new int[3][]
	{
		new int[6] { 1, 2, 6, 5, 4, 6 },
		new int[6] { 1, 3, 5, 5, 4, 5 },
		new int[6] { 2, 3, 4, 4, 4, 4 }
	};

	public static float JackpotMultiplier = 50f;

	public static float BellsMultiplier = 20f;

	public static float CherryMultiplier = 11f;

	public static float LemonMultiplier = 9f;

	public static float BarMultiplier = 7f;

	public static float[] PairMults = new float[5] { 6f, 3f, 2f, 2f, 1.2f };

	public static List<int> BetOptions = new List<int> { 1, 5, 10, 25, 50 };

	public static int MaxPayout = 5000;

	public static Color MachineColor = new Color(0.83f, 0.24f, 0.24f);

	public static Color AccentColor = new Color(1f, 0.82f, 0.3f);

	public static bool EnableLights = true;

	public static float LightSpeed = 4f;

	public static float SpinSeconds = 2.2f;

	public static float ReelStagger = 0.35f;

	public static bool EnableSounds = true;

	public static float SoundVolume = 0.7f;

	public static int PlacementMode = 0;

	public static float SideOffset = 2.3f;

	public static float FrontOffset = 0.8f;

	public static Vector3 ManualPosition = new Vector3(-0.41f, 0f, 12.91f);

	public static float ManualRotationY = 180f;

	public static float PairMult(int sym)
	{
		if (sym < 0 || sym > 4)
		{
			return 0f;
		}
		if (PairMults == null || sym >= PairMults.Length)
		{
			return 0f;
		}
		return PairMults[sym];
	}

	public static int GetBet(int index)
	{
		if (BetOptions == null || BetOptions.Count == 0)
		{
			return 1;
		}
		if (index < 0)
		{
			index = 0;
		}
		if (index >= BetOptions.Count)
		{
			index = BetOptions.Count - 1;
		}
		return BetOptions[index];
	}

	public static void NotifyChanged()
	{
		try
		{
			if ((Object)(object)SlotMachineController.Instance != (Object)null)
			{
				SlotMachineController.Instance.OnConfigChanged();
			}
		}
		catch (Exception ex)
		{
			Debug.LogException(ex);
		}
	}

	internal static Color ParseColor(string s, Color fallback)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		if (!string.IsNullOrEmpty(s) && ColorUtility.TryParseHtmlString(s.Trim(), ref result))
		{
			return result;
		}
		return fallback;
	}

	internal static List<int> ParseBetOptions(string s)
	{
		List<int> list = new List<int>();
		if (!string.IsNullOrEmpty(s))
		{
			string[] array = s.Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				if (int.TryParse(array[i].Trim(), out var result) && result > 0)
				{
					list.Add(result);
				}
			}
		}
		if (list.Count <= 0)
		{
			return new List<int> { 1, 5, 10, 25, 50 };
		}
		return list;
	}

	internal static int NameToSymbol(string name)
	{
		switch (name)
		{
		case "seven":
		case "sevens":
		case "7":
			return 0;
		case "bells":
		case "bell":
			return 1;
		case "cherry":
		case "cherries":
			return 2;
		case "lemon":
		case "lemons":
			return 3;
		case "bars":
		case "bar":
			return 4;
		case "skull":
		case "skulls":
			return 5;
		default:
			return -1;
		}
	}

	internal static int[] ParseWeights(string s, int[] fallback)
	{
		int[] array = (int[])fallback.Clone();
		if (!string.IsNullOrEmpty(s))
		{
			string[] array2 = s.Split(',');
			for (int i = 0; i < array2.Length && i < 6; i++)
			{
				string text = array2[i].Trim();
				int num = text.IndexOf(':');
				int result2;
				if (num >= 0)
				{
					int num2 = NameToSymbol(text.Substring(0, num).Trim().ToLowerInvariant());
					if (num2 >= 0 && int.TryParse(text.Substring(num + 1).Trim(), out var result))
					{
						array[num2] = Mathf.Max(0, result);
					}
				}
				else if (int.TryParse(text, out result2))
				{
					array[i] = Mathf.Max(0, result2);
				}
			}
		}
		return array;
	}

	internal static float[] ParsePairMults(string s, float[] fallback)
	{
		float[] array = (float[])fallback.Clone();
		if (!string.IsNullOrEmpty(s))
		{
			string[] array2 = s.Split(',');
			for (int i = 0; i < array2.Length && i < 5; i++)
			{
				if (float.TryParse(array2[i].Trim(), out var result))
				{
					array[i] = Mathf.Max(0f, result);
				}
			}
		}
		return array;
	}

	internal static Vector3 ParseVector3(string s, Vector3 fallback)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (!string.IsNullOrEmpty(s))
		{
			string[] array = s.Split(',');
			if (array.Length == 3 && float.TryParse(array[0].Trim(), out var result) && float.TryParse(array[1].Trim(), out var result2) && float.TryParse(array[2].Trim(), out var result3))
			{
				return new Vector3(result, result2, result3);
			}
		}
		return fallback;
	}
}
[ContentWarningSetting]
public class SlotReelWeight1Setting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.ReelWeights[0] = SlotConfig.ParseWeights(((StringSetting)this).Value, SlotConfig.ReelWeights[0]);
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "7:1,bell:2,cherry:6,lemon:5,bar:4,skull:6";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: reel 1 weights (7,bell,cherry,lemon,bar,skull)";
	}
}
[ContentWarningSetting]
public class SlotReelWeight2Setting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.ReelWeights[1] = SlotConfig.ParseWeights(((StringSetting)this).Value, SlotConfig.ReelWeights[1]);
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "7:1,bell:3,cherry:5,lemon:5,bar:4,skull:5";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: reel 2 weights (7,bell,cherry,lemon,bar,skull)";
	}
}
[ContentWarningSetting]
public class SlotReelWeight3Setting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.ReelWeights[2] = SlotConfig.ParseWeights(((StringSetting)this).Value, SlotConfig.ReelWeights[2]);
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "7:2,bell:3,cherry:4,lemon:4,bar:4,skull:4";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: reel 3 weights (7,bell,cherry,lemon,bar,skull)";
	}
}
[ContentWarningSetting]
public class SlotJackpotMultiplierSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.JackpotMultiplier = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 50f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 500f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: triple 7s payout (x bet)";
	}
}
[ContentWarningSetting]
public class SlotBellsMultiplierSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.BellsMultiplier = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 20f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 500f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: triple bells payout (x bet)";
	}
}
[ContentWarningSetting]
public class SlotCherryMultiplierSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.CherryMultiplier = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 11f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 500f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: triple cherry payout (x bet)";
	}
}
[ContentWarningSetting]
public class SlotLemonMultiplierSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.LemonMultiplier = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 9f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 500f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: triple lemon payout (x bet)";
	}
}
[ContentWarningSetting]
public class SlotBarMultiplierSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.BarMultiplier = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 7f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 500f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: triple bar payout (x bet)";
	}
}
[ContentWarningSetting]
public class SlotPairMultsSetting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.PairMults = SlotConfig.ParsePairMults(((StringSetting)this).Value, SlotConfig.PairMults);
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "6,3,2,2,1.2";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: pair payouts (7,bell,cherry,lemon,bar) x bet";
	}
}
[ContentWarningSetting]
public class SlotBetOptionsSetting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.BetOptions = SlotConfig.ParseBetOptions(((StringSetting)this).Value);
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "1,5,10,25,50";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: bet options (comma separated $)";
	}
}
[ContentWarningSetting]
public class SlotMaxPayoutSetting : IntSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.MaxPayout = ((IntSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	public override int GetDefaultValue()
	{
		return 5000;
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: max payout per spin ($)";
	}
}
[ContentWarningSetting]
public class SlotMachineColorSetting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		SlotConfig.MachineColor = SlotConfig.ParseColor(((StringSetting)this).Value, new Color(0.83f, 0.24f, 0.24f));
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "#D43B3B";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: cabinet color (hex)";
	}
}
[ContentWarningSetting]
public class SlotAccentColorSetting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		SlotConfig.AccentColor = SlotConfig.ParseColor(((StringSetting)this).Value, new Color(1f, 0.82f, 0.3f));
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "#FFD24D";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: accent color (hex)";
	}
}
[ContentWarningSetting]
public class SlotEnableLightsSetting : BoolSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.EnableLights = ((BoolSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override bool GetDefaultValue()
	{
		return true;
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: marquee lights";
	}
}
[ContentWarningSetting]
public class SlotLightSpeedSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.LightSpeed = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 4f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0.5f, 12f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: light chase speed";
	}
}
[ContentWarningSetting]
public class SlotSpinSecondsSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.SpinSeconds = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 2.2f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0.8f, 6f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: reel spin duration (s)";
	}
}
[ContentWarningSetting]
public class SlotReelStaggerSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.ReelStagger = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 0.35f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 1.5f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: delay between reel stops (s)";
	}
}
[ContentWarningSetting]
public class SlotEnableSoundsSetting : BoolSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.EnableSounds = ((BoolSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override bool GetDefaultValue()
	{
		return true;
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: sounds";
	}
}
[ContentWarningSetting]
public class SlotSoundVolumeSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.SoundVolume = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 0.7f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 1f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: sound volume";
	}
}
[ContentWarningSetting]
public class SlotPlacementModeSetting : EnumSetting, IExposedSetting
{
	public override List<string> GetChoices()
	{
		return new List<string> { "Auto (right of the shop)", "Manual" };
	}

	public override int GetDefaultValue()
	{
		return 0;
	}

	public override void ApplyValue()
	{
		SlotConfig.PlacementMode = ((IntSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: placement mode";
	}
}
[ContentWarningSetting]
public class SlotSideOffsetSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.SideOffset = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 2.3f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(-8f, 8f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: side offset from shop (m)";
	}
}
[ContentWarningSetting]
public class SlotFrontOffsetSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.FrontOffset = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 0.8f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(-6f, 6f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: front offset from shop (m)";
	}
}
[ContentWarningSetting]
public class SlotManualPositionSetting : StringSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		SlotConfig.ManualPosition = SlotConfig.ParseVector3(((StringSetting)this).Value, new Vector3(-0.41f, 0f, 12.91f));
		SlotConfig.NotifyChanged();
	}

	protected override string GetDefaultValue()
	{
		return "-0.41,0,12.91";
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: manual position (x,y,z)";
	}
}
[ContentWarningSetting]
public class SlotManualRotationSetting : FloatSetting, IExposedSetting
{
	public override void ApplyValue()
	{
		SlotConfig.ManualRotationY = ((FloatSetting)this).Value;
		SlotConfig.NotifyChanged();
	}

	protected override float GetDefaultValue()
	{
		return 180f;
	}

	protected override float2 GetMinMaxValue()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return new float2(0f, 360f);
	}

	public SettingCategory GetSettingCategory()
	{
		return (SettingCategory)4;
	}

	public string GetDisplayName()
	{
		return "Slots: manual rotation Y (deg)";
	}
}
public class SlotMachineController : Interactable
{
	public static SlotMachineController Instance;

	public static int BetIndex;

	public static Vector3 PendingAnchor;

	private SlotVisuals m_vis;

	private AudioSource m_audio;

	private string m_hoverCache = "Slot machine";

	private bool m_spinning;

	private bool m_celebrating;

	private float[] m_reelAngles = new float[3];

	private Coroutine m_spinRoutine;

	private bool m_refinedOrientation;

	private float m_spawnTime;

	private Vector3 m_anchorPos;

	private bool m_loggedNoShop;

	private bool m_loggedScreen;

	private bool m_payTableOut;

	private Coroutine m_panelRoutine;

	public int CurrentBet => SlotConfig.GetBet(BetIndex);

	public override string hoverText
	{
		get
		{
			return m_hoverCache;
		}
		set
		{
			m_hoverCache = value;
		}
	}

	protected override void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		((Interactable)this).Awake();
		Instance = this;
		m_spawnTime = Time.time;
		m_anchorPos = PendingAnchor;
		PendingAnchor = Vector3.zero;
		m_vis = SlotModelBuilder.Build();
		m_vis.Root.transform.SetParent(((Component)this).transform, false);
		m_vis.Root.transform.localPosition = Vector3.zero;
		m_vis.Root.transform.localRotation = Quaternion.identity;
		if ((Object)(object)m_vis.BetMinusBtn != (Object)null)
		{
			m_vis.BetMinusBtn.AddComponent<BetDownButton>();
		}
		if ((Object)(object)m_vis.BetPlusBtn != (Object)null)
		{
			m_vis.BetPlusBtn.AddComponent<BetUpButton>();
		}
		if ((Object)(object)m_vis.PaySwitch != (Object)null)
		{
			m_vis.PaySwitch.AddComponent<PayTableSwitch>();
		}
		if ((Object)(object)m_vis.PayTablePanel != (Object)null)
		{
			m_vis.PayTablePanel.SetActive(false);
		}
		Debug.Log((object)("[CWSlotMachine] " + SlotResolver.OddsSummary()));
		m_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
		m_audio.spatialBlend = 1f;
		m_audio.minDistance = 2.5f;
		m_audio.maxDistance = 14f;
		m_audio.volume = Mathf.Clamp01(SlotConfig.SoundVolume);
		RefreshHover();
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	public override void OnStartHover(Player player)
	{
		((Interactable)this).OnStartHover(player);
		RefreshHover();
	}

	public override bool IsValid(Player player)
	{
		return !m_spinning;
	}

	public override void Interact(Player player)
	{
		if (!m_spinning)
		{
			int currentBet = CurrentBet;
			RoomStatsHolder roomStats = SurfaceNetworkHandler.RoomStats;
			if (roomStats == null || roomStats.Money < currentBet)
			{
				PlaySound(SlotSounds.Reject);
				RefreshHover();
			}
			else
			{
				BeginSpin(player, currentBet);
			}
		}
	}

	private void BeginSpin(Player player, int bet)
	{
		m_spinning = true;
		RefreshHover();
		((MonoBehaviour)this).StartCoroutine(LeverAnim());
		PlaySound(SlotSounds.Clack);
		int actorNr = -1;
		string actorName = "Player";
		try
		{
			if ((Object)(object)player != (Object)null && player.refs != null && (Object)(object)player.refs.view != (Object)null)
			{
				actorNr = player.refs.view.OwnerActorNr;
				Player owner = player.refs.view.Owner;
				if (owner != null && !string.IsNullOrEmpty(owner.NickName))
				{
					actorName = owner.NickName;
				}
			}
		}
		catch (Exception ex)
		{
			Debug.Log((object)("[CWSlotMachine] actor lookup failed: " + ex.Message));
		}
		SlotNet current = SlotNet.Current;
		if ((Object)(object)current != (Object)null)
		{
			current.RequestSpin(actorNr, actorName, bet);
		}
		else
		{
			ResolveLocal(bet);
		}
	}

	private void ResolveLocal(int bet)
	{
		SlotResolver.Result result = SlotResolver.Resolve(bet);
		RoomStatsHolder roomStats = SurfaceNetworkHandler.RoomStats;
		if (roomStats != null)
		{
			roomStats.RemoveMoney(bet);
			if (result.Payout > 0)
			{
				roomStats.AddMoney(result.Payout);
			}
		}
		OnResult(MyActorNr(), "You", result.R1, result.R2, result.R3, bet, result.Payout, result.Tier);
	}

	private static int MyActorNr()
	{
		try
		{
			return (PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0;
		}
		catch
		{
			return 0;
		}
	}

	public void OnResult(int actorNr, string actorName, int r1, int r2, int r3, int bet, int payout, int tier)
	{
		Debug.Log((object)("[CWSlotMachine] spin by " + actorName + " -> [" + SlotResolver.SymbolNames[r1] + ", " + SlotResolver.SymbolNames[r2] + ", " + SlotResolver.SymbolNames[r3] + "] tier " + tier + " bet $" + bet + " payout $" + payout));
		if (m_spinRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(m_spinRoutine);
		}
		bool isMine = !PhotonNetwork.InRoom || actorNr == MyActorNr();
		m_spinRoutine = ((MonoBehaviour)this).StartCoroutine(SpinToResults(r1, r2, r3, bet, payout, tier, isMine, actorName));
	}

	private IEnumerator SpinToResults(int r1, int r2, int r3, int bet, int payout, int tier, bool isMine, string actorName)
	{
		float num = Mathf.Max(0.8f, SlotConfig.SpinSeconds);
		float num2 = Mathf.Max(0f, SlotConfig.ReelStagger);
		PlayWhir(num + num2 * 2f + 0.4f);
		int[] array = new int[3] { r1, r2, r3 };
		float[] from = new float[3];
		float[] to = new float[3];
		float[] durations = new float[3];
		for (int i = 0; i < 3; i++)
		{
			from[i] = m_reelAngles[i];
			int num3 = SlotModelBuilder.StripPos(array[i]) * 30;
			float num4 = ((num > 1.5f) ? 3f : 2f);
			float num5 = Mathf.Ceil((from[i] + 360f * num4 - (float)num3) / 360f);
			to[i] = (float)num3 + 360f * num5;
			durations[i] = num + num2 * (float)i;
		}
		float t = 0f;
		float total = num + num2 * 2f;
		while (t < total)
		{
			t += Time.deltaTime;
			for (int j = 0; j < 3; j++)
			{
				if (m_vis != null && !((Object)(object)m_vis.Reels[j] == (Object)null))
				{
					float num6 = Mathf.Clamp01(t / durations[j]);
					float num7 = 1f - Mathf.Pow(1f - num6, 3f);
					float num8 = Mathf.LerpUnclamped(from[j], to[j], num7);
					m_vis.Reels[j].localRotation = Quaternion.AngleAxis(num8, Vector3.right);
				}
			}
			yield return null;
		}
		for (int k = 0; k < 3; k++)
		{
			m_reelAngles[k] = to[k];
			if (m_vis != null && (Object)(object)m_vis.Reels[k] != (Object)null)
			{
				m_vis.Reels[k].localRotation = Quaternion.AngleAxis(to[k], Vector3.right);
			}
			PlaySound(SlotSounds.Click);
			yield return (object)new WaitForSeconds(0.08f);
		}
		yield return (object)new WaitForSeconds(0.25f);
		Finish(bet, payout, tier, isMine, actorName);
	}

	private void Finish(int bet, int payout, int tier, bool isMine, string actorName)
	{
		m_spinning = false;
		RefreshHover();
		if (tier == -1)
		{
			PlaySound(SlotSounds.Reject);
		}
		else if (payout > 0)
		{
			bool flag = tier == 0;
			PlaySound(flag ? SlotSounds.Jackpot : SlotSounds.Win);
			((MonoBehaviour)this).StartCoroutine(LightCelebration(flag ? 4f : 2.2f, flag));
			UserInterface.ShowMoneyNotification(isMine ? "SLOT MACHINE" : actorName.ToUpperInvariant(), "+$" + payout, (MoneyCellType)1);
		}
		else
		{
			PlaySound(SlotSounds.Lose);
			if (isMine)
			{
				UserInterface.ShowMoneyNotification("SLOT MACHINE", "-$" + bet, (MoneyCellType)0);
			}
		}
	}

	public void TogglePayTable()
	{
		if (m_vis != null && !((Object)(object)m_vis.PayTablePanel == (Object)null))
		{
			m_payTableOut = !m_payTableOut;
			if (m_payTableOut)
			{
				m_vis.PayTablePanel.SetActive(true);
			}
			if (m_panelRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(m_panelRoutine);
			}
			m_panelRoutine = ((MonoBehaviour)this).StartCoroutine(SlidePayTable());
			PlaySound(SlotSounds.Clack);
			Debug.Log((object)("[CWSlotMachine] paytable " + (m_payTableOut ? "extended" : "retracted")));
		}
	}

	private IEnumerator SlidePayTable()
	{
		Transform p = m_vis.PayTablePanel.transform;
		float fromY = p.localPosition.y;
		float toY = (m_payTableOut ? 2.55f : 1.2f);
		float t = 0f;
		while (t < 0.45f)
		{
			t += Time.deltaTime;
			float num = Mathf.SmoothStep(0f, 1f, t / 0.45f);
			Vector3 localPosition = p.localPosition;
			localPosition.y = Mathf.LerpUnclamped(fromY, toY, num);
			p.localPosition = localPosition;
			yield return null;
		}
		Vector3 localPosition2 = p.localPosition;
		localPosition2.y = toY;
		p.localPosition = localPosition2;
		if (!m_payTableOut)
		{
			m_vis.PayTablePanel.SetActive(false);
		}
	}

	private IEnumerator LeverAnim()
	{
		if (m_vis != null && !((Object)(object)m_vis.LeverPivot == (Object)null))
		{
			Transform lp = m_vis.LeverPivot;
			float t = 0f;
			while (t < 0.22f)
			{
				t += Time.deltaTime;
				lp.localRotation = Quaternion.Euler(0f, 0f, Mathf.LerpUnclamped(0f, 105f, Mathf.SmoothStep(0f, 1f, t / 0.22f)));
				yield return null;
			}
			yield return (object)new WaitForSeconds(0.25f);
			t = 0f;
			while (t < 0.4f)
			{
				t += Time.deltaTime;
				lp.localRotation = Quaternion.Euler(0f, 0f, Mathf.LerpUnclamped(105f, 0f, Mathf.SmoothStep(0f, 1f, t / 0.4f)));
				yield return null;
			}
			lp.localRotation = Quaternion.Euler(0f, 0f, 0f);
		}
	}

	private IEnumerator LightCelebration(float dur, bool jackpot)
	{
		if (m_vis == null || m_vis.BulbMats.Count == 0)
		{
			yield break;
		}
		m_celebrating = true;
		Color on = (Color)(jackpot ? new Color(1f, 0.85f, 0.2f) : SlotConfig.AccentColor);
		float t = 0f;
		bool state = false;
		while (t < dur)
		{
			t += Time.deltaTime;
			state = !state;
			foreach (Material bulbMat in m_vis.BulbMats)
			{
				if ((Object)(object)bulbMat != (Object)null && bulbMat.HasProperty("_EmissionColor"))
				{
					bulbMat.SetColor("_EmissionColor", state ? (on * 1.1f) : (on * 0.08f));
				}
			}
			yield return (object)new WaitForSeconds(0.09f);
		}
		foreach (Material bulbMat2 in m_vis.BulbMats)
		{
			if ((Object)(object)bulbMat2 != (Object)null && bulbMat2.HasProperty("_EmissionColor"))
			{
				bulbMat2.SetColor("_EmissionColor", IdleBulbColor());
			}
		}
		m_celebrating = false;
	}

	private static Color IdleBulbColor()
	{
		//IL_0000: 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 SlotConfig.AccentColor * 0.12f;
	}

	private unsafe void Update()
	{
		//IL_0025: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_00b4: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)286) && (Object)(object)Player.localPlayer != (Object)null)
		{
			Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 1.2f;
			val.y = ((Component)this).transform.position.y;
			MethodInfo method = typeof(Player).GetMethod("Teleport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(Player.localPlayer, new object[2]
				{
					val,
					-((Component)this).transform.forward
				});
			}
			Vector3 val2 = val;
			Debug.Log((object)("[CWSlotMachine] F5 teleport -> " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString()));
		}
		if (!m_refinedOrientation)
		{
			if (Time.time - m_spawnTime < 6f)
			{
				TryRefineOrientation();
			}
			else
			{
				Debug.Log((object)"[CWSlotMachine] refine window closed without reposition");
				m_refinedOrientation = true;
			}
		}
		if (m_vis == null || !SlotConfig.EnableLights || m_celebrating)
		{
			return;
		}
		float num = Time.time * Mathf.Max(0.5f, SlotConfig.LightSpeed);
		int count = m_vis.BulbMats.Count;
		for (int i = 0; i < count; i++)
		{
			Material val3 = m_vis.BulbMats[i];
			if (!((Object)(object)val3 == (Object)null) && val3.HasProperty("_EmissionColor"))
			{
				bool flag = Mathf.Repeat((float)i - num, (float)count) < 1.5f;
				val3.SetColor("_EmissionColor", flag ? (SlotConfig.AccentColor * 0.9f) : IdleBulbColor());
			}
		}
	}

	private unsafe void TryRefineOrientation()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: 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_0119: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: 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_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: 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_0257: 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_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			ShopHandler instance = ShopHandler.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				if (!m_loggedNoShop)
				{
					m_loggedNoShop = true;
					Debug.Log((object)"[CWSlotMachine] refine: no ShopHandler yet");
				}
				return;
			}
			Vector3 val = Vector3.back;
			ShopViewScreen componentInChildren = ((Component)instance).GetComponentInChildren<ShopViewScreen>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				if (!m_loggedScreen)
				{
					m_loggedScreen = true;
					Camera main = Camera.main;
					Debug.Log((object)("[CWSlotMachine] refine: shop screen fwd=" + ((object)((Component)componentInChildren).transform.forward/*cast due to .constrained prefix*/).ToString() + " pos=" + ((object)((Component)componentInChildren).transform.position/*cast due to .constrained prefix*/).ToString() + (((Object)(object)main != (Object)null) ? (" | cam pos=" + ((object)((Component)main).transform.position/*cast due to .constrained prefix*/).ToString() + " fwd=" + ((object)((Component)main).transform.forward/*cast due to .constrained prefix*/).ToString()) : " | no camera")));
				}
				if (Vector3.Distance(((Component)componentInChildren).transform.position, m_anchorPos) > 4f)
				{
					m_refinedOrientation = true;
					return;
				}
				val = -((Component)componentInChildren).transform.forward;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					m_refinedOrientation = true;
					return;
				}
				((Vector3)(ref val)).Normalize();
			}
			Vector3 position = ((Component)instance).transform.position;
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude > 0.01f)
			{
				((Vector3)(ref forward)).Normalize();
			}
			if (SlotConfig.PlacementMode != 0 || (!(Vector3.Distance(position, m_anchorPos) > 0.5f) && !(Vector3.Angle(forward, val) > 25f)))
			{
				m_refinedOrientation = true;
				return;
			}
			m_anchorPos = position;
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			Vector3 pos = position + val2 * SlotConfig.SideOffset + val * SlotConfig.FrontOffset;
			pos = SlotSpawner.AvoidObstacles(groundY: pos.y = SlotSpawner.GroundAt(position), pos: pos, selfRoot: ((Component)this).transform, keepClearOf: position, minDistFromCenter: 1.6f);
			((Component)this).transform.position = pos;
			((Component)this).transform.rotation = Quaternion.LookRotation(val);
			m_refinedOrientation = true;
			string[] obj = new string[5] { "[CWSlotMachine] refined placement to ", null, null, null, null };
			Vector3 val3 = pos;
			obj[1] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString();
			obj[2] = " (toCustomer ";
			val3 = val;
			obj[3] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString();
			obj[4] = ")";
			Debug.Log((object)string.Concat(obj));
		}
		catch (Exception ex)
		{
			Debug.Log((object)("[CWSlotMachine] orientation refine failed: " + ex.Message));
			m_refinedOrientation = true;
		}
	}

	private void PlaySound(AudioClip clip)
	{
		if (SlotConfig.EnableSounds && !((Object)(object)m_audio == (Object)null) && !((Object)(object)clip == (Object)null))
		{
			m_audio.PlayOneShot(clip, Mathf.Clamp01(SlotConfig.SoundVolume));
		}
	}

	private void PlayWhir(float dur)
	{
		if (SlotConfig.EnableSounds && !((Object)(object)m_audio == (Object)null))
		{
			m_audio.loop = true;
			m_audio.clip = SlotSounds.Whir;
			m_audio.Play();
			((MonoBehaviour)this).StartCoroutine(StopWhirAfter(dur));
		}
	}

	private IEnumerator StopWhirAfter(float d)
	{
		yield return (object)new WaitForSeconds(d);
		if ((Object)(object)m_audio != (Object)null)
		{
			m_audio.Stop();
			m_audio.loop = false;
			m_audio.clip = null;
		}
	}

	public void RefreshHover()
	{
		if (m_spinning)
		{
			m_hoverCache = "Slot machine — spinning...";
			return;
		}
		RoomStatsHolder roomStats = SurfaceNetworkHandler.RoomStats;
		long num = ((roomStats != null) ? roomStats.Money : 0);
		int currentBet = CurrentBet;
		m_hoverCache = ((num < currentBet) ? ("Slot machine — needs $" + currentBet + " (you have $" + num + ")") : ("Slot machine — spin for $" + currentBet));
	}

	public void OnConfigChanged()
	{
		//IL_0027: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (m_vis == null)
		{
			return;
		}
		if ((Object)(object)m_vis.BodyMat != (Object)null)
		{
			m_vis.BodyMat.color = SlotConfig.MachineColor;
		}
		if ((Object)(object)m_vis.AccentMat != (Object)null)
		{
			m_vis.AccentMat.color = SlotConfig.AccentColor;
			if (m_vis.AccentMat.HasProperty("_EmissionColor"))
			{
				m_vis.AccentMat.SetColor("_EmissionColor", SlotConfig.AccentColor * 0.35f);
			}
		}
		if ((Object)(object)m_audio != (Object)null)
		{
			m_audio.volume = Mathf.Clamp01(SlotConfig.SoundVolume);
		}
		RefreshHover();
	}
}
public class SlotVisuals
{
	public GameObject Root;

	public Transform[] Reels = (Transform[])(object)new Transform[3];

	public Transform LeverPivot;

	public List<Material> BulbMats = new List<Material>();

	public Material BodyMat;

	public Material AccentMat;

	public Material GoldMat;

	public Material DarkMat;

	public GameObject ChipRoot;

	public GameObject BetMinusBtn;

	public GameObject BetPlusBtn;

	public GameObject PayTablePanel;

	public GameObject PaySwitch;

	public const float PanelRetractedY = 1.2f;

	public const float PanelExtendedY = 2.55f;
}
public static class SlotModelBuilder
{
	public static readonly int[] ReelLayout = new int[12]
	{
		0, 2, 4, 1, 5, 3, 0, 4, 2, 5,
		1, 3
	};

	private const float ReelRadius = 0.155f;

	private const float SymbolRadius = 0.168f;

	private const float ReelY = 1.25f;

	private const float ReelZ = 0.16f;

	private static readonly float[] ReelX = new float[3] { -0.31f, 0f, 0.31f };

	private static Material s_gold;

	private static Material s_cherry;

	private static Material s_lemon;

	private static Material s_skull;

	private static Material s_eye;

	private static Material s_reel;

	private static Material s_dark;

	private static Material s_greenStem;

	public static int StripPos(int sym)
	{
		for (int i = 0; i < ReelLayout.Length; i++)
		{
			if (ReelLayout[i] == sym)
			{
				return i;
			}
		}
		return (sym % ReelLayout.Length + ReelLayout.Length) % ReelLayout.Length;
	}

	public static SlotVisuals Build()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: 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_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: 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_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_040c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0503: Unknown result type (might be due to invalid IL or missing references)
		//IL_0524: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0561: Unknown result type (might be due to invalid IL or missing references)
		//IL_0579: Unknown result type (might be due to invalid IL or missing references)
		//IL_0583: 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_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_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_063b: 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_069d: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0717: Unknown result type (might be due to invalid IL or missing references)
		//IL_072b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: Unknown result type (might be due to invalid IL or missing references)
		//IL_076a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0795: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_084a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0851: Expected O, but got Unknown
		//IL_087c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0892: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0912: Unknown result type (might be due to invalid IL or missing references)
		//IL_0937: Unknown result type (might be due to invalid IL or missing references)
		//IL_0965: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a4d: Expected O, but got Unknown
		//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a9f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0acb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0adf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b4b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b9f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
		//IL_09de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a05: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c29: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c50: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c6f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ccd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cdf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cf4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0da3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e07: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e75: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e89: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eb4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ec8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ef3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f07: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f64: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f84: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fb2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ff6: Unknown result type (might be due to invalid IL or missing references)
		//IL_1018: Unknown result type (might be due to invalid IL or missing references)
		//IL_103a: Unknown result type (might be due to invalid IL or missing references)
		//IL_105c: Unknown result type (might be due to invalid IL or missing references)
		//IL_107e: Unknown result type (might be due to invalid IL or missing references)
		//IL_10a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_10c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_10e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_1106: Unknown result type (might be due to invalid IL or missing references)
		//IL_1128: Unknown result type (might be due to invalid IL or missing references)
		//IL_114a: Unknown result type (might be due to invalid IL or missing references)
		//IL_116c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1186: Unknown result type (might be due to invalid IL or missing references)
		//IL_11b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_11ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_11e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_11e7: Expected O, but got Unknown
		//IL_120f: Unknown result type (might be due to invalid IL or missing references)
		//IL_122f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1245: Unknown result type (might be due to invalid IL or missing references)
		//IL_1272: Unknown result type (might be due to invalid IL or missing references)
		//IL_1299: Unknown result type (might be due to invalid IL or missing references)
		//IL_12ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_1303: Unknown result type (might be due to invalid IL or missing references)
		//IL_1317: Unknown result type (might be due to invalid IL or missing references)
		//IL_1342: Unknown result type (might be due to invalid IL or missing references)
		//IL_1356: Unknown result type (might be due to invalid IL or missing references)
		//IL_1381: Unknown result type (might be due to invalid IL or missing references)
		//IL_1395: Unknown result type (might be due to invalid IL or missing references)
		//IL_13c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_13d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_1438: Unknown result type (might be due to invalid IL or missing references)
		//IL_1451: Unknown result type (might be due to invalid IL or missing references)
		//IL_1475: Unknown result type (might be due to invalid IL or missing references)
		//IL_148e: Unknown result type (might be due to invalid IL or missing references)
		//IL_14b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_14cb: Unknown result type (might be due to invalid IL or missing references)
		SlotVisuals slotVisuals = new SlotVisuals();
		GameObject val = (slotVisuals.Root = new GameObject("CWSlotMachine"));
		Shader val2 = Shader.Find("Universal Render Pipeline/Lit");
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = Shader.Find("Standard");
		}
		slotVisuals.BodyMat = MakeLit(val2, SlotConfig.MachineColor, 0.08f, 0.3f);
		slotVisuals.AccentMat = MakeLit(val2, SlotConfig.AccentColor, 0.12f, 0.35f);
		EnableEmission(slotVisuals.AccentMat, SlotConfig.AccentColor * 0.22f);
		slotVisuals.GoldMat = MakeLit(val2, new Color(1f, 0.84f, 0.35f), 0.35f, 0.45f);
		EnableEmission(slotVisuals.GoldMat, new Color(1f, 0.72f, 0.18f) * 0.5f);
		slotVisuals.DarkMat = MakeLit(val2, new Color(0.09f, 0.09f, 0.1f), 0.3f, 0.6f);
		s_dark = slotVisuals.DarkMat;
		s_reel = MakeLit(val2, new Color(0.42f, 0.4f, 0.38f), 0.05f, 0.35f);
		s_gold = slotVisuals.GoldMat;
		s_cherry = MakeLit(val2, new Color(0.85f, 0.12f, 0.15f), 0.1f, 0.4f);
		EnableEmission(s_cherry, new Color(0.85f, 0.1f, 0.12f) * 0.25f);
		s_lemon = MakeLit(val2, new Color(0.95f, 0.85f, 0.15f), 0.1f, 0.4f);
		s_skull = MakeLit(val2, new Color(0.92f, 0.92f, 0.9f), 0.05f, 0.5f);
		s_eye = MakeLit(val2, new Color(0.05f, 0.05f, 0.05f), 0f, 0.8f);
		PrimBox("Pedestal", val.transform, new Vector3(0f, 0.07f, 0.05f), new Vector3(1.18f, 0.14f, 0.7f), slotVisuals.DarkMat);
		PrimBox("Body", val.transform, new Vector3(0f, 0.9f, 0f), new Vector3(1.12f, 1.55f, 0.55f), slotVisuals.BodyMat);
		PrimBox("Band", val.transform, new Vector3(0f, 1.63f, 0f), new Vector3(1.14f, 0.08f, 0.57f), slotVisuals.AccentMat);
		Material mat = MakeLit(val2, SlotConfig.MachineColor * 0.62f, 0.15f, 0.5f);
		PrimBox("SidePanelL", val.transform, new Vector3(-0.575f, 0.92f, 0f), new Vector3(0.035f, 1.42f, 0.5f), mat);
		PrimBox("SidePanelR", val.transform, new Vector3(0.575f, 0.92f, 0f), new Vector3(0.035f, 1.42f, 0.5f), mat);
		PrimBox("BaseSkirt", val.transform, new Vector3(0f, 0.16f, 0f), new Vector3(1.18f, 0.17f, 0.6f), slotVisuals.DarkMat);
		PrimBox("TrimFL", val.transform, new Vector3(-0.545f, 0.9f, 0.26f), new Vector3(0.06f, 1.55f, 0.06f), slotVisuals.DarkMat);
		PrimBox("TrimFR", val.transform, new Vector3(0.545f, 0.9f, 0.26f), new Vector3(0.06f, 1.55f, 0.06f), slotVisuals.DarkMat);
		PrimBox("TrimBL", val.transform, new Vector3(-0.545f, 0.9f, -0.26f), new Vector3(0.06f, 1.55f, 0.06f), slotVisuals.DarkMat);
		PrimBox("TrimBR", val.transform, new Vector3(0.545f, 0.9f, -0.26f), new Vector3(0.06f, 1.55f, 0.06f), slotVisuals.DarkMat);
		PrimBox("DoorInset", val.transform, new Vector3(0f, 0.78f, 0.285f), new Vector3(0.95f, 0.4f, 0.03f), mat);
		PrimBox("DoorGlow", val.transform, new Vector3(0f, 0.78f, 0.3f), new Vector3(0.82f, 0.3f, 0.02f), slotVisuals.AccentMat);
		Material mat2 = MakeLit(val2, new Color(0.82f, 0.13f, 0.11f), 0.1f, 0.55f);
		Material mat3 = MakeLit(val2, new Color(0.13f, 0.62f, 0.22f), 0.1f, 0.55f);
		Material val3 = MakeLit(val2, Color.white, 0f, 0.6f);
		EnableEmission(val3, Color.white * 0.25f);
		slotVisuals.BetMinusBtn = PrimBox("BetMinusBtn", val.transform, new Vector3(0.24f, 0.78f, 0.325f), new Vector3(0.17f, 0.17f, 0.06f), mat2);
		slotVisuals.BetPlusBtn = PrimBox("BetPlusBtn", val.transform, new Vector3(-0.24f, 0.78f, 0.325f), new Vector3(0.17f, 0.17f, 0.06f), mat3);
		PrimBox("MinusGlyph", val.transform, new Vector3(0.24f, 0.78f, 0.36f), new Vector3(0.1f, 0.026f, 0.02f), val3);
		PrimBox("PlusGlyphH", val.transform, new Vector3(-0.24f, 0.78f, 0.36f), new Vector3(0.1f, 0.026f, 0.02f), val3);
		PrimBox("PlusGlyphV", val.transform, new Vector3(-0.24f, 0.78f, 0.36f), new Vector3(0.026f, 0.1f, 0.02f), val3);
		PrimBox("ReelBack", val.transform, new Vector3(0f, 1.25f, 0.02f), new Vector3(1f, 0.46f, 0.06f), slotVisuals.DarkMat);
		PrimBox("FrameTop", val.transform, new Vector3(0f, 1.515f, 0.29f), new Vector3(1.08f, 0.07f, 0.06f), slotVisuals.AccentMat);
		PrimBox("FrameBottom", val.transform, new Vector3(0f, 0.985f, 0.29f), new Vector3(1.08f, 0.07f, 0.06f), slotVisuals.AccentMat);
		PrimBox("FrameLeft", val.transform, new Vector3(-0.505f, 1.25f, 0.29f), new Vector3(0.07f, 0.6f, 0.06f), slotVisuals.AccentMat);
		PrimBox("FrameRight", val.transform, new Vector3(0.505f, 1.25f, 0.29f), new Vector3(0.07f, 0.6f, 0.06f), slotVisuals.AccentMat);
		MakeChevron("PaylineArrowL", val.transform, slotVisuals.GoldMat, -0.62f, 1);
		MakeChevron("PaylineArrowR", val.transform, slotVisuals.GoldMat, 0.62f, -1);
		for (int i = 0; i < 3; i++)
		{
			GameObject val4 = new GameObject("Reel" + i);
			val4.transform.parent = val.transform;
			val4.transform.localPosition = new Vector3(ReelX[i], 1.25f, 0.16f);
			PrimCyl("ReelDrum", val4.transform, Vector3.zero, 0.155f, 0.24f, s_reel).transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			PrimCyl("ReelCapL", val4.transform, new Vector3(-0.135f, 0f, 0f), 0.167f, 0.035f, slotVisuals.DarkMat).transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			PrimCyl("ReelCapR", val4.transform, new Vector3(0.135f, 0f, 0f), 0.167f, 0.035f, slotVisuals.DarkMat).transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			for (int j = 0; j < ReelLayout.Length; j++)
			{
				float num = (float)j * 30f * ((float)Math.PI / 180f);
				GameObject obj = MakeSymbol(ReelLayout[j], val4.transform, "Sym" + i + "_" + j);
				obj.transform.localPosition = new Vector3(0f, Mathf.Sin(num) * 0.168f, Mathf.Cos(num) * 0.168f);
				obj.transform.localRotation = Quaternion.LookRotation(new Vector3(0f, Mathf.Sin(num), Mathf.Cos(num)));
			}
			slotVisuals.Reels[i] = val4.transform;
		}
		GameObject val5 = new GameObject("PayTablePanel");
		val5.transform.parent = val.transform;
		val5.transform.localPosition = new Vector3(0f, 1.2f, -0.06f);
		PrimBox("PayBoard", val5.transform, Vector3.zero, new Vector3(0.92f, 0.68f, 0.04f), slotVisuals.DarkMat);
		PrimBox("PayFrameT", val5.transform, new Vector3(0f, 0.36f, 0f), new Vector3(0.98f, 0.05f, 0.06f), slotVisuals.GoldMat);
		PrimBox("PayFrameB", val5.transform, new Vector3(0f, -0.36f, 0f), new Vector3(0.98f, 0.05f, 0.06f), slotVisuals.GoldMat);
		PrimBox("PayFrameL", val5.transform, new Vector3(-0.47f, 0f, 0f), new Vector3(0.05f, 0.72f, 0.06f), slotVisuals.GoldMat);
		PrimBox("PayFrameR", val5.transform, new Vector3(0.47f, 0f, 0f), new Vector3(0.05f, 0.72f, 0.06f), slotVisuals.GoldMat);
		PrimBox("PayHeader", val5.transform, new Vector3(0f, 0.26f, 0.012f), new Vector3(0.9f, 0.15f, 0.05f), slotVisuals.AccentMat);
		Font builtinResource = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
		if ((Object)(object)builtinResource == (Object)null)
		{
			builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}
		if ((Object)(object)builtinResource != (Object)null)
		{
			GameObject val6 = new GameObject("PayTitle");
			val6.transform.parent = val5.transform;
			val6.transform.localPosition = new Vector3(0f, 0.26f, 0.05f);
			val6.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			TextMesh obj2 = val6.AddComponent<TextMesh>();
			obj2.font = builtinResource;
			obj2.text = "PAYTABLE";
			obj2.characterSize = 0.062f;
			obj2.anchor = (TextAnchor)4;
			obj2.alignment = (TextAlignment)1;
			obj2.color = new Color(1f, 0.84f, 0.35f);
			GameObject val7 = new GameObject("PayBody");
			val7.transform.parent = val5.transform;
			val7.transform.localPosition = new Vector3(0f, -0.07f, 0.05f);
			val7.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			TextMesh obj3 = val7.AddComponent<TextMesh>();
			obj3.font = builtinResource;
			obj3.text = "777=50x  BELL=20x\nCHERRY=11x LEMON=9x\nBAR=7x\nPAIRS: 7=6x BELL=3x\nCHR/LMN=2x BAR=1.2x\nNO MATCH=LOSE BET";
			obj3.characterSize = 0.042f;
			obj3.anchor = (TextAnchor)4;
			obj3.alignment = (TextAlignment)1;
			obj3.color = new Color(1f, 0.95f, 0.8f);
		}
		else
		{
			Debug.Log((object)"[CWSlotMachine] no builtin font available for paytable text");
		}
		Material baseMat = MakeLit(val2, Color.white, 0f, 0.3f);
		AddBulb(slotVisuals, val5.transform, baseMat, new Vector3(-0.47f, 0.36f, 0.05f));
		AddBulb(slotVisuals, val5.transform, baseMat, new Vector3(0.47f, 0.36f, 0.05f));
		slotVisuals.PayTablePanel = val5;
		slotVisuals.PaySwitch = PrimBox("PaySwitch", val.transform, new Vector3(-0.62f, 1.72f, 0.18f), new Vector3(0.07f, 0.16f, 0.16f), slotVisuals.GoldMat);
		PrimBox("Marquee", val.transform, new Vector3(0f, 1.87f, 0f), new Vector3(1.24f, 0.42f, 0.5f), slotVisuals.AccentMat);
		PrimBox("MarqueeBorder", val.transform, new Vector3(0f, 1.87f, 0.255f), new Vector3(1.16f, 0.34f, 0.02f), slotVisuals.DarkMat);
		PrimBox("MarqueeEdgeL", val.transform, new Vector3(-0.63f, 1.87f, 0f), new Vector3(0.03f, 0.44f, 0.52f), slotVisuals.GoldMat);
		PrimBox("MarqueeEdgeR", val.transform, new Vector3(0.63f, 1.87f, 0f), new Vector3(0.03f, 0.44f, 0.52f), slotVisuals.GoldMat);
		for (int k = 0; k < 3; k++)
		{
			GameObject obj4 = MakeSymbol(0, val.transform, "Marquee7_" + k);
			obj4.transform.localPosition = new Vector3((float)(k - 1) * 0.34f, 1.87f, 0.27f);
			obj4.transform.localScale = Vector3.one * 2.1f;
		}
		Material baseMat2 = MakeLit(val2, Color.white, 0f, 0.3f);
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.55f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.33f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.11f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.11f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.33f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.55f, 2.115f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.55f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.33f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.11f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.11f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.33f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.55f, 1.625f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(-0.655f, 1.87f, 0.26f));
		AddBulb(slotVisuals, val.transform, baseMat2, new Vector3(0.655f, 1.87f, 0.26f));
		Material mat4 = MakeLit(val2, new Color(0.85f, 0.87f, 0.9f), 0.9f, 0.65f);
		PrimBox("LeverBracket", val.transform, new Vector3(-0.585f, 1.1f, 0.05f), new Vector3(0.14f, 0.26f, 0.26f), slotVisuals.DarkMat);
		GameObject val8 = new GameObject("LeverPivot");
		val8.transform.parent = val.transform;
		val8.transform.localPosition = new Vector3(-0.66f, 1.1f, 0.05f);
		val8.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		PrimSphere("LeverHub", val8.transform, Vector3.zero, 0.06f, mat4);
		PrimCyl("LeverShaft", val8.transform, new Vector3(0f, 0.18f, 0f), 0.034f, 0.36f, mat4);
		Material mat5 = MakeLit(val2, new Color(0.9f, 0.15f, 0.12f), 0.1f, 0.5f);
		PrimSphere("LeverKnob", val8.transform, new Vector3(0f, 0.4f, 0f), 0.075f, mat5);
		slotVisuals.LeverPivot = val8.transform;
		PrimBox("Tray", val.transform, new Vector3(0f, 0.5f, 0.3f), new Vector3(0.72f, 0.16f, 0.28f), slotVisuals.DarkMat);
		PrimBox("TrayLip", val.transform, new Vector3(0f, 0.59f, 0.42f), new Vector3(0.72f, 0.03f, 0.05f), slotVisuals.AccentMat);
		PrimBox("CoinSlotPlate", val.transform, new Vector3(0f, 0.5f, 0.45f), new Vector3(0.16f, 0.07f, 0.02f), slotVisuals.GoldMat);
		PrimBox("CoinSlot", val.transform, new Vector3(0f, 0.5f, 0.46f), new Vector3(0.1f, 0.016f, 0.02f), slotVisuals.DarkMat);
		Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true);
		foreach (Collider val9 in componentsInChildren)
		{
			if ((Object)(object)((Component)val9).gameObject != (Object)(object)val)
			{
				Object.Destroy((Object)(object)val9);
			}
		}
		if ((Object)(object)slotVisuals.BetMinusBtn != (Object)null)
		{
			BoxCollider obj5 = slotVisuals.BetMinusBtn.AddComponent<BoxCollider>();
			obj5.center = Vector3.zero;
			obj5.size = new Vector3(1.2f, 1.2f, 3f);
		}
		if ((Object)(object)slotVisuals.BetPlusBtn != (Object)null)
		{
			BoxCollider obj6 = slotVisuals.BetPlusBtn.AddComponent<BoxCollider>();
			obj6.center = Vector3.zero;
			obj6.size = new Vector3(1.2f, 1.2f, 3f);
		}
		if ((Object)(object)slotVisuals.PaySwitch != (Object)null)
		{
			BoxCollider obj7 = slotVisuals.PaySwitch.AddComponent<BoxCollider>();
			obj7.center = Vector3.zero;
			obj7.size = new Vector3(2f, 2f, 2f);
		}
		return slotVisuals;
	}

	private static void AddBulb(SlotVisuals vis, Transform parent, Material baseMat, Vector3 pos)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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_004a: Expected O, but got Unknown
		//IL_004b: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
		((Object)obj).name = "Bulb";
		obj.transform.parent = parent;
		obj.transform.localPosition = pos;
		obj.transform.localScale = Vector3.one * 0.06f;
		Material val = new Material(baseMat);
		EnableEmission(val, SlotConfig.AccentColor * 0.08f);
		obj.GetComponent<Renderer>().sharedMaterial = val;
		Light obj2 = obj.AddComponent<Light>();
		obj2.type = (LightType)2;
		obj2.range = 0.7f;
		obj2.intensity = 0.18f;
		obj2.color = new Color(1f, 0.85f, 0.6f);
		vis.BulbMats.Add(val);
	}

	private static GameObject MakeSymbol(int sym, Transform parent, string name)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_004c: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00ea: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.parent = parent;
		switch (sym)
		{
		case 0:
			PrimBox("bar", val.transform, new Vector3(0f, 0.045f, 0f), new Vector3(0.1f, 0.028f, 0.024f), s_gold);
			PrimBox("diag", val.transform, new Vector3(-0.012f, -0.012f, 0f), new Vector3(0.028f, 0.115f, 0.024f), s_gold).transform.localRotation = Quaternion.Euler(0f, 0f, 25f);
			break;
		case 1:
			PrimSphere("bell", val.transform, new Vector3(0f, 0.012f, 0f), 0.04f, s_gold).transform.localScale = new Vector3(0.085f, 0.07f, 0.085f);
			PrimBox("rim", val.transform, new Vector3(0f, -0.026f, 0f), new Vector3(0.095f, 0.014f, 0.095f), s_gold);
			PrimSphere("clapper", val.transform, new Vector3(0f, -0.045f, 0f), 0.014f, s_gold);
			break;
		case 2:
		{
			PrimSphere("c1", val.transform, new Vector3(-0.028f, -0.02f, 0f), 0.036f, s_cherry);
			PrimSphere("c2", val.transform, new Vector3(0.03f, -0.026f, 0f), 0.036f, s_cherry);
			GameObject obj = PrimBox("stem", val.transform, new Vector3(-0.005f, 0.035f, 0f), new Vector3(0.012f, 0.07f, 0.012f), s_skull);
			obj.transform.localRotation = Quaternion.Euler(0f, 0f, 20f);
			obj.GetComponent<Renderer>().sharedMaterial = MakeGreenStem();
			break;
		}
		case 3:
			PrimSphere("lemon", val.transform, Vector3.zero, 0.04f, s_lemon).transform.localScale = new Vector3(0.1f, 0.072f, 0.072f);
			break;
		case 4:
			PrimBox("bar", val.transform, Vector3.zero, new Vector3(0.115f, 0.05f, 0.028f), s_eye);
			break;
		default:
			PrimSphere("skull", val.transform, new Vector3(0f, 0.008f, 0f), 0.042f, s_skull);
			PrimBox("jaw", val.transform, new Vector3(0f, -0.035f, 0f), new Vector3(0.05f, 0.03f, 0.04f), s_skull);
			PrimSphere("eyeL", val.transform, new Vector3(-0.017f, 0.008f, 0.036f), 0.012f, s_eye);
			PrimSphere("eyeR", val.transform, new Vector3(0.017f, 0.008f, 0.036f), 0.012f, s_eye);
			break;
		}
		return val;
	}

	private static void MakeChevron(string name, Transform parent, Material mat, float x, int dir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0066: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.parent = parent;
		float num = x + (float)dir * 0.07f;
		float num2 = 0.11f;
		for (int i = -1; i <= 1; i += 2)
		{
			GameObject obj = PrimBox(name + ((i < 0) ? "_a" : "_b"), val.transform, new Vector3(num - (float)dir * 0.039f, 1.25f + (float)i * 0.039f, 0.3f), new Vector3(num2, 0.03f, 0.03f), mat);
			float num3 = ((dir > 0) ? ((i < 0) ? (-135f) : 135f) : ((i < 0) ? (-45f) : 45f));
			obj.transform.localRotation = Quaternion.Euler(0f, 0f, num3);
		}
	}

	private static Material MakeGreenStem()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)s_greenStem == (Object)null)
		{
			s_greenStem = MakeLit(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"), new Color(0.2f, 0.6f, 0.15f), 0f, 0.4f);
		}
		return s_greenStem;
	}

	private static GameObject PrimBox(string name, Transform parent, Vector3 pos, Vector3 size, Material mat)
	{
		//IL_001f: 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)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)obj).name = name;
		obj.transform.parent = parent;
		obj.transform.localPosition = pos;
		obj.transform.localScale = size;
		obj.GetComponent<Renderer>().sharedMaterial = mat;
		return obj;
	}

	private static GameObject PrimSphere(string name, Transform parent, Vector3 pos, float radius, Material mat)
	{
		//IL_001f: 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)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
		((Object)obj).name = name;
		obj.transform.parent = parent;
		obj.transform.localPosition = pos;
		obj.transform.localScale = Vector3.one * (radius * 2f);
		obj.GetComponent<Renderer>().sharedMaterial = mat;
		return obj;
	}

	private static GameObject PrimCyl(string name, Transform parent, Vector3 pos, float radius, float height, Material mat)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
		((Object)obj).name = name;
		obj.transform.parent = parent;
		obj.transform.localPosition = pos;
		obj.transform.localScale = new Vector3(radius * 2f, height / 2f, radius * 2f);
		obj.GetComponent<Renderer>().sharedMaterial = mat;
		return obj;
	}

	private static Material MakeLit(Shader shader, Color color, float metallic, float smoothness)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		Material val = new Material(shader);
		val.color = color;
		if (val.HasProperty("_Metallic"))
		{
			val.SetFloat("_Metallic", metallic);
		}
		if (val.HasProperty("_Glossiness"))
		{
			val.SetFloat("_Glossiness", smoothness);
		}
		if (val.HasProperty("_Smoothness"))
		{
			val.SetFloat("_Smoothness", smoothness);
		}
		return val;
	}

	private static void EnableEmission(Material m, Color c)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		m.EnableKeyword("_EMISSION");
		if (m.HasProperty("_EmissionColor"))
		{
			m.SetColor("_EmissionColor", c);
		}
	}
}
public class SlotNet : MonoBehaviour
{
	public static SlotNet Current;

	private PhotonView m_view;

	private float m_lastSpinAt = -99f;

	private void Awake()
	{
		Current = this;
		m_view = ((Component)this).GetComponent<PhotonView>();
	}

	private void OnDestroy()
	{
		if ((Object)(object)Current == (Object)(object)this)
		{
			Current = null;
		}
	}

	public void RequestSpin(int actorNr, string actorName, int bet)
	{
		if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
		{
			ProcessSpinRequest(actorNr, actorName, bet);
		}
		else if ((Object)(object)m_view != (Object)null)
		{
			m_view.RPC("SlotRPCM_Spin", (RpcTarget)2, new object[3] { actorNr, actorName, bet });
		}
	}

	[PunRPC]
	private void SlotRPCM_Spin(int actorNr, string actorName, int bet)
	{
		ProcessSpinRequest(actorNr, actorName, bet);
	}

	private void ProcessSpinRequest(int actorNr, string actorName, int bet)
	{
		if (Time.time - m_lastSpinAt < 0.8f)
		{
			SendResult(actorNr, actorName, 0, 0, 0, bet, 0, -1);
			return;
		}
		m_lastSpinAt = Time.time;
		RoomStatsHolder roomStats = SurfaceNetworkHandler.RoomStats;
		bool flag = SlotConfig.BetOptions != null && SlotConfig.BetOptions.Contains(bet);
		if (roomStats == null || !flag || roomStats.Money < bet)
		{
			SendResult(actorNr, actorName, 0, 0, 0, bet, 0, -1);
			return;
		}
		SlotResolver.Result result = SlotResolver.Resolve(bet);
		roomStats.RemoveMoney(bet);
		if (result.Payout > 0)
		{
			roomStats.AddMoney(result.Payout);
		}
		SendResult(actorNr, actorName, result.R1, result.R2, result.R3, bet, result.Payout, result.Tier);
	}

	private void SendResult(int actorNr, string actorName, int r1, int r2, int r3, int bet, int payout, int tier)
	{
		if (PhotonNetwork.InRoom && (Object)(object)m_view != (Object)null)
		{
			m_view.RPC("SlotRPCA_Result", (RpcTarget)0, new object[8] { actorNr, actorName, r1, r2, r3, bet, payout, tier });
		}
		else if ((Object)(object)SlotMachineController.Instance != (Object)null)
		{
			SlotMachineController.Instance.OnResult(actorNr, actorName, r1, r2, r3, bet, payout, tier);
		}
	}

	[PunRPC]
	private void SlotRPCA_Result(int actorNr, string actorName, int r1, int r2, int r3, int bet, int payout, int tier)
	{
		if ((Object)(object)SlotMachineController.Instance != (Object)null)
		{
			SlotMachineController.Instance.OnResult(actorNr, actorName, r1, r2, r3, bet, payout, tier);
		}
	}
}
[HarmonyPatch(typeof(SurfaceNetworkHandler), "Awake")]
public static class SlotSpawnPatch
{
	[HarmonyPostfix]
	public static void Postfix()
	{
		try
		{
			SlotSpawner.TrySpawn();
		}
		catch (Exception ex)
		{
			Debug.Log((object)("[CWSlotMachine] spawn failed: " + ex));
		}
	}
}
[HarmonyPatch(typeof(InteractionUI), "SetData")]
public static class InteractionUIRefreshPatch
{
	private sealed class LabelCache
	{
		public string Text;
	}

	private static readonly ConditionalWeakTable<InteractionUI, LabelCache> m_cache = new ConditionalWeakTable<InteractionUI, LabelCache>();

	[HarmonyPostfix]
	public static void Postfix(InteractionUI __instance, Interactable interactable)
	{
		if (!((Object)(object)interactable == (Object)null) && !((Object)(object)__instance.m_text == (Object)null))
		{
			string hoverText = interactable.hoverText;
			if (!m_cache.TryGetValue(__instance, out var value))
			{
				value = new LabelCache();
				m_cache.Add(__instance, value);
			}
			if (!(value.Text == hoverText))
			{
				value.Text = hoverText;
				((TMP_Text)__instance.m_text).text = hoverText;
			}
		}
	}
}
public static class SlotSpawner
{
	public unsafe static void TrySpawn()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00b7: 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_00eb: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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_00d3: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: 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_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)SlotMachineController.Instance != (Object)null) && !((Object)(object)Object.FindFirstObjectByType<SlotMachineController>() != (Object)null))
		{
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(-0.41f, 0f, 12.91f);
			GameObject val = GameObject.Find("ShopV2");
			if ((Object)(object)val != (Object)null)
			{
				position = val.transform.position;
			}
			Vector3 val2;
			float num;
			if (SlotConfig.PlacementMode == 1)
			{
				val2 = SlotConfig.ManualPosition;
				num = SlotConfig.ManualRotationY;
			}
			else
			{
				Vector3 back = Vector3.back;
				Vector3 val3 = Vector3.Cross(Vector3.up, back);
				val2 = position + val3 * SlotConfig.SideOffset + back * SlotConfig.FrontOffset;
				Quaternion val4 = Quaternion.LookRotation(back);
				num = ((Quaternion)(ref val4)).eulerAngles.y;
			}
			float groundY = (val2.y = GroundAt(position));
			if (SlotConfig.PlacementMode == 0)
			{
				val2 = AvoidObstacles(val2, groundY, null, position, 1.6f);
			}
			GameObject val5 = new GameObject("CWSlotMachine");
			val5.transform.position = val2;
			val5.transform.rotation = Quaternion.Euler(0f, num, 0f);
			int num2 = LayerMask.NameToLayer("Interactable");
			Interactable val6 = Object.FindFirstObjectByType<Interactable>();
			if ((Object)(object)val6 != (Object)null)
			{
				num2 = ((Component)val6).gameObject.layer;
			}
			if (num2 < 0)
			{
				num2 = val5.layer;
			}
			val5.layer = num2;
			SlotMachineController.PendingAnchor = position;
			BoxCollider obj = val5.AddComponent<BoxCollider>();
			obj.center = new Vector3(-0.05f, 1.05f, 0.1f);
			obj.size = new Vector3(1.35f, 2.15f, 0.9f);
			val5.AddComponent<SlotMachineController>();
			Transform[] componentsInChildren = val5.GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = num2;
			}
			GameObject val7 = (((Object)(object)SurfaceNetworkHandler.Instance != (Object)null) ? ((Component)SurfaceNetworkHandler.Instance).gameObject : null);
			if ((Object)(object)val7 != (Object)null && (Object)(object)val7.GetComponent<SlotNet>() == (Object)null)
			{
				val7.AddComponent<SlotNet>();
			}
			string[] obj2 = new string[7] { "[CWSlotMachine] spawned at ", null, null, null, null, null, null };
			Vector3 val8 = val2;
			obj2[1] = ((object)(*(Vector3*)(&val8))/*cast due to .constrained prefix*/).ToString();
			obj2[2] = " (groundY ";
			obj2[3] = groundY.ToString("F2");
			obj2[4] = ", layer ";
			obj2[5] = LayerMask.LayerToName(num2);
			obj2[6] = ")";
			Debug.Log((object)string.Concat(obj2));
		}
	}

	public static float GroundAt(Vector3 anchor)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(anchor + Vector3.up * 8f, Vector3.down, ref val, 20f))
		{
			return ((RaycastHit)(ref val)).point.y;
		}
		return anchor.y;
	}

	public static Vector3 AvoidObstacles(Vector3 pos, float groundY, Transform selfRoot = null, Vector3 keepClearOf = default(Vector3), float minDistFromCenter = 0f)
	{
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		float[] array = new float[3] { 0f, 0.7f, 1.3f };
		foreach (float num in array)
		{
			int num2 = ((num == 0f) ? 1 : 8);
			for (int j = 0; j < 2; j++)
			{
				bool flag = j == 0 && minDistFromCenter > 0f;
				for (int k = 0; k < num2; k++)
				{
					Vector3 val = pos;
					if (num > 0f)
					{
						float num3 = (float)k * 45f * ((float)Math.PI / 180f);
						val += new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * num;
					}
					if (IsClear(val, groundY, selfRoot) && (!flag || !(Vector3.Distance(keepClearOf, val) < minDistFromCenter)))
					{
						return SnapToGround(val, groundY, selfRoot);
					}
				}
				if (!flag)
				{
					break;
				}
			}
		}
		pos.y = groundY;
		return pos;
	}

	private static bool IsClear(Vector3 p, float groundY, Transform selfRoot)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[8];
		int num = Physics.RaycastNonAlloc(p + Vector3.up * 8f, Vector3.down, array, 20f);
		float num2 = float.MinValue;
		for (int i = 0; i < num; i++)
		{
			if ((!((Object)(object)selfRoot != (Object)null) || !IsSelf(((Component)((RaycastHit)(ref array[i])).collider).transform, selfRoot)) && ((RaycastHit)(ref array[i])).point.y > num2)
			{
				num2 = ((RaycastHit)(ref array[i])).point.y;
			}
		}
		if (num2 == float.MinValue)
		{
			return true;
		}
		return num2 <= groundY + 0.45f;
	}

	private static Vector3 SnapToGround(Vector3 p, float groundY, Transform selfRoot)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[8];
		int num = Physics.RaycastNonAlloc(p + Vector3.up * 8f, Vector3.down, array, 20f);
		float num2 = float.MinValue;
		for (int i = 0; i < num; i++)
		{
			if ((!((Object)(object)selfRoot != (Object)null) || !IsSelf(((Component)((RaycastHit)(ref array[i])).collider).transform, selfRoot)) && ((RaycastHit)(ref array[i])).point.y > num2)
			{
				num2 = ((RaycastHit)(ref array[i])).point.y;
			}
		}
		p.y = ((num2 == float.MinValue) ? groundY : num2);
		return p;
	}

	private static bool IsSelf(Transform t, Transform root)
	{
		if (!((Object)(object)t == (Object)(object)root))
		{
			if ((Object)(object)t != (Object)null && (Object)(object)root != (Object)null)
			{
				return t.IsChildOf(root);
			}
			return false;
		}
		return true;
	}
}
public static class SlotResolver
{
	public struct Result
	{
		public int R1;

		public int R2;

		public int R3;

		public int Payout;

		public int Tier;

		public Result(int r1, int r2, int r3, int payout, int tier)
		{
			R1 = r1;
			R2 = r2;
			R3 = r3;
			Payout = payout;
			Tier = tier;
		}
	}

	public static readonly string[] SymbolNames = new string[6] { "7", "bell", "cherry", "lemon", "bar", "skull" };

	public static Result Resolve(int bet)
	{
		int num = WeightedDraw(0);
		int num2 = WeightedDraw(1);
		int num3 = WeightedDraw(2);
		float num4;
		int tier;
		if (num == num2 && num2 == num3)
		{
			switch (num)
			{
			case 0:
				num4 = SlotConfig.JackpotMultiplier;
				tier = 0;
				break;
			case 1:
				num4 = SlotConfig.BellsMultiplier;
				tier = 1;
				break;
			case 2:
				num4 = SlotConfig.CherryMultiplier;
				tier = 1;
				break;
			case 3:
				num4 = SlotConfig.LemonMultiplier;
				tier = 1;
				break;
			case 4:
				num4 = SlotConfig.BarMultiplier;
				tier = 1;
				break;
			default:
				num4 = 0f;
				tier = 5;
				break;
			}
		}
		else
		{
			int num5 = -1;
			if (num == num2)
			{
				num5 = num;
			}
			else if (num2 == num3)
			{
				num5 = num2;
			}
			else if (num == num3)
			{
				num5 = num;
			}
			if (num5 >= 0)
			{
				num4 = SlotConfig.PairMult(num5);
				tier = 2;
			}
			else
			{
				num4 = 0f;
				tier = 3;
			}
		}
		int num6 = Mathf.RoundToInt((float)bet * num4);
		if (num6 > SlotConfig.MaxPayout)
		{
			num6 = SlotConfig.MaxPayout;
		}
		if (num6 < 0)
		{
			num6 = 0;
		}
		return new Result(num, num2, num3, num6, tier);
	}

	private static int WeightedDraw(int reel)
	{
		int[] array = SlotConfig.ReelWeights[reel];
		int num = 0;
		for (int i = 0; i < array.Length; i++)
		{
			num += Mathf.Max(0, array[i]);
		}
		if (num <= 0)
		{
			return Random.Range(0, array.Length);
		}
		int num2 = Random.Range(0, num);
		int num3 = 0;
		for (int j = 0; j < array.Length; j++)
		{
			num3 += Mathf.Max(0, array[j]);
			if (num2 < num3)
			{
				return j;
			}
		}
		return array.Length - 1;
	}

	public static string OddsSummary()
	{
		double num = 0.0;
		double num2 = 0.0;
		double num3 = 0.0;
		for (int i = 0; i < 6; i++)
		{
			for (int j = 0; j < 6; j++)
			{
				for (int k = 0; k < 6; k++)
				{
					double num4 = P(i, 0) * P(j, 1) * P(k, 2);
					double num5;
					if (i != j || j != k)
					{
						num5 = ((i != j && j != k && i != k) ? 0.0 : ((double)SlotConfig.PairMult((i == j) ? i : ((j == k) ? j : i))));
					}
					else
					{
						switch (i)
						{
						case 0:
							num5 = SlotConfig.JackpotMultiplier;
							num3 += num4;
							break;
						case 1:
							num5 = SlotConfig.BellsMultiplier;
							break;
						case 2:
							num5 = SlotConfig.CherryMultiplier;
							break;
						case 3:
							num5 = SlotConfig.LemonMultiplier;
							break;
						case 4:
							num5 = SlotConfig.BarMultiplier;
							break;
						default:
							num5 = 0.0;
							break;
						}
					}
					num += num4 * num5;
					if (num5 > 0.0)
					{
						num2 += num4;
					}
				}
			}
		}
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append("paytable RTP ").Append(Format(num * 100.0)).Append("%, win chance ")
			.Append(Format(num2 * 100.0))
			.Append("%, jackpot chance ")
			.Append(Format(num3 * 100.0))
			.Append("%");
		for (int l = 0; l < 3; l++)
		{
			stringBuilder.Append(" | reel").Append(l + 1).Append(": ");
			int[] array = SlotConfig.ReelWeights[l];
			int num6 = 0;
			for (int m = 0; m < array.Length; m++)
			{
				num6 += Math.Max(0, array[m]);