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 Pack Of Cards v1.0.5
PackOfCardsMod.dll
Decompiled a day agousing System; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PackOfCardsMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PackOfCardsMod")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7a22f61b-c571-445a-ba37-b2779eb31345")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public static class PackOfCardsPreset { public static Value CreateValuePreset() { Value val = ScriptableObject.CreateInstance<Value>(); val.valueMin = 3500f; val.valueMax = 3500f; return val; } public static Durability CreateDurabilityPreset() { Durability val = ScriptableObject.CreateInstance<Durability>(); val.fragility = 10f; val.durability = 50f; return val; } public static PhysAttribute CreatePhysPreset() { PhysAttribute val = ScriptableObject.CreateInstance<PhysAttribute>(); val.mass = 0.2f; return val; } public static PhysAudio CreateAudioPreset() { return ScriptableObject.CreateInstance<PhysAudio>(); } } [BepInPlugin("ty.packofcards", "Pack of Cards Item", "1.0.3")] public class TyPackOfCardsLoot : BaseUnityPlugin { internal static TyPackOfCardsLoot Instance; internal Dictionary<string, AssetBundle> cardBundles = new Dictionary<string, AssetBundle>(); internal Dictionary<string, GameObject> cardPrefabs = new Dictionary<string, GameObject>(); private readonly string[] cardNames = new string[10] { "xrcard", "rcard1", "rarecard2", "basecard", "2ndtmehcard", "3rdtmehcard", "cc", "3rdworstcard", "2ndtwcard", "mcard" }; private void Awake() { Instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"PackOfCardsMod loaded."); LoadCardBundles(); RegisterPackValuable(); } public void Log(string msg) { ((BaseUnityPlugin)this).Logger.LogInfo((object)msg); } public void LogWarn(string msg) { ((BaseUnityPlugin)this).Logger.LogWarning((object)msg); } private void LoadCardBundles() { string path = Path.Combine(Paths.PluginPath, "Ty_REPO-Pack_Of_Cards"); string[] array = cardNames; foreach (string text in array) { string text2 = Path.Combine(path, text); if (!File.Exists(text2)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Card bundle not found: " + text2)); continue; } AssetBundle val = AssetBundle.LoadFromFile(text2); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load card bundle: " + text2)); continue; } cardBundles[text] = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded card bundle: " + text)); string[] allAssetNames = val.GetAllAssetNames(); string text3 = allAssetNames.FirstOrDefault((string a) => a.EndsWith(".prefab") || !Enumerable.Contains(a, '.')); if (!string.IsNullOrEmpty(text3)) { GameObject val2 = val.LoadAsset<GameObject>(text3); if ((Object)(object)val2 != (Object)null) { cardPrefabs[text] = val2; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded card prefab for " + text + ": " + ((Object)val2).name)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Prefab asset path found but failed to load GameObject: " + text3)); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("No prefab asset found inside bundle: " + text)); } } } private void RegisterPackValuable() { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown string text = Path.Combine(Paths.PluginPath, "Ty_REPO-PackOfCard"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Cannot register valuable — PackOfCards bundle not loaded."); return; } string[] allAssetNames = val.GetAllAssetNames(); string text2 = allAssetNames.FirstOrDefault((string a) => a.EndsWith(".prefab") || !Enumerable.Contains(a, '.')); if (text2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"No prefab found in cardpack AssetBundle!"); return; } GameObject val2 = val.LoadAsset<GameObject>(text2); if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load prefab at path: " + text2)); return; } if (!Object.op_Implicit((Object)(object)val2.GetComponent<Rigidbody>())) { Rigidbody val3 = val2.AddComponent<Rigidbody>(); val3.mass = 0.2f; } if (!Object.op_Implicit((Object)(object)val2.GetComponent<BoxCollider>())) { BoxCollider val4 = val2.AddComponent<BoxCollider>(); val4.size = new Vector3(0.2f, 0.1f, 0.3f); } ValuableObject val5 = val2.GetComponent<ValuableObject>() ?? val2.AddComponent<ValuableObject>(); val5.valuePreset = PackOfCardsPreset.CreateValuePreset(); val5.durabilityPreset = PackOfCardsPreset.CreateDurabilityPreset(); val5.physAttributePreset = PackOfCardsPreset.CreatePhysPreset(); val5.audioPreset = PackOfCardsPreset.CreateAudioPreset(); if (!Object.op_Implicit((Object)(object)val2.GetComponent<PhysGrabObject>())) { val2.AddComponent<PhysGrabObject>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<PhysGrabObjectImpactDetector>())) { val2.AddComponent<PhysGrabObjectImpactDetector>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<RoomVolumeCheck>())) { val2.AddComponent<RoomVolumeCheck>(); } ValuableVolume val6 = val2.GetComponent<ValuableVolume>() ?? val2.AddComponent<ValuableVolume>(); val6.VolumeType = (Type)1; if (!Object.op_Implicit((Object)(object)val2.GetComponent<PackOpenBehaviourNew>())) { PackOpenBehaviourNew packOpenBehaviourNew = val2.AddComponent<PackOpenBehaviourNew>(); packOpenBehaviourNew.interactRange = 2.5f; } PrefabRef val7 = new PrefabRef(); ((PrefabRef<GameObject>)(object)val7).SetPrefab(val, text2); LevelValuables[] array = Resources.FindObjectsOfTypeAll<LevelValuables>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registering Pack of Cards with {array.Length} levels"); LevelValuables[] array2 = array; foreach (LevelValuables val8 in array2) { if (val8.small != null) { val8.small.Add(val7); ((BaseUnityPlugin)this).Logger.LogInfo((object)("✓ Added Pack of Cards to " + ((Object)val8).name)); } } } } public class PackOpenBehaviour : MonoBehaviour { } public class PackOpenBehaviourNew : MonoBehaviour { public float interactRange = 2.5f; private bool opened = false; private Transform mainCam; private void Start() { Camera main = Camera.main; mainCam = ((main != null) ? ((Component)main).transform : null); } private void Update() { //IL_004c: 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) if (opened) { return; } if ((Object)(object)mainCam == (Object)null) { Camera main = Camera.main; mainCam = ((main != null) ? ((Component)main).transform : null); } if (!((Object)(object)mainCam == (Object)null)) { float num = Vector3.Distance(mainCam.position, ((Component)this).transform.position); if (num <= interactRange && Input.GetKeyDown((KeyCode)101)) { OpenPack(); } } } private void OpenPack() { //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: 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_024f: 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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) opened = true; TyPackOfCardsLoot.Instance?.Log("Player opened a Pack of Cards."); List<string> list = new List<string> { "xrcard", "rcard1", "rarecard2", "basecard", "2ndtmehcard", "3rdtmehcard", "cc", "3rdworstcard", "2ndtwcard", "mcard" }; Random random = new Random(); int num = list.Count; while (num > 1) { num--; int index = random.Next(num + 1); string value = list[index]; list[index] = list[num]; list[num] = value; } for (int i = 0; i < list.Count; i++) { string text = list[i]; float num2 = ((text == "mcard") ? 0.2f : ((i == 0) ? 0.05f : ((i != 1 && i != 2) ? 0.1f : 0.075f))); if (!(Random.value <= num2)) { TyPackOfCardsLoot.Instance?.Log($"Card {text} skipped (roll > {num2})."); } else if (text == "mcard") { if (TrySpawnRandomMonster()) { TyPackOfCardsLoot.Instance?.Log("mcard effect: spawned random monster."); } else { TyPackOfCardsLoot.Instance?.LogWarn("mcard effect: no monster prefab found to spawn."); } } else if ((Object)(object)TyPackOfCardsLoot.Instance != (Object)null && TyPackOfCardsLoot.Instance.cardPrefabs.ContainsKey(text)) { GameObject val = TyPackOfCardsLoot.Instance.cardPrefabs[text]; Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.3f; GameObject val3 = Object.Instantiate<GameObject>(val, val2, Quaternion.identity); TyPackOfCardsLoot.Instance?.Log($"Spawned card {text} at {val2}."); } else { TyPackOfCardsLoot.Instance?.LogWarn("Card prefab not available: " + text); } } Collider[] components = ((Component)this).GetComponents<Collider>(); foreach (Collider val4 in components) { val4.enabled = false; } Renderer component = ((Component)this).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component)) { component.enabled = false; } Object.Destroy((Object)(object)((Component)this).gameObject, 1f); } private bool TrySpawnRandomMonster() { //IL_0050: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) GameObject[] array = (from g in Resources.FindObjectsOfTypeAll<GameObject>() where ((Object)g).name.ToLower().Contains("enemy") || ((Object)g).name.ToLower().Contains("monster") || ((Object)g).name.ToLower().Contains("spawner") select g).ToArray(); if (array.Length == 0) { return false; } GameObject val = array[Random.Range(0, array.Length)]; Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.5f; Object.Instantiate<GameObject>(val, val2, Quaternion.identity); return true; } }