Decompiled source of Owned Items v1.0.3

vesnum-owneditems-103.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPOVesnumStuffHolder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPOVesnumStuffHolder")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("69e1e82b-9865-4b33-af02-4ca7d0b0e603")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.Vesnum.owneditems", "Owned Items", "1.0.2")]
public class OwnedItemsPlugin : BaseUnityPlugin
{
	public static OwnedItemsPlugin instance;

	public static ConfigEntry<bool> EnableMod;

	public static ConfigEntry<KeyCode> PreviousPage;

	public static ConfigEntry<KeyCode> NextPage;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		instance = this;
		Harmony val = new Harmony("com.Vesnum.owneditems");
		val.PatchAll();
		SceneManager.sceneLoaded += OnSceneLoaded;
		ApplyConfigEntrys();
		Debug.Log((object)"[Owned Items] Scene loaded event subscribed. Good.");
	}

	private void ApplyConfigEntrys()
	{
		EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enables/Disables the mod");
		PreviousPage = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "PreviousPage", (KeyCode)276, "Previous Page key");
		NextPage = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "NextPage", (KeyCode)275, "Next Page key");
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		if ((Object)(object)GameObject.Find("OwnedItems_ModHandler") == (Object)null)
		{
			GameObject val = new GameObject("OwnedItems_ModHandler");
			val.AddComponent<OwnedItems_ModHandler>();
			Object.DontDestroyOnLoad((Object)(object)val);
		}
	}
}
public class OwnedItems_CustomTruckScreen : MonoBehaviourPunCallbacks
{
	[CompilerGenerated]
	private sealed class <AnimateTextWave>d__60 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public TextMeshProUGUI _text;

		public OwnedItems_CustomTruckScreen <>4__this;

		private TMP_TextInfo <textInfo>5__1;

		private float <waveSpeed>5__2;

		private float <waveHeight>5__3;

		private Vector3[] <vertices>5__4;

		private Vector3 <offset>5__5;

		private int <i>5__6;

		private int <meshIndex>5__7;

		private int <vertexIndex>5__8;

		private float <time>5__9;

		private float <wave>5__10;

		private int <i>5__11;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<textInfo>5__1 = null;
			<vertices>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)_text == (Object)null)
				{
					return false;
				}
				<textInfo>5__1 = ((TMP_Text)_text).textInfo;
				<waveSpeed>5__2 = 1f;
				<waveHeight>5__3 = 0.03f;
				((TMP_Text)_text).ForceMeshUpdate(false, false);
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)_text == (Object)null)
			{
				return false;
			}
			((TMP_Text)_text).ForceMeshUpdate(false, false);
			<textInfo>5__1 = ((TMP_Text)_text).textInfo;
			<i>5__6 = 0;
			while (<i>5__6 < <textInfo>5__1.characterCount)
			{
				if (<textInfo>5__1.characterInfo[<i>5__6].isVisible)
				{
					<meshIndex>5__7 = <textInfo>5__1.characterInfo[<i>5__6].materialReferenceIndex;
					<vertexIndex>5__8 = <textInfo>5__1.characterInfo[<i>5__6].vertexIndex;
					<vertices>5__4 = <textInfo>5__1.meshInfo[<meshIndex>5__7].vertices;
					<time>5__9 = Time.time;
					<wave>5__10 = Mathf.Sin(<time>5__9 * <waveSpeed>5__2 + (float)<i>5__6 * 0.3f) * <waveHeight>5__3;
					<offset>5__5 = new Vector3(0f, <wave>5__10, 0f);
					ref Vector3 reference = ref <vertices>5__4[<vertexIndex>5__8];
					reference += <offset>5__5;
					ref Vector3 reference2 = ref <vertices>5__4[<vertexIndex>5__8 + 1];
					reference2 += <offset>5__5;
					ref Vector3 reference3 = ref <vertices>5__4[<vertexIndex>5__8 + 2];
					reference3 += <offset>5__5;
					ref Vector3 reference4 = ref <vertices>5__4[<vertexIndex>5__8 + 3];
					reference4 += <offset>5__5;
				}
				<i>5__6++;
			}
			<i>5__11 = 0;
			while (<i>5__11 < <textInfo>5__1.meshInfo.Length)
			{
				<textInfo>5__1.meshInfo[<i>5__11].mesh.vertices = <textInfo>5__1.meshInfo[<i>5__11].vertices;
				((TMP_Text)_text).UpdateGeometry(<textInfo>5__1.meshInfo[<i>5__11].mesh, <i>5__11);
				<i>5__11++;
			}
			<>2__current = null;
			<>1__state = 1;
			return true;
		}

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

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

	public static OwnedItems_CustomTruckScreen instance;

	private bool isBatterySync = false;

	private bool isStuffShowned = false;

	private bool isShop;

	private bool masterHasMod = false;

	private bool isRightArrow = false;

	private bool isLeftArrow = false;

	private bool isEverythingDisabled = false;

	private int currentPageNumber = -1;

	private int totalPageNumber = 1;

	private int newPage;

	private int tryTimes = 3;

	private float countDownTimer = 0f;

	private float screenWaitTimer = 0f;

	private float refreshTimer = 4f;

	private float pageCoolDown = 0f;

	private string debugModName;

	private string currentPageText;

	private string currentPageValues;

	private string currentPageNEW;

	private GameObject truckScreenShop;

	private Vector4 originalMargin;

	private Color originalBGColor;

	private Coroutine waveRoutine;

	private Hashtable props;

	private string[] currentBuyKeys;

	private int[] currentBuyValues;

	private string[] currentBatteryBarKeys;

	private int[] currentBatteryBarValues;

	private Dictionary<string, int> beforeBuy;

	private Dictionary<string, int> currentBuy;

	private Dictionary<string, int> afterBuy;

	private Dictionary<string, int> currentBatteryBar;

	private Transform leftArrow;

	private Transform rightArrow;

	private TextMeshProUGUI arrowTextMesh;

	private TextMeshProUGUI itemTextMesh;

	private TextMeshProUGUI valueTextMesh;

	private TextMeshProUGUI NEWTextMesh;

	private TextMeshProUGUI infoTextMesh;

	private List<string> mostUsable;

	private void Awake()
	{
		instance = this;
	}

	private void Start()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//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_0274: Unknown result type (might be due to invalid IL or missing references)
		isShop = SemiFunc.RunIsShop();
		props = new Hashtable();
		debugModName = OwnedItems_ModHandler.debugModName;
		mostUsable = new List<string>
		{
			" Crystal", "Health Pack", " Grenade", " Mine", " Gun", " Melee", " Cannon", " Laser", " Drone", " Orb",
			" Rubber", " Bucket", " Phase", " Extraction", " Valuable", "Cart Small", "Cart Medium", " Upgrade"
		};
		if (IsMasterAndMasterHasMod())
		{
			currentBuy = new Dictionary<string, int>();
			currentBatteryBar = new Dictionary<string, int>();
			props[(object)"currentBuyKey"] = StatsManager.instance.itemsPurchased.Keys.ToArray();
			props[(object)"currentBuyValue"] = StatsManager.instance.itemsPurchased.Values.ToArray();
			props[(object)"currentBatteryBarKey"] = StatsManager.instance.itemStatBattery.Keys.ToArray();
			props[(object)"currentBatteryBarValue"] = StatsManager.instance.itemStatBattery.Values.ToArray();
			PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
		}
		else if (IsSingleOrMasterHasNotMod())
		{
			currentBuy = new Dictionary<string, int>(StatsManager.instance.itemsPurchased);
			currentBatteryBar = new Dictionary<string, int>(StatsManager.instance.itemStatBattery);
		}
		beforeBuy = new Dictionary<string, int>(StatsManager.instance.itemsPurchased);
		CheckScreens();
		originalMargin = ((TMP_Text)TruckScreenText.instance.textMesh).margin;
		originalBGColor = TruckScreenText.instance.mainBackgroundColor;
		if (!OwnedItems_ModHandler.IsLocked())
		{
			((TMP_Text)TruckScreenText.instance.textMesh).margin = new Vector4(0f, 0.3f, 0f, 0f);
		}
	}

	private void Update()
	{
		if (!isShop || OwnedItems_ModHandler.IsLocked())
		{
			if (!IsAnythingNull() && SemiFunc.IsMultiplayer())
			{
				RefreshScreen();
			}
			if (!isEverythingDisabled)
			{
				MakeEveryThingDisabled(onOff: true);
			}
			return;
		}
		if (isShop && !OwnedItems_ModHandler.IsLocked() && isEverythingDisabled)
		{
			MakeEveryThingDisabled(onOff: false);
		}
		CheckScreens();
		CheckTextMeshLinesForOwnedItems();
		PageController();
		ShowStuffsInShop();
		RefreshScreen();
	}

	public override void OnLeftLobby()
	{
		OwnedItems_ModHandler.modLock = true;
	}

	public override void OnDisconnected(DisconnectCause cause)
	{
		OwnedItems_ModHandler.modLock = true;
	}

	public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
	{
		if (((Dictionary<object, object>)(object)propertiesThatChanged).TryGetValue((object)"masterHasMod", out object value))
		{
			masterHasMod = (bool)value;
		}
		if (((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"currentPageNumber"))
		{
			currentPageNumber = (int)propertiesThatChanged[(object)"currentPageNumber"];
			isStuffShowned = false;
		}
		if (((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"currentBuyKey") && ((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"currentBuyValue"))
		{
			currentBuyKeys = (string[])((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)"currentBuyKey"];
			currentBuyValues = (int[])((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)"currentBuyValue"];
			if (currentBuy != null)
			{
				currentBuy.Clear();
			}
			for (int i = 0; i < currentBuyKeys.Length; i++)
			{
				currentBuy[currentBuyKeys[i]] = currentBuyValues[i];
			}
		}
		if (((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"currentBatteryBarKey") && ((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"currentBatteryBarValue") && !isBatterySync && currentBatteryBar != null)
		{
			currentBatteryBarKeys = (string[])((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)"currentBatteryBarKey"];
			currentBatteryBarValues = (int[])((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)"currentBatteryBarValue"];
			for (int j = 0; j < currentBatteryBarKeys.Length; j++)
			{
				currentBatteryBar[currentBatteryBarKeys[j]] = currentBatteryBarValues[j];
			}
			isBatterySync = true;
		}
	}

	private bool IsAnythingNull()
	{
		return (Object)(object)truckScreenShop == (Object)null || beforeBuy == null || afterBuy == null || (Object)(object)arrowTextMesh == (Object)null || (Object)(object)itemTextMesh == (Object)null || (Object)(object)valueTextMesh == (Object)null || (Object)(object)NEWTextMesh == (Object)null || currentBuy == null;
	}

	private void MakeEveryThingDisabled(bool onOff)
	{
		//IL_0250: 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)
		if (onOff)
		{
			currentPageNumber = -1;
			if (IsMasterAndMasterHasMod() && SemiFunc.IsMultiplayer())
			{
				props[(object)"currentPageNumber"] = currentPageNumber;
				PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
			}
			isStuffShowned = false;
			ShowStuffsInShop();
			if ((Object)(object)arrowTextMesh != (Object)null)
			{
				((Behaviour)arrowTextMesh).enabled = false;
				((Component)rightArrow).gameObject.SetActive(false);
				((Component)leftArrow).gameObject.SetActive(false);
			}
			if ((Object)(object)itemTextMesh != (Object)null)
			{
				((Behaviour)itemTextMesh).enabled = false;
			}
			if ((Object)(object)valueTextMesh != (Object)null)
			{
				((Behaviour)valueTextMesh).enabled = false;
			}
			if ((Object)(object)NEWTextMesh != (Object)null)
			{
				((Behaviour)NEWTextMesh).enabled = false;
			}
			if ((Object)(object)infoTextMesh != (Object)null)
			{
				((Behaviour)infoTextMesh).enabled = false;
			}
			if ((Object)(object)TruckScreenText.instance.textMesh != (Object)null)
			{
				((TMP_Text)TruckScreenText.instance.textMesh).margin = originalMargin;
			}
			isEverythingDisabled = true;
		}
		else
		{
			if ((Object)(object)arrowTextMesh != (Object)null)
			{
				((Behaviour)arrowTextMesh).enabled = true;
				((Component)rightArrow).gameObject.SetActive(true);
				((Component)leftArrow).gameObject.SetActive(true);
			}
			if ((Object)(object)itemTextMesh != (Object)null)
			{
				((Behaviour)itemTextMesh).enabled = true;
			}
			if ((Object)(object)valueTextMesh != (Object)null)
			{
				((Behaviour)valueTextMesh).enabled = true;
			}
			if ((Object)(object)NEWTextMesh != (Object)null)
			{
				((Behaviour)NEWTextMesh).enabled = true;
			}
			if ((Object)(object)infoTextMesh != (Object)null)
			{
				((Behaviour)infoTextMesh).enabled = true;
			}
			if ((Object)(object)TruckScreenText.instance.textMesh != (Object)null)
			{
				((TMP_Text)TruckScreenText.instance.textMesh).margin = new Vector4(0f, 0.3f, 0f, 0f);
			}
			currentPageNumber = -1;
			if (IsMasterAndMasterHasMod() && SemiFunc.IsMultiplayer())
			{
				props[(object)"currentPageNumber"] = currentPageNumber;
				PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
			}
			isEverythingDisabled = false;
		}
	}

	private bool IsMasterHasMod()
	{
		if (masterHasMod)
		{
			return true;
		}
		masterHasMod = SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)OwnedItems_ModHandler.instance != (Object)null;
		if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)OwnedItems_ModHandler.instance != (Object)null)
		{
			props[(object)"masterHasMod"] = masterHasMod;
			PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
		}
		return masterHasMod;
	}

	private bool IsSingleOrMasterHasNotMod()
	{
		if (!SemiFunc.IsMultiplayer())
		{
			return true;
		}
		if (!IsMasterHasMod())
		{
			return true;
		}
		return false;
	}

	private bool IsMasterAndMasterHasMod()
	{
		return SemiFunc.IsMasterClient() && IsMasterHasMod();
	}

	private void RefreshScreen()
	{
		if (!isShop || IsAnythingNull() || (SemiFunc.IsNotMasterClient() && IsMasterHasMod()))
		{
			return;
		}
		if (refreshTimer > 0f)
		{
			refreshTimer -= Time.deltaTime;
			return;
		}
		if (IsMasterAndMasterHasMod())
		{
			props[(object)"currentBuyKey"] = StatsManager.instance.itemsPurchased.Keys.ToArray();
			props[(object)"currentBuyValue"] = StatsManager.instance.itemsPurchased.Values.ToArray();
			PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
		}
		else if (IsSingleOrMasterHasNotMod())
		{
			currentBuy = new Dictionary<string, int>(StatsManager.instance.itemsPurchased);
		}
		foreach (KeyValuePair<string, int> item in new Dictionary<string, int>(currentBuy))
		{
			if (afterBuy.TryGetValue(item.Key, out var value) && value != item.Value)
			{
				if (IsMasterAndMasterHasMod())
				{
					props[(object)"currentBuyKey"] = StatsManager.instance.itemsPurchased.Keys.ToArray();
					props[(object)"currentBuyValue"] = StatsManager.instance.itemsPurchased.Values.ToArray();
					PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
					isStuffShowned = false;
					refreshTimer = 4f;
					break;
				}
				if (IsSingleOrMasterHasNotMod())
				{
					currentBuy = new Dictionary<string, int>(StatsManager.instance.itemsPurchased);
					isStuffShowned = false;
					refreshTimer = 4f;
					break;
				}
			}
		}
		refreshTimer = 4f;
	}

	private void PageController()
	{
		//IL_0046: 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)
		if (pageCoolDown > 0f)
		{
			pageCoolDown -= Time.deltaTime;
			return;
		}
		newPage = currentPageNumber;
		bool flag = false;
		if (!isStuffShowned)
		{
			return;
		}
		if (Input.GetKeyDown(OwnedItems_ModHandler.NextPageKey()) || isRightArrow)
		{
			currentPageNumber++;
			if (currentPageNumber + 1 > totalPageNumber)
			{
				currentPageNumber = -1;
			}
			newPage = currentPageNumber;
			flag = true;
			isRightArrow = false;
		}
		if (Input.GetKeyDown(OwnedItems_ModHandler.PreviousPageKey()) || isLeftArrow)
		{
			currentPageNumber--;
			if (currentPageNumber < -1)
			{
				currentPageNumber = totalPageNumber - 1;
			}
			newPage = currentPageNumber;
			flag = true;
			isLeftArrow = false;
		}
		if (flag)
		{
			if (IsMasterAndMasterHasMod())
			{
				props[(object)"currentPageNumber"] = newPage;
				PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
			}
			else if (IsSingleOrMasterHasNotMod())
			{
				currentPageNumber = newPage;
				isStuffShowned = false;
			}
			pageCoolDown = 0.3f;
		}
	}

	public void ShowStuffsInShop()
	{
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_0796: Unknown result type (might be due to invalid IL or missing references)
		//IL_0714: Unknown result type (might be due to invalid IL or missing references)
		//IL_0719: Unknown result type (might be due to invalid IL or missing references)
		if (!isShop || isStuffShowned || IsAnythingNull())
		{
			return;
		}
		if (screenWaitTimer < 1f)
		{
			screenWaitTimer += Time.deltaTime;
			return;
		}
		int num = 0;
		currentPageText = "";
		currentPageValues = "";
		currentPageNEW = "";
		if (IsMasterAndMasterHasMod())
		{
			afterBuy = new Dictionary<string, int>(StatsManager.instance.itemsPurchased);
		}
		else if (IsSingleOrMasterHasNotMod())
		{
			afterBuy = new Dictionary<string, int>(currentBuy);
		}
		try
		{
			foreach (KeyValuePair<string, int> item in new Dictionary<string, int>(currentBuy).OrderBy(delegate(KeyValuePair<string, int> pair)
			{
				int num3 = mostUsable.FindIndex((string s) => pair.Key.Contains(s));
				return (num3 == -1) ? int.MaxValue : num3;
			}))
			{
				if (item.Value <= 0 && item.Key != "Item Power Crystal")
				{
					continue;
				}
				Item val = StatsManager.instance.itemDictionary[item.Key];
				string text = item.Key;
				if ((Object)(object)val != (Object)null)
				{
					if (!string.IsNullOrEmpty(((Object)val).name))
					{
						text = ((Object)val).name;
					}
					else if (!string.IsNullOrEmpty(val.itemName))
					{
						text = val.itemName;
					}
				}
				string sprite = ChangeItemsIcon(((object)(emojiIcon)(ref val.emojiIcon)).ToString(), text);
				string text2 = ChangeItemsName(val.itemName);
				string text3 = ((object)(itemType)(ref val.itemType)).ToString();
				string color = ChangeItemsColor(text3, text);
				int maxAmount = val.maxAmount;
				int itemBattery = 0;
				int itemMaxBar = 0;
				string text4 = TextWithHTMLCode("/" + maxAmount, 0.2f, "#fb0", null, bold: true);
				string text5 = TextWithHTMLCode(" ", 0.2f, "");
				string text6 = TextWithHTMLCode(item.Value.ToString(), 0.28f, "#fb0", null, bold: true);
				if (item.Value >= maxAmount && text3 != "power_crystal")
				{
					text4 += TextWithHTMLCode("MAX", 0.16f, "#900", null, bold: true);
				}
				if (maxAmount == 1 && text3 != "item_upgrade")
				{
					text4 = TextWithHTMLCode(" ", 0.2f, "#fb0", null, bold: true);
					text6 = TextWithHTMLCode(" ", 0.28f, "#fb0", null, bold: true);
				}
				if (maxAmount >= 99)
				{
					text4 = TextWithHTMLCode(" ", 0.2f, "#fb0", null, bold: true);
				}
				if (text3 == "item_upgrade" && !text2.Contains("Map"))
				{
					text4 = "";
				}
				if (num + 1 > currentPageNumber * 11 && num + 1 <= (currentPageNumber + 1) * 11)
				{
					if (beforeBuy.TryGetValue(item.Key, out var value) && value != item.Value)
					{
						string text7 = "+" + (item.Value - value) + " ";
						if (maxAmount == 1 && !text2.Contains("Map"))
						{
							text7 = "\t\t";
						}
						text5 = TextWithHTMLCode(text7 + "NEW", 0.2f, "");
					}
					foreach (KeyValuePair<string, int> item2 in currentBatteryBar.OrderByDescending((KeyValuePair<string, int> x) => x.Value))
					{
						if (item2.Key.Contains(text) && item2.Key.EndsWith("/1"))
						{
							(itemBattery, itemMaxBar) = ItemBatteryBarCal(text, item2.Value);
							break;
						}
					}
					currentPageText = currentPageText + TextWithHTMLCode(text2 + "  ", 0.28f, color, sprite, bold: true) + TextWithBars(itemBattery, itemMaxBar) + "\n";
					currentPageValues = currentPageValues + text6 + text4 + "\t\t\t\t" + TextWithHTMLCode(text2, 0.28f, "", sprite, bold: true) + "\n";
					currentPageNEW = currentPageNEW + text5 + "\t\t\t\t" + TextWithHTMLCode(text2, 0.28f, "", sprite, bold: true) + "\n";
				}
				num++;
			}
		}
		catch
		{
		}
		float num2 = (float)num / 11f;
		totalPageNumber = Mathf.CeilToInt(num2);
		((TMP_Text)arrowTextMesh).text = TextWithHTMLCode("", 0.38f, "red", "arrowleft", bold: true) + TextWithHTMLCode("  " + (currentPageNumber + 1) + " / " + totalPageNumber + "  ", 0.3f, "red", null, bold: true) + TextWithHTMLCode("", 0.38f, "red", "arrowright", bold: true);
		((TMP_Text)infoTextMesh).text = TextWithHTMLCode("OWN/MAX", 0.2f, "#fb0", null, bold: true);
		if (currentPageNumber != -1)
		{
			((Behaviour)TruckScreenText.instance.textMesh).enabled = false;
			((Behaviour)infoTextMesh).enabled = true;
			StartWave(NEWTextMesh);
			((TMP_Text)itemTextMesh).text = currentPageText + "\n";
			((TMP_Text)valueTextMesh).text = currentPageValues;
			((TMP_Text)NEWTextMesh).text = currentPageNEW;
			TruckScreenText.instance.mainBackgroundColor = new Color(0.7f, 0.7f, 0.7f, 1f);
		}
		else
		{
			((Behaviour)TruckScreenText.instance.textMesh).enabled = true;
			((Behaviour)infoTextMesh).enabled = false;
			StopWave();
			((TMP_Text)infoTextMesh).text = "";
			((TMP_Text)itemTextMesh).text = "";
			((TMP_Text)valueTextMesh).text = "";
			((TMP_Text)NEWTextMesh).text = "";
			TruckScreenText.instance.mainBackgroundColor = originalBGColor;
		}
		isStuffShowned = true;
	}

	private (int, int) ItemBatteryBarCal(string assetName, int currentBattery)
	{
		int num = 0;
		Dictionary<string, int> dictionary = new Dictionary<string, int>
		{
			{ "Item Cart Cannon", 5 },
			{ "Item Cart Laser", 5 },
			{ "Item Drone Battery", 12 },
			{ "Item Drone Feather", 6 },
			{ "Item Drone Indestructible", 6 },
			{ "Item Drone Torque", 6 },
			{ "Item Drone Zero Gravity", 6 },
			{ "Item Extraction Tracker", 6 },
			{ "Item Gun Handgun", 15 },
			{ "Item Gun Laser", 5 },
			{ "Item Gun Shockwave", 12 },
			{ "Item Gun Shotgun", 5 },
			{ "Item Gun Stun", 20 },
			{ "Item Gun Tranq", 8 },
			{ "Item Melee Baseball Bat", 10 },
			{ "Item Melee Frying Pan", 10 },
			{ "Item Melee Inflatable Hammer", 10 },
			{ "Item Melee Sledge Hammer", 10 },
			{ "Item Melee Stun Baton", 15 },
			{ "Item Melee Sword", 10 },
			{ "Item Orb Zero Gravity", 6 },
			{ "Item Phase Bridge", 6 },
			{ "Item Rubber Duck", 6 },
			{ "Item Valuable Tracker", 6 }
		};
		if (dictionary.TryGetValue(assetName, out var value))
		{
			currentBattery = ((currentBattery > 0) ? Mathf.Clamp(Mathf.RoundToInt((float)(currentBattery * value) / 100f), 0, value) : 0);
			num = value;
		}
		else
		{
			currentBattery = 0;
			num = 0;
		}
		return (currentBattery, num);
	}

	private string TextWithBars(int _itemBattery, int _itemMaxBar)
	{
		string text = "";
		if (_itemBattery > 0)
		{
			text += "<size=0.28f><b><color=yellow>";
			for (int i = 0; i < _itemBattery; i++)
			{
				text += "I";
			}
			text += "</color></b></size>";
		}
		int num = _itemMaxBar - _itemBattery;
		if (num > 0)
		{
			text += "<size=0.28f><b><color=black>";
			for (int j = 0; j < num; j++)
			{
				text += "I";
			}
			text += "</color></b></size>";
		}
		if (_itemBattery == 0 && _itemMaxBar == 0)
		{
			text = "<size=0.28f> </size>";
		}
		return text;
	}

	private string TextWithHTMLCode(string text, float size, string color, string sprite = null, bool bold = false, bool sub = false, bool sup = false)
	{
		string text2 = size.ToString();
		if (text2.Contains(","))
		{
			text2 = text2.Replace(",", ".");
		}
		string text3 = text;
		if (color != "")
		{
			text3 = "<color=" + color + ">" + text3 + "</color>";
		}
		if (sup)
		{
			text3 = "<sup>" + text3 + "</sup>";
		}
		if (sub)
		{
			text3 = "<sub>" + text3 + "</sub>";
		}
		if (bold)
		{
			text3 = "<b>" + text3 + "</b>";
		}
		if (sprite != null)
		{
			text3 = "<sprite name=" + sprite + "> " + text3;
		}
		if (size >= 0f)
		{
			text3 = "<size=" + text2 + ">" + text3 + "</size>";
		}
		return text3;
	}

	private void CheckTextMeshLinesForOwnedItems()
	{
		if ((Object)(object)valueTextMesh == (Object)null || (Object)(object)NEWTextMesh == (Object)null || (Object)(object)truckScreenShop == (Object)null)
		{
			return;
		}
		if (((TMP_Text)valueTextMesh).textInfo.lineCount > 12)
		{
			int num = ((TMP_Text)valueTextMesh).text.IndexOf('\n');
			if (num != -1)
			{
				((TMP_Text)valueTextMesh).text = ((TMP_Text)valueTextMesh).text.Substring(num + 1);
			}
		}
		if (((TMP_Text)NEWTextMesh).textInfo.lineCount > 12)
		{
			int num2 = ((TMP_Text)NEWTextMesh).text.IndexOf('\n');
			if (num2 != -1)
			{
				((TMP_Text)NEWTextMesh).text = ((TMP_Text)NEWTextMesh).text.Substring(num2 + 1);
			}
		}
		if (((TMP_Text)itemTextMesh).textInfo.lineCount > 12)
		{
			int num3 = ((TMP_Text)itemTextMesh).text.IndexOf('\n');
			if (num3 != -1)
			{
				((TMP_Text)itemTextMesh).text = ((TMP_Text)itemTextMesh).text.Substring(num3 + 1);
			}
		}
	}

	private void CheckScreens()
	{
		if ((Object)(object)truckScreenShop == (Object)null)
		{
			if (countDownTimer > 0f)
			{
				countDownTimer -= Time.deltaTime;
				return;
			}
			try
			{
				truckScreenShop = (from t in Object.FindObjectsOfType<TruckScreenText>()
					select ((Component)t).gameObject).FirstOrDefault();
			}
			catch
			{
				if ((Object)(object)truckScreenShop == (Object)null)
				{
					WarningCountDown("Can't find Truck Screen Text.", "Couldn't find Truck Screen Text.");
					return;
				}
			}
			if (tryTimes != 3)
			{
				WarningCountDown("Truck Screen Text has found!", "", isSuccess: true);
			}
		}
		if ((Object)(object)arrowTextMesh == (Object)null)
		{
			arrowTextMesh = CreateArrowTextScreen();
			if ((Object)(object)arrowTextMesh != (Object)null)
			{
				leftArrow = ((TMP_Text)arrowTextMesh).transform.Find("LeftArrow");
				rightArrow = ((TMP_Text)arrowTextMesh).transform.Find("RightArrow");
			}
			if ((Object)(object)arrowTextMesh == (Object)null)
			{
				return;
			}
		}
		if ((Object)(object)itemTextMesh == (Object)null)
		{
			itemTextMesh = CreateItemTextScreen();
			if ((Object)(object)itemTextMesh == (Object)null)
			{
				return;
			}
		}
		if ((Object)(object)NEWTextMesh == (Object)null)
		{
			NEWTextMesh = CreateNEWTextScreen();
			if ((Object)(object)NEWTextMesh == (Object)null)
			{
				return;
			}
		}
		if ((Object)(object)valueTextMesh == (Object)null)
		{
			valueTextMesh = CreateValueTextScreen();
			if ((Object)(object)valueTextMesh == (Object)null)
			{
				return;
			}
		}
		if (afterBuy != null)
		{
			return;
		}
		if (countDownTimer > 0f)
		{
			countDownTimer -= Time.deltaTime;
			return;
		}
		try
		{
			afterBuy = new Dictionary<string, int>(currentBuy);
		}
		catch
		{
			if (afterBuy == null || currentBuy == null)
			{
				WarningCountDown("Can't find itemsPurchased.", "Couldn't find itemsPurchased.");
				return;
			}
		}
		if (tryTimes != 3)
		{
			WarningCountDown("itemsPurchased has found!", "", isSuccess: true);
		}
	}

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

	private void StartWave(TextMeshProUGUI _text)
	{
		if (waveRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(waveRoutine);
		}
		waveRoutine = ((MonoBehaviour)this).StartCoroutine(AnimateTextWave(_text));
	}

	private void StopWave()
	{
		if (waveRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(waveRoutine);
			waveRoutine = null;
		}
	}

	public TextMeshProUGUI CreateNewTMP(GameObject originalTMPGameObject, string newTMPName)
	{
		if (countDownTimer > 0f)
		{
			countDownTimer -= Time.deltaTime;
			return null;
		}
		try
		{
			originalTMPGameObject.transform.Find("Canvas/Mask/Text (TMP)");
		}
		catch
		{
			WarningCountDown("Can't find 'Text (TMP)' path.", "Couldn't find 'Text (TMP)' path.");
			return null;
		}
		Transform val = originalTMPGameObject.transform.Find("Canvas/Mask/Text (TMP)");
		if ((Object)(object)val != (Object)null)
		{
			if (tryTimes != 3)
			{
				WarningCountDown("'Text (TMP)' path has found!", "", isSuccess: true);
			}
			TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, ((TMP_Text)componentInChildren).transform.parent);
				((Object)val2).name = ((Object)((Component)componentInChildren).gameObject).name + "_" + newTMPName;
				val2.SetActive(true);
				OwnedItems_ModHandler.ApplyEmojisPlus(val2.GetComponentInChildren<TextMeshProUGUI>(true));
				if (tryTimes != 3)
				{
					WarningCountDown("'Text (TMP)' path and component has found!", "", isSuccess: true);
				}
				return val2.GetComponent<TextMeshProUGUI>();
			}
			WarningCountDown("Can't find 'Text (TMP)' text mesh component", "Couldn't find 'Text (TMP)' text mesh component.");
			return null;
		}
		WarningCountDown("Can't find 'Text (TMP)' path.", "Couldn't find 'Text (TMP)' path.");
		return null;
	}

	private void CreateArrow(PhysGrabObjectGrabArea grabAreaComponent, string name, Vector3 localPos, int delta)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0044: 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_0071: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Expected O, but got Unknown
		//IL_00e4: 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_0106: 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_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Expected O, but got Unknown
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Expected O, but got Unknown
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(truckScreenShop.transform.Find("Canvas/Mask/Text (TMP)_ArrowTextTMP"));
		val.transform.localPosition = localPos;
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
		BoxCollider val2 = val.AddComponent<BoxCollider>();
		val2.size = new Vector3(70f, 50f, 32f);
		val.tag = "Phys Grab Object";
		val.layer = LayerMask.NameToLayer("StaticGrabObject");
		GameObject val3 = new GameObject(name + "_GrabArea");
		val3.transform.SetParent(val.transform);
		val3.transform.localPosition = Vector3.zero;
		val3.transform.localRotation = Quaternion.identity;
		val3.transform.localScale = Vector3.one;
		val3.layer = LayerMask.NameToLayer("Ignore Raycast");
		BoxCollider val4 = val3.AddComponent<BoxCollider>();
		val4.size = new Vector3(70f, 50f, 32f);
		StaticGrabObject val5 = val.AddComponent<StaticGrabObject>();
		val5.colliderTransform = val3.transform;
		PhysGrabObjectGrabArea val6 = val.AddComponent<PhysGrabObjectGrabArea>();
		GrabArea val7 = new GrabArea();
		val7.grabAreaTransform = val3.transform;
		val7.grabAreaEventOnStart.AddListener((UnityAction)delegate
		{
			ChangePage(delta);
		});
		val6.grabAreas = new List<GrabArea> { val7 };
		if (IsMasterAndMasterHasMod() || SemiFunc.IsMultiplayer())
		{
			PhotonView view = val.AddComponent<PhotonView>();
			AllocateManualViewID(view, name);
			PhotonView val8 = val.AddComponent<PhotonView>();
			val8.Synchronization = (ViewSynchronization)3;
			val8.OwnershipTransfer = (OwnershipOption)0;
		}
	}

	private void AllocateManualViewID(PhotonView view, string name)
	{
		if (!(name == "RightArrow"))
		{
			if (name == "LeftArrow")
			{
				view.ViewID = 2718;
			}
			else
			{
				PhotonNetwork.AllocateViewID(view);
			}
		}
		else
		{
			view.ViewID = 2717;
		}
	}

	public void ChangePage(int delta)
	{
		if (delta == 1 && pageCoolDown <= 0f)
		{
			isRightArrow = true;
		}
		if (delta == -1 && pageCoolDown <= 0f)
		{
			isLeftArrow = true;
		}
	}

	public TextMeshProUGUI CreateArrowTextScreen()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = CreateNewTMP(truckScreenShop, "ArrowTextTMP");
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		Material val2 = new Material(((TMP_Text)TruckScreenText.instance.textMesh).fontSharedMaterial);
		PhysGrabObjectGrabArea grabAreaComponent = ComponentHolderProtocol.AddComponent<PhysGrabObjectGrabArea>((Object)(object)val);
		val2.SetTexture(ShaderUtilities.ID_MainTex, ((TMP_Asset)((TMP_Text)TruckScreenText.instance.textMesh).font).material.GetTexture(ShaderUtilities.ID_MainTex));
		val2.SetFloat(ShaderUtilities.ID_FaceDilate, 0.5f);
		val2.SetColor(ShaderUtilities.ID_OutlineColor, new Color(0f, 0f, 0f));
		val2.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.5f);
		((TMP_Text)val).fontMaterial = val2;
		((TMP_Text)val).alignment = (TextAlignmentOptions)1026;
		((TMP_Text)val).transform.localPosition = new Vector3(0f, -0.13f, 0f);
		((TMP_Text)val).transform.localScale = new Vector3(0.95f, 0.95f, 0.95f);
		((TMP_Text)val).margin = new Vector4(-0.4f, 0f, -0.4f, -0.28f);
		CreateArrow(grabAreaComponent, "RightArrow", new Vector3(0.55f, -1.228f, -0.079f), 1);
		CreateArrow(grabAreaComponent, "LeftArrow", new Vector3(-0.55f, -1.228f, -0.079f), -1);
		return val;
	}

	public TextMeshProUGUI CreateItemTextScreen()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = CreateNewTMP(truckScreenShop, "ItemTextTMP");
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		Material val2 = new Material(((TMP_Text)TruckScreenText.instance.textMesh).fontSharedMaterial);
		val2.SetTexture(ShaderUtilities.ID_MainTex, ((TMP_Asset)((TMP_Text)TruckScreenText.instance.textMesh).font).material.GetTexture(ShaderUtilities.ID_MainTex));
		val2.SetFloat(ShaderUtilities.ID_FaceDilate, 0.5f);
		val2.SetColor(ShaderUtilities.ID_OutlineColor, new Color(0f, 0f, 0f));
		val2.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.5f);
		((TMP_Text)val).fontMaterial = val2;
		return val;
	}

	public TextMeshProUGUI CreateNEWTextScreen()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = CreateNewTMP(truckScreenShop, "NEWTextTMP");
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		Material val2 = new Material(((TMP_Text)TruckScreenText.instance.textMesh).fontSharedMaterial);
		val2.SetTexture(ShaderUtilities.ID_MainTex, ((TMP_Asset)((TMP_Text)TruckScreenText.instance.textMesh).font).material.GetTexture(ShaderUtilities.ID_MainTex));
		val2.SetFloat(ShaderUtilities.ID_FaceDilate, 0.5f);
		val2.SetColor(ShaderUtilities.ID_OutlineColor, new Color(1f, 0f, 0f));
		val2.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.5f);
		((TMP_Text)val).fontMaterial = val2;
		((Graphic)val).color = new Color(1f, 0.733f, 0f);
		((TMP_Text)val).transform.localPosition = new Vector3(2.65f, 0f, 0f);
		((TMP_Text)val).margin = new Vector4(0f, 0f, -5f, 0f);
		return val;
	}

	public TextMeshProUGUI CreateValueTextScreen()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = CreateNewTMP(truckScreenShop, "ValueTextTMP");
		TextMeshProUGUI val2 = CreateNewTMP(truckScreenShop, "InfoTextTMP");
		if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
		{
			return null;
		}
		Material val3 = new Material(((TMP_Text)TruckScreenText.instance.textMesh).fontSharedMaterial);
		val3.SetTexture(ShaderUtilities.ID_MainTex, ((TMP_Asset)((TMP_Text)TruckScreenText.instance.textMesh).font).material.GetTexture(ShaderUtilities.ID_MainTex));
		val3.SetFloat(ShaderUtilities.ID_FaceDilate, 0.8f);
		val3.SetColor(ShaderUtilities.ID_OutlineColor, Color.red);
		val3.SetFloat(ShaderUtilities.ID_OutlineWidth, 1f);
		((TMP_Text)val).fontMaterial = val3;
		((TMP_Text)val).transform.localPosition = new Vector3(3.15f, 0f, 0f);
		((TMP_Text)val).margin = new Vector4(0f, 0f, -2f, 0f);
		((TMP_Text)val2).fontMaterial = val3;
		((TMP_Text)val2).fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.333f);
		((TMP_Text)val2).fontMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, 0.033f);
		((TMP_Text)val2).margin = new Vector4(-0.08f, 0f, -0.08f, -0.2f);
		((TMP_Text)val2).alignment = (TextAlignmentOptions)1028;
		((TMP_Text)val2).transform.SetParent(((TMP_Text)val).transform);
		infoTextMesh = val2;
		return val;
	}

	public void WarningCountDown(string warningMessage, string lastMessage, bool isSuccess = false)
	{
		if (isSuccess)
		{
			Debug.LogWarning((object)(debugModName + warningMessage));
			tryTimes = 3;
			countDownTimer = 0f;
		}
		else if (tryTimes > 0)
		{
			Debug.LogWarning((object)(debugModName + warningMessage + " Trying again..."));
			tryTimes--;
			countDownTimer = 5f;
		}
		else if (tryTimes <= 0)
		{
			Debug.LogWarning((object)(debugModName + lastMessage + " This mod could be outdated or not functional anymore. Please disable or remove the mod."));
			OwnedItems_ModHandler.modLock = true;
		}
	}

	public string ChangeItemsName(string _itemName)
	{
		if (_itemName.Contains("Upgrade"))
		{
			_itemName = _itemName.Replace(" Upgrade", "");
			if (_itemName.Contains("Sprint"))
			{
				_itemName = _itemName.Replace("Sprint ", "");
			}
			if (_itemName.Contains("Tumble Launch"))
			{
				_itemName = _itemName.Replace("Tumble ", "");
			}
		}
		if (_itemName.Contains("Health Pack"))
		{
			_itemName = _itemName.Replace(" (100)", "");
			_itemName = _itemName.Replace(" (50)", "");
			_itemName = _itemName.Replace(" (25)", "");
		}
		if (_itemName.Contains(" Duct Taped Grenades"))
		{
			_itemName = _itemName.Replace(" Duct", "Duct");
		}
		return _itemName;
	}

	public string ChangeItemsIcon(string _itemIcon, string _itemAssetName)
	{
		if (_itemAssetName == "Item Cart Medium" || _itemAssetName == "Item Cart Small")
		{
			return "cart";
		}
		if (_itemAssetName.Contains("Item Upgrade"))
		{
			return "player";
		}
		return _itemAssetName switch
		{
			"Item Cart Cannon" => "item_gun_cannon", 
			"Item Cart Laser" => "item_gun_laser", 
			"Item Duck Bucket" => "item_duck_bucket", 
			"Item Gun Laser" => "item_gun_laser_pistol", 
			"Item Gun Shockwave" => "item_gun_shockwave", 
			"Item Gun Stun" => "item_gun_stun", 
			"Item Melee Stun Baton" => "weapon_stun", 
			"Item Mine Shockwave" => "item_mine_shockwave", 
			"Item Mine Stun" => "item_mine_stun", 
			"Item Phase Bridge" => "item_phase_bridge", 
			"Item Power Crystal" => "item_power_crystal", 
			_ => _itemIcon, 
		};
	}

	public string ChangeItemsColor(string _itemType, string _itemAssetName)
	{
		if (_itemType == "drone" || _itemType == "orb")
		{
			return "#9600FF";
		}
		if (_itemType == "grenade" || _itemType == "mine")
		{
			return "#2B7A07";
		}
		switch (_itemType)
		{
		case "gun":
			if (_itemAssetName == "Item Cart Cannon" || _itemAssetName == "Item Cart Laser")
			{
				return "#FF18CC";
			}
			return "#4FFFCF";
		case "healthPack":
			return "green";
		case "melee":
			return "#FF2617";
		case "power_crystal":
			return "yellow";
		case "item_upgrade":
			return "orange";
		default:
			return "white";
		}
	}
}
public class OwnedItems_ModHandler : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <WaitForSceneToLoad>d__17 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public OwnedItems_ModHandler <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.inShop = SemiFunc.RunIsShop();
				if (<>4__this.inShop && (Object)(object)<>4__this.handler == (Object)null)
				{
					<>4__this.handler = new GameObject("OwnedItems_CustomTruckScreen");
					<>4__this.handler.AddComponent<OwnedItems_CustomTruckScreen>();
				}
				else if (!<>4__this.inShop && (Object)(object)<>4__this.handler != (Object)null)
				{
					Object.Destroy((Object)(object)<>4__this.handler);
					<>4__this.handler = null;
				}
				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();
		}
	}

	public static OwnedItems_ModHandler instance;

	public static string debugModName = "[Owned Items]: ";

	public static KeyCode nextPageKey = OwnedItemsPlugin.NextPage.Value;

	public static KeyCode previousPageKey = OwnedItemsPlugin.PreviousPage.Value;

	private string bundlePath;

	private static AssetBundle bundle;

	private bool inShop;

	public static bool modLock;

	private GameObject handler;

	private float configCheckTimer = 0f;

	private void Awake()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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)
		instance = this;
		modLock = false;
		SceneManager.sceneLoaded += OnSceneLoaded;
		modLock = !OwnedItemsPlugin.EnableMod.Value;
		nextPageKey = OwnedItemsPlugin.NextPage.Value;
		previousPageKey = OwnedItemsPlugin.PreviousPage.Value;
		try
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)OwnedItemsPlugin.instance).Info.Location);
			bundlePath = Path.Combine(directoryName, "emojiplusbundle");
			bundle = AssetBundle.LoadFromFile(bundlePath);
		}
		catch
		{
			if ((Object)(object)bundle == (Object)null || bundlePath == null)
			{
				Debug.LogWarning((object)(debugModName + "emojiplusbundle doesn't loaded. The path should be: " + bundlePath));
			}
		}
	}

	public static void ApplyEmojisPlus(TextMeshProUGUI textMesh)
	{
		try
		{
			TMP_SpriteAsset val = bundle.LoadAsset<TMP_SpriteAsset>("emojisplus");
			if ((Object)(object)val != (Object)null)
			{
				((TMP_Text)textMesh).spriteAsset = val;
			}
			else
			{
				Debug.LogWarning((object)(debugModName + "There is no emojisplus.asset"));
			}
		}
		catch
		{
		}
	}

	private void Update()
	{
		configCheckTimer += Time.deltaTime;
		if (configCheckTimer >= 3f)
		{
			configCheckTimer = 0f;
			UpdateApplyConfigEntrys();
		}
	}

	public void UpdateApplyConfigEntrys()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0051: 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_0057: 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)
		bool value = OwnedItemsPlugin.EnableMod.Value;
		KeyCode value2 = OwnedItemsPlugin.PreviousPage.Value;
		KeyCode value3 = OwnedItemsPlugin.NextPage.Value;
		if (modLock != !value || previousPageKey != value2 || nextPageKey != value3)
		{
			modLock = !value;
			previousPageKey = value2;
			nextPageKey = value3;
		}
	}

	public static bool IsLocked()
	{
		return modLock;
	}

	public static KeyCode PreviousPageKey()
	{
		//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_0009: Unknown result type (might be due to invalid IL or missing references)
		return previousPageKey;
	}

	public static KeyCode NextPageKey()
	{
		//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_0009: Unknown result type (might be due to invalid IL or missing references)
		return nextPageKey;
	}

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

	public void OnMasterClientSwitched(Player newMasterClient)
	{
		((MonoBehaviour)this).StartCoroutine(WaitForSceneToLoad());
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		((MonoBehaviour)this).StartCoroutine(WaitForSceneToLoad());
	}
}