Decompiled source of ShopRoulette v1.0.0

ShopRoulette.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Adir")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShopRoulette")]
[assembly: AssemblyTitle("ShopRoulette")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute(string assemblyName) : Attribute()
	{
		public string AssemblyName { get; } = assemblyName;
	}
}
namespace ShopRoulette
{
	internal static class Chips
	{
		public const float Radius = 0.026f;

		public const float Height = 0.0055f;

		public static readonly int[] Values = new int[5] { 1, 5, 10, 25, 100 };

		public static readonly Color[] Colors = (Color[])(object)new Color[5]
		{
			new Color(0.85f, 0.85f, 0.82f),
			new Color(0.75f, 0.08f, 0.1f),
			new Color(0.1f, 0.25f, 0.75f),
			new Color(0.1f, 0.55f, 0.2f),
			new Color(0.08f, 0.08f, 0.08f)
		};

		private static Mesh? mesh;

		public static Mesh Mesh
		{
			get
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: 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_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: 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_0197: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)mesh))
				{
					return mesh;
				}
				MeshBuilder meshBuilder = new MeshBuilder();
				int vertexCount = meshBuilder.VertexCount;
				Vector3 val = default(Vector3);
				for (int i = 0; i <= 28; i++)
				{
					float num = (float)i / 28f * MathF.PI * 2f;
					((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
					meshBuilder.Add(val * 0.026f, val, new Vector2((float)i / 28f, 0.01f));
					meshBuilder.Add(val * 0.026f + Vector3.up * 0.0055f, val, new Vector2((float)i / 28f, 0.11f));
				}
				for (int j = 0; j < 28; j++)
				{
					int num2 = vertexCount + j * 2;
					meshBuilder.Quad(0, num2, num2 + 1, num2 + 3, num2 + 2);
				}
				bool[] array = new bool[2] { true, false };
				foreach (bool num3 in array)
				{
					float num4 = (num3 ? 0.0055f : 0f);
					Vector3 n = (num3 ? Vector3.up : Vector3.down);
					int a = meshBuilder.Add(new Vector3(0f, num4, 0f), n, new Vector2(0.5f, 0.56f));
					int vertexCount2 = meshBuilder.VertexCount;
					for (int l = 0; l <= 28; l++)
					{
						float num5 = (float)l / 28f * MathF.PI * 2f;
						float num6 = Mathf.Cos(num5);
						float num7 = Mathf.Sin(num5);
						meshBuilder.Add(new Vector3(num6 * 0.026f, num4, num7 * 0.026f), n, new Vector2(0.5f + num6 * 0.44f, 0.56f + num7 * 0.44f));
					}
					for (int m = 0; m < 28; m++)
					{
						meshBuilder.Tri(0, a, vertexCount2 + m, vertexCount2 + m + 1);
					}
				}
				mesh = meshBuilder.Build("Roulette Chip");
				return mesh;
			}
		}

		public static List<int> Breakdown(int amount)
		{
			List<int> list = new List<int>();
			int num = Values.Length - 1;
			while (num >= 0 && list.Count < 40)
			{
				while (amount >= Values[num] && list.Count < 40)
				{
					amount -= Values[num];
					list.Add(num);
				}
				num--;
			}
			return list;
		}

		public static GameObject Spawn(Transform parent, int denomIndex, Color owner)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			GameObject val = new GameObject("Chip");
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = Mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = Looks.Chip(denomIndex, owner);
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			return val;
		}
	}
	internal static class Looks
	{
		private static Shader? lit;

		private static Shader? overlay;

		private static TMP_FontAsset? font;

		private static readonly Dictionary<string, Material> cache = new Dictionary<string, Material>();

		public static Color Red = new Color(0.72f, 0.04f, 0.05f);

		public static Color Black = new Color(0.035f, 0.035f, 0.04f);

		public static Color Green = new Color(0.02f, 0.45f, 0.18f);

		public static Color Gold = new Color(1f, 0.76f, 0.33f);

		private static Texture2D? wood;

		private static readonly Dictionary<string, Texture2D> noise = new Dictionary<string, Texture2D>();

		private static readonly Dictionary<string, Material> chipMats = new Dictionary<string, Material>();

		public static Shader Lit
		{
			get
			{
				if (Object.op_Implicit((Object)(object)lit))
				{
					return lit;
				}
				lit = Shader.Find("Standard");
				if (!Object.op_Implicit((Object)(object)lit))
				{
					lit = (from m in Resources.FindObjectsOfTypeAll<Material>()
						select m.shader).FirstOrDefault((Func<Shader, bool>)((Shader s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name.StartsWith("Standard")));
				}
				if (!Object.op_Implicit((Object)(object)lit))
				{
					MeshRenderer obj = Object.FindObjectOfType<MeshRenderer>();
					object obj2;
					if (obj == null)
					{
						obj2 = null;
					}
					else
					{
						Material sharedMaterial = ((Renderer)obj).sharedMaterial;
						obj2 = ((sharedMaterial != null) ? sharedMaterial.shader : null);
					}
					lit = (Shader?)obj2;
				}
				ManualLogSource logger = ShopRoulette.Logger;
				Shader? obj3 = lit;
				logger.LogInfo((object)("Using shader " + (((obj3 != null) ? ((Object)obj3).name : null) ?? "none") + " for the table"));
				return lit;
			}
		}

		public static Shader Overlay
		{
			get
			{
				if (Object.op_Implicit((Object)(object)overlay))
				{
					return overlay;
				}
				overlay = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Unlit/Transparent");
				return overlay;
			}
		}

		public static TMP_FontAsset? Font
		{
			get
			{
				if (Object.op_Implicit((Object)(object)font))
				{
					return font;
				}
				TMP_Text val = (Object.op_Implicit((Object)(object)CurrencyUI.instance) ? ((Component)CurrencyUI.instance).GetComponent<TMP_Text>() : null);
				font = (Object.op_Implicit((Object)(object)val) ? val.font : null);
				if (!Object.op_Implicit((Object)(object)font))
				{
					font = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().FirstOrDefault();
				}
				return font;
			}
		}

		public static Material Mahogany => Make("mahogany", new Color(0.55f, 0.25f, 0.14f), 0f, 0.78f, (Texture?)(object)WoodTexture());

		public static Material DarkWood => Make("darkwood", new Color(0.3f, 0.13f, 0.07f), 0f, 0.7f, (Texture?)(object)WoodTexture());

		public static Material Brass => Make("brass", Gold, 1f, 0.82f);

		public static Material Chrome => Make("chrome", new Color(0.92f, 0.93f, 0.96f), 1f, 0.9f);

		public static Material Leather => Make("leather", new Color(0.09f, 0.045f, 0.035f), 0f, 0.55f, (Texture?)(object)NoiseTexture("leather", 0.12f, 64));

		public static Material Felt => Make("felt", new Color(0.09f, 0.42f, 0.2f), 0f, 0.08f, (Texture?)(object)NoiseTexture("felt", 0.18f, 256));

		public static Material PocketRed => Make("pocketred", Red, 0f, 0.55f);

		public static Material PocketBlack => Make("pocketblack", Black, 0f, 0.6f);

		public static Material PocketGreen => Make("pocketgreen", Green, 0f, 0.55f);

		public static Material Ball => Make("ball", new Color(0.97f, 0.96f, 0.92f), 0f, 0.93f, (Texture?)null, (Color?)new Color(0.18f, 0.18f, 0.17f));

		public static Material Shadow => Make("shadow", new Color(0.02f, 0.02f, 0.02f), 0f, 0.2f);

		public static Material Make(string key, Color color, float metallic, float gloss, Texture? tex = null, Color? emission = null)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003c: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (cache.TryGetValue(key, out Material value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = new Material(Lit)
			{
				name = "Roulette " + key,
				color = color
			};
			if (Object.op_Implicit((Object)(object)tex))
			{
				value.mainTexture = tex;
			}
			value.SetFloat("_Metallic", metallic);
			value.SetFloat("_Glossiness", gloss);
			if (emission.HasValue)
			{
				Color valueOrDefault = emission.GetValueOrDefault();
				value.EnableKeyword("_EMISSION");
				value.SetColor("_EmissionColor", valueOrDefault);
				value.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			cache[key] = value;
			return value;
		}

		public static Material MakeOverlay(string key, Color color)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (cache.TryGetValue(key, out Material value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = new Material(Overlay)
			{
				name = "Roulette " + key,
				color = color,
				renderQueue = 3100
			};
			cache[key] = value;
			return value;
		}

		public static Material ZoneMaterial(int zone)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			return (Material)(zone switch
			{
				0 => Make("zonered", Red * 0.95f, 0f, 0.25f, (Texture?)(object)NoiseTexture("felt", 0.18f, 256)), 
				1 => Make("zoneblack", new Color(0.06f, 0.06f, 0.07f), 0f, 0.25f, (Texture?)(object)NoiseTexture("felt", 0.18f, 256)), 
				_ => Make("zonegreen", new Color(0.03f, 0.6f, 0.26f), 0f, 0.25f, (Texture?)(object)NoiseTexture("felt", 0.18f, 256)), 
			});
		}

		public static Color ZoneColor(int zone)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(zone switch
			{
				0 => Red, 
				1 => Black, 
				_ => Green, 
			});
		}

		public static Color ZoneGlow(int zone)
		{
			//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_004c: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(zone switch
			{
				0 => new Color(1f, 0.25f, 0.2f), 
				1 => new Color(0.75f, 0.75f, 0.85f), 
				_ => new Color(0.2f, 1f, 0.45f), 
			});
		}

		public static Material Bulb(bool on)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!on)
			{
				return Make("bulboff", new Color(0.35f, 0.3f, 0.25f), 0f, 0.9f, (Texture?)null, (Color?)new Color(0.05f, 0.04f, 0.02f));
			}
			return Make("bulbon", new Color(1f, 0.9f, 0.6f), 0f, 0.9f, (Texture?)null, (Color?)new Color(2.2f, 1.6f, 0.7f));
		}

		public static Material Neon(string key, Color c)
		{
			//IL_000b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			return Make("neon" + key, c, 0f, 0.5f, null, c * 2.5f);
		}

		public static Texture2D WoodTexture()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)wood))
			{
				return wood;
			}
			wood = new Texture2D(512, 512, (TextureFormat)4, true)
			{
				name = "Roulette Wood",
				wrapMode = (TextureWrapMode)0
			};
			Color32[] array = (Color32[])(object)new Color32[262144];
			for (int i = 0; i < 512; i++)
			{
				for (int j = 0; j < 512; j++)
				{
					float num = (float)j / 512f;
					float num2 = (float)i / 512f;
					float num3 = Mathf.PerlinNoise(num * 3f, num2 * 0.8f) * 6f + Mathf.PerlinNoise(num * 11f, num2 * 2f) * 0.8f;
					float num4 = Mathf.Sin((num2 * 22f + num3) * MathF.PI);
					float num5 = 0.8f + 0.2f * num4 * num4;
					float num6 = Mathf.PerlinNoise(num * 180f, num2 * 14f);
					float num7 = num5 * (0.9f + 0.1f * num6);
					byte b = (byte)(255f * Mathf.Clamp01(num7));
					array[i * 512 + j] = new Color32(b, (byte)((float)(int)b * 0.92f), (byte)((float)(int)b * 0.86f), byte.MaxValue);
				}
			}
			wood.SetPixels32(array);
			wood.Apply(true);
			return wood;
		}

		public static Texture2D NoiseTexture(string key, float amount, int size)
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (noise.TryGetValue(key, out Texture2D value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = new Texture2D(size, size, (TextureFormat)4, true)
			{
				name = "Roulette " + key,
				wrapMode = (TextureWrapMode)0
			};
			Random random = new Random(key.GetHashCode());
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = Mathf.PerlinNoise((float)j * 0.05f, (float)i * 0.05f);
					float num2 = (float)random.NextDouble();
					float num3 = 1f - amount + amount * (0.55f * num2 + 0.45f * num);
					byte b = (byte)(255f * num3);
					array[i * size + j] = new Color32(b, b, b, byte.MaxValue);
				}
			}
			value.SetPixels32(array);
			value.Apply(true);
			noise[key] = value;
			return value;
		}

		public static Material Chip(int denomIndex, Color owner)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			string text = denomIndex + "|" + ColorUtility.ToHtmlStringRGB(owner);
			if (chipMats.TryGetValue(text, out Material value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			Color val = Chips.Colors[denomIndex];
			Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, true)
			{
				name = "Chip " + text,
				wrapMode = (TextureWrapMode)1
			};
			Color[] array = (Color[])(object)new Color[16384];
			Color val3 = default(Color);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = ((float)j + 0.5f) / 128f;
					float num2 = ((float)i + 0.5f) / 128f;
					if (num2 < 0.12f)
					{
						val3 = (Color)((Mathf.Repeat(num * 8f, 1f) < 0.35f) ? new Color(0.95f, 0.94f, 0.9f) : val);
					}
					else
					{
						float num3 = Vector2.Distance(new Vector2(num, num2), new Vector2(0.5f, 0.56f)) / 0.44f;
						float num4 = Mathf.Atan2(num2 - 0.56f, num - 0.5f) / (MathF.PI * 2f) + 0.5f;
						if (num3 > 0.82f)
						{
							val3 = (Color)((Mathf.Repeat(num4 * 8f, 1f) < 0.35f) ? new Color(0.95f, 0.94f, 0.9f) : val);
						}
						else if (num3 > 0.74f)
						{
							val3 = val * 0.8f;
						}
						else if (num3 > 0.5f)
						{
							val3 = owner;
						}
						else if (num3 > 0.45f)
						{
							((Color)(ref val3))..ctor(0.95f, 0.94f, 0.9f);
						}
						else
						{
							val3 = val * 1.1f;
						}
					}
					array[i * 128 + j] = val3;
				}
			}
			val2.SetPixels(array);
			val2.Apply(true);
			value = new Material(Lit)
			{
				name = "Chip " + text,
				color = Color.white,
				mainTexture = (Texture)(object)val2
			};
			value.SetFloat("_Metallic", 0f);
			value.SetFloat("_Glossiness", 0.55f);
			chipMats[text] = value;
			return value;
		}

		public static TextMeshPro Text(Transform parent, string name, Vector3 localPos, Quaternion localRot, float size, Color color, TextAlignmentOptions align = (TextAlignmentOptions)514, float width = 2f, float height = 0.5f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = localRot;
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			if (Object.op_Implicit((Object)(object)Font))
			{
				((TMP_Text)val2).font = Font;
			}
			((TMP_Text)val2).fontSize = size;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).enableWordWrapping = false;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(width, height);
			((TMP_Text)val2).richText = true;
			return val2;
		}
	}
	internal sealed class MeshBuilder
	{
		private readonly List<Vector3> verts = new List<Vector3>();

		private readonly List<Vector3> normals = new List<Vector3>();

		private readonly List<Vector2> uvs = new List<Vector2>();

		private readonly List<List<int>> subs = new List<List<int>>();

		public int VertexCount => verts.Count;

		public int Add(Vector3 v, Vector3 n, Vector2 uv)
		{
			//IL_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			verts.Add(v);
			normals.Add(n);
			uvs.Add(uv);
			return verts.Count - 1;
		}

		private List<int> Sub(int sub)
		{
			while (subs.Count <= sub)
			{
				subs.Add(new List<int>());
			}
			return subs[sub];
		}

		public void Tri(int sub, int a, int b, int c)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(verts[b] - verts[a], verts[c] - verts[a]);
			Vector3 val2 = normals[a] + normals[b] + normals[c];
			List<int> list = Sub(sub);
			if (Vector3.Dot(val, val2) >= 0f)
			{
				list.Add(a);
				list.Add(b);
				list.Add(c);
			}
			else
			{
				list.Add(a);
				list.Add(c);
				list.Add(b);
			}
		}

		public void Quad(int sub, int a, int b, int c, int d)
		{
			Tri(sub, a, b, c);
			Tri(sub, a, c, d);
		}

		public Mesh Build(string name)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			Mesh val = new Mesh
			{
				name = name
			};
			if (verts.Count > 65000)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.SetVertices(verts);
			val.SetNormals(normals);
			val.SetUVs(0, uvs);
			val.subMeshCount = Mathf.Max(1, subs.Count);
			for (int i = 0; i < subs.Count; i++)
			{
				val.SetTriangles(subs[i], i);
			}
			val.RecalculateBounds();
			val.RecalculateTangents();
			return val;
		}

		public void Lathe(int sub, IList<Vector2> profile, int segments, float a0 = 0f, float a1 = MathF.PI * 2f, float uvScale = 1f)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//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_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_0064: 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)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			int count = profile.Count;
			Vector2[] array = (Vector2[])(object)new Vector2[count];
			for (int i = 0; i < count; i++)
			{
				Vector2 val = Vector2.zero;
				if (i > 0)
				{
					val += SegNormal(profile[i - 1], profile[i]);
				}
				if (i < count - 1)
				{
					val += SegNormal(profile[i], profile[i + 1]);
				}
				array[i] = ((Vector2)(ref val)).normalized;
			}
			float[] array2 = new float[count];
			for (int j = 1; j < count; j++)
			{
				array2[j] = array2[j - 1] + Vector2.Distance(profile[j - 1], profile[j]);
			}
			int count2 = verts.Count;
			for (int k = 0; k <= segments; k++)
			{
				float num = Mathf.Lerp(a0, a1, (float)k / (float)segments);
				float num2 = Mathf.Cos(num);
				float num3 = Mathf.Sin(num);
				for (int l = 0; l < count; l++)
				{
					Vector2 val2 = profile[l];
					Vector2 val3 = array[l];
					Add(new Vector3(val2.x * num2, val2.y, val2.x * num3), new Vector3(val3.x * num2, val3.y, val3.x * num3), new Vector2((float)k / (float)segments * uvScale, array2[l] * uvScale));
				}
			}
			for (int m = 0; m < segments; m++)
			{
				for (int n = 0; n < count - 1; n++)
				{
					int num4 = count2 + m * count + n;
					int num5 = num4 + count;
					if (!(profile[n].x < 1E-05f) || !(profile[n + 1].x < 1E-05f))
					{
						Quad(sub, num4, num4 + 1, num5 + 1, num5);
					}
				}
			}
		}

		private static Vector2 SegNormal(Vector2 p0, Vector2 p1)
		{
			//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_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = p1 - p0;
			Vector2 normalized = ((Vector2)(ref val)).normalized;
			return new Vector2(0f - normalized.y, normalized.x);
		}

		public void LatheSharp(int sub, IList<Vector2> points, int segments, float a0 = 0f, float a1 = MathF.PI * 2f)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < points.Count - 1; i++)
			{
				Lathe(sub, (IList<Vector2>)(object)new Vector2[2]
				{
					points[i],
					points[i + 1]
				}, segments, a0, a1);
			}
		}

		public void Sweep(int sub, IList<Vector3> path, IList<Vector2> section, bool closedPath = true)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			int count = path.Count;
			int count2 = section.Count;
			Vector2[] array = (Vector2[])(object)new Vector2[count2];
			for (int i = 0; i < count2; i++)
			{
				Vector2 val = Vector2.zero;
				if (i > 0)
				{
					val += SegNormal(section[i - 1], section[i]);
				}
				if (i < count2 - 1)
				{
					val += SegNormal(section[i], section[i + 1]);
				}
				array[i] = ((Vector2)(ref val)).normalized;
			}
			int count3 = verts.Count;
			int num = (closedPath ? (count + 1) : count);
			float num2 = 0f;
			Vector3 val5 = default(Vector3);
			for (int j = 0; j < num; j++)
			{
				int num3 = j % count;
				Vector3 val2 = path[(num3 - 1 + count) % count];
				Vector3 val3 = path[(num3 + 1) % count];
				if (!closedPath)
				{
					if (num3 == 0)
					{
						val2 = path[num3];
					}
					if (num3 == count - 1)
					{
						val3 = path[num3];
					}
				}
				Vector3 val4 = val3 - val2;
				val4.y = 0f;
				((Vector3)(ref val4)).Normalize();
				((Vector3)(ref val5))..ctor(val4.z, 0f, 0f - val4.x);
				float num4 = 1f;
				Vector3 val7;
				if (closedPath || (num3 > 0 && num3 < count - 1))
				{
					Vector3 val6 = path[num3] - val2;
					val6.y = 0f;
					val7 = new Vector3(val6.z, 0f, 0f - val6.x);
					float num5 = Vector3.Dot(((Vector3)(ref val7)).normalized, val5);
					if (num5 > 0.3f)
					{
						num4 = 1f / num5;
					}
				}
				if (j > 0)
				{
					num2 += Vector3.Distance(path[(j - 1) % count], path[num3]);
				}
				for (int k = 0; k < count2; k++)
				{
					Vector2 val8 = section[k];
					Vector2 val9 = array[k];
					Vector3 v = path[num3] + val5 * (val8.x * num4) + Vector3.up * val8.y;
					val7 = val5 * val9.x + Vector3.up * val9.y;
					Add(v, ((Vector3)(ref val7)).normalized, new Vector2(num2 * 2f, (float)k / (float)(count2 - 1)));
				}
			}
			for (int l = 0; l < num - 1; l++)
			{
				for (int m = 0; m < count2 - 1; m++)
				{
					int num6 = count3 + l * count2 + m;
					Quad(sub, num6, num6 + 1, num6 + count2 + 1, num6 + count2);
				}
			}
		}

		public void Box(int sub, Vector3 center, Vector3 size, Quaternion rot, float uvScale = 1f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_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_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_00a6: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = size * 0.5f;
			Vector3[] array = (Vector3[])(object)new Vector3[6]
			{
				Vector3.right,
				Vector3.left,
				Vector3.up,
				Vector3.down,
				Vector3.forward,
				Vector3.back
			};
			foreach (Vector3 val2 in array)
			{
				Vector3 val3 = ((val2.y != 0f) ? Vector3.right : Vector3.up);
				Vector3 val4 = Vector3.Cross(val2, val3);
				Vector3 val5 = Vector3.Scale(val2, val);
				Vector3 val6 = Vector3.Scale(val3, val);
				Vector3 val7 = Vector3.Scale(val4, val);
				Vector3 n = rot * val2;
				float num = ((Vector3)(ref val6)).magnitude * 2f * uvScale;
				float num2 = ((Vector3)(ref val7)).magnitude * 2f * uvScale;
				int a = Add(center + rot * (val5 - val6 - val7), n, new Vector2(0f, 0f));
				int b = Add(center + rot * (val5 + val6 - val7), n, new Vector2(num, 0f));
				int c = Add(center + rot * (val5 + val6 + val7), n, new Vector2(num, num2));
				int d = Add(center + rot * (val5 - val6 + val7), n, new Vector2(0f, num2));
				Quad(sub, a, b, c, d);
			}
		}

		public void Sphere(int sub, Vector3 center, float radius, int rings = 12, int segments = 18)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			int count = verts.Count;
			List<Vector2> list = new List<Vector2>();
			for (int i = 0; i <= rings; i++)
			{
				float num = MathF.PI * (float)i / (float)rings;
				list.Add(new Vector2(Mathf.Sin(num) * radius, Mathf.Cos(num) * radius));
			}
			Lathe(sub, list, segments);
			for (int j = count; j < verts.Count; j++)
			{
				List<Vector3> list2 = verts;
				int index = j;
				list2[index] += center;
			}
		}

		public void Gem(int sub, Vector3 center, Vector3 halfSize, Quaternion rot)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[6]
			{
				new Vector3(halfSize.x, 0f, 0f),
				new Vector3(0f - halfSize.x, 0f, 0f),
				new Vector3(0f, halfSize.y, 0f),
				new Vector3(0f, (0f - halfSize.y) * 0.2f, 0f),
				new Vector3(0f, 0f, halfSize.z),
				new Vector3(0f, 0f, 0f - halfSize.z)
			};
			int[,] array2 = new int[8, 3]
			{
				{ 0, 2, 4 },
				{ 4, 2, 1 },
				{ 1, 2, 5 },
				{ 5, 2, 0 },
				{ 0, 4, 3 },
				{ 4, 1, 3 },
				{ 1, 5, 3 },
				{ 5, 0, 3 }
			};
			for (int i = 0; i < 8; i++)
			{
				Vector3 val = center + rot * array[array2[i, 0]];
				Vector3 val2 = center + rot * array[array2[i, 1]];
				Vector3 val3 = center + rot * array[array2[i, 2]];
				Vector3 val4 = Vector3.Cross(val2 - val, val3 - val);
				Vector3 val5 = ((Vector3)(ref val4)).normalized;
				if (Vector3.Dot(val5, (val + val2 + val3) / 3f - center) < 0f)
				{
					val5 = -val5;
				}
				Tri(sub, Add(val, val5, Vector2.zero), Add(val2, val5, Vector2.right), Add(val3, val5, Vector2.up));
			}
		}

		public void Translate(int fromVertex, Vector3 offset)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			for (int i = fromVertex; i < verts.Count; i++)
			{
				List<Vector3> list = verts;
				int index = i;
				list[index] += offset;
			}
		}

		public void Transform(int fromVertex, Matrix4x4 m)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			for (int i = fromVertex; i < verts.Count; i++)
			{
				verts[i] = ((Matrix4x4)(ref m)).MultiplyPoint3x4(verts[i]);
				List<Vector3> list = normals;
				int index = i;
				Vector3 val = ((Matrix4x4)(ref m)).MultiplyVector(normals[i]);
				list[index] = ((Vector3)(ref val)).normalized;
			}
		}

		public void Rod(int sub, Vector3 a, Vector3 b, float radius, int sides = 10)
		{
			//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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			int vertexCount = VertexCount;
			float num = Vector3.Distance(a, b);
			Lathe(sub, (IList<Vector2>)(object)new Vector2[4]
			{
				new Vector2(0f, num),
				new Vector2(radius, num),
				new Vector2(radius, 0f),
				new Vector2(0f, 0f)
			}, sides);
			Transform(vertexCount, Matrix4x4.TRS(a, Quaternion.FromToRotation(Vector3.up, b - a), Vector3.one));
		}

		public void RoundedSlab(int topSub, int sideSub, float halfX, float halfZ, float radius, float y0, float y1, int cornerSegments = 8)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = RoundedRect(Vector3.zero, halfX, halfZ, radius, cornerSegments);
			bool[] array = new bool[2] { true, false };
			foreach (bool flag in array)
			{
				float num = (flag ? y1 : y0);
				Vector3 n = (flag ? Vector3.up : Vector3.down);
				int a = Add(new Vector3(0f, num, 0f), n, new Vector2(0.5f, 0.5f));
				int vertexCount = VertexCount;
				foreach (Vector3 item in list)
				{
					Add(new Vector3(item.x, num, item.z), n, new Vector2(item.x / (halfX * 2f) + 0.5f, item.z / (halfZ * 2f) + 0.5f));
				}
				for (int j = 0; j < list.Count; j++)
				{
					Tri(flag ? topSub : sideSub, a, vertexCount + j, vertexCount + (j + 1) % list.Count);
				}
			}
			Sweep(sideSub, list, (IList<Vector2>)(object)new Vector2[2]
			{
				new Vector2(0f, y1),
				new Vector2(0f, y0)
			});
		}

		public void FlatQuad(int sub, Vector3 center, float sizeX, float sizeZ, float y = 0f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			float num = sizeX / 2f;
			float num2 = sizeZ / 2f;
			int a = Add(center + new Vector3(0f - num, y, 0f - num2), Vector3.up, new Vector2(0f, 0f));
			int b = Add(center + new Vector3(num, y, 0f - num2), Vector3.up, new Vector2(1f, 0f));
			int c = Add(center + new Vector3(num, y, num2), Vector3.up, new Vector2(1f, 1f));
			int d = Add(center + new Vector3(0f - num, y, num2), Vector3.up, new Vector2(0f, 1f));
			Quad(sub, a, b, c, d);
		}

		public static List<Vector3> RoundedRect(Vector3 center, float halfX, float halfZ, float radius, int cornerSegments, float y = 0f)
		{
			//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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			Vector2[] array = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(halfX - radius, 0f - halfZ + radius),
				new Vector2(halfX - radius, halfZ - radius),
				new Vector2(0f - halfX + radius, halfZ - radius),
				new Vector2(0f - halfX + radius, 0f - halfZ + radius)
			};
			float[] array2 = new float[4] { -90f, 0f, 90f, 180f };
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j <= cornerSegments; j++)
				{
					float num = (array2[i] + 90f * (float)j / (float)cornerSegments) * (MathF.PI / 180f);
					list.Add(center + new Vector3(array[i].x + Mathf.Cos(num) * radius, y, array[i].y + Mathf.Sin(num) * radius));
				}
			}
			return list;
		}
	}
	internal static class Net
	{
		public const byte Hello = 171;

		public const byte Place = 172;

		public const byte State = 173;

		public const byte Bet = 174;

		public const byte Spin = 175;

		public const byte Deny = 176;

		private static bool hooked;

		public static bool Multiplayer
		{
			get
			{
				if (Object.op_Implicit((Object)(object)GameManager.instance))
				{
					return SemiFunc.IsMultiplayer();
				}
				return false;
			}
		}

		public static bool IsHost => SemiFunc.IsMasterClientOrSingleplayer();

		public static int LocalActor
		{
			get
			{
				if (!Multiplayer || PhotonNetwork.LocalPlayer == null)
				{
					return 1;
				}
				return PhotonNetwork.LocalPlayer.ActorNumber;
			}
		}

		public static double Time
		{
			get
			{
				if (!Multiplayer)
				{
					return Time.timeAsDouble;
				}
				return PhotonNetwork.Time;
			}
		}

		public static event Action<byte, object?, int>? Received;

		public static void Hook()
		{
			if (!hooked && PhotonNetwork.NetworkingClient != null)
			{
				PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
				hooked = true;
			}
		}

		private static void OnEvent(EventData e)
		{
			if (e.Code < 171 || e.Code > 176)
			{
				return;
			}
			try
			{
				Net.Received?.Invoke(e.Code, e.CustomData, e.Sender);
			}
			catch (Exception arg)
			{
				ShopRoulette.Logger.LogError((object)$"Roulette event {e.Code} failed: {arg}");
			}
		}

		public static void ToHost(byte code, object? data)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			if (!Multiplayer || IsHost)
			{
				Net.Received?.Invoke(code, data, LocalActor);
				return;
			}
			PhotonNetwork.RaiseEvent(code, data, new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)2
			}, SendOptions.SendReliable);
		}

		public static void ToOthers(byte code, object? data)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if (Multiplayer)
			{
				PhotonNetwork.RaiseEvent(code, data, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		public static void ToActor(int actor, byte code, object? data)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!Multiplayer || actor == LocalActor)
			{
				Net.Received?.Invoke(code, data, LocalActor);
				return;
			}
			RaiseEventOptions val = new RaiseEventOptions();
			val.TargetActors = new int[1] { actor };
			PhotonNetwork.RaiseEvent(code, data, val, SendOptions.SendReliable);
		}
	}
	internal static class Placement
	{
		private const float CenterX = 0.12f;

		private const float HalfLength = 1.44f;

		private const float HalfWidth = 0.68f;

		public static bool Find(out Vector3 position, out float yaw)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			position = default(Vector3);
			yaw = 0f;
			LevelGenerator instance = LevelGenerator.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.LevelPathPoints == null)
			{
				return false;
			}
			int mask = LayerMask.GetMask(new string[5] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "StaticGrabObject" });
			int floorMask = -5 & ~LayerMask.GetMask(new string[5] { "Player", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "Enemy" });
			List<Vector3> list = new List<Vector3>();
			if (Object.op_Implicit((Object)(object)ShopManager.instance))
			{
				if (Object.op_Implicit((Object)(object)ShopManager.instance.extractionPoint))
				{
					list.Add(ShopManager.instance.extractionPoint.position);
				}
				list.AddRange(from v in ShopManager.instance.itemVolumes
					where Object.op_Implicit((Object)(object)v)
					select ((Component)v).transform.position);
			}
			if (Object.op_Implicit((Object)(object)ShopKeeper.instance))
			{
				list.Add(((Component)ShopKeeper.instance).transform.position);
			}
			if (Object.op_Implicit((Object)(object)instance.LevelPathTruck))
			{
				list.Add(((Component)instance.LevelPathTruck).transform.position);
			}
			List<LevelPoint> list2 = instance.LevelPathPoints.Where((LevelPoint pt) => Object.op_Implicit((Object)(object)pt)).ToList();
			float[] array = new float[3] { 0.75f, 0.45f, 0.2f };
			foreach (float num2 in array)
			{
				float num3 = float.MinValue;
				foreach (LevelPoint item in list2)
				{
					for (float num4 = -1.5f; num4 <= 1.51f; num4 += 0.75f)
					{
						for (float num5 = -1.5f; num5 <= 1.51f; num5 += 0.75f)
						{
							for (float num6 = 0f; num6 < 180f; num6 += 45f)
							{
								if (Fits(((Component)item).transform.position + new Vector3(num4, 0f, num5), num6, num2, mask, floorMask, out var floor))
								{
									float num7 = ((list.Count == 0) ? 6f : Mathf.Min(6f, list.Min((Vector3 a) => Vector3.Distance(a, floor))));
									if (item.inStartRoom)
									{
										num7 -= 2f;
									}
									float num8 = num7;
									Vector2 val = new Vector2(num4, num5);
									num7 = num8 - ((Vector2)(ref val)).magnitude * 0.2f;
									if (num7 > num3)
									{
										num3 = num7;
										position = floor;
										yaw = num6;
									}
								}
							}
						}
					}
				}
				if (num3 > float.MinValue)
				{
					ShopRoulette.Logger.LogInfo((object)$"Roulette table placed at {position} facing {yaw} (standing room {num2} m)");
					return true;
				}
			}
			return false;
		}

		private static bool Fits(Vector3 around, float yaw, float standingRoom, int mask, int floorMask, out Vector3 floor)
		{
			//IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00b2: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			floor = default(Vector3);
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(around + Vector3.up * 1.2f, Vector3.down, ref val, 3f, floorMask, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val)).normal.y < 0.95f)
			{
				return false;
			}
			floor = ((RaycastHit)(ref val)).point;
			Quaternion val2 = Quaternion.Euler(0f, yaw, 0f);
			Vector3 val3 = floor + val2 * new Vector3(0.12f, 0f, 0f);
			if (Physics.CheckBox(val3 + Vector3.up * 1.2f, new Vector3(1.44f, 1.02f, 0.68f), val2, mask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (Physics.CheckBox(val3 + Vector3.up * 1f, new Vector3(1.44f + standingRoom * 0.5f, 0.8f, 0.68f + standingRoom), val2, mask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			float[] array = new float[2] { -1f, 1f };
			RaycastHit val4 = default(RaycastHit);
			foreach (float num in array)
			{
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num2 in array2)
				{
					float[] array3 = new float[2] { 0f, standingRoom };
					foreach (float num3 in array3)
					{
						if (!Physics.Raycast(val3 + val2 * new Vector3(num * (1.44f + num3 * 0.5f), 0f, num2 * (0.68f + num3)) + Vector3.up * 0.5f, Vector3.down, ref val4, 1f, floorMask, (QueryTriggerInteraction)1) || Mathf.Abs(((RaycastHit)(ref val4)).point.y - floor.y) > 0.08f)
						{
							return false;
						}
					}
				}
			}
			return true;
		}
	}
	internal sealed class RouletteSim
	{
		public enum Sound : byte
		{
			Fret,
			Diamond,
			Bounce,
			Drop,
			Settle
		}

		public struct SoundEvent
		{
			public float Time;

			public Sound Type;

			public float Strength;
		}

		public const float BallRadius = 0.011f;

		public const float WallR = 0.374f;

		public const float TrackInnerR = 0.345f;

		public const float RotorOuterR = 0.295f;

		public const float PocketOuterR = 0.27f;

		public const float PocketInnerR = 0.228f;

		public const float DiamondR = 0.321f;

		public const float DiamondHalfDepth = 0.009f;

		public const float DiamondHalfWidth = 0.01f;

		public const float DiamondHeight = 0.01f;

		public const float PocketFloorZ = 0.01f;

		public const float FretTopZ = 0.023f;

		public const int Pockets = 37;

		public const int Diamonds = 8;

		public const float PocketAngle = 0.16981582f;

		public const float Tau = MathF.PI * 2f;

		public static readonly int[] WheelOrder = new int[37]
		{
			0, 32, 15, 19, 4, 21, 2, 25, 17, 34,
			6, 27, 13, 36, 11, 30, 8, 23, 10, 5,
			24, 16, 33, 1, 20, 14, 31, 9, 22, 18,
			29, 7, 28, 12, 35, 3, 26
		};

		private const float G = 9.81f;

		private const float RollFactor = 0.71428573f;

		private const float RollResistance = 0.01f;

		private const float WallFriction = 0.028f;

		private const float PocketFriction = 0.2f;

		private const float AirDrag = 0.03f;

		private const float WheelDecay = 45f;

		public const float IdleWheelSpeed = 0.45f;

		private const float Dt = 0.001f;

		private const int SampleEvery = 4;

		public const float SampleDt = 0.004f;

		private const float MaxTime = 45f;

		public readonly List<float> X = new List<float>();

		public readonly List<float> Y = new List<float>();

		public readonly List<float> Z = new List<float>();

		public readonly List<float> Wheel = new List<float>();

		public readonly List<float> Speed = new List<float>();

		public readonly List<bool> Grounded = new List<bool>();

		public readonly List<SoundEvent> Sounds = new List<SoundEvent>();

		private readonly Random rng;

		public int ResultPocket { get; private set; }

		public int ResultNumber => WheelOrder[ResultPocket];

		public float Duration => (float)(X.Count - 1) * 0.004f;

		public float SettleRelAngle { get; private set; }

		public float SettleR { get; private set; }

		public float WheelSpeedAtEnd { get; private set; }

		public float LaunchAngle { get; private set; }

		public float LaunchSpeed { get; private set; }

		public float WheelSpeed0 { get; private set; }

		private RouletteSim(int seed)
		{
			rng = new Random(seed);
		}

		private float Range(float a, float b)
		{
			return a + (float)rng.NextDouble() * (b - a);
		}

		public static RouletteSim Run(int seed, float wheelAngle0)
		{
			RouletteSim rouletteSim = new RouletteSim(seed);
			rouletteSim.Simulate(wheelAngle0);
			return rouletteSim;
		}

		public static float SurfaceZ(float r, out float slope)
		{
			if (r >= 0.345f)
			{
				slope = 0.28f;
				return 0.051f + (r - 0.345f) * slope;
			}
			if (r >= 0.295f)
			{
				slope = 0.38f;
				return 0.032f + (r - 0.295f) * slope;
			}
			if (r >= 0.27f)
			{
				slope = 0.32f;
				return 0.024f + (r - 0.27f) * slope;
			}
			float num = r - 0.249f;
			slope = 0.8f * num;
			return 0.01f + 0.4f * num * num;
		}

		private static bool InPocketRing(float r)
		{
			return r < 0.27f;
		}

		private static bool OnRotor(float r)
		{
			return r < 0.295f;
		}

		private void Simulate(float wheel)
		{
			float num = (WheelSpeed0 = Range(2.6f, 3.6f));
			float a = (LaunchAngle = Range(0f, MathF.PI * 2f));
			float num4 = (LaunchSpeed = Range(5.1f, 6.1f));
			float num6 = 0.374f * DMath.Cos(a);
			float num7 = 0.374f * DMath.Sin(a);
			float slope;
			float num8 = SurfaceZ(0.374f, out slope);
			float num9 = num4 * DMath.Sin(a);
			float num10 = (0f - num4) * DMath.Cos(a);
			float num11 = 0f;
			bool flag = true;
			float num12 = 0f;
			float num13 = 0f;
			float num14 = 0f;
			int num15 = -1;
			int num16 = 0;
			Record(num6, num7, num8, wheel, num4, flag);
			float num17;
			bool flag4;
			do
			{
				num16++;
				num12 += 0.001f;
				num = ((num > 0.45f) ? (num * 0.99997777f) : 0.45f);
				wheel += num * 0.001f;
				if (wheel > MathF.PI * 2f)
				{
					wheel -= MathF.PI * 2f;
				}
				if (num14 > 0f)
				{
					num14 -= 0.001f;
				}
				num17 = DMath.Sqrt(num6 * num6 + num7 * num7);
				float num18 = num6 / num17;
				float num19 = num7 / num17;
				float num20 = 0f - num19;
				float num21 = num18;
				SurfaceZ(num17, out var slope2);
				float num22 = 0f;
				float num23 = 0f;
				if (OnRotor(num17))
				{
					num22 = num20 * num * num17;
					num23 = num21 * num * num17;
				}
				float num24 = num9 - num22;
				float num25 = num10 - num23;
				float num26 = DMath.Sqrt(num24 * num24 + num25 * num25);
				float num27 = 0f;
				float num28 = 0f;
				float num29 = DMath.Sqrt(num9 * num9 + num10 * num10);
				num27 -= 0.03f * num29 * num9;
				num28 -= 0.03f * num29 * num10;
				if (flag)
				{
					float num30 = -9.81f * slope2 / (1f + slope2 * slope2) * 0.71428573f;
					num27 += num18 * num30;
					num28 += num19 * num30;
					float num31 = (InPocketRing(num17) ? 0.2f : 0.01f);
					if (num26 > 1E-05f)
					{
						float num32 = num31 * 9.81f * 0.71428573f;
						float num33 = num26 / 0.001f;
						if (num32 > num33)
						{
							num32 = num33;
						}
						num27 -= num24 / num26 * num32;
						num28 -= num25 / num26 * num32;
					}
					if (num17 >= 0.37390003f)
					{
						float num34 = num9 * num20 + num10 * num21;
						float num35 = num34 * num34 / num17 + num30;
						if (num35 > 0f && (num34 > 0.0001f || num34 < -0.0001f))
						{
							float num36 = 0.028f * num35;
							num27 -= num20 * ((num34 > 0f) ? num36 : (0f - num36));
							num28 -= num21 * ((num34 > 0f) ? num36 : (0f - num36));
						}
					}
				}
				else
				{
					num11 -= 0.009810001f;
				}
				num9 += num27 * 0.001f;
				num10 += num28 * 0.001f;
				float num37 = num17;
				num6 += num9 * 0.001f;
				num7 += num10 * 0.001f;
				num8 += num11 * 0.001f;
				num17 = DMath.Sqrt(num6 * num6 + num7 * num7);
				num18 = num6 / num17;
				num19 = num7 / num17;
				num20 = 0f - num19;
				num21 = num18;
				if (num17 > 0.374f)
				{
					num6 = num18 * 0.374f;
					num7 = num19 * 0.374f;
					num17 = 0.374f;
					float num38 = num9 * num18 + num10 * num19;
					if (num38 > 0f)
					{
						float num39 = num38 * 1.25f;
						num9 -= num18 * num39;
						num10 -= num19 * num39;
						if (num38 > 0.25f)
						{
							AddSound(num12, Sound.Bounce, num38);
						}
					}
				}
				if (num17 < 0.228f)
				{
					num6 = num18 * 0.228f;
					num7 = num19 * 0.228f;
					num17 = 0.228f;
					float num40 = num9 * num18 + num10 * num19;
					if (num40 < 0f)
					{
						float num41 = num40 * 1.4f;
						num9 -= num18 * num41;
						num10 -= num19 * num41;
						if (num40 < -0.2f)
						{
							AddSound(num12, Sound.Fret, (0f - num40) * 0.6f);
						}
					}
				}
				if (num37 < 0.27f && num17 >= 0.27f && num8 < SurfaceZ(0.2701f, out slope) - 0.002f)
				{
					num6 = num18 * 0.26990002f;
					num7 = num19 * 0.26990002f;
					num17 = 0.26990002f;
					float num42 = num9 * num18 + num10 * num19;
					if (num42 > 0f)
					{
						float num43 = num42 * 1.35f;
						num9 -= num18 * num43;
						num10 -= num19 * num43;
						if (num42 > 0.15f)
						{
							AddSound(num12, Sound.Fret, num42 * 0.7f);
						}
					}
				}
				if (InPocketRing(num17) && num8 < 0.023f)
				{
					int num44 = (int)(WrapAngle(DMath.Atan2(num7, num6) - wheel) / 0.16981582f);
					if (num44 >= 37)
					{
						num44 = 36;
					}
					if (num15 >= 0 && num44 != num15 && InPocketRing(num37))
					{
						bool flag2 = num44 == (num15 + 1) % 37;
						float a2 = (float)(flag2 ? num44 : num15) * 0.16981582f + wheel + (flag2 ? (-0.0002f) : 0.0002f);
						num6 = num17 * DMath.Cos(a2);
						num7 = num17 * DMath.Sin(a2);
						num18 = num6 / num17;
						num19 = num7 / num17;
						num20 = 0f - num19;
						num21 = num18;
						float num45 = num * num17;
						float num46 = num9 * num20 + num10 * num21;
						float num47 = num9 * num18 + num10 * num19;
						float num48 = num46 - num45;
						float num49 = ((num48 < 0f) ? (0f - num48) : num48);
						float num50 = Range(0.45f, 0.75f);
						float num51 = (0f - num48) * num50;
						num47 += Range(-0.35f, 0.35f) * num49;
						num46 = num45 + num51;
						num9 = num20 * num46 + num18 * num47;
						num10 = num21 * num46 + num19 * num47;
						float num52 = num49 * Range(0.3f, 0.8f);
						if (num52 > 0.03f)
						{
							num11 = (flag ? 0f : ((num11 > 0f) ? num11 : 0f)) + num52;
							flag = false;
						}
						AddSound(num12, Sound.Fret, num49);
						num44 = num15;
					}
					num15 = num44;
				}
				else
				{
					num15 = -1;
				}
				if (num14 <= 0f && num17 > 0.312f && num17 < 0.33f && num8 < SurfaceZ(num17, out slope) + 0.01f)
				{
					float num53 = DMath.Atan2(num7, num6);
					float num54 = DMath.Round((num53 - MathF.PI / 8f) / (MathF.PI / 4f));
					float num55 = num54 * (MathF.PI / 4f) + MathF.PI / 8f;
					float num56 = WrapAngleSigned(num53 - num55) * num17;
					if (num56 > -0.01f && num56 < 0.01f)
					{
						float num57 = num9 * num20 + num10 * num21;
						float num58 = num9 * num18 + num10 * num19;
						float num59 = ((num57 < 0f) ? (0f - num57) : num57);
						bool flag3 = ((int)num54 & 1) == 1;
						num57 *= (flag3 ? Range(0.25f, 0.6f) : Range(0.55f, 0.85f));
						num58 += num59 * (flag3 ? Range(-0.45f, 0.2f) : Range(-0.25f, 0.1f));
						num9 = num20 * num57 + num18 * num58;
						num10 = num21 * num57 + num19 * num58;
						num11 = ((num11 > 0f) ? num11 : 0f) + num59 * (flag3 ? Range(0.1f, 0.35f) : Range(0.25f, 0.6f));
						flag = false;
						num14 = 0.08f;
						AddSound(num12, Sound.Diamond, num59);
					}
				}
				float num60 = SurfaceZ(num17, out slope2);
				if (flag)
				{
					if (num60 < num8 - 0.003f)
					{
						flag = false;
						num11 = 0f;
						AddSound(num12, Sound.Drop, num29);
					}
					else
					{
						num8 = num60;
						num11 = 0f;
					}
				}
				else if (num8 <= num60)
				{
					num8 = num60;
					if (num11 < -0.12f)
					{
						AddSound(num12, Sound.Bounce, 0f - num11);
						num11 = (0f - num11) * (InPocketRing(num17) ? 0.45f : 0.4f);
					}
					else
					{
						num11 = 0f;
						flag = true;
					}
				}
				num29 = DMath.Sqrt(num9 * num9 + num10 * num10);
				float num61 = num29;
				if (InPocketRing(num17))
				{
					float num62 = num9 + num7 * num;
					float num63 = num10 - num6 * num;
					num61 = DMath.Sqrt(num62 * num62 + num63 * num63);
				}
				num13 = ((!flag || !InPocketRing(num17) || !(num61 < 0.03f)) ? 0f : (num13 + 0.001f));
				flag4 = num13 > 0.35f || num12 > 45f;
				if (num16 % 4 == 0 || flag4)
				{
					Record(num6, num7, num8, wheel, num29, flag);
				}
			}
			while (!flag4);
			float num64 = WrapAngle(DMath.Atan2(num7, num6) - wheel);
			ResultPocket = Math.Min((int)(num64 / 0.16981582f), 36);
			SettleRelAngle = num64;
			SettleR = num17;
			WheelSpeedAtEnd = num;
			AddSound(num12, Sound.Settle, 1f);
		}

		private void Record(float x, float y, float z, float wheel, float speed, bool grounded)
		{
			X.Add(x);
			Y.Add(y);
			Z.Add(z);
			Wheel.Add(wheel);
			Speed.Add(speed);
			Grounded.Add(grounded);
		}

		private void AddSound(float t, Sound type, float strength)
		{
			if (Sounds.Count > 0)
			{
				SoundEvent soundEvent = Sounds[Sounds.Count - 1];
				if (soundEvent.Type == type && t - soundEvent.Time < 0.02f)
				{
					return;
				}
			}
			Sounds.Add(new SoundEvent
			{
				Time = t,
				Type = type,
				Strength = strength
			});
		}

		public static float WrapAngle(float a)
		{
			while (a < 0f)
			{
				a += MathF.PI * 2f;
			}
			while (a >= MathF.PI * 2f)
			{
				a -= MathF.PI * 2f;
			}
			return a;
		}

		private static float WrapAngleSigned(float a)
		{
			a = WrapAngle(a);
			if (!(a > MathF.PI))
			{
				return a;
			}
			return a - MathF.PI * 2f;
		}
	}
	internal static class DMath
	{
		private const float Pi = MathF.PI;

		private const float HalfPi = MathF.PI / 2f;

		public static float Sqrt(float v)
		{
			return (float)Math.Sqrt(v);
		}

		public static float Round(float v)
		{
			return (float)Math.Floor(v + 0.5f);
		}

		public static float Sin(float a)
		{
			a -= MathF.PI * 2f * (float)Math.Floor((a + MathF.PI) / (MathF.PI * 2f));
			if (a > MathF.PI / 2f)
			{
				a = MathF.PI - a;
			}
			else if (a < -MathF.PI / 2f)
			{
				a = -MathF.PI - a;
			}
			float num = a * a;
			return a * (1f + num * (-1f / 6f + num * (1f / 120f + num * (-0.0001984127f + num * (2.7557319E-06f + num * -2.5052108E-08f)))));
		}

		public static float Cos(float a)
		{
			return Sin(a + MathF.PI / 2f);
		}

		public static float Atan2(float y, float x)
		{
			float num = ((x < 0f) ? (0f - x) : x);
			float num2 = ((y < 0f) ? (0f - y) : y);
			if (num == 0f && num2 == 0f)
			{
				return 0f;
			}
			bool num3 = num2 > num;
			float num4 = (num3 ? (num / num2) : (num2 / num));
			float num5 = ((!(num4 > 0.41421357f)) ? AtanSmall(num4) : (MathF.PI / 4f + AtanSmall((num4 - 1f) / (num4 + 1f))));
			if (num3)
			{
				num5 = MathF.PI / 2f - num5;
			}
			if (x < 0f)
			{
				num5 = MathF.PI - num5;
			}
			if (!(y < 0f))
			{
				return num5;
			}
			return 0f - num5;
		}

		private static float AtanSmall(float t)
		{
			float num = t * t;
			return t * (1f + num * (-1f / 3f + num * (0.2f + num * (-1f / 7f + num * (1f / 9f + num * (-1f / 11f + num * (1f / 13f)))))));
		}
	}
	internal enum Phase
	{
		Open,
		Betting,
		Spinning,
		Result
	}
	internal sealed class RouletteTable : MonoBehaviour
	{
		private sealed class Stack
		{
			public readonly List<GameObject> Chips = new List<GameObject>();

			public TextMeshPro Label;

			public Vector3 Base;

			public int Slot;

			public int Amount;
		}

		private sealed class Flight
		{
			public Transform T;

			public Vector3 From;

			public Vector3 To;

			public float Start;

			public float Duration;

			public float Arc;

			public GameObject? Reveal;

			public bool Shrink;

			public bool Clack;
		}

		private TableParts p;

		private Phase phase;

		private double phaseEnd;

		private int round;

		private int seed;

		private int expected = -1;

		private int result = -1;

		private double t0;

		private float w0;

		private readonly Dictionary<(int actor, int zone), int> bets = new Dictionary<(int, int), int>();

		private readonly List<int> history = new List<int>();

		private readonly List<(int actor, int amount)> payouts = new List<(int, int)>();

		private readonly Random hostRng = new Random();

		private float wheelAngle;

		private float wheelSpeed = 0.45f;

		private float ballRel;

		private float ballR = 0.249f;

		private RouletteSim? sim;

		private int simRound = -1;

		private double simReceived;

		private float windAngle0;

		private float windSpeed0;

		private Vector3 windBall0;

		private int soundIndex;

		private int spinAudioNext;

		private bool launched;

		private int correctionPockets;

		private float correctionStart;

		private Vector3 lastBallPos;

		private int shownResultRound = -1;

		private int collectRound = -1;

		private int chipIndex = 1;

		private int hoverZone = -1;

		private int hoverButton = -1;

		private TextMeshPro tooltip;

		private GameObject ghost;

		private int ghostChip = -1;

		private string denyText = "";

		private float denyUntil;

		private int lastTick = -1;

		private readonly Dictionary<(int actor, int zone), Stack> stacks = new Dictionary<(int, int), Stack>();

		private readonly List<Flight> flights = new List<Flight>();

		private static readonly Dictionary<int, (string name, Color color)> playerCache = new Dictionary<int, (string, Color)>();

		private static readonly HashSet<int> playerCacheGood = new HashSet<int>();

		public static RouletteTable? Instance { get; private set; }

		public static RouletteTable Spawn(Vector3 position, float yaw)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0016: 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)
			Sounds.Build();
			GameObject val = new GameObject("ShopRoulette Table");
			val.transform.SetPositionAndRotation(position, Quaternion.Euler(0f, yaw, 0f));
			RouletteTable rouletteTable = val.AddComponent<RouletteTable>();
			rouletteTable.p = TableBuilder.Build(val.transform);
			rouletteTable.Setup();
			return rouletteTable;
		}

		private void Awake()
		{
			Instance = this;
		}

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

		private void Setup()
		{
			//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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			playerCache.Clear();
			playerCacheGood.Clear();
			Random random = new Random();
			wheelAngle = (float)(random.NextDouble() * 6.2831854820251465);
			ballRel = ((float)random.Next(37) + 0.5f) * 0.16981582f;
			float num = wheelAngle + ballRel;
			p.Ball.localPosition = (lastBallPos = new Vector3(Mathf.Cos(num) * ballR, 0.01f, Mathf.Sin(num) * ballR));
			tooltip = Looks.Text(((Component)this).transform, "Tooltip", Vector3.zero, Quaternion.identity, 0.42f, Color.white, (TextAlignmentOptions)514, 1.2f, 0.3f);
			((Component)tooltip).gameObject.SetActive(false);
			((TMP_Text)tooltip).outlineWidth = 0.18f;
			((TMP_Text)tooltip).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220);
			ghost = new GameObject("Ghost");
			ghost.transform.SetParent(((Component)this).transform, false);
			ghost.AddComponent<MeshFilter>().sharedMesh = Chips.Mesh;
			((Renderer)ghost.AddComponent<MeshRenderer>()).shadowCastingMode = (ShadowCastingMode)0;
			ghost.SetActive(false);
			UpdateBoard(full: true);
		}

		public object[] Pack()
		{
			List<int> list = new List<int>();
			foreach (KeyValuePair<(int, int), int> bet in bets)
			{
				list.Add(bet.Key.Item1);
				list.Add(bet.Key.Item2);
				list.Add(bet.Value);
			}
			List<int> list2 = new List<int>();
			foreach (var (item, item2) in payouts)
			{
				list2.Add(item);
				list2.Add(item2);
			}
			return new object[11]
			{
				(int)phase,
				phaseEnd,
				seed,
				t0,
				w0,
				expected,
				round,
				result,
				list.ToArray(),
				history.ToArray(),
				list2.ToArray()
			};
		}

		private void Broadcast()
		{
			Net.ToOthers(173, Pack());
			OnStateChanged();
		}

		public void HostBet(int actor, int zone, int amount)
		{
			if (zone < 0 || zone > 2)
			{
				return;
			}
			Phase phase = this.phase;
			if ((uint)phase > 1u)
			{
				Net.ToActor(actor, 176, "No more bets!");
				return;
			}
			(int, int) key = (actor, zone);
			int value2;
			if (amount > 0)
			{
				if (Array.IndexOf(Chips.Values, amount) < 0)
				{
					return;
				}
				int num = SemiFunc.StatGetRunCurrency();
				if (num < amount)
				{
					Net.ToActor(actor, 176, "Not enough money!");
					return;
				}
				int value = ShopRoulette.maxBet.Value;
				if (value > 0 && bets.Where((KeyValuePair<(int actor, int zone), int> b) => b.Key.actor == actor).Sum((KeyValuePair<(int actor, int zone), int> b) => b.Value) + amount > value)
				{
					Net.ToActor(actor, 176, $"Table limit is ${value}K per player");
					return;
				}
				SetCurrency(num - amount);
				bets[key] = bets.GetValueOrDefault(key) + amount;
				if (this.phase == Phase.Open)
				{
					this.phase = Phase.Betting;
					phaseEnd = Net.Time + (double)ShopRoulette.betTime.Value;
				}
			}
			else if (bets.TryGetValue(key, out value2))
			{
				bets.Remove(key);
				SetCurrency(SemiFunc.StatGetRunCurrency() + value2);
				if (bets.Count == 0)
				{
					this.phase = Phase.Open;
				}
			}
			Broadcast();
		}

		public void HostSpin(int actor)
		{
			if (phase == Phase.Betting)
			{
				StartSpin();
			}
			else if (phase == Phase.Open)
			{
				Net.ToActor(actor, 176, "Place a bet first!");
			}
		}

		private void StartSpin()
		{
			seed = hostRng.Next();
			w0 = RouletteSim.WrapAngle(wheelAngle + wheelSpeed * 1.2f + 1.5f);
			t0 = Net.Time + 1.2;
			RouletteSim rouletteSim = RouletteSim.Run(seed, w0);
			expected = rouletteSim.ResultNumber;
			result = -1;
			round++;
			payouts.Clear();
			phase = Phase.Spinning;
			phaseEnd = t0 + (double)rouletteSim.Duration + 0.7;
			Broadcast();
		}

		private void Resolve()
		{
			int zone = Layout.ZoneOfNumber(expected);
			payouts.Clear();
			int num = 0;
			foreach (KeyValuePair<(int, int), int> item in bets.Where((KeyValuePair<(int actor, int zone), int> b) => b.Key.zone == zone))
			{
				int num2 = item.Value * Layout.ZonePayout[zone];
				payouts.Add((item.Key.Item1, num2));
				num += num2;
			}
			if (num > 0)
			{
				SetCurrency(SemiFunc.StatGetRunCurrency()