Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EndosCoinPurse v1.0.0
EndosCoinPurse.dll
Decompiled 5 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("FSOS-X R10 EXP")] [assembly: AssemblyProduct("ValheimMod")] [assembly: AssemblyCopyright("Copyright © FSOS-X R10 EXP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ad339bed-d2c1-4e38-afdc-8494abc8ceeb")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ValheimMuntBuidelHUD; public class BuidelClickComponent : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler { public void OnPointerEnter(PointerEventData eventData) { } public void OnPointerExit(PointerEventData eventData) { } public void OnPointerClick(PointerEventData eventData) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; InventoryGui instance = InventoryGui.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null) { return; } if ((int)eventData.button == 0) { FieldInfo field = typeof(InventoryGui).GetField("m_dragItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = typeof(InventoryGui).GetField("m_dragInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo method = typeof(InventoryGui).GetMethod("SetupDragItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { field = typeof(InventoryGui).GetField("dragItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (field2 == null) { field2 = typeof(InventoryGui).GetField("dragInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (method == null) { method = typeof(InventoryGui).GetMethod("SetDragItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } ItemData val = ((!(field != null)) ? ((ItemData)null) : ((ItemData)field.GetValue(instance))); Inventory val2 = ((!(field2 != null)) ? ((Inventory)null) : ((Inventory)field2.GetValue(instance))); if (val != null) { if (val.m_shared.m_name == "$item_coins" && MuntBuidelHUDMod.VirtueleBuidelInv.AddItem(val)) { if (val2 != null) { val2.RemoveItem(val); } if (method != null) { try { method.Invoke(instance, new object[3] { null, null, 0 }); } catch { method.Invoke(instance, null); } } } } else { ItemData item = MuntBuidelHUDMod.VirtueleBuidelInv.GetItem("$item_coins", -1, false); if (item != null && item.m_stack > 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Coins"); if ((Object)(object)itemPrefab != (Object)null) { int stack = item.m_stack; ItemData val3 = ((Humanoid)localPlayer).PickupPrefab(itemPrefab, stack, true); if (val3 != null) { MuntBuidelHUDMod.VirtueleBuidelInv.RemoveItem(item); if (method != null) { try { method.Invoke(instance, new object[3] { val3, ((Humanoid)localPlayer).GetInventory(), val3.m_stack }); } catch { method.Invoke(instance, new object[2] { val3, ((Humanoid)localPlayer).GetInventory() }); } } } } } } } MuntBuidelHUDMod.UpdateBuidelCount(); instance.m_playerGrid.UpdateInventory(((Humanoid)localPlayer).GetInventory(), localPlayer, (ItemData)null); } } [BepInPlugin("EndosCoinPurse", "EndosCoinPurseMod", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MuntBuidelHUDMod : BaseUnityPlugin { public const string ModGUID = "EndosCoinPurse"; public const string ModName = "EndosCoinPurseMod"; public const string ModVersion = "1.0.0"; private Harmony harmony; public static GameObject BuidelPanel; public static Text BuidelText; public static Inventory VirtueleBuidelInv; public static ConfigEntry<float> ConfigPosX; public static ConfigEntry<float> ConfigPosY; public static void CreateBuidelSlotUI(InventoryGui gui) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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_0332: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Expected O, but got Unknown //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)gui.m_playerGrid).transform.parent; if ((Object)(object)parent == (Object)null) { return; } BuidelPanel = new GameObject("BuidelSlotHUD", new Type[4] { typeof(RectTransform), typeof(Image), typeof(CanvasGroup), typeof(BuidelClickComponent) }); BuidelPanel.transform.SetParent(parent, false); Image component = BuidelPanel.GetComponent<Image>(); ((Graphic)component).raycastTarget = true; Image val = null; Image[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Image>(true); foreach (Image val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sprite != (Object)null && (((Object)((Component)val2).gameObject).name.Contains("bkg") || ((Object)((Component)val2).gameObject).name.Contains("Bkg") || ((Object)((Component)val2).gameObject).name.Contains("Border")) && ((Graphic)val2).rectTransform.sizeDelta.x < 100f && ((Object)val2.sprite).name != "inventory_bkg") { val = val2; break; } } if ((Object)(object)val == (Object)null && ((Component)gui.m_playerGrid).transform.childCount > 0) { val = ((Component)((Component)gui.m_playerGrid).transform.GetChild(0)).GetComponent<Image>(); } if ((Object)(object)val != (Object)null && (Object)(object)val.sprite != (Object)null) { component.sprite = val.sprite; component.type = (Type)1; ((Graphic)component).material = ((Graphic)val).material; ((Graphic)component).color = ((Graphic)val).color; } else { ((Graphic)component).color = new Color(0.12f, 0.09f, 0.07f, 0.95f); } RectTransform component2 = BuidelPanel.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(0f, 1f); component2.pivot = new Vector2(0f, 1f); component2.sizeDelta = new Vector2(64f, 64f); UpdateBuidelPosition(); GameObject val3 = new GameObject("SlotBinnenzijde", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(BuidelPanel.transform, false); Image component3 = val3.GetComponent<Image>(); ((Graphic)component3).raycastTarget = false; ((Graphic)component3).color = new Color(0f, 0f, 0f, 0f); RectTransform component4 = val3.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(1f, 1f); component4.offsetMin = new Vector2(0f, 0f); component4.offsetMax = new Vector2(0f, 0f); GameObject val4 = new GameObject("BuidelIcon", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(val3.transform, false); Image component5 = val4.GetComponent<Image>(); ((Graphic)component5).raycastTarget = false; if ((Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Coins"); if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component6 = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component6 != (Object)null && component6.m_itemData.m_shared.m_icons != null && component6.m_itemData.m_shared.m_icons.Length != 0) { component5.sprite = component6.m_itemData.m_shared.m_icons[0]; ((Graphic)component5).color = Color.white; ((Graphic)component5).material = null; } } } RectTransform component7 = val4.GetComponent<RectTransform>(); component7.anchorMin = new Vector2(0.5f, 1f); component7.anchorMax = new Vector2(0.5f, 1f); component7.pivot = new Vector2(0.5f, 0.5f); component7.sizeDelta = new Vector2(44f, 44f); component7.anchoredPosition = new Vector2(0f, -10f); GameObject val5 = new GameObject("BuidelText", new Type[2] { typeof(RectTransform), typeof(Text) }); val5.transform.SetParent(val3.transform, false); BuidelText = val5.GetComponent<Text>(); ((Graphic)BuidelText).raycastTarget = false; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val6 in array) { if (((Object)val6).name.Contains("Averia")) { BuidelText.font = val6; break; } } if ((Object)(object)BuidelText.font == (Object)null) { ? val7 = BuidelText; Object builtinResource = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); ((Text)val7).font = (Font)(object)((builtinResource is Font) ? builtinResource : null); } BuidelText.fontSize = 14; ((Graphic)BuidelText).color = new Color(1f, 0.82f, 0f, 1f); BuidelText.alignment = (TextAnchor)4; Shadow obj = val5.AddComponent<Shadow>(); obj.effectColor = Color.black; obj.effectDistance = new Vector2(1.5f, -1.5f); RectTransform component8 = val5.GetComponent<RectTransform>(); component8.anchorMin = new Vector2(0f, 0f); component8.anchorMax = new Vector2(1f, 1f); component8.pivot = new Vector2(0.5f, 0.5f); component8.offsetMin = new Vector2(0f, 0f); component8.offsetMax = new Vector2(0f, 0f); } private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown harmony = new Harmony("EndosCoinPurse"); harmony.PatchAll(); ConfigPosX = ((BaseUnityPlugin)this).Config.Bind<float>("Positie", "Buidel X Positie", 570f, "De horizontale positie van het muntzakje op het inventarisscherm."); ConfigPosY = ((BaseUnityPlugin)this).Config.Bind<float>("Positie", "Buidel Y Positie", 30f, "De verticale positie van het muntzakje op het inventarisscherm."); ConfigPosX.SettingChanged += delegate { UpdateBuidelPosition(); }; ConfigPosY.SettingChanged += delegate { UpdateBuidelPosition(); }; VirtueleBuidelInv = new Inventory("VirtueleMuntbuidel", (Sprite)null, 1, 1); Inventory virtueleBuidelInv = VirtueleBuidelInv; virtueleBuidelInv.m_onChanged = (Action)Delegate.Combine(virtueleBuidelInv.m_onChanged, new Action(UpdateBuidelCount)); Logger.LogInfo((object)"EndosCoinPurse HUD succesvol opgestart!"); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } public static void UpdateBuidelPosition() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)BuidelPanel != (Object)null) { RectTransform component = BuidelPanel.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.anchoredPosition = new Vector2(ConfigPosX.Value, ConfigPosY.Value); } } } public static void UpdateBuidelCount() { if (VirtueleBuidelInv != null && !((Object)(object)BuidelText == (Object)null)) { int num = VirtueleBuidelInv.CountItems("$item_coins", -1, true); BuidelText.text = ((num > 0) ? num.ToString() : "0"); } } } [HarmonyPatch(typeof(InventoryGui), "Show")] public static class InventoryGuiShowPatch { private static void Postfix(InventoryGui __instance) { if ((Object)(object)MuntBuidelHUDMod.BuidelPanel == (Object)null) { MuntBuidelHUDMod.CreateBuidelSlotUI(__instance); } if ((Object)(object)MuntBuidelHUDMod.BuidelPanel != (Object)null) { MuntBuidelHUDMod.BuidelPanel.SetActive(true); MuntBuidelHUDMod.UpdateBuidelPosition(); MuntBuidelHUDMod.UpdateBuidelCount(); } } } [HarmonyPatch(typeof(InventoryGui), "Hide")] public static class InventoryGuiHidePatch { private static void Postfix() { if ((Object)(object)MuntBuidelHUDMod.BuidelPanel != (Object)null) { MuntBuidelHUDMod.BuidelPanel.SetActive(false); } } } [HarmonyPatch(typeof(Player), "Save")] public static class PlayerSavePatch { private static void Postfix(Player __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); MuntBuidelHUDMod.VirtueleBuidelInv.Save(val); __instance.m_customData["buidel_items_hud"] = Convert.ToBase64String(val.GetArray()); } } [HarmonyPatch(typeof(Player), "Load")] public static class PlayerLoadPatch { private static void Postfix(Player __instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (__instance.m_customData.TryGetValue("buidel_items_hud", out var value) && !string.IsNullOrEmpty(value)) { ZPackage val = new ZPackage(Convert.FromBase64String(value)); MuntBuidelHUDMod.VirtueleBuidelInv.Load(val); } } }