using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using DunGen.Graph;
using LethalLevelLoader;
using TerminalApi;
using TerminalApi.Classes;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TerminalDungeon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TerminalDungeon")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77eed504-aecb-4aad-98fc-473afc8bb190")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalDungeon;
[BepInPlugin("qh3.TerminalDungeon", "TerminalDungeon", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
internal static ManualLogSource Log = Logger.CreateLogSource("qh3.TerminalDungeon");
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
Log.LogInfo((object)"Loading TerminalDungeon Mod");
Instance = this;
TerminalApi.AddCommand("Dungeon", new CommandInfo
{
DisplayTextSupplier = GetDungeonWeight
}, (string)null, true);
}
private string GetDungeonWeight()
{
if ((Object)(object)StartOfRound.Instance != (Object)null)
{
StringBuilder stringBuilder = new StringBuilder();
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
stringBuilder.Append("* ");
string value = Regex.Replace(val.PlanetName, "[\\d\\s]", "");
stringBuilder.Append(value);
stringBuilder.Append(": ");
IntWithRarity[] flowTypes = GetFlowTypes(val);
IntWithRarity[] array = flowTypes;
foreach (IntWithRarity val2 in array)
{
int id = val2.id;
int rarity = val2.rarity;
stringBuilder.Append(((Object)RoundManager.Instance.dungeonFlowTypes[id].dungeonFlow).name);
stringBuilder.Append($"({rarity}) ");
}
stringBuilder.AppendLine();
}
return stringBuilder.ToString();
}
return "DungeonWeight Error";
}
private IntWithRarity[] GetFlowTypes(SelectableLevel level)
{
IntWithRarity[] result = level.dungeonFlowTypes;
if (IsModLoaded("imabatby.lethallevelloader"))
{
result = GetLethalLevelLoaderFlowTypes(level);
}
return result;
}
private IntWithRarity[] GetLethalLevelLoaderFlowTypes(SelectableLevel level)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Expected O, but got Unknown
List<StringContainer> list = new List<StringContainer>();
List<int> list2 = new List<int>();
List<ExtendedDungeonFlowWithRarity> list3 = new List<ExtendedDungeonFlowWithRarity>();
ExtendedLevel val = default(ExtendedLevel);
if (LevelManager.TryGetExtendedLevel(level, ref val, (ContentType)2))
{
list3 = DungeonManager.GetValidExtendedDungeonFlows(val, true);
}
if (list3.Count == 0)
{
list.Add(new StringContainer
{
SomeText = ((Object)PatchedContent.ExtendedDungeonFlows[0].DungeonFlow).name
});
list2.Add(300);
}
else
{
List<DungeonFlow> dungeonFlows = Extensions.GetDungeonFlows(RoundManager.Instance);
foreach (ExtendedDungeonFlowWithRarity item in list3)
{
list.Add(new StringContainer
{
SomeText = ((Object)dungeonFlows[dungeonFlows.IndexOf(item.extendedDungeonFlow.DungeonFlow)]).name
});
list2.Add(item.rarity);
}
}
List<IntWithRarity> list4 = new List<IntWithRarity>();
Dictionary<string, int> dictionary = new Dictionary<string, int>();
int num = 0;
foreach (DungeonFlow dungeonFlow in Extensions.GetDungeonFlows(RoundManager.Instance))
{
dictionary.Add(((Object)dungeonFlow).name, num);
num++;
}
for (int i = 0; i < list.ToArray().Length; i++)
{
IntWithRarity val2 = new IntWithRarity();
Extensions.Add(val2, dictionary[list[i].SomeText], list2[i]);
list4.Add(val2);
}
return list4.ToArray();
}
private bool IsModLoaded(string guid)
{
if (Chainloader.PluginInfos.TryGetValue(guid, out var _))
{
return true;
}
return false;
}
}