using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen.Graph;
using FacilityOrMansion.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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 FacilityOrMansion
{
[BepInPlugin("dsrdakota.FacilityOrMansion", "Facility or Mansion", "1.0.2")]
public class FacilityOrMansionBase : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("dsrdakota.FacilityOrMansion");
public static FacilityOrMansionBase Instance { get; private set; }
public static ConfigEntry<bool> modIsEnabled { get; set; }
public static ConfigEntry<bool> mansionOnly { get; set; }
public static ConfigEntry<bool> facilityOnly { get; set; }
public static ManualLogSource mls { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
modIsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Facility or Mansion", "Mod Enabled", true, "Enable or disable the mod.");
mansionOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Choose Only One", "Mansion Only", true, "Interiors set to Mansion.");
facilityOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Choose Only One", "Facility Only", false, "Interiors set to Facility.");
mls = Logger.CreateLogSource("DeathWrench.FacilityOrMansion");
mls.LogInfo((object)"Facility or Mansion Only mod has awakened!");
harmony.PatchAll(typeof(DungeonFlowTypePatch));
}
}
}
namespace FacilityOrMansion.Patches
{
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
FacilityOrMansionBase.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;
FacilityOrMansionBase.mls.LogInfo((object)("DungeonFlow Name = " + ((Object)manager.dungeonFlowTypes[i].dungeonFlow).name));
if (((Object)manager.dungeonFlowTypes[i].dungeonFlow).name == "Level2Flow")
{
if (FacilityOrMansionBase.mansionOnly.Value && FacilityOrMansionBase.facilityOnly.Value)
{
val.rarity = 150;
}
if (FacilityOrMansionBase.mansionOnly.Value && !FacilityOrMansionBase.facilityOnly.Value)
{
val.rarity = 300;
}
if (FacilityOrMansionBase.facilityOnly.Value && !FacilityOrMansionBase.mansionOnly.Value)
{
val.rarity = 0;
}
}
else
{
if (FacilityOrMansionBase.mansionOnly.Value && FacilityOrMansionBase.facilityOnly.Value)
{
val.rarity = 150;
}
if (FacilityOrMansionBase.mansionOnly.Value && !FacilityOrMansionBase.facilityOnly.Value)
{
val.rarity = 0;
}
if (FacilityOrMansionBase.facilityOnly.Value && !FacilityOrMansionBase.mansionOnly.Value)
{
val.rarity = 300;
}
}
FacilityOrMansionBase.mls.LogInfo((object)$"New Rarity = {val.rarity}");
list.Add(val);
}
return list.ToArray();
}
}
internal class DungeonFlowTypePatch
{
[HarmonyPatch(typeof(RoundManager), "Awake")]
[HarmonyPriority(250)]
[HarmonyPostfix]
private static void onStartPrefix(RoundManager __instance)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
if (FacilityOrMansionBase.modIsEnabled.Value)
{
List<IndoorMapType> list = new List<IndoorMapType>();
FacilityOrMansionBase.mls.LogInfo((object)"Inserting missing dungeon flows into the RoundManager");
List<IndoorMapType> list2 = __instance.dungeonFlowTypes.ToList();
Object[] array = Resources.FindObjectsOfTypeAll(typeof(IndoorMapType));
foreach (Object val in array)
{
Type type = ((object)val).GetType();
DungeonFlow val2 = (DungeonFlow)type.GetProperty("dungeonFlow").GetValue(type);
float mapTileSize = (float)type.GetProperty("MapTileSize").GetValue(type);
FacilityOrMansionBase.mls.LogInfo((object)("mapsize: " + mapTileSize));
IndoorMapType val3 = new IndoorMapType();
val3.dungeonFlow = val2;
val3.MapTileSize = mapTileSize;
FacilityOrMansionBase.mls.LogInfo((object)("map name: " + ((Object)val2).name));
list.Add(val3);
}
for (int j = 0; j < list.Count; j++)
{
IndoorMapType item = list[j];
list2.Add(item);
}
__instance.dungeonFlowTypes = list2.ToArray();
}
}
[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
[HarmonyPrefix]
private static void FlowTypeUpdate(RoundManager __instance)
{
if (FacilityOrMansionBase.modIsEnabled.Value)
{
SelectableLevel currentLevel = __instance.currentLevel;
FacilityOrMansionBase.mls.LogInfo((object)"Changing dungeon flow values");
currentLevel.dungeonFlowTypes = __instance.setDungeonFlowTypeRarity();
}
}
}
}