using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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("SetMyDungeon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SetMyDungeon")]
[assembly: AssemblyTitle("SetMyDungeon")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace SetMyDungeon
{
[BepInPlugin("SetMyDungeon", "SetMyDungeon", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static ConfigEntry<bool> SetDungeonEnabled;
public static Dictionary<int, ConfigEntry<int>> Id2Rarity = new Dictionary<int, ConfigEntry<int>>();
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin SetMyDungeon is loaded!");
Harmony val = new Harmony("SetMyDungeon");
SetConfig();
val.PatchAll();
}
private void SetConfig()
{
SetDungeonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SetDungeonEnabled", false, "Enable or disable the Set Dungeon feature.");
SetId2Rarity();
}
private void SetId2Rarity()
{
Id2Rarity.Add(0, ((BaseUnityPlugin)this).Config.Bind<int>("General", "Factory", 1, "Weight for Factory (id = 0), 0 ~ 4294967295"));
Id2Rarity.Add(1, ((BaseUnityPlugin)this).Config.Bind<int>("General", "Mansion", 1, "Weight for Mansion (id = 1), 0 ~ 4294967295"));
Id2Rarity.Add(4, ((BaseUnityPlugin)this).Config.Bind<int>("General", "Mineshaft", 1, "Weight for Mineshaft (id = 4), 0 ~ 4294967295"));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "SetMyDungeon";
public const string PLUGIN_NAME = "SetMyDungeon";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SetMyDungeon.Patches
{
[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
public class RM_GenerateNewFloor
{
private static void Prefix(RoundManager __instance)
{
int num = __instance.currentLevel.dungeonFlowTypes.Length;
Plugin.Logger.LogInfo((object)$"Generating the map. This map contains {num} dungeon flow types.");
if (num > 0)
{
for (int i = 0; i < num; i++)
{
IntWithRarity val = __instance.currentLevel.dungeonFlowTypes[i];
int id = val.id;
int rarity = val.rarity;
Plugin.Logger.LogInfo((object)$"(OriginGame)The [{i}]th dungeon(id = {id}) has a rarity of {rarity}");
if (Plugin.SetDungeonEnabled.Value)
{
if (Plugin.Id2Rarity.ContainsKey(id))
{
__instance.currentLevel.dungeonFlowTypes[i].rarity = Plugin.Id2Rarity[id].Value;
Plugin.Logger.LogInfo((object)$"(SetMyDungeon)The [{i}]th dungeon(id = {id}) has been set to a rarity of {Plugin.Id2Rarity[id].Value}");
}
else
{
Plugin.Logger.LogInfo((object)$"(SetMyDungeon)The [{i}]th dungeon(id = {id}) is not configured, using the original rarity of {rarity}");
}
}
else
{
Plugin.Logger.LogInfo((object)$"(SetMyDungeon)SetDungeonEnabled is false, using the original rarity of {rarity}");
}
}
}
else
{
Plugin.Logger.LogInfo((object)"This map has no dungeon flow types.");
}
}
}
}