Decompiled source of RandomCardDeck v1.0.1

plugins/GeckVolantMarin-RandomCardDeck.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GeckVolantMarin-RandomCardDeck")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GeckVolantMarin-RandomCardDeck")]
[assembly: AssemblyTitle("GeckVolantMarin-RandomCardDeck")]
[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 GeckVolantMarin.RandomCardDeck
{
	public static class NewCards
	{
		public static CardInfo randomCard;

		private static void createRandomCard()
		{
			randomCard = CardExtensions.SetPixelPortrait(CardManager.New("GeckVolantMarin-RandomCardDeck", "RandomCard", "Random Card", 0, 0, "You don't know which one."), "GeckVolantMarin-RandomCardDeck/assets/Cards/randomCard/pixel.png");
		}

		public static void createCards()
		{
			createRandomCard();
		}
	}
	[HarmonyPatch]
	public static class NewDecks
	{
		private static readonly Harmony HarmonyInstance = new Harmony("GeckVolantMarin-RandomCardDeck");

		public static StarterDeckInfo randomCardDeck;

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void NewRun()
		{
			if (!(AscensionSaveData.Data.currentStarterDeck == "GeckVolantMarin-RandomCardDeck_Random"))
			{
				return;
			}
			List<CardInfo> list = new List<CardInfo>();
			foreach (CardInfo cardInfo in ((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).CardInfos)
			{
				list.Add(cardInfo);
			}
			foreach (CardInfo item in list)
			{
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).RemoveCard(item);
			}
			List<CardInfo> list2 = new List<CardInfo>(CardManager.AllCardsCopy.Where((CardInfo ci) => CardExtensions.HasAnyOfCardMetaCategories(ci, (CardMetaCategory[])(object)new CardMetaCategory[3]
			{
				default(CardMetaCategory),
				(CardMetaCategory)3,
				(CardMetaCategory)1
			}) && (int)ci.temple == 0).ToArray());
			double[] array = new double[list2.Count()];
			for (int i = 0; i < list2.Count(); i++)
			{
				array[i] = (CardExtensions.HasCardMetaCategory(list2[i], (CardMetaCategory)3) ? 0.3 : 1.0);
			}
			for (int j = 0; j < 3; j++)
			{
				CardInfo randomThings_FromArray = RNG.getRandomThings_FromArray<CardInfo>(list2.ToArray(), array, 0.0);
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(randomThings_FromArray);
			}
			if (SaveManager.saveFile.ascensionData.numRunsSinceReachedFirstBoss == 0)
			{
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("PeltHare"));
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("PeltHare"));
			}
			else if (SaveManager.saveFile.ascensionData.numRunsSinceReachedFirstBoss == 1)
			{
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("Opossum"));
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("PeltHare"));
			}
			else if (SaveManager.saveFile.ascensionData.numRunsSinceReachedFirstBoss > 1)
			{
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("Opossum"));
				((CardCollectionInfo)SaveManager.saveFile.ascensionData.currentRun.playerDeck).AddCard(CardLoader.GetCardByName("RingWorm"));
			}
		}

		private static void createRandomCardDeck()
		{
			randomCardDeck = ScriptableObject.CreateInstance<StarterDeckInfo>();
			randomCardDeck.title = "Random";
			randomCardDeck.iconSprite = TextureHelper.GetImageAsSprite("GeckVolantMarin-RandomCardDeck/assets/DeckIcons/random.png", (SpriteType)9, (FilterMode)0);
			randomCardDeck.cards = new List<CardInfo>
			{
				NewCards.randomCard,
				NewCards.randomCard,
				NewCards.randomCard
			};
			StarterDeckManager.Add("GeckVolantMarin-RandomCardDeck", randomCardDeck, 0);
		}

		public static void createDecks()
		{
			createRandomCardDeck();
			HarmonyInstance.PatchAll(typeof(Plugin).Assembly);
		}
	}
	[BepInPlugin("GeckVolantMarin-RandomCardDeck", "GeckVolantMarin-RandomCardDeck", "1.0.0")]
	[BepInProcess("Inscryption.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static string directory;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			directory = ((BaseUnityPlugin)this).Info.Location;
			NewCards.createCards();
			NewDecks.createDecks();
			Logger.LogInfo((object)"Reussi?");
			Logger.LogInfo((object)"Plugin GeckVolantMarin-RandomCardDeck is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GeckVolantMarin-RandomCardDeck";

		public const string PLUGIN_NAME = "GeckVolantMarin-RandomCardDeck";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}