Decompiled source of Lethal Trading Cards v1.0.3

LethalTradingCards.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 BepInEx.Configuration;
using HarmonyLib;
using LethalLib.Modules;
using LethalTradingCards.Behaviours;
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("LethalTradingCards")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalTradingCards")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5501de44-7100-420d-a2ac-f00c9cb10c1d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace LethalTradingCards
{
	[BepInPlugin("ModusInteractive.LethalTradingCards", "Lethal Trading Cards", "1.0.0.0")]
	public class LethalCardsBase : BaseUnityPlugin
	{
		private const string modGUID = "ModusInteractive.LethalTradingCards";

		private const string modName = "Lethal Trading Cards";

		private const string modVersion = "1.0.0.0";

		private ConfigEntry<int> boosterPackRarity;

		private readonly Harmony harmony = new Harmony("ModusInteractive.LethalTradingCards");

		private static LethalCardsBase Instance;

		public List<GameObject> cardList;

		public List<int> cardWeights;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			boosterPackRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BoosterPackRarity", 40, "The rate at which the booster pack will spawn. Generally between 1-100.");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethaltradingcardsassetbundle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/LethalTradingCards/BoosterPackItem.asset");
			BoosterPackScript boosterPackScript = val2.spawnPrefab.AddComponent<BoosterPackScript>();
			((GrabbableObject)boosterPackScript).grabbable = true;
			((GrabbableObject)boosterPackScript).grabbableToEnemies = true;
			((GrabbableObject)boosterPackScript).itemProperties = val2;
			Item val3 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card01Item.asset");
			Item val4 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card01_holoItem.asset");
			Item val5 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card02Item.asset");
			Item val6 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card02_holoItem.asset");
			Item val7 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card03Item.asset");
			Item val8 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card03_holoItem.asset");
			Item val9 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card04Item.asset");
			Item val10 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card04_holoItem.asset");
			Item val11 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card05Item.asset");
			Item val12 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card05_holoItem.asset");
			Item val13 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card06Item.asset");
			Item val14 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card06_holoItem.asset");
			Item val15 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card07Item.asset");
			Item val16 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card07_holoItem.asset");
			Item val17 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card08Item.asset");
			Item val18 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card08_holoItem.asset");
			Item val19 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card09Item.asset");
			Item val20 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card09_holoItem.asset");
			Item val21 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card10Item.asset");
			Item val22 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card10_holoItem.asset");
			Item val23 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card11Item.asset");
			Item val24 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card11_holoItem.asset");
			Item val25 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card12Item.asset");
			Item val26 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card12_holoItem.asset");
			Item val27 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card13Item.asset");
			Item val28 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card13_holoItem.asset");
			Item val29 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card14Item.asset");
			Item val30 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card14_holoItem.asset");
			Item val31 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card15Item.asset");
			Item val32 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card15_holoItem.asset");
			Item val33 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card16Item.asset");
			Item val34 = val.LoadAsset<Item>("Assets/LethalTradingCards/Card16_holoItem.asset");
			cardList = new List<GameObject>
			{
				val3.spawnPrefab, val4.spawnPrefab, val5.spawnPrefab, val6.spawnPrefab, val7.spawnPrefab, val8.spawnPrefab, val9.spawnPrefab, val10.spawnPrefab, val11.spawnPrefab, val12.spawnPrefab,
				val13.spawnPrefab, val14.spawnPrefab, val15.spawnPrefab, val16.spawnPrefab, val17.spawnPrefab, val18.spawnPrefab, val19.spawnPrefab, val20.spawnPrefab, val21.spawnPrefab, val22.spawnPrefab,
				val23.spawnPrefab, val24.spawnPrefab, val25.spawnPrefab, val26.spawnPrefab, val27.spawnPrefab, val28.spawnPrefab, val29.spawnPrefab, val30.spawnPrefab, val31.spawnPrefab, val32.spawnPrefab,
				val33.spawnPrefab, val34.spawnPrefab
			};
			cardWeights = new List<int>
			{
				20, 6, 15, 3, 20, 6, 6, 1, 15, 5,
				15, 5, 6, 1, 20, 5, 10, 2, 10, 2,
				6, 1, 10, 2, 15, 5, 15, 5, 10, 2,
				15, 5
			};
			boosterPackScript.packContents = cardList;
			boosterPackScript.packWeights = cardWeights;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Utilities.FixMixerGroups(val4.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Utilities.FixMixerGroups(val5.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
			Utilities.FixMixerGroups(val6.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
			Utilities.FixMixerGroups(val7.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
			Utilities.FixMixerGroups(val8.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val9.spawnPrefab);
			Utilities.FixMixerGroups(val9.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val10.spawnPrefab);
			Utilities.FixMixerGroups(val10.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val11.spawnPrefab);
			Utilities.FixMixerGroups(val11.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val12.spawnPrefab);
			Utilities.FixMixerGroups(val12.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val13.spawnPrefab);
			Utilities.FixMixerGroups(val13.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val14.spawnPrefab);
			Utilities.FixMixerGroups(val14.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val15.spawnPrefab);
			Utilities.FixMixerGroups(val15.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val16.spawnPrefab);
			Utilities.FixMixerGroups(val16.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val17.spawnPrefab);
			Utilities.FixMixerGroups(val17.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val18.spawnPrefab);
			Utilities.FixMixerGroups(val18.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val19.spawnPrefab);
			Utilities.FixMixerGroups(val19.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val20.spawnPrefab);
			Utilities.FixMixerGroups(val20.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val21.spawnPrefab);
			Utilities.FixMixerGroups(val21.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val22.spawnPrefab);
			Utilities.FixMixerGroups(val22.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val23.spawnPrefab);
			Utilities.FixMixerGroups(val23.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val24.spawnPrefab);
			Utilities.FixMixerGroups(val24.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val25.spawnPrefab);
			Utilities.FixMixerGroups(val25.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val26.spawnPrefab);
			Utilities.FixMixerGroups(val26.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val27.spawnPrefab);
			Utilities.FixMixerGroups(val27.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val28.spawnPrefab);
			Utilities.FixMixerGroups(val28.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val29.spawnPrefab);
			Utilities.FixMixerGroups(val29.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val30.spawnPrefab);
			Utilities.FixMixerGroups(val30.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val31.spawnPrefab);
			Utilities.FixMixerGroups(val31.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val32.spawnPrefab);
			Utilities.FixMixerGroups(val32.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val33.spawnPrefab);
			Utilities.FixMixerGroups(val33.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val34.spawnPrefab);
			Utilities.FixMixerGroups(val34.spawnPrefab);
			Items.RegisterItem(val3);
			Items.RegisterItem(val5);
			Items.RegisterItem(val7);
			Items.RegisterItem(val9);
			Items.RegisterItem(val11);
			Items.RegisterItem(val13);
			Items.RegisterItem(val15);
			Items.RegisterItem(val17);
			Items.RegisterItem(val19);
			Items.RegisterItem(val21);
			Items.RegisterItem(val23);
			Items.RegisterItem(val25);
			Items.RegisterItem(val27);
			Items.RegisterItem(val29);
			Items.RegisterItem(val31);
			Items.RegisterItem(val33);
			Items.RegisterItem(val4);
			Items.RegisterItem(val6);
			Items.RegisterItem(val8);
			Items.RegisterItem(val10);
			Items.RegisterItem(val12);
			Items.RegisterItem(val14);
			Items.RegisterItem(val16);
			Items.RegisterItem(val18);
			Items.RegisterItem(val20);
			Items.RegisterItem(val22);
			Items.RegisterItem(val24);
			Items.RegisterItem(val26);
			Items.RegisterItem(val28);
			Items.RegisterItem(val30);
			Items.RegisterItem(val32);
			Items.RegisterItem(val34);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, boosterPackRarity.Value, (LevelTypes)(-1));
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ModusInteractive.LethalTradingCards");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Lethal Trading Cards");
		}
	}
}
namespace LethalTradingCards.Behaviours
{
	internal class BoosterPackScript : GiftBoxItem
	{
		public List<GameObject> packContents;

		public List<int> packWeights;

		public int weightTotal;

		public float valueMultiplier = 1.5f;

		public override void Start()
		{
			((GiftBoxItem)this).Start();
			weightTotal = 0;
			foreach (int packWeight in packWeights)
			{
				weightTotal += packWeight;
			}
			Debug.Log((object)("Random Roll: " + RandomWeighted()));
			base.objectInPresent = packContents[RandomWeighted()];
			GrabbableObject component = base.objectInPresent.GetComponent<GrabbableObject>();
			base.objectInPresentValue = (int)((float)Random.Range(component.itemProperties.minValue, component.itemProperties.maxValue) * RoundManager.Instance.scrapValueMultiplier * valueMultiplier);
			base.PoofParticle = ((Component)this).GetComponentInChildren<ParticleSystem>();
			if (!Object.op_Implicit((Object)(object)base.presentAudio))
			{
				base.presentAudio = ((Component)this).GetComponentInChildren<AudioSource>();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GiftBoxItem)this).ItemActivate(used, buttonDown);
		}

		private int RandomWeighted()
		{
			int num = 0;
			int num2 = 0;
			int num3 = Random.Range(0, weightTotal + 1);
			for (num = 0; num < packWeights.Count; num++)
			{
				num2 += packWeights[num];
				if (num2 >= num3)
				{
					break;
				}
			}
			return num;
		}
	}
}