Decompiled source of CaseOpening v1.0.3

Games/CaseOpening/CaseOpening.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Mirror;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("41d4debe-2d40-4287-8f4d-5f2dfc5b782e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CaseOpeningMod
{
	[BepInPlugin("com.Syd4r.caseopening", "Case Opening", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CaseOpeningPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Case Opening Assembly loaded by BepInEx! Waiting for Base Loader...");
		}
	}
}
namespace MoreGamesBase
{
	public class CaseOpening : GameBase
	{
		public enum Rarity
		{
			Blue,
			Purple,
			Pink,
			Red,
			Gold
		}

		public enum Wear
		{
			FactoryNew,
			MinimalWear,
			FieldTested,
			WellWorn,
			BattleScarred
		}

		[CompilerGenerated]
		private sealed class <ServerResolveSpin>d__50 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Rarity rarity;

			public int itemIndex;

			public Wear wear;

			public bool isStatTrak;

			public int pattern;

			public float delay;

			public CaseOpening <>4__this;

			private float <finalMultiplier>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ServerResolveSpin>d__50(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<finalMultiplier>5__1 = <>4__this.CalculateFinalMultiplier(rarity, itemIndex, wear, isStatTrak, pattern);
					if (<finalMultiplier>5__1 > 0f)
					{
						((GameBase)<>4__this).Payout((double)<finalMultiplier>5__1, (ChangeType)1, (Dictionary<string, object>)null, -1L);
					}
					<>2__current = (object)new WaitForSeconds(0.7f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					((GameBase)<>4__this).ResetGame();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitAndReveal>d__55 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Rarity rarity;

			public int itemIndex;

			public Wear wear;

			public bool isStatTrak;

			public int pattern;

			public CaseOpening <>4__this;

			private Vector3 <finalWorldPos>5__1;

			private GameObject <realItemPrefab>5__2;

			private GameObject <finalSpriteObj>5__3;

			private SpriteRenderer <finalSr>5__4;

			private Vector3 <startLocalPos>5__5;

			private Vector3 <targetLocalPos>5__6;

			private Vector3 <startScale>5__7;

			private Vector3 <targetScale>5__8;

			private float <animTime>5__9;

			private float <animDuration>5__10;

			private float <finalMult>5__11;

			private float <textDelay>5__12;

			private string <coloredFinalMult>5__13;

			private float <t>5__14;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitAndReveal>d__55(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<realItemPrefab>5__2 = null;
				<finalSpriteObj>5__3 = null;
				<finalSr>5__4 = null;
				<coloredFinalMult>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Expected O, but got Unknown
				//IL_00f2: 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_0393: 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_0314: 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_0325: Unknown result type (might be due to invalid IL or missing references)
				//IL_033c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0342: Unknown result type (might be due to invalid IL or missing references)
				//IL_034d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Unknown result type (might be due to invalid IL or missing references)
				//IL_024a: Unknown result type (might be due to invalid IL or missing references)
				//IL_025b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0260: Unknown result type (might be due to invalid IL or missing references)
				//IL_0267: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_0276: Unknown result type (might be due to invalid IL or missing references)
				//IL_028d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: Unknown result type (might be due to invalid IL or missing references)
				//IL_029c: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.spinDuration + 0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.activeCenterLine != (Object)null)
					{
						Object.Destroy((Object)(object)<>4__this.activeCenterLine);
						<>4__this.activeCenterLine = null;
					}
					if ((Object)(object)<>4__this.winningItemInstance == (Object)null)
					{
						return false;
					}
					<>4__this.isRevealing = true;
					<>4__this.skipReveal = false;
					<finalWorldPos>5__1 = <>4__this.winningItemInstance.transform.position;
					if ((Object)(object)<>4__this.stripContainer != (Object)null)
					{
						((Component)<>4__this.stripContainer).gameObject.SetActive(false);
					}
					<realItemPrefab>5__2 = <>4__this.GetPrefabRef(rarity, itemIndex, isSpinningView: false);
					<finalSpriteObj>5__3 = Object.Instantiate<GameObject>(<realItemPrefab>5__2);
					if (<>4__this.instanceLayer != -1)
					{
						<>4__this.SetLayerRecursively(<finalSpriteObj>5__3, <>4__this.instanceLayer);
					}
					<finalSpriteObj>5__3.transform.SetParent(<>4__this.backgroundParent, true);
					<finalSpriteObj>5__3.transform.position = <finalWorldPos>5__1;
					<finalSpriteObj>5__3.transform.localRotation = Quaternion.identity;
					<>4__this.activeRewards.Add(<finalSpriteObj>5__3);
					<finalSr>5__4 = <finalSpriteObj>5__3.GetComponentInChildren<SpriteRenderer>();
					if ((Object)(object)<finalSr>5__4 != (Object)null)
					{
						((Renderer)<finalSr>5__4).sortingOrder = 50;
					}
					<startLocalPos>5__5 = <finalSpriteObj>5__3.transform.localPosition;
					<targetLocalPos>5__6 = new Vector3(0.2f, 0f, 1.5f);
					<startScale>5__7 = <finalSpriteObj>5__3.transform.localScale;
					<targetScale>5__8 = <startScale>5__7 * 1.7f;
					if (rarity == Rarity.Gold)
					{
						<targetScale>5__8 = <startScale>5__7 * 2.3f;
					}
					<animTime>5__9 = 0f;
					<animDuration>5__10 = 0.4f;
					goto IL_0370;
				case 2:
					<>1__state = -1;
					goto IL_0370;
				case 3:
					<>1__state = -1;
					goto IL_0491;
				case 4:
					<>1__state = -1;
					goto IL_0541;
				case 5:
					<>1__state = -1;
					goto IL_05e3;
				case 6:
					{
						<>1__state = -1;
						break;
					}
					IL_0370:
					if (<animTime>5__9 < <animDuration>5__10 && !<>4__this.skipReveal)
					{
						<animTime>5__9 += Time.deltaTime;
						<t>5__14 = Mathf.SmoothStep(0f, 1f, <animTime>5__9 / <animDuration>5__10);
						<finalSpriteObj>5__3.transform.localPosition = Vector3.Lerp(<startLocalPos>5__5, <targetLocalPos>5__6, <t>5__14);
						<finalSpriteObj>5__3.transform.localScale = Vector3.Lerp(<startScale>5__7, <targetScale>5__8, <t>5__14);
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					<finalSpriteObj>5__3.transform.localPosition = <targetLocalPos>5__6;
					<finalSpriteObj>5__3.transform.localScale = <targetScale>5__8;
					<finalMult>5__11 = <>4__this.CalculateFinalMultiplier(rarity, itemIndex, wear, isStatTrak, pattern);
					<textDelay>5__12 = 0.2f;
					if ((Object)(object)<>4__this.revealTextBase != (Object)null)
					{
						((TMP_Text)<>4__this.revealTextBase).text = "Rarity Multiplier: " + <>4__this.GetBaseMultString(rarity);
						((Component)<>4__this.revealTextBase).gameObject.SetActive(true);
					}
					if (!<>4__this.skipReveal)
					{
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WaitForSkip(<textDelay>5__12));
						<>1__state = 3;
						return true;
					}
					goto IL_0491;
					IL_0541:
					if ((Object)(object)<>4__this.revealTextWear != (Object)null)
					{
						((TMP_Text)<>4__this.revealTextWear).text = "Wear: " + <>4__this.GetWearString(wear);
						((Component)<>4__this.revealTextWear).gameObject.SetActive(true);
					}
					if (!<>4__this.skipReveal)
					{
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WaitForSkip(<textDelay>5__12));
						<>1__state = 5;
						return true;
					}
					goto IL_05e3;
					IL_0491:
					if ((Object)(object)<>4__this.revealTextStatTrak != (Object)null)
					{
						if (isStatTrak)
						{
							((TMP_Text)<>4__this.revealTextStatTrak).text = "<color=#eb4b4b>StatTrak™</color>";
						}
						else
						{
							((TMP_Text)<>4__this.revealTextStatTrak).text = "<color=#000000>No StatTrak</color>";
						}
						((Component)<>4__this.revealTextStatTrak).gameObject.SetActive(true);
					}
					if (!<>4__this.skipReveal)
					{
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WaitForSkip(<textDelay>5__12));
						<>1__state = 4;
						return true;
					}
					goto IL_0541;
					IL_05e3:
					if ((Object)(object)<>4__this.revealTextPattern != (Object)null)
					{
						if (rarity == Rarity.Pink && itemIndex == 0 && (pattern == 661 || pattern == 151 || pattern == 955 || pattern == 321 || pattern == 387))
						{
							((TMP_Text)<>4__this.revealTextPattern).text = $"Pattern: {pattern} <color=#4b69ff>(BLUE GEM!)</color>";
						}
						else
						{
							((TMP_Text)<>4__this.revealTextPattern).text = $"Pattern: {pattern}";
						}
						((Component)<>4__this.revealTextPattern).gameObject.SetActive(true);
					}
					if (!<>4__this.skipReveal)
					{
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WaitForSkip(<textDelay>5__12));
						<>1__state = 6;
						return true;
					}
					break;
				}
				if (<finalMult>5__11 >= 10f)
				{
					<coloredFinalMult>5__13 = "<color=#d4af37>" + <finalMult>5__11.ToString("0.##") + "x</color>";
				}
				else if (<finalMult>5__11 >= 1f)
				{
					<coloredFinalMult>5__13 = "<color=#00ff00>" + <finalMult>5__11.ToString("0.##") + "x</color>";
				}
				else
				{
					<coloredFinalMult>5__13 = "<color=#ff0000>" + <finalMult>5__11.ToString("0.##") + "x</color>";
				}
				if ((Object)(object)<>4__this.revealTextTotal != (Object)null)
				{
					((TMP_Text)<>4__this.revealTextTotal).text = "TOTAL WIN: " + <coloredFinalMult>5__13;
					((Component)<>4__this.revealTextTotal).gameObject.SetActive(true);
				}
				<>4__this.isRevealing = false;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForSkip>d__56 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float duration;

			public CaseOpening <>4__this;

			private float <t>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForSkip>d__56(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__1 < duration)
				{
					if (<>4__this.skipReveal)
					{
						return false;
					}
					<t>5__1 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("Scene References")]
		public Camera externalCamera;

		public Transform backgroundParent;

		public GameObject itemPrefab;

		public GameObject centerLinePrefab;

		public GameObject openCase;

		[Header("Text Reveals")]
		public TextMeshPro revealTextBase;

		public TextMeshPro revealTextStatTrak;

		public TextMeshPro revealTextWear;

		public TextMeshPro revealTextPattern;

		public TextMeshPro revealTextTotal;

		[Header("Item Pools")]
		public GameObject[] blueItems;

		public GameObject[] purpleItems;

		public GameObject[] pinkItems;

		public GameObject[] redItems;

		public GameObject goldIcon;

		public GameObject[] goldItems;

		private readonly float spinDuration = 6f;

		private readonly float itemSpacing = 0.41f;

		private readonly int itemsInStrip = 40;

		private readonly int winningSlotIndex = 35;

		private readonly Color colBlue = new Color(0.29f, 0.41f, 1f);

		private readonly Color colPurple = new Color(0.53f, 0.28f, 1f);

		private readonly Color colPink = new Color(0.83f, 0.17f, 0.9f);

		private readonly Color colRed = new Color(0.92f, 0.29f, 0.29f);

		private readonly Color colGold = new Color(0.89f, 0.68f, 0.22f);

		private List<GameObject> activeRewards = new List<GameObject>();

		private Transform stripContainer;

		private GameObject winningItemInstance;

		private GameObject activeCenterLine;

		private bool isSpinning = false;

		private bool isRevealing = false;

		private bool skipReveal = false;

		private float spinTimer = 0f;

		private float startX = 0f;

		private float targetX = 0f;

		private static int nextAvailableLayer = 31;

		private int instanceLayer = -1;

		private void Start()
		{
			IsolateCameraAndAssets();
			HideRevealText();
			ApplyTextGlow(revealTextBase);
			ApplyTextGlow(revealTextStatTrak);
			ApplyTextGlow(revealTextWear);
			ApplyTextGlow(revealTextPattern);
			ApplyTextGlow(revealTextTotal);
		}

		private void IsolateCameraAndAssets()
		{
			instanceLayer = nextAvailableLayer;
			nextAvailableLayer--;
			if (nextAvailableLayer < 15)
			{
				nextAvailableLayer = 31;
			}
			if ((Object)(object)externalCamera != (Object)null)
			{
				externalCamera.cullingMask = 1 << instanceLayer;
			}
			if ((Object)(object)backgroundParent != (Object)null)
			{
				SetLayerRecursively(((Component)backgroundParent).gameObject, instanceLayer);
			}
			if ((Object)(object)openCase != (Object)null)
			{
				SetLayerRecursively(openCase, instanceLayer);
			}
			if ((Object)(object)revealTextBase != (Object)null)
			{
				SetLayerRecursively(((Component)revealTextBase).gameObject, instanceLayer);
			}
			if ((Object)(object)revealTextStatTrak != (Object)null)
			{
				SetLayerRecursively(((Component)revealTextStatTrak).gameObject, instanceLayer);
			}
			if ((Object)(object)revealTextWear != (Object)null)
			{
				SetLayerRecursively(((Component)revealTextWear).gameObject, instanceLayer);
			}
			if ((Object)(object)revealTextPattern != (Object)null)
			{
				SetLayerRecursively(((Component)revealTextPattern).gameObject, instanceLayer);
			}
			if ((Object)(object)revealTextTotal != (Object)null)
			{
				SetLayerRecursively(((Component)revealTextTotal).gameObject, instanceLayer);
			}
		}

		private void SetLayerRecursively(GameObject obj, int layer)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if ((Object)(object)obj == (Object)null)
			{
				return;
			}
			obj.layer = layer;
			foreach (Transform item in obj.transform)
			{
				Transform val = item;
				SetLayerRecursively(((Component)val).gameObject, layer);
			}
		}

		private void ApplyTextGlow(TextMeshPro tmp)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)tmp == (Object)null))
			{
				((TMP_Text)tmp).fontMaterial = new Material(((TMP_Text)tmp).fontSharedMaterial);
				((TMP_Text)tmp).fontMaterial.EnableKeyword("OUTLINE_ON");
				((TMP_Text)tmp).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color.white);
				((TMP_Text)tmp).fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.15f);
			}
		}

		public override bool Weaved()
		{
			return true;
		}

		public void BroadcastSpinSequence(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.CaseOpening::UserRpcSpinSequence(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		public void BroadcastClearStrip(string text)
		{
			if (NetworkServer.active)
			{
				string text2 = "System.Void MoreGamesBase.CaseOpening::UserRpcClearStrip(System.String)";
				int stableHashCode = Extensions.GetStableHashCode(text2);
				NetworkWriterPooled val = NetworkWriterPool.Get();
				NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text);
				((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true);
				NetworkWriterPool.Return(val);
			}
		}

		protected override void StartGame()
		{
			if (isRevealing)
			{
				skipReveal = true;
				return;
			}
			((GameBase)this).StartGame();
			if (((NetworkBehaviour)this).isServer)
			{
				BroadcastClearStrip("clear");
				Rarity randomRarity = GetRandomRarity();
				int randomIndexForRarity = GetRandomIndexForRarity(randomRarity);
				Wear randomWear = GetRandomWear(randomRarity);
				bool flag = Random.value <= 0.1f;
				int num = Random.Range(1, 1001);
				float num2 = itemSpacing / 2f * 0.8f;
				float num3 = Random.Range(0f - num2, num2);
				int num4 = Random.Range(1, int.MaxValue);
				string text = string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3},{4},{5:F3},{6}", (int)randomRarity, randomIndexForRarity, (int)randomWear, flag ? 1 : 0, num, num3, num4);
				BroadcastSpinSequence(text);
				float delay = spinDuration;
				((MonoBehaviour)this).StartCoroutine(ServerResolveSpin(randomRarity, randomIndexForRarity, randomWear, flag, num, delay));
			}
		}

		private Rarity GetRandomRarity()
		{
			float num = Random.Range(0f, 100f);
			if (num <= 1f)
			{
				return Rarity.Gold;
			}
			if (num <= 4f)
			{
				return Rarity.Red;
			}
			if (num <= 12f)
			{
				return Rarity.Pink;
			}
			if (num <= 35f)
			{
				return Rarity.Purple;
			}
			return Rarity.Blue;
		}

		private int GetRandomIndexForRarity(Rarity rarity)
		{
			return rarity switch
			{
				Rarity.Blue => Random.Range(0, blueItems.Length), 
				Rarity.Purple => Random.Range(0, purpleItems.Length), 
				Rarity.Pink => Random.Range(0, pinkItems.Length), 
				Rarity.Red => Random.Range(0, redItems.Length), 
				Rarity.Gold => Random.Range(0, goldItems.Length), 
				_ => 0, 
			};
		}

		private Wear GetRandomWear(Rarity rarity)
		{
			float num = Random.Range(0f, 1f);
			if (num < 0.05f)
			{
				return Wear.FactoryNew;
			}
			if (num < 0.15f)
			{
				return Wear.MinimalWear;
			}
			if (num < 0.4f)
			{
				return Wear.FieldTested;
			}
			if (num < 0.7f)
			{
				return Wear.WellWorn;
			}
			return Wear.BattleScarred;
		}

		[IteratorStateMachine(typeof(<ServerResolveSpin>d__50))]
		private IEnumerator ServerResolveSpin(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ServerResolveSpin>d__50(0)
			{
				<>4__this = this,
				rarity = rarity,
				itemIndex = itemIndex,
				wear = wear,
				isStatTrak = isStatTrak,
				pattern = pattern,
				delay = delay
			};
		}

		private float CalculateFinalMultiplier(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern)
		{
			float num = 0f;
			if (rarity == Rarity.Blue)
			{
				num = 0.1f;
			}
			if (rarity == Rarity.Purple)
			{
				num = 0.5f;
			}
			if (rarity == Rarity.Pink)
			{
				num = 2f;
			}
			if (rarity == Rarity.Red)
			{
				num = 8f;
			}
			if (rarity == Rarity.Gold)
			{
				float[] array = new float[10] { 23f, 15f, 15f, 17f, 35f, 12f, 12f, 10f, 4f, 12f };
				num = ((itemIndex < 0 || itemIndex >= array.Length) ? 50f : array[itemIndex]);
			}
			if (wear == Wear.FactoryNew)
			{
				num *= 2f;
			}
			if (wear == Wear.MinimalWear)
			{
				num *= 1.5f;
			}
			if (wear == Wear.FieldTested)
			{
				num *= 1f;
			}
			if (wear == Wear.WellWorn)
			{
				num *= 0.8f;
			}
			if (wear == Wear.BattleScarred)
			{
				num *= 0.5f;
			}
			if (isStatTrak)
			{
				num *= 1.5f;
			}
			if (rarity == Rarity.Pink && itemIndex == 0 && (pattern == 661 || pattern == 151 || pattern == 955 || pattern == 321 || pattern == 387))
			{
				num *= 50f;
			}
			return num;
		}

		public void UserRpcClearStrip(string networkText)
		{
			if (!NetworkClient.active)
			{
				return;
			}
			if ((Object)(object)openCase != (Object)null && openCase.activeSelf)
			{
				openCase.SetActive(false);
			}
			if ((Object)(object)activeCenterLine != (Object)null)
			{
				Object.Destroy((Object)(object)activeCenterLine);
				activeCenterLine = null;
			}
			foreach (GameObject activeReward in activeRewards)
			{
				if ((Object)(object)activeReward != (Object)null)
				{
					Object.Destroy((Object)(object)activeReward);
				}
			}
			activeRewards.Clear();
			winningItemInstance = null;
			if ((Object)(object)stripContainer != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)stripContainer).gameObject);
				stripContainer = null;
			}
			HideRevealText();
			isSpinning = false;
			isRevealing = false;
			skipReveal = false;
		}

		public void UserRpcSpinSequence(string networkText)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				return;
			}
			string[] array = networkText.Split(new char[1] { ',' });
			if (array.Length != 7)
			{
				return;
			}
			Rarity rarity = (Rarity)int.Parse(array[0]);
			int num = int.Parse(array[1]);
			Wear wear = (Wear)int.Parse(array[2]);
			bool isStatTrak = int.Parse(array[3]) == 1;
			int pattern = int.Parse(array[4]);
			float num2 = float.Parse(array[5], CultureInfo.InvariantCulture);
			int seed = int.Parse(array[6]);
			GenerateVisualStrip(rarity, num, seed);
			if ((Object)(object)centerLinePrefab != (Object)null)
			{
				activeCenterLine = Object.Instantiate<GameObject>(centerLinePrefab, backgroundParent, false);
				activeCenterLine.transform.localPosition = new Vector3(0f, 0f, 3f);
				activeCenterLine.transform.localScale = new Vector3(0.004f, 0.37f, 1f);
				if (instanceLayer != -1)
				{
					SetLayerRecursively(activeCenterLine, instanceLayer);
				}
			}
			startX = 0f;
			targetX = 0f - (float)winningSlotIndex * itemSpacing + num2;
			spinTimer = 0f;
			isSpinning = true;
			isRevealing = false;
			skipReveal = false;
			((MonoBehaviour)this).StartCoroutine(WaitAndReveal(rarity, num, wear, isStatTrak, pattern));
		}

		private void GenerateVisualStrip(Rarity winRarity, int winIndex, int seed)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_006a: 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_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0283: 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_021a: Unknown result type (might be due to invalid IL or missing references)
			State state = Random.state;
			Random.InitState(seed);
			GameObject val = new GameObject("StripContainer");
			if (instanceLayer != -1)
			{
				val.layer = instanceLayer;
			}
			stripContainer = val.transform;
			stripContainer.SetParent(backgroundParent, false);
			stripContainer.localPosition = new Vector3(0f, 0f, 0.6f);
			stripContainer.localScale = Vector3.one;
			for (int i = -15; i < itemsInStrip; i++)
			{
				Rarity rarity = winRarity;
				int index = winIndex;
				if (i != winningSlotIndex)
				{
					rarity = GetRandomRarity();
					index = GetRandomIndexForRarity(rarity);
				}
				GameObject val2 = new GameObject($"Slot_{i}");
				if (instanceLayer != -1)
				{
					val2.layer = instanceLayer;
				}
				val2.transform.SetParent(stripContainer, false);
				val2.transform.localPosition = new Vector3((float)i * itemSpacing, 0f, 0f);
				val2.transform.localScale = Vector3.one;
				if (i == winningSlotIndex)
				{
					winningItemInstance = val2;
				}
				GameObject val3 = Object.Instantiate<GameObject>(itemPrefab);
				val3.transform.SetParent(val2.transform, false);
				val3.transform.localPosition = new Vector3(0f, -0.17f, 0.1f);
				val3.transform.localScale = new Vector3(0.38f, 0.022f, 1f);
				if (instanceLayer != -1)
				{
					SetLayerRecursively(val3, instanceLayer);
				}
				Transform val4 = val3.transform.Find("itemBar");
				if ((Object)(object)val4 != (Object)null)
				{
					SpriteRenderer component = ((Component)val4).GetComponent<SpriteRenderer>();
					if ((Object)(object)component != (Object)null)
					{
						component.color = GetColorForRarity(rarity);
						((Renderer)component).sortingOrder = 2;
					}
				}
				GameObject prefabRef = GetPrefabRef(rarity, index, isSpinningView: true);
				if ((Object)(object)prefabRef != (Object)null)
				{
					GameObject val5 = Object.Instantiate<GameObject>(prefabRef);
					val5.transform.SetParent(val2.transform, false);
					val5.transform.localPosition = new Vector3(0f, 0f, 0.2f);
					val5.transform.localScale = new Vector3(0.06f, 0.08f, 1f);
					if (instanceLayer != -1)
					{
						SetLayerRecursively(val5, instanceLayer);
					}
					SpriteRenderer val6 = val5.GetComponent<SpriteRenderer>();
					if ((Object)(object)val6 == (Object)null)
					{
						val6 = val5.GetComponentInChildren<SpriteRenderer>();
					}
					if ((Object)(object)val6 != (Object)null)
					{
						((Renderer)val6).sortingOrder = 5;
					}
				}
			}
			Random.state = state;
		}

		[IteratorStateMachine(typeof(<WaitAndReveal>d__55))]
		private IEnumerator WaitAndReveal(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitAndReveal>d__55(0)
			{
				<>4__this = this,
				rarity = rarity,
				itemIndex = itemIndex,
				wear = wear,
				isStatTrak = isStatTrak,
				pattern = pattern
			};
		}

		[IteratorStateMachine(typeof(<WaitForSkip>d__56))]
		private IEnumerator WaitForSkip(float duration)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForSkip>d__56(0)
			{
				<>4__this = this,
				duration = duration
			};
		}

		private string GetWearString(Wear w)
		{
			return w switch
			{
				Wear.FactoryNew => "<color=#00ff00>FN</color>", 
				Wear.MinimalWear => "<color=#adff2f>MW</color>", 
				Wear.FieldTested => "<color=#ffff00>FT</color>", 
				Wear.WellWorn => "<color=#ffa500>WW</color>", 
				Wear.BattleScarred => "<color=#ff0000>BS</color>", 
				_ => "", 
			};
		}

		private GameObject GetPrefabRef(Rarity r, int index, bool isSpinningView)
		{
			return (GameObject)(r switch
			{
				Rarity.Gold => isSpinningView ? goldIcon : goldItems[index], 
				Rarity.Blue => blueItems[index], 
				Rarity.Purple => purpleItems[index], 
				Rarity.Pink => pinkItems[index], 
				Rarity.Red => redItems[index], 
				_ => null, 
			});
		}

		private Color GetColorForRarity(Rarity r)
		{
			//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_002b: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(r switch
			{
				Rarity.Blue => colBlue, 
				Rarity.Purple => colPurple, 
				Rarity.Pink => colPink, 
				Rarity.Red => colRed, 
				Rarity.Gold => colGold, 
				_ => Color.white, 
			});
		}

		private void Update()
		{
			//IL_00ad: 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)
			if (isRevealing)
			{
				skipReveal = true;
			}
			if (isSpinning && !((Object)(object)stripContainer == (Object)null))
			{
				spinTimer += Time.deltaTime;
				float num = Mathf.Clamp01(spinTimer / spinDuration);
				if (num >= 1f)
				{
					isSpinning = false;
				}
				float num2 = 1f - Mathf.Pow(1f - num, 3f);
				float num3 = Mathf.Lerp(startX, targetX, num2);
				stripContainer.localPosition = new Vector3(num3, stripContainer.localPosition.y, stripContainer.localPosition.z);
			}
		}

		private string GetBaseMultString(Rarity r)
		{
			return r switch
			{
				Rarity.Blue => "<color=#ff0000>0.1x</color>", 
				Rarity.Purple => "<color=#ff0000>0.5x</color>", 
				Rarity.Pink => "<color=#00ff00>2.0x</color>", 
				Rarity.Red => "<color=#d4af37>8.0x</color>", 
				Rarity.Gold => "<color=#d4af37>Variable</color>", 
				_ => "0x", 
			};
		}

		private void HideRevealText()
		{
			if (Object.op_Implicit((Object)(object)revealTextBase))
			{
				((Component)revealTextBase).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)revealTextStatTrak))
			{
				((Component)revealTextStatTrak).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)revealTextWear))
			{
				((Component)revealTextWear).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)revealTextPattern))
			{
				((Component)revealTextPattern).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)revealTextTotal))
			{
				((Component)revealTextTotal).gameObject.SetActive(false);
			}
		}
	}
}