Decompiled source of PokemonTCG v0.2.7

patchers/PokemonTCGContentExtractor/PokemonTCGContentExtractor.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[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("PokemonTCGContentExtractor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PokemonTCGContentExtractor")]
[assembly: AssemblyTitle("PokemonTCGContentExtractor")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 PokemonTCGContentExtractor
{
	public static class Patcher
	{
		private static ManualLogSource? Log;

		public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };

		public static void Initialize()
		{
			Log = Logger.CreateLogSource("PokemonTCGContentExtractor");
			try
			{
				Log.LogInfo((object)"Searching for PokemonTCG and LethalCardLoader installations...");
				string text = Directory.GetFiles(Paths.PluginPath, "PokemonTCG.dll", SearchOption.AllDirectories).FirstOrDefault();
				if (string.IsNullOrEmpty(text))
				{
					Log.LogError((object)("PokemonTCG.dll not found inside: " + Paths.PluginPath));
					return;
				}
				string directoryName = Path.GetDirectoryName(text);
				if (string.IsNullOrEmpty(directoryName))
				{
					Log.LogError((object)"Unable to determine PokemonTCG directory.");
					return;
				}
				string text2 = Directory.GetFiles(Paths.PluginPath, "LethalCardLoader.dll", SearchOption.AllDirectories).FirstOrDefault();
				if (string.IsNullOrEmpty(text2))
				{
					Log.LogError((object)"LethalCardLoader.dll not found. Make sure Sholiver-LethalCardLoader is installed.");
					return;
				}
				string directoryName2 = Path.GetDirectoryName(text2);
				if (string.IsNullOrEmpty(directoryName2))
				{
					Log.LogError((object)"Unable to determine LethalCardLoader directory.");
					return;
				}
				string text3 = Path.Combine(directoryName, "Content.zip");
				string text4 = Path.Combine(directoryName2, "Content");
				string path = Path.Combine(text4, ".extracted.marker");
				if (File.Exists(path))
				{
					Log.LogInfo((object)"PokemonTCG Content is already correctly extracted.");
					return;
				}
				if (!File.Exists(text3))
				{
					Log.LogError((object)("Content.zip not found: " + text3));
					return;
				}
				if (Directory.Exists(text4))
				{
					Log.LogWarning((object)"Incomplete Content directory detected in LethalCardLoader. Deleting it.");
					Directory.Delete(text4, recursive: true);
				}
				Log.LogInfo((object)"Extracting Content.zip into LethalCardLoader directory...");
				int num = 0;
				int num2 = 0;
				using (ZipArchive zipArchive = ZipFile.OpenRead(text3))
				{
					foreach (ZipArchiveEntry entry in zipArchive.Entries)
					{
						if (string.IsNullOrEmpty(entry.Name))
						{
							continue;
						}
						string fullPath = Path.GetFullPath(Path.Combine(directoryName2, entry.FullName));
						try
						{
							string directoryName3 = Path.GetDirectoryName(fullPath);
							if (!string.IsNullOrEmpty(directoryName3))
							{
								Directory.CreateDirectory(directoryName3);
							}
							entry.ExtractToFile(fullPath, overwrite: true);
							num++;
						}
						catch (Exception ex)
						{
							num2++;
							Log.LogError((object)$"Failed to extract '{entry.FullName}' (path length: {fullPath.Length}): {ex.Message}");
						}
					}
				}
				int num3 = Directory.GetFiles(text4, "*.json", SearchOption.AllDirectories).Length;
				int num4 = Directory.GetFiles(text4, "*.png", SearchOption.AllDirectories).Length;
				Log.LogInfo((object)($"Extraction terminée : {num} fichiers extraits, {num2} échecs. " + $"Sur le disque : {num3} json, {num4} png."));
				if (num2 > 0)
				{
					Log.LogError((object)"Des fichiers n'ont pas pu être extraits (voir les erreurs ci-dessus). Le marker ne sera pas créé, l'extraction sera retentée au prochain lancement.");
					return;
				}
				if (num4 == 0)
				{
					Log.LogError((object)"Aucune image .png trouvée après extraction. Content.zip ne contient probablement pas d'images : vérifie l'archive elle-même.");
					return;
				}
				File.WriteAllText(path, DateTime.UtcNow.ToString("o"));
				Log.LogInfo((object)"PokemonTCG Content extracted successfully.");
			}
			catch (Exception arg)
			{
				ManualLogSource? log = Log;
				if (log != null)
				{
					log.LogError((object)$"Unable to extract PokemonTCG Content.zip: {arg}");
				}
			}
		}

		public static void Patch(AssemblyDefinition assembly)
		{
		}
	}
}

plugins/PokemonTCG/PokemonTCG.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("PokemonTCG")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PokemonTCG")]
[assembly: AssemblyTitle("PokemonTCG")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace PokemonTCG
{
	[HarmonyPatch(typeof(StartOfRound), "Start")]
	internal static class RemoveVanillaScrapPatch
	{
		private static void Postfix(StartOfRound __instance)
		{
			if ((Object)(object)__instance == (Object)null || __instance.levels == null)
			{
				return;
			}
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if ((Object)(object)val == (Object)null || val.spawnableScrap == null)
				{
					continue;
				}
				int count = val.spawnableScrap.Count;
				val.spawnableScrap.RemoveAll(delegate(SpawnableItemWithRarity scrap)
				{
					if (scrap == null || (Object)(object)scrap.spawnableItem == (Object)null)
					{
						return true;
					}
					string itemName = scrap.spawnableItem.itemName;
					string name = ((Object)scrap.spawnableItem).name;
					bool flag = itemName == "BasePack" || name == "BasePack";
					return !flag;
				});
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)$"[PokemonTCG] {val.PlanetName}: {count} scraps -> {val.spawnableScrap.Count} boosters only");
				}
			}
		}
	}
	[BepInPlugin("vroumvroum.pokemontcg", "PokemonTCG", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource? Log;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("vroumvroum.pokemontcg");
			val.PatchAll();
			Log.LogInfo((object)"PokemonTCG loaded!");
		}
	}
}