Decompiled source of Shopkeep v1.0.0

Shopkeep.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.Events;
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("Shopkeep")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Shopkeep")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0b261f31-75b2-4405-b7ec-25e6fade4c16")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Shopkeep;

public class BercansDestroy : MonoBehaviour
{
	private void OnDestroy()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		foreach (Transform item in ((Component)this).transform)
		{
			Transform val = item;
			if (((Object)((Component)val).gameObject).name.Contains("Haldor"))
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}
	}
}
[BepInPlugin("com.yourname.shopkeep", "Shopkeep", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Shopkeep : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("com.yourname.shopkeep");

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Shopkeep mod loaded!");
		harmony.PatchAll();
		PrefabManager.OnVanillaPrefabsAvailable += RegisterNPC;
	}

	private void RegisterNPC()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Registering Shopkeep NPC...");
		ShopkeepNPC.Register();
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterNPC;
	}
}
public class ItemEffects
{
	private const string VitalityKey = "Shopkeep_Vitality";

	private const string EnduranceKey = "Shopkeep_Endurance";

	private const string BurdenKey = "Shopkeep_Burden";

	private const int MaxScrollUses = 3;

	public static void ApplyMysteryBox(Player player)
	{
		List<(string, int, float)> list = new List<(string, int, float)>
		{
			("Wood", 50, 30f),
			("FineWood", 20, 20f),
			("Coins", 500, 25f),
			("Copper", 10, 15f),
			("Tin", 10, 15f),
			("Bronze", 10, 12f),
			("Iron", 10, 12f),
			("Silver", 10, 10f),
			("BlackMetal", 10, 8f),
			("Flametal", 5, 4f),
			("Chitin", 15, 15f),
			("Crystal", 10, 10f),
			("Ruby", 5, 8f),
			("FreezeGland", 10, 10f),
			("Blueberries", 20, 20f),
			("SerpentStew", 3, 10f),
			("BloodPudding", 3, 10f),
			("LoxPie", 3, 8f),
			("CookedMeat", 10, 15f),
			("CarrotSeeds", 10, 15f),
			("TurnipSeeds", 10, 15f),
			("OnionSeeds", 10, 12f),
			("BarleySeed", 10, 10f),
			("FlaxSeed", 10, 10f),
			("MeadHealthMedium", 3, 10f),
			("MeadStaminaMedium", 3, 10f),
			("MeadPoisonResist", 2, 8f),
			("AxeIron", 1, 3f),
			("AxeBlackMetal", 1, 2f),
			("BattleaxeBlackmetal", 1, 1f),
			("PickaxeBronze", 1, 3f),
			("PickaxeIron", 1, 2f),
			("SwordBronze", 1, 3f),
			("SwordIron", 1, 2f),
			("SwordBlackmetal", 1, 1f),
			("SwordMistwalker", 1, 0.5f),
			("BowFineWood", 1, 3f),
			("BowHuntsman", 1, 2f),
			("BowDraugrFang", 1, 1f),
			("APPLY_VITALITY", 1, 2f),
			("APPLY_ENDURANCE", 1, 2f),
			("APPLY_BURDEN", 1, 2f)
		};
		float num = 0f;
		foreach (var item in list)
		{
			num += item.Item3;
		}
		float num2 = Random.Range(0f, num);
		float num3 = 0f;
		foreach (var item2 in list)
		{
			num3 += item2.Item3;
			if (num2 <= num3)
			{
				if (item2.Item1 == "APPLY_VITALITY")
				{
					ApplyScrollOfVitality(player);
					MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Vitality!", 0, (Sprite)null, false);
				}
				else if (item2.Item1 == "APPLY_ENDURANCE")
				{
					ApplyScrollOfEndurance(player);
					MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Endurance!", 0, (Sprite)null, false);
				}
				else if (item2.Item1 == "APPLY_BURDEN")
				{
					ApplyScrollOfBurden(player);
					MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Burden!", 0, (Sprite)null, false);
				}
				else
				{
					((Humanoid)player).GetInventory().AddItem(item2.Item1, item2.Item2, 1, 0, 0L, "", false);
					MessageHud.instance.ShowMessage((MessageType)2, $"Mystery Box: You found {item2.Item1} x{item2.Item2}!", 0, (Sprite)null, false);
				}
				break;
			}
		}
	}

	public static void ApplyScrollOfVitality(Player player)
	{
		int scrollUses = GetScrollUses(player, "Shopkeep_Vitality");
		if (scrollUses >= 3)
		{
			MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Vitality!", 0, (Sprite)null, false);
			return;
		}
		player.m_customData["Shopkeep_Vitality"] = (scrollUses + 1).ToString();
		((Character)player).SetMaxHealth(((Character)player).GetMaxHealth() + 25f);
		MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Vitality: Max health increased by 25! ({scrollUses + 1}/{3})", 0, (Sprite)null, false);
	}

	public static void ApplyScrollOfEndurance(Player player)
	{
		int scrollUses = GetScrollUses(player, "Shopkeep_Endurance");
		if (scrollUses >= 3)
		{
			MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Endurance!", 0, (Sprite)null, false);
			return;
		}
		player.m_customData["Shopkeep_Endurance"] = (scrollUses + 1).ToString();
		player.SetMaxStamina(((Character)player).GetMaxStamina() + 25f, false);
		MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Endurance: Max stamina increased by 25! ({scrollUses + 1}/{3})", 0, (Sprite)null, false);
	}

	public static void ApplyScrollOfBurden(Player player)
	{
		int scrollUses = GetScrollUses(player, "Shopkeep_Burden");
		if (scrollUses >= 3)
		{
			MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Burden!", 0, (Sprite)null, false);
			return;
		}
		player.m_customData["Shopkeep_Burden"] = (scrollUses + 1).ToString();
		player.m_maxCarryWeight += 100f;
		MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Burden: Carry weight increased by 100! ({scrollUses + 1}/{3})", 0, (Sprite)null, false);
	}

	private static int GetScrollUses(Player player, string key)
	{
		if (player.m_customData.ContainsKey(key))
		{
			return int.Parse(player.m_customData[key]);
		}
		return 0;
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public class StatRestorePatch
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			if (__instance.m_customData.ContainsKey("Shopkeep_Vitality"))
			{
				int num = int.Parse(__instance.m_customData["Shopkeep_Vitality"]);
				((Character)__instance).SetMaxHealth(((Character)__instance).GetMaxHealth() + (float)num * 25f);
			}
			if (__instance.m_customData.ContainsKey("Shopkeep_Endurance"))
			{
				int num2 = int.Parse(__instance.m_customData["Shopkeep_Endurance"]);
				__instance.SetMaxStamina(((Character)__instance).GetMaxStamina() + (float)num2 * 25f, false);
			}
			if (__instance.m_customData.ContainsKey("Shopkeep_Burden"))
			{
				int num3 = int.Parse(__instance.m_customData["Shopkeep_Burden"]);
				__instance.m_maxCarryWeight += (float)num3 * 100f;
			}
		}
	}
}
public class ShopkeepInteract : MonoBehaviour, Interactable, Hoverable
{
	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		Player val = (Player)(object)((user is Player) ? user : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		ShopUI.Show();
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	public string GetHoverText()
	{
		return "Bercans\n[E] Browse Wares";
	}

	public string GetHoverName()
	{
		return "Bercans";
	}
}
public class ShopkeepNPC
{
	public static void Register()
	{
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Expected O, but got Unknown
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Expected O, but got Unknown
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_00a9: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Bercans", "piece_bone_throne");
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"Failed to clone prefab!");
			return;
		}
		Interactable[] componentsInChildren = val.GetComponentsInChildren<Interactable>();
		foreach (Interactable val2 in componentsInChildren)
		{
			Object.Destroy((Object)(object)((val2 is Object) ? val2 : null));
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("Haldor");
		if ((Object)(object)prefab != (Object)null)
		{
			GameObject val3 = Object.Instantiate<GameObject>(prefab, val.transform);
			val3.transform.localPosition = new Vector3(0f, 0.3f, 0.3f);
			val3.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			val3.transform.localScale = new Vector3(1f, 1f, 1f);
			Trader component = val3.GetComponent<Trader>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Character component2 = val3.GetComponent<Character>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			BaseAI component3 = val3.GetComponent<BaseAI>();
			if ((Object)(object)component3 != (Object)null)
			{
				Object.Destroy((Object)(object)component3);
			}
			ZNetView component4 = val3.GetComponent<ZNetView>();
			if ((Object)(object)component4 != (Object)null)
			{
				Object.Destroy((Object)(object)component4);
			}
			MonoBehaviour[] componentsInChildren2 = val3.GetComponentsInChildren<MonoBehaviour>();
			foreach (MonoBehaviour val4 in componentsInChildren2)
			{
				((Behaviour)val4).enabled = false;
			}
		}
		val.AddComponent<ShopkeepInteract>();
		PieceConfig val5 = new PieceConfig();
		val5.Name = "Bercans";
		val5.Description = "A traveling merchant with rare wares.";
		val5.PieceTable = "Hammer";
		val5.AddRequirement(new RequirementConfig("Coins", 10000, 0, true));
		PieceManager.Instance.AddPiece(new CustomPiece(val, false, val5));
		Debug.Log((object)"Bercans registered!");
	}
}
public class ShopKeyListener : MonoBehaviour
{
	private void Update()
	{
		if (ZInput.GetButtonDown("Escape") || ZInput.GetButtonDown("JoyButtonB"))
		{
			ShopUI.Hide();
		}
	}
}
public class ShopUI
{
	private struct ShopItem
	{
		public string itemName;

		public string displayName;

		public int price;

		public int amount;

		public string category;
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__6_0;

		internal void <CreateUI>b__6_0()
		{
			Hide();
		}
	}

	private static GameObject shopPanel;

	private static bool isOpen = false;

	private static List<ShopItem> shopItems = new List<ShopItem>
	{
		new ShopItem
		{
			itemName = "CookedMeat",
			displayName = "Cooked Meat",
			price = 50,
			amount = 5,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "Bread",
			displayName = "Bread",
			price = 8,
			amount = 50,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "FishCooked",
			displayName = "Cooked Fish",
			price = 60,
			amount = 5,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "SerpentStew",
			displayName = "Serpent Stew",
			price = 250,
			amount = 3,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "LoxPie",
			displayName = "Lox Meat Pie",
			price = 300,
			amount = 3,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "BloodPudding",
			displayName = "Blood Pudding",
			price = 200,
			amount = 3,
			category = "Food"
		},
		new ShopItem
		{
			itemName = "MeadHealthMinor",
			displayName = "Minor Health Mead",
			price = 150,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MeadHealthMedium",
			displayName = "Medium Health Mead",
			price = 250,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MeadStaminaMinor",
			displayName = "Minor Stamina Mead",
			price = 150,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MeadStaminaMedium",
			displayName = "Medium Stamina Mead",
			price = 250,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MeadPoisonResist",
			displayName = "Poison Resistance Mead",
			price = 300,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MeadFrostResist",
			displayName = "Frost Resistance Mead",
			price = 300,
			amount = 1,
			category = "Potions"
		},
		new ShopItem
		{
			itemName = "MysteryBox",
			displayName = "Mystery Box",
			price = 500,
			amount = 1,
			category = "Special"
		},
		new ShopItem
		{
			itemName = "ScrollOfVitality",
			displayName = "Scroll of Vitality (+25 Health)",
			price = 2000,
			amount = 1,
			category = "Special"
		},
		new ShopItem
		{
			itemName = "ScrollOfEndurance",
			displayName = "Scroll of Endurance (+25 Stamina)",
			price = 2000,
			amount = 1,
			category = "Special"
		},
		new ShopItem
		{
			itemName = "ScrollOfBurden",
			displayName = "Scroll of Burden (+100 Carry Weight)",
			price = 2000,
			amount = 1,
			category = "Special"
		}
	};

	public static void Show()
	{
		if (isOpen)
		{
			Hide();
			return;
		}
		CreateUI();
		isOpen = true;
		GUIManager.BlockInput(true);
	}

	public static void Hide()
	{
		if ((Object)(object)shopPanel != (Object)null)
		{
			Object.Destroy((Object)(object)shopPanel);
			shopPanel = null;
		}
		isOpen = false;
		GUIManager.BlockInput(false);
	}

	private static void CreateUI()
	{
		//IL_001a: 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_0038: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Expected O, but got Unknown
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Expected O, but got Unknown
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Expected O, but got Unknown
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Expected O, but got Unknown
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		shopPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-400f, 0f), 1400f, 1500f, true);
		shopPanel.AddComponent<ShopKeyListener>();
		GUIManager.Instance.CreateText("Free Gold Market", shopPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -60f), GUIManager.Instance.AveriaSerifBold, 36, GUIManager.Instance.ValheimOrange, true, Color.black, 1200f, 60f, false);
		int playerCoins = GetPlayerCoins();
		GUIManager.Instance.CreateText($"Your Coins: {playerCoins}", shopPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -110f), GUIManager.Instance.AveriaSerifBold, 24, Color.yellow, true, Color.black, 1200f, 40f, false);
		GameObject val = GUIManager.Instance.CreateButton("X", shopPanel.transform, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-25f, -25f), 40f, 40f);
		ButtonClickedEvent onClick = val.GetComponent<Button>().onClick;
		object obj = <>c.<>9__6_0;
		if (obj == null)
		{
			UnityAction val2 = delegate
			{
				Hide();
			};
			<>c.<>9__6_0 = val2;
			obj = (object)val2;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
		GameObject val3 = new GameObject("ScrollView");
		val3.transform.SetParent(shopPanel.transform, false);
		RectTransform val4 = val3.AddComponent<RectTransform>();
		val4.anchorMin = new Vector2(0.5f, 0f);
		val4.anchorMax = new Vector2(0.5f, 1f);
		val4.offsetMin = new Vector2(-670f, 10f);
		val4.offsetMax = new Vector2(670f, -160f);
		ScrollRect val5 = val3.AddComponent<ScrollRect>();
		GameObject val6 = new GameObject("Viewport");
		val6.transform.SetParent(val3.transform, false);
		RectTransform val7 = val6.AddComponent<RectTransform>();
		val7.anchorMin = Vector2.zero;
		val7.anchorMax = Vector2.one;
		val7.offsetMin = Vector2.zero;
		val7.offsetMax = Vector2.zero;
		val6.AddComponent<Mask>().showMaskGraphic = false;
		((Graphic)val6.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.1f);
		GameObject val8 = new GameObject("Content");
		val8.transform.SetParent(val6.transform, false);
		RectTransform val9 = val8.AddComponent<RectTransform>();
		val9.anchorMin = new Vector2(0f, 1f);
		val9.anchorMax = new Vector2(1f, 1f);
		val9.pivot = new Vector2(0.5f, 1f);
		val9.offsetMin = Vector2.zero;
		val9.offsetMax = Vector2.zero;
		VerticalLayoutGroup val10 = val8.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val10).spacing = 15f;
		((LayoutGroup)val10).padding = new RectOffset(5, 5, 5, 5);
		ContentSizeFitter val11 = val8.AddComponent<ContentSizeFitter>();
		val11.verticalFit = (FitMode)2;
		val5.viewport = val7;
		val5.content = val9;
		val5.horizontal = false;
		val5.vertical = true;
		string text = "";
		foreach (ShopItem shopItem in shopItems)
		{
			if (shopItem.category != text)
			{
				text = shopItem.category;
				GUIManager.Instance.CreateText("-- " + shopItem.category + " --", val8.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(10f, 0f), GUIManager.Instance.AveriaSerifBold, 22, GUIManager.Instance.ValheimOrange, true, Color.black, 1200f, 40f, false);
			}
			CreateItemRow(val8.transform, shopItem);
		}
	}

	private static void CreateItemRow(Transform parent, ShopItem item)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Expected O, but got Unknown
		GameObject val = new GameObject("Row_" + item.itemName);
		val.transform.SetParent(parent, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.sizeDelta = new Vector2(1300f, 60f);
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 0f;
		((LayoutGroup)val3).childAlignment = (TextAnchor)3;
		((LayoutGroup)val3).padding = new RectOffset(10, 10, 2, 2);
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
		GameObject val4 = GUIManager.Instance.CreateText($"{item.displayName} x{item.amount}", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 22, Color.white, true, Color.black, 850f, 50f, false);
		LayoutElement val5 = val4.AddComponent<LayoutElement>();
		val5.minWidth = 850f;
		val5.preferredWidth = 850f;
		val5.minHeight = 50f;
		val5.preferredHeight = 50f;
		GameObject val6 = GUIManager.Instance.CreateText($"{item.price} coins", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 22, Color.yellow, true, Color.black, 250f, 50f, false);
		LayoutElement val7 = val6.AddComponent<LayoutElement>();
		val7.minWidth = 250f;
		val7.preferredWidth = 250f;
		val7.minHeight = 50f;
		val7.preferredHeight = 50f;
		ShopItem capturedItem = item;
		GameObject val8 = GUIManager.Instance.CreateButton("Buy", val.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), Vector2.zero, 120f, 55f);
		((Graphic)val8.GetComponentInChildren<Text>()).color = Color.white;
		val8.GetComponentInChildren<Text>().fontSize = 20;
		LayoutElement val9 = val8.AddComponent<LayoutElement>();
		val9.minWidth = 120f;
		val9.preferredWidth = 120f;
		val9.minHeight = 55f;
		val9.preferredHeight = 55f;
		((UnityEvent)val8.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
		{
			BuyItem(capturedItem);
		});
	}

	private static void BuyItem(ShopItem item)
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		int playerCoins = GetPlayerCoins();
		if (playerCoins < item.price)
		{
			MessageHud.instance.ShowMessage((MessageType)2, "Not enough coins!", 0, (Sprite)null, false);
			return;
		}
		int num = item.price;
		List<ItemData> list = new List<ItemData>();
		foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems())
		{
			if (num <= 0)
			{
				break;
			}
			if ((Object)(object)allItem.m_dropPrefab != (Object)null && ((Object)allItem.m_dropPrefab).name == "Coins")
			{
				if (num >= allItem.m_stack)
				{
					num -= allItem.m_stack;
					list.Add(allItem);
				}
				else
				{
					allItem.m_stack -= num;
					num = 0;
				}
			}
		}
		foreach (ItemData item2 in list)
		{
			((Humanoid)localPlayer).GetInventory().RemoveItem(item2);
		}
		switch (item.itemName)
		{
		case "MysteryBox":
			ItemEffects.ApplyMysteryBox(localPlayer);
			Hide();
			Show();
			return;
		case "ScrollOfVitality":
			ItemEffects.ApplyScrollOfVitality(localPlayer);
			Hide();
			Show();
			return;
		case "ScrollOfEndurance":
			ItemEffects.ApplyScrollOfEndurance(localPlayer);
			Hide();
			Show();
			return;
		case "ScrollOfBurden":
			ItemEffects.ApplyScrollOfBurden(localPlayer);
			Hide();
			Show();
			return;
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab(item.itemName);
		if ((Object)(object)prefab == (Object)null)
		{
			prefab = ZNetScene.instance.GetPrefab(item.itemName);
		}
		if ((Object)(object)prefab == (Object)null)
		{
			Debug.LogError((object)("Could not find prefab: " + item.itemName));
			MessageHud.instance.ShowMessage((MessageType)2, "Error: Could not find " + item.displayName + "!", 0, (Sprite)null, false);
			return;
		}
		ItemDrop component = prefab.GetComponent<ItemDrop>();
		if ((Object)(object)component != (Object)null)
		{
			ItemData val = component.m_itemData.Clone();
			val.m_stack = item.amount;
			((Humanoid)localPlayer).GetInventory().AddItem(val);
			MessageHud.instance.ShowMessage((MessageType)1, "Purchased " + item.displayName + "!", 0, (Sprite)null, false);
		}
		Hide();
		Show();
	}

	private static int GetPlayerCoins()
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return 0;
		}
		int num = 0;
		foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems())
		{
			if ((Object)(object)allItem.m_dropPrefab != (Object)null && ((Object)allItem.m_dropPrefab).name == "Coins")
			{
				num += allItem.m_stack;
			}
		}
		return num;
	}
}