Decompiled source of QuotaRoulette v0.1.0

QuotaRoulette.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModMenu;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuotaRoulette
{
	internal static class Art
	{
		internal static Texture2D Face;

		internal static Texture2D Glyphs;

		internal static AudioClip Tick;

		internal static AudioClip Spin;

		internal static AudioClip Win;

		internal static AudioClip Jackpot;

		internal static AudioClip Even;

		internal static AudioClip Lose;

		internal static AudioClip Bust;

		internal static AudioClip Coins;

		internal const string Chars = " 0123456789$%:.-!?/+ABCDEFGHIJKLMNOPQRSTUVWXYZ'x,()";

		private static readonly Dictionary<PrimitiveType, Mesh> Prims = new Dictionary<PrimitiveType, Mesh>();

		internal static void Load()
		{
			try
			{
				Face = Tex("wheel_face", mips: true);
				Glyphs = Tex("glyphs", mips: false);
				Tick = Wav("tick");
				Spin = Wav("spin");
				Win = Wav("win");
				Jackpot = Wav("jackpot");
				Even = Wav("even");
				Lose = Wav("lose");
				Bust = Wav("bust");
				Coins = Wav("coins");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Quota Roulette: art failed to load: " + ex));
			}
		}

		private static Stream Res(string name)
		{
			return typeof(Art).Assembly.GetManifestResourceStream("QuotaRoulette." + name);
		}

		private static Texture2D Tex(string name, bool mips)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			using Stream stream = Res(name + ".png");
			if (stream == null)
			{
				Plugin.Log.LogError((object)("Quota Roulette: " + name + ".png is missing."));
				return null;
			}
			MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, mips)
			{
				name = "QuotaRoulette." + name,
				wrapMode = (TextureWrapMode)1,
				anisoLevel = 4
			};
			ImageConversion.LoadImage(val, memoryStream.ToArray(), true);
			return val;
		}

		private static AudioClip Wav(string name)
		{
			using Stream stream = Res(name + ".wav");
			if (stream == null)
			{
				Plugin.Log.LogError((object)("Quota Roulette: sound " + name + " is missing."));
				return null;
			}
			using BinaryReader binaryReader = new BinaryReader(stream);
			binaryReader.ReadBytes(12);
			int num = 1;
			int num2 = 44100;
			int num3 = 16;
			byte[] array = null;
			while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length - 8)
			{
				string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(4));
				int num4 = binaryReader.ReadInt32();
				if (text == "fmt ")
				{
					binaryReader.ReadInt16();
					num = binaryReader.ReadInt16();
					num2 = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadInt16();
					num3 = binaryReader.ReadInt16();
					if (num4 > 16)
					{
						binaryReader.ReadBytes(num4 - 16);
					}
				}
				else
				{
					if (text == "data")
					{
						array = binaryReader.ReadBytes(num4);
						break;
					}
					binaryReader.ReadBytes(num4);
				}
			}
			if (array == null || num3 != 16)
			{
				Plugin.Log.LogError((object)("Quota Roulette: sound " + name + " isn't 16-bit PCM."));
				return null;
			}
			int num5 = array.Length / 2;
			float[] array2 = new float[num5];
			for (int i = 0; i < num5; i++)
			{
				array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f;
			}
			AudioClip obj = AudioClip.Create("QuotaRoulette." + name, num5 / num, num, num2, false);
			obj.SetData(array2, 0);
			return obj;
		}

		internal static Material LitSource(Component near)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			Material val = null;
			if ((Object)(object)near != (Object)null)
			{
				val = (from r in near.GetComponentsInChildren<MeshRenderer>(true)
					select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && (Object)(object)m.shader != (Object)null && ((Object)m.shader).name == "HDRP/Lit"));
			}
			if ((Object)(object)val == (Object)null)
			{
				val = (from r in Object.FindObjectsOfType<MeshRenderer>()
					select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && (Object)(object)m.shader != (Object)null && ((Object)m.shader).name == "HDRP/Lit"));
			}
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Shader val2 = Shader.Find("HDRP/Lit");
			if (!((Object)(object)val2 != (Object)null))
			{
				return null;
			}
			return new Material(val2);
		}

		internal static Material Lit(Material src, string name, Color c, float metal, float smooth, Texture tex = null, Color? emissive = null)
		{
			//IL_001b: 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_0021: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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)
			Material val = (((Object)(object)src != (Object)null) ? new Material(src) : new Material(Shader.Find("Standard")));
			((Object)val).name = "QuotaRoulette." + name;
			string[] array = new string[7] { "_NORMALMAP", "_NORMALMAP_TANGENT_SPACE", "_MASKMAP", "_DETAIL_MAP", "_EMISSIVE_COLOR_MAP", "_BENTNORMALMAP", "_HEIGHTMAP" };
			foreach (string text in array)
			{
				val.DisableKeyword(text);
			}
			array = new string[6] { "_NormalMap", "_MaskMap", "_DetailMap", "_EmissiveColorMap", "_BentNormalMap", "_HeightMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", c);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", c);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metal);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smooth);
			}
			if (val.HasProperty("_BaseColorMap"))
			{
				val.SetTexture("_BaseColorMap", tex);
			}
			if (val.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", tex);
			}
			if (val.HasProperty("_EmissiveColor"))
			{
				val.SetColor("_EmissiveColor", (Color)(((??)emissive) ?? Color.black));
			}
			return val;
		}

		internal static Material Unlit(string name, Color c, Texture map = null)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("HDRP/Unlit");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				name = "QuotaRoulette." + name
			};
			if ((Object)(object)map != (Object)null)
			{
				val2.SetFloat("_SurfaceType", 1f);
				val2.SetFloat("_BlendMode", 0f);
				val2.SetFloat("_ZWrite", 0f);
				val2.SetFloat("_TransparentZWrite", 0f);
				val2.SetTexture("_UnlitColorMap", map);
			}
			val2.SetColor("_UnlitColor", c);
			try
			{
				HDMaterial.ValidateMaterial(val2);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Quota Roulette: " + name + ": " + ex.Message));
			}
			if ((Object)(object)map != (Object)null && val2.renderQueue < 3000)
			{
				val2.renderQueue = 3000;
			}
			return val2;
		}

		internal static Mesh Prim(PrimitiveType t)
		{
			//IL_0005: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			if (Prims.TryGetValue(t, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			GameObject obj = GameObject.CreatePrimitive(t);
			value = obj.GetComponent<MeshFilter>().sharedMesh;
			Object.Destroy((Object)(object)obj);
			return Prims[t] = value;
		}

		internal static Mesh Disc(float r, int seg = 96)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0119: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			Vector3[] array = (Vector3[])(object)new Vector3[seg + 1];
			Vector2[] array2 = (Vector2[])(object)new Vector2[seg + 1];
			Vector3[] array3 = (Vector3[])(object)new Vector3[seg + 1];
			int[] array4 = new int[seg * 3];
			array[0] = Vector3.zero;
			array2[0] = new Vector2(0.5f, 0.5f);
			array3[0] = Vector3.forward;
			for (int i = 0; i < seg; i++)
			{
				float num = (float)i * MathF.PI * 2f / (float)seg;
				float num2 = Mathf.Cos(num);
				float num3 = Mathf.Sin(num);
				array[i + 1] = new Vector3(num2 * r, num3 * r, 0f);
				array2[i + 1] = new Vector2(0.5f - num2 * 0.5f, 0.5f + num3 * 0.5f);
				array3[i + 1] = Vector3.forward;
				array4[i * 3] = 0;
				array4[i * 3 + 1] = 1 + i;
				array4[i * 3 + 2] = 1 + (i + 1) % seg;
			}
			Mesh val = new Mesh
			{
				name = "QuotaRoulette.Disc",
				vertices = array,
				uv = array2,
				normals = array3,
				triangles = array4
			};
			val.RecalculateBounds();
			return val;
		}

		internal static Mesh Torus(float R, float r, int seg = 96, int side = 12)
		{
			//IL_0061: 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_007b: 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_0085: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00a3: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_0157: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<int> list3 = new List<int>();
			Vector3 val = default(Vector3);
			for (int i = 0; i <= seg; i++)
			{
				float num = (float)i * MathF.PI * 2f / (float)seg;
				((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f);
				for (int j = 0; j <= side; j++)
				{
					float num2 = (float)j * MathF.PI * 2f / (float)side;
					Vector3 val2 = val * Mathf.Cos(num2) + Vector3.forward * Mathf.Sin(num2);
					list.Add(val * R + val2 * r);
					list2.Add(val2);
				}
			}
			int num3 = side + 1;
			for (int k = 0; k < seg; k++)
			{
				for (int l = 0; l < side; l++)
				{
					int num4 = k * num3 + l;
					int num5 = (k + 1) * num3 + l;
					list3.AddRange(new int[6]
					{
						num4,
						num4 + 1,
						num5,
						num5,
						num4 + 1,
						num5 + 1
					});
				}
			}
			Mesh val3 = new Mesh
			{
				name = "QuotaRoulette.Torus"
			};
			val3.SetVertices(list);
			val3.SetNormals(list2);
			val3.SetTriangles(list3, 0);
			FixWinding(val3);
			val3.RecalculateBounds();
			return val3;
		}

		internal static Mesh Wedge(float length, float width, float thick)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0097: 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_009e: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d5: 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_0171: 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_0181: 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_019a: 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_01a6: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			float num = width / 2f;
			float num2 = thick / 2f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0f, 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f - num, length, 0f);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(num, length, 0f);
			Vector3[] pts = (Vector3[])(object)new Vector3[6]
			{
				val + Vector3.forward * num2,
				val2 + Vector3.forward * num2,
				val3 + Vector3.forward * num2,
				val - Vector3.forward * num2,
				val2 - Vector3.forward * num2,
				val3 - Vector3.forward * num2
			};
			List<Vector3> v = new List<Vector3>();
			List<int> tri = new List<int>();
			Face(new int[3] { 0, 1, 2 });
			Face(new int[3] { 3, 5, 4 });
			Face(new int[4] { 0, 3, 4, 1 });
			Face(new int[4] { 1, 4, 5, 2 });
			Face(new int[4] { 2, 5, 3, 0 });
			Mesh val4 = new Mesh
			{
				name = "QuotaRoulette.Wedge"
			};
			val4.SetVertices(v);
			val4.SetTriangles(tri, 0);
			val4.RecalculateNormals();
			FixWinding(val4);
			val4.RecalculateNormals();
			val4.RecalculateBounds();
			return val4;
			void Face(params int[] idx)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				int count = v.Count;
				foreach (int num3 in idx)
				{
					v.Add(pts[num3]);
				}
				for (int j = 1; j + 1 < idx.Length; j++)
				{
					tri.AddRange(new int[3]
					{
						count,
						count + j,
						count + j + 1
					});
				}
			}
		}

		private static void FixWinding(Mesh m)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_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_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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0058: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3[] vertices = m.vertices;
			int[] triangles = m.triangles;
			Bounds bounds = m.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			for (int i = 0; i < triangles.Length; i += 3)
			{
				Vector3 val = vertices[triangles[i]];
				Vector3 val2 = vertices[triangles[i + 1]];
				Vector3 val3 = vertices[triangles[i + 2]];
				if (Vector3.Dot(Vector3.Cross(val2 - val, val3 - val), (val + val2 + val3) / 3f - center) < 0f)
				{
					int num = triangles[i + 1];
					triangles[i + 1] = triangles[i + 2];
					triangles[i + 2] = num;
				}
			}
			m.triangles = triangles;
		}

		internal static void Text(Mesh m, string text, float h, float maxWidth)
		{
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_018e: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			text = (text ?? "").ToUpperInvariant().Replace('×', 'x');
			float num = h * 0.62f;
			if ((float)text.Length * num > maxWidth && text.Length > 0)
			{
				num = maxWidth / (float)text.Length;
				h = num / 0.62f;
			}
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<int> list3 = new List<int>();
			float num2 = (float)text.Length * num / 2f;
			for (int i = 0; i < text.Length; i++)
			{
				int num3 = " 0123456789$%:.-!?/+ABCDEFGHIJKLMNOPQRSTUVWXYZ'x,()".IndexOf((text[i] == 'X' && i > 0 && char.IsDigit(text[i - 1])) ? 'x' : text[i]);
				if (num3 > 0)
				{
					float num4 = num2 - ((float)i + 0.5f) * num;
					float num5 = (float)(num3 % 8) / 8f;
					float num6 = 1f - (float)(num3 / 8) / 8f;
					float num7 = num5 + 0.125f;
					float num8 = num6 - 0.125f;
					int count = list.Count;
					list.Add(new Vector3(num4 + h / 2f, (0f - h) / 2f, 0f));
					list2.Add(new Vector2(num5, num8));
					list.Add(new Vector3(num4 - h / 2f, (0f - h) / 2f, 0f));
					list2.Add(new Vector2(num7, num8));
					list.Add(new Vector3(num4 - h / 2f, h / 2f, 0f));
					list2.Add(new Vector2(num7, num6));
					list.Add(new Vector3(num4 + h / 2f, h / 2f, 0f));
					list2.Add(new Vector2(num5, num6));
					list3.AddRange(new int[6]
					{
						count,
						count + 2,
						count + 1,
						count,
						count + 3,
						count + 2
					});
				}
			}
			m.Clear();
			m.SetVertices(list);
			m.SetUVs(0, list2);
			m.SetTriangles(list3, 0);
			Vector3[] array = (Vector3[])(object)new Vector3[list.Count];
			for (int j = 0; j < array.Length; j++)
			{
				array[j] = Vector3.forward;
			}
			m.normals = array;
			m.RecalculateBounds();
		}
	}
	internal static class Host
	{
		private const string SaveKey = "QuotaRoulette.Spins";

		internal static int QuotaIndex = -1;

		internal static int Used;

		internal static int Forced = -1;

		private static bool _freeNext;

		private static Terminal _terminal;

		private static SpinMsg _pending;

		private static int _item = -1;

		private static int ThisQuota
		{
			get
			{
				if (!((Object)(object)TimeOfDay.Instance != (Object)null))
				{
					return 0;
				}
				return TimeOfDay.Instance.timesFulfilledQuota;
			}
		}

		internal static int SpinsLeft => Mathf.Max(0, Plugin.SpinsPerQuota.Value - ((QuotaIndex == ThisQuota) ? Used : 0));

		internal static int Credits
		{
			get
			{
				Terminal terminal = Terminal;
				if (!((Object)(object)terminal != (Object)null))
				{
					return 0;
				}
				return terminal.groupCredits;
			}
		}

		internal static Terminal Terminal
		{
			get
			{
				if (!((Object)(object)_terminal != (Object)null))
				{
					return _terminal = Object.FindObjectOfType<Terminal>();
				}
				return _terminal;
			}
		}

		internal static View MakeView()
		{
			return new View
			{
				Known = true,
				Enabled = Plugin.Enabled.Value,
				NeedQuotaMet = Plugin.NeedQuotaMet.Value,
				Spinning = Spinner.Active,
				SpinsLeft = SpinsLeft,
				StakePercent = Plugin.StakePercent.Value,
				MinStake = Plugin.MinStake.Value,
				MaxStake = Mathf.Max(Plugin.MinStake.Value, Plugin.MaxStake.Value)
			};
		}

		internal static int Stake(View v)
		{
			TimeOfDay instance = TimeOfDay.Instance;
			return Mathf.Min(Mathf.Clamp(Mathf.RoundToInt((float)((((Object)(object)instance != (Object)null) ? instance.quotaFulfilled : 0) * v.StakePercent) / 100f), v.MinStake, Mathf.Max(v.MinStake, v.MaxStake)), Mathf.Max(0, Credits));
		}

		internal static string WhyNot(View v, bool free = false)
		{
			if (!v.Enabled && !free)
			{
				return "The wheel is switched off";
			}
			if (v.Spinning || Spinner.Active)
			{
				return "Spinning...";
			}
			if (free)
			{
				return null;
			}
			if (v.SpinsLeft <= 0)
			{
				return "Already spun this quota";
			}
			TimeOfDay instance = TimeOfDay.Instance;
			if (v.NeedQuotaMet && (Object)(object)instance != (Object)null && instance.quotaFulfilled < instance.profitQuota)
			{
				return $"Meet the quota first ({instance.quotaFulfilled}/{instance.profitQuota})";
			}
			if (Credits < v.MinStake)
			{
				return $"Needs {v.MinStake} credits to stake";
			}
			return null;
		}

		internal static void Ask(ulong sender, string who)
		{
			if (!Net.IsHost)
			{
				return;
			}
			bool freeNext = _freeNext;
			string text = WhyNot(MakeView(), freeNext);
			if (text != null)
			{
				Net.SendNo(sender, text);
				return;
			}
			_freeNext = false;
			if (QuotaIndex != ThisQuota)
			{
				QuotaIndex = ThisQuota;
				Used = 0;
			}
			if (!freeNext)
			{
				Used++;
			}
			int num = Stake(MakeView());
			SetCredits(Credits - num);
			int num2 = Roll();
			Kind kind = Outcomes.Layout[num2];
			SpinMsg spinMsg = new SpinMsg
			{
				From = Wheel.Angle,
				Segment = num2,
				Stake = num,
				Test = freeNext,
				Who = (who ?? ""),
				Seconds = Plugin.SpinSeconds.Value * Random.Range(0.9f, 1.1f),
				SalePercent = ((kind == Kind.Sale) ? Plugin.SalePercent.Value : 0),
				Growl = Plugin.ScareGrowl.Value
			};
			spinMsg.To = Outcomes.StopAngle(spinMsg.From, num2, Random.Range(0.18f, 0.82f), Random.Range(4, 7));
			spinMsg.Payout = Outcomes.Payout(kind, num);
			if (kind == Kind.Item)
			{
				_item = PickItem();
				if (_item < 0)
				{
					spinMsg.Payout = num;
				}
				else
				{
					spinMsg.ItemName = Terminal.buyableItemsList[_item].itemName;
				}
			}
			Plugin.Log.LogInfo((object)string.Format("Quota Roulette: {0} spun for {1}: {2} (segment {3}), pays {4}{5}{6}", who, num, Outcomes.Labels[(uint)kind], num2, spinMsg.Payout, (spinMsg.ItemName != "") ? (", item " + spinMsg.ItemName) : "", freeNext ? " [test]" : ""));
			_pending = spinMsg;
			Net.SendSpin(spinMsg);
			Net.SendView();
		}

		private static int Roll()
		{
			if (Forced >= 0)
			{
				int[] array = (from i in Enumerable.Range(0, Outcomes.Layout.Length)
					where (int)Outcomes.Layout[i] == Forced
					select i).ToArray();
				Forced = -1;
				if (array.Length != 0)
				{
					return array[Random.Range(0, array.Length)];
				}
			}
			return Random.Range(0, Outcomes.Layout.Length);
		}

		internal static void Finish(SpinMsg s)
		{
			if (Net.IsHost && s == _pending)
			{
				_pending = null;
				if (s.Payout > 0)
				{
					SetCredits(Credits + s.Payout);
				}
				if (s.Kind == Kind.Item && _item >= 0)
				{
					SpawnItem(_item);
				}
				_item = -1;
				Net.SendView();
			}
		}

		internal static void SetCredits(int value)
		{
			Terminal terminal = Terminal;
			if (!((Object)(object)terminal == (Object)null))
			{
				value = Mathf.Max(0, value);
				terminal.groupCredits = value;
				terminal.SyncGroupCreditsClientRpc(value, terminal.numberOfItemsInDropship);
			}
		}

		private static int PickItem()
		{
			Terminal t = Terminal;
			if ((Object)(object)t == (Object)null || t.buyableItemsList == null)
			{
				return -1;
			}
			int[] array = Enumerable.Range(0, t.buyableItemsList.Length).Where(delegate(int i)
			{
				Item val = t.buyableItemsList[i];
				return (Object)(object)val != (Object)null && (Object)(object)val.spawnPrefab != (Object)null && val.creditsWorth > 0 && val.creditsWorth <= Plugin.FreeItemMaxPrice.Value;
			}).ToArray();
			if (array.Length != 0)
			{
				return array[Random.Range(0, array.Length)];
			}
			return -1;
		}

		private static void SpawnItem(int index)
		{
			//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_0032: 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)
			Terminal terminal = Terminal;
			StartOfRound instance = StartOfRound.Instance;
			if (!((Object)(object)terminal == (Object)null) && !((Object)(object)instance == (Object)null))
			{
				Item obj = terminal.buyableItemsList[index];
				Vector3 dropPoint = Wheel.DropPoint;
				GameObject obj2 = Object.Instantiate<GameObject>(obj.spawnPrefab, dropPoint, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), instance.propsContainer);
				GrabbableObject component = obj2.GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null)
				{
					component.fallTime = 0f;
				}
				obj2.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		internal static string TestSpin()
		{
			if (!Net.IsHost)
			{
				return null;
			}
			string text = WhyNot(MakeView(), free: true);
			if (text != null)
			{
				return text;
			}
			if (!Wheel.Built)
			{
				return "go to the Company first";
			}
			_freeNext = true;
			Ask(0uL, LocalName());
			return "test spin";
		}

		internal static string ResetSpins()
		{
			if (!Net.IsHost)
			{
				return null;
			}
			Used = 0;
			QuotaIndex = ThisQuota;
			Net.SendView();
			return "spins this quota reset";
		}

		internal static string LocalName()
		{
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if (!((Object)(object)val != (Object)null))
			{
				return "";
			}
			return val.playerUsername;
		}

		private static bool SaveAllowed(GameNetworkManager g)
		{
			if ((Object)(object)g != (Object)null)
			{
				return g.currentSaveFileName != "LCChallengeFile";
			}
			return false;
		}

		internal static void Load()
		{
			GameNetworkManager instance = GameNetworkManager.Instance;
			QuotaIndex = -1;
			Used = 0;
			if (Net.IsHost && SaveAllowed(instance))
			{
				string[] array = ES3.Load<string>("QuotaRoulette.Spins", instance.currentSaveFileName, "").Split(':');
				if (array.Length == 2 && int.TryParse(array[0], out var result) && int.TryParse(array[1], out var result2))
				{
					QuotaIndex = result;
					Used = result2;
				}
			}
		}

		internal static void Save(GameNetworkManager g, bool wipe = false)
		{
			if (g.isHostingGame && SaveAllowed(g))
			{
				ES3.Save<string>("QuotaRoulette.Spins", wipe ? "" : $"{QuotaIndex}:{Used}", g.currentSaveFileName);
			}
		}
	}
	internal static class Spinner
	{
		private static SpinMsg _s;

		private static float _start;

		internal static bool Active => _s != null;

		internal static SpinMsg Current => _s;

		internal static void Begin(SpinMsg s)
		{
			_s = s;
			_start = Time.time;
			Wheel.OnSpinStart(s);
		}

		internal static void Clear()
		{
			_s = null;
		}

		internal static float Angle(out float speed01)
		{
			speed01 = 0f;
			if (_s == null)
			{
				return Wheel.Angle;
			}
			float num = Mathf.Clamp01((Time.time - _start) / Mathf.Max(0.1f, _s.Seconds));
			float num2 = 1f - num;
			speed01 = num2 * num2;
			return _s.From + (_s.To - _s.From) * (1f - num2 * num2 * num2);
		}

		internal static void Tick()
		{
			if (_s != null && !(Time.time - _start < _s.Seconds))
			{
				SpinMsg s = _s;
				_s = null;
				Wheel.OnSpinEnd(s);
				Sale.OnSpinEnd(s);
				Host.Finish(s);
			}
		}
	}
	internal static class Sale
	{
		private static int _percent;

		private static int _daysLeft;

		private static int[] _base;

		internal static bool On => _percent > 0;

		internal static void OnSpinEnd(SpinMsg s)
		{
			if (s.Kind != Kind.Sale || s.SalePercent <= 0)
			{
				return;
			}
			Terminal terminal = Host.Terminal;
			if (!((Object)(object)terminal == (Object)null) && terminal.itemSalesPercentages != null)
			{
				if (_base == null)
				{
					_base = (int[])terminal.itemSalesPercentages.Clone();
				}
				_percent = Mathf.Max(_percent, s.SalePercent);
				_daysLeft = 1;
				Lay(terminal);
			}
		}

		private static void Lay(Terminal t)
		{
			int num = 100 - _percent;
			for (int i = 0; i < t.itemSalesPercentages.Length; i++)
			{
				t.itemSalesPercentages[i] = Mathf.Min(t.itemSalesPercentages[i], num);
			}
		}

		internal static void Before(Terminal t)
		{
			if (On)
			{
				if (_base != null && t.itemSalesPercentages != null && _base.Length == t.itemSalesPercentages.Length)
				{
					_base.CopyTo(t.itemSalesPercentages, 0);
				}
				if (_daysLeft <= 0)
				{
					Clear();
				}
			}
		}

		internal static void After(Terminal t)
		{
			if (On && _daysLeft > 0 && t.itemSalesPercentages != null)
			{
				_base = (int[])t.itemSalesPercentages.Clone();
				_daysLeft--;
				Lay(t);
			}
		}

		internal static void Clear()
		{
			_percent = 0;
			_daysLeft = 0;
			_base = null;
		}
	}
	[HarmonyPatch]
	internal static class HostPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "SetTimeAndPlanetToSavedSettings")]
		[HarmonyPostfix]
		private static void Loaded()
		{
			Host.Load();
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		[HarmonyPostfix]
		private static void Saved(GameNetworkManager __instance)
		{
			Host.Save(__instance);
		}

		[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
		[HarmonyPostfix]
		private static void Wiped(GameNetworkManager __instance)
		{
			Host.QuotaIndex = -1;
			Host.Used = 0;
			Host.Save(__instance, wipe: true);
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPostfix]
		private static void Fired()
		{
			Host.QuotaIndex = -1;
			Host.Used = 0;
			Sale.Clear();
			Net.SendView();
		}

		[HarmonyPatch(typeof(Terminal), "SetItemSales")]
		[HarmonyPrefix]
		private static void SalesBefore(Terminal __instance)
		{
			Sale.Before(__instance);
		}

		[HarmonyPatch(typeof(Terminal), "SetItemSales")]
		[HarmonyPostfix]
		private static void SalesAfter(Terminal __instance)
		{
			Sale.After(__instance);
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
		[HarmonyPostfix]
		private static void NewQuota()
		{
			Net.SendView();
		}
	}
	internal static class MenuHooks
	{
		internal const string ModMenuGuid = "daniel.lethalcompany.modmenu";

		private const string Tab = "Quota Roulette";

		private static string NotHere()
		{
			if (!Net.InGame)
			{
				return "not in a game";
			}
			if (!Wheel.Built)
			{
				return "go to the Company first";
			}
			return null;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Register()
		{
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.Enabled, "Wheel enabled", true, (string)null, (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.NeedQuotaMet, "Need quota met", true, (string)null, (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.ScareGrowl, "Scare growl", true, "the Company roars, never attacks", (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.Volume, "Volume", false, (string)null, (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.ManualPlacement, "Manual placement", false, "off: finds a clear spot", (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.PlaceOut, "Out from desk (m)", false, "manual placement", (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.PlaceAlong, "Along wall (m)", false, "manual placement", (Func<string>)null);
			MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.PlaceTurn, "Turn (deg)", false, (string)null, (Func<string>)null);
			MenuApi.Button("Quota Roulette", "Test spin", (Func<string>)Host.TestSpin, true, true, (Func<string>)NotHere, "skips the quota check, doesn't use the spin");
			MenuApi.Button("Quota Roulette", "Reset spins this quota", (Func<string>)Host.ResetSpins, true, true, (Func<string>)(() => (!Net.InGame) ? "not in a game" : null), (string)null);
			string[] options = new string[Outcomes.Labels.Length + 1];
			options[0] = "random";
			for (int num = 0; num < Outcomes.Labels.Length; num++)
			{
				options[num + 1] = Outcomes.Labels[num];
			}
			MenuApi.Choice("Quota Roulette", "Next spin lands on", options, (Func<int, string>)delegate(int k)
			{
				if (!Net.IsHost)
				{
					return (string)null;
				}
				Host.Forced = k - 1;
				return (k != 0) ? ("next spin lands on " + options[k]) : "next spin is a fair roll";
			}, true, true, (Func<string>)(() => (!Net.InGame) ? "not in a game" : null), (string)null);
			MenuApi.Tuning((Action)delegate
			{
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.SpinsPerQuota, "Spins per quota", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.StakePercent, "Stake % of sold", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.MinStake, "Min stake", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.MaxStake, "Max stake", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.SpinSeconds, "Spin time (s)", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.JackpotTimes, "Jackpot pays (x)", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.DoubleTimes, "x2 pays (x)", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.HalfTimes, "Half pays (x)", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.SalePercent, "Sale % off", true, (string)null, (Func<string>)null);
				MenuApi.Setting("Quota Roulette", (ConfigEntryBase)(object)Plugin.FreeItemMaxPrice, "Free item max price", true, (string)null, (Func<string>)null);
			});
		}
	}
	internal static class Net
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static HandleNamedMessageDelegate <>9__11_0;

			public static HandleNamedMessageDelegate <>9__11_1;

			public static HandleNamedMessageDelegate <>9__11_2;

			public static HandleNamedMessageDelegate <>9__11_3;

			public static HandleNamedMessageDelegate <>9__11_4;

			internal void <Register>b__11_0(ulong sender, FastBufferReader r)
			{
				string who = default(string);
				((FastBufferReader)(ref r)).ReadValueSafe(ref who, false);
				Host.Ask(sender, who);
			}

			internal void <Register>b__11_1(ulong sender, FastBufferReader r)
			{
				SendView(sender);
			}

			internal void <Register>b__11_2(ulong sender, FastBufferReader r)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				View view = new View();
				view.Read(r);
				View.Current = view;
			}

			internal void <Register>b__11_3(ulong sender, FastBufferReader r)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				SpinMsg spinMsg = new SpinMsg();
				spinMsg.Read(r);
				Spinner.Begin(spinMsg);
			}

			internal void <Register>b__11_4(ulong sender, FastBufferReader r)
			{
				string why = default(string);
				((FastBufferReader)(ref r)).ReadValueSafe(ref why, false);
				Wheel.Refused(why);
			}
		}

		private const string MsgView = "DanielLC.QuotaRoulette.View";

		private const string MsgSpin = "DanielLC.QuotaRoulette.Spin";

		private const string MsgAsk = "DanielLC.QuotaRoulette.Ask";

		private const string MsgNo = "DanielLC.QuotaRoulette.No";

		private const string MsgHello = "DanielLC.QuotaRoulette.Hello";

		private static readonly string[] All = new string[5] { "DanielLC.QuotaRoulette.View", "DanielLC.QuotaRoulette.Spin", "DanielLC.QuotaRoulette.Ask", "DanielLC.QuotaRoulette.No", "DanielLC.QuotaRoulette.Hello" };

		private static bool _registered;

		public static bool IsHost
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton != (Object)null)
				{
					return NetworkManager.Singleton.IsServer;
				}
				return false;
			}
		}

		public static bool InGame
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton != (Object)null)
				{
					return NetworkManager.Singleton.IsListening;
				}
				return false;
			}
		}

		public static void Register()
		{
			//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_00ac: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//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_00d6: Expected O, but got Unknown
			//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_007d: Expected O, but got Unknown
			//IL_00f5: 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_0100: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			if (_registered || (Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null)
			{
				return;
			}
			CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager;
			if (singleton.IsServer)
			{
				object obj = <>c.<>9__11_0;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader r)
					{
						string who = default(string);
						((FastBufferReader)(ref r)).ReadValueSafe(ref who, false);
						Host.Ask(sender, who);
					};
					<>c.<>9__11_0 = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("DanielLC.QuotaRoulette.Ask", (HandleNamedMessageDelegate)obj);
				object obj2 = <>c.<>9__11_1;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader r)
					{
						SendView(sender);
					};
					<>c.<>9__11_1 = val2;
					obj2 = (object)val2;
				}
				customMessagingManager.RegisterNamedMessageHandler("DanielLC.QuotaRoulette.Hello", (HandleNamedMessageDelegate)obj2);
			}
			else
			{
				object obj3 = <>c.<>9__11_2;
				if (obj3 == null)
				{
					HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader r)
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						View view = new View();
						view.Read(r);
						View.Current = view;
					};
					<>c.<>9__11_2 = val3;
					obj3 = (object)val3;
				}
				customMessagingManager.RegisterNamedMessageHandler("DanielLC.QuotaRoulette.View", (HandleNamedMessageDelegate)obj3);
				object obj4 = <>c.<>9__11_3;
				if (obj4 == null)
				{
					HandleNamedMessageDelegate val4 = delegate(ulong sender, FastBufferReader r)
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						SpinMsg spinMsg = new SpinMsg();
						spinMsg.Read(r);
						Spinner.Begin(spinMsg);
					};
					<>c.<>9__11_3 = val4;
					obj4 = (object)val4;
				}
				customMessagingManager.RegisterNamedMessageHandler("DanielLC.QuotaRoulette.Spin", (HandleNamedMessageDelegate)obj4);
				object obj5 = <>c.<>9__11_4;
				if (obj5 == null)
				{
					HandleNamedMessageDelegate val5 = delegate(ulong sender, FastBufferReader r)
					{
						string why = default(string);
						((FastBufferReader)(ref r)).ReadValueSafe(ref why, false);
						Wheel.Refused(why);
					};
					<>c.<>9__11_4 = val5;
					obj5 = (object)val5;
				}
				customMessagingManager.RegisterNamedMessageHandler("DanielLC.QuotaRoulette.No", (HandleNamedMessageDelegate)obj5);
				Send("DanielLC.QuotaRoulette.Hello", 0uL, null);
			}
			_registered = true;
		}

		public static void Unregister()
		{
			CustomMessagingManager val = (((Object)(object)NetworkManager.Singleton != (Object)null) ? NetworkManager.Singleton.CustomMessagingManager : null);
			if (val != null)
			{
				string[] all = All;
				foreach (string text in all)
				{
					try
					{
						val.UnregisterNamedMessageHandler(text);
					}
					catch (Exception)
					{
					}
				}
			}
			_registered = false;
			View.Current = new View();
			Spinner.Clear();
		}

		internal static void AskSpin(string who)
		{
			if (IsHost)
			{
				Host.Ask(0uL, who);
				return;
			}
			Send("DanielLC.QuotaRoulette.Ask", 0uL, delegate(FastBufferWriter w)
			{
				((FastBufferWriter)(ref w)).WriteValueSafe(who ?? "", false);
			});
		}

		internal static void SendNo(ulong to, string why)
		{
			if (to == 0L)
			{
				Wheel.Refused(why);
				return;
			}
			Send("DanielLC.QuotaRoulette.No", to, delegate(FastBufferWriter w)
			{
				((FastBufferWriter)(ref w)).WriteValueSafe(why ?? "", false);
			});
		}

		internal static void SendView(ulong? to = null)
		{
			if (IsHost)
			{
				View view = Host.MakeView();
				if (!to.HasValue)
				{
					View.Current = view;
					SendAll("DanielLC.QuotaRoulette.View", view.Write);
				}
				else if (to.Value != 0L)
				{
					Send("DanielLC.QuotaRoulette.View", to.Value, view.Write);
				}
			}
		}

		internal static void SendSpin(SpinMsg s)
		{
			Spinner.Begin(s);
			SendAll("DanielLC.QuotaRoulette.Spin", s.Write);
		}

		private static void Send(string msg, ulong to, Action<FastBufferWriter> write)
		{
			//IL_003c: 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)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || !singleton.IsListening)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, 4096);
			try
			{
				write?.Invoke(val);
				singleton.CustomMessagingManager.SendNamedMessage(msg, to, val, (NetworkDelivery)3);
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void SendAll(string msg, Action<FastBufferWriter> write)
		{
			//IL_0033: 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)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.IsServer)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, 4096);
			try
			{
				write(val);
				foreach (ulong connectedClientsId in singleton.ConnectedClientsIds)
				{
					if (connectedClientsId != 0L)
					{
						singleton.CustomMessagingManager.SendNamedMessage(msg, connectedClientsId, val, (NetworkDelivery)3);
					}
				}
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
		}
	}
	internal class View
	{
		internal static View Current = new View();

		internal bool Known;

		internal bool Enabled = true;

		internal bool NeedQuotaMet = true;

		internal bool Spinning;

		internal int SpinsLeft = 1;

		internal int StakePercent = 20;

		internal int MinStake = 25;

		internal int MaxStake = 1500;

		internal void Write(FastBufferWriter w)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0036: 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_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref Enabled, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref NeedQuotaMet, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref Spinning, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref SpinsLeft, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref StakePercent, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref MinStake, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref MaxStake, default(ForPrimitives));
		}

		internal void Read(FastBufferReader r)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0036: 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_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref Enabled, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref NeedQuotaMet, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref Spinning, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref SpinsLeft, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref StakePercent, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref MinStake, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref MaxStake, default(ForPrimitives));
			Known = true;
		}
	}
	internal class SpinMsg
	{
		internal float From;

		internal float To;

		internal float Seconds;

		internal int Segment;

		internal int Stake;

		internal int Payout;

		internal int SalePercent;

		internal bool Growl;

		internal bool Test;

		internal string Who = "";

		internal string ItemName = "";

		internal Kind Kind => Outcomes.Layout[Segment];

		internal void Write(FastBufferWriter w)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0036: 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_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00ba: 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)
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref From, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref To, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref Seconds, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Segment, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Stake, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Payout, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref SalePercent, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref Growl, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref Test, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe(Who ?? "", false);
			((FastBufferWriter)(ref w)).WriteValueSafe(ItemName ?? "", false);
		}

		internal void Read(FastBufferReader r)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0036: 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_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00ba: 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)
			((FastBufferReader)(ref r)).ReadValueSafe<float>(ref From, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<float>(ref To, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<float>(ref Seconds, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref Segment, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref Stake, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref Payout, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref SalePercent, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref Growl, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref Test, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe(ref Who, false);
			((FastBufferReader)(ref r)).ReadValueSafe(ref ItemName, false);
			if (Segment < 0 || Segment >= Outcomes.Layout.Length)
			{
				Segment = 0;
			}
		}
	}
	[HarmonyPatch]
	internal static class NetPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartOfRoundStart()
		{
			Net.Register();
		}

		[HarmonyPatch(typeof(StartOfRound), "OnDestroy")]
		[HarmonyPrefix]
		private static void StartOfRoundDestroy()
		{
			Net.Unregister();
		}
	}
	internal enum Kind : byte
	{
		Jackpot,
		Double,
		Even,
		Half,
		Bust,
		Item,
		Sale,
		Scare
	}
	internal static class Outcomes
	{
		internal static readonly Kind[] Layout = new Kind[16]
		{
			Kind.Jackpot,
			Kind.Half,
			Kind.Double,
			Kind.Bust,
			Kind.Item,
			Kind.Half,
			Kind.Double,
			Kind.Sale,
			Kind.Scare,
			Kind.Even,
			Kind.Half,
			Kind.Double,
			Kind.Bust,
			Kind.Item,
			Kind.Even,
			Kind.Sale
		};

		internal const float SegDeg = 22.5f;

		internal static readonly string[] Labels = new string[8] { "JACKPOT", "x2", "EVEN", "HALF", "BUST", "FREE ITEM", "SALE", "SCARE" };

		internal static int Payout(Kind k, int stake)
		{
			return Mathf.Max(0, Mathf.RoundToInt((float)stake * k switch
			{
				Kind.Jackpot => Plugin.JackpotTimes.Value, 
				Kind.Double => Plugin.DoubleTimes.Value, 
				Kind.Even => 1f, 
				Kind.Half => Plugin.HalfTimes.Value, 
				_ => 0f, 
			}));
		}

		internal static bool Good(Kind k)
		{
			if (k != Kind.Jackpot && k != Kind.Double && k != Kind.Item)
			{
				return k == Kind.Sale;
			}
			return true;
		}

		internal static int SegmentAt(float angle)
		{
			return Mathf.Clamp((int)(Mod(0f - angle, 360f) / 22.5f), 0, Layout.Length - 1);
		}

		internal static float StopAngle(float from, int k, float f, int turns)
		{
			float num = Mod((0f - ((float)k + f)) * 22.5f, 360f);
			return from + (float)turns * 360f + Mod(num - from, 360f);
		}

		internal static float Mod(float a, float m)
		{
			a %= m;
			if (!(a < 0f))
			{
				return a;
			}
			return a + m;
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "daniel.lethalcompany.quotaroulette";

		public const string Name = "Quota Roulette";

		public const string Version = "0.1.0";
	}
	[BepInPlugin("daniel.lethalcompany.quotaroulette", "Quota Roulette", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> NeedQuotaMet;

		internal static ConfigEntry<int> SpinsPerQuota;

		internal static ConfigEntry<int> StakePercent;

		internal static ConfigEntry<int> MinStake;

		internal static ConfigEntry<int> MaxStake;

		internal static ConfigEntry<float> SpinSeconds;

		internal static ConfigEntry<float> JackpotTimes;

		internal static ConfigEntry<float> DoubleTimes;

		internal static ConfigEntry<float> HalfTimes;

		internal static ConfigEntry<int> SalePercent;

		internal static ConfigEntry<int> FreeItemMaxPrice;

		internal static ConfigEntry<bool> ScareGrowl;

		internal static ConfigEntry<float> Volume;

		internal static ConfigEntry<bool> ManualPlacement;

		internal static ConfigEntry<float> PlaceOut;

		internal static ConfigEntry<float> PlaceAlong;

		internal static ConfigEntry<float> PlaceTurn;

		private readonly Harmony _harmony = new Harmony("daniel.lethalcompany.quotaroulette");

		private void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Expected O, but got Unknown
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Wheel (host)", "Enabled", true, "Off: the wheel still stands at the Company but can't be spun.");
			NeedQuotaMet = ((BaseUnityPlugin)this).Config.Bind<bool>("Wheel (host)", "Need quota met", true, "Only spin once the crew has sold enough to meet this quota.");
			SpinsPerQuota = ((BaseUnityPlugin)this).Config.Bind<int>("Wheel (host)", "Spins per quota", 1, new ConfigDescription("Spins the crew gets each quota.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			StakePercent = ((BaseUnityPlugin)this).Config.Bind<int>("Wheel (host)", "Stake percent", 20, new ConfigDescription("A spin stakes this percent of the credits sold toward this quota.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			MinStake = ((BaseUnityPlugin)this).Config.Bind<int>("Wheel (host)", "Min stake", 25, new ConfigDescription("The stake is never below this many credits.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
			MaxStake = ((BaseUnityPlugin)this).Config.Bind<int>("Wheel (host)", "Max stake", 1500, new ConfigDescription("The stake is never above this many credits.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100000), Array.Empty<object>()));
			SpinSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Wheel (host)", "Spin seconds", 7f, new ConfigDescription("About how long a spin lasts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), Array.Empty<object>()));
			JackpotTimes = ((BaseUnityPlugin)this).Config.Bind<float>("Prizes (host)", "Jackpot pays", 3f, new ConfigDescription("JACKPOT (1 segment of 16) pays the stake back times this.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			DoubleTimes = ((BaseUnityPlugin)this).Config.Bind<float>("Prizes (host)", "x2 pays", 2f, new ConfigDescription("x2 (3 segments) pays the stake back times this.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			HalfTimes = ((BaseUnityPlugin)this).Config.Bind<float>("Prizes (host)", "Half pays", 0.5f, new ConfigDescription("HALF (3 segments) pays the stake back times this. EVEN (2) pays it back; BUST (2) and SCARE (1) pay nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			SalePercent = ((BaseUnityPlugin)this).Config.Bind<int>("Prizes (host)", "Sale percent", 30, new ConfigDescription("SALE (2 segments): this percent off everything in the store, today and the next day.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 90), Array.Empty<object>()));
			FreeItemMaxPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Prizes (host)", "Free item max price", 400, new ConfigDescription("FREE ITEM (2 segments) drops a random store item costing up to this in front of the wheel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100000), Array.Empty<object>()));
			ScareGrowl = ((BaseUnityPlugin)this).Config.Bind<bool>("Prizes (host)", "Scare growl", true, "SCARE (1 segment): the Company growls from behind the counter and screens shake. It never attacks.");
			Volume = ((BaseUnityPlugin)this).Config.Bind<float>("Local", "Volume", 1f, new ConfigDescription("Wheel sounds for you (0-1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ManualPlacement = ((BaseUnityPlugin)this).Config.Bind<bool>("Local", "Manual placement", false, "Off: the wheel finds a clear spot beside the counter. On: it stands at the offsets below, from the sell desk.");
			PlaceOut = ((BaseUnityPlugin)this).Config.Bind<float>("Local", "Out from desk (m)", 4f, new ConfigDescription("Manual placement: metres out from the desk toward the yard.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-20f, 20f), Array.Empty<object>()));
			PlaceAlong = ((BaseUnityPlugin)this).Config.Bind<float>("Local", "Along wall (m)", 5f, new ConfigDescription("Manual placement: metres along the wall (positive is away from the ship's side).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-20f, 20f), Array.Empty<object>()));
			PlaceTurn = ((BaseUnityPlugin)this).Config.Bind<float>("Local", "Turn (deg)", 0f, new ConfigDescription("An extra turn for the wheel, either placement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>()));
			ManualPlacement.SettingChanged += delegate
			{
				Wheel.Replace();
			};
			PlaceOut.SettingChanged += delegate
			{
				Wheel.Replace();
			};
			PlaceAlong.SettingChanged += delegate
			{
				Wheel.Replace();
			};
			PlaceTurn.SettingChanged += delegate
			{
				Wheel.Replace();
			};
			Art.Load();
			_harmony.PatchAll(typeof(Plugin).Assembly);
			SceneManager.sceneLoaded += Wheel.OnSceneLoaded;
			if (Chainloader.PluginInfos.ContainsKey("daniel.lethalcompany.modmenu"))
			{
				try
				{
					MenuHooks.Register();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Quota Roulette: no F6 tab (needs ModMenu 0.3.6 or newer): " + ex.GetType().Name));
				}
			}
			Log.LogInfo((object)"Quota Roulette 0.1.0 loaded.");
		}
	}
	internal static class Wheel
	{
		internal static GameObject Root;

		internal static float Angle;

		private static readonly Vector3 C = new Vector3(0f, 1.75f, 0f);

		private const float FaceR = 0.92f;

		private const float BackR = 1.1f;

		private const float BulbR = 1.04f;

		private const int Bulbs = 24;

		private static Transform _disc;

		private static Transform _pointer;

		private static MeshRenderer[] _bulbs;

		private static Material _bulbOn;

		private static Material _bulbOff;

		private static Mesh _status;

		private static string _statusText;

		private static AudioSource _audio;

		private static InteractTrigger _trigger;

		private static readonly List<ParticleSystem> _confetti = new List<ParticleSystem>();

		private static HDAdditionalLightData _lamp;

		private static float _flick;

		private static float _flickSign = 1f;

		private static float _resultUntil;

		private static float _celebrateUntil;

		private static float _viewTimer;

		private static float _buildAt = -1f;

		private static int _lastPeg;

		private static int _tries;

		private static string _result;

		internal static bool Built => (Object)(object)Root != (Object)null;

		internal static Vector3 DropPoint
		{
			get
			{
				//IL_0030: 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_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_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Root != (Object)null)
				{
					return Root.transform.TransformPoint(new Vector3(Random.Range(-0.4f, 0.4f), 0.8f, 1.3f));
				}
				DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>();
				if (!((Object)(object)val != (Object)null))
				{
					return Vector3.zero;
				}
				return ((Component)val).transform.position + Vector3.up;
			}
		}

		internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			Runner.Ensure();
			if (((Scene)(ref scene)).name == "CompanyBuilding")
			{
				_buildAt = Time.time + 1.5f;
				_tries = 0;
			}
		}

		internal static void Replace()
		{
			if (Built)
			{
				Remove();
				Build();
			}
		}

		internal static void Fail()
		{
			Remove();
		}

		private static void Remove()
		{
			if ((Object)(object)Root != (Object)null)
			{
				Root.SetActive(false);
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			_disc = null;
			_pointer = null;
			_bulbs = null;
			_status = null;
			_statusText = null;
			_audio = null;
			_trigger = null;
			_lamp = null;
			_confetti.Clear();
		}

		private static bool Floor(Vector3 p, float refY, int mask, out Vector3 floor)
		{
			//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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			floor = p;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(new Vector3(p.x, refY + 2f, p.z), Vector3.down, ref val, 5f, mask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (Mathf.Abs(((RaycastHit)(ref val)).point.y - refY) > 1.2f || ((RaycastHit)(ref val)).normal.y < 0.8f)
			{
				return false;
			}
			floor = ((RaycastHit)(ref val)).point;
			return true;
		}

		private static float SegDist(Vector3 p, Vector3 a, Vector3 b)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			p.y = (a.y = (b.y = 0f));
			Vector3 val = b - a;
			float num = ((((Vector3)(ref val)).sqrMagnitude < 0.0001f) ? 0f : Mathf.Clamp01(Vector3.Dot(p - a, val) / ((Vector3)(ref val)).sqrMagnitude));
			return Vector3.Distance(p, a + val * num);
		}

		private static void Place(DepositItemsDesk desk, out Vector3 pos, out Quaternion rot)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004c: 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_006d: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00a3: 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_00b4: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00d9: 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_00e7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: 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)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			int num = (((Object)(object)instance != (Object)null) ? instance.collidersAndRoomMaskAndDefault : 1107298561);
			Vector3 val;
			if (!((Object)(object)desk.triggerCollider != (Object)null))
			{
				val = ((Component)desk).transform.position;
			}
			else
			{
				Bounds bounds = ((Collider)desk.triggerCollider).bounds;
				val = ((Bounds)(ref bounds)).center;
			}
			Vector3 val2 = val;
			Vector3 val3 = (((Object)(object)instance != (Object)null && (Object)(object)instance.shipDoorNode != (Object)null) ? instance.shipDoorNode.position : (((Object)(object)instance != (Object)null) ? instance.elevatorTransform.position : (val2 + Vector3.right * 15f)));
			Vector3 outward = (((val3 - val2).x >= 0f) ? Vector3.right : Vector3.left);
			Vector3 val4 = (((val3 - val2).z <= 0f) ? Vector3.forward : Vector3.back);
			float num2 = val2.y - 1f;
			RaycastHit val5 = default(RaycastHit);
			if (Physics.Raycast(val2 + outward * 1.5f + Vector3.up * 0.5f, Vector3.down, ref val5, 5f, num, (QueryTriggerInteraction)1))
			{
				num2 = ((RaycastHit)(ref val5)).point.y;
			}
			ItemDropship val6 = Object.FindObjectOfType<ItemDropship>();
			Vector3 look = val2 + outward * 4f;
			look.y = num2;
			if (Plugin.ManualPlacement.Value)
			{
				Vector3 val7 = val2 + outward * Plugin.PlaceOut.Value + val4 * Plugin.PlaceAlong.Value;
				if (!Floor(val7, num2, num, out pos))
				{
					pos = new Vector3(val7.x, num2, val7.z);
				}
				rot = Facing(pos);
				return;
			}
			Vector3 val8 = Vector3.zero;
			bool flag = false;
			float[] array = new float[6] { 4f, 5f, 3.2f, 6f, 7f, 8.5f };
			foreach (float num3 in array)
			{
				float[] array2 = new float[2] { 1f, -1f };
				foreach (float num4 in array2)
				{
					float[] array3 = new float[4] { 2.5f, 1.8f, 3.5f, 5f };
					foreach (float num5 in array3)
					{
						if (!Floor(val2 + outward * num5 + val4 * (num3 * num4), num2, num, out var floor))
						{
							continue;
						}
						if (!flag)
						{
							val8 = floor;
							flag = true;
						}
						if (!(SegDist(floor, val2, val3) < 2.2f) && (!((Object)(object)val6 != (Object)null) || !(Vector3.Distance(floor, ((Component)val6).transform.position) < 4f)))
						{
							Quaternion val9 = Facing(floor);
							if (!Physics.CheckBox(floor + Vector3.up * 1.75f, new Vector3(1.15f, 1.6f, 0.45f), val9, num, (QueryTriggerInteraction)1))
							{
								pos = floor;
								rot = val9;
								return;
							}
						}
					}
				}
			}
			Plugin.Log.LogWarning((object)"Quota Roulette: no clear spot found beside the counter; standing it at the first floor found (Manual placement can move it).");
			pos = (flag ? val8 : (new Vector3(val2.x, num2, val2.z) + outward * 2.5f + val4 * 4f));
			rot = Facing(pos);
			Quaternion Facing(Vector3 at)
			{
				//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_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_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_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val10 = look - at;
				val10.y = 0f;
				if (((Vector3)(ref val10)).sqrMagnitude < 0.25f)
				{
					val10 = outward;
				}
				return Quaternion.LookRotation(((Vector3)(ref val10)).normalized, Vector3.up) * Quaternion.Euler(0f, Plugin.PlaceTurn.Value, 0f);
			}
		}

		private static void Build()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0041: 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_0056: 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_00b8: 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_0114: 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_0177: 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)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0850: Unknown result type (might be due to invalid IL or missing references)
			//IL_085d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_090f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0723: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Expected O, but got Unknown
			//IL_0764: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_0783: Expected O, but got Unknown
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0967: Unknown result type (might be due to invalid IL or missing references)
			//IL_096c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0979: Unknown result type (might be due to invalid IL or missing references)
			//IL_097f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
			DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>();
			if ((Object)(object)val == (Object)null || (Object)(object)Art.Face == (Object)null)
			{
				return;
			}
			Place(val, out var pos, out var rot);
			Root = new GameObject("QuotaRoulette.Wheel");
			SceneManager.MoveGameObjectToScene(Root, ((Component)val).gameObject.scene);
			Root.transform.SetPositionAndRotation(pos, rot);
			Transform transform = Root.transform;
			Material src = Art.LitSource((Component)(object)val);
			Material mat = Art.Lit(src, "Red", new Color(0.42f, 0.05f, 0.04f), 0.35f, 0.45f);
			Material val2 = Art.Lit(src, "Steel", new Color(0.13f, 0.13f, 0.14f), 0.85f, 0.5f);
			Material val3 = Art.Lit(src, "Brass", new Color(0.8f, 0.6f, 0.26f), 0.9f, 0.62f);
			Material sharedMaterial = Art.Lit(src, "Face", Color.white, 0f, 0.4f, (Texture)(object)Art.Face);
			_bulbOn = Art.Unlit("BulbOn", new Color(1f, 0.86f, 0.45f)) ?? val3;
			_bulbOff = Art.Unlit("BulbOff", new Color(0.3f, 0.17f, 0.07f)) ?? val2;
			Mesh mesh = Art.Prim((PrimitiveType)3);
			Mesh mesh2 = Art.Prim((PrimitiveType)2);
			Mesh mesh3 = Art.Prim((PrimitiveType)0);
			Part("Base", transform, mesh, mat, new Vector3(0f, 0.06f, -0.1f), Quaternion.identity, new Vector3(1.8f, 0.12f, 0.8f));
			Part("Plinth", transform, mesh, val2, new Vector3(0f, 0.15f, -0.12f), Quaternion.identity, new Vector3(1.5f, 0.06f, 0.5f));
			float[] array = new float[2] { -0.7f, 0.7f };
			foreach (float num in array)
			{
				Part("Leg", transform, mesh, val2, new Vector3(num, 1.65f, -0.14f), Quaternion.identity, new Vector3(0.08f, 3.3f, 0.08f));
			}
			Quaternion rot2 = Quaternion.Euler(90f, 0f, 0f);
			Part("Back", transform, mesh2, mat, C + new Vector3(0f, 0f, -0.06f), rot2, new Vector3(2.2f, 0.04f, 2.2f));
			Part("Axle", transform, mesh2, val2, C + new Vector3(0f, 0f, -0.12f), rot2, new Vector3(0.12f, 0.05f, 0.12f));
			_disc = new GameObject("Disc").transform;
			_disc.SetParent(transform, false);
			_disc.localPosition = C;
			GameObject val4 = new GameObject("Face");
			val4.transform.SetParent(_disc, false);
			val4.AddComponent<MeshFilter>().sharedMesh = Art.Disc(0.92f);
			((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
			Part("Hub", _disc, mesh2, val3, new Vector3(0f, 0f, 0.03f), rot2, new Vector3(0.2f, 0.03f, 0.2f));
			for (int j = 0; j < Outcomes.Layout.Length; j++)
			{
				Part("Peg", _disc, mesh2, val3, Quaternion.Euler(0f, 0f, (float)j * 22.5f) * new Vector3(0f, 0.87f, 0f) + new Vector3(0f, 0f, 0.03f), rot2, new Vector3(0.03f, 0.03f, 0.03f));
			}
			GameObject val5 = new GameObject("Rim");
			val5.transform