Decompiled source of DolyCompanyCards v0.1.1

plugins/DolyTheMaid-DolyCompanyCards/DolyCardsReal.dll

Decompiled 2 hours ago
using System;
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DolyCardsReal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DolyCardsReal")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("110fab3c-c07a-41c9-9c46-e5048d9aa176")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DolyCards;

[BepInPlugin("com.doly.dolycards", "Doly Cards", "1.0.0")]
public class DolyCardsReal : BaseUnityPlugin
{
	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Doly Cards loading...");
		try
		{
			InstallContent();
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Doly Cards failed to install: {arg}");
		}
	}

	private void InstallContent()
	{
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string fullName = Directory.GetParent(directoryName).Parent.FullName;
		string text = Path.Combine(fullName, "Sholiver-LethalCardLoader", "Content");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string resourcePrefix = executingAssembly.GetName().Name + ".Content.";
		string[] array = (from name in executingAssembly.GetManifestResourceNames()
			where name.StartsWith(resourcePrefix)
			select name).ToArray();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"========== DOLY CARDS ==========");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin directory: " + directoryName));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugins directory: " + fullName));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Destination directory: " + text));
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Embedded Content resources: {array.Length}");
		if (array.Length == 0)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"No embedded Content resources were found. Make sure your files have Build Action = Embedded Resource.");
			return;
		}
		int num = 0;
		int num2 = 0;
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			try
			{
				string text3 = text2.Substring(resourcePrefix.Length);
				string extension = Path.GetExtension(text3);
				string path = text3.Substring(0, text3.Length - extension.Length).Replace('.', Path.DirectorySeparatorChar) + extension;
				string text4 = Path.Combine(text, path);
				Directory.CreateDirectory(Path.GetDirectoryName(text4));
				using (Stream stream = executingAssembly.GetManifestResourceStream(text2))
				{
					if (stream == null)
					{
						((BaseUnityPlugin)this).Logger.LogError((object)("Could not open resource: " + text2));
						num2++;
						continue;
					}
					using FileStream destination = new FileStream(text4, FileMode.Create, FileAccess.Write);
					stream.CopyTo(destination);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Extracted: " + text3 + " -> " + text4));
				num++;
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to extract {text2}: {arg}");
				num2++;
			}
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Extraction complete. " + $"Successful: {num}, Failed: {num2}"));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"========== END DOLY CARDS ==========");
		if (num2 == 0)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Doly Cards installed successfully!");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Doly Cards installation completed with {num2} failures.");
		}
	}
}