using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DunGen.Graph;
using HarmonyLib;
using MansionOnly.Patches;
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("MansionOnly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MansionOnly")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e1b520cb-a939-4e3e-ba61-c8defb1fac7f")]
[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 MansionOnly
{
[BepInPlugin("Ncrxpted.MansionOnly", "Mansion Only Mod", "1.0.0")]
public class MansionModBase : BaseUnityPlugin
{
private const string modGUID = "Ncrxpted.MansionOnly";
private const string modName = "Mansion Only Mod";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Ncrxpted.MansionOnly");
public static MansionModBase Instance { get; private set; }
public static ManualLogSource mls { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Ncrxpted.MansionOnly");
mls.LogInfo((object)"The Mansion Only mod has awakened!");
harmony.PatchAll(typeof(DungeonFlowTypePatch));
}
}
}
namespace MansionOnly.Patches
{
internal class DungeonFlowTypePatch
{
[HarmonyPatch(typeof(RoundManager), "Awake")]
[HarmonyPriority(250)]
[HarmonyPostfix]
private static void onStartPrefix(RoundManager __instance)
{
List<DungeonFlow> list = new List<DungeonFlow>();
MansionModBase.mls.LogInfo((object)"Inserting missing dungeon flows into the RoundManager");
List<DungeonFlow> list2 = __instance.dungeonFlowTypes.ToList();
list.AddRange(Resources.FindObjectsOfTypeAll<DungeonFlow>());
for (int i = 0; i < list.Count; i++)
{
DungeonFlow item = list[i];
list2.Add(item);
}
__instance.dungeonFlowTypes = list2.ToArray();
}
[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
[HarmonyPrefix]
private static void FlowTypeUpdate(RoundManager __instance)
{
SelectableLevel currentLevel = __instance.currentLevel;
MansionModBase.mls.LogInfo((object)"Changing dungeon flow values");
currentLevel.dungeonFlowTypes = __instance.setDungeonFlowTypeRarity();
}
}
public static class DungeonFlowTypeExtensions
{
public static IntWithRarity[] setDungeonFlowTypeRarity(this RoundManager manager)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
MansionModBase.mls.LogInfo((object)"Entered setDungeonFlowTypeRarity");
List<IntWithRarity> list = new List<IntWithRarity>();
for (int i = 0; i < manager.dungeonFlowTypes.Length; i++)
{
IntWithRarity val = new IntWithRarity();
val.id = i;
MansionModBase.mls.LogInfo((object)("DungeonFlow Name = " + ((Object)manager.dungeonFlowTypes[i]).name));
if (((Object)manager.dungeonFlowTypes[i]).name == "Level2Flow")
{
val.rarity = 300;
}
else
{
val.rarity = 0;
}
MansionModBase.mls.LogInfo((object)$"New Rarity = {val.rarity}");
list.Add(val);
}
return list.ToArray();
}
}
}