Decompiled source of ProgressionTaskBar v1.0.5

ProgressionTaskBar.dll

Decompiled a day ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ProgressionTaskBar;

[BepInPlugin("yuri.ProgressionTaskBar", "Progression Task Bar", "1.0.5")]
public class Plugin : BaseUnityPlugin
{
	private class Etapa
	{
		public string chave;

		public string bioma;

		public string chefe;

		public string matar;

		public string itemId;

		public string itemNome;

		public int precisa;

		public string abre;

		public Etapa(string chave, string bioma, string chefe, string matar, string itemId, string itemNome, int precisa, string abre)
		{
			this.chave = chave;
			this.bioma = bioma;
			this.chefe = chefe;
			this.matar = matar;
			this.itemId = itemId;
			this.itemNome = itemNome;
			this.precisa = precisa;
			this.abre = abre;
		}
	}

	public static bool Aberta;

	private ConfigEntry<bool> ligado;

	private ConfigEntry<KeyboardShortcut> tecla;

	private bool aberto;

	private bool escolhendo;

	private Rect janela;

	private Vector2 rolagem;

	private bool posicionado;

	private Texture2D branco;

	private GUIStyle texto;

	private GUIStyle titulo;

	private GUIStyle miudo;

	private bool avisou;

	private static readonly Etapa[] etapas = new Etapa[8]
	{
		new Etapa("defeated_eikthyr", "Prados", "Eikthyr", "Cervos nos prados.", "TrophyDeer", "troféu de cervo", 2, "Picareta de chifre. A Floresta Negra abre de verdade."),
		new Etapa("defeated_gdking", "Floresta Negra", "O Ancião", "Greydwarfs, brutos e xamãs. Quebra os ninhos.", "AncientSeed", "semente antiga", 3, "Chave do pântano. As criptas afundadas abrem."),
		new Etapa("defeated_bonemass", "Pântano", "Bonemass", "Draugr, esqueletos, sanguessugas e gosmas nas criptas.", "WitheredBone", "osso seco", 10, "Osso da sorte. A prata da montanha passa a ser achada."),
		new Etapa("defeated_dragon", "Montanha", "Moder", "Lobos, drakes e golens. Os ovos ficam em ninhos de drake e não passam no portal.", "DragonEgg", "ovo de dragão", 3, "Lágrima de dragão e a mesa do artesão."),
		new Etapa("defeated_goblinking", "Planície", "Yagluth", "Fulings, berserkers e xamãs nas aldeias.", "GoblinTotem", "totem de fuling", 5, "Espírito rasgado e a fonte de fogo-fátuo."),
		new Etapa("defeated_queen", "Terras Nebulosas", "A Rainha", "Seekers e soldados seeker nas minas infestadas.", "TrophySeekerBrute", "troféu de soldado seeker", 3, "Carapaça majestosa. As Terras das Cinzas vêm depois."),
		new Etapa("defeated_fader", "Terras das Cinzas", "Fader", "As criaturas e as fortalezas das cinzas, onde os sinos estão.", "Bell", "sino", 3, "O caminho para o Norte Profundo."),
		new Etapa("defeated_frozenking_p3", "Norte Profundo", "Kall Fimbulbringer", "Abre Mörkhalla com a chave intricada, quebra o gelo malicioso e vence a invasão jotun. Faz isso três vezes. O Kall tem três fases.", "HatefulBlood", "sangue malicioso", 3, "Zera o jogo.")
	};

	private void Awake()
	{
		//IL_003e: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ligado", true, "Liga a janela so neste jogo. O servidor nao precisa do mod. Fechada, ela nao pega o mouse.");
		tecla = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Geral", "Tecla", new KeyboardShortcut((KeyCode)287, (KeyCode[])(object)new KeyCode[0]), "Clica nessa opcao e aperta a tecla. O botao Escolher tecla, dentro da janela, faz o mesmo.");
		janela = new Rect(80f, 60f, 680f, 680f);
		branco = new Texture2D(1, 1);
		branco.SetPixel(0, 0, Color.white);
		branco.Apply();
		((Object)branco).hideFlags = (HideFlags)61;
		LigarMouse();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Janela de progresso pronta. Tecla: " + tecla.Value));
	}

	private void Update()
	{
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		Aberta = ligado.Value && aberto;
		if (!ligado.Value)
		{
			return;
		}
		if (aberto)
		{
			AplicarRoda();
		}
		if (escolhendo)
		{
			return;
		}
		if (aberto && Input.GetKeyDown((KeyCode)27))
		{
			aberto = false;
			Aberta = false;
			return;
		}
		KeyboardShortcut value = tecla.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			aberto = !aberto;
			Aberta = aberto;
		}
	}

	private void OnGUI()
	{
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		if (!ligado.Value || !aberto)
		{
			return;
		}
		Matrix4x4 matrix = GUI.matrix;
		Color color = GUI.color;
		GUI.matrix = Matrix4x4.identity;
		try
		{
			if (escolhendo)
			{
				CapturarTecla();
			}
			GarantirEstilo();
			if (!posicionado)
			{
				((Rect)(ref janela)).x = ((float)Screen.width - ((Rect)(ref janela)).width) * 0.5f;
				((Rect)(ref janela)).y = ((float)Screen.height - ((Rect)(ref janela)).height) * 0.5f;
				posicionado = true;
			}
			janela = GUI.Window(48189, janela, new WindowFunction(Desenhar), "Progression Task Bar");
		}
		catch (Exception ex)
		{
			if (!avisou)
			{
				avisou = true;
				((BaseUnityPlugin)this).Logger.LogError((object)("Barra falhou: " + ex.Message));
			}
		}
		finally
		{
			GUI.color = color;
			GUI.matrix = matrix;
		}
	}

	private void AplicarRoda()
	{
		//IL_001d: 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_0076: 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)
		Mouse current = Mouse.current;
		if (current == null)
		{
			return;
		}
		float num = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y;
		if (num > -0.01f && num < 0.01f)
		{
			return;
		}
		if (num > 10f || num < -10f)
		{
			num /= 120f;
		}
		Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
		val.y = (float)Screen.height - val.y;
		if (((Rect)(ref janela)).Contains(val))
		{
			ref Vector2 reference = ref rolagem;
			reference.y -= num * 56f;
			if (rolagem.y < 0f)
			{
				rolagem.y = 0f;
			}
		}
	}

	private void LigarMouse()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Expected O, but got Unknown
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Expected O, but got Unknown
		Harmony val = new Harmony("yuri.ProgressionTaskBar");
		BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.NonPublic;
		val.Patch((MethodBase)AccessTools.Method(typeof(GameCamera), "UpdateMouseCapture", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("SoltaCursor", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("SemJogo", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseDelta", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaDelta", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaRoda", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButton", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButtonDown", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButtonUp", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static void SoltaCursor()
	{
		if (Aberta)
		{
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
		}
	}

	private static void SemJogo(ref bool __result)
	{
		if (Aberta)
		{
			__result = false;
		}
	}

	private static bool BloqueiaBool(ref bool __result)
	{
		if (!Aberta)
		{
			return true;
		}
		__result = false;
		return false;
	}

	private static bool BloqueiaRoda(ref float __result)
	{
		if (!Aberta)
		{
			return true;
		}
		__result = 0f;
		return false;
	}

	private static bool BloqueiaDelta(ref Vector2 __result)
	{
		//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)
		if (!Aberta)
		{
			return true;
		}
		__result = Vector2.zero;
		return false;
	}

	private void Desenhar(int id)
	{
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: 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_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		ContarProgresso(out var feitos, out var atual);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("Historia do Valheim. " + feitos + " de " + etapas.Length + " chefes.", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button(escolhendo ? "Aperta a tecla" : "Escolher tecla", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) }))
		{
			escolhendo = true;
		}
		if (GUILayout.Button("Fechar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
		{
			aberto = false;
		}
		GUILayout.EndHorizontal();
		Barra((float)feitos / (float)etapas.Length, new Color(0.9f, 0.62f, 0.18f));
		if (escolhendo)
		{
			GUILayout.Label("Aperta a tecla nova agora. Esc cancela. Shift, Ctrl ou Alt podem acompanhar.", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		else
		{
			GUILayout.Label(NomeTecla() + " abre e fecha. Esc tambem fecha. Fora da janela o jogo responde normal. Escolher tecla grava a proxima tecla que tu apertar.", miudo, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		}
		GUILayout.Space(6f);
		rolagem = GUILayout.BeginScrollView(rolagem, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		for (int i = 0; i < etapas.Length; i++)
		{
			bool flag = ChefeMorto(etapas[i].chave);
			int num = Contar(etapas[i].itemId);
			float fator = Fator(flag, num, etapas[i].precisa);
			string text = (flag ? "Feito" : ((i == atual) ? "Agora" : "Depois"));
			Color cor = (flag ? new Color(0.35f, 0.72f, 0.4f) : ((i == atual) ? new Color(0.9f, 0.72f, 0.28f) : new Color(0.45f, 0.42f, 0.38f)));
			GUILayout.Label(i + 1 + ". " + etapas[i].bioma + "  -  " + etapas[i].chefe + "   [" + text + "]", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			Barra(fator, cor);
			GUILayout.Label("Matar: " + etapas[i].matar, texto, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Coletar: " + num + " / " + etapas[i].precisa + " " + etapas[i].itemNome + ". Oferece no altar e mata o chefe.", texto, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Abre: " + etapas[i].abre, texto, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Space(8f);
		}
		GUILayout.EndScrollView();
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 28f));
	}

	private static void ContarProgresso(out int feitos, out int atual)
	{
		feitos = 0;
		atual = -1;
		for (int i = 0; i < etapas.Length; i++)
		{
			if (ChefeMorto(etapas[i].chave))
			{
				feitos++;
			}
			else if (atual < 0)
			{
				atual = i;
			}
		}
	}

	private static float Fator(bool morto, int tem, int precisa)
	{
		if (morto)
		{
			return 1f;
		}
		if (precisa <= 0)
		{
			return 0f;
		}
		float num = (float)tem / (float)precisa;
		if (num < 0f)
		{
			num = 0f;
		}
		if (num > 1f)
		{
			num = 1f;
		}
		return num * 0.7f;
	}

	private void Barra(float fator, Color cor)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0057: 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_006f: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (fator < 0f)
		{
			fator = 0f;
		}
		if (fator > 1f)
		{
			fator = 1f;
		}
		Rect rect = GUILayoutUtility.GetRect(18f, 16f);
		Color color = GUI.color;
		GUI.color = new Color(0.12f, 0.1f, 0.08f, 0.95f);
		GUI.DrawTexture(rect, (Texture)(object)branco);
		GUI.color = cor;
		GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width * fator, ((Rect)(ref rect)).height), (Texture)(object)branco);
		GUI.color = color;
	}

	private void CapturarTecla()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Invalid comparison between Unknown and I4
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_0149: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		Event current = Event.current;
		if (current == null || (int)current.type != 4 || (int)current.keyCode == 0)
		{
			return;
		}
		if ((int)current.keyCode == 27)
		{
			escolhendo = false;
			current.Use();
		}
		else if (!EhModificador(current.keyCode))
		{
			if (current.shift)
			{
				tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 });
			}
			else if (current.control)
			{
				tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });
			}
			else if (current.alt)
			{
				tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
			}
			else
			{
				tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[0]);
			}
			escolhendo = false;
			current.Use();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Tecla nova: " + tecla.Value));
		}
	}

	private static bool EhModificador(KeyCode codigo)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Invalid comparison between Unknown and I4
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Invalid comparison between Unknown and I4
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Invalid comparison between Unknown and I4
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Invalid comparison between Unknown and I4
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Invalid comparison between Unknown and I4
		return (int)codigo == 304 || (int)codigo == 303 || (int)codigo == 306 || (int)codigo == 305 || (int)codigo == 308 || (int)codigo == 307;
	}

	private unsafe string NomeTecla()
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = tecla.Value;
		if ((int)((KeyboardShortcut)(ref value)).MainKey == 0)
		{
			return "sem tecla";
		}
		value = tecla.Value;
		return ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString();
	}

	private void GarantirEstilo()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_003f: 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_005f: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		if (texto == null)
		{
			texto = new GUIStyle(GUI.skin.label);
			Pintar(texto, 14, new Color(0.93f, 0.88f, 0.78f));
			titulo = new GUIStyle(GUI.skin.label);
			Pintar(titulo, 16, new Color(0.96f, 0.84f, 0.55f));
			miudo = new GUIStyle(GUI.skin.label);
			Pintar(miudo, 12, new Color(0.75f, 0.7f, 0.62f));
		}
	}

	private static void Pintar(GUIStyle estilo, int tamanho, Color cor)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		estilo.wordWrap = true;
		estilo.fontSize = tamanho;
		estilo.normal.textColor = cor;
	}

	private static bool ChefeMorto(string chave)
	{
		if ((Object)(object)ZoneSystem.instance == (Object)null || chave == null)
		{
			return false;
		}
		return ZoneSystem.instance.GetGlobalKey(chave);
	}

	private static int Contar(string item)
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || item == null)
		{
			return 0;
		}
		Inventory inventory = ((Humanoid)localPlayer).GetInventory();
		if (inventory == null)
		{
			return 0;
		}
		return inventory.CountItems(item, -1, true);
	}
}