using 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(); val.valueMin = 3500f; val.valueMax = 3500f; return val; } public static Durability CreateDurabilityPreset() { Durability val = ScriptableObject.CreateInstance(); val.fragility = 10f; val.durability = 50f; return val; } public static PhysAttribute CreatePhysPreset() { PhysAttribute val = ScriptableObject.CreateInstance(); val.mass = 0.2f; return val; } public static PhysAudio CreateAudioPreset() { return ScriptableObject.CreateInstance(); } } [BepInPlugin("ty.packofcards", "Pack of Cards Item", "1.0.3")] public class TyPackOfCardsLoot : BaseUnityPlugin { internal static TyPackOfCardsLoot Instance; internal Dictionary cardBundles = new Dictionary(); internal Dictionary cardPrefabs = new Dictionary(); 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(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(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 val3 = val2.AddComponent(); val3.mass = 0.2f; } if (!Object.op_Implicit((Object)(object)val2.GetComponent())) { BoxCollider val4 = val2.AddComponent(); val4.size = new Vector3(0.2f, 0.1f, 0.3f); } ValuableObject val5 = val2.GetComponent() ?? val2.AddComponent(); val5.valuePreset = PackOfCardsPreset.CreateValuePreset(); val5.durabilityPreset = PackOfCardsPreset.CreateDurabilityPreset(); val5.physAttributePreset = PackOfCardsPreset.CreatePhysPreset(); val5.audioPreset = PackOfCardsPreset.CreateAudioPreset(); if (!Object.op_Implicit((Object)(object)val2.GetComponent())) { val2.AddComponent(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent())) { val2.AddComponent(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent())) { val2.AddComponent(); } ValuableVolume val6 = val2.GetComponent() ?? val2.AddComponent(); val6.VolumeType = (Type)1; if (!Object.op_Implicit((Object)(object)val2.GetComponent())) { PackOpenBehaviourNew packOpenBehaviourNew = val2.AddComponent(); packOpenBehaviourNew.interactRange = 2.5f; } PrefabRef val7 = new PrefabRef(); ((PrefabRef)(object)val7).SetPrefab(val, text2); LevelValuables[] array = Resources.FindObjectsOfTypeAll(); ((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 list = new List { "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(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(); foreach (Collider val4 in components) { val4.enabled = false; } Renderer component = ((Component)this).GetComponent(); 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() 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(val, val2, Quaternion.identity); return true; } }