using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib; using REPOLib.Modules; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.SceneManagement; [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("Empress")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("WoodlandMansionCompatPatch")] [assembly: AssemblyTitle("WoodlandMansionCompatPatch")] [assembly: AssemblyVersion("1.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 WoodlandMansionCompatPatch { [BepInPlugin("empress.repo.woodlandmansioncompatpatch", "Empress Woodland Mansion Compat Patch", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class WoodlandMansionCompatPatchPlugin : BaseUnityPlugin { private sealed class WoodlandPrefabBuckets { public List StartRooms { get; set; } = new List(); public List Normal1 { get; set; } = new List(); public List Passage1 { get; set; } = new List(); public List DeadEnd1 { get; set; } = new List(); public List Extraction1 { get; set; } = new List(); public List Normal2 { get; set; } = new List(); public List Passage2 { get; set; } = new List(); public List DeadEnd2 { get; set; } = new List(); public List Extraction2 { get; set; } = new List(); public List Normal3 { get; set; } = new List(); public List Passage3 { get; set; } = new List(); public List DeadEnd3 { get; set; } = new List(); public List Extraction3 { get; set; } = new List(); public int TotalModuleCount => Normal1.Count + Passage1.Count + DeadEnd1.Count + Extraction1.Count + Normal2.Count + Passage2.Count + DeadEnd2.Count + Extraction2.Count + Normal3.Count + Passage3.Count + DeadEnd3.Count + Extraction3.Count; } internal const string PluginGuid = "empress.repo.woodlandmansioncompatpatch"; internal const string PluginName = "Empress Woodland Mansion Compat Patch"; internal const string PluginVersion = "1.0.0"; private const string WoodlandBundleFileName = "Woodland_Mansion.repobundle"; private const string WoodlandLevelName = "Level - Woodland Mansion"; private const string WoodlandLevelResourcePath = "Woodland Mansion"; private const float WoodlandLevelPointCheckRadius = 0.5f; private const float WoodlandLevelPointRepairRadius = 2f; private const float WoodlandLevelPointConnectDistance = 15f; private const float WoodlandLevelPointConnectForwardDot = -0.8f; private const float WoodlandLevelPointConnectApproachDot = 0.8f; private const float WoodlandLevelPointValidationDelay = 0.5f; private static readonly string[] WoodlandStartRoomNames = new string[1] { "Module - Woodland Mansion - SR - 1 - Entrance" }; private static readonly string[] WoodlandNormal1Names = new string[10] { "Module - Woodland Mansion - N - 1 - Allium Room", "Module - Woodland Mansion - N - 1 - Birch Arch Room", "Module - Woodland Mansion - N - 1 - Birch Pillar Room", "Module - Woodland Mansion - N - 1 - Checkerboard Room", "Module - Woodland Mansion - N - 1 - Office", "Module - Woodland Mansion - N - 1 - Sapling Farm Room", "Module - Woodland Mansion - N - 1 - Small Dining Room", "Module - Woodland Mansion - N - 1 - Small Library Room", "Module - Woodland Mansion - N - 1 - Spider Room", "Module - Woodland Mansion - N - 1 - X-Room" }; private static readonly string[] WoodlandPassage1Names = new string[1] { "Module - Woodland Mansion - DE - 1 - Small Storage Room" }; private static readonly string[] WoodlandDeadEnd1Names = new string[7] { "Module - Woodland Mansion - DE - 1 - Flower Room", "Module - Woodland Mansion - DE - 1 - Forge Room", "Module - Woodland Mansion - DE - 1 - Gray Banner Room", "Module - Woodland Mansion - DE - 1 - Pumpkin King Room", "Module - Woodland Mansion - DE - 1 - Single Bed Bedroom", "Module - Woodland Mansion - DE - 1 - Wheat Farm", "Module - Woodland Mansion - DE - 1 - White Tulip Room" }; private static readonly string[] WoodlandExtraction1Names = new string[1] { "Module - Woodland Mansion - E - 1 - Arena Room" }; private readonly Harmony _woodlandHarmony = new Harmony("empress.repo.woodlandmansioncompatpatch"); private AssetBundle? _woodlandBundle; private bool _woodlandRepairApplied; private bool _woodlandRepairQueued; private bool _woodlandLoggedMissingBundle; private bool _woodlandLoggedMissingPrefabs; private bool _woodlandLoggedDoorMapFallback; private bool _woodlandLoggedRepairAttempt; internal static WoodlandMansionCompatPatchPlugin? Instance { get; private set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BundleLoader.OnAllBundlesLoaded += WoodlandHandleBundlesLoaded; SceneManager.activeSceneChanged += WoodlandOnActiveSceneChanged; _woodlandHarmony.PatchAll(); WoodlandPatchUnityWarningFilter(); if ((Object)(object)RunManager.instance != (Object)null) { ((MonoBehaviour)this).StartCoroutine(WoodlandRepairWhenReady()); } } private void WoodlandOnActiveSceneChanged(Scene current, Scene next) { _woodlandRepairApplied = false; _woodlandRepairQueued = false; _woodlandLoggedRepairAttempt = false; if ((Object)(object)RunManager.instance != (Object)null) { ((MonoBehaviour)this).StartCoroutine(WoodlandRepairWhenReady()); } } private void WoodlandHandleBundlesLoaded() { if (!_woodlandRepairQueued && !_woodlandRepairApplied) { _woodlandRepairQueued = true; ((MonoBehaviour)this).StartCoroutine(WoodlandRepairWhenReady()); } } private void WoodlandPatchUnityWarningFilter() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown Type type = AccessTools.TypeByName("UnityEngine.DebugLogHandler"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "LogFormat", new Type[4] { typeof(LogType), typeof(Object), typeof(string), typeof(object[]) }, (Type[])null); if (methodInfo != null) { _woodlandHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(WoodlandMansionCompatPatchPlugin), "WoodlandSuppressMissingScriptWarningPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.Method(type, "LogFormat", new Type[5] { typeof(LogType), typeof(LogOption), typeof(Object), typeof(string), typeof(object[]) }, (Type[])null); if (methodInfo2 != null) { _woodlandHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(WoodlandMansionCompatPatchPlugin), "WoodlandSuppressMissingScriptWarningPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private IEnumerator WoodlandRepairWhenReady() { yield return null; for (int attempt = 0; attempt < 120; attempt++) { if (_woodlandRepairApplied) { break; } if (WoodlandTryRepairLevel()) { break; } yield return null; } _woodlandRepairQueued = false; } internal bool WoodlandTryRepairCurrentLevel() { List list = new List(); if ((Object)(object)LevelGenerator.Instance != (Object)null && (Object)(object)LevelGenerator.Instance.Level != (Object)null) { list.Add(LevelGenerator.Instance.Level); } if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null) { list.Add(RunManager.instance.levelCurrent); } return WoodlandTryRepairLevel(list); } private bool WoodlandTryRepairLevel(IEnumerable? candidates = null) { if (_woodlandRepairApplied) { return true; } Level val = WoodlandFindLevel(candidates) ?? WoodlandFindLevel(Levels.AllLevels); if ((Object)(object)val == (Object)null) { return false; } if (!_woodlandLoggedRepairAttempt) { _woodlandLoggedRepairAttempt = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Woodland Mansion Compat Patch is rebuilding Level - Woodland Mansion from the original bundle."); } AssetBundle val2 = WoodlandGetBundle(); if ((Object)(object)val2 == (Object)null) { if (!_woodlandLoggedMissingBundle) { _woodlandLoggedMissingBundle = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Woodland Mansion Compat Patch could not locate the Woodland Mansion bundle."); } return false; } _woodlandLoggedMissingBundle = false; WoodlandPrefabBuckets woodlandPrefabBuckets = WoodlandCollectPrefabs(val2); if (woodlandPrefabBuckets.StartRooms.Count == 0 || woodlandPrefabBuckets.TotalModuleCount == 0) { if (!_woodlandLoggedMissingPrefabs) { _woodlandLoggedMissingPrefabs = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Empress Woodland Mansion Compat Patch could not rebuild the Woodland Mansion prefab lists from the original bundle."); } return false; } _woodlandLoggedMissingPrefabs = false; WoodlandApplyHideFlags((Object)(object)val2); WoodlandApplyHideFlags((Object)(object)val); WoodlandEnsureLevelFallbackData(val); WoodlandRegisterLevelObjects(val); val.StartRooms = WoodlandRegisterPrefabs(val, "StartRoom", woodlandPrefabBuckets.StartRooms); val.ModulesNormal1 = WoodlandRegisterPrefabs(val, "Normal", woodlandPrefabBuckets.Normal1); val.ModulesPassage1 = WoodlandRegisterPrefabs(val, "Passage", woodlandPrefabBuckets.Passage1); val.ModulesDeadEnd1 = WoodlandRegisterPrefabs(val, "DeadEnd", woodlandPrefabBuckets.DeadEnd1); val.ModulesExtraction1 = WoodlandRegisterPrefabs(val, "Extraction", woodlandPrefabBuckets.Extraction1); val.ModulesNormal2 = WoodlandRegisterPrefabs(val, "Normal", woodlandPrefabBuckets.Normal2); val.ModulesPassage2 = WoodlandRegisterPrefabs(val, "Passage", woodlandPrefabBuckets.Passage2); val.ModulesDeadEnd2 = WoodlandRegisterPrefabs(val, "DeadEnd", woodlandPrefabBuckets.DeadEnd2); val.ModulesExtraction2 = WoodlandRegisterPrefabs(val, "Extraction", woodlandPrefabBuckets.Extraction2); val.ModulesNormal3 = WoodlandRegisterPrefabs(val, "Normal", woodlandPrefabBuckets.Normal3); val.ModulesPassage3 = WoodlandRegisterPrefabs(val, "Passage", woodlandPrefabBuckets.Passage3); val.ModulesDeadEnd3 = WoodlandRegisterPrefabs(val, "DeadEnd", woodlandPrefabBuckets.DeadEnd3); val.ModulesExtraction3 = WoodlandRegisterPrefabs(val, "Extraction", woodlandPrefabBuckets.Extraction3); _woodlandRepairApplied = WoodlandCountValidPrefabRefs(val.StartRooms) > 0 && WoodlandCountValidModules(val) > 0; if (_woodlandRepairApplied) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Woodland Mansion Compat Patch repaired {((Object)val).name} with {WoodlandCountValidPrefabRefs(val.StartRooms)} start rooms and {WoodlandCountValidModules(val)} modules."); } return _woodlandRepairApplied; } private static Level? WoodlandFindLevel(IEnumerable? candidates) { if (candidates == null) { return null; } foreach (Level candidate in candidates) { if (WoodlandIsWoodlandLevel(candidate)) { return candidate; } } return null; } private AssetBundle? WoodlandGetBundle() { if ((Object)(object)_woodlandBundle != (Object)null) { return _woodlandBundle; } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (WoodlandBundleMatches(allLoadedAssetBundle)) { _woodlandBundle = allLoadedAssetBundle; return _woodlandBundle; } } string text = Directory.GetFiles(Paths.PluginPath, "Woodland_Mansion.repobundle", SearchOption.AllDirectories).FirstOrDefault(); if (string.IsNullOrWhiteSpace(text)) { return null; } _woodlandBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_woodlandBundle != (Object)null) { return _woodlandBundle; } foreach (AssetBundle allLoadedAssetBundle2 in AssetBundle.GetAllLoadedAssetBundles()) { if (WoodlandBundleMatches(allLoadedAssetBundle2)) { _woodlandBundle = allLoadedAssetBundle2; return _woodlandBundle; } } return _woodlandBundle; } private static bool WoodlandBundleMatches(AssetBundle? bundle) { if ((Object)(object)bundle == (Object)null) { return false; } try { if (!string.IsNullOrWhiteSpace(((Object)bundle).name) && (((Object)bundle).name.IndexOf("woodland", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)bundle).name.IndexOf("mansion", StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } } catch { } try { if (bundle.GetAllAssetNames().Any((string assetName) => assetName.IndexOf("woodland mansion", StringComparison.OrdinalIgnoreCase) >= 0 || assetName.IndexOf("repolib level.asset", StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } } catch { } try { Level[] array = bundle.LoadAllAssets(); foreach (Level level in array) { if (WoodlandIsWoodlandLevel(level)) { return true; } } } catch { } try { GameObject[] array2 = bundle.LoadAllAssets(); foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && ((Object)val).name.StartsWith("Module - Woodland Mansion -", StringComparison.OrdinalIgnoreCase)) { return true; } } } catch { } return false; } private static WoodlandPrefabBuckets WoodlandCollectPrefabs(AssetBundle bundle) { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); StartRoom[] array = bundle.LoadAllAssets(); foreach (StartRoom val in array) { WoodlandAddAssetByName(dictionary, ((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null); } Module[] array2 = bundle.LoadAllAssets(); foreach (Module val2 in array2) { WoodlandAddAssetByName(dictionary, ((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); } GameObject[] array3 = bundle.LoadAllAssets(); foreach (GameObject prefab in array3) { WoodlandAddAssetByName(dictionary, prefab); } if (!dictionary.Keys.Any((string name) => name.StartsWith("Module - Woodland Mansion -", StringComparison.OrdinalIgnoreCase))) { StartRoom[] array4 = Resources.FindObjectsOfTypeAll(); Scene scene; foreach (StartRoom val3 in array4) { if (!((Object)(object)val3 == (Object)null)) { scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { WoodlandAddAssetByName(dictionary, ((Component)val3).gameObject); } } } Module[] array5 = Resources.FindObjectsOfTypeAll(); foreach (Module val4 in array5) { if (!((Object)(object)val4 == (Object)null)) { scene = ((Component)val4).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { WoodlandAddAssetByName(dictionary, ((Component)val4).gameObject); } } } GameObject[] array6 = Resources.FindObjectsOfTypeAll(); foreach (GameObject val5 in array6) { if (!((Object)(object)val5 == (Object)null)) { scene = val5.scene; if (!((Scene)(ref scene)).IsValid()) { WoodlandAddAssetByName(dictionary, val5); } } } } return new WoodlandPrefabBuckets { StartRooms = WoodlandResolvePrefabs(dictionary, WoodlandStartRoomNames), Normal1 = WoodlandResolvePrefabs(dictionary, WoodlandNormal1Names), Passage1 = WoodlandResolvePrefabs(dictionary, WoodlandPassage1Names), DeadEnd1 = WoodlandResolvePrefabs(dictionary, WoodlandDeadEnd1Names), Extraction1 = WoodlandResolvePrefabs(dictionary, WoodlandExtraction1Names), Normal2 = new List(), Passage2 = new List(), DeadEnd2 = new List(), Extraction2 = new List(), Normal3 = new List(), Passage3 = new List(), DeadEnd3 = new List(), Extraction3 = new List() }; } private static void WoodlandAddAssetByName(IDictionary prefabsByName, GameObject? prefab) { if (!((Object)(object)prefab == (Object)null) && !string.IsNullOrWhiteSpace(((Object)prefab).name) && !prefabsByName.ContainsKey(((Object)prefab).name)) { prefabsByName[((Object)prefab).name] = prefab; } } private static List WoodlandResolvePrefabs(IReadOnlyDictionary prefabsByName, IEnumerable names) { List list = new List(); foreach (string name in names) { if (prefabsByName.TryGetValue(name, out GameObject value)) { list.Add(value); } } return list; } private static void WoodlandRegisterLevelObjects(Level level) { if (level.ConnectObject != null) { GameObject val = WoodlandResolvePrefab(level.ConnectObject); if ((Object)(object)val != (Object)null) { WoodlandRegisterNetworkPrefab("Level/" + WoodlandGetLevelPath(level) + "/Other/" + WoodlandGetPrefabName(level.ConnectObject, val), val); } } if (level.BlockObject != null) { GameObject val2 = WoodlandResolvePrefab(level.BlockObject); if ((Object)(object)val2 != (Object)null) { WoodlandRegisterNetworkPrefab("Level/" + WoodlandGetLevelPath(level) + "/Other/" + WoodlandGetPrefabName(level.BlockObject, val2), val2); } } } private static string WoodlandGetLevelPath(Level level) { return string.IsNullOrWhiteSpace(((Object)level).name) ? "Woodland Mansion" : ((Object)level).name; } private static string WoodlandGetPrefabName(PrefabRef prefabRef, GameObject prefab) { return string.IsNullOrWhiteSpace(prefabRef.PrefabName) ? ((Object)prefab).name : prefabRef.PrefabName; } private static GameObject? WoodlandResolvePrefab(PrefabRef? prefabRef) { if (prefabRef == null) { return null; } if (prefabRef.IsValid()) { return prefabRef.Prefab; } AssetBundle bundle = prefabRef.Bundle; if ((Object)(object)bundle == (Object)null || string.IsNullOrWhiteSpace(prefabRef.PrefabName)) { return null; } GameObject[] array = bundle.LoadAllAssets(); foreach (GameObject val in array) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, prefabRef.PrefabName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static List WoodlandRegisterPrefabs(Level level, string moduleTypeName, IEnumerable prefabs) { List list = new List(); foreach (GameObject prefab in prefabs) { string prefabId = "Level/" + ((Object)level).name + "/" + moduleTypeName + "/" + ((Object)prefab).name; PrefabRef val = WoodlandRegisterNetworkPrefab(prefabId, prefab); if (val != null) { list.Add(val); } } return list; } private static PrefabRef? WoodlandRegisterNetworkPrefab(string prefabId, GameObject prefab) { PrefabRef val = WoodlandGetRegisteredPrefabRef(prefabId, prefab); if (val != null) { return val; } WoodlandPreparePrefab(prefab); Utilities.FixAudioMixerGroups(prefab); return NetworkPrefabs.RegisterNetworkPrefab(prefabId, prefab); } private static PrefabRef? WoodlandGetRegisteredPrefabRef(string prefabId, GameObject prefab) { if (!NetworkPrefabs.PrefabRefs.TryGetValue(prefabId, out var value) || value == null) { return null; } if ((Object)(object)value.Prefab == (Object)null || (Object)(object)value.Prefab == (Object)(object)prefab) { return value; } return null; } private static void WoodlandPreparePrefab(GameObject prefab) { WoodlandApplyHideFlags((Object)(object)prefab); WoodlandAssignFallbackAudioMixerGroups(prefab); WoodlandAssignFallbackPhysAttributes(prefab); WoodlandAssignFallbackHingeData(prefab); } private static void WoodlandAssignFallbackAudioMixerGroups(GameObject prefab) { AudioMixerGroup val = WoodlandGetFallbackAudioMixerGroup(); if ((Object)(object)prefab == (Object)null || (Object)(object)val == (Object)null) { return; } AudioSource[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (AudioSource val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.outputAudioMixerGroup != (Object)null)) { val2.outputAudioMixerGroup = val; } } } private static void WoodlandAssignFallbackPhysAttributes(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } NotValuableObject[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (NotValuableObject val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.physAttributePreset != (Object)null)) { Rigidbody component = ((Component)val).GetComponent(); float mass = (((Object)(object)component != (Object)null && component.mass > 0f) ? component.mass : 1f); val.physAttributePreset = WoodlandCreateFallbackPhysAttribute(mass); } } } private static void WoodlandAssignFallbackHingeData(GameObject prefab) { if (!((Object)(object)prefab == (Object)null)) { PhysGrabHinge[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (PhysGrabHinge hinge in componentsInChildren) { WoodlandEnsurePhysGrabHingeCompatibility(hinge); } } } internal static void WoodlandEnsurePhysGrabHingeCompatibility(PhysGrabHinge? hinge) { //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Expected O, but got Unknown PhysGrabHinge hinge2 = hinge; if ((Object)(object)hinge2 == (Object)null) { return; } PhysGrabHinge val = hinge2; if (val.moveLoop == null) { val.moveLoop = WoodlandCreateFallbackSound(); } if ((Object)(object)hinge2.hingeAudio == (Object)null) { hinge2.hingeAudio = WoodlandCreateFallbackHingeAudio(); } else { WoodlandNormalizeSound(hinge2.hingeAudio.moveLoop); WoodlandNormalizeSound(hinge2.hingeAudio.moveLoopEnd); WoodlandNormalizeSound(hinge2.hingeAudio.Close); WoodlandNormalizeSound(hinge2.hingeAudio.CloseHeavy); WoodlandNormalizeSound(hinge2.hingeAudio.Open); WoodlandNormalizeSound(hinge2.hingeAudio.OpenHeavy); WoodlandNormalizeSound(hinge2.hingeAudio.HingeBreak); } val = hinge2; if (val.audioSource == null) { val.audioSource = ((Component)hinge2).GetComponent() ?? ((Component)hinge2).gameObject.AddComponent(); } hinge2.audioSource.playOnAwake = false; if ((Object)(object)hinge2.audioSource.outputAudioMixerGroup == (Object)null) { hinge2.audioSource.outputAudioMixerGroup = WoodlandGetFallbackAudioMixerGroup(); } if ((Object)(object)((Component)hinge2).GetComponent() == (Object)null) { ((Component)hinge2).gameObject.AddComponent(); } if ((Object)(object)((Component)hinge2).GetComponent() == (Object)null) { ((Component)hinge2).gameObject.AddComponent(); } if ((Object)(object)hinge2.hingePoint == (Object)null) { Rigidbody val2 = ((IEnumerable)((Component)hinge2).GetComponentsInChildren(true)).FirstOrDefault((Func)((Rigidbody rigidbody) => (Object)(object)rigidbody != (Object)null && (Object)(object)((Component)rigidbody).transform != (Object)(object)((Component)hinge2).transform)); if ((Object)(object)val2 != (Object)null) { hinge2.hingePoint = ((Component)val2).transform; } else if (((Component)hinge2).transform.childCount > 0) { hinge2.hingePoint = ((Component)hinge2).transform.GetChild(0); } else { GameObject val3 = new GameObject("Woodland Mansion Patch Hinge Point"); val3.transform.SetParent(((Component)hinge2).transform, false); WoodlandApplyHideFlags((Object)(object)val3); hinge2.hingePoint = val3.transform; } } val = hinge2; if (val.wallTagHinges == null) { val.wallTagHinges = Array.Empty(); } val = hinge2; if (val.wallTagObjects == null) { val.wallTagObjects = Array.Empty(); } val = hinge2; if (val.lowPassTriggers == null) { val.lowPassTriggers = Array.Empty(); } } private static HingeAudio WoodlandCreateFallbackHingeAudio() { HingeAudio val = ScriptableObject.CreateInstance(); val.moveLoopEnabled = false; val.moveLoop = WoodlandCreateFallbackSound(); val.moveLoopEnd = WoodlandCreateFallbackSound(); val.Close = WoodlandCreateFallbackSound(); val.CloseHeavy = WoodlandCreateFallbackSound(); val.Open = WoodlandCreateFallbackSound(); val.OpenHeavy = WoodlandCreateFallbackSound(); val.HingeBreak = WoodlandCreateFallbackSound(); WoodlandApplyHideFlags((Object)(object)val); return val; } private static Sound WoodlandCreateFallbackSound() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Sound val = new Sound(); WoodlandNormalizeSound(val); return val; } private static void WoodlandNormalizeSound(Sound? sound) { if (sound != null) { Sound val = sound; if (val.Sounds == null) { val.Sounds = Array.Empty(); } val = sound; if (val.LowPassIgnoreColliders == null) { val.LowPassIgnoreColliders = new List(); } } } private static PhysAttribute WoodlandCreateFallbackPhysAttribute(float mass) { PhysAttribute val = ScriptableObject.CreateInstance(); val.mass = Mathf.Max(0.01f, mass); WoodlandApplyHideFlags((Object)(object)val); return val; } private static AudioMixerGroup? WoodlandGetFallbackAudioMixerGroup() { if ((Object)(object)AudioManager.instance == (Object)null) { return null; } return AudioManager.instance.SoundMasterGroup ?? AudioManager.instance.PersistentSoundGroup ?? AudioManager.instance.MusicMasterGroup ?? AudioManager.instance.MicrophoneSoundGroup ?? AudioManager.instance.MicrophoneSpectateGroup ?? AudioManager.instance.TTSSoundGroup ?? AudioManager.instance.TTSSpectateGroup; } private static int WoodlandCountModules(Level level) { return (level.ModulesNormal1?.Count ?? 0) + (level.ModulesPassage1?.Count ?? 0) + (level.ModulesDeadEnd1?.Count ?? 0) + (level.ModulesExtraction1?.Count ?? 0) + (level.ModulesNormal2?.Count ?? 0) + (level.ModulesPassage2?.Count ?? 0) + (level.ModulesDeadEnd2?.Count ?? 0) + (level.ModulesExtraction2?.Count ?? 0) + (level.ModulesNormal3?.Count ?? 0) + (level.ModulesPassage3?.Count ?? 0) + (level.ModulesDeadEnd3?.Count ?? 0) + (level.ModulesExtraction3?.Count ?? 0); } private static int WoodlandCountValidModules(Level level) { return WoodlandCountValidPrefabRefs(level.ModulesNormal1) + WoodlandCountValidPrefabRefs(level.ModulesPassage1) + WoodlandCountValidPrefabRefs(level.ModulesDeadEnd1) + WoodlandCountValidPrefabRefs(level.ModulesExtraction1) + WoodlandCountValidPrefabRefs(level.ModulesNormal2) + WoodlandCountValidPrefabRefs(level.ModulesPassage2) + WoodlandCountValidPrefabRefs(level.ModulesDeadEnd2) + WoodlandCountValidPrefabRefs(level.ModulesExtraction2) + WoodlandCountValidPrefabRefs(level.ModulesNormal3) + WoodlandCountValidPrefabRefs(level.ModulesPassage3) + WoodlandCountValidPrefabRefs(level.ModulesDeadEnd3) + WoodlandCountValidPrefabRefs(level.ModulesExtraction3); } private static int WoodlandCountValidPrefabRefs(IEnumerable? prefabRefs) { if (prefabRefs == null) { return 0; } int num = 0; foreach (PrefabRef prefabRef in prefabRefs) { if (prefabRef != null && prefabRef.IsValid()) { num++; } } return num; } internal static bool WoodlandIsCurrentLevel() { return WoodlandIsWoodlandLevel(((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null) || WoodlandIsWoodlandLevel(((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelCurrent : null); } internal static bool WoodlandShouldSuppressMissingScriptWarning(LogType logType, string? format, object[]? args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)logType != 2 || !WoodlandIsCurrentLevel()) { return false; } if (WoodlandIsMissingScriptWarning(format)) { return true; } if (args == null || args.Length == 0 || string.IsNullOrWhiteSpace(format)) { return false; } try { return WoodlandIsMissingScriptWarning(string.Format(format, args)); } catch { return false; } } internal static bool WoodlandShouldSuppressMissingScriptWarning(LogEventArgs? eventArgs) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if (eventArgs == null || (int)eventArgs.Level != 4 || !WoodlandIsCurrentLevel()) { return false; } if (!WoodlandIsUnityLogSource(eventArgs.Source)) { return false; } if (eventArgs.Data is string message) { return WoodlandIsMissingScriptWarning(message); } return WoodlandIsMissingScriptWarning(eventArgs.Data?.ToString()); } private static bool WoodlandIsUnityLogSource(ILogSource? source) { return source != null && string.Equals(source.SourceName, "Unity Log", StringComparison.OrdinalIgnoreCase); } private static bool WoodlandIsMissingScriptWarning(string? message) { if (string.IsNullOrWhiteSpace(message)) { return false; } return message.IndexOf("The referenced script", StringComparison.Ordinal) >= 0 && message.IndexOf("missing", StringComparison.OrdinalIgnoreCase) >= 0; } private static bool WoodlandSuppressMissingScriptWarningPrefix(LogType logType, string format, object[] args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !WoodlandShouldSuppressMissingScriptWarning(logType, format, args); } internal static bool WoodlandIsWoodlandLevel(Level? level) { if ((Object)(object)level == (Object)null) { return false; } return string.Equals(((Object)level).name, "Level - Woodland Mansion", StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)level).name, "Woodland Mansion", StringComparison.OrdinalIgnoreCase) || (!string.IsNullOrWhiteSpace(((Object)level).name) && ((Object)level).name.IndexOf("woodland", StringComparison.OrdinalIgnoreCase) >= 0 && ((Object)level).name.IndexOf("mansion", StringComparison.OrdinalIgnoreCase) >= 0) || (!string.IsNullOrWhiteSpace(level.NarrativeName) && level.NarrativeName.IndexOf("woodland", StringComparison.OrdinalIgnoreCase) >= 0 && level.NarrativeName.IndexOf("mansion", StringComparison.OrdinalIgnoreCase) >= 0); } internal static void WoodlandEnsureLevelFallbackData(Level? level) { if (WoodlandIsWoodlandLevel(level)) { level.NarrativeName = (string.IsNullOrWhiteSpace(level.NarrativeName) ? "Woodland Mansion" : level.NarrativeName); level.ModuleAmount = Mathf.Max(level.ModuleAmount, 8); level.PassageMaxAmount = Mathf.Max(level.PassageMaxAmount, 2); Level val = level; if (val.ValuablePresets == null) { val.ValuablePresets = new List(); } val = level; if (val.AmbiencePresets == null) { val.AmbiencePresets = new List(); } if (level.ValuablePresets.Count == 0 && (Object)(object)ValuablePresets.GenericValuablePreset != (Object)null) { level.ValuablePresets.Add(ValuablePresets.GenericValuablePreset); } if (level.AmbiencePresets.Count == 0 && WoodlandTryGetFallbackAmbience(out LevelAmbience ambience)) { level.AmbiencePresets.Add(ambience); } } } private static bool WoodlandTryGetFallbackAmbience(out LevelAmbience ambience) { ambience = null; if ((Object)(object)AudioManager.instance != (Object)null && AudioManager.instance.levelAmbiences != null) { foreach (LevelAmbience levelAmbience in AudioManager.instance.levelAmbiences) { if ((Object)(object)levelAmbience == (Object)null) { continue; } ambience = levelAmbience; return true; } } if ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levels != null) { foreach (Level level in RunManager.instance.levels) { if (level?.AmbiencePresets == null) { continue; } foreach (LevelAmbience ambiencePreset in level.AmbiencePresets) { if ((Object)(object)ambiencePreset == (Object)null) { continue; } ambience = ambiencePreset; return true; } } } return false; } internal static void WoodlandEnsureExtractionPointCompatibility(ExtractionPoint extractionPoint) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown if ((Object)(object)extractionPoint == (Object)null || !WoodlandIsCurrentLevel()) { return; } if ((Object)(object)extractionPoint.extractionArea == (Object)null) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val).name = "Woodland Mansion Patch Extraction Area"; val.transform.SetParent(((Component)extractionPoint).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * 0.1f; MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } Collider component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { } val.SetActive(false); WoodlandApplyHideFlags((Object)(object)val); extractionPoint.extractionArea = val; } if ((Object)(object)extractionPoint.grossUp == (Object)null) { GameObject val2 = new GameObject("Woodland Mansion Patch GrossUp"); val2.transform.SetParent(((Component)extractionPoint).transform, false); val2.SetActive(false); WoodlandApplyHideFlags((Object)(object)val2); extractionPoint.grossUp = val2; } } internal void WoodlandRepairLevelPoints(LevelGenerator levelGenerator) { if ((Object)(object)levelGenerator == (Object)null || !WoodlandIsWoodlandLevel(levelGenerator.Level) || levelGenerator.LevelPathPoints == null) { return; } int num = 0; int num2 = 0; foreach (LevelPoint levelPathPoint in levelGenerator.LevelPathPoints) { if (WoodlandRepairLevelPoint(levelPathPoint)) { num++; } if (WoodlandRepairLevelPointRoom(levelPathPoint)) { num2++; } } if (num > 0 || num2 > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Woodland Mansion Compat Patch repaired {num} Woodland Mansion level points onto the navmesh and restored {num2} room links."); } } private static bool WoodlandRepairLevelPoint(LevelPoint? levelPoint) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)levelPoint == (Object)null) { return false; } Vector3 position = ((Component)levelPoint).transform.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 0.5f, -1)) { return false; } NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val2, 2f, -1)) { return false; } ((Component)levelPoint).transform.position = ((NavMeshHit)(ref val2)).position; WoodlandRepairLevelPointRoom(levelPoint); return true; } private static bool WoodlandRepairLevelPointRoom(LevelPoint? levelPoint) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)levelPoint == (Object)null || (Object)(object)levelPoint.Room != (Object)null) { return false; } RoomVolume room = default(RoomVolume); Vector3 val = default(Vector3); if (!SemiFunc.GetRoomVolumeAtPosition(((Component)levelPoint).transform.position, ref room, ref val)) { return false; } levelPoint.Room = room; return true; } internal IEnumerator WoodlandSilentLevelPointCheck(LevelPoint levelPoint) { if (!((Object)(object)levelPoint == (Object)null)) { while ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { yield return (object)new WaitForSeconds(0.1f); } yield return (object)new WaitForSeconds(0.5f); if (WoodlandIsCurrentLevel()) { WoodlandRepairLevelPoint(levelPoint); WoodlandRepairLevelPointRoom(levelPoint); WoodlandRepairLevelPointConnections(levelPoint, LevelGenerator.Instance?.LevelPathPoints); } } } private static void WoodlandRepairLevelPointConnections(LevelPoint? levelPoint, IList? allLevelPoints) { if ((Object)(object)levelPoint == (Object)null) { return; } if (levelPoint.ConnectedPoints == null) { levelPoint.ConnectedPoints = new List(); } levelPoint.ConnectedPoints.RemoveAll((LevelPoint connectedPoint) => (Object)(object)connectedPoint == (Object)null); LevelPoint[] array = levelPoint.ConnectedPoints.ToArray(); foreach (LevelPoint source in array) { WoodlandAddLevelPointConnection(source, levelPoint); } if (!levelPoint.ModuleConnect || allLevelPoints == null || levelPoint.ConnectedPoints.Count > 0) { return; } LevelPoint val = null; float currentBestDistance = float.MaxValue; foreach (LevelPoint allLevelPoint in allLevelPoints) { if (WoodlandCanConnectLevelPoints(levelPoint, allLevelPoint, currentBestDistance, out var distance)) { val = allLevelPoint; currentBestDistance = distance; } } WoodlandAddLevelPointConnection(levelPoint, val); WoodlandAddLevelPointConnection(val, levelPoint); } private static bool WoodlandCanConnectLevelPoints(LevelPoint source, LevelPoint? candidate, float currentBestDistance, out float distance) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) distance = 0f; if ((Object)(object)source == (Object)null || (Object)(object)candidate == (Object)null || (Object)(object)source == (Object)(object)candidate || !candidate.ModuleConnect) { return false; } Vector3 val = ((Component)source).transform.position - ((Component)candidate).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= Mathf.Epsilon) { return false; } distance = ((Vector3)(ref val)).magnitude; if (distance >= 15f || distance >= currentBestDistance) { return false; } if (Vector3.Dot(((Component)candidate).transform.forward, ((Component)source).transform.forward) > -0.8f) { return false; } return Vector3.Dot(((Component)candidate).transform.forward, ((Vector3)(ref val)).normalized) > 0.8f; } private static void WoodlandAddLevelPointConnection(LevelPoint? source, LevelPoint? target) { if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null)) { if (source.ConnectedPoints == null) { source.ConnectedPoints = new List(); } if (!source.ConnectedPoints.Contains(target)) { source.ConnectedPoints.Add(target); } } } internal GameObject WoodlandCreateFallbackDoorMapObject(Map map, DirtFinderMapDoor door) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) MapLayer layerParent = map.GetLayerParent(((Component)door).transform.position.y); GameObject val = WoodlandInstantiateFallbackDoorMapObject(map, ((Component)layerParent).transform); ((Object)val).name = ((Object)((Component)door).gameObject).name; door.Target = val.transform; DirtFinderMapDoorTarget val2 = val.GetComponent() ?? val.AddComponent(); val2.Target = ((Component)door).transform; val2.Layer = layerParent; DirtFinderMapDoorTarget val3 = val2; if (val3.HingeTransform == null) { val3.HingeTransform = val.transform; } map.DoorUpdate(val2.HingeTransform, ((Component)door).transform, layerParent); if (!_woodlandLoggedDoorMapFallback) { _woodlandLoggedDoorMapFallback = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Woodland Mansion Compat Patch injected fallback minimap door markers for missing Woodland Mansion door prefabs."); } return val; } private static GameObject WoodlandInstantiateFallbackDoorMapObject(Map map, Transform parent) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) GameObject val; if ((Object)(object)map.Door1x1Object != (Object)null) { val = Object.Instantiate(map.Door1x1Object, parent); Collider[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren) { } } else { val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.SetParent(parent, false); val.transform.localScale = new Vector3(0.12f, 0.12f, 0.3f); Collider component = val.GetComponent(); if (!((Object)(object)component != (Object)null)) { } } val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; DirtFinderMapDoorTarget val3 = val.GetComponent() ?? val.AddComponent(); DirtFinderMapDoorTarget val4 = val3; if (val4.HingeTransform == null) { val4.HingeTransform = val.transform; } WoodlandApplyHideFlags((Object)(object)val); return val; } private static void WoodlandApplyHideFlags(Object obj) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (obj == (Object)null) { return; } obj.hideFlags = (HideFlags)(obj.hideFlags | 0x23); GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (val == null) { return; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { ((Object)val2).hideFlags = (HideFlags)(((Object)val2).hideFlags | 0x23); GameObject gameObject = ((Component)val2).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); Component[] components = ((Component)val2).GetComponents(); foreach (Component val3 in components) { if ((Object)(object)val3 != (Object)null) { ((Object)val3).hideFlags = (HideFlags)(((Object)val3).hideFlags | 0x23); } } } } } [HarmonyPatch(typeof(LevelGenerator), "StartRoomGeneration")] internal static class WoodlandMansionCompatPatchStartRoomGenerationPatch { [HarmonyPrefix] private static void WoodlandPrefix() { WoodlandMansionCompatPatchPlugin.Instance?.WoodlandTryRepairCurrentLevel(); } } [HarmonyPatch(typeof(PhysGrabHinge), "Awake")] internal static class WoodlandMansionCompatPatchPhysGrabHingeAwakePatch { [HarmonyPrefix] private static void WoodlandPrefix(PhysGrabHinge __instance) { if (WoodlandMansionCompatPatchPlugin.WoodlandIsCurrentLevel()) { WoodlandMansionCompatPatchPlugin.WoodlandEnsurePhysGrabHingeCompatibility(__instance); } } } [HarmonyPatch(typeof(ExtractionPoint), "Start")] internal static class WoodlandMansionCompatPatchExtractionPointStartPatch { [HarmonyPostfix] private static void WoodlandPostfix(ExtractionPoint __instance) { WoodlandMansionCompatPatchPlugin.WoodlandEnsureExtractionPointCompatibility(__instance); } } [HarmonyPatch(typeof(Levels), "RegisterLevelWithGame")] internal static class WoodlandMansionCompatPatchRegisterLevelPatch { [HarmonyPrefix] private static void WoodlandPrefix(Level level) { WoodlandMansionCompatPatchPlugin.WoodlandEnsureLevelFallbackData(level); } } [HarmonyPatch(typeof(Map), "AddDoor")] internal static class WoodlandMansionCompatPatchMapAddDoorPatch { [HarmonyPrefix] private static bool WoodlandPrefix(Map __instance, DirtFinderMapDoor door, GameObject doorPrefab, ref GameObject __result) { if (!WoodlandMansionCompatPatchPlugin.WoodlandIsCurrentLevel() || (Object)(object)door == (Object)null || (Object)(object)doorPrefab != (Object)null) { return true; } WoodlandMansionCompatPatchPlugin instance = WoodlandMansionCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.WoodlandCreateFallbackDoorMapObject(__instance, door); return false; } } [HarmonyPatch(typeof(LevelGenerator), "NavMeshSetupRPC")] internal static class WoodlandMansionCompatPatchNavMeshSetupPatch { [HarmonyPostfix] private static void WoodlandPostfix(LevelGenerator __instance) { WoodlandMansionCompatPatchPlugin.Instance?.WoodlandRepairLevelPoints(__instance); } } [HarmonyPatch(typeof(LevelPoint), "NavMeshCheck")] internal static class WoodlandMansionCompatPatchLevelPointNavMeshCheckPatch { [HarmonyPrefix] private static bool WoodlandPrefix(LevelPoint __instance, ref IEnumerator __result) { if (!WoodlandMansionCompatPatchPlugin.WoodlandIsCurrentLevel()) { return true; } WoodlandMansionCompatPatchPlugin instance = WoodlandMansionCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.WoodlandSilentLevelPointCheck(__instance); return false; } } [HarmonyPatch(typeof(UnityLogListener), "LogEvent")] internal static class WoodlandMansionCompatPatchUnityLogListenerPatch { [HarmonyPrefix] private static bool WoodlandPrefix(LogEventArgs eventArgs) { return !WoodlandMansionCompatPatchPlugin.WoodlandShouldSuppressMissingScriptWarning(eventArgs); } } [HarmonyPatch(typeof(UnityLogSource), "UnityLogMessageHandler")] internal static class WoodlandMansionCompatPatchUnityLogSourcePatch { [HarmonyPrefix] private static bool WoodlandPrefix(LogEventArgs eventArgs) { return !WoodlandMansionCompatPatchPlugin.WoodlandShouldSuppressMissingScriptWarning(eventArgs); } } [HarmonyPatch(typeof(Logger), "InternalLogEvent")] internal static class WoodlandMansionCompatPatchInternalLogEventPatch { [HarmonyPrefix] private static bool WoodlandPrefix(LogEventArgs eventArgs) { return !WoodlandMansionCompatPatchPlugin.WoodlandShouldSuppressMissingScriptWarning(eventArgs); } } }