using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DunGen;
using HarmonyLib;
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: AssemblyCompany("FrontEntranceManor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Forces mansions to use the ground front door main entrance.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FrontEntranceManor")]
[assembly: AssemblyTitle("FrontEntranceManor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace FrontEntranceManor
{
[BepInPlugin("terraformer9x.FrontEntranceManor", "Front Entrance Manor", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string pluginGUID = "terraformer9x.FrontEntranceManor";
private const string pluginName = "Front Entrance Manor";
private const string pluginVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("FrontEntranceManor");
public static Plugin Instance;
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Front Entrance Manor 1.0.0 is loaded!");
harmony.PatchAll(typeof(FrontDoorPatch));
}
public static void Log(string msg)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
}
public static void LogError(string msg)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
}
public static void LogDebug(string msg)
{
((BaseUnityPlugin)Instance).Logger.LogDebug((object)msg);
}
}
internal class FrontDoorPatch
{
[HarmonyPatch(typeof(Dungeon), "PostGenerateDungeon")]
[HarmonyPostfix]
private static void ForceFrontDoor(Dungeon __instance)
{
Plugin.LogDebug(((Object)__instance.DungeonFlow).name + " detected, forcing ground level entrance.");
Tile val = __instance.AllTiles?.First((Tile x) => ((Object)x).name == "ManorStartRoom(Clone)");
if (!((Object)(object)val != (Object)null))
{
return;
}
Transform obj = ((Component)val).transform.Find("MainEntrancePropSet");
LocalPropSet val2 = ((obj != null) ? ((Component)obj).GetComponent<LocalPropSet>() : null);
if (!((Object)(object)val2 != (Object)null))
{
return;
}
val2.Props.Weights.ForEach(delegate(GameObjectChance x)
{
if (((Object)x.Value).name != "MainEntranceSpawnPositionA")
{
x.MainPathWeight = 0f;
}
x.BranchPathWeight = 0f;
});
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "FrontEntranceManor";
public const string PLUGIN_NAME = "FrontEntranceManor";
public const string PLUGIN_VERSION = "1.0.0";
}
}