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 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) { } } }