using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("mishelin.NoMineshaft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("NoMineshaft")]
[assembly: AssemblyTitle("mishelin.NoMineshaft")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[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 NoMineshaft
{
[BepInPlugin("mishelin.NoMineshaft", "NoMineshaft", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class NoMineshaft : BaseUnityPlugin
{
[HarmonyPatch(typeof(RoundManager))]
internal class InteriorPatch
{
private static readonly string myMinesaftMoonObjName = "Level3Flow";
private static readonly string myFactoryMoonObjName = "Level1Flow";
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void RemoveMineshaftInterior(RoundManager __instance)
{
if (__instance.dungeonFlowTypes.Length < 2)
{
return;
}
PluginLogInfoWithPrefix("Attempting to disable Mineshaft by setting Rarity to 0");
int num = FindMineshaftDungFlowId(__instance.dungeonFlowTypes);
if (num == -1 || LethalLevelLoaderFix())
{
return;
}
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
if (val.dungeonFlowTypes == null)
{
continue;
}
for (int j = 0; j < val.dungeonFlowTypes.Length; j++)
{
if (val.dungeonFlowTypes[j].id == num)
{
int rarity = val.dungeonFlowTypes[j].rarity;
val.dungeonFlowTypes[j].rarity = 0;
PluginLogInfoWithPrefix($"{val.PlanetName}: Rarity set to 0 (was {rarity})");
}
}
}
}
private static int FindMineshaftDungFlowId(IndoorMapType[] availableInteriors)
{
int num = 0;
int result = -1;
foreach (IndoorMapType val in availableInteriors)
{
if (((object)val.dungeonFlow).ToString().Contains(myMinesaftMoonObjName))
{
result = num;
break;
}
num++;
}
return result;
}
private static bool LethalLevelLoaderFix()
{
Type type = Type.GetType("LethalLevelLoader.ExtendedDungeonFlow, LethalLevelLoader");
if ((object)type == null)
{
return false;
}
PluginLogInfoWithPrefix("LethalLevelLoader detected. Patching Dungeons...");
Object[] array = Resources.FindObjectsOfTypeAll(type);
Object[] array2 = array;
foreach (Object val in array2)
{
object obj = type.GetProperty("DungeonFlow", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
Object val2 = (Object)((obj is Object) ? obj : null);
if (val2 == null || !val2.name.Contains(myMinesaftMoonObjName))
{
continue;
}
PluginLogInfoWithPrefix("Found Mineshaft Extended Object: " + val.name);
object obj2 = type.GetProperty("LevelMatchingProperties", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
if (obj2 != null)
{
if (obj2.GetType().GetField("planetNames", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj2) is IList list)
{
int count = list.Count;
list.Clear();
PluginLogInfoWithPrefix($"Wiped Mineshaft whitelist. Removed {count} moons.");
}
else
{
PluginLogInfoWithPrefix("Could not access planetNames list.");
}
}
}
return true;
}
}
public static NoMineshaft Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
Logger.LogInfo((object)"mishelin.NoMineshaft v1.1.0 has loaded!");
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("mishelin.NoMineshaft");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
private static void PluginLogInfoWithPrefix(string content)
{
Logger.LogInfo((object)("[EVIL] " + content));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "mishelin.NoMineshaft";
public const string PLUGIN_NAME = "NoMineshaft";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}