using System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using DunGen; using DunGen.Graph; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; 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: AssemblyCompany("SqrRoomRemoval")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SqrRoomRemoval")] [assembly: AssemblyTitle("SqrRoomRemoval")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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 SqrRoomRemoval { [BepInPlugin("MysticDEV.SqrRoomRemoval", "Sqr Room Removal", "1.0.0")] public class SqrRoomRemovalPlugin : BaseUnityPlugin { internal static ManualLogSource PluginLogger; internal const string TargetTileName = "NarrowHallwayTile2x2"; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown PluginLogger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Sqr Room Removal loaded, will remove square rooms from generating in mansion interiors before each generation."); Harmony val = new Harmony("MysticDEV.SqrRoomRemoval"); val.PatchAll(typeof(RoundManagerPatch)); val.PatchAll(typeof(NetworkPrefabPatch2)); } } [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] internal static class RoundManagerPatch { private static bool loaded; [HarmonyPrefix] private static void Prefix() { if (loaded) { SqrRoomRemovalPlugin.PluginLogger.LogInfo((object)"Skipping since already removed."); return; } int num = 0; DungeonFlow[] array = Resources.FindObjectsOfTypeAll(); foreach (DungeonFlow val in array) { TileSet[] usedTileSets = val.GetUsedTileSets(); foreach (TileSet val2 in usedTileSets) { int count = val2.TileWeights.Weights.Count; val2.TileWeights.Weights.RemoveAll((GameObjectChance w) => (Object)(object)w.Value != (Object)null && ((Object)w.Value).name == "NarrowHallwayTile2x2"); int num2 = count - val2.TileWeights.Weights.Count; if (num2 > 0) { SqrRoomRemovalPlugin.PluginLogger.LogInfo((object)("Removed 'NarrowHallwayTile2x2' from TileSet '" + ((Object)val2).name + "' " + string.Format("(in flow '{0}') - {1} entr{2}", ((Object)val).name, num2, (num2 == 1) ? "y" : "ies"))); num += num2; loaded = true; } } } SqrRoomRemovalPlugin.PluginLogger.LogInfo((object)$"Pre-generation tile strip: total entries removed this pass: {num}"); } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch2 { private static readonly string MOD_GUID = "MysticDEV.SqrRoomRemoval"; [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } }