Please disclose if your mod was created primarily 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 Cursed Doll v1.0.0
CursedDoll.dll
Decompiled 6 months agousing System; 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 System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jewelcrafting; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("CursedDoll")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("KG")] [assembly: AssemblyProduct("CursedDoll")] [assembly: AssemblyCopyright("Copyright © KG 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("80388C38-EA27-4D63-A430-FCAE3A749DA3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CursedDoll { [BepInPlugin("CursedDoll", "CursedDoll", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CursedDollPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch_ValhallaItem { private static void Postfix(ZNetScene __instance) { __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)CursedDoll).name), CursedDoll); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPriority(0)] public static class DB_Patch_ValhallaItem { private static void Postfix() { AddValhallaItemToODB(); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPriority(0)] public static class DB_Patch2_ValhallaItem { private static void Postfix() { AddValhallaItemToODB(); } } [CompilerGenerated] private static class <>O { public static ItemBreakHandler <0>__BreakHandler_CursedDoll; } private const string GUID = "CursedDoll"; private const string PluginName = "CursedDoll"; private const string PluginVersion = "1.0.0"; private static GameObject CursedDoll; private static AssetBundle asset; private static AssetBundle GetAssetBundle(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } private void Awake() { //IL_0084: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown asset = GetAssetBundle("curseddoll"); CursedDoll = asset.LoadAsset<GameObject>("kg_CursedDoll"); CursedDoll.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "Cursed Doll"; CursedDoll.GetComponent<ItemDrop>().m_itemData.m_shared.m_description = ""; object obj = <>O.<0>__BreakHandler_CursedDoll; if (obj == null) { ItemBreakHandler val = BreakHandler_CursedDoll; <>O.<0>__BreakHandler_CursedDoll = val; obj = (object)val; } API.OnItemBreak((ItemBreakHandler)obj); new Harmony("CursedDoll").PatchAll(); } private static bool HasItem(string prefab) { return ((Humanoid)Player.m_localPlayer).m_inventory.m_inventory.Any((ItemData itemData) => ((Object)itemData.m_dropPrefab).name == prefab); } public static bool HasCursedDoll() { return HasItem(((Object)CursedDoll).name); } public static bool BreakHandler_CursedDoll(ItemData _) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (HasCursedDoll()) { CustomRemoveItemsNoLevel(((Object)CursedDoll).name, 1); MessageHud.instance.ShowMessage((MessageType)2, "Cursed Doll Destroyed", 0, (Sprite)null, false); Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("fx_shaman_fireball_expl"), ((Component)Player.m_localPlayer).transform.position, Quaternion.identity); return false; } return true; } private static void CustomRemoveItemsNoLevel(string name, int amount) { foreach (ItemData item in ((Humanoid)Player.m_localPlayer).m_inventory.m_inventory) { if (((Object)item.m_dropPrefab).name == name) { int num = Mathf.Min(item.m_stack, amount); item.m_stack -= num; amount -= num; if (amount <= 0) { break; } } } ((Humanoid)Player.m_localPlayer).m_inventory.m_inventory.RemoveAll((ItemData x) => x.m_stack <= 0); ((Humanoid)Player.m_localPlayer).m_inventory.Changed(); } private static void AddValhallaItemToODB() { if (!((Object)(object)ObjectDB.instance == (Object)null) && ObjectDB.instance.m_items.Count != 0 && !((Object)(object)ObjectDB.instance.GetItemPrefab("Amber") == (Object)null) && !((Object)(object)ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)CursedDoll).name)) != (Object)null)) { ObjectDB.instance.m_items.Add(CursedDoll); ObjectDB.instance.m_itemByHash[StringExtensionMethods.GetStableHashCode(((Object)CursedDoll).name)] = CursedDoll; } } } }