Decompiled source of Dawnlib Frikin Dungeon ID Exporter v1.0.0

DawnlibIDsFrikinExporter.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;

[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("DawnlibIDsFrikinExporter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DawnlibIDsFrikinExporter")]
[assembly: AssemblyTitle("DawnlibIDsFrikinExporter")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("local.dungeonidexporter", "Dungeon ID Exporter", "1.6.0")]
public class DungeonIDExporter : BaseUnityPlugin
{
	private bool exported;

	private bool waitingLogged;

	private void Update()
	{
		if (exported)
		{
			return;
		}
		try
		{
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "com.github.teamxiaolan.dawnlib");
			if (assembly == null)
			{
				return;
			}
			Type type = assembly.GetType("Dawn.LethalContent");
			FieldInfo field = type.GetField("Dungeons", BindingFlags.Static | BindingFlags.Public);
			object value = field.GetValue(null);
			Type type2 = value.GetType();
			if (!(bool)type2.GetProperty("IsFrozen").GetValue(value))
			{
				if (!waitingLogged)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Waiting for DawnLib dungeon registry...");
					waitingLogged = true;
				}
				return;
			}
			int num = (int)type2.GetProperty("Count").GetValue(value);
			IEnumerable source = (IEnumerable)type2.GetProperty("Keys").GetValue(value);
			string[] array = (from object key in source
				select key.ToString() into key
				orderby key
				select key).ToArray();
			string text = Path.Combine(Paths.ConfigPath, "DungeonIDs.txt");
			File.WriteAllLines(text, array);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Dungeon export complete!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Registry count: " + num));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Exported keys: " + array.Length));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("File: " + text));
			exported = true;
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Dungeon export failed: " + ex));
			exported = true;
		}
	}
}