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 Photon.Pun; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: AssemblyInformationalVersion("1.0.6")] [assembly: AssemblyProduct("EchoholdCompatPatch")] [assembly: AssemblyTitle("EchoholdCompatPatch")] [assembly: AssemblyVersion("1.0.6.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 EchoholdCompatPatch { [BepInPlugin("empress.repo.echoholdcompatpatch", "Empress Echohold Compat Patch", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class EchoholdCompatPatchPlugin : BaseUnityPlugin { private sealed class EchoholdLoadingGraphic { public AssetBundle Bundle { get; } public Sprite Sprite { get; } public string ResourcePath { get; } public bool CanUsePrefabRef { get; } public EchoholdLoadingGraphic(AssetBundle bundle, Sprite sprite, string resourcePath, bool canUsePrefabRef) { Bundle = bundle; Sprite = sprite; ResourcePath = resourcePath; CanUsePrefabRef = canUsePrefabRef; } } private sealed class EchoholdPrefabBuckets { 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.echoholdcompatpatch"; internal const string PluginName = "Empress Echohold Compat Patch"; internal const string PluginVersion = "1.0.6"; private const string EchoholdBundleFileName = "Echohold.repobundle"; private const string EchoholdLevelName = "Level - Echohold"; private const string EchoholdLevelResourcePath = "Echohold"; private const float EchoholdLevelPointCheckRadius = 0.5f; private const float EchoholdLevelPointRepairRadius = 2f; private const float EchoholdLevelPointConnectDistance = 15f; private const float EchoholdLevelPointConnectForwardDot = -0.8f; private const float EchoholdLevelPointConnectApproachDot = 0.8f; private const float EchoholdLevelPointValidationDelay = 0.5f; private const int EchoholdVehicleVolumeCount = 4; private const float EchoholdVehicleVolumeSideOffset = 2f; private const float EchoholdVehicleVolumeForwardOffset = 2.5f; private const float EchoholdVehicleVolumeForwardSpacing = 2f; private const float EchoholdChargingStationForwardOffset = 6.5f; private static readonly string[] EchoholdLoadingGraphicFieldNames = new string[3] { "LoadingGraphic01", "LoadingGraphic02", "LoadingGraphic03" }; private static readonly string[] EchoholdPreferredLoadingGraphicNames = new string[3] { "level arctic 01", "level arctic 02", "level arctic 03" }; private static readonly List EchoholdLoadingSprites = new List(); private static readonly string[] EchoholdStartRoomNames = new string[1] { "Start Room - Echohold - Lab" }; private static readonly string[] EchoholdNormal1Names = new string[5] { "Module - Echohold - N - 1 - Corridor 2", "Module - Echohold - N - 1 - Main Corridor", "Module - Echohold - N - 1 - Server Room", "Module - Echohold - N - 1 - Zero Gravity Lab", "Module - Echohold - N - 1 - Corridor 3" }; private static readonly string[] EchoholdPassage1Names = new string[4] { "Module - Echohold - P - 1 - Cafeteria", "Module - Echohold - P - 1 - Control Room", "Module - Echohold - P - 1 - Engine Room", "Module - Echohold - P - 1 - Science Lab" }; private static readonly string[] EchoholdDeadEnd1Names = new string[5] { "Module - Echohold - DE - 1 - Crew Quarters", "Module - Echohold - DE - 1 - Crew Quarters 2", "Module - Echohold - DE - 1 - Lab Testing", "Module - Echohold - DE - 1 - Medical Room", "Module - Echohold - DE - 1 - Storage Room" }; private static readonly string[] EchoholdExtraction1Names = new string[1] { "Module - Echohold - E - 1 - Lab" }; private readonly Harmony _echoholdHarmony = new Harmony("empress.repo.echoholdcompatpatch"); private AssetBundle? _echoholdBundle; private bool _echoholdRepairApplied; private bool _echoholdRepairQueued; private bool _echoholdItemsRepairApplied; private bool _echoholdLoggedMissingBundle; private bool _echoholdLoggedMissingPrefabs; private bool _echoholdLoggedDoorMapFallback; internal static EchoholdCompatPatchPlugin? Instance { get; private set; } private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Instance = this; GameObject gameObject = ((Component)this).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); BundleLoader.OnAllBundlesLoaded += EchoholdHandleBundlesLoaded; _echoholdHarmony.PatchAll(); EchoholdPatchUnityWarningFilter(); if ((Object)(object)RunManager.instance != (Object)null) { ((MonoBehaviour)this).StartCoroutine(EchoholdRepairWhenReady()); } } private void EchoholdHandleBundlesLoaded() { if (_echoholdRepairQueued || _echoholdRepairApplied) { return; } _echoholdRepairQueued = true; try { EchoholdTryRepairLevel(); } finally { _echoholdRepairQueued = false; } } private void EchoholdPatchUnityWarningFilter() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) { _echoholdHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(EchoholdCompatPatchPlugin), "EchoholdSuppressMissingScriptWarningPrefix", (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) { _echoholdHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(EchoholdCompatPatchPlugin), "EchoholdSuppressMissingScriptWarningPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private IEnumerator EchoholdRepairWhenReady() { yield return null; for (int attempt = 0; attempt < 120; attempt++) { if (_echoholdRepairApplied) { break; } if (EchoholdTryRepairLevel()) { break; } yield return null; } _echoholdRepairQueued = false; } internal bool EchoholdTryRepairCurrentLevel() { 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 EchoholdTryRepairLevel(list); } private bool EchoholdTryRepairLevel(IEnumerable? candidates = null) { if (_echoholdRepairApplied) { return true; } Level val = EchoholdFindLevel(candidates) ?? EchoholdFindLevel(Levels.AllLevels); if ((Object)(object)val == (Object)null) { return false; } AssetBundle val2 = EchoholdGetBundle(); if ((Object)(object)val2 == (Object)null) { if (!_echoholdLoggedMissingBundle) { _echoholdLoggedMissingBundle = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Echohold Compat Patch could not locate the Echohold bundle."); } return false; } _echoholdLoggedMissingBundle = false; EchoholdPrefabBuckets echoholdPrefabBuckets = EchoholdCollectPrefabs(val2); if (echoholdPrefabBuckets.StartRooms.Count == 0 || echoholdPrefabBuckets.TotalModuleCount == 0) { if (!_echoholdLoggedMissingPrefabs) { _echoholdLoggedMissingPrefabs = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Empress Echohold Compat Patch could not rebuild the Echohold prefab lists from the original bundle."); } return false; } _echoholdLoggedMissingPrefabs = false; EchoholdApplyHideFlags((Object)(object)val2); EchoholdApplyHideFlags((Object)(object)val); EchoholdEnsureLevelFallbackData(val); EchoholdEnsureLevelLoadingGraphics(val, val2); EchoholdTryRepairItems(val2); EchoholdRegisterLevelObjects(val); val.StartRooms = EchoholdRegisterPrefabs(val, "StartRoom", echoholdPrefabBuckets.StartRooms); val.ModulesNormal1 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal1); val.ModulesPassage1 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage1); val.ModulesDeadEnd1 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd1); val.ModulesExtraction1 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction1); val.ModulesNormal2 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal2); val.ModulesPassage2 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage2); val.ModulesDeadEnd2 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd2); val.ModulesExtraction2 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction2); val.ModulesNormal3 = EchoholdRegisterPrefabs(val, "Normal", echoholdPrefabBuckets.Normal3); val.ModulesPassage3 = EchoholdRegisterPrefabs(val, "Passage", echoholdPrefabBuckets.Passage3); val.ModulesDeadEnd3 = EchoholdRegisterPrefabs(val, "DeadEnd", echoholdPrefabBuckets.DeadEnd3); val.ModulesExtraction3 = EchoholdRegisterPrefabs(val, "Extraction", echoholdPrefabBuckets.Extraction3); _echoholdRepairApplied = val.StartRooms.Count > 0 && EchoholdCountModules(val) > 0; if (_echoholdRepairApplied) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {((Object)val).name} with {val.StartRooms.Count} start rooms and {EchoholdCountModules(val)} modules."); } return _echoholdRepairApplied; } private static Level? EchoholdFindLevel(IEnumerable? candidates) { if (candidates == null) { return null; } foreach (Level candidate in candidates) { if (EchoholdIsEchoholdLevel(candidate)) { return candidate; } } return null; } private AssetBundle? EchoholdGetBundle() { if ((Object)(object)_echoholdBundle != (Object)null) { return _echoholdBundle; } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (EchoholdBundleMatches(allLoadedAssetBundle)) { _echoholdBundle = allLoadedAssetBundle; return _echoholdBundle; } } string text = Directory.GetFiles(Paths.PluginPath, "Echohold.repobundle", SearchOption.AllDirectories).FirstOrDefault(); if (string.IsNullOrWhiteSpace(text)) { return null; } _echoholdBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_echoholdBundle != (Object)null) { return _echoholdBundle; } foreach (AssetBundle allLoadedAssetBundle2 in AssetBundle.GetAllLoadedAssetBundles()) { if (EchoholdBundleMatches(allLoadedAssetBundle2)) { _echoholdBundle = allLoadedAssetBundle2; return _echoholdBundle; } } return _echoholdBundle; } private static bool EchoholdBundleMatches(AssetBundle? bundle) { if ((Object)(object)bundle == (Object)null) { return false; } try { if (!string.IsNullOrWhiteSpace(((Object)bundle).name) && ((Object)bundle).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } catch { } try { if (bundle.GetAllAssetNames().Any((string assetName) => assetName.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0 || assetName.EndsWith("level - echohold.asset", StringComparison.OrdinalIgnoreCase))) { return true; } } catch { } try { Level[] array = bundle.LoadAllAssets(); for (int i = 0; i < array.Length; i++) { if (EchoholdIsEchoholdLevel(array[i])) { return true; } } } catch { } try { GameObject[] array2 = bundle.LoadAllAssets(); foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null) && (((Object)val).name.StartsWith("Start Room - Echohold -", StringComparison.OrdinalIgnoreCase) || ((Object)val).name.StartsWith("Module - Echohold -", StringComparison.OrdinalIgnoreCase))) { return true; } } } catch { } return false; } private static EchoholdPrefabBuckets EchoholdCollectPrefabs(AssetBundle bundle) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) { EchoholdAddAssetByName(dictionary, ((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null); } Module[] array2 = bundle.LoadAllAssets(); foreach (Module val2 in array2) { EchoholdAddAssetByName(dictionary, ((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); } GameObject[] array3 = bundle.LoadAllAssets(); foreach (GameObject prefab in array3) { EchoholdAddAssetByName(dictionary, prefab); } if (!dictionary.Keys.Any((string name) => name.StartsWith("Start Room - Echohold -", StringComparison.OrdinalIgnoreCase)) || !dictionary.Keys.Any((string name) => name.StartsWith("Module - Echohold -", StringComparison.OrdinalIgnoreCase))) { array = Resources.FindObjectsOfTypeAll(); Scene scene; foreach (StartRoom val3 in array) { if (!((Object)(object)val3 == (Object)null)) { scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, ((Component)val3).gameObject); } } } array2 = Resources.FindObjectsOfTypeAll(); foreach (Module val4 in array2) { if (!((Object)(object)val4 == (Object)null)) { scene = ((Component)val4).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, ((Component)val4).gameObject); } } } array3 = Resources.FindObjectsOfTypeAll(); foreach (GameObject val5 in array3) { if (!((Object)(object)val5 == (Object)null)) { scene = val5.scene; if (!((Scene)(ref scene)).IsValid()) { EchoholdAddAssetByName(dictionary, val5); } } } } return new EchoholdPrefabBuckets { StartRooms = EchoholdResolvePrefabs(dictionary, EchoholdStartRoomNames), Normal1 = EchoholdResolvePrefabs(dictionary, EchoholdNormal1Names), Passage1 = EchoholdResolvePrefabs(dictionary, EchoholdPassage1Names), DeadEnd1 = EchoholdResolvePrefabs(dictionary, EchoholdDeadEnd1Names), Extraction1 = EchoholdResolvePrefabs(dictionary, EchoholdExtraction1Names), 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 EchoholdAddAssetByName(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 EchoholdResolvePrefabs(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 EchoholdRegisterLevelObjects(Level level) { if (level.ConnectObject != null) { GameObject val = EchoholdResolvePrefab(level.ConnectObject); if ((Object)(object)val != (Object)null) { EchoholdRegisterNetworkPrefab("Level/" + EchoholdGetLevelPath(level) + "/Other/" + EchoholdGetPrefabName(level.ConnectObject, val), val); } } if (level.BlockObject != null) { GameObject val2 = EchoholdResolvePrefab(level.BlockObject); if ((Object)(object)val2 != (Object)null) { EchoholdRegisterNetworkPrefab("Level/" + EchoholdGetLevelPath(level) + "/Other/" + EchoholdGetPrefabName(level.BlockObject, val2), val2); } } } private static string EchoholdGetLevelPath(Level level) { if (!string.IsNullOrWhiteSpace(((Object)level).name)) { return ((Object)level).name; } return "Echohold"; } private static string EchoholdGetPrefabName(PrefabRef prefabRef, GameObject prefab) { if (!string.IsNullOrWhiteSpace(prefabRef.PrefabName)) { return prefabRef.PrefabName; } return ((Object)prefab).name; } private static GameObject? EchoholdResolvePrefab(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 EchoholdRegisterPrefabs(Level level, string moduleTypeName, IEnumerable prefabs) { List list = new List(); foreach (GameObject item in prefabs.OrderBy((GameObject gameObject) => ((Object)gameObject).name, StringComparer.OrdinalIgnoreCase)) { PrefabRef val = EchoholdRegisterNetworkPrefab("Level/" + ((Object)level).name + "/" + moduleTypeName + "/" + ((Object)item).name, item); if (val != null) { list.Add(val); } } return list; } private static PrefabRef? EchoholdRegisterNetworkPrefab(string prefabId, GameObject prefab) { PrefabRef val = EchoholdGetRegisteredPrefabRef(prefabId, prefab); if (val != null) { return val; } EchoholdPreparePrefab(prefab); Utilities.FixAudioMixerGroups(prefab); return NetworkPrefabs.RegisterNetworkPrefab(prefabId, prefab); } private static PrefabRef? EchoholdGetRegisteredPrefabRef(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 EchoholdPreparePrefab(GameObject prefab) { EchoholdApplyHideFlags((Object)(object)prefab); EchoholdEnsureVehicleSupport(prefab); EchoholdNormalizeBoxColliderSizes(prefab); EchoholdIgnoreUnreadableMeshesForNavMesh(prefab); EchoholdEnsureItemComponentReferences(prefab); EchoholdEnsurePlasmaComponentReferences(prefab); EchoholdAssignFallbackAudioMixerGroups(prefab); EchoholdAssignFallbackPhysAttributes(prefab); } private static void EchoholdEnsureVehicleSupport(GameObject prefab) { if (!((Object)(object)prefab == (Object)null) && EchoholdIsStartRoomPrefab(prefab)) { EchoholdEnsureVehicleItemVolumes(prefab); EchoholdEnsureVehicleChargingStation(prefab); } } private static bool EchoholdIsStartRoomPrefab(GameObject prefab) { GameObject prefab2 = prefab; if (!((Object)(object)prefab2.GetComponentInChildren(true) != (Object)null)) { return EchoholdStartRoomNames.Any((string name) => string.Equals(((Object)prefab2).name, name, StringComparison.OrdinalIgnoreCase)); } return true; } private static void EchoholdEnsureVehicleItemVolumes(GameObject prefab) { int num = prefab.GetComponentsInChildren(true).Count(EchoholdIsVehicleItemVolume); if (num < 4) { Transform parent = EchoholdFindOrCreateVehicleSupportRoot(prefab); Transform anchor = EchoholdFindTruckAnchor(prefab); for (int i = num; i < 4; i++) { EchoholdCreateVehicleItemVolume(parent, anchor, i); } } } private static bool EchoholdIsVehicleItemVolume(ItemVolume itemVolume) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 return (int)EchoholdGetComponentField((Component)(object)itemVolume, "itemVolume", (itemVolume)0) == 9; } private static void EchoholdCreateVehicleItemVolume(Transform parent, Transform anchor, int index) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject((index == 0) ? "Item Volume vehicle" : $"Item Volume vehicle ({index})"); val.SetActive(false); val.transform.SetParent(parent, false); val.transform.SetPositionAndRotation(EchoholdGetVehicleVolumePosition(anchor, index), anchor.rotation); ItemVolume target = val.AddComponent(); EchoholdSetComponentField((Component)(object)target, "itemVolume", (object)(itemVolume)9); GameObject val2 = new GameObject("Vehicle"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = new Vector3(2.6f, 1.4f, 4f); EchoholdSetComponentField((Component)(object)target, "volumes", new List { val2 }); EchoholdApplyHideFlags((Object)(object)val); } private static Vector3 EchoholdGetVehicleVolumePosition(Transform anchor, int index) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) float num = ((index % 2 == 0) ? (-2f) : 2f); float num2 = 2.5f + (float)(index / 2) * 2f; return anchor.position + anchor.right * num + anchor.forward * num2 + Vector3.up * 0.25f; } private static Transform EchoholdFindTruckAnchor(GameObject prefab) { LevelPoint[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (LevelPoint val in componentsInChildren) { if ((Object)(object)val != (Object)null && EchoholdGetComponentField((Component)(object)val, "Truck", fallback: false)) { return ((Component)val).transform; } } RoomVolume[] componentsInChildren2 = prefab.GetComponentsInChildren(true); foreach (RoomVolume val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && EchoholdGetComponentField((Component)(object)val2, "Truck", fallback: false)) { return ((Component)val2).transform; } } return prefab.transform; } private static Transform EchoholdFindOrCreateVehicleSupportRoot(GameObject prefab) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Transform val = ((IEnumerable)prefab.GetComponentsInChildren(true)).FirstOrDefault((Func)((Transform child) => (Object)(object)child != (Object)null && string.Equals(((Object)child).name, "Empress Vehicle Support", StringComparison.OrdinalIgnoreCase))); if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = new GameObject("Empress Vehicle Support"); val2.transform.SetParent(prefab.transform, false); EchoholdApplyHideFlags((Object)val2); return val2.transform; } private static void EchoholdEnsureVehicleChargingStation(GameObject prefab) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (prefab.GetComponentsInChildren(true).Any(EchoholdIsVehicleChargingStation)) { return; } ChargingStation val = EchoholdFindFallbackChargingStationTemplate(); if (!((Object)(object)val == (Object)null) && EchoholdIsVehicleChargingStation(val)) { ChargingStation val2 = EchoholdFindLegacyChargingStation(prefab); Transform val3 = EchoholdFindOrCreateVehicleSupportRoot(prefab); Transform val4 = EchoholdFindTruckAnchor(prefab); GameObject val5 = EchoholdCloneInactiveChargingStationTemplate(val); ((Object)val5).name = "Charging Station New"; val5.transform.SetParent(val3, false); if ((Object)(object)val2 != (Object)null) { val5.transform.SetPositionAndRotation(((Component)val2).transform.position, ((Component)val2).transform.rotation); ((Component)val2).gameObject.SetActive(false); } else { val5.transform.SetPositionAndRotation(val4.position + val4.forward * 6.5f + Vector3.up * 0.05f, Quaternion.LookRotation(-val4.forward, Vector3.up)); } Transform val6 = EchoholdFindChildByExactName(val5.transform, "Charge Area"); if ((Object)(object)val6 != (Object)null) { val6.localScale = new Vector3(Mathf.Max(val6.localScale.x, 4f), Mathf.Max(val6.localScale.y, 2f), Mathf.Max(val6.localScale.z, 4f)); } EchoholdApplyHideFlags((Object)(object)val5); Utilities.FixAudioMixerGroups(val5); } } private static GameObject EchoholdCloneInactiveChargingStationTemplate(ChargingStation template) { GameObject gameObject = ((Component)template).gameObject; bool activeSelf = gameObject.activeSelf; try { if (activeSelf) { gameObject.SetActive(false); } GameObject obj = Object.Instantiate(gameObject); obj.SetActive(false); return obj; } finally { if ((Object)(object)gameObject != (Object)null && activeSelf) { gameObject.SetActive(true); } } } internal static void EchoholdActivateVehicleChargingStation(StartRoom? startRoom) { if ((Object)(object)startRoom == (Object)null || !EchoholdIsCurrentLevel() || !EchoholdIsStartRoomPrefab(((Component)startRoom).gameObject)) { return; } ChargingStation[] componentsInChildren = ((Component)startRoom).GetComponentsInChildren(true); foreach (ChargingStation val in componentsInChildren) { if ((Object)(object)val != (Object)null && EchoholdIsVehicleChargingStation(val) && string.Equals(((Object)((Component)val).gameObject).name, "Charging Station New", StringComparison.OrdinalIgnoreCase) && !((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } } ItemVolume[] componentsInChildren2 = ((Component)startRoom).GetComponentsInChildren(true); foreach (ItemVolume val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && EchoholdIsVehicleItemVolume(val2) && !((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(true); } } } private static ChargingStation? EchoholdFindFallbackChargingStationTemplate() { ChargingStation val = EchoholdFindChargingStationTemplateFromLevels(); if ((Object)(object)val != (Object)null && EchoholdIsVehicleChargingStation(val)) { return val; } return Resources.FindObjectsOfTypeAll().Where(delegate(ChargingStation candidate) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)candidate != (Object)null) { Scene scene = ((Component)candidate).gameObject.scene; return !((Scene)(ref scene)).IsValid(); } return false; }).OrderByDescending(EchoholdIsVehicleChargingStation) .FirstOrDefault() ?? val; } private static ChargingStation? EchoholdFindChargingStationTemplateFromLevels() { ChargingStation val = null; if (RunManager.instance?.levels == null) { return val; } foreach (Level level in RunManager.instance.levels) { if ((Object)(object)level == (Object)null || EchoholdIsEchoholdLevel(level) || level.StartRooms == null) { continue; } foreach (PrefabRef startRoom in level.StartRooms) { GameObject val2 = null; try { val2 = EchoholdResolvePrefab(startRoom); } catch { } if ((Object)(object)val2 == (Object)null) { continue; } ChargingStation[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (ChargingStation val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { if (EchoholdIsVehicleChargingStation(val3)) { return val3; } if (val == null) { val = val3; } } } } } return val; } private static ChargingStation? EchoholdFindLegacyChargingStation(GameObject prefab) { return ((IEnumerable)prefab.GetComponentsInChildren(true)).FirstOrDefault((Func)((ChargingStation candidate) => (Object)(object)candidate != (Object)null && !EchoholdIsVehicleChargingStation(candidate))); } private static bool EchoholdIsVehicleChargingStation(ChargingStation? chargingStation) { if ((Object)(object)chargingStation == (Object)null) { return false; } Transform transform = ((Component)chargingStation).transform; if ((Object)(object)EchoholdFindChildByExactName(transform, "Charge Area") != (Object)null) { return (Object)(object)EchoholdFindChildByExactName(transform, "Line Between Two Points") != (Object)null; } return false; } private static Transform? EchoholdFindChildByExactName(Transform root, string name) { string name2 = name; return ((IEnumerable)((Component)root).GetComponentsInChildren(true)).FirstOrDefault((Func)((Transform child) => (Object)(object)child != (Object)null && string.Equals(((Object)child).name, name2, StringComparison.OrdinalIgnoreCase))); } private static T EchoholdGetComponentField(Component target, string fieldName, T fallback) { if ((Object)(object)target == (Object)null) { return fallback; } try { if (AccessTools.Field(((object)target).GetType(), fieldName) == null) { return fallback; } return (T)((Traverse.Create((object)target).Field(fieldName).GetValue() is T val) ? ((object)val) : ((object)fallback)); } catch { return fallback; } } private static void EchoholdSetComponentField(Component target, string fieldName, object value) { if ((Object)(object)target == (Object)null) { return; } try { if (!(AccessTools.Field(((object)target).GetType(), fieldName) == null)) { Traverse.Create((object)target).Field(fieldName).SetValue(value); } } catch { } } private static void EchoholdNormalizeBoxColliderSizes(GameObject prefab) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return; } BoxCollider[] componentsInChildren = prefab.GetComponentsInChildren(true); Vector3 val2 = default(Vector3); foreach (BoxCollider val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Vector3 size = val.size; ((Vector3)(ref val2))..ctor(Mathf.Abs(size.x), Mathf.Abs(size.y), Mathf.Abs(size.z)); if (size != val2) { val.size = val2; } } } } private static void EchoholdIgnoreUnreadableMeshesForNavMesh(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)((val != null) ? val.sharedMesh : null) == (Object)null) && !EchoholdMeshIsReadable(val.sharedMesh)) { EchoholdIgnoreObjectFromNavMeshBuild(((Component)val).gameObject); } } SkinnedMeshRenderer[] componentsInChildren2 = prefab.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { if (!((Object)(object)((val2 != null) ? val2.sharedMesh : null) == (Object)null) && !EchoholdMeshIsReadable(val2.sharedMesh)) { EchoholdIgnoreObjectFromNavMeshBuild(((Component)val2).gameObject); } } } private static bool EchoholdMeshIsReadable(Mesh mesh) { try { return mesh.isReadable; } catch { return false; } } private static void EchoholdIgnoreObjectFromNavMeshBuild(GameObject gameObject) { if (!((Object)(object)gameObject == (Object)null)) { NavMeshModifier obj = gameObject.GetComponent() ?? gameObject.AddComponent(); obj.ignoreFromBuild = true; obj.applyToChildren = false; } } private static void EchoholdEnsureItemComponentReferences(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } ItemAttributes[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (ItemAttributes val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { EchoholdSetFieldIfNull((Component)(object)val, "photonView", (Object?)(object)(((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent())); EchoholdSetFieldIfNull((Component)(object)val, "roomVolumeCheck", (Object?)(object)(((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent())); EchoholdSetFieldIfNull((Component)(object)val, "itemEquippable", (Object?)(object)(((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent())); EchoholdSetFieldIfNull((Component)(object)val, "physGrabObject", (Object?)(object)(((Component)val).GetComponent() ?? ((Component)val).GetComponentInChildren(true) ?? ((Component)val).GetComponentInParent())); EchoholdSetFieldIfNull((Component)(object)val, "itemToggle", (Object?)(object)(((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent())); } } } private static void EchoholdEnsurePlasmaComponentReferences(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } Component val = EchoholdFindComponentByTypeName(prefab, "PlasmaEnergySystem"); Component[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Component val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Name; if (string.Equals(name, "ItemPlasmaGun", StringComparison.Ordinal)) { EchoholdSetFieldIfNull(val2, "physGrabObject", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInChildren(true) ?? val2.GetComponentInParent())); EchoholdSetFieldIfNull(val2, "itemToggle", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInParent())); EchoholdSetFieldIfNull(val2, "plasmaEnergySystem", (Object?)(object)(val ?? EchoholdFindComponentByTypeName(val2.gameObject, "PlasmaEnergySystem"))); EchoholdSetFieldIfNull(val2, "photonView", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInParent())); EchoholdSetFieldIfNull(val2, "impactDetector", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInParent())); EchoholdSetFieldIfNull(val2, "itemEquippable", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInParent())); EchoholdSetFieldIfNull(val2, "roomVolumeCheck", (Object?)(object)(val2.GetComponent() ?? val2.GetComponentInParent())); } else if (string.Equals(name, "PlasmaVisualLogic", StringComparison.Ordinal)) { EchoholdSetFieldIfNull(val2, "plasmaEnergySystem", (Object?)(object)(val ?? EchoholdFindComponentByTypeName(val2.gameObject, "PlasmaEnergySystem"))); } } } } private static Component? EchoholdFindComponentByTypeName(GameObject root, string typeName) { if ((Object)(object)root == (Object)null || string.IsNullOrWhiteSpace(typeName)) { return null; } Component[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals(((object)val).GetType().Name, typeName, StringComparison.Ordinal)) { return val; } } return null; } private static void EchoholdSetFieldIfNull(Component target, string fieldName, Object? value) { if ((Object)(object)target == (Object)null || value == (Object)null || string.IsNullOrWhiteSpace(fieldName)) { return; } try { if (!(AccessTools.Field(((object)target).GetType(), fieldName) == null)) { Traverse val = Traverse.Create((object)target).Field(fieldName); if (val.GetValue() == null) { val.SetValue((object)value); } } } catch { } } private static void EchoholdAssignFallbackAudioMixerGroups(GameObject prefab) { AudioMixerGroup val = EchoholdGetFallbackAudioMixerGroup(); 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 AudioMixerGroup? EchoholdGetFallbackAudioMixerGroup() { 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 void EchoholdAssignFallbackPhysAttributes(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 = EchoholdCreateFallbackPhysAttribute(mass); } } } private static PhysAttribute EchoholdCreateFallbackPhysAttribute(float mass) { PhysAttribute obj = ScriptableObject.CreateInstance(); obj.mass = Mathf.Max(0.01f, mass); EchoholdApplyHideFlags((Object)(object)obj); return obj; } private bool EchoholdTryRepairItems(AssetBundle bundle) { if (_echoholdItemsRepairApplied || (Object)(object)bundle == (Object)null) { return false; } List list = (from itemContent in bundle.LoadAllAssets() where (Object)(object)((itemContent != null) ? itemContent.Prefab : null) != (Object)null select itemContent).OrderBy((ItemContent itemContent) => ((Object)((Component)itemContent.Prefab).gameObject).name, StringComparer.OrdinalIgnoreCase).ToList(); int num = 0; foreach (ItemContent item in list) { ItemAttributes prefab = item.Prefab; Item val = prefab?.item; if (!((Object)(object)prefab == (Object)null) && !((Object)(object)val == (Object)null) && EchoholdIsEchoholdItem(prefab, val)) { EchoholdPreparePrefab(((Component)prefab).gameObject); if (!EchoholdItemAlreadyRegistered(prefab, val) && Items.RegisterItem(item) != null) { num++; } } } _echoholdItemsRepairApplied = true; if (num > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {num} Echohold item registrations."); } return num > 0; } private static bool EchoholdIsEchoholdItem(ItemAttributes itemAttributes, Item item) { string value = (((Object)(object)itemAttributes != (Object)null) ? ((Object)((Component)itemAttributes).gameObject).name : string.Empty); string value2 = (((Object)(object)item != (Object)null) ? item.itemName : string.Empty); string value3 = (((Object)(object)item != (Object)null) ? ((Object)item).name : string.Empty); if (!EchoholdContainsEchoholdItemName(value) && !EchoholdContainsEchoholdItemName(value2)) { return EchoholdContainsEchoholdItemName(value3); } return true; } private static bool EchoholdContainsEchoholdItemName(string? value) { if (string.IsNullOrWhiteSpace(value)) { return false; } if (value.IndexOf("plasma", StringComparison.OrdinalIgnoreCase) < 0 && value.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) < 0) { return value.IndexOf("railgun", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool EchoholdItemAlreadyRegistered(ItemAttributes itemAttributes, Item item) { if ((Object)(object)itemAttributes == (Object)null || (Object)(object)item == (Object)null) { return false; } if (EchoholdItemListContains(Items.RegisteredItems, item) || EchoholdItemListContains(Items.AllItems, item)) { return true; } string key = "Items/" + ((Object)((Component)itemAttributes).gameObject).name; if (NetworkPrefabs.PrefabRefs.ContainsKey(key)) { return true; } return false; } private static bool EchoholdItemListContains(IEnumerable? items, Item item) { if (items == null || (Object)(object)item == (Object)null) { return false; } foreach (Item item2 in items) { if (!((Object)(object)item2 == (Object)null)) { if ((Object)(object)item2 == (Object)(object)item) { return true; } if (!string.IsNullOrWhiteSpace(((Object)item2).name) && string.Equals(((Object)item2).name, ((Object)item).name, StringComparison.OrdinalIgnoreCase)) { return true; } if (!string.IsNullOrWhiteSpace(item2.itemName) && string.Equals(item2.itemName, item.itemName, StringComparison.OrdinalIgnoreCase)) { return true; } } } return false; } private static int EchoholdCountModules(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); } internal static bool EchoholdIsCurrentLevel() { if (!EchoholdIsEchoholdLevel(((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null)) { return EchoholdIsEchoholdLevel(((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelCurrent : null); } return true; } internal static bool EchoholdShouldSuppressUnityLog(LogType logType, string? format, object[]? args) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!EchoholdIsCurrentLevel()) { return false; } string text = EchoholdFormatUnityLogMessage(format, args); if (string.IsNullOrWhiteSpace(text)) { return false; } if ((int)logType == 2 && EchoholdIsMissingScriptWarning(text)) { return true; } if ((int)logType == 2 && text.StartsWith("BoxCollider does not support negative scale or size.", StringComparison.Ordinal)) { return true; } if ((int)logType == 0 && text.StartsWith("RuntimeNavMeshBuilder: Source mesh ", StringComparison.Ordinal) && text.IndexOf("does not allow read access", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((int)logType == 0) { if (!text.StartsWith("Level Point: ", StringComparison.Ordinal)) { return text.StartsWith(" Point Name: ", StringComparison.Ordinal); } return true; } return false; } internal static bool EchoholdShouldSuppressUnityLog(LogEventArgs? eventArgs) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if (eventArgs == null || !EchoholdIsCurrentLevel()) { return false; } if (!EchoholdIsUnityLogSource(eventArgs.Source)) { return false; } return EchoholdShouldSuppressUnityLog((LogType)(((int)eventArgs.Level != 2) ? (((int)eventArgs.Level == 4) ? 2 : 3) : 0), eventArgs.Data?.ToString(), null); } private static bool EchoholdIsUnityLogSource(ILogSource? source) { if (source != null) { return string.Equals(source.SourceName, "Unity Log", StringComparison.OrdinalIgnoreCase); } return false; } private static bool EchoholdIsMissingScriptWarning(string? message) { if (string.IsNullOrWhiteSpace(message)) { return false; } if (message.IndexOf("The referenced script", StringComparison.Ordinal) >= 0) { return message.IndexOf("missing", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static string EchoholdFormatUnityLogMessage(string? format, object[]? args) { if (format == null) { return string.Empty; } if (args == null || args.Length == 0) { return format; } try { return string.Format(format, args); } catch { return format; } } private static bool EchoholdSuppressMissingScriptWarningPrefix(LogType logType, string format, object[] args) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return !EchoholdShouldSuppressUnityLog(logType, format, args); } private static bool EchoholdIsEchoholdLevel(Level? level) { if ((Object)(object)level == (Object)null) { return false; } if (!string.Equals(((Object)level).name, "Level - Echohold", StringComparison.OrdinalIgnoreCase) && !string.Equals(((Object)level).name, "Echohold", StringComparison.OrdinalIgnoreCase) && (string.IsNullOrWhiteSpace(((Object)level).name) || ((Object)level).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) < 0)) { if (!string.IsNullOrWhiteSpace(level.NarrativeName)) { return level.NarrativeName.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } return true; } internal static void EchoholdEnsureLevelFallbackData(Level? level) { if (EchoholdIsEchoholdLevel(level)) { 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 && EchoholdTryGetFallbackAmbience(out LevelAmbience ambience)) { level.AmbiencePresets.Add(ambience); } } } private static void EchoholdEnsureLevelLoadingGraphics(Level level, AssetBundle bundle) { List list = EchoholdCollectLoadingGraphics(bundle); EchoholdCacheLoadingSprites(list); string[] echoholdLoadingGraphicFieldNames = EchoholdLoadingGraphicFieldNames; foreach (string text in echoholdLoadingGraphicFieldNames) { if (list.Count != 0 || !EchoholdLevelLoadingGraphicValid(level, text)) { EchoholdLoadingGraphic echoholdLoadingGraphic = ((list.Count > 0) ? list[Math.Min(Array.IndexOf(EchoholdLoadingGraphicFieldNames, text), list.Count - 1)] : null); if (echoholdLoadingGraphic == null || !EchoholdSetLevelLoadingGraphic(level, text, echoholdLoadingGraphic)) { EchoholdCopyFallbackLevelLoadingGraphic(level, text); } } } } private static List EchoholdCollectLoadingGraphics(AssetBundle bundle) { List list = new List(); HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); List source = (from sprite in bundle.LoadAllAssets() where (Object)(object)sprite != (Object)null && !string.IsNullOrWhiteSpace(((Object)sprite).name) select sprite).ToList(); string[] echoholdPreferredLoadingGraphicNames = EchoholdPreferredLoadingGraphicNames; foreach (string preferredName in echoholdPreferredLoadingGraphicNames) { Sprite val = ((IEnumerable)source).FirstOrDefault((Func)((Sprite candidate) => string.Equals(((Object)candidate).name, preferredName, StringComparison.OrdinalIgnoreCase))); if (!((Object)(object)val == (Object)null) && hashSet.Add(((Object)val).name)) { bool canUsePrefabRef = (Object)(object)bundle.LoadAsset(((Object)val).name) != (Object)null; list.Add(new EchoholdLoadingGraphic(bundle, val, ((Object)val).name, canUsePrefabRef)); } } foreach (string item in bundle.GetAllAssetNames().OrderBy(EchoholdLoadingGraphicRank).ThenBy((string name) => name, StringComparer.OrdinalIgnoreCase)) { Sprite val2 = bundle.LoadAsset(item); if (!((Object)(object)val2 == (Object)null) && hashSet.Add(item)) { list.Add(new EchoholdLoadingGraphic(bundle, val2, item, canUsePrefabRef: true)); } } foreach (Sprite item2 in source.OrderBy((Sprite sprite) => EchoholdLoadingGraphicRank(((Object)sprite).name)).ThenBy((Sprite sprite) => ((Object)sprite).name, StringComparer.OrdinalIgnoreCase)) { if (!((Object)(object)item2 == (Object)null) && !string.IsNullOrWhiteSpace(((Object)item2).name) && hashSet.Add(((Object)item2).name)) { bool canUsePrefabRef2 = (Object)(object)bundle.LoadAsset(((Object)item2).name) != (Object)null; list.Add(new EchoholdLoadingGraphic(bundle, item2, ((Object)item2).name, canUsePrefabRef2)); } } return list; } private static void EchoholdCacheLoadingSprites(IEnumerable graphics) { EchoholdLoadingSprites.Clear(); foreach (EchoholdLoadingGraphic graphic in graphics) { if ((Object)(object)graphic.Sprite != (Object)null && !EchoholdLoadingSprites.Contains(graphic.Sprite)) { EchoholdLoadingSprites.Add(graphic.Sprite); } if (EchoholdLoadingSprites.Count >= EchoholdLoadingGraphicFieldNames.Length) { break; } } } internal static void EchoholdApplyLoadingGraphics(LoadingUI? loadingUI) { if (!((Object)(object)loadingUI == (Object)null) && EchoholdIsCurrentLevel() && EchoholdLoadingSprites.Count != 0) { EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic01, 0); EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic02, 1); EchoholdApplyLoadingGraphic(loadingUI.loadingGraphic03, 2); } } private static void EchoholdApplyLoadingGraphic(Image? image, int index) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)image == (Object)null)) { Sprite sprite = EchoholdLoadingSprites[Math.Min(index, EchoholdLoadingSprites.Count - 1)]; image.sprite = sprite; ((Graphic)image).color = Color.white; } } private static int EchoholdLoadingGraphicRank(string value) { if (string.IsNullOrWhiteSpace(value)) { return 1000; } string text = value.ToLowerInvariant(); int num = 0; if (text.Contains("loading") || text.Contains("load")) { num -= 100; } if (text.Contains("graphic")) { num -= 50; } if (text.Contains("echohold")) { num -= 25; } if (text.Contains("arctic")) { num -= 10; } if (text.Contains("icon") || text.Contains("map")) { num += 100; } return num; } private static bool EchoholdLevelLoadingGraphicValid(Level level, string fieldName) { try { if (AccessTools.Field(((object)level).GetType(), fieldName) == null) { return false; } object value = Traverse.Create((object)level).Field(fieldName).GetValue(); if (value == null) { return false; } Sprite val = (Sprite)((value is Sprite) ? value : null); if (val != null) { return (Object)(object)val != (Object)null; } return AccessTools.Method(value.GetType(), "IsValid", Type.EmptyTypes, (Type[])null) != null && Traverse.Create(value).Method("IsValid", Array.Empty()).GetValue(); } catch { return false; } } private static bool EchoholdSetLevelLoadingGraphic(Level level, string fieldName, EchoholdLoadingGraphic graphic) { try { FieldInfo fieldInfo = AccessTools.Field(((object)level).GetType(), fieldName); if (fieldInfo == null) { return false; } if (typeof(Sprite).IsAssignableFrom(fieldInfo.FieldType)) { Traverse.Create((object)level).Field(fieldName).SetValue((object)graphic.Sprite); return true; } if (!fieldInfo.FieldType.Name.StartsWith("PrefabRef", StringComparison.Ordinal)) { return false; } if (!graphic.CanUsePrefabRef) { return false; } object obj = Traverse.Create((object)level).Field(fieldName).GetValue() ?? AccessTools.CreateInstance(fieldInfo.FieldType); if (obj == null) { return false; } if (AccessTools.Method(fieldInfo.FieldType, "SetPrefab", new Type[2] { typeof(AssetBundle), typeof(string) }, (Type[])null) != null) { Traverse.Create(obj).Method("SetPrefab", new object[2] { graphic.Bundle, graphic.ResourcePath }).GetValue(); } else { if (AccessTools.Field(fieldInfo.FieldType, "bundle") != null) { Traverse.Create(obj).Field("bundle").SetValue((object)graphic.Bundle); } if (AccessTools.Field(fieldInfo.FieldType, "resourcePath") != null) { Traverse.Create(obj).Field("resourcePath").SetValue((object)graphic.ResourcePath); } if (AccessTools.Field(fieldInfo.FieldType, "prefabName") != null) { Traverse.Create(obj).Field("prefabName").SetValue((object)Path.GetFileNameWithoutExtension(graphic.ResourcePath)); } } Traverse.Create((object)level).Field(fieldName).SetValue(obj); return EchoholdLevelLoadingGraphicValid(level, fieldName); } catch { return false; } } private static bool EchoholdCopyFallbackLevelLoadingGraphic(Level level, string fieldName) { if (RunManager.instance?.levels == null) { return false; } foreach (Level level2 in RunManager.instance.levels) { if ((Object)(object)level2 == (Object)null || (Object)(object)level2 == (Object)(object)level) { continue; } try { FieldInfo fieldInfo = AccessTools.Field(((object)level2).GetType(), fieldName); FieldInfo fieldInfo2 = AccessTools.Field(((object)level).GetType(), fieldName); if (fieldInfo == null || fieldInfo2 == null) { continue; } object value = Traverse.Create((object)level2).Field(fieldName).GetValue(); if (value != null) { Traverse.Create((object)level).Field(fieldName).SetValue(value); if (EchoholdLevelLoadingGraphicValid(level, fieldName)) { return true; } } } catch { } } return false; } private static bool EchoholdTryGetFallbackAmbience(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)) { 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)) { ambience = ambiencePreset; return true; } } } } return false; } internal static void EchoholdEnsureExtractionPointCompatibility(ExtractionPoint extractionPoint) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown if ((Object)(object)extractionPoint == (Object)null || !EchoholdIsCurrentLevel()) { return; } if ((Object)(object)extractionPoint.extractionArea == (Object)null) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val).name = "Echohold 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) { Object.Destroy((Object)(object)component2); } val.SetActive(false); EchoholdApplyHideFlags((Object)(object)val); extractionPoint.extractionArea = val; } if ((Object)(object)extractionPoint.grossUp == (Object)null) { GameObject val2 = new GameObject("Echohold Patch GrossUp"); val2.transform.SetParent(((Component)extractionPoint).transform, false); val2.SetActive(false); EchoholdApplyHideFlags((Object)(object)val2); extractionPoint.grossUp = val2; } } internal bool EchoholdTryStartSilentLevelPoint(LevelPoint levelPoint) { if (!EchoholdIsEchoholdLevelPoint(levelPoint)) { return false; } if ((Object)(object)LevelGenerator.Instance != (Object)null) { LevelGenerator instance = LevelGenerator.Instance; if (instance.LevelPathPoints == null) { instance.LevelPathPoints = new List(); } if (!LevelGenerator.Instance.LevelPathPoints.Contains(levelPoint)) { LevelGenerator.Instance.LevelPathPoints.Add(levelPoint); } if (levelPoint.Truck) { LevelGenerator.Instance.LevelPathTruck = levelPoint; } } if ((Object)(object)((Component)levelPoint).GetComponentInParent() != (Object)null) { EchoholdSetLevelPointBool(levelPoint, "inStartRoom", value: true); } ((MonoBehaviour)this).StartCoroutine(EchoholdSilentLevelPointCheck(levelPoint)); return true; } private static void EchoholdSetLevelPointBool(LevelPoint levelPoint, string fieldName, bool value) { try { if (AccessTools.Field(((object)levelPoint).GetType(), fieldName) != null) { Traverse.Create((object)levelPoint).Field(fieldName).SetValue((object)value); } } catch { } } private static bool EchoholdIsEchoholdLevelPoint(LevelPoint? levelPoint) { if ((Object)(object)levelPoint == (Object)null) { return false; } if (EchoholdIsCurrentLevel()) { return true; } Module componentInParent = ((Component)levelPoint).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && !string.IsNullOrWhiteSpace(((Object)componentInParent).name) && ((Object)componentInParent).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } StartRoom componentInParent2 = ((Component)levelPoint).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && !string.IsNullOrWhiteSpace(((Object)componentInParent2).name) && ((Object)componentInParent2).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } Transform val = ((Component)levelPoint).transform; while ((Object)(object)val != (Object)null) { if (!string.IsNullOrWhiteSpace(((Object)val).name) && ((Object)val).name.IndexOf("echohold", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } internal void EchoholdRepairLevelPoints(LevelGenerator levelGenerator) { if ((Object)(object)levelGenerator == (Object)null || !EchoholdIsEchoholdLevel(levelGenerator.Level) || levelGenerator.LevelPathPoints == null) { return; } int num = 0; int num2 = 0; foreach (LevelPoint levelPathPoint in levelGenerator.LevelPathPoints) { if (EchoholdRepairLevelPoint(levelPathPoint)) { num++; } if (EchoholdRepairLevelPointRoom(levelPathPoint)) { num2++; } } if (num > 0 || num2 > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Empress Echohold Compat Patch repaired {num} Echohold level points onto the navmesh and restored {num2} room links."); } } private static bool EchoholdRepairLevelPoint(LevelPoint? levelPoint) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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; EchoholdRepairLevelPointRoom(levelPoint); return true; } private static bool EchoholdRepairLevelPointRoom(LevelPoint? levelPoint) { //IL_001f: 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 EchoholdSilentLevelPointCheck(LevelPoint levelPoint) { if ((Object)(object)levelPoint == (Object)null) { yield break; } 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 (EchoholdIsCurrentLevel()) { EchoholdRepairLevelPoint(levelPoint); EchoholdRepairLevelPointRoom(levelPoint); EchoholdRepairLevelPointConnections(levelPoint, LevelGenerator.Instance?.LevelPathPoints); if (levelPoint.ModuleConnect) { EchoholdSetLevelPointBool(levelPoint, "ModuleConnected", value: true); } } } private static void EchoholdRepairLevelPointConnections(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(); for (int i = 0; i < array.Length; i++) { EchoholdAddLevelPointConnection(array[i], levelPoint); } if (!levelPoint.ModuleConnect || allLevelPoints == null || levelPoint.ConnectedPoints.Count > 0) { return; } LevelPoint val = null; float currentBestDistance = float.MaxValue; foreach (LevelPoint allLevelPoint in allLevelPoints) { if (EchoholdCanConnectLevelPoints(levelPoint, allLevelPoint, currentBestDistance, out var distance)) { val = allLevelPoint; currentBestDistance = distance; } } EchoholdAddLevelPointConnection(levelPoint, val); EchoholdAddLevelPointConnection(val, levelPoint); } private static bool EchoholdCanConnectLevelPoints(LevelPoint source, LevelPoint? candidate, float currentBestDistance, out float distance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) 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 EchoholdAddLevelPointConnection(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 EchoholdCreateFallbackDoorMapObject(Map map, DirtFinderMapDoor door) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) MapLayer layerParent = map.GetLayerParent(((Component)door).transform.position.y); GameObject val = EchoholdInstantiateFallbackDoorMapObject(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 (!_echoholdLoggedDoorMapFallback) { _echoholdLoggedDoorMapFallback = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress Echohold Compat Patch injected fallback minimap door markers for missing Echohold door prefabs."); } return val; } private static GameObject EchoholdInstantiateFallbackDoorMapObject(Map map, Transform parent) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } } 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) { Object.Destroy((Object)(object)component); } } val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; DirtFinderMapDoorTarget val2 = val.GetComponent() ?? val.AddComponent(); if (val2.HingeTransform == null) { val2.HingeTransform = val.transform; } EchoholdApplyHideFlags((Object)(object)val); return val; } private static void EchoholdApplyHideFlags(Object obj) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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 obj2 in componentsInChildren) { ((Object)obj2).hideFlags = (HideFlags)(((Object)obj2).hideFlags | 0x23); GameObject gameObject = ((Component)obj2).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23); Component[] components = ((Component)obj2).GetComponents(); foreach (Component val2 in components) { if ((Object)(object)val2 != (Object)null) { ((Object)val2).hideFlags = (HideFlags)(((Object)val2).hideFlags | 0x23); } } } } } [HarmonyPatch(typeof(LevelPoint), "Start")] internal static class EchoholdCompatPatchLevelPointStartPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LevelPoint __instance) { EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null || !instance.EchoholdTryStartSilentLevelPoint(__instance)) { return true; } return false; } } [HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")] internal static class EchoholdCompatPatchLoadingUILevelAnimationStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(LoadingUI __instance) { EchoholdCompatPatchPlugin.EchoholdApplyLoadingGraphics(__instance); } } [HarmonyPatch(typeof(LevelGenerator), "StartRoomGeneration")] internal static class EchoholdCompatPatchStartRoomGenerationPatch { [HarmonyPrefix] private static void EchoholdPrefix() { EchoholdCompatPatchPlugin.Instance?.EchoholdTryRepairCurrentLevel(); } } [HarmonyPatch(typeof(StartRoom), "Start")] internal static class EchoholdCompatPatchStartRoomStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(StartRoom __instance) { EchoholdCompatPatchPlugin.EchoholdActivateVehicleChargingStation(__instance); } } [HarmonyPatch(typeof(ExtractionPoint), "Start")] internal static class EchoholdCompatPatchExtractionPointStartPatch { [HarmonyPostfix] private static void EchoholdPostfix(ExtractionPoint __instance) { EchoholdCompatPatchPlugin.EchoholdEnsureExtractionPointCompatibility(__instance); } } [HarmonyPatch(typeof(Levels), "RegisterLevelWithGame")] internal static class EchoholdCompatPatchRegisterLevelPatch { [HarmonyPrefix] private static void EchoholdPrefix(Level level) { EchoholdCompatPatchPlugin.EchoholdEnsureLevelFallbackData(level); } } [HarmonyPatch(typeof(Map), "AddDoor")] internal static class EchoholdCompatPatchMapAddDoorPatch { [HarmonyPrefix] private static bool EchoholdPrefix(Map __instance, DirtFinderMapDoor door, GameObject doorPrefab, ref GameObject __result) { if (!EchoholdCompatPatchPlugin.EchoholdIsCurrentLevel() || (Object)(object)door == (Object)null || (Object)(object)doorPrefab != (Object)null) { return true; } EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.EchoholdCreateFallbackDoorMapObject(__instance, door); return false; } } [HarmonyPatch(typeof(LevelGenerator), "NavMeshSetupRPC")] internal static class EchoholdCompatPatchNavMeshSetupPatch { [HarmonyPostfix] private static void EchoholdPostfix(LevelGenerator __instance) { EchoholdCompatPatchPlugin.Instance?.EchoholdRepairLevelPoints(__instance); } } [HarmonyPatch(typeof(LevelPoint), "NavMeshCheck")] internal static class EchoholdCompatPatchLevelPointNavMeshCheckPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LevelPoint __instance, ref IEnumerator __result) { if (!EchoholdCompatPatchPlugin.EchoholdIsCurrentLevel()) { return true; } EchoholdCompatPatchPlugin instance = EchoholdCompatPatchPlugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } __result = instance.EchoholdSilentLevelPointCheck(__instance); return false; } } [HarmonyPatch(typeof(UnityLogListener), "LogEvent")] internal static class EchoholdCompatPatchUnityLogListenerPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } [HarmonyPatch(typeof(UnityLogSource), "UnityLogMessageHandler")] internal static class EchoholdCompatPatchUnityLogSourcePatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } [HarmonyPatch(typeof(Logger), "InternalLogEvent")] internal static class EchoholdCompatPatchInternalLogEventPatch { [HarmonyPrefix] private static bool EchoholdPrefix(LogEventArgs eventArgs) { return !EchoholdCompatPatchPlugin.EchoholdShouldSuppressUnityLog(eventArgs); } } }