using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Internal; using Dawn.Utils; using DunGen; using DunGen.Adapters; using DunGen.Collision; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalLevelLoader; using LethalLevelLoader.AssetBundles; using LethalLevelLoader.Compatibility; using LethalLevelLoader.NetcodePatcher; using LethalLevelLoader.Patcher; using LethalLevelLoader.Tools; using LethalLib.Modules; using LethalModDataLib.Base; using LethalPerformance.Patches.ReferenceHolder; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using TMPro; using Unity.AI.Navigation; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("LethalLib")] [assembly: IgnoresAccessChecksTo("LethalPerformance")] [assembly: IgnoresAccessChecksTo("LethalPerformance.Patcher")] [assembly: IgnoresAccessChecksTo("LethalPerformance.Unity")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalLevelLoader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A Custom API to support the manual and dynamic integration of custom levels and dungeons in Lethal Company.")] [assembly: AssemblyFileVersion("1.7.7.0")] [assembly: AssemblyInformationalVersion("1.7.7+8004fa82652f1a38afc8942308416a04b4d1637d")] [assembly: AssemblyProduct("LethalLevelLoader")] [assembly: AssemblyTitle("LethalLevelLoader")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/IAmBatby/LethalLevelLoader/")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public enum ContentType { Vanilla, Custom, Any, External } internal static class HookHelper { public sealed class DisposableHookCollection { private readonly List ilHooks = new List(); private readonly List hooks = new List(); public void Clear() { foreach (Hook hook in hooks) { hook.Dispose(); } hooks.Clear(); foreach (ILHook ilHook in ilHooks) { ilHook.Dispose(); } ilHooks.Clear(); } public void ILHook(string methodName, Manipulator to, Type[] parameters = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown ilHooks.Add(new ILHook((MethodBase)EzGetMethod(methodName, parameters), to)); } public void Hook(string methodName, Delegate to, Type[] parameters = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown hooks.Add(new Hook((MethodBase)EzGetMethod(methodName, parameters), to)); } } public static MethodInfo MethodOf(Delegate method) { return method.Method; } public static MethodInfo EzGetMethod(Type type, string name, Type[] parameters = null) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; if (parameters == null) { return type.GetMethod(name, bindingAttr); } return type.GetMethod(name, bindingAttr, null, parameters, null); } public static MethodInfo EzGetMethod(string name, Type[] parameters = null) { return EzGetMethod(typeof(T), name, parameters); } } public static class NetworkScenePatcher { [CompilerGenerated] private static class <>O { public static Action, NetworkSceneManager> <0>__GenerateScenesInBuild_Hook; public static Func, NetworkSceneManager, uint, string> <1>__SceneNameFromHash_Hook; public static Func, NetworkSceneManager, int, string, LoadSceneMode, bool> <2>__ValidateSceneBeforeLoading_Hook; public static Manipulator <3>__ReplaceBuildIndexByScenePath; public static Manipulator <4>__ReplaceScenePathByBuildIndex; public static Func <5>__GetScenePathByBuildIndex; public static Func <6>__GetBuildIndexByScenePath; } private static List scenePaths = new List(); internal static Dictionary scenePathToBuildIndex = new Dictionary(); internal static Dictionary buildIndexToScenePath = new Dictionary(); private static Dictionary sceneHashToScenePath = new Dictionary(); private static Dictionary levelSceneDict = new Dictionary(); private static Dictionary fullSceneIndexToPathDict = new Dictionary(); private static Dictionary fullScenePathToIndexDict = new Dictionary(); private static HookHelper.DisposableHookCollection hooks = new HookHelper.DisposableHookCollection(); internal static bool patched { get; private set; } public static Dictionary GetLevelSceneDict() { return new Dictionary(levelSceneDict); } public static void AddScenePath(string scenePath) { if (!scenePaths.Contains(scenePath)) { DebugHelper.Log("Adding ScenePath: " + scenePath, DebugType.Developer); scenePaths.Add(scenePath); } } public static bool TryGetSceneIndex(int levelSceneIndex, string levelScenePath, out int sceneIndex) { sceneIndex = -1; int[] array = levelSceneDict.Keys.ToArray(); if (levelSceneDict.TryGetValue(array[levelSceneIndex], out var value)) { if (value == levelScenePath) { if (fullScenePathToIndexDict.TryGetValue(levelScenePath, out var value2)) { sceneIndex = value2; } else { DebugHelper.LogError("Failed At Full Scene Path", DebugType.User); } } else { DebugHelper.LogError("Failed At Path. Path 1: " + levelScenePath + ", Path 2: " + value, DebugType.User); } } else { DebugHelper.LogError("Failed At Level Scene Dict", DebugType.User); } return sceneIndex != -1; } internal static void Patch() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown if (!patched) { patched = true; hooks.Hook("GenerateScenesInBuild", new Action, NetworkSceneManager>(GenerateScenesInBuild_Hook)); hooks.Hook("SceneNameFromHash", new Func, NetworkSceneManager, uint, string>(SceneNameFromHash_Hook)); hooks.Hook("ValidateSceneBeforeLoading", new Func, NetworkSceneManager, int, string, LoadSceneMode, bool>(ValidateSceneBeforeLoading_Hook), new Type[3] { typeof(int), typeof(string), typeof(LoadSceneMode) }); HookHelper.DisposableHookCollection disposableHookCollection = hooks; object obj = <>O.<3>__ReplaceBuildIndexByScenePath; if (obj == null) { Manipulator val = ReplaceBuildIndexByScenePath; <>O.<3>__ReplaceBuildIndexByScenePath = val; obj = (object)val; } disposableHookCollection.ILHook("SceneHashFromNameOrPath", (Manipulator)obj); HookHelper.DisposableHookCollection disposableHookCollection2 = hooks; object obj2 = <>O.<3>__ReplaceBuildIndexByScenePath; if (obj2 == null) { Manipulator val2 = ReplaceBuildIndexByScenePath; <>O.<3>__ReplaceBuildIndexByScenePath = val2; obj2 = (object)val2; } disposableHookCollection2.ILHook("ValidateSceneEvent", (Manipulator)obj2); HookHelper.DisposableHookCollection disposableHookCollection3 = hooks; object obj3 = <>O.<4>__ReplaceScenePathByBuildIndex; if (obj3 == null) { Manipulator val3 = ReplaceScenePathByBuildIndex; <>O.<4>__ReplaceScenePathByBuildIndex = val3; obj3 = (object)val3; } disposableHookCollection3.ILHook("ScenePathFromHash", (Manipulator)obj3); } } internal static void Unpatch() { if (patched) { patched = false; hooks.Clear(); } } private static void ReplaceScenePathByBuildIndex(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodInfo methodInfo = HookHelper.MethodOf(new Func(GetScenePathByBuildIndex)); while (val.TryGotoNext(new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetScenePathByBuildIndex") })) { val.Remove(); val.Emit(OpCodes.Call, (MethodBase)methodInfo); } } private static void ReplaceBuildIndexByScenePath(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodInfo methodInfo = HookHelper.MethodOf(new Func(GetBuildIndexByScenePath)); while (val.TryGotoNext(new Func[1] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, typeof(SceneUtility), "GetBuildIndexByScenePath") })) { val.Remove(); val.Emit(OpCodes.Call, (MethodBase)methodInfo); } } private static string GetScenePathByBuildIndex(int buildIndex) { if (buildIndexToScenePath.TryGetValue(buildIndex, out var value)) { return value; } return SceneUtility.GetScenePathByBuildIndex(buildIndex); } private static int GetBuildIndexByScenePath(string scenePath) { int num = SceneUtility.GetBuildIndexByScenePath(scenePath); if (num == -1 && scenePathToBuildIndex.TryGetValue(scenePath, out var value)) { num = value; } return num; } private static void GenerateScenesInBuild_Hook(Action orig, NetworkSceneManager self) { scenePathToBuildIndex.Clear(); buildIndexToScenePath.Clear(); sceneHashToScenePath.Clear(); fullScenePathToIndexDict.Clear(); fullSceneIndexToPathDict.Clear(); levelSceneDict.Clear(); orig(self); for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { string scenePathByBuildIndex = SceneUtility.GetScenePathByBuildIndex(i); fullSceneIndexToPathDict.Add(i, scenePathByBuildIndex); fullScenePathToIndexDict.Add(scenePathByBuildIndex, i); if (scenePathByBuildIndex.Contains("Level")) { levelSceneDict.Add(i, scenePathByBuildIndex); } } int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings; for (int j = 0; j < scenePaths.Count; j++) { int num = sceneCountInBuildSettings + j; string text = scenePaths[j]; uint num2 = XXHash.Hash32(text); self.HashToBuildIndex.Add(num2, num); self.BuildIndexToHash.Add(num, num2); scenePathToBuildIndex.Add(text, num); buildIndexToScenePath.Add(num, text); sceneHashToScenePath.Add(num2, text); fullSceneIndexToPathDict.Add(num, text); fullScenePathToIndexDict.Add(text, num); levelSceneDict.Add(num, text); DebugHelper.Log("Added modded scene path: " + text, DebugType.Developer); } } private static string SceneNameFromHash_Hook(Func orig, NetworkSceneManager self, uint sceneHash) { if (sceneHash == 0) { return "No Scene"; } if (sceneHashToScenePath.TryGetValue(sceneHash, out var value)) { return value; } return orig(self, sceneHash); } private static bool ValidateSceneBeforeLoading_Hook(Func orig, NetworkSceneManager self, int sceneIndex, string sceneName, LoadSceneMode loadSceneMode) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) bool flag = orig(self, sceneIndex, sceneName, loadSceneMode); return true; } } namespace LethalLevelLoader { public static class LethalBundleManager { public enum ModProcessingStatus { Inactive, Loading, Complete } private static readonly Dictionary> obtainedExtendedModsDict = new Dictionary>(); private static readonly List obtainedExtendedModsList = new List(); internal static Dictionary>> onExtendedModLoadedRequestDict = new Dictionary>>(); public static ModProcessingStatus CurrentStatus { get; internal set; } = ModProcessingStatus.Inactive; public static ExtendedEvent OnFinishedProcessing { get; private set; } = new ExtendedEvent(); public static bool HasFinalisedFoundContent { get; internal set; } internal static void Start() { if (!Plugin.IsSetupComplete) { DebugHelper.Log("LethalBundleManager: Starting!", DebugType.User); PatchedContent.VanillaMod = ExtendedMod.Create("LethalCompany", "Zeekerss"); ReadKnownSceneBundles(); TryLoadLethalBundles(); } } private static void ReadKnownSceneBundles() { if (!File.Exists(LethalLevelLoader.AssetBundles.AssetBundleLoader.KnownSceneBundlesPath)) { return; } string[] array = File.ReadAllLines(LethalLevelLoader.AssetBundles.AssetBundleLoader.KnownSceneBundlesPath); if (array.Length < 1 || !int.TryParse(array[0], out var result) || result != LethalBundleManifest.ManifestVersion) { DebugHelper.LogWarning("Invalid or different manifest version found, it will be remade.'", DebugType.User); return; } for (int i = 1; i < array.Length; i++) { LethalBundleManifest value = new LethalBundleManifest(array[i]); LethalLevelLoader.AssetBundles.AssetBundleLoader.knownSceneBundles.TryAdd(value.fileName, value); } } private static void WriteKnownSceneBundles() { List list = new List(1) { $"{LethalBundleManifest.ManifestVersion}" }; foreach (LethalBundleManifest value in LethalLevelLoader.AssetBundles.AssetBundleLoader.knownSceneBundles.Values) { list.Add($"{value}"); } File.WriteAllLines(LethalLevelLoader.AssetBundles.AssetBundleLoader.KnownSceneBundlesPath, list, Encoding.UTF8); LethalLevelLoader.AssetBundles.AssetBundleLoader.knownSceneBundles = null; } private static bool TryLoadLethalBundles() { DebugHelper.Log("LethalBundleManger: Now Loading Bundles!", DebugType.User); if (LethalLevelLoader.AssetBundles.AssetBundleLoader.LoadAllBundlesRequest(null, null, ".lethalbundle", OnAssetBundleGroupCreated)) { CurrentStatus = ModProcessingStatus.Loading; LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundlesFinishedProcessing.AddListener(OnAssetBundleLoadRequestFinished); return true; } return false; } private static void OnAssetBundleGroupCreated(AssetBundleGroup newGroup) { DebugHelper.Log("LethalBundleManger Recieved Group: " + newGroup.GroupName, DebugType.User); FindContentInAssetBundleGroup(newGroup); } private static void OnAssetBundleLoadRequestFinished() { DebugHelper.Log("LethalBundleManger Finished Requested Load", DebugType.User); LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundlesFinishedProcessing.RemoveListener(OnAssetBundleLoadRequestFinished); FinialiseFoundContent(); } private static void FindContentInAssetBundleGroup(AssetBundleGroup group) { List list = group.LoadAllAssets(); if (list.Count > 0) { foreach (ExtendedMod item in list) { RegisterExtendedMod(item, group); } return; } foreach (ExtendedContent item2 in group.LoadAllAssets()) { RegisterNewExtendedContent(item2, group); } } internal static void RegisterExtendedMod(ExtendedMod extendedMod, AssetBundleGroup source) { DebugHelper.Log("Found ExtendedMod: " + ((Object)extendedMod).name, DebugType.User); extendedMod.ModNameAliases.Add(extendedMod.ModName); ExtendedMod extendedMod2 = null; foreach (ExtendedMod obtainedExtendedMods in obtainedExtendedModsList) { if (extendedMod.ModMergeSetting == ModMergeSetting.MatchingModName && obtainedExtendedMods.ModMergeSetting == ModMergeSetting.MatchingModName) { if (obtainedExtendedMods.ModName == extendedMod.ModName) { extendedMod2 = obtainedExtendedMods; } } else if (extendedMod.ModMergeSetting == ModMergeSetting.MatchingAuthorName && obtainedExtendedMods.ModMergeSetting == ModMergeSetting.MatchingAuthorName && obtainedExtendedMods.AuthorName == extendedMod.AuthorName) { extendedMod2 = obtainedExtendedMods; } } if ((Object)(object)extendedMod2 != (Object)null) { if (!extendedMod2.ModName.Contains(extendedMod2.AuthorName)) { DebugHelper.Log("Renaming ExtendedMod: " + extendedMod2.ModName + " To: " + extendedMod2.AuthorName + "sMod Due To Upcoming ExtendedMod Merge!", DebugType.Developer); extendedMod2.ModNameAliases.Add(extendedMod.ModName); extendedMod2.ModName = extendedMod2.AuthorName + "sMod"; } DebugHelper.Log("Merging ExtendedMod: " + extendedMod.ModName + " (" + extendedMod.AuthorName + ") With Already Obtained ExtendedMod: " + extendedMod2.ModName + " (" + extendedMod2.AuthorName + ")", DebugType.Developer); { foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { try { extendedMod2.RegisterExtendedContent(extendedContent); } catch (Exception exception) { DebugHelper.LogError(exception, DebugType.User); } } return; } } obtainedExtendedModsList.Add(extendedMod); if (source != null) { if (!obtainedExtendedModsDict.TryGetValue(source, out var value)) { obtainedExtendedModsDict.Add(source, new List(1) { extendedMod }); } else if (!value.Contains(extendedMod)) { value.Add(extendedMod); } } List extendedContents = extendedMod.ExtendedContents; extendedMod.UnregisterAllExtendedContent(); foreach (ExtendedContent item in extendedContents) { try { extendedMod.RegisterExtendedContent(item); } catch (Exception exception2) { DebugHelper.LogError(exception2, DebugType.User); } } } internal static void RegisterNewExtendedContent(ExtendedContent extendedContent, AssetBundleGroup source) { if ((Object)(object)extendedContent == (Object)null) { DebugHelper.LogError("Failed to register new ExtendedContent as it was null!", DebugType.User); return; } string contentSourceName = ((source == null) ? ((Object)extendedContent).name : source.GroupName); ExtendedMod extendedMod = null; if (extendedContent is ExtendedLevel extendedLevel) { if (string.IsNullOrEmpty(extendedLevel.contentSourceName)) { extendedLevel.contentSourceName = contentSourceName; } extendedMod = GetOrCreateExtendedMod(source, extendedLevel.contentSourceName); } else if (extendedContent is ExtendedDungeonFlow extendedDungeonFlow) { if (string.IsNullOrEmpty(extendedDungeonFlow.contentSourceName)) { extendedDungeonFlow.contentSourceName = contentSourceName; } extendedMod = GetOrCreateExtendedMod(source, extendedDungeonFlow.contentSourceName); } else if (extendedContent is ExtendedItem extendedItem) { extendedMod = GetOrCreateExtendedMod(source, extendedItem.Item.itemName.RemoveWhitespace()); } else if (extendedContent is ExtendedEnemyType extendedEnemyType) { extendedMod = GetOrCreateExtendedMod(source, extendedEnemyType.EnemyType.enemyName.RemoveWhitespace()); } else if (extendedContent is ExtendedBuyableVehicle extendedBuyableVehicle) { extendedMod = GetOrCreateExtendedMod(source, ((Object)extendedBuyableVehicle).name.RemoveWhitespace()); } else if (extendedContent is ExtendedUnlockableItem extendedUnlockableItem) { extendedMod = GetOrCreateExtendedMod(source, ((Object)extendedUnlockableItem).name.RemoveWhitespace()); } else if (extendedContent is ExtendedFootstepSurface extendedFootstepSurface) { extendedMod = GetOrCreateExtendedMod(source, ((Object)extendedFootstepSurface).name.RemoveWhitespace()); } if (!((Object)(object)extendedMod != (Object)null)) { return; } try { extendedMod.RegisterExtendedContent(extendedContent); } catch (Exception exception) { DebugHelper.LogError(exception, DebugType.User); } } internal static ExtendedMod GetOrCreateExtendedMod(AssetBundleGroup source, string contentSourceName) { if (source == null) { DebugHelper.Log("Creating New ExtendedMod: " + contentSourceName, DebugType.Developer); ExtendedMod extendedMod = ExtendedMod.Create(contentSourceName); obtainedExtendedModsList.Add(extendedMod); return extendedMod; } if (obtainedExtendedModsDict.TryGetValue(source, out var value)) { return value[0]; } DebugHelper.Log("Creating New ExtendedMod: " + contentSourceName, DebugType.Developer); ExtendedMod extendedMod2 = ExtendedMod.Create(contentSourceName); obtainedExtendedModsList.Add(extendedMod2); if (!obtainedExtendedModsDict.TryGetValue(source, out var value2)) { obtainedExtendedModsDict.Add(source, new List(1) { extendedMod2 }); } else if (!value2.Contains(extendedMod2)) { value2.Add(extendedMod2); } return extendedMod2; } internal static void FinialiseFoundContent() { foreach (ExtendedMod obtainedExtendedMods in obtainedExtendedModsList) { PatchedContent.ExtendedMods.Add(obtainedExtendedMods); DebugHelper.DebugExtendedMod(obtainedExtendedMods); } PatchedContent.ExtendedMods.Sort(default(ExtendedMod.ExtendedModComparer)); foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { extendedMod.SortRegisteredContent(); } foreach (KeyValuePair>> item in onExtendedModLoadedRequestDict) { foreach (ExtendedMod extendedMod2 in PatchedContent.ExtendedMods) { if (!extendedMod2.ModNameAliases.Contains(item.Key) && !(extendedMod2.AuthorName == item.Key)) { continue; } foreach (Action item2 in item.Value) { item2(extendedMod2); } } } WriteKnownSceneBundles(); NetworkRegisterCustomScenes(); LethalLevelLoader.AssetBundles.AssetBundleLoader.ClearCache(); DebugHelper.Log("Custom Content Processed. Unlocking Main Menu.", DebugType.User); HasFinalisedFoundContent = true; CurrentStatus = ModProcessingStatus.Complete; OnFinishedProcessing.Invoke(); } internal static void NetworkRegisterCustomScenes() { List list = new List(); List list2 = new List(); for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { list.Add(AssetBundleUtilities.GetSceneName(SceneUtility.GetScenePathByBuildIndex(i))); } foreach (AssetBundleGroup assetBundleGroup in LethalLevelLoader.AssetBundles.AssetBundleLoader.Instance.AssetBundleGroups) { foreach (LethalLevelLoader.AssetBundles.AssetBundleInfo assetBundleInfo in assetBundleGroup.GetAssetBundleInfos()) { foreach (string sceneName in assetBundleInfo.GetSceneNames()) { if (!list2.Contains(sceneName)) { list2.Add(sceneName); } } } } foreach (string item in list2) { if (!list.Contains(item)) { NetworkScenePatcher.AddScenePath(item); if (!PatchedContent.AllLevelSceneNames.Contains(item)) { PatchedContent.AllLevelSceneNames.Add(item); } } } foreach (string allLevelSceneName in PatchedContent.AllLevelSceneNames) { DebugHelper.Log("Loaded SceneName: " + allLevelSceneName, DebugType.Developer); } } } [CreateAssetMenu(fileName = "ExtendedBuyableVehicle", menuName = "Lethal Level Loader/Extended Content/ExtendedBuyableVehicle", order = 21)] public class ExtendedBuyableVehicle : ExtendedContent { [field: SerializeField] public BuyableVehicle BuyableVehicle { get; set; } [field: SerializeField] public string TerminalKeywordName { get; set; } = string.Empty; public int VehicleID { get; set; } public TerminalNode VehicleBuyNode { get; set; } public TerminalNode VehicleBuyConfirmNode { get; set; } public TerminalNode VehicleInfoNode { get; set; } internal static ExtendedBuyableVehicle Create(BuyableVehicle newBuyableVehicle) { ExtendedBuyableVehicle extendedBuyableVehicle = ScriptableObject.CreateInstance(); ((Object)extendedBuyableVehicle).name = ((Object)newBuyableVehicle.vehiclePrefab).name; extendedBuyableVehicle.BuyableVehicle = newBuyableVehicle; return extendedBuyableVehicle; } public void Initialize() { ContentRestorer.RestoreAudioAssetReferencesInParent(BuyableVehicle.vehiclePrefab); ContentRestorer.RestoreAudioAssetReferencesInParent(BuyableVehicle.secondaryPrefab); } internal override (bool result, string log) TryValidateContent() { if (BuyableVehicle == null) { return (result: false, log: "BuyableVehicle Was Null Or Empty"); } if ((Object)(object)BuyableVehicle.vehiclePrefab == (Object)null) { return (result: false, log: "Vehicle Prefab Was Null Or Empty"); } if ((Object)(object)BuyableVehicle.secondaryPrefab == (Object)null) { return (result: false, log: "Vehicle Secondary Prefab Was Null Or Empty"); } NetworkObject val = default(NetworkObject); if (!BuyableVehicle.vehiclePrefab.TryGetComponent(ref val)) { return (result: false, log: "Vehicle Prefab Is Missing NetworkObject Component"); } if (!BuyableVehicle.secondaryPrefab.TryGetComponent(ref val)) { return (result: false, log: "Vehicle Secondary Prefab Is Missing NetworkObject Component"); } return base.TryValidateContent(); } } public class ExtendedContent : ScriptableObject { [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct ExtendedContentComparer : IComparer { public readonly int Compare(ExtendedContent a, ExtendedContent b) { return string.Compare(((Object)a).name, ((Object)b).name, StringComparison.OrdinalIgnoreCase); } } public ExtendedMod ExtendedMod { get; internal set; } public ContentType ContentType { get; internal set; } [field: SerializeField] public List ContentTags { get; internal set; } = new List(); public string ModName => ExtendedMod.ModName; public string AuthorName => ExtendedMod.AuthorName; public string UniqueIdentificationName => AuthorName.ToLowerInvariant() + "." + ModName.ToLowerInvariant() + "." + ((Object)this).name.ToLowerInvariant(); [Obsolete] public List ContentTagStrings { get; internal set; } = new List(); internal virtual void TryCreateMatchingProperties() { } internal virtual (bool result, string log) TryValidateContent() { int num = ContentTags.RemoveAll((ContentTag tag) => (Object)(object)tag == (Object)null || string.IsNullOrEmpty(tag.contentTagName)); if (num > 0) { DebugHelper.LogWarning($"Removed '{num}' missing or empty tags in ExtendedContent: {((Object)this).name}", DebugType.User); } return (result: true, log: string.Empty); } internal virtual void ConvertObsoleteValues() { } public bool TryGetTag(string tag) { foreach (ContentTag contentTag in ContentTags) { if (contentTag.contentTagName == tag) { return true; } } return false; } public bool TryGetTag(string tag, out ContentTag returnTag) { returnTag = null; foreach (ContentTag contentTag in ContentTags) { if (contentTag.contentTagName == tag) { returnTag = contentTag; return true; } } return false; } public bool TryAddTag(string tag) { if (!TryGetTag(tag)) { ContentTags.Add(ContentTag.Create(tag)); return true; } return false; } } [Serializable] public class StringWithRarity(string newName, int newRarity) { [SerializeField] private string _name = newName; [SerializeField] [Range(0f, 300f)] private int _rarity = newRarity; [HideInInspector] public string Name { get { return newName; } set { newName = value; } } [HideInInspector] public int Rarity { get { return newRarity; } set { newRarity = value; } } } [Serializable] public class Vector2WithRarity { [SerializeField] private Vector2 _minMax = new Vector2(newMin, newMax); [SerializeField] private int _rarity; [HideInInspector] public float Min { get { return _minMax.x; } set { _minMax.x = value; } } [HideInInspector] public float Max { get { return _minMax.y; } set { _minMax.y = value; } } [HideInInspector] public int Rarity { get { return _rarity; } set { _rarity = value; } } public Vector2WithRarity(float newMin, float newMax, int newRarity) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) _rarity = newRarity; base..ctor(); } public Vector2WithRarity(Vector2 vector2, int newRarity) : this(vector2.x, vector2.y, newRarity) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) } [Serializable] public struct ClipWithRarity { [SerializeField] private AnimationClip _clip; [SerializeField] [Range(0f, 300f)] private int _rarity; [HideInInspector] public AnimationClip Clip { readonly get { return _clip; } set { _clip = value; } } [HideInInspector] public int Rarity { readonly get { return _rarity; } set { _rarity = value; } } public ClipWithRarity(AnimationClip clip, int rarity) { _clip = clip; _rarity = rarity; } } [CreateAssetMenu(fileName = "ExtendedDungeonFlow", menuName = "Lethal Level Loader/Extended Content/ExtendedDungeonFlow", order = 21)] public class ExtendedDungeonFlow : ExtendedContent { [Space(25f)] [Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")] [Obsolete] public bool generateAutomaticConfigurationOptions = true; [Obsolete] public bool enableDynamicDungeonSizeRestriction; [Obsolete] public float dungeonSizeMin = 1f; [Obsolete] public float dungeonSizeMax = 1f; [Obsolete] [Range(0f, 1f)] public float dungeonSizeLerpPercentage = 1f; [Obsolete] public AudioClip dungeonFirstTimeAudio; [Obsolete] public DungeonFlow dungeonFlow; [Obsolete] public string dungeonDisplayName = string.Empty; [Obsolete] public string contentSourceName = string.Empty; [Obsolete] public List dynamicLevelTagsList = new List(); [Obsolete] public List dynamicRoutePricesList = new List(); [Obsolete] public List dynamicCurrentWeatherList = new List(); [Obsolete] public List manualPlanetNameReferenceList = new List(); [Obsolete] public List manualContentSourceNameReferenceList = new List(); [Obsolete] [Range(0.1f, 10000f)] public float OverrideCameraMaxDistance = 400f; [CompilerGenerated] private Tile[] k__BackingField; [field: Header("General Settings")] [field: SerializeField] public DungeonFlow DungeonFlow { get; set; } [field: SerializeField] public string DungeonName { get; set; } = string.Empty; [field: SerializeField] [field: Min(0f)] public float MapTileSize { get; set; } = 1f; [field: SerializeField] public AudioClip FirstTimeDungeonAudio { get; set; } [field: SerializeField] public Vector3 RestrictBounds { get; set; } = Vector3.zero; [field: SerializeField] [field: Min(0f)] public int CullingTileDepth { get; set; } = 6; [field: Space(5f)] [field: Header("Dynamic Injection Matching Settings")] [field: SerializeField] public LevelMatchingProperties LevelMatchingProperties { get; set; } [field: Space(5f)] [field: Header("Extended Feature Settings")] [field: SerializeField] public GameObject OverrideKeyPrefab { get; set; } [field: SerializeField] public List IndoorMapHazards { get; set; } = new List(); [field: SerializeField] public List GlobalPropCountOverridesList { get; set; } = new List(); [field: Space(5f)] [field: SerializeField] public bool IsDynamicDungeonSizeRestrictionEnabled { get; set; } [field: SerializeField] public Vector2 DynamicDungeonSizeMinMax { get; set; } = new Vector2(1f, 1f); [field: SerializeField] [field: Range(0f, 1f)] public float DynamicDungeonSizeLerpRate { get; set; } = 1f; public float DynamicDungeonSizeMin => DynamicDungeonSizeMinMax.x; public float DynamicDungeonSizeMax => DynamicDungeonSizeMinMax.y; [field: Tooltip("Lower the kill floor of any Level this Dungeon generates on down to the lowest point of the generation.")] [field: SerializeField] public bool IsDynamicOutOfBoundsTriggerEnabled { get; set; } [field: Space(5f)] [field: SerializeField] public AudioClip[] OverrideCreakOpenDoorSFX { get; set; } [field: SerializeField] public AudioClip[] OverrideCreakShutDoorSFX { get; set; } [field: Space(5f)] [field: Tooltip("Overrides Vanilla Camera Far Plane Clip Distance Inside.")] [field: Range(0.1f, 10000f)] [field: SerializeField] public float OverrideCameraFarPlaneDistanceInside { get; set; } = 400f; [field: Space(10f)] [field: Header("Misc. Settings")] [field: SerializeField] public bool GenerateAutomaticConfigurationOptions { get; set; } = true; [Obsolete] [field: SerializeField] public List SpawnableMapObjects { get; set; } = new List(); [Obsolete] [field: SerializeField] public Vector3 OverrideRestrictedTilePlacementBounds { get; set; } = Vector3.zero; public int DungeonID { get; internal set; } public bool IsCurrentDungeon => (Object)(object)DungeonManager.CurrentExtendedDungeonFlow == (Object)(object)this; [HideInInspector] public DungeonEvents DungeonEvents { get; internal set; } = new DungeonEvents(); [HideInInspector] public Tile[] AllTiles { get { if (k__BackingField == null) { k__BackingField = DungeonFlow.GetTiles().ToArray(); } return k__BackingField; } } internal static ExtendedDungeonFlow Create(DungeonFlow newDungeonFlow, AudioClip newFirstTimeDungeonAudio, Vector3 newRestrictBounds, int newCullingTileDepth) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ExtendedDungeonFlow extendedDungeonFlow = ScriptableObject.CreateInstance(); extendedDungeonFlow.DungeonFlow = newDungeonFlow; extendedDungeonFlow.FirstTimeDungeonAudio = newFirstTimeDungeonAudio; extendedDungeonFlow.RestrictBounds = newRestrictBounds; extendedDungeonFlow.CullingTileDepth = newCullingTileDepth; extendedDungeonFlow.TryCreateMatchingProperties(); return extendedDungeonFlow; } internal void Initialize() { if ((Object)(object)LevelMatchingProperties == (Object)null) { LevelMatchingProperties = LevelMatchingProperties.Create(this); } GetDungeonFlowID(); if (string.IsNullOrEmpty(DungeonName)) { DungeonName = ((Object)DungeonFlow).name; } ((Object)this).name = ((Object)DungeonFlow).name.Replace("Flow", "") + "ExtendedDungeonFlow"; if ((Object)(object)FirstTimeDungeonAudio == (Object)null) { DebugHelper.LogWarning("Custom Dungeon: " + DungeonName + " Is Missing A DungeonFirstTimeAudio Reference! Assigning Facility Audio To Prevent Errors.", DebugType.Developer); FirstTimeDungeonAudio = Patches.RoundManager.firstTimeDungeonAudios[0]; } } private void GetDungeonFlowID() { if (base.ContentType == ContentType.Custom) { DungeonID = PatchedContent.ExtendedDungeonFlows.Count; } ContentType contentType = base.ContentType; if ((contentType != ContentType.Vanilla && contentType != ContentType.External) || 1 == 0) { return; } for (int i = 0; i < Patches.RoundManager.dungeonFlowTypes.Length; i++) { if (Patches.RoundManager.dungeonFlowTypes[i] != null && (Object)(object)Patches.RoundManager.dungeonFlowTypes[i].dungeonFlow == (Object)(object)DungeonFlow) { DungeonID = i; } } } internal override void TryCreateMatchingProperties() { if ((Object)(object)LevelMatchingProperties == (Object)null) { LevelMatchingProperties = LevelMatchingProperties.Create(this); } LevelMatchingProperties.ApplyValues(null, manualContentSourceNameReferenceList, newPlanetNames: manualPlanetNameReferenceList, newLevelTags: dynamicLevelTagsList, newRoutePrices: dynamicRoutePricesList, newCurrentWeathers: dynamicCurrentWeatherList); } internal override (bool result, string log) TryValidateContent() { int num = IndoorMapHazards.RemoveAll((IndoorMapHazard mapHazard) => mapHazard == null || (Object)(object)mapHazard.hazardType == (Object)null || (Object)(object)mapHazard.hazardType.prefabToSpawn == (Object)null); if (num > 0) { DebugHelper.LogWarning($"Removed '{num}' missing or empty IndoorMapHazard spawns in ExtendedDungeonFlow: {((Object)this).name}", DebugType.User); } if (base.ContentType == ContentType.Custom) { if ((Object)(object)DungeonFlow == (Object)null) { return (result: false, log: "DungeonFlow Was Null"); } if (DungeonFlow.Nodes == null || DungeonFlow.Nodes.Count == 0) { return (result: false, log: "DungeonFlow Nodes List Was Null Or Empty"); } if (DungeonFlow.Lines == null || DungeonFlow.Lines.Count == 0) { return (result: false, log: "DungeonFlow Lines List Was Null Or Empty"); } } for (int num2 = 0; num2 < AllTiles.Length; num2++) { Tile val = AllTiles[num2]; if (val.AllDoorways.Count > 0 || val.UsedDoorways.Count > 0 || val.UnusedDoorways.Count > 0) { DebugHelper.LogWarning("Tile '" + ((Object)val).name + "' does not have its 'AllDoorways', 'UsedDoorways', or 'UnusedDoorways' lists empty! Clearing them all to avoid generation issues...", DebugType.Developer); val.AllDoorways.Clear(); val.UsedDoorways.Clear(); val.UnusedDoorways.Clear(); } } return base.TryValidateContent(); } internal override void ConvertObsoleteValues() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown if ((Object)(object)DungeonFlow == (Object)null && (Object)(object)dungeonFlow != (Object)null) { DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonFlow is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DungeonFlow instead.", DebugType.Developer); DungeonFlow = dungeonFlow; dungeonFlow = null; } if (string.IsNullOrEmpty(DungeonName) && !string.IsNullOrEmpty(dungeonDisplayName)) { DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonDisplayName is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DungeonName instead.", DebugType.Developer); DungeonName = dungeonDisplayName; dungeonDisplayName = string.Empty; } if ((Object)(object)FirstTimeDungeonAudio == (Object)null && (Object)(object)dungeonFirstTimeAudio != (Object)null) { DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonFirstTimeAudio is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.FirstTimeDungeonAudio instead.", DebugType.Developer); FirstTimeDungeonAudio = dungeonFirstTimeAudio; dungeonFirstTimeAudio = null; } if (dungeonSizeLerpPercentage != 1f) { DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonSizeLerpPercentage is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DynamicDungeonSizeLerpRate instead.", DebugType.Developer); } if (dungeonSizeMax != 1f || dungeonSizeMin != 1f) { DebugHelper.LogWarning("ExtendedDungeonFlow.dungeonSizeMin and ExtendedDungeonFlow.dungeonSizeMax are Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.DynamicSungeonSizeMinMax instead.", DebugType.Developer); DynamicDungeonSizeMinMax = new Vector2(dungeonSizeMin, dungeonSizeMax); } if (!string.IsNullOrEmpty(contentSourceName)) { DebugHelper.LogWarning("ExtendedDungeonFlow.contentSourceName is Obsolete and will be removed in following releases, Please use ExtendedMod.AuthorName instead.", DebugType.Developer); } if ((Object)(object)LevelMatchingProperties == (Object)null && (dynamicLevelTagsList.Count > 0 || dynamicRoutePricesList.Count > 0 || dynamicCurrentWeatherList.Count > 0 || manualContentSourceNameReferenceList.Count > 0 || manualContentSourceNameReferenceList.Count > 0)) { DebugHelper.LogWarning("ExtendedDungeonFlow dynamic and manual match reference lists are Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.LevelMatchingProperties instead.", DebugType.Developer); TryCreateMatchingProperties(); } if (enableDynamicDungeonSizeRestriction || IsDynamicDungeonSizeRestrictionEnabled != enableDynamicDungeonSizeRestriction) { DebugHelper.LogWarning("ExtendedDungeonFlow.enableDynamicDungeonSizeRestriction Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.IsDynamicDungeonRestrictionEnabled instead.", DebugType.Developer); IsDynamicDungeonSizeRestrictionEnabled = enableDynamicDungeonSizeRestriction; } if (!generateAutomaticConfigurationOptions || GenerateAutomaticConfigurationOptions != generateAutomaticConfigurationOptions) { DebugHelper.LogWarning("ExtendedDungeonFlow.generateAutomaticConfigurationOptions Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.GenerateAutomaticConfigurationOptions instead.", DebugType.Developer); GenerateAutomaticConfigurationOptions = generateAutomaticConfigurationOptions; } if (SpawnableMapObjects.Count > 0) { DebugHelper.LogWarning("ExtendedDungeonFlow.SpawnableMapObjects Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.IndoorMapHazards instead.", DebugType.Developer); foreach (SpawnableMapObject spawnableMapObject in SpawnableMapObjects) { IndoorMapHazardType val = ScriptableObject.CreateInstance(); val.prefabToSpawn = spawnableMapObject.prefabToSpawn; val.spawnFacingAwayFromWall = spawnableMapObject.spawnFacingAwayFromWall; val.spawnFacingWall = spawnableMapObject.spawnFacingWall; val.spawnWithBackToWall = spawnableMapObject.spawnWithBackToWall; val.spawnWithBackFlushAgainstWall = spawnableMapObject.spawnWithBackFlushAgainstWall; val.requireDistanceBetweenSpawns = spawnableMapObject.requireDistanceBetweenSpawns; val.disallowSpawningNearEntrances = spawnableMapObject.disallowSpawningNearEntrances; IndoorMapHazard item = new IndoorMapHazard { hazardType = val, numberToSpawn = spawnableMapObject.numberToSpawn }; IndoorMapHazards.Add(item); } } Vector3 overrideRestrictedTilePlacementBounds = OverrideRestrictedTilePlacementBounds; if (((Vector3)(ref overrideRestrictedTilePlacementBounds)).sqrMagnitude > 1f) { DebugHelper.LogWarning("ExtendedDungeonFlow.OverrideRestrictedTilePlacementBounds Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.RestrictBounds instead.", DebugType.Developer); RestrictBounds = OverrideRestrictedTilePlacementBounds; } if (OverrideCameraMaxDistance != 400f && OverrideCameraFarPlaneDistanceInside == 400f) { DebugHelper.LogWarning("ExtendedDungeonFlow.OverrideCameraMaxDistance Is Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.OverrideCameraFarPlaneDistanceInside instead.", DebugType.Developer); OverrideCameraFarPlaneDistanceInside = OverrideCameraMaxDistance; } } } [Serializable] public class GlobalPropCountOverride { public int globalPropID; [Range(0f, 1f)] public float globalPropCountScaleRate; } [Serializable] public class DungeonEvents { public ExtendedEvent onBeforeDungeonGenerate = new ExtendedEvent(); public ExtendedEvent onShipLand = new ExtendedEvent(); public ExtendedEvent onShipLeave = new ExtendedEvent(); public ExtendedEvent> onSpawnedSyncedObjects = new ExtendedEvent>(); public ExtendedEvent> onSpawnedMapObjects = new ExtendedEvent>(); public ExtendedEvent> onSpawnedScrapObjects = new ExtendedEvent>(); public ExtendedEvent<(EnemyVent, EnemyAI)> onEnemySpawnedFromVent = new ExtendedEvent<(EnemyVent, EnemyAI)>(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent onPowerSwitchToggle = new ExtendedEvent(); public ExtendedEvent onApparatusTaken = new ExtendedEvent(); } [CreateAssetMenu(fileName = "ExtendedEnemyType", menuName = "Lethal Level Loader/Extended Content/ExtendedEnemyType", order = 24)] public class ExtendedEnemyType : ExtendedContent { [field: Header("General Settings")] [field: SerializeField] public EnemyType EnemyType { get; set; } [field: SerializeField] public string EnemyDisplayName { get; set; } [field: Space(5f)] [field: Header("Dynamic Injection Matching Settings")] [field: SerializeField] public LevelMatchingProperties OutsideLevelMatchingProperties { get; set; } [field: SerializeField] public DungeonMatchingProperties OutsideDungeonMatchingProperties { get; set; } [field: SerializeField] public LevelMatchingProperties DaytimeLevelMatchingProperties { get; set; } [field: SerializeField] public DungeonMatchingProperties DaytimeDungeonMatchingProperties { get; set; } [field: SerializeField] public LevelMatchingProperties InsideLevelMatchingProperties { get; set; } [field: SerializeField] public DungeonMatchingProperties InsideDungeonMatchingProperties { get; set; } [field: Space(5f)] [field: Header("Terminal Bestiary Override Settings")] [field: SerializeField] [field: TextArea(2, 20)] public string InfoNodeDescription { get; set; } = string.Empty; [field: SerializeField] public VideoClip InfoNodeVideoClip { get; set; } public ScanNodeProperties ScanNodeProperties { get; internal set; } public int EnemyID { get; internal set; } public TerminalNode EnemyInfoNode { get; internal set; } public static ExtendedEnemyType Create(EnemyType enemyType, ExtendedMod extendedMod, ContentType contentType) { ExtendedEnemyType extendedEnemyType = ScriptableObject.CreateInstance(); extendedEnemyType.EnemyType = enemyType; ((Object)extendedEnemyType).name = enemyType.enemyName.Sanitized(toLower: false) + "ExtendedEnemyType"; extendedEnemyType.ContentType = contentType; extendedMod.RegisterExtendedContent(extendedEnemyType); extendedEnemyType.TryCreateMatchingProperties(); return extendedEnemyType; } public void Initalize() { DebugHelper.Log("Initializing Custom Enemy: " + EnemyType.enemyName, DebugType.Developer); TryCreateMatchingProperties(); ContentRestorer.RestoreAudioAssetReferencesInParent(EnemyType.enemyPrefab); } internal override void TryCreateMatchingProperties() { if ((Object)(object)InsideLevelMatchingProperties == (Object)null) { InsideLevelMatchingProperties = LevelMatchingProperties.Create(this); } if ((Object)(object)InsideDungeonMatchingProperties == (Object)null) { InsideDungeonMatchingProperties = DungeonMatchingProperties.Create(this); } if ((Object)(object)OutsideLevelMatchingProperties == (Object)null) { OutsideLevelMatchingProperties = LevelMatchingProperties.Create(this); } if ((Object)(object)OutsideDungeonMatchingProperties == (Object)null) { OutsideDungeonMatchingProperties = DungeonMatchingProperties.Create(this); } if ((Object)(object)DaytimeLevelMatchingProperties == (Object)null) { DaytimeLevelMatchingProperties = LevelMatchingProperties.Create(this); } if ((Object)(object)DaytimeDungeonMatchingProperties == (Object)null) { DaytimeDungeonMatchingProperties = DungeonMatchingProperties.Create(this); } } internal override (bool result, string log) TryValidateContent() { if ((Object)(object)EnemyType == (Object)null) { return (result: false, log: "EnemyType Was Null"); } if ((Object)(object)EnemyType.enemyPrefab == (Object)null) { return (result: false, log: "EnemyPrefab Was Null"); } if (!Object.op_Implicit((Object)(object)EnemyType.enemyPrefab.GetComponent())) { return (result: false, log: "EnemyPrefab Did Not Contain A NetworkObject"); } EnemyAI componentInChildren = EnemyType.enemyPrefab.GetComponentInChildren(false); if ((Object)(object)componentInChildren == (Object)null) { return (result: false, log: "EnemyPrefab Did Not Contain A Component Deriving From EnemyAI"); } if ((Object)(object)componentInChildren.enemyType == (Object)null) { return (result: false, log: "EnemyAI.enemyType Was Null"); } if ((Object)(object)componentInChildren.enemyType != (Object)(object)EnemyType) { return (result: false, log: "EnemyAI.enemyType Did Not Match ExtendedEnemyType.EnemyType"); } return base.TryValidateContent(); } } [CreateAssetMenu(fileName = "ExtendedFootstepSurface", menuName = "Lethal Level Loader/Extended Content/ExtendedFootstepSurface", order = 27)] public class ExtendedFootstepSurface : ExtendedContent { [Space(25f)] [Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")] [Obsolete] public FootstepSurface footstepSurface; [Obsolete] public List associatedMaterials; [field: Header("General Settings")] [field: SerializeField] public FootstepSurface FootstepSurface { get; set; } [field: Header("Extended Feature Settings")] [field: Tooltip("Allow Quicksand to affect players while on this ExtendedFootstepSurface.")] [field: SerializeField] public bool AllowSinking { get; set; } = true; [field: Tooltip("Allow Earth Leviathans to emerge out of this ExtendedFootstepSurface.")] [field: SerializeField] public bool AllowEarthLeviathanEmerge { get; set; } = true; [field: Tooltip("Allow Masked to use this ExtendedFootstepSurface, otherwise GameObject tag is used.")] [field: SerializeField] public bool AllowMaskedFootsteps { get; set; } = true; [HideInInspector] public Dictionary AssociatedTerrainNames { get; } = new Dictionary(); [HideInInspector] public int SurfaceIndex { get; internal set; } = -1; internal static ExtendedFootstepSurface Create(FootstepSurface newFootstepSurface, bool allowSinking, params TerrainWithIndices[] newAssociatedTerrains) { ExtendedFootstepSurface extendedFootstepSurface = ScriptableObject.CreateInstance(); extendedFootstepSurface.FootstepSurface = newFootstepSurface; extendedFootstepSurface.AllowSinking = allowSinking; for (int i = 0; i < newAssociatedTerrains?.Length; i++) { TerrainWithIndices terrainWithIndices = newAssociatedTerrains[i]; if (!string.IsNullOrEmpty(terrainWithIndices.terrainName)) { int[] layerIndices = terrainWithIndices.layerIndices; if (layerIndices != null && layerIndices.Length != 0) { extendedFootstepSurface.AssociatedTerrainNames[terrainWithIndices.terrainName] = terrainWithIndices.GetIndexMask(); } } } return extendedFootstepSurface; } internal void Initialize() { ((Object)this).name = FootstepSurface.surfaceTag.Sanitized(toLower: false) + "ExtendedFootstepSurface"; if (base.ContentType == ContentType.Custom) { string text = base.ExtendedMod.ModMergeSetting switch { ModMergeSetting.MatchingAuthorName => base.ExtendedMod.AuthorName, ModMergeSetting.MatchingModName => base.ExtendedMod.ModName, _ => base.UniqueIdentificationName, }; FootstepSurface.surfaceTag = text + "/" + FootstepSurface.surfaceTag; } } internal bool IsTerrainMatch(TerrainData terrainData) { return AssociatedTerrainNames.ContainsKey(((Object)terrainData).name); } internal bool IsTerrainMatch(TerrainData terrainData, int terrainLayer) { if (AssociatedTerrainNames.TryGetValue(((Object)terrainData).name, out var value)) { return ((byte)(1 << terrainLayer) & value) != 0; } return false; } internal override (bool result, string log) TryValidateContent() { if (FootstepSurface == null) { return (result: false, log: "FootstepSurface Was Null"); } if (string.IsNullOrEmpty(FootstepSurface.surfaceTag)) { FootstepSurface.surfaceTag = "Untagged"; } return base.TryValidateContent(); } internal override void ConvertObsoleteValues() { //IL_005a: 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) //IL_0070: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown if (footstepSurface == null) { return; } AudioClip[] clips = footstepSurface.clips; if (clips == null || clips.Length == 0) { AudioClip[] jumpLandSFX = footstepSurface.jumpLandSFX; if ((jumpLandSFX == null || jumpLandSFX.Length == 0) && !((Object)(object)footstepSurface.hitSurfaceSFX != (Object)null)) { return; } } DebugHelper.LogWarning("ExtendedFootstepSurface.footstepSurface is Obsolete and will be removed in following releases, Please use ExtendedFootstepSurface.FootstepSurface instead.", DebugType.Developer); FootstepSurface = new FootstepSurface { surfaceTag = footstepSurface.surfaceTag, clips = (footstepSurface.clips ?? Array.Empty()).ToArray(), hitSurfaceSFX = footstepSurface.hitSurfaceSFX, jumpLandSFX = (footstepSurface.jumpLandSFX ?? Array.Empty()).ToArray() }; footstepSurface = null; } } [Serializable] public struct TerrainWithIndices { public string terrainName; [Range(0f, 7f)] public int[] layerIndices; public TerrainWithIndices(string terrainName, params int[] layerIndices) { this.terrainName = terrainName; this.layerIndices = layerIndices; } public readonly byte GetIndexMask() { HashSet hashSet = new HashSet(); int[] array = layerIndices; foreach (int item in array) { hashSet.Add(item); } HashSet hashSet2 = hashSet; int num = hashSet2.RemoveWhere((int index) => (index < 0 || index > 7) ? true : false); if (num > 0) { DebugHelper.LogWarning($"Removed {num} indices for Terrain: {terrainName}", DebugType.Developer); } byte b = 0; foreach (int item2 in hashSet2) { b += (byte)(1 << item2); } return b; } } public enum VanillaSurfaceTags : sbyte { None = -1, Concrete, Gravel, Catwalk, Aluminum, Grass, Rock, Puddle, Tiles, Snow, Carpet, Untagged, Wood, Slime, Tree } [CreateAssetMenu(fileName = "ExtendedItem", menuName = "Lethal Level Loader/Extended Content/ExtendedItem", order = 23)] public class ExtendedItem : ExtendedContent { [field: Header("General Settings")] [field: SerializeField] public Item Item { get; set; } [field: SerializeField] public string PluralisedItemName { get; set; } = string.Empty; [field: SerializeField] public bool IsBuyableItem { get; set; } [field: Space(5f)] [field: Header("Dynamic Injection Matching Settings")] [field: SerializeField] public LevelMatchingProperties LevelMatchingProperties { get; set; } [field: SerializeField] public DungeonMatchingProperties DungeonMatchingProperties { get; set; } [field: Space(5f)] [field: Header("Terminal Store & Info Override Settings")] [field: SerializeField] public string OverrideInfoNodeDescription { get; set; } = string.Empty; [field: SerializeField] public string OverrideBuyNodeDescription { get; set; } = string.Empty; [field: SerializeField] public string OverrideBuyConfirmNodeDescription { get; set; } = string.Empty; public TerminalNode BuyNode { get; internal set; } public TerminalNode BuyConfirmNode { get; internal set; } public TerminalNode BuyInfoNode { get; internal set; } public int CreditsWorth { get { if ((Object)(object)BuyNode != (Object)null && (Object)(object)BuyConfirmNode != (Object)null) { BuyNode.itemCost = Item.creditsWorth; BuyConfirmNode.itemCost = Item.creditsWorth; } else { Debug.LogWarning((object)"BuyNode And/Or BuyConfirm Node Missing!"); } return Item.creditsWorth; } set { if (value >= 0) { if ((Object)(object)BuyNode != (Object)null && (Object)(object)BuyConfirmNode != (Object)null) { BuyNode.itemCost = value; BuyConfirmNode.itemCost = value; } else { Debug.LogWarning((object)"BuyNode And/Or BuyConfirm Node Missing!"); } Item.creditsWorth = value; } } } public static ExtendedItem Create(Item newItem, ExtendedMod extendedMod, ContentType contentType) { ExtendedItem extendedItem = ScriptableObject.CreateInstance(); extendedItem.Item = newItem; ((Object)extendedItem).name = newItem.itemName.Sanitized(toLower: false) + "ExtendedItem"; extendedItem.ContentType = contentType; extendedMod.RegisterExtendedContent(extendedItem); extendedItem.TryCreateMatchingProperties(); return extendedItem; } public void Initialize() { DebugHelper.Log("Initializing Custom Item: " + Item.itemName + ". Is Buyable: " + IsBuyableItem + ". Is Scrap: " + Item.isScrap, DebugType.Developer); TryCreateMatchingProperties(); if (!Patches.StartOfRound.allItemsList.itemsList.Contains(Item)) { Patches.StartOfRound.allItemsList.itemsList.Add(Item); } if (IsBuyableItem) { TerminalManager.CreateItemTerminalData(this); } for (int i = 0; i < Item.spawnPositionTypes?.Count; i++) { ItemGroup targetItemGroup = Item.spawnPositionTypes[i]; if ((Object)(object)targetItemGroup != (Object)null) { ItemGroup val = OriginalContent.ItemGroups.Find((ItemGroup itemGroup) => string.Equals(((Object)itemGroup).name, ((Object)targetItemGroup).name, StringComparison.Ordinal)); if ((Object)(object)val != (Object)null) { Item.spawnPositionTypes[i] = ContentRestorer.RestoreAsset((Object)(object)targetItemGroup, val, debugAction: false, destroyOnReplace: true); } } } ContentRestorer.RestoreAudioAssetReferencesInParent(Item.spawnPrefab); } internal override void TryCreateMatchingProperties() { if ((Object)(object)LevelMatchingProperties == (Object)null) { LevelMatchingProperties = LevelMatchingProperties.Create(this); } if ((Object)(object)DungeonMatchingProperties == (Object)null) { DungeonMatchingProperties = DungeonMatchingProperties.Create(this); } } internal override (bool result, string log) TryValidateContent() { if ((Object)(object)Item == (Object)null) { return (result: false, log: "Item Was Null"); } if ((Object)(object)Item.spawnPrefab == (Object)null) { return (result: false, log: "SpawnPrefab Was Null"); } return base.TryValidateContent(); } public void SetLevelMatchingProperties(LevelMatchingProperties newLevelMatchingProperties) { if ((Object)(object)Plugin.Instance != (Object)null) { Debug.LogError((object)"SetLevelMatchingProperties() Should Only Be Used In Editor!"); } LevelMatchingProperties = newLevelMatchingProperties; } } [CreateAssetMenu(fileName = "ExtendedLevel", menuName = "Lethal Level Loader/Extended Content/ExtendedLevel", order = 20)] public class ExtendedLevel : ExtendedContent { [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct ExtendedLevelDifficultyComparer : IComparer { public readonly int Compare(ExtendedLevel a, ExtendedLevel b) { return a.CalculatedDifficultyRating - b.CalculatedDifficultyRating; } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct ExtendedLevelRoutePriceComparer : IComparer { public readonly int Compare(ExtendedLevel a, ExtendedLevel b) { return a.RoutePrice - b.RoutePrice; } } [Space(5f)] [SerializeField] [Min(0f)] private int routePrice; [Space(25f)] [Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")] [Obsolete] public SelectableLevel selectableLevel; [Obsolete] [Range(0.1f, 10000f)] public float OverrideCameraMaxDistance = 400f; [Obsolete] [Space(5f)] public string contentSourceName = string.Empty; [Obsolete] [Space(5f)] public List levelTags = new List(); [CompilerGenerated] private string k__BackingField; [CompilerGenerated] private int k__BackingField; [field: Header("General Settings")] [field: SerializeField] public SelectableLevel SelectableLevel { get; set; } [field: Header("Extended Feature Settings")] [field: SerializeField] public bool OverrideDynamicRiskLevelAssignment { get; set; } [field: Tooltip("Enable to use Terrain layers for Player footstep sound effects instead of GameObject tags, when applicable. Disabled by default for older moons to keep their intended (original) footstep sounds.")] [field: SerializeField] public bool UseTerrainFootsteps { get; set; } [field: Space(5f)] [field: SerializeField] public bool IsRouteHidden { get; set; } [field: SerializeField] public bool IsRouteLocked { get; set; } public bool IsRouteRemoved { get; set; } [field: SerializeField] public string LockedRouteNodeText { get; set; } = string.Empty; [field: Space(5f)] [field: SerializeField] public List ShipFlyToMoonClips { get; set; } = new List(); [field: SerializeField] public List ShipFlyFromMoonClips { get; set; } = new List(); [field: Space(5f)] [field: SerializeField] public List SceneSelections { get; set; } = new List(); [field: Space(5f)] [field: Tooltip("Overrides Vanilla Camera Far Plane Clip Distance Outside.")] [field: Range(0.1f, 10000f)] [field: SerializeField] public float OverrideCameraFarPlaneDistanceOutside { get; set; } = 400f; [field: Space(5f)] [field: Tooltip("Overrides Vanilla Camera Far Plane Clip Distance In Orbit.")] [field: Range(0.1f, 10000f)] [field: SerializeField] public float OverrideCameraFarPlaneDistanceInOrbit { get; set; } = 400f; [field: Space(5f)] [field: Header("Weather Effect Override Settings")] [field: SerializeField] public Vector3 OverrideDustStormVolumeSize { get; set; } = Vector3.zero; [field: Space(5f)] [field: SerializeField] public GameObject OverrideQuicksandPrefab { get; set; } [field: SerializeField] public GameObject OverrideRainPrefab { get; set; } [field: SerializeField] public AudioClip OverrideRainAmbience { get; set; } [field: Space(5f)] [field: SerializeField] public ParticleSystem OverrideStormyLightningStrikeExplosion { get; set; } [field: SerializeField] public ParticleSystem OverrideStormyStaticElectricityParticle { get; set; } [field: SerializeField] public AudioClip[] OverrideStormyLightningStrikeSFX { get; set; } [field: SerializeField] public AudioClip[] OverrideStormyDistantThunderSFX { get; set; } [field: SerializeField] public AudioClip OverrideStormyStaticElectricitySFX { get; set; } [field: Space(5f)] [field: SerializeField] public GameObject OverrideStormyRainPrefab { get; set; } [field: SerializeField] public AudioClip OverrideStormyRainAmbience { get; set; } [field: Space(5f)] [field: SerializeField] public Vector3 OverrideFoggyVolumeSize { get; set; } = Vector3.zero; [field: Space(5f)] [field: SerializeField] public GameObject OverrideFloodedPrefab { get; set; } [field: SerializeField] public AudioClip OverrideFloodedAmbience { get; set; } [field: Space(5f)] [field: SerializeField] public AudioClip OverrideEclipsedMusic { get; set; } [field: Space(5f)] [field: Header("Time Of Day Music Override Settings")] [field: SerializeField] public AudioClip OverrideStartOfDayMusic { get; set; } [field: SerializeField] public AudioClip OverrideMidDayMusic { get; set; } [field: SerializeField] public AudioClip OverrideLateDayMusic { get; set; } [field: SerializeField] public AudioClip OverrideNightMusic { get; set; } [field: Space(5f)] [field: Header("Entrance Teleport SFX Override Settings")] [field: SerializeField] public AudioClip[] OverrideCreakOpenDoorSFX { get; set; } [field: SerializeField] public AudioClip[] OverrideCreakShutDoorSFX { get; set; } [field: Space(5f)] [field: Header("Terminal Route Override Settings")] [field: SerializeField] public string OverrideRouteNoun { get; set; } = string.Empty; [field: SerializeField] [field: TextArea(2, 20)] public string OverrideInfoNodeDescription { get; set; } = string.Empty; [field: SerializeField] [field: TextArea(2, 20)] public string OverrideRouteNodeDescription { get; set; } = string.Empty; [field: SerializeField] [field: TextArea(2, 20)] public string OverrideRouteConfirmNodeDescription { get; set; } = string.Empty; [field: Space(10f)] [field: Header("Misc. Settings")] [field: Space(5f)] [field: SerializeField] public bool GenerateAutomaticConfigurationOptions { get; set; } = true; [Obsolete] [field: SerializeField] public AnimationClip ShipFlyToMoonClip { get; set; } [Obsolete] [field: SerializeField] public AnimationClip ShipFlyFromMoonClip { get; set; } public int RoutePrice { get { if ((Object)(object)RouteNode != (Object)null) { routePrice = RouteNode.itemCost; RouteConfirmNode.itemCost = routePrice; return RouteNode.itemCost; } DebugHelper.LogWarning("routeNode Is Missing! Using internal value!", DebugType.Developer); return routePrice; } set { if ((Object)(object)RouteNode != (Object)null && (Object)(object)RouteConfirmNode != (Object)null) { RouteNode.itemCost = value; RouteConfirmNode.itemCost = value; } else { DebugHelper.LogWarning("routeNode Is Missing! Only setting internal value!", DebugType.Developer); } routePrice = value; } } public string TerminalNoun { get { if (!string.IsNullOrEmpty(OverrideRouteNoun)) { return OverrideRouteNoun.StripSpecialCharacters().RemoveWhitespace().ToLowerInvariant(); } return NumberlessPlanetName.StripSpecialCharacters().RemoveWhitespace().ToLowerInvariant(); } } public string NumberlessPlanetName { get { if (string.IsNullOrEmpty(k__BackingField)) { k__BackingField = GetNumberlessPlanetName(SelectableLevel); } return k__BackingField; } } public int CalculatedDifficultyRating { get { if (k__BackingField == 0) { k__BackingField = LevelManager.CalculateExtendedLevelDifficultyRating(this); } return k__BackingField; } } public bool IsCurrentLevel => (Object)(object)LevelManager.CurrentExtendedLevel == (Object)(object)this; public bool IsLevelLoaded { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (IsCurrentLevel) { Scene sceneByName = SceneManager.GetSceneByName(SelectableLevel.sceneName); return ((Scene)(ref sceneByName)).isLoaded; } return false; } } [HideInInspector] public LevelEvents LevelEvents { get; internal set; } = new LevelEvents(); public TerminalNode RouteNode { get; internal set; } public TerminalNode RouteConfirmNode { get; internal set; } public TerminalNode InfoNode { get; internal set; } public TerminalNode SimulateNode { get; internal set; } public List EnabledExtendedWeatherEffects { get; set; } = new List(); public ExtendedWeatherEffect CurrentExtendedWeatherEffect { get; set; } internal static ExtendedLevel Create(SelectableLevel newSelectableLevel) { ExtendedLevel extendedLevel = ScriptableObject.CreateInstance(); extendedLevel.SelectableLevel = newSelectableLevel; return extendedLevel; } internal void Initialize(string _, bool generateTerminalAssets) { if (SceneSelections.Find((StringWithRarity scene) => string.Equals(scene.Name, ((Object)SelectableLevel).name, StringComparison.Ordinal)) == null) { StringWithRarity item = new StringWithRarity(SelectableLevel.sceneName, 300); SceneSelections.Add(item); } foreach (StringWithRarity item2 in new List(SceneSelections)) { if (!PatchedContent.AllLevelSceneNames.Contains(item2.Name)) { DebugHelper.LogWarning("Removing SceneSelection From: " + SelectableLevel.PlanetName + " As SceneName: " + item2.Name + " Is Not Loaded!", DebugType.Developer); SceneSelections.Remove(item2); } } if (ShipFlyToMoonClips.Count > 0) { for (int num = 0; num < ShipFlyToMoonClips.Count; num++) { if ((Object)(object)ShipFlyToMoonClips[num].Clip == (Object)null) { ShipFlyToMoonClips[num] = new ClipWithRarity(LevelLoader.defaultShipFlyToMoonClip, ShipFlyToMoonClips[num].Rarity); } } } else { ShipFlyToMoonClips.Add(new ClipWithRarity(LevelLoader.defaultShipFlyToMoonClip, 300)); } if (ShipFlyFromMoonClips.Count > 0) { for (int num2 = 0; num2 < ShipFlyFromMoonClips.Count; num2++) { if ((Object)(object)ShipFlyFromMoonClips[num2].Clip == (Object)null) { ShipFlyFromMoonClips[num2] = new ClipWithRarity(LevelLoader.defaultShipFlyFromMoonClip, ShipFlyFromMoonClips[num2].Rarity); } } } else { ShipFlyFromMoonClips.Add(new ClipWithRarity(LevelLoader.defaultShipFlyFromMoonClip, 300)); } if ((Object)(object)OverrideStartOfDayMusic == (Object)null) { OverrideStartOfDayMusic = LevelLoader.defaultStartOfDayMusic; } if ((Object)(object)OverrideMidDayMusic == (Object)null) { OverrideMidDayMusic = LevelLoader.defaultMidDayMusic; } if ((Object)(object)OverrideLateDayMusic == (Object)null) { OverrideLateDayMusic = LevelLoader.defaultLateDayMusic; } if ((Object)(object)OverrideNightMusic == (Object)null) { OverrideNightMusic = LevelLoader.defaultNightMusic; } ContentType contentType = base.ContentType; if ((contentType == ContentType.Custom || contentType == ContentType.External) ? true : false) { ((Object)this).name = NumberlessPlanetName.StripSpecialCharacters() + "ExtendedLevel"; ((Object)SelectableLevel).name = NumberlessPlanetName.StripSpecialCharacters() + "Level"; if (generateTerminalAssets) { TerminalManager.CreateLevelTerminalData(this, routePrice); } } if (base.ContentType == ContentType.External) { OverrideDynamicRiskLevelAssignment = true; UseTerrainFootsteps = false; } SelectableLevel val = SelectableLevel; if (val.spawnableMapObjects == null) { val.spawnableMapObjects = Array.Empty(); } val = SelectableLevel; if (val.indoorMapHazards == null) { val.indoorMapHazards = Array.Empty(); } if (base.ContentType == ContentType.Vanilla) { GetVanillaInfoNode(); } SetExtendedDungeonFlowMatches(); } internal override (bool result, string log) TryValidateContent() { int num = SceneSelections.RemoveAll((StringWithRarity sceneSelection) => sceneSelection == null || string.IsNullOrEmpty(sceneSelection.Name)); if (num > 0) { DebugHelper.LogWarning($"Removed '{num}' missing or empty scene selections in ExtendedLevel: {((Object)this).name}", DebugType.User); } int num2 = ShipFlyToMoonClips.RemoveAll((ClipWithRarity clipSelection) => clipSelection.Rarity == 0); if (num2 > 0) { DebugHelper.LogWarning($"Removed '{num2}' zero-rarity ShipFlyToMoon clip overrides in ExtendedLevel: {((Object)this).name}", DebugType.User); } int num3 = ShipFlyFromMoonClips.RemoveAll((ClipWithRarity clipSelection) => clipSelection.Rarity == 0); if (num3 > 0) { DebugHelper.LogWarning($"Removed '{num3}' zero-rarity ShipFlyFromMoon clip overrides in ExtendedLevel: {((Object)this).name}", DebugType.User); } if ((Object)(object)SelectableLevel == (Object)null) { return (result: false, log: "SelectableLevel Was Null"); } if (string.IsNullOrEmpty(SelectableLevel.sceneName)) { return (result: false, log: "SelectableLevel SceneName Was Null Or Empty"); } if ((Object)(object)SelectableLevel.planetPrefab == (Object)null) { return (result: false, log: "SelectableLevel PlanetPrefab Was Null"); } Animator val = default(Animator); if (!SelectableLevel.planetPrefab.TryGetComponent(ref val)) { return (result: false, log: "SelectableLevel PlanetPrefab Animator Was Null"); } if ((Object)(object)val.runtimeAnimatorController == (Object)null) { return (result: false, log: "SelectableLevel PlanetPrefab Animator AnimatorController Was Null"); } return base.TryValidateContent(); } internal override void ConvertObsoleteValues() { if (levelTags.Count > 0 && base.ContentTags.Count == 0) { DebugHelper.LogWarning("ExtendedLevel.levelTags Is Obsolete and will be removed in following releases, Please use .ContentTags instead.", DebugType.Developer); foreach (ContentTag item in ContentTagManager.CreateNewContentTags(levelTags)) { base.ContentTags.Add(item); } } levelTags.Clear(); if ((Object)(object)SelectableLevel == (Object)null && (Object)(object)selectableLevel != (Object)null) { DebugHelper.LogWarning("ExtendedLevel.selectableLevel Is Obsolete and will be removed in following releases, Please use .SelectableLevel instead.", DebugType.Developer); SelectableLevel = selectableLevel; } if (!string.IsNullOrEmpty(contentSourceName)) { DebugHelper.LogWarning("ExtendedLevel.contentSourceName is Obsolete and will be removed in following releases, Please use ExtendedMod.AuthorName instead.", DebugType.Developer); } if ((Object)(object)ShipFlyToMoonClip != (Object)null) { DebugHelper.LogWarning("ExtendedLevel.ShipFlyToMoonClip Is Obsolete and will be removed in following releases, Please use ExtendedLevel.ShipFlyToMoonClips instead.", DebugType.Developer); if (ShipFlyToMoonClips.Count == 0) { ShipFlyToMoonClips.Add(new ClipWithRarity(ShipFlyToMoonClip, 300)); } } if ((Object)(object)ShipFlyFromMoonClip != (Object)null) { DebugHelper.LogWarning("ExtendedLevel.ShipFlyFromMoonClip Is Obsolete and will be removed in following releases, Please use ExtendedLevel.ShipFlyFromMoonClips instead.", DebugType.Developer); if (ShipFlyFromMoonClips.Count == 0) { ShipFlyFromMoonClips.Add(new ClipWithRarity(ShipFlyFromMoonClip, 300)); } } if (OverrideCameraMaxDistance != 400f && OverrideCameraFarPlaneDistanceOutside == 400f && OverrideCameraFarPlaneDistanceInOrbit == 400f) { DebugHelper.LogWarning("ExtendedLevel.OverrideCameraMaxDistance Is Obsolete and will be removed in following releases, Please use ExtendedLevel.OverrideCameraFarPlaneDistanceOutside instead.", DebugType.Developer); OverrideCameraFarPlaneDistanceOutside = OverrideCameraMaxDistance; OverrideCameraFarPlaneDistanceInOrbit = OverrideCameraMaxDistance; } } internal static string GetNumberlessPlanetName(SelectableLevel selectableLevel) { if (!((Object)(object)selectableLevel != (Object)null) || string.IsNullOrEmpty(selectableLevel.PlanetName)) { return string.Empty; } return selectableLevel.PlanetName.SkipToLetters(); } internal void SetLevelID(int levelId) { if (base.ContentType == ContentType.Custom) { SelectableLevel.levelID = levelId; if ((Object)(object)RouteNode != (Object)null) { RouteNode.displayPlanetInfo = levelId; } if ((Object)(object)RouteConfirmNode != (Object)null) { RouteConfirmNode.buyRerouteToMoon = levelId; } } } internal void SetExtendedDungeonFlowMatches() { List list = SelectableLevel.dungeonFlowTypes.ToList(); for (int i = 0; i < list.Count; i++) { IntWithRarity dungeonWithRarity = list[i]; if (dungeonWithRarity != null) { ExtendedDungeonFlow extendedDungeonFlow = PatchedContent.ExtendedDungeonFlows.Find((ExtendedDungeonFlow extendedDungeonFlow3) => extendedDungeonFlow3.DungeonID == dungeonWithRarity.id); if ((Object)(object)extendedDungeonFlow != (Object)null) { extendedDungeonFlow.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, dungeonWithRarity.rarity)); continue; } } Debug.LogWarning((object)$"Invalid DungeonFlow entry at index '{i}' for SelectableLevel: {((Object)SelectableLevel).name}"); list.RemoveAt(i--); } if (string.Equals(((Object)SelectableLevel).name, "MarchLevel", StringComparison.Ordinal)) { ExtendedDungeonFlow extendedDungeonFlow2 = PatchedContent.ExtendedDungeonFlows.Find((ExtendedDungeonFlow extendedDungeonFlow3) => string.Equals(((Object)extendedDungeonFlow3.DungeonFlow).name, "Level1Flow3Exits", StringComparison.Ordinal)); if ((Object)(object)extendedDungeonFlow2 != (Object)null) { extendedDungeonFlow2.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, 300)); } } SelectableLevel.dungeonFlowTypes = list.ToArray(); } internal void GetVanillaInfoNode() { CompatibleNoun[] compatibleNouns = TerminalManager.routeInfoKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { if (string.Equals(val.noun.word, NumberlessPlanetName, StringComparison.OrdinalIgnoreCase)) { InfoNode = val.result; break; } } } public void ForceSetRoutePrice(int newValue) { if ((Object)(object)Plugin.Instance != (Object)null) { Debug.LogWarning((object)"ForceSetRoutePrice Should Only Be Used In Editor! Consider Using RoutePrice Property To Sync TerminalNode's With New Value."); } routePrice = newValue; } } [Serializable] public class LevelEvents { public ExtendedEvent onLevelLoaded = new ExtendedEvent(); public ExtendedEvent onShipLand = new ExtendedEvent(); public ExtendedEvent onShipLeave = new ExtendedEvent(); public ExtendedEvent onDaytimeEnemySpawn = new ExtendedEvent(); public ExtendedEvent onNighttimeEnemySpawn = new ExtendedEvent(); public ExtendedEvent onStoryLogCollected = new ExtendedEvent(); public ExtendedEvent onApparatusTaken = new ExtendedEvent(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent onPowerSwitchToggle = new ExtendedEvent(); public ExtendedEvent onDayModeToggle = new ExtendedEvent(); } public enum ModMergeSetting { MatchingAuthorName, MatchingModName, Disabled } [CreateAssetMenu(fileName = "ExtendedMod", menuName = "Lethal Level Loader/ExtendedMod", order = 30)] public class ExtendedMod : ScriptableObject { [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct ExtendedModComparer : IComparer { public readonly int Compare(ExtendedMod a, ExtendedMod b) { return string.Compare(a.ModName, b.ModName, StringComparison.OrdinalIgnoreCase); } } [CompilerGenerated] private static ContentTag k__BackingField; [CompilerGenerated] private static ContentTag k__BackingField; [field: SerializeField] public string ModName { get; internal set; } = "Unspecified"; [field: SerializeField] public string AuthorName { get; internal set; } = "Unknown"; public List ModNameAliases { get; internal set; } = new List(); [field: SerializeField] public ModMergeSetting ModMergeSetting { get; internal set; } [field: SerializeField] public List ExtendedLevels { get; private set; } = new List(); [field: SerializeField] public List ExtendedDungeonFlows { get; private set; } = new List(); [field: SerializeField] public List ExtendedItems { get; private set; } = new List(); [field: SerializeField] public List ExtendedEnemyTypes { get; private set; } = new List(); [field: SerializeField] public List ExtendedWeatherEffects { get; private set; } = new List(); [field: SerializeField] public List ExtendedFootstepSurfaces { get; private set; } = new List(); [field: SerializeField] public List ExtendedStoryLogs { get; private set; } = new List(); [field: SerializeField] public List ExtendedBuyableVehicles { get; private set; } = new List(); [field: SerializeField] public List ExtendedUnlockableItems { get; private set; } = new List(); [field: SerializeField] public List StreamingLethalBundleNames { get; private set; } = new List(); public static ContentTag VanillaContentTag { get { if ((Object)(object)k__BackingField == (Object)null) { k__BackingField = ContentTag.Create("Vanilla"); } return k__BackingField; } } public static ContentTag CustomContentTag { get { if ((Object)(object)k__BackingField == (Object)null) { k__BackingField = ContentTag.Create("Custom"); } return k__BackingField; } } public List ExtendedContents { get { List list = new List(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { list.Add(extendedLevel); } foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { list.Add(extendedDungeonFlow); } foreach (ExtendedItem extendedItem in ExtendedItems) { list.Add(extendedItem); } foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes) { list.Add(extendedEnemyType); } foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects) { list.Add(extendedWeatherEffect); } foreach (ExtendedFootstepSurface extendedFootstepSurface in ExtendedFootstepSurfaces) { list.Add(extendedFootstepSurface); } foreach (ExtendedStoryLog extendedStoryLog in ExtendedStoryLogs) { list.Add(extendedStoryLog); } foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles) { list.Add(extendedBuyableVehicle); } foreach (ExtendedUnlockableItem extendedUnlockableItem in ExtendedUnlockableItems) { list.Add(extendedUnlockableItem); } return list; } } internal static ExtendedMod Create(string modName) { ExtendedMod extendedMod = ScriptableObject.CreateInstance(); extendedMod.ModName = modName; ((Object)extendedMod).name = modName.Sanitized(toLower: false) + "Mod"; DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName, DebugType.Developer); return extendedMod; } public static ExtendedMod Create(string modName, string authorName) { ExtendedMod extendedMod = ScriptableObject.CreateInstance(); extendedMod.ModName = modName; ((Object)extendedMod).name = modName.Sanitized(toLower: false) + "Mod"; extendedMod.AuthorName = authorName; if ((Object)(object)Plugin.Instance != (Object)null) { DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName + " by " + authorName, DebugType.Developer); } return extendedMod; } public static ExtendedMod Create(string modName, string authorName, ExtendedContent[] extendedContents) { ExtendedMod extendedMod = ScriptableObject.CreateInstance(); extendedMod.ModName = modName; ((Object)extendedMod).name = modName.Sanitized(toLower: false) + "Mod"; extendedMod.AuthorName = authorName; foreach (ExtendedContent newExtendedContent in extendedContents) { extendedMod.RegisterExtendedContent(newExtendedContent); } if ((Object)(object)Plugin.Instance != (Object)null) { DebugHelper.Log("Created New ExtendedMod: " + extendedMod.ModName + " by " + authorName, DebugType.Developer); } return extendedMod; } internal void RegisterExtendedContent(ExtendedContent newExtendedContent) { if ((Object)(object)newExtendedContent != (Object)null) { if (!ExtendedContents.Contains(newExtendedContent)) { if (newExtendedContent is ExtendedLevel extendedLevel) { RegisterExtendedContent(extendedLevel); return; } if (newExtendedContent is ExtendedDungeonFlow extendedDungeonFlow) { RegisterExtendedContent(extendedDungeonFlow); return; } if (newExtendedContent is ExtendedItem extendedItem) { RegisterExtendedContent(extendedItem); return; } if (newExtendedContent is ExtendedEnemyType extendedEnemyType) { RegisterExtendedContent(extendedEnemyType); return; } if (newExtendedContent is ExtendedWeatherEffect extendedWeatherEffect) { RegisterExtendedContent(extendedWeatherEffect); return; } if (newExtendedContent is ExtendedFootstepSurface extendedFootstepSurface) { RegisterExtendedContent(extendedFootstepSurface); return; } if (newExtendedContent is ExtendedStoryLog extendedStoryLog) { RegisterExtendedContent(extendedStoryLog); return; } if (newExtendedContent is ExtendedBuyableVehicle extendedBuyableVehicle) { RegisterExtendedContent(extendedBuyableVehicle); return; } if (newExtendedContent is ExtendedUnlockableItem extendedUnlockableItem) { RegisterExtendedContent(extendedUnlockableItem); return; } throw new ArgumentException(((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Unimplemented Registration Check!", "newExtendedContent"); } throw new ArgumentException(((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Already Being Registered To This Mod!", "newExtendedContent"); } throw new ArgumentNullException("newExtendedContent", "Null ExtendedContent Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check!"); } internal void RegisterExtendedContent(T extendedContent, List extendedContentList) where T : ExtendedContent { if ((Object)(object)extendedContent == (Object)null) { DebugHelper.LogError($"{((object)extendedContent).GetType()} Was Null", DebugType.User); return; } if (extendedContentList == null) { DebugHelper.LogError($"{((object)extendedContent).GetType()} Content List Was Null", DebugType.User); return; } extendedContent.ConvertObsoleteValues(); TryThrowInvalidContentException(extendedContent, extendedContent.TryValidateContent()); extendedContentList.Add(extendedContent); extendedContent.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedLevel extendedLevel) { RegisterExtendedContent(extendedLevel, ExtendedLevels); } internal void RegisterExtendedContent(ExtendedDungeonFlow extendedDungeonFlow) { RegisterExtendedContent(extendedDungeonFlow, ExtendedDungeonFlows); } internal void RegisterExtendedContent(ExtendedItem extendedItem) { RegisterExtendedContent(extendedItem, ExtendedItems); } internal void RegisterExtendedContent(ExtendedEnemyType extendedEnemyType) { RegisterExtendedContent(extendedEnemyType, ExtendedEnemyTypes); } internal void RegisterExtendedContent(ExtendedWeatherEffect extendedWeatherEffect) { RegisterExtendedContent(extendedWeatherEffect, ExtendedWeatherEffects); } internal void RegisterExtendedContent(ExtendedFootstepSurface extendedFootstepSurface) { RegisterExtendedContent(extendedFootstepSurface, ExtendedFootstepSurfaces); } internal void RegisterExtendedContent(ExtendedStoryLog extendedStoryLog) { RegisterExtendedContent(extendedStoryLog, ExtendedStoryLogs); } internal void RegisterExtendedContent(ExtendedBuyableVehicle extendedBuyableVehicle) { RegisterExtendedContent(extendedBuyableVehicle, ExtendedBuyableVehicles); } internal void RegisterExtendedContent(ExtendedUnlockableItem extendedUnlockableItem) { RegisterExtendedContent(extendedUnlockableItem, ExtendedUnlockableItems); } internal void TryThrowInvalidContentException(ExtendedContent extendedContent, (bool, string) result) { if (!result.Item1) { if ((Object)(object)extendedContent == (Object)null) { throw new ArgumentNullException("extendedContent", "Null ExtendedContent Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check! " + result.Item2); } throw new ArgumentException(((Object)extendedContent).name + " (" + ((object)extendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check! " + result.Item2, "extendedContent"); } } internal void UnregisterExtendedContent(ExtendedContent currentExtendedContent) { if (currentExtendedContent is ExtendedLevel item) { ExtendedLevels.Remove(item); } else if (currentExtendedContent is ExtendedDungeonFlow item2) { ExtendedDungeonFlows.Remove(item2); } else if (currentExtendedContent is ExtendedItem item3) { ExtendedItems.Remove(item3); } else if (currentExtendedContent is ExtendedUnlockableItem item4) { ExtendedUnlockableItems.Remove(item4); } currentExtendedContent.ExtendedMod = null; DebugHelper.LogWarning("Unregistered ExtendedContent: " + ((Object)currentExtendedContent).name + " In ExtendedMod: " + ModName, DebugType.Developer); } internal void UnregisterAllExtendedContent() { ExtendedLevels.Clear(); ExtendedDungeonFlows.Clear(); ExtendedItems.Clear(); ExtendedEnemyTypes.Clear(); ExtendedWeatherEffects.Clear(); ExtendedFootstepSurfaces.Clear(); ExtendedStoryLogs.Clear(); ExtendedBuyableVehicles.Clear(); ExtendedUnlockableItems.Clear(); } internal void SortRegisteredContent() { ExtendedContent.ExtendedContentComparer extendedContentComparer = default(ExtendedContent.ExtendedContentComparer); ExtendedLevels.Sort(extendedContentComparer); ExtendedDungeonFlows.Sort(extendedContentComparer); ExtendedItems.Sort(extendedContentComparer); ExtendedEnemyTypes.Sort(extendedContentComparer); ExtendedWeatherEffects.Sort(extendedContentComparer); ExtendedFootstepSurfaces.Sort(extendedContentComparer); ExtendedStoryLogs.Sort(extendedContentComparer); ExtendedBuyableVehicles.Sort(extendedContentComparer); ExtendedUnlockableItems.Sort(extendedContentComparer); } } [CreateAssetMenu(fileName = "ExtendedStoryLog", menuName = "Lethal Level Loader/Extended Content/ExtendedStoryLog", order = 26)] public class ExtendedStoryLog : ExtendedContent { public string sceneName = string.Empty; public int storyLogID; [Space(5f)] public string terminalKeywordNoun = string.Empty; [Space(5f)] public string storyLogTitle = string.Empty; [TextArea(2, 20)] public string storyLogDescription = string.Empty; [HideInInspector] internal int newStoryLogID; [HideInInspector] internal TerminalNode assignedNode; internal override (bool result, string log) TryValidateContent() { if (string.IsNullOrEmpty(sceneName)) { return (result: false, log: "StoryLog SceneName Was Null Or Empty"); } if (string.IsNullOrEmpty(terminalKeywordNoun)) { return (result: false, log: "StoryLog TerminalKeywordNoun Was Null Or Empty"); } if (string.IsNullOrEmpty(storyLogTitle)) { return (result: false, log: "StoryLog Title Was Null Or Empty"); } if (string.IsNullOrEmpty(storyLogDescription)) { return (result: false, log: "StoryLog Description Was Null Or Empty"); } return base.TryValidateContent(); } } [CreateAssetMenu(fileName = "ExtendedUnlockableItem", menuName = "Lethal Level Loader/Extended Content/ExtendedUnlockableItem", order = 21)] public class ExtendedUnlockableItem : ExtendedContent { [field: Header("General Settings")] [field: SerializeField] public UnlockableItem UnlockableItem { get; set; } [field: SerializeField] public int ItemCost { get; set; } [field: Space(5f)] [field: Header("Terminal Store & Info Override Settings")] [field: TextArea(2, 20)] [field: SerializeField] public string OverrideInfoNodeDescription { get; set; } = string.Empty; [field: TextArea(2, 20)] [field: SerializeField] public string OverrideBuyNodeDescription { get; set; } = string.Empty; [field: TextArea(2, 20)] [field: SerializeField] public string OverrideBuyConfirmNodeDescription { get; set; } = string.Empty; public int UnlockableItemID { get; set; } = -1; public TerminalNode BuyNode { get; internal set; } public TerminalNode BuyConfirmNode { get; internal set; } public TerminalNode BuyInfoNode { get; internal set; } public void Initialize() { TerminalManager.CreateUnlockableItemTerminalData(this); if (!Patches.StartOfRound.unlockablesList.unlockables.Contains(UnlockableItem)) { Patches.StartOfRound.unlockablesList.unlockables.Add(UnlockableItem); } if ((Object)(object)UnlockableItem.prefabObject == (Object)null) { ContentRestorer.RestoreAudioAssetReferencesInParent(UnlockableItem.prefabObject); } } internal static ExtendedUnlockableItem Create(UnlockableItem newUnlockableItem, ExtendedMod extendedMod, ContentType contentType) { ExtendedUnlockableItem extendedUnlockableItem = ScriptableObject.CreateInstance(); extendedUnlockableItem.UnlockableItem = newUnlockableItem; ((Object)extendedUnlockableItem).name = newUnlockableItem.unlockableName.Sanitized(toLower: false) + "ExtendedUnlockableItem"; extendedUnlockableItem.ContentType = contentType; extendedMod.RegisterExtendedContent(extendedUnlockableItem); return extendedUnlockableItem; } internal override (bool result, string log) TryValidateContent() { if (UnlockableItem.unlockableType == 1 && !UnlockableItem.alreadyUnlocked) { if ((Object)(object)UnlockableItem.prefabObject == (Object)null) { return (result: false, log: "Unlockable Item Prefab Was Null Or Empty"); } NetworkObject val = default(NetworkObject); if (!UnlockableItem.prefabObject.TryGetComponent(ref val)) { return (result: false, log: "Unlockable Item Prefab Is Missing NetworkObject Component"); } AutoParentToShip val2 = default(AutoParentToShip); if (!UnlockableItem.prefabObject.TryGetComponent(ref val2)) { return (result: false, log: "Unlockable Item Prefab Is Missing AutoParentToShip Component"); } } else if (UnlockableItem.unlockableType == 0 && (Object)(object)UnlockableItem.suitMaterial == (Object)null) { return (result: false, log: "Unlockable Suit Is Missing Suit Material"); } return base.TryValidateContent(); } } [CreateAssetMenu(fileName = "ExtendedWeatherEffect", menuName = "Lethal Level Loader/Extended Content/ExtendedWeatherEffect", order = 25)] public class ExtendedWeatherEffect : ExtendedContent { public ContentType contentType; [field: Header("General Settings")] [field: SerializeField] public LevelWeatherType BaseWeatherType { get; set; } = (LevelWeatherType)(-1); [field: SerializeField] public string WeatherDisplayName { get; set; } = string.Empty; [field: SerializeField] public GameObject WorldObject { get; set; } [field: SerializeField] public GameObject GlobalObject { get; set; } internal static ExtendedWeatherEffect Create(LevelWeatherType levelWeatherType, WeatherEffect weatherEffect, string weatherDisplayName, ContentType newContentType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Create(levelWeatherType, weatherEffect?.effectObject, weatherEffect?.effectPermanentObject, weatherDisplayName, newContentType); } internal static ExtendedWeatherEffect Create(LevelWeatherType levelWeatherType, GameObject worldObject, GameObject globalObject, string newWeatherDisplayName, ContentType newContentType) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) ExtendedWeatherEffect extendedWeatherEffect = ScriptableObject.CreateInstance(); extendedWeatherEffect.ContentType = newContentType; extendedWeatherEffect.WeatherDisplayName = newWeatherDisplayName; ((Object)extendedWeatherEffect).name = extendedWeatherEffect.WeatherDisplayName + "ExtendedWeatherEffect"; extendedWeatherEffect.BaseWeatherType = levelWeatherType; extendedWeatherEffect.WorldObject = worldObject; extendedWeatherEffect.GlobalObject = globalObject; return extendedWeatherEffect; } } [DisallowMultipleComponent] public class FootstepSurfaceHelper : MonoBehaviour { public TerrainData AssignedTerrainData { get; private set; } [field: Header("ExtendedFootstepSurface Helper")] [field: Tooltip("List of Terrain layers and their assigned footstep surface.")] [field: SerializeField] public List AssignedLayerSurfaces { get; private set; } = new List(8); public void Reset() { Terrain val = default(Terrain); if (!((Component)this).TryGetComponent(ref val)) { return; } AssignedTerrainData = val.terrainData; if ((Object)(object)AssignedTerrainData == (Object)null) { return; } for (int i = 0; i < AssignedTerrainData.terrainLayers?.Length; i++) { TerrainLayer val2 = AssignedTerrainData.terrainLayers[i]; if ((Object)(object)val2 != (Object)null) { TerrainLayerWithSurface terrainLayerWithSurface = new TerrainLayerWithSurface(); terrainLayerWithSurface.surfaceTag = ((Object)val2).name; terrainLayerWithSurface.useVanillaTag = VanillaSurfaceTags.None; terrainLayerWithSurface.terrainLayer = val2; TerrainLayerWithSurface item = terrainLayerWithSurface; AssignedLayerSurfaces.Add(item); } } } public void Awake() { Terrain val = default(Terrain); if (!((Component)this).TryGetComponent(ref val)) { DebugHelper.LogWarning("Terrain not found for FootstepSurfaceHelper component in: " + ((Object)this).name, DebugType.User); return; } AssignedTerrainData = val.terrainData; if ((Object)(object)AssignedTerrainData == (Object)null) { DebugHelper.LogWarning("TerrainData is null or missing for Terrain in: " + ((Object)this).name, DebugType.User); return; } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel == (Object)null || currentExtendedLevel.ContentType == ContentType.External) { return; } if (!currentExtendedLevel.UseTerrainFootsteps) { currentExtendedLevel.UseTerrainFootsteps = true; DebugHelper.LogWarning("Enabled 'UseTerrainFootsteps' for ExtendedLevel " + ((Object)currentExtendedLevel).name + " due to the presence of a FootstepSurfaceHelper!", DebugType.Developer); } ExtendedFootstepSurface[] array = new ExtendedFootstepSurface[8]; for (int i = 0; i < AssignedTerrainData.terrainLayers?.Length; i++) { TerrainLayer terrainLayer = AssignedTerrainData.terrainLayers[i]; if ((Object)(object)terrainLayer == (Object)null) { DebugHelper.LogWarning($"Layer at index '{i}' is null or missing for Terrain: {((Object)AssignedTerrainData).name}", DebugType.User); continue; } int num = AssignedLayerSurfaces.FindIndex((TerrainLayerWithSurface surface) => (Object)(object)surface.terrainLayer == (Object)(object)terrainLayer); if (num == -1) { DebugHelper.LogDebug($"No surface specified for Terrain layer '{((Object)terrainLayer).name}' at index '{i}', GameObject tag footsteps will be used for it instead.", DebugType.Developer); continue; } TerrainLayerWithSurface terrainLayerWithSurface = AssignedLayerSurfaces[num]; if (terrainLayerWithSurface.useVanillaTag != VanillaSurfaceTags.None) { int useVanillaTag = (int)terrainLayerWithSurface.useVanillaTag; if (useVanillaTag < PatchedContent.ExtendedFootstepSurfaces.Count) { array[i] = PatchedContent.ExtendedFootstepSurfaces[useVanillaTag]; } else { DebugHelper.LogError($"Could not get vanilla FootstepSurface '{terrainLayerWithSurface.useVanillaTag}' as ExtendedFootstepSurface list is empty.", DebugType.User); } continue; } if (string.IsNullOrEmpty(terrainLayerWithSurface.surfaceTag)) { DebugHelper.LogWarning("Custom surface tag for Terrain layer '" + ((Object)terrainLayer).name + "' is missing or empty in: " + ((Object)this).name, DebugType.User); continue; } string text = null; if (!string.IsNullOrEmpty(terrainLayerWithSurface.overrideExtendedModName)) { text = terrainLayerWithSurface.overrideExtendedModName; } string text2 = text; string text3 = text2; if (text3 == null) { text = currentExtendedLevel.ExtendedMod.ModMergeSetting switch { ModMergeSetting.MatchingAuthorName => currentExtendedLevel.ExtendedMod.AuthorName, ModMergeSetting.MatchingModName => currentExtendedLevel.ExtendedMod.ModName, _ => currentExtendedLevel.UniqueIdentificationName, }; } string fullSurfaceTag = text + "/" + terrainLayerWithSurface.surfaceTag; ExtendedFootstepSurface extendedFootstepSurface = PatchedContent.ExtendedFootstepSurfaces.Find((ExtendedFootstepSurface surface) => string.Equals(surface.FootstepSurface.surfaceTag, fullSurfaceTag, StringComparison.Ordinal)); if ((Object)(object)extendedFootstepSurface == (Object)null) { DebugHelper.LogWarning("Could not find ExtendedFootstepSurface with matching tag '" + terrainLayerWithSurface.surfaceTag + "' for layer '" + ((Object)terrainLayer).name + "' in: " + ((Object)this).name, DebugType.User); } else { array[i] = extendedFootstepSurface; } } TerrainManager.TerrainFootstepsDict[AssignedTerrainData] = array; } } [Serializable] public struct TerrainLayerWithSurface { [Tooltip("Surface tag of the ExtendedFootstepSurface to use for this Terrain layer.")] public string surfaceTag; [Tooltip("Use a vanilla tag for this Terrain layer instead. NOTE: For custom footsteps, leave as 'None' and use the field above!")] public VanillaSurfaceTags useVanillaTag; [Tooltip("Terrain layer to change the footsteps of.")] [Space(10f)] public TerrainLayer terrainLayer; [Tooltip("Override ExtendedMod name for this surface tag. Should be left empty unless using footsteps registered by another ExtendedMod.")] public string overrideExtendedModName; public TerrainLayerWithSurface() { surfaceTag = string.Empty; useVanillaTag = VanillaSurfaceTags.None; terrainLayer = null; overrideExtendedModName = string.Empty; } } public class LLLSaveFile : ModDataContainer { public int parityStepsTaken; public Dictionary itemSaveData = new Dictionary(); public List extendedLevelSaveData = new List(); public string CurrentLevelName { get; internal set; } = string.Empty; public void Reset() { CurrentLevelName = string.Empty; parityStepsTaken = 0; itemSaveData = new Dictionary(); extendedLevelSaveData = new List(); } } public struct AllItemsListItemData { public string itemObjectName; public string itemName; public string modName; public string modAuthor; public int allItemsListIndex; public int modItemsListIndex; public int itemNameDuplicateIndex; public bool isScrap; public bool saveItemVariable; public AllItemsListItemData(string newItemObjectName, string newItemName, string newModName, string newModAuthor, int newAllItemsListIndex, int newModItemsListIndex, int newItemNameDuplicateIndex, bool newIsScrap, bool newSaveItemVariable) { itemObjectName = newItemObjectName; itemName = newItemName; modName = newModName; modAuthor = newModAuthor; allItemsListIndex = newAllItemsListIndex; modItemsListIndex = newModItemsListIndex; itemNameDuplicateIndex = newItemNameDuplicateIndex; isScrap = newIsScrap; saveItemVariable = newSaveItemVariable; } } public struct ExtendedLevelData : INetworkSerializable { public string uniqueIdentifier; public bool isHidden; public bool isLocked; public readonly string UniqueIdentifier => uniqueIdentifier; public ExtendedLevelData(ExtendedLevel extendedLevel) { uniqueIdentifier = extendedLevel.UniqueIdentificationName; isHidden = extendedLevel.IsRouteHidden; isLocked = extendedLevel.IsRouteLocked; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) serializer.SerializeValue(ref uniqueIdentifier, false); ((BufferSerializer*)(&serializer))->SerializeValue(ref isHidden, default(ForPrimitives)); ((BufferSerializer*)(&serializer))->SerializeValue(ref isLocked, default(ForPrimitives)); } public readonly void ApplySavedValues(ExtendedLevel extendedLevel) { extendedLevel.IsRouteHidden = isHidden; extendedLevel.IsRouteLocked = isLocked; } } [CreateAssetMenu(fileName = "ContentTag", menuName = "Lethal Level Loader/Utility/ContentTag", order = 11)] public class ContentTag : ScriptableObject { public string contentTagName = string.Empty; public Color contentTagColor = Color.white; public static ContentTag Create(string tag, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ContentTag contentTag = ScriptableObject.CreateInstance(); contentTag.contentTagName = tag; contentTag.contentTagColor = color; ((Object)contentTag).name = tag; return contentTag; } public static ContentTag Create(string tag) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Create(tag, Color.white); } public override string ToString() { return contentTagName.Sanitized(toLower: false).RemoveWhitespace(); } } [CreateAssetMenu(fileName = "DungeonMatchingProperties", menuName = "Lethal Level Loader/Utility/DungeonMatchingProperties", order = 13)] public class DungeonMatchingProperties : MatchingProperties { [Space(5f)] public List dungeonTags = new List(); [Space(5f)] public List dungeonNames = new List(); public new static DungeonMatchingProperties Create(ExtendedContent extendedContent) { DungeonMatchingProperties dungeonMatchingProperties = ScriptableObject.CreateInstance(); ((Object)dungeonMatchingProperties).name = ((Object)extendedContent).name + "DungeonMatchingProperties"; return dungeonMatchingProperties; } public int GetDynamicRarity(ExtendedDungeonFlow extendedDungeonFlow) { int currentValue = 0; MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedTags(extendedDungeonFlow.ContentTags, dungeonNames), ((Object)extendedDungeonFlow).name, "Content Tags"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedDungeonFlow.AuthorName, authorNames), ((Object)extendedDungeonFlow).name, "Author Name"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedStrings(extendedDungeonFlow.ExtendedMod.ModNameAliases, modNames), ((Object)extendedDungeonFlow).name, "Mod Name Name"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(((Object)extendedDungeonFlow.DungeonFlow).name, dungeonNames), ((Object)extendedDungeonFlow).name, "Dungeon Name"); return currentValue; } public void ApplyValues(List newModNames = null, List newAuthorNames = null, List newDungeonTags = null, List newDungeonNames = null) { if (newModNames != null && newModNames.Count != 0) { modNames = new List(newModNames); } if (newAuthorNames != null && newAuthorNames.Count != 0) { authorNames = new List(newAuthorNames); } if (newDungeonTags != null && newDungeonTags.Count != 0) { dungeonTags = new List(newDungeonTags); } if (newDungeonNames != null && newDungeonNames.Count != 0) { dungeonNames = new List(newDungeonNames); } } } [CreateAssetMenu(fileName = "LevelMatchingProperties", menuName = "Lethal Level Loader/Utility/LevelMatchingProperties", order = 12)] public class LevelMatchingProperties : MatchingProperties { [Space(5f)] public List levelTags = new List(); [Space(5f)] public List currentRoutePrice = new List(); [Space(5f)] public List currentWeather = new List(); [Space(5f)] public List planetNames = new List(); public new static LevelMatchingProperties Create(ExtendedContent extendedContent) { LevelMatchingProperties levelMatchingProperties = ScriptableObject.CreateInstance(); ((Object)levelMatchingProperties).name = ((Object)extendedContent).name + "LevelMatchingProperties"; return levelMatchingProperties; } public int GetDynamicRarity(ExtendedLevel extendedLevel) { int currentValue = 0; MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedTags(extendedLevel.ContentTags, levelTags), ((Object)extendedLevel).name, "Content Tags"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedLevel.AuthorName, authorNames), ((Object)extendedLevel).name, "Author Name"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedStrings(extendedLevel.ExtendedMod.ModNameAliases, modNames), ((Object)extendedLevel).name, "Mod Name"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingWithinRanges(extendedLevel.RoutePrice, currentRoutePrice), ((Object)extendedLevel).name, "Route Price"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(extendedLevel.NumberlessPlanetName, planetNames), ((Object)extendedLevel).name, "Planet Name"); MatchingProperties.UpdateRarity(ref currentValue, MatchingProperties.GetHighestRarityViaMatchingNormalizedString(((object)Unsafe.As(ref extendedLevel.SelectableLevel.currentWeather)/*cast due to .constrained prefix*/).ToString(), currentWeather), ((Object)extendedLevel).name, "Current Weather"); return currentValue; } public void ApplyValues(List newModNames = null, List newAuthorNames = null, List newLevelTags = null, List newRoutePrices = null, List newCurrentWeathers = null, List newPlanetNames = null) { if (newModNames != null && newModNames.Count != 0) { modNames = new List(newModNames); } if (newAuthorNames != null && newAuthorNames.Count != 0) { authorNames = new List(newAuthorNames); } if (newLevelTags != null && newLevelTags.Count != 0) { levelTags = new List(newLevelTags); } if (newRoutePrices != null && newRoutePrices.Count != 0) { currentRoutePrice = new List(newRoutePrices); } if (newCurrentWeathers != null && newCurrentWeathers.Count != 0) { currentWeather = new List(newCurrentWeathers); } if (newPlanetNames != null && newPlanetNames.Count != 0) { planetNames = new List(newPlanetNames); } } } public class MatchingProperties : ScriptableObject { [Space(5f)] public List modNames = new List(); [Space(5f)] public List authorNames = new List(); public static MatchingProperties Create(ExtendedContent extendedContent) { MatchingProperties matchingProperties = ScriptableObject.CreateInstance(); ((Object)matchingProperties).name = ((Object)extendedContent).name + "MatchingProperties"; return matchingProperties; } internal static bool UpdateRarity(ref int currentValue, int newValue, string debugActionObject = null, string debugActionReason = null) { if (newValue > currentValue) { if (!string.IsNullOrEmpty(debugActionReason)) { if (!string.IsNullOrEmpty(debugActionObject)) { DebugHelper.Log("Raised Rarity Of: " + debugActionObject + " From (" + currentValue + ") To (" + newValue + ") Due To Matching " + debugActionReason, DebugType.Developer); } else { DebugHelper.Log("Raised Rarity From (" + currentValue + ") To (" + newValue + ") Due To Matching " + debugActionReason, DebugType.Developer); } } currentValue = newValue; return true; } return false; } internal static int GetHighestRarityViaMatchingWithinRanges(int comparingValue, List matchingVectors) { int num = 0; foreach (Vector2WithRarity matchingVector in matchingVectors) { if (matchingVector.Rarity >= num && (float)comparingValue >= matchingVector.Min && (float)comparingValue <= matchingVector.Max) { num = matchingVector.Rarity; } } return num; } internal static int GetHighestRarityViaMatchingNormalizedString(string comparingString, List matchingStrings) { return GetHighestRarityViaMatchingNormalizedStrings(new List(1) { comparingString }, matchingStrings); } internal static int GetHighestRarityViaMatchingNormalizedTags(List comparingTags, List matchingStrings) { return GetHighestRarityViaMatchingNormalizedStrings(comparingTags.ConvertAll((ContentTag t) => t.contentTagName), matchingStrings); } internal static int GetHighestRarityViaMatchingNormalizedStrings(List comparingStrings, List matchingStrings) { int num = 0; foreach (StringWithRarity matchingString in matchingStrings) { foreach (string item in new List(comparingStrings)) { if (matchingString.Rarity >= num && matchingString.Name.ContainsSanitized(item, bothWays: true)) { num = matchingString.Rarity; } } } return num; } } public class MoonsCataloguePage { [CompilerGenerated] private List k__BackingField; public List ExtendedLevelGroups { get; } = newExtendedLevelGroups.ToList(); public List ExtendedLevels { get { if (k__BackingField == null || k__BackingField.Count == 0) { k__BackingField = new List(); foreach (ExtendedLevelGroup extendedLevelGroup in ExtendedLevelGroups) { k__BackingField.AddRange(extendedLevelGroup.extendedLevelsList); } } return k__BackingField; } } public MoonsCataloguePage(List newExtendedLevelGroups) { } public void RebuildLevelGroups(List newExtendedLevelGroups, int splitCount) { List list = new List(); foreach (ExtendedLevelGroup newExtendedLevelGroup in newExtendedLevelGroups) { list.AddRange(newExtendedLevelGroup.extendedLevelsList); } RebuildLevelGroups(list.ToArray(), splitCount); } public void RebuildLevelGroups(List newExtendedLevels, int splitCount) { RebuildLevelGroups(newExtendedLevels.ToArray(), splitCount); } public void RebuildLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount) { ExtendedLevelGroups.Clear(); ExtendedLevelGroups.AddRange(TerminalManager.GetExtendedLevelGroups(newExtendedLevels, splitCount)); } } [Serializable] public class ExtendedLevelGroup { [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct ExtendedLevelGroupDifficultyComparer : IComparer { public readonly int Compare(ExtendedLevelGroup a, ExtendedLevelGroup b) { return a.AverageCalculatedDifficulty - b.AverageCalculatedDifficulty; } } public List extendedLevelsList = newExtendedLevels.ToList(); [CompilerGenerated] private int k__BackingField = -1; public int AverageCalculatedDifficulty { get { if (k__BackingField == -1) { k__BackingField = GetAverageCalculatedDifficulty(); } return k__BackingField; } } public ExtendedLevelGroup(List newExtendedLevels) { } public ExtendedLevelGroup(List newSelectableLevels) : this(newSelectableLevels.ConvertAll(LevelManager.GetExtendedLevel)) { } public int GetAverageCalculatedDifficulty() { if (extendedLevelsList.Count == 0) { return 0; } int num = 0; foreach (ExtendedLevel extendedLevels in extendedLevelsList) { num += extendedLevels.CalculatedDifficultyRating; } return num / extendedLevelsList.Count; } } public struct NetworkSceneInfo : INetworkSerializable { public enum SceneOrigin { Build, Bundle } private uint m_levelSceneIndex; private LethalLevelLoaderNetworkManager.StringContainer m_levelScenePath; public string LevelScenePath => m_levelScenePath.SomeText; public int LevelSceneIndex => (int)m_levelSceneIndex; public int SceneIndex { get { NetworkScenePatcher.TryGetSceneIndex((int)m_levelSceneIndex, LevelScenePath, out var sceneIndex); return sceneIndex; } } public bool IsLoaded { get { if (Origin == SceneOrigin.Build) { return true; } if (AssetBundleLoader.TryGetAssetBundleInfo(LevelScenePath, out var info)) { return info.IsLoaded; } return false; } } public SceneOrigin Origin { get { if (SceneIndex >= SceneManager.sceneCountInBuildSettings) { return SceneOrigin.Bundle; } return SceneOrigin.Build; } } public NetworkSceneInfo(int levelSceneIndex, string levelScenePath) { m_levelScenePath = new LethalLevelLoaderNetworkManager.StringContainer(); m_levelScenePath.SomeText = levelScenePath; m_levelSceneIndex = (uint)levelSceneIndex; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer*)(&serializer))->SerializeValue(ref m_levelSceneIndex, default(ForPrimitives)); ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref m_levelScenePath); } } public static class PatchedContent { internal static Dictionary UniqueIdentifiersDictionary = new Dictionary(); internal static Dictionary ExtendedLevelDictionary = new Dictionary(); internal static Dictionary ExtendedDungeonFlowDictionary = new Dictionary(); internal static Dictionary ExtendedItemDictionary = new Dictionary(); internal static Dictionary ExtendedEnemyTypeDictionary = new Dictionary(); internal static Dictionary ExtendedBuyableVehicleDictionary = new Dictionary(); internal static Dictionary ExtendedUnlockableItemDictionary = new Dictionary(); public static ExtendedMod VanillaMod { get; internal set; } public static List AllLevelSceneNames { get; internal set; } = new List(); public static List ExtendedMods { get; internal set; } = new List(); public static List ExtendedLevels { get; internal set; } = new List(); public static List VanillaExtendedLevels { get { List list = new List(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { if (extendedLevel.ContentType == ContentType.Vanilla) { list.Add(extendedLevel); } } return list; } } public static List CustomExtendedLevels { get { List list = new List(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { ContentType contentType = extendedLevel.ContentType; if ((contentType == ContentType.Custom || contentType == ContentType.External) ? true : false) { list.Add(extendedLevel); } } return list; } } [Obsolete("Use PatchedContent.SelectableLevels instead.")] public static List SeletectableLevels => SelectableLevels; public static List SelectableLevels { get { List list = new List(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { list.Add(extendedLevel.SelectableLevel); } return list; } } public static List MoonsCatalogue { get { List list = new List(); foreach (SelectableLevel item in OriginalContent.MoonsCatalogue) { list.Add(item); } foreach (ExtendedLevel extendedLevel in ExtendedLevels) { ContentType contentType = extendedLevel.ContentType; if ((contentType == ContentType.Custom || contentType == ContentType.External) ? true : false) { list.Add(extendedLevel.SelectableLevel); } } return list; } } public static List ExtendedDungeonFlows { get; internal set; } = new List(); public static List VanillaExtendedDungeonFlows { get { List list = new List(); foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { if (extendedDungeonFlow.ContentType == ContentType.Vanilla) { list.Add(extendedDungeonFlow); } } return list; } } public static List CustomExtendedDungeonFlows { get { List list = new List(); foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { if (extendedDungeonFlow.ContentType == ContentType.Custom) { list.Add(extendedDungeonFlow); } } return list; } } public static List ExtendedWeatherEffects { get; internal set; } = new List(); public static List VanillaExtendedWeatherEffects { get { List list = new List(); foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects) { if (extendedWeatherEffect.contentType == ContentType.Vanilla) { list.Add(extendedWeatherEffect); } } return list; } } public static List CustomExtendedWeatherEffects { get { List list = new List(); foreach (ExtendedWeatherEffect extendedWeatherEffect in ExtendedWeatherEffects) { if (extendedWeatherEffect.contentType == ContentType.Custom) { list.Add(extendedWeatherEffect); } } return list; } } public static List ExtendedItems { get; internal set; } = new List(); public static List CustomExtendedItems { get { List list = new List(); foreach (ExtendedItem extendedItem in ExtendedItems) { if (extendedItem.ContentType == ContentType.Custom) { list.Add(extendedItem); } } return list; } } public static List ExtendedEnemyTypes { get; internal set; } = new List(); public static List CustomExtendedEnemyTypes { get { List list = new List(); foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes) { if (extendedEnemyType.ContentType == ContentType.Custom) { list.Add(extendedEnemyType); } } return list; } } public static List VanillaExtendedEnemyTypes { get { List list = new List(); foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes) { if (extendedEnemyType.ContentType == ContentType.Vanilla) { list.Add(extendedEnemyType); } } return list; } } public static List ExtendedBuyableVehicles { get; internal set; } = new List(); public static List CustomExtendedBuyableVehicles { get { List list = new List(); foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles) { if (extendedBuyableVehicle.ContentType == ContentType.Custom) { list.Add(extendedBuyableVehicle); } } return list; } } public static List VanillaExtendedBuyableVehicles { get { List list = new List(); foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles) { if (extendedBuyableVehicle.ContentType == ContentType.Vanilla) { list.Add(extendedBuyableVehicle); } } return list; } } public static List ExtendedUnlockableItems { get; internal set; } = new List(); public static List CustomExtendedUnlockableItems { get { List list = new List(); foreach (ExtendedUnlockableItem extendedUnlockableItem in ExtendedUnlockableItems) { if (extendedUnlockableItem.ContentType == ContentType.Custom) { list.Add(extendedUnlockableItem); } } return list; } } public static List VanillaExtendedUnlockableItems { get { List list = new List(); foreach (ExtendedUnlockableItem extendedUnlockableItem in ExtendedUnlockableItems) { if (extendedUnlockableItem.ContentType == ContentType.Vanilla) { list.Add(extendedUnlockableItem); } } return list; } } public static List ExtendedFootstepSurfaces { get; internal set; } = new List(); public static List CustomExtendedFootstepSurfaces { get { List list = new List(); foreach (ExtendedFootstepSurface extendedFootstepSurface in ExtendedFootstepSurfaces) { if (extendedFootstepSurface.ContentType == ContentType.Custom) { list.Add(extendedFootstepSurface); } } return list; } } public static List VanillaExtendedFootstepSurfaces { get { List list = new List(); foreach (ExtendedFootstepSurface extendedFootstepSurface in ExtendedFootstepSurfaces) { if (extendedFootstepSurface.ContentType == ContentType.Vanilla) { list.Add(extendedFootstepSurface); } } return list; } } public static List Items { get; internal set; } = new List(); public static List Enemies { get; internal set; } = new List(); public static void RegisterExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow) { extendedDungeonFlow.ConvertObsoleteValues(); if (string.IsNullOrEmpty(((Object)extendedDungeonFlow).name)) { DebugHelper.LogWarning("Tried to register ExtendedDungeonFlow with missing name! Setting to DungeonFlow name for safety!", DebugType.Developer); ((Object)extendedDungeonFlow).name = ((Object)extendedDungeonFlow.DungeonFlow).name; } LethalBundleManager.RegisterNewExtendedContent(extendedDungeonFlow, null); } public static void RegisterExtendedLevel(ExtendedLevel extendedLevel) { LethalBundleManager.RegisterNewExtendedContent(extendedLevel, null); } public static void RegisterExtendedMod(ExtendedMod extendedMod) { DebugHelper.Log("Registering ExtendedMod: " + extendedMod.ModName + " Manually.", DebugType.IAmBatby); LethalBundleManager.RegisterExtendedMod(extendedMod, null); } internal static void SortExtendedMods() { ExtendedMods.Sort(default(ExtendedMod.ExtendedModComparer)); foreach (ExtendedMod extendedMod in ExtendedMods) { extendedMod.SortRegisteredContent(); } } internal static void PopulateContentDictionaries() { foreach (ExtendedLevel extendedLevel in ExtendedLevels) { TryAdd(ExtendedLevelDictionary, extendedLevel.SelectableLevel, extendedLevel); TryAddUUID(extendedLevel); } foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { TryAdd(ExtendedDungeonFlowDictionary, extendedDungeonFlow.DungeonFlow, extendedDungeonFlow); TryAddUUID(extendedDungeonFlow); } foreach (ExtendedItem extendedItem in ExtendedItems) { TryAdd(ExtendedItemDictionary, extendedItem.Item, extendedItem); TryAddUUID(extendedItem); } foreach (ExtendedEnemyType extendedEnemyType in ExtendedEnemyTypes) { TryAdd(ExtendedEnemyTypeDictionary, extendedEnemyType.EnemyType, extendedEnemyType); TryAddUUID(extendedEnemyType); } foreach (ExtendedBuyableVehicle extendedBuyableVehicle in ExtendedBuyableVehicles) { TryAdd(ExtendedBuyableVehicleDictionary, extendedBuyableVehicle.BuyableVehicle, extendedBuyableVehicle); TryAddUUID(extendedBuyableVehicle); } foreach (ExtendedUnlockableItem extendedUnlockableItem in ExtendedUnlockableItems) { TryAdd(ExtendedUnlockableItemDictionary, extendedUnlockableItem.UnlockableItem, extendedUnlockableItem); TryAddUUID(extendedUnlockableItem); } } internal static void TryAddUUID(ExtendedContent extendedContent) { TryAdd(UniqueIdentifiersDictionary, extendedContent.UniqueIdentificationName, extendedContent); } internal static bool TryAdd(Dictionary dict, T1 key, T2 value) where T2 : ExtendedContent { if (dict.TryAdd(key, value)) { return true; } if ((Object)(object)value.ExtendedMod != (Object)(object)VanillaMod) { DebugHelper.LogError("Could not add " + key.ToString() + " to dictionary.", DebugType.Developer); } return false; } public static bool TryGetExtendedContent(SelectableLevel selectableLevel, out ExtendedLevel extendedLevel) { return ExtendedLevelDictionary.TryGetValue(selectableLevel, out extendedLevel); } public static bool TryGetExtendedContent(DungeonFlow dungeonFlow, out ExtendedDungeonFlow extendedDungeonFlow) { return ExtendedDungeonFlowDictionary.TryGetValue(dungeonFlow, out extendedDungeonFlow); } public static bool TryGetExtendedContent(Item item, out ExtendedItem extendedItem) { return ExtendedItemDictionary.TryGetValue(item, out extendedItem); } public static bool TryGetExtendedContent(EnemyType enemyType, out ExtendedEnemyType extendedEnemyType) { return ExtendedEnemyTypeDictionary.TryGetValue(enemyType, out extendedEnemyType); } public static bool TryGetExtendedContent(BuyableVehicle buyableVehicle, out ExtendedBuyableVehicle extendedBuyableVehicle) { return ExtendedBuyableVehicleDictionary.TryGetValue(buyableVehicle, out extendedBuyableVehicle); } public static bool TryGetExtendedContent(UnlockableItem unlockableItem, out ExtendedUnlockableItem extendedUnlockableItem) { return ExtendedUnlockableItemDictionary.TryGetValue(unlockableItem, out extendedUnlockableItem); } public static bool TryGetExtendedContent(string uniqueIdentifierName, out T extendedContent) where T : ExtendedContent { extendedContent = null; if (UniqueIdentifiersDictionary.TryGetValue(uniqueIdentifierName, out var value)) { extendedContent = value as T; } return (Object)(object)extendedContent != (Object)null; } } public static class OriginalContent { public static StartOfRound StartOfRound => Patches.StartOfRound; public static RoundManager RoundManager => Patches.RoundManager; public static Terminal Terminal => Patches.Terminal; public static TimeOfDay TimeOfDay => Patches.TimeOfDay; public static List SelectableLevels { get; internal set; } = new List(); public static List MoonsCatalogue { get; internal set; } = new List(); public static List DungeonFlows { get; internal set; } = new List(); public static List Items { get; internal set; } = new List(); public static List ItemGroups { get; internal set; } = new List(); public static List UnlockableItems { get; internal set; } = new List(); public static List FootstepSurfaces { get; internal set; } = new List(); public static List Enemies { get; internal set; } = new List(); public static List SpawnableOutsideObjects { get; internal set; } = new List(); public static List IndoorMapHazards { get; internal set; } = new List(); public static List AudioMixers { get; internal set; } = new List(); public static List AudioMixerGroups { get; internal set; } = new List(); public static List AudioMixerSnapshots { get; internal set; } = new List(); public static List LevelAmbienceLibraries { get; internal set; } = new List(); public static List ReverbPresets { get; internal set; } = new List(); public static List TerminalKeywords { get; internal set; } = new List(); public static List TerminalNodes { get; internal set; } = new List(); } internal static class EventPatches { internal static DayMode previousDayMode = (DayMode)(-1); internal static readonly List scrapSpawnedThisRound = new List(); internal static readonly List spawnedMapObjects = new List(); private static EnemyVent cachedSelectedVent; [HarmonyPriority(200)] [HarmonyPatch(typeof(StoryLog), "CollectLog")] [HarmonyPrefix] internal static void StoryLogCollectLog_Prefix(StoryLog __instance) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onStoryLogCollected.Invoke(__instance); LevelManager.GlobalLevelEvents.onStoryLogCollected.Invoke(__instance); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnRandomDaytimeEnemy")] [HarmonyPostfix] internal static void RoundManagerSpawnRandomDaytimeEnemy_Postfix(RoundManager __instance, bool __result) { if (__result && (Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { object obj; if (__instance.SpawnedEnemies.Count <= 0) { obj = null; } else { List spawnedEnemies = __instance.SpawnedEnemies; obj = spawnedEnemies[spawnedEnemies.Count - 1]; } EnemyAI val = (EnemyAI)obj; if ((Object)(object)val != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onDaytimeEnemySpawn.Invoke(val); LevelManager.GlobalLevelEvents.onDaytimeEnemySpawn.Invoke(val); } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnRandomOutsideEnemy")] [HarmonyPostfix] internal static void RoundManagerSpawnRandomOutsideEnemy_Postfix(RoundManager __instance, bool __result) { if (__result && (Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { object obj; if (__instance.SpawnedEnemies.Count <= 0) { obj = null; } else { List spawnedEnemies = __instance.SpawnedEnemies; obj = spawnedEnemies[spawnedEnemies.Count - 1]; } EnemyAI val = (EnemyAI)obj; if ((Object)(object)val != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onNighttimeEnemySpawn.Invoke(val); LevelManager.GlobalLevelEvents.onNighttimeEnemySpawn.Invoke(val); } } } [HarmonyPriority(201)] [HarmonyPatch(typeof(DungeonGenerator), "Generate")] [HarmonyPrefix] internal static void DungeonGeneratorGenerate_Prefix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onBeforeDungeonGenerate.Invoke(Patches.RoundManager); DungeonManager.GlobalDungeonEvents.onBeforeDungeonGenerate.Invoke(Patches.RoundManager); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SwitchPower")] [HarmonyPrefix] internal static void RoundManagerSwitchPower_Prefix(bool on) { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPowerSwitchToggle.Invoke(on); DungeonManager.GlobalDungeonEvents.onPowerSwitchToggle.Invoke(on); } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onPowerSwitchToggle.Invoke(on); LevelManager.GlobalLevelEvents.onPowerSwitchToggle.Invoke(on); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPostfix] internal static void RoundManagerSpawnScrapInLevel_Postfix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { scrapSpawnedThisRound.Clear(); scrapSpawnedThisRound.AddRange(Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0)); scrapSpawnedThisRound.RemoveAll((GrabbableObject item) => item.isInElevator || item.isInShipRoom || item.scrapPersistedThroughRounds); DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedScrapObjects.Invoke(scrapSpawnedThisRound); DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects.Invoke(scrapSpawnedThisRound); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnSyncedProps")] [HarmonyPostfix] internal static void RoundManagerSpawnSyncedProps_Postfix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedSyncedObjects.Invoke(Patches.RoundManager.spawnedSyncedObjects); DungeonManager.GlobalDungeonEvents.onSpawnedSyncedObjects.Invoke(Patches.RoundManager.spawnedSyncedObjects); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")] [HarmonyPrefix] internal static void RoundManagerSpawnEventFromVent_Prefix(EnemyVent vent) { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { cachedSelectedVent = vent; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnEnemyGameObject")] [HarmonyPostfix] internal static void RoundManagerSpawnEventFromVent_Postfix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && (Object)(object)cachedSelectedVent != (Object)null) { ExtendedEvent<(EnemyVent, EnemyAI)> onEnemySpawnedFromVent = DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onEnemySpawnedFromVent; EnemyVent item = cachedSelectedVent; List spawnedEnemies = Patches.RoundManager.SpawnedEnemies; onEnemySpawnedFromVent.Invoke((item, spawnedEnemies[spawnedEnemies.Count - 1])); ExtendedEvent<(EnemyVent, EnemyAI)> onEnemySpawnedFromVent2 = DungeonManager.GlobalDungeonEvents.onEnemySpawnedFromVent; EnemyVent item2 = cachedSelectedVent; List spawnedEnemies2 = Patches.RoundManager.SpawnedEnemies; onEnemySpawnedFromVent2.Invoke((item2, spawnedEnemies2[spawnedEnemies2.Count - 1])); cachedSelectedVent = null; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPostfix] internal static void RoundManagerSpawnMapObjects_Postfix() { spawnedMapObjects.Clear(); if (!((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) || !((Scene)(ref LevelLoader.currentLevelScene)).isLoaded) { return; } GameObject[] rootGameObjects = ((Scene)(ref LevelLoader.currentLevelScene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { IIndoorMapHazard[] componentsInChildren = val.GetComponentsInChildren(false); foreach (IIndoorMapHazard val2 in componentsInChildren) { Behaviour val3 = (Behaviour)(object)((val2 is Behaviour) ? val2 : null); if (val3 != null) { spawnedMapObjects.Add(((Component)((Component)val3).transform.root).gameObject); } } } DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedMapObjects.Invoke(spawnedMapObjects); DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects.Invoke(spawnedMapObjects); } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")] [HarmonyPrefix] internal static void StartOfRoundOnShipLandedMiscEvents_Prefix() { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onShipLand.Invoke(); LevelManager.GlobalLevelEvents.onShipLand.Invoke(); } if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onShipLand.Invoke(); DungeonManager.GlobalDungeonEvents.onShipLand.Invoke(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] [HarmonyPrefix] internal static void StartOfRoundShipLeave_Prefix() { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onShipLeave.Invoke(); LevelManager.GlobalLevelEvents.onShipLeave.Invoke(); } if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onShipLeave.Invoke(); DungeonManager.GlobalDungeonEvents.onShipLeave.Invoke(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")] [HarmonyPrefix] internal static void EntranceTeleportTeleportPlayerServerRpc_Prefix(EntranceTeleport __instance, int playerObj) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage != 0) { return; } PlayerControllerB val = Patches.StartOfRound.allPlayerScripts[playerObj]; if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).IsOwner) { return; } if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { if (__instance.isEntranceToBuilding) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerEnterDungeon.Invoke((__instance, val)); DungeonManager.GlobalDungeonEvents.onPlayerEnterDungeon.Invoke((__instance, val)); } else { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerExitDungeon.Invoke((__instance, val)); DungeonManager.GlobalDungeonEvents.onPlayerExitDungeon.Invoke((__instance, val)); } } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { if (__instance.isEntranceToBuilding) { LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerEnterDungeon.Invoke((__instance, val)); LevelManager.GlobalLevelEvents.onPlayerEnterDungeon.Invoke((__instance, val)); } else { LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerExitDungeon.Invoke((__instance, val)); LevelManager.GlobalLevelEvents.onPlayerExitDungeon.Invoke((__instance, val)); } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(LungProp), "EquipItem")] [HarmonyPrefix] internal static void LungPropEquipItem_Prefix(LungProp __instance) { if (__instance.isLungDocked) { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onApparatusTaken.Invoke(__instance); DungeonManager.GlobalDungeonEvents.onApparatusTaken.Invoke(__instance); } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.LevelEvents.onApparatusTaken.Invoke(__instance); LevelManager.GlobalLevelEvents.onApparatusTaken.Invoke(__instance); } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(TimeOfDay), "GetDayPhase")] [HarmonyPostfix] internal static void TimeOfDayGetDayPhase_Postfix(DayMode __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0036: Unknown result type (might be due to invalid IL or missing references) if ((int)previousDayMode == -1 || previousDayMode != __result) { LevelManager.CurrentExtendedLevel.LevelEvents.onDayModeToggle.Invoke(__result); LevelManager.GlobalLevelEvents.onDayModeToggle.Invoke(__result); } previousDayMode = __result; } } public delegate void ParameterEvent(T param); public class ExtendedEvent : ExtendedEvent { private readonly List> paramListeners = new List>(); public override int Listeners => base.Listeners + paramListeners.Count; private event ParameterEvent onParameterEvent; public void Invoke(T param) { this.onParameterEvent?.Invoke(param); Invoke(); } public void AddListener(ParameterEvent listener) { onParameterEvent += listener; paramListeners.Add(listener); } public void RemoveListener(ParameterEvent listener) { onParameterEvent -= listener; paramListeners.Remove(listener); } public override void ClearListeners() { base.ClearListeners(); foreach (ParameterEvent paramListener in paramListeners) { onParameterEvent -= paramListener; } paramListeners.Clear(); } } public class ExtendedEvent { private readonly List listeners = new List(); public bool HasListeners => Listeners != 0; public virtual int Listeners => listeners.Count; protected event Action onEvent; public void Invoke() { try { this.onEvent?.Invoke(); } catch (Exception exception) { DebugHelper.LogError(exception, DebugType.User); } } public void AddListener(Action listener) { onEvent += listener; listeners.Add(listener); } public void RemoveListener(Action listener) { onEvent -= listener; listeners.Remove(listener); } public virtual void ClearListeners() { foreach (Action listener in listeners) { onEvent -= listener; } listeners.Clear(); } } public static class Extensions { private static readonly Regex sanitizeRegex = new Regex("(\\s*[^\\p{L}])", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled | RegexOptions.CultureInvariant); private static readonly Regex skipToLetterRegex = new Regex("(^[^\\p{L}]+)", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled | RegexOptions.CultureInvariant); private static readonly Regex stripSpecialCharactersRegex = new Regex("([^\\p{L}\\d\\s])", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled | RegexOptions.CultureInvariant); public static IEnumerable GetTiles(this DungeonFlow dungeonFlow) { if ((Object)(object)dungeonFlow == (Object)null) { return Array.Empty(); } HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); foreach (GraphNode node in dungeonFlow.Nodes) { foreach (TileSet item in node?.TileSets) { if ((Object)(object)item != (Object)null && hashSet2.Add(item)) { hashSet.UnionWith(item.GetTilesInTileSet()); } } } foreach (TileInjectionRule tileInjectionRule in dungeonFlow.TileInjectionRules) { if ((Object)(object)tileInjectionRule?.TileSet != (Object)null && hashSet2.Add(tileInjectionRule.TileSet)) { hashSet.UnionWith(tileInjectionRule.TileSet.GetTilesInTileSet()); } } foreach (GraphLine line in dungeonFlow.Lines) { foreach (DungeonArchetype item2 in line?.DungeonArchetypes) { HashSet hashSet3 = new HashSet(); foreach (TileSet tileSet in item2.TileSets) { hashSet3.Add(tileSet); } HashSet hashSet4 = hashSet3; hashSet4.UnionWith(item2.BranchCapTileSets); foreach (TileSet item3 in hashSet4) { if ((Object)(object)item3 != (Object)null && hashSet2.Add(item3)) { hashSet.UnionWith(item3.GetTilesInTileSet()); } } } } return hashSet; } public static IEnumerable GetTilesInTileSet(this TileSet tileSet) { if ((Object)(object)tileSet == (Object)null) { return Array.Empty(); } HashSet hashSet = new HashSet(); if (tileSet.TileWeights != null && tileSet.TileWeights.Weights != null) { foreach (GameObjectChance weight in tileSet.TileWeights.Weights) { if (weight != null && (Object)(object)weight.Value != (Object)null) { Tile componentInChildren = weight.Value.GetComponentInChildren(false); if ((Object)(object)componentInChildren != (Object)null) { hashSet.Add(componentInChildren); } } } } return hashSet; } public static IEnumerable GetRandomMapObjects(this DungeonFlow dungeonFlow) { if ((Object)(object)dungeonFlow == (Object)null) { return Array.Empty(); } return dungeonFlow.GetRandomMapObjects(dungeonFlow.GetTiles()); } public static IEnumerable GetRandomMapObjects(this DungeonFlow dungeonFlow, IEnumerable allTiles) { if ((Object)(object)dungeonFlow == (Object)null) { return Array.Empty(); } List list = new List(); List list2 = new List(); foreach (Tile allTile in allTiles) { ((Component)allTile).GetComponentsInChildren(true, list2); list.AddRange(list2); } return list; } public static IEnumerable GetSpawnSyncedObjects(this DungeonFlow dungeonFlow) { if ((Object)(object)dungeonFlow == (Object)null) { return Array.Empty(); } return dungeonFlow.GetSpawnSyncedObjects(dungeonFlow.GetTiles()); } public static IEnumerable GetSpawnSyncedObjects(this DungeonFlow dungeonFlow, IEnumerable allTiles) { if ((Object)(object)dungeonFlow == (Object)null) { return Array.Empty(); } HashSet hashSet = new HashSet(); foreach (Tile allTile in allTiles) { Doorway[] componentsInChildren = ((Component)allTile).gameObject.GetComponentsInChildren(); foreach (Doorway val in componentsInChildren) { foreach (GameObjectWeight connectorPrefabWeight in val.ConnectorPrefabWeights) { hashSet.UnionWith(connectorPrefabWeight.GameObject.GetComponentsInChildren(true)); } foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights) { hashSet.UnionWith(blockerPrefabWeight.GameObject.GetComponentsInChildren(true)); } } hashSet.UnionWith(((Component)allTile).gameObject.GetComponentsInChildren(true)); } return hashSet; } public static void AddReferences(this CompatibleNoun compatibleNoun, TerminalKeyword firstNoun, TerminalNode firstResult) { compatibleNoun.noun = firstNoun; compatibleNoun.result = firstResult; } public static void AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword newNoun, TerminalNode newResult) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = Array.Empty(); } CompatibleNoun val = new CompatibleNoun(newNoun, newResult); terminalKeyword.compatibleNouns = CollectionExtensions.AddItem((IEnumerable)terminalKeyword.compatibleNouns, val).ToArray(); } public static void AddCompatibleNoun(this TerminalNode terminalNode, TerminalKeyword newNoun, TerminalNode newResult) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (terminalNode.terminalOptions == null) { terminalNode.terminalOptions = Array.Empty(); } CompatibleNoun val = new CompatibleNoun(newNoun, newResult); terminalNode.terminalOptions = CollectionExtensions.AddItem((IEnumerable)terminalNode.terminalOptions, val).ToArray(); } public static void Add(this IntWithRarity intWithRarity, int id, int rarity) { intWithRarity.id = id; intWithRarity.rarity = rarity; } public static bool ContainsSanitized(this string input, string[] comparisons, bool bothWays = false) { foreach (string text in comparisons) { if (!string.IsNullOrEmpty(text) && input.ContainsSanitized(text, bothWays)) { return true; } } return false; } public static bool ContainsSanitized(this string input, string comparison, bool bothWays = false) { (string, string) tuple = (input.Sanitized(), comparison.Sanitized()); if (!tuple.Item1.Contains(tuple.Item2, StringComparison.Ordinal)) { if (bothWays) { return tuple.Item2.Contains(tuple.Item1, StringComparison.Ordinal); } return false; } return true; } public static string Sanitized(this string input, bool toLower = true) { string text = sanitizeRegex.Replace(input, string.Empty); if (!toLower) { return text; } return text.ToLowerInvariant(); } public static string RemoveWhitespace(this string input) { return string.Join(string.Empty, input.Split((string[]?)null, StringSplitOptions.RemoveEmptyEntries)); } public static string SkipToLetters(this string input) { return skipToLetterRegex.Replace(input, string.Empty); } public static string StripSpecialCharacters(this string input) { return stripSpecialCharactersRegex.Replace(input, string.Empty).Trim(); } public static string Truncate(this string input, int length) { if (string.IsNullOrEmpty(input)) { return string.Empty; } if (input.Length > length) { return input.Substring(0, length); } return input; } public static List GetDungeonFlows(this RoundManager roundManager) { List list = new List(roundManager.dungeonFlowTypes.Length); for (int i = 0; i < roundManager.dungeonFlowTypes.Length; i++) { if (roundManager.dungeonFlowTypes[i] != null && (Object)(object)roundManager.dungeonFlowTypes[i].dungeonFlow != (Object)null) { list.Add(roundManager.dungeonFlowTypes[i].dungeonFlow); } } return list; } public static T TryAddComponent(this GameObject gameObject) where T : Component { T result = default(T); if (!gameObject.TryGetComponent(ref result)) { return gameObject.AddComponent(); } return result; } } internal static class Patches { [StructLayout(LayoutKind.Sequential, Size = 1)] private struct DoorwayPairComparer : IComparer { public readonly int Compare(DoorwayPair a, DoorwayPair b) { int num = ((DoorwayPair)(ref b)).TileWeight.CompareTo(((DoorwayPair)(ref a)).TileWeight); if (num == 0) { return ((DoorwayPair)(ref b)).DoorwayWeight.CompareTo(((DoorwayPair)(ref a)).DoorwayWeight); } return num; } } internal const int priority = 200; internal static string delayedSceneLoadingName = string.Empty; internal static List allSceneNamesCalledToLoad = new List(); internal static ulong currentClientId; public static ExtendedEvent OnBeforeVanillaContentCollected = new ExtendedEvent(); public static ExtendedEvent OnAfterVanillaContentCollected = new ExtendedEvent(); public static ExtendedEvent OnAfterCustomContentRestored = new ExtendedEvent(); private static bool hasInitiallyChangedLevel; private static readonly HashSet temporaryIndoorMapHazards = new HashSet(); internal const string disabledText = "[ At least one player is loading custom moon! ]"; internal const string routingText = "Routing..."; internal static bool IsServer { get { if ((Object)(object)NetworkManager.Singleton != (Object)null) { return NetworkManager.Singleton.IsServer; } return false; } } public static StartOfRound StartOfRound { get; internal set; } public static RoundManager RoundManager { get; internal set; } public static Terminal Terminal { get; internal set; } public static TimeOfDay TimeOfDay { get; internal set; } [HarmonyPriority(200)] [HarmonyPatch(typeof(PreInitSceneScript), "Awake")] [HarmonyPrefix] internal static void PreInitSceneScriptAwake_Prefix(PreInitSceneScript __instance) { if (!Plugin.IsSetupComplete) { AudioSource val = default(AudioSource); if (((Component)__instance).TryGetComponent(ref val)) { OriginalContent.AudioMixers.Add(val.outputAudioMixerGroup.audioMixer); } ContentTagParser.ImportVanillaContentTags(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(SceneManager), "LoadScene", new Type[] { typeof(string) })] [HarmonyPrefix] internal static bool SceneManagerLoadScene(string sceneName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (allSceneNamesCalledToLoad.Count == 0) { List list = allSceneNamesCalledToLoad; Scene activeScene = SceneManager.GetActiveScene(); list.Add(((Scene)(ref activeScene)).name); } SceneManager.GetSceneByName(sceneName); allSceneNamesCalledToLoad.Add(sceneName); if (sceneName == "MainMenu" && !allSceneNamesCalledToLoad.Contains("InitSceneLaunchOptions")) { DebugHelper.LogError("SceneManager has been told to load Main Menu without ever loading InitSceneLaunchOptions. This will break LethalLevelLoader. This is likely due to a \"Skip to Main Menu\" mod.", DebugType.User); return false; } if (LethalBundleManager.CurrentStatus == LethalBundleManager.ModProcessingStatus.Loading) { DebugHelper.LogWarning("SceneManager has attempted to load " + sceneName + " Scene before AssetBundles have finished loading. Pausing request until LethalLevelLoader is ready to proceed.", DebugType.User); delayedSceneLoadingName = sceneName; LethalBundleManager.OnFinishedProcessing.RemoveListener(LoadMainMenu); LethalBundleManager.OnFinishedProcessing.AddListener(LoadMainMenu); return false; } return true; } internal static void LoadMainMenu() { DebugHelper.LogWarning("Proceeding with the loading of " + delayedSceneLoadingName + " Scene as LethalLevelLoader has finished loading AssetBundles.", DebugType.User); if (delayedSceneLoadingName != string.Empty) { SceneManager.LoadScene(delayedSceneLoadingName); } delayedSceneLoadingName = string.Empty; } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void GameNetworkManagerStart_Prefix(GameNetworkManager __instance) { if (!LethalBundleManager.HasFinalisedFoundContent) { LethalBundleManager.FinialiseFoundContent(); } if (Plugin.IsSetupComplete) { return; } NetworkManager networkManager = (NetworkBundleManager.networkManager = (LethalLevelLoaderNetworkManager.networkManager = ((Component)__instance).GetComponent())); AudioSource val = default(AudioSource); foreach (NetworkPrefab prefab in NetworkBundleManager.networkManager.NetworkConfig.Prefabs.m_Prefabs) { if (prefab.Prefab.TryGetComponent(ref val)) { OriginalContent.AudioMixers.Add(val.outputAudioMixerGroup.audioMixer); break; } } GameObject val2 = PrefabHelper.CreateNetworkPrefab("LethalLevelLoaderNetworkManagerTest"); val2.AddComponent(); val2.GetComponent().SceneMigrationSynchronization = true; val2.GetComponent().DestroyWithScene = false; LethalLevelLoaderNetworkManager.networkingManagerPrefab = val2; LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val2); DebugHelper.Log("Creating NetworkBundleManager", DebugType.IAmBatby); GameObject val3 = PrefabHelper.CreateNetworkPrefab("NetworkBundleManager"); val3.AddComponent(); val3.GetComponent().SceneMigrationSynchronization = true; val3.GetComponent().DestroyWithScene = false; NetworkBundleManager.networkingManagerPrefab = val3; LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val3); AssetBundleLoader.NetworkRegisterCustomContent(networkManager); LethalLevelLoaderNetworkManager.RegisterPrefabs(networkManager); } [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void GameNetworkManagerSaveGameValues_Postfix(GameNetworkManager __instance) { if (__instance.isHostingGame && StartOfRound.inShipPhase && !StartOfRound.isChallengeFile) { SaveManager.SaveGameValues(); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void StartOfRoundAwake_Prefix(StartOfRound __instance) { Plugin.OnBeforeSetupInvoke(); StartOfRound = __instance; RoundManager = Object.FindAnyObjectByType((FindObjectsInactive)0); Terminal = Object.FindAnyObjectByType((FindObjectsInactive)0); TimeOfDay = Object.FindAnyObjectByType((FindObjectsInactive)0); currentClientId = NetworkManager.Singleton.LocalClientId; if (!Plugin.IsSetupComplete) { StartOfRound.allItemsList.itemsList.RemoveAt(2); OnBeforeVanillaContentCollected.Invoke(); DebugStopwatch.StartStopWatch("Scrape Vanilla Content"); ContentExtractor.TryScrapeVanillaItems(StartOfRound); ContentExtractor.TryScrapeVanillaUnlockableItems(StartOfRound); ContentExtractor.TryScrapeVanillaFootstepSurfaces(StartOfRound); ContentExtractor.TryScrapeVanillaContent(StartOfRound, RoundManager); ContentExtractor.ObtainSpecialContentReferences(); OnAfterVanillaContentCollected.Invoke(); } if (LethalLevelLoaderNetworkManager.networkManager.IsServer || LethalLevelLoaderNetworkManager.networkManager.IsHost) { Object.Instantiate(LethalLevelLoaderNetworkManager.networkingManagerPrefab).GetComponent().Spawn(false); Object.Instantiate(NetworkBundleManager.networkingManagerPrefab).GetComponent().Spawn(false); } DebugStopwatch.StartStopWatch("Fix AudioSource Settings"); AudioSource[] array = Resources.FindObjectsOfTypeAll(); foreach (AudioSource val in array) { val.spatialize = false; } if (!Plugin.IsSetupComplete) { TerminalManager.CacheTerminalReferences(); DebugStopwatch.StartStopWatch("Scrape Vanilla Level Assets"); LevelManager.ObtainShipAnimatorClips(StartOfRound); LevelManager.ObtainTimeOfDayClips(TimeOfDay); LevelManager.ObtainGrassShaderReference(); DungeonLoader.defaultKeyPrefab = RoundManager.keyPrefab; DebugStopwatch.StartStopWatch("Create Vanilla ExtendedContent"); AssetBundleLoader.CreateVanillaExtendedDungeonFlows(); AssetBundleLoader.CreateVanillaExtendedLevels(StartOfRound); AssetBundleLoader.CreateVanillaExtendedItems(); AssetBundleLoader.CreateVanillaExtendedEnemyTypes(); AssetBundleLoader.CreateVanillaExtendedBuyableVehicles(); AssetBundleLoader.CreateVanillaExtendedUnlockableItems(); AssetBundleLoader.CreateVanillaExtendedFootstepSurfaces(); DebugStopwatch.StartStopWatch("Initialize Custom ExtendedContent"); AssetBundleLoader.InitializeBundles(); if (DawnLibCompatibility.Enabled) { DawnLibCompatibility.RegisterDawnExtendedLevels(); } PatchedContent.PopulateContentDictionaries(); string text = "LethalLevelLoader Loaded The Following ExtendedLevels:\n"; for (int j = 0; j < PatchedContent.ExtendedLevels.Count; j++) { ExtendedLevel extendedLevel = PatchedContent.ExtendedLevels[j]; if ((Object)(object)extendedLevel != (Object)null && (Object)(object)extendedLevel.SelectableLevel != (Object)null) { extendedLevel.SetLevelID(j); text = text + $"{j + 1}. {extendedLevel.SelectableLevel.PlanetName} ({extendedLevel.ContentType})" + "\n"; } } text += "LethalLevelLoader Loaded The Following ExtendedDungeonFlows:\n"; for (int k = 0; k < PatchedContent.ExtendedDungeonFlows.Count; k++) { ExtendedDungeonFlow extendedDungeonFlow = PatchedContent.ExtendedDungeonFlows[k]; if ((Object)(object)extendedDungeonFlow != (Object)null && (Object)(object)extendedDungeonFlow.DungeonFlow != (Object)null) { text = text + $"{k + 1}. {extendedDungeonFlow.DungeonName} ({((Object)extendedDungeonFlow.DungeonFlow).name}) ({extendedDungeonFlow.ContentType})" + "\n"; } } DebugHelper.Log(text, DebugType.User); DebugStopwatch.StartStopWatch("Restore Level Content"); foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { ContentRestorer.RestoreVanillaLevelAssetReferences(customExtendedLevel); } DebugStopwatch.StartStopWatch("Restore Dungeon Content"); foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { ContentRestorer.RestoreVanillaDungeonAssetReferences(customExtendedDungeonFlow); } DebugStopwatch.StartStopWatch("Restore Additional Content"); ContentRestorer.RestoreVanillaItemAssetReferences(); ContentRestorer.DestroyRestoredAssets(); OnAfterCustomContentRestored.Invoke(); DebugStopwatch.StartStopWatch("Dynamic Risk Level"); LevelManager.PopulateDynamicRiskLevelDictionary(); LevelManager.AssignCalculatedRiskLevels(); DebugStopwatch.StartStopWatch("Apply, Merge & Populate Content Tags"); ContentTagParser.ApplyVanillaContentTags(); ContentTagManager.MergeAllExtendedModTags(); ContentTagManager.PopulateContentTagData(); DebugHelper.DebugAllContentTags(); } DebugStopwatch.StartStopWatch("Bind Configs"); ConfigLoader.BindConfigs(); DebugStopwatch.StartStopWatch("ExtendedLevel Injection"); LevelManager.PatchVanillaLevelLists(); DebugStopwatch.StartStopWatch("ExtendedDungeonFlow Injection"); DungeonManager.PatchVanillaDungeonLists(); DebugStopwatch.StartStopWatch("ExtendedItem Injection"); ItemManager.PatchVanillaBuyableItemsLists(); ItemManager.RefreshDynamicItemRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("ExtendedEnemyType Injection"); if (!Plugin.IsSetupComplete) { EnemyManager.UpdateEnemyIDs(); } foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { TerminalManager.CreateEnemyTypeTerminalData(customExtendedEnemyType); } if (!Plugin.IsSetupComplete) { EnemyManager.AddCustomEnemyTypesToTestAllEnemiesLevel(); EnemyManager.PopulateEnemySizeLists(); } EnemyManager.RefreshDynamicEnemyTypeRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("ExtendedBuyableVehicle Injection"); if (!Plugin.IsSetupComplete) { VehiclesManager.SetBuyableVehicleIDs(); } VehiclesManager.PatchVanillaVehiclesLists(); if (!Plugin.IsSetupComplete) { VehiclesManager.SetBuyableVehicleIDs(); foreach (ExtendedBuyableVehicle customExtendedBuyableVehicle in PatchedContent.CustomExtendedBuyableVehicles) { TerminalManager.CreateBuyableVehicleTerminalData(customExtendedBuyableVehicle); } } DebugStopwatch.StartStopWatch("ExtendedUnlockableItem Injection"); if (!Plugin.IsSetupComplete) { UnlockableItemManager.PatchVanillaUnlockableItemLists(); UnlockableItemManager.SetUnlockableItemIDs(); foreach (ExtendedUnlockableItem customExtendedUnlockableItem in PatchedContent.CustomExtendedUnlockableItems) { TerminalManager.CreateUnlockableItemTerminalData(customExtendedUnlockableItem); } } DebugStopwatch.StartStopWatch("ExtendedFootstepSurface Injection"); FootstepSurfaceManager.PatchVanillaFootstepSurfaceLists(); DebugStopwatch.StartStopWatch("ExtendedStoryLog Injection"); TerminalManager.CreateTerminalDataForAllExtendedStoryLogs(); DebugStopwatch.StartStopWatch("Create ExtendedLevelGroups & Filter Assets"); TerminalManager.CreateExtendedLevelGroups(); if (!Plugin.IsSetupComplete) { TerminalManager.CreateMoonsFilterTerminalAssets(); CompatibleNoun[] compatibleNouns = TerminalManager.routeKeyword.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns) { TerminalManager.AddTerminalNodeEventListener(val2.result, TerminalManager.OnBeforeRouteNodeLoaded, TerminalManager.LoadNodeActionType.Before); } TerminalManager.AddTerminalNodeEventListener(TerminalManager.moonsKeyword.specialKeywordResult, TerminalManager.RefreshMoonsCataloguePage, TerminalManager.LoadNodeActionType.After); } DebugStopwatch.StartStopWatch("Initialize Save"); if (LethalLevelLoaderNetworkManager.networkManager.IsServer) { SaveManager.InitializeSave(); } DebugStopwatch.StopStopWatch("Initialize Save"); if (!Plugin.IsSetupComplete) { AssetBundleLoader.CreateVanillaExtendedWeatherEffects(TimeOfDay); WeatherManager.RefreshVanillaWeatherEffects(TimeOfDay); WeatherManager.PopulateExtendedLevelEnabledExtendedWeatherEffects(); Plugin.CompleteSetup(); StartOfRound.SetPlanetsWeather(0); } else { WeatherManager.RefreshVanillaWeatherEffects(TimeOfDay); } Plugin.LobbyInitialized(); } [HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool StartOfRoundSetPlanetsWeather_Prefix(int connectedPlayersOnServer) { if (!Plugin.IsSetupComplete) { DebugHelper.LogWarning("Exiting SetPlanetsWeather() Early To Avoid Weather Being Set Before Custom Levels Are Registered.", DebugType.User); return false; } return true; } [HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void StartOfRoundSetPlanetsWeather_Postfix() { if (IsServer) { LethalLevelLoaderNetworkManager.Instance.GetUpdatedLevelCurrentWeatherServerRpc(); } } [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPrefix] [HarmonyPriority(200)] public static void StartOfRoundChangeLevel_Prefix(ref int levelID) { if (!IsServer) { return; } if (!hasInitiallyChangedLevel && !string.IsNullOrEmpty(SaveManager.currentSaveFile.CurrentLevelName)) { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (((Object)extendedLevel.SelectableLevel).name == SaveManager.currentSaveFile.CurrentLevelName) { DebugHelper.Log("Loading Previously Saved SelectableLevel: " + extendedLevel.SelectableLevel.PlanetName, DebugType.User); levelID = Array.FindIndex(StartOfRound.levels, (SelectableLevel level) => (Object)(object)level == (Object)(object)extendedLevel.SelectableLevel); hasInitiallyChangedLevel = true; return; } } } if (!hasInitiallyChangedLevel && !string.IsNullOrEmpty(SaveManager.currentSaveFile.CurrentLevelName) && !SaveManager.currentSaveFile.CurrentLevelName.Contains("Experimentation") && (levelID >= StartOfRound.levels.Length || levelID > OriginalContent.SelectableLevels.Count)) { levelID = 0; } hasInitiallyChangedLevel = true; } [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPostfix] [HarmonyPriority(200)] public static void StartOfRoundChangeLevel_Postfix(int levelID) { NetworkBundleManager.Instance.Refresh(); if (IsServer && (Object)(object)RoundManager.currentLevel != (Object)null && SaveManager.currentSaveFile.CurrentLevelName != RoundManager.currentLevel.PlanetName) { DebugHelper.Log("Saving Current SelectableLevel: " + RoundManager.currentLevel.PlanetName, DebugType.User); SaveManager.currentSaveFile.CurrentLevelName = ((Object)RoundManager.currentLevel).name; } } [HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void StartOfRoundLoadShipGrabbableItems_Prefix() { SaveManager.LoadShipGrabbableItems(); } [HarmonyPatch(typeof(Terminal), "ParseWord")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void TerminalParseWord_Postfix(Terminal __instance, ref TerminalKeyword __result, string playerWord) { if ((Object)(object)__result != (Object)null) { TerminalKeyword val = TerminalManager.TryFindAlternativeNoun(__instance, __result, playerWord); if ((Object)(object)val != (Object)null) { __result = val; } } } [HarmonyPatch(typeof(Terminal), "RunTerminalEvents")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool TerminalRunTerminalEvents_Prefix(Terminal __instance, TerminalNode node) { return TerminalManager.OnBeforeLoadNewNode(ref node); } [HarmonyPatch(typeof(Terminal), "LoadNewNode")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool TerminalLoadNewNode_Prefix(Terminal __instance, ref TerminalNode node) { TerminalManager.moonsInCataloguePage = 0; TerminalManager.linesInCataloguePage = 0; return TerminalManager.OnBeforeLoadNewNode(ref node); } [HarmonyPatch(typeof(Terminal), "LoadNewNode")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void TerminalLoadNewNode_Postfix(Terminal __instance, ref TerminalNode node) { TerminalManager.OnLoadNewNode(ref node); } [HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable TerminalScrollMouse_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0051: 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_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown FieldInfo field = typeof(PlayerControllerB).GetField("terminalScrollVertical", BindingFlags.Instance | BindingFlags.Public); MethodInfo getMethod = typeof(Scrollbar).GetProperty("value", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo setMethod = typeof(Scrollbar).GetProperty("value", BindingFlags.Instance | BindingFlags.Public).GetSetMethod(); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[9] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Dup, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)3f, (string)null), new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)setMethod, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match 1/3 Terminal scroll amount.", DebugType.User); return instructions; } MethodInfo method = typeof(Patches).GetMethod("TryAdaptTerminalScrolling", BindingFlags.Static | BindingFlags.NonPublic); Label label = default(Label); return val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)field), new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Call, (object)method), new CodeInstruction(OpCodes.Brfalse_S, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }).CreateLabel(ref label).Advance(-2) .SetOperandAndAdvance((object)label) .InstructionEnumeration(); } private static bool TryAdaptTerminalScrolling(Scrollbar scrollbar, float scrollDirection) { if (TerminalManager.moonsInCataloguePage == 0) { return false; } if (TerminalManager.linesInCataloguePage == 0) { TerminalManager.linesInCataloguePage = Terminal.currentText.Split('\n').Length; } scrollbar.value += scrollDirection * (TerminalManager.linesToScroll / (float)TerminalManager.linesInCataloguePage); return true; } [HarmonyPatch(typeof(SceneManager), "Internal_SceneLoaded")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void OnSceneLoaded(ref Scene scene, LoadSceneMode mode) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel == (Object)null || !currentExtendedLevel.IsLevelLoaded) { return; } LevelLoader.currentLevelScene = scene; if (currentExtendedLevel.ContentType != ContentType.External) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject parent in rootGameObjects) { ContentRestorer.RestoreAudioAssetReferencesInParent(parent); } LevelLoader.RestoreSceneBlankReferences(); LevelLoader.RefreshWeatherEffects(currentExtendedLevel); LevelLoader.RefreshTimeOfDayMusic(currentExtendedLevel); if (currentExtendedLevel.UseTerrainFootsteps) { TerrainManager.BakeTerrainFootsteps(); SceneManager.sceneUnloaded += TerrainManager.CleanupTerrainFootsteps; } LevelLoader.ApplyCameraDistanceOverride(GameNetworkManager.Instance.localPlayerController, outside: true); LevelLoader.ValidateMapPropsContainer(); if ((Object)(object)currentExtendedLevel.SelectableLevel != (Object)null && currentExtendedLevel.SelectableLevel.spawnEnemiesAndScrap) { LevelLoader.RestoreRuntimeDungeon(); } } EventPatches.previousDayMode = (DayMode)(-1); currentExtendedLevel.LevelEvents.onLevelLoaded.Invoke(); LevelManager.GlobalLevelEvents.onLevelLoaded.Invoke(); } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void GenerateNewLevelClientRpc_Prefix(RoundManager __instance, int randomSeed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel != (Object)null && currentExtendedLevel.IsLevelLoaded && currentExtendedLevel.ContentType != ContentType.External) { LevelLoader.RefreshShipAnimatorClips(currentExtendedLevel, randomSeed); } } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable StartOfRoundStartGame_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((OpCode?)OpCodes.Call, (object)typeof(NetworkBehaviour).GetProperty("NetworkManager", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty).GetGetMethod(), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)typeof(NetworkManager).GetProperty("SceneManager", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty).GetGetMethod(), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)typeof(StartOfRound).GetField("currentLevel"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)typeof(SelectableLevel).GetField("sceneName"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)typeof(NetworkSceneManager).GetMethod("LoadScene", BindingFlags.Public), (string)null), new CodeMatch((OpCode?)OpCodes.Pop, (object)null, (string)null) }).Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldfld, (object)typeof(StartOfRound).GetField("randomMapSeed")), new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("PerformSceneSelection", BindingFlags.Static | BindingFlags.NonPublic)), new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).InstructionEnumeration(); } private static void PerformSceneSelection(int randomMapSeed) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (!IsServer || (Object)(object)currentExtendedLevel == (Object)null || currentExtendedLevel.ContentType == ContentType.External) { return; } currentExtendedLevel.SelectableLevel.sceneName = string.Empty; Random random = new Random(randomMapSeed); int num = 1; foreach (StringWithRarity sceneSelection in currentExtendedLevel.SceneSelections) { DebugHelper.Log("Scene Selection #" + num + " \"" + sceneSelection.Name + "\" (" + sceneSelection.Rarity + ")", DebugType.Developer); num++; } int[] array = new int[currentExtendedLevel.SceneSelections.Count]; for (int i = 0; i < array.Length; i++) { array[i] = currentExtendedLevel.SceneSelections[i]?.Rarity ?? (-1); } int randomWeightedIndex = RoundManager.GetRandomWeightedIndex(array, random); currentExtendedLevel.SelectableLevel.sceneName = currentExtendedLevel.SceneSelections[randomWeightedIndex].Name; DebugHelper.Log("Selected SceneName: " + currentExtendedLevel.SelectableLevel.sceneName + " For ExtendedLevel: " + currentExtendedLevel.NumberlessPlanetName, DebugType.Developer); } [HarmonyPatch(typeof(StartOfRound), "SceneManager_OnLoadComplete1")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void StartOfRoundOnLoadComplete_Prefix(string sceneName) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (!((Object)(object)currentExtendedLevel == (Object)null) && !string.Equals(currentExtendedLevel.SelectableLevel.sceneName, sceneName, StringComparison.Ordinal)) { int num = currentExtendedLevel.SceneSelections.FindIndex((StringWithRarity scene) => string.Equals(scene.Name, sceneName, StringComparison.Ordinal)); if (num != -1) { currentExtendedLevel.SelectableLevel.sceneName = sceneName; } else if (!string.Equals(sceneName, "SampleSceneRelay", StringComparison.Ordinal)) { DebugHelper.LogFatal("Critical Failure! Scene '" + sceneName + "' has no selection entry for ExtendedLevel " + currentExtendedLevel.NumberlessPlanetName + "!", DebugType.User); } } } [HarmonyPatch(typeof(DungeonGenerator), "Generate")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void DungeonGeneratorGenerate_Prefix() { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DungeonLoader.PrepareDungeon(); } LevelManager.LogDayHistory(); if ((Object)(object)RoundManager != (Object)null && ((Object)(object)RoundManager.dungeonGenerator == (Object)null || (Object)(object)RoundManager.dungeonGenerator.Generator?.DungeonFlow == (Object)null)) { DebugHelper.LogFatal("Critical Failure! DungeonGenerator DungeonFlow Is Null!", DebugType.User); } } [HarmonyPatch(typeof(RoundManager), "Generator_OnGenerationStatusChanged")] [HarmonyTranspiler] public static IEnumerable OnGenerationStatusChanged_Transpiler(IEnumerable instructions) { //IL_0002: 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_0022: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Bne_Un, (object)null, (string)null) }); if (val.IsInvalid) { return instructions; } object operand = val.Operand; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null) }); if (val.IsInvalid) { return instructions; } val.Operand = operand; return val.InstructionEnumeration(); } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyTranspiler] public static IEnumerable GenerateNewLevelClientRpc_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)typeof(RoundManager).GetMethod("GenerateNewFloor", BindingFlags.Instance | BindingFlags.Public), (string)null) }).SetInstruction(new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("InjectHostDungeonFlowSelection", BindingFlags.Static | BindingFlags.NonPublic))) .InstructionEnumeration(); } [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] [HarmonyTranspiler] public static IEnumerable GenerateNewFloor_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)typeof(RoundManager).GetField("dungeonGenerator", BindingFlags.Instance | BindingFlags.Public), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)typeof(RuntimeDungeon).GetMethod("Generate", BindingFlags.Instance | BindingFlags.Public), (string)null) }).SetInstruction(new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("InjectHostDungeonSizeSelection", BindingFlags.Static | BindingFlags.Public))) .InstructionEnumeration(); } public static void InjectHostDungeonSizeSelection(RoundManager roundManager) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LethalLevelLoaderNetworkManager.Instance.GetDungeonFlowSizeServerRpc(); } else { roundManager.dungeonGenerator.Generate(); } } internal static void InjectHostDungeonFlowSelection(RoundManager roundManager) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel != (Object)null && currentExtendedLevel.IsLevelLoaded && (Object)(object)currentExtendedLevel.SelectableLevel != (Object)null && currentExtendedLevel.SelectableLevel.spawnEnemiesAndScrap) { DungeonLoader.SelectDungeon(); } else { roundManager.GenerateNewFloor(); } } [HarmonyPatch(typeof(RoundManager), "SetLockedDoors")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void RoundManagerSetLockedDoors_Prefix() { RoundManager.keyPrefab = (((Object)(object)DungeonManager.CurrentExtendedDungeonFlow.OverrideKeyPrefab != (Object)null) ? DungeonManager.CurrentExtendedDungeonFlow.OverrideKeyPrefab : DungeonLoader.defaultKeyPrefab); } [HarmonyPatch(typeof(RoundManager), "SpawnOutsideHazards")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void RoundManagerSpawnOutsideHazards_Prefix() { RoundManager.quicksandPrefab = (((Object)(object)LevelManager.CurrentExtendedLevel.OverrideQuicksandPrefab != (Object)null) ? LevelManager.CurrentExtendedLevel.OverrideQuicksandPrefab : LevelLoader.defaultQuicksandPrefab); } [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void RoundManagerFinishGeneratingNewLevelClientRpc_Prefix(RoundManager __instance, ref bool __state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 __state = (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1; } [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void RoundManagerFinishGeneratingNewLevelClientRpc_Postfix(bool __state) { if (!__state) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel != (Object)null && currentExtendedLevel.IsLevelLoaded && currentExtendedLevel.ContentType != ContentType.External) { LevelLoader.RestoreShaders(); } } } [HarmonyPatch(typeof(StoryLog), "Start")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void StoryLogStart_Prefix(StoryLog __instance) { //IL_002b: 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) foreach (ExtendedStoryLog extendedStoryLog in LevelManager.CurrentExtendedLevel.ExtendedMod.ExtendedStoryLogs) { string sceneName = extendedStoryLog.sceneName; Scene scene = ((Component)__instance).gameObject.scene; if (sceneName == ((Scene)(ref scene)).name && __instance.storyLogID == extendedStoryLog.storyLogID) { DebugHelper.Log("Updating " + extendedStoryLog.storyLogTitle + "ID", DebugType.Developer); __instance.storyLogID = extendedStoryLog.newStoryLogID; } } } [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void RoundManagerSpawnMapObjects_Prefix(SelectableLevel ___currentLevel) { temporaryIndoorMapHazards.UnionWith(DungeonManager.CurrentExtendedDungeonFlow.IndoorMapHazards); if (___currentLevel.indoorMapHazards == null) { ___currentLevel.indoorMapHazards = Array.Empty(); } IndoorMapHazard[] indoorMapHazards = ___currentLevel.indoorMapHazards; HashSet hashSet = temporaryIndoorMapHazards; int num = 0; IndoorMapHazard[] array = (IndoorMapHazard[])(object)new IndoorMapHazard[indoorMapHazards.Length + hashSet.Count]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(indoorMapHazards); readOnlySpan.CopyTo(new Span(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; foreach (IndoorMapHazard item in hashSet) { array[num] = item; num++; } ___currentLevel.indoorMapHazards = array; } [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void RoundManagerSpawnMapObjects_Postfix(SelectableLevel ___currentLevel) { ___currentLevel.indoorMapHazards = Array.FindAll(___currentLevel.indoorMapHazards, (IndoorMapHazard mapHazard) => !temporaryIndoorMapHazards.Contains(mapHazard)); temporaryIndoorMapHazards.Clear(); } [HarmonyPatch(typeof(RoundManager), "GeneratedFloorPostProcessing")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void RoundManagerGeneratedFloorPostProcessing_Prefix() { if (Settings.injectDynamicMatchingWeights) { ItemManager.InjectCustomItemsIntoLevelViaDynamicRarity(LevelManager.CurrentExtendedLevel, DungeonManager.CurrentExtendedDungeonFlow); EnemyManager.InjectCustomEnemyTypesIntoLevelViaDynamicRarity(LevelManager.CurrentExtendedLevel, DungeonManager.CurrentExtendedDungeonFlow); } } [HarmonyPatch(typeof(PlayerControllerB), "GetCurrentMaterialStandingOn")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable SwapActiveTerrain_Transpiler(IEnumerable instructions) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown MethodInfo methodInfo = typeof(Component).GetMethod("GetComponent", 1, Array.Empty()).MakeGenericMethod(typeof(Terrain)); MethodInfo method = typeof(Object).GetMethod("op_Inequality", BindingFlags.Static | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)methodInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)method, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match Terrain null comparison.", DebugType.User); return instructions; } Type type = Type.MakeGenericMethodParameter(0).MakeByRefType(); MethodInfo methodInfo2 = typeof(Component).GetMethod("TryGetComponent", 1, new Type[1] { type }).MakeGenericMethod(typeof(Terrain)); MethodInfo getMethod = typeof(Terrain).GetProperty("activeTerrain", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); val.RemoveInstructions(3).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloca_S, (object)(sbyte)0), new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2) }).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match active Terrain local variable assignment.", DebugType.User); return instructions; } MethodInfo getMethod2 = typeof(Terrain).GetProperty("terrainData", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); val.SetOpcodeAndAdvance(OpCodes.Pop).MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)getMethod2, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match TerrainData local variable assignment.", DebugType.User); return instructions; } MethodInfo method2 = typeof(TerrainManager).GetMethod("SwapTerrainAlphaMap", BindingFlags.Static | BindingFlags.NonPublic); return val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Call, (object)method2) }).InstructionEnumeration(); } [HarmonyPatch(typeof(PlayerControllerB), "GetCurrentMaterialStandingOn")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable SwapFootstepSurface_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown MethodInfo getMethod = typeof(StartOfRound).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); FieldInfo field = typeof(StartOfRound).GetField("currentLevel", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = typeof(SelectableLevel).GetField("levelID", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field2, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_2, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match Vow level check.", DebugType.User); return instructions; } FieldInfo field3 = typeof(PlayerControllerB).GetField("currentFootstepSurfaceIndex", BindingFlags.Instance | BindingFlags.Public); MethodInfo method = typeof(FootstepSurfaceManager).GetMethod("TryGetAndSetFootstepSurfaceIndex", new Type[3] { typeof(Terrain), typeof(int), typeof(PlayerControllerB) }); Label label = default(Label); val.CreateLabel(ref label).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Ldloc_3, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)method), new CodeInstruction(OpCodes.Brfalse, (object)label), new CodeInstruction(OpCodes.Ret, (object)null) }).MatchForward(true, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field3, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)12, (string)null), new CodeMatch((OpCode?)OpCodes.Beq, (object)null, (string)null) }); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match Gunkfish slime footstep check when replacing footsteps.", DebugType.User); return instructions; } MethodInfo method2 = typeof(FootstepSurfaceManager).GetMethod("SwitchToUntaggedIndex", BindingFlags.Static | BindingFlags.NonPublic); return val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldflda, (object)field3), new CodeInstruction(OpCodes.Call, (object)method2) }).InstructionEnumeration(); } [HarmonyPatch(typeof(PlayerControllerB), "GetCurrentMaterialStandingOn")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable RestoreOldFootsteps_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown FieldInfo field = typeof(PlayerControllerB).GetField("currentFootstepSurfaceIndex", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)12, (string)null), new CodeMatch((OpCode?)OpCodes.Beq, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match Gunkfish slime footstep check when restoring footsteps.", DebugType.User); return instructions; } Label label = default(Label); val.CreateLabel(ref label).MatchBack(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null) }); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match 'checkStandingOnTerrain' check.", DebugType.User); return instructions; } MethodInfo getMethod = typeof(LevelManager).GetProperty("CurrentExtendedLevel", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); MethodInfo getMethod2 = typeof(ExtendedLevel).GetProperty("UseTerrainFootsteps", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); Label label2 = default(Label); return val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)getMethod), new CodeInstruction(OpCodes.Callvirt, (object)getMethod2), new CodeInstruction(OpCodes.Brfalse, (object)label) }).CreateLabel(ref label2).Advance(-2) .SetOperandAndAdvance((object)label2) .InstructionEnumeration(); } [HarmonyPatch(typeof(SandWormAI), "StartEmergeAnimation")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable SandWormAIStartEmergeAnimation_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Expected O, but got Unknown MethodInfo getMethod = typeof(RaycastHit).GetProperty("collider", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo getMethod2 = typeof(Component).GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo getMethod3 = typeof(Terrain).GetProperty("activeTerrain", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); MethodInfo method = typeof(Object).GetMethod("op_Equality", BindingFlags.Static | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)getMethod2, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod3, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)getMethod2, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)method, (string)null) }); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match active Terrain equality check.", DebugType.User); return instructions; } CodeInstruction instructionAndAdvance = val.InstructionAt(-2); LocalBuilder localBuilder = generator.DeclareLocal(typeof(Terrain)); Type type = Type.MakeGenericMethodParameter(0).MakeByRefType(); MethodInfo methodInfo = typeof(Component).GetMethod("TryGetComponent", 1, new Type[1] { type }).MakeGenericMethod(typeof(Terrain)); val.RemoveInstructions(4).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloca_S, (object)localBuilder), new CodeInstruction(OpCodes.Callvirt, (object)methodInfo) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match local variable true assignment.", DebugType.User); return instructions; } MethodInfo getMethod4 = typeof(RaycastHit).GetProperty("point", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo method2 = typeof(TerrainManager).GetMethod("CanWormEmergeFromPoint", BindingFlags.Static | BindingFlags.Public); return val.SetInstructionAndAdvance(instructionAndAdvance).Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, (object)getMethod4), new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder), new CodeInstruction(OpCodes.Call, (object)method2) }).InstructionEnumeration(); } [HarmonyPatch(typeof(MaskedPlayerEnemy), "GetMaterialStandingOn")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable MaskedPlayerEnemyGetMaterialStandingOn_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0068: 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_0088: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown FieldInfo field = typeof(MaskedPlayerEnemy).GetField("enemyRayHit", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo getMethod = typeof(RaycastHit).GetProperty("collider", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo getMethod2 = typeof(StartOfRound).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); FieldInfo field2 = typeof(StartOfRound).GetField("footstepSurfaces", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldflda, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod2, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field2, (string)null) }); if (val.Advance(3).IsInvalid) { DebugHelper.LogError("Could not match RaycastHit collider getter.", DebugType.User); return instructions; } LocalBuilder localBuilder = generator.DeclareLocal(typeof(Terrain)); LocalBuilder localBuilder2 = generator.DeclareLocal(typeof(int)); Type type = Type.MakeGenericMethodParameter(0).MakeByRefType(); MethodInfo methodInfo = typeof(Component).GetMethod("TryGetComponent", 1, new Type[1] { type }).MakeGenericMethod(typeof(Terrain)); MethodInfo getMethod3 = typeof(RaycastHit).GetProperty("point", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo method = typeof(TerrainManager).GetMethod("TryObtainTerrainLayerAtPoint", BindingFlags.Static | BindingFlags.Public); MethodInfo method2 = typeof(FootstepSurfaceManager).GetMethod("TryGetAndSetFootstepSurfaceIndex", new Type[3] { typeof(Terrain), typeof(int), typeof(MaskedPlayerEnemy) }); Label label = default(Label); return val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldflda, (object)field), new CodeInstruction(OpCodes.Call, (object)getMethod) }).CreateLabel(ref label).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[16] { new CodeInstruction(OpCodes.Ldloca_S, (object)localBuilder), new CodeInstruction(OpCodes.Callvirt, (object)methodInfo), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldflda, (object)field), new CodeInstruction(OpCodes.Call, (object)getMethod3), new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder), new CodeInstruction(OpCodes.Ldloca_S, (object)localBuilder2), new CodeInstruction(OpCodes.Call, (object)method), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder), new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)method2), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ret, (object)null) }) .InstructionEnumeration(); } [HarmonyPatch(typeof(EntranceTeleport), "PlayCreakSFX")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable EntranceTeleportPlayCreakSFX_Transpiler(IEnumerable instructions) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown MethodInfo getMethod = typeof(StartOfRound).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); FieldInfo field = typeof(StartOfRound).GetField("creakOpenDoorMetal", BindingFlags.Instance | BindingFlags.Public); CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }; CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, array); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match first creakOpenDoorMetal local variable assignment.", DebugType.User); return instructions; } CodeInstruction instruction = val.Instruction; MethodInfo method = typeof(Patches).GetMethod("SwapOpenDoorSFX", BindingFlags.Static | BindingFlags.NonPublic); FieldInfo field2 = typeof(EntranceTeleport).GetField("isEntranceToBuilding", BindingFlags.Instance | BindingFlags.Public); val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldloca_S, (object)(sbyte)0)).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)field2), new CodeInstruction(OpCodes.Call, (object)method), instruction }).MatchForward(true, array); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match second creakOpenDoorMetal local variable assignment.", DebugType.User); return instructions; } instruction = val.Instruction; FieldInfo field3 = typeof(EntranceTeleport).GetField("exitScript", BindingFlags.Instance | BindingFlags.Public); return val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldloca_S, (object)(sbyte)0)).Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)field3), new CodeInstruction(OpCodes.Ldfld, (object)field2), new CodeInstruction(OpCodes.Call, (object)method), instruction }).InstructionEnumeration(); } private static void SwapOpenDoorSFX(ref AudioClip[] openDoorClips, bool isEntranceToBuilding) { if (isEntranceToBuilding) { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (!((Object)(object)currentExtendedLevel == (Object)null) && currentExtendedLevel.ContentType != ContentType.External) { AudioClip[] overrideCreakOpenDoorSFX = currentExtendedLevel.OverrideCreakOpenDoorSFX; if (overrideCreakOpenDoorSFX != null && overrideCreakOpenDoorSFX.Length != 0) { openDoorClips = currentExtendedLevel.OverrideCreakOpenDoorSFX; } } return; } ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; if (!((Object)(object)currentExtendedDungeonFlow == (Object)null) && currentExtendedDungeonFlow.ContentType != ContentType.External) { AudioClip[] overrideCreakOpenDoorSFX2 = currentExtendedDungeonFlow.OverrideCreakOpenDoorSFX; if (overrideCreakOpenDoorSFX2 != null && overrideCreakOpenDoorSFX2.Length != 0) { openDoorClips = currentExtendedDungeonFlow.OverrideCreakOpenDoorSFX; } } } [HarmonyPatch(typeof(EntranceTeleport), "PlayAudioAtTeleportPositions")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable EntranceTeleportPlayAudioAtTeleportPositions_Transpiler(IEnumerable instructions) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown MethodInfo getMethod = typeof(StartOfRound).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(); FieldInfo field = typeof(StartOfRound).GetField("shutDoorMetal", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Call, (object)getMethod, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }); if (val.Advance(1).IsInvalid) { DebugHelper.LogError("Could not match shutDoorMetal local variable assignment.", DebugType.User); return instructions; } CodeInstruction instruction = val.Instruction; MethodInfo method = typeof(Patches).GetMethod("SwapShutDoorSFX", BindingFlags.Static | BindingFlags.NonPublic); return val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldloca_S, (object)(sbyte)0)).Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloca_S, (object)(sbyte)1), new CodeInstruction(OpCodes.Call, (object)method), instruction }).InstructionEnumeration(); } private static void SwapShutDoorSFX(ref AudioClip[] shutDoorClipsInside, ref AudioClip[] shutDoorClipsOutside) { ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; if ((Object)(object)currentExtendedDungeonFlow != (Object)null && currentExtendedDungeonFlow.ContentType != ContentType.External) { AudioClip[] overrideCreakShutDoorSFX = currentExtendedDungeonFlow.OverrideCreakShutDoorSFX; if (overrideCreakShutDoorSFX != null && overrideCreakShutDoorSFX.Length != 0) { shutDoorClipsInside = currentExtendedDungeonFlow.OverrideCreakShutDoorSFX; } } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel != (Object)null && currentExtendedLevel.ContentType != ContentType.External) { AudioClip[] overrideCreakShutDoorSFX2 = currentExtendedLevel.OverrideCreakShutDoorSFX; if (overrideCreakShutDoorSFX2 != null && overrideCreakShutDoorSFX2.Length != 0) { shutDoorClipsOutside = currentExtendedLevel.OverrideCreakShutDoorSFX; } } } [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void EntranceTeleportTeleportPlayerServerRpc_Prefix(EntranceTeleport __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage == 0) { LevelLoader.ApplyCameraDistanceOverride(GameNetworkManager.Instance.localPlayerController, !__instance.isEntranceToBuilding); } } [HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void PlayerControllerBTeleportPlayer_Postfix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner) { LevelLoader.ApplyCameraDistanceOverride(__instance, !__instance.isInsideFactory); } } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPatch(typeof(StartOfRound), "ChangePlanet")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void StartOfRoundChangePlanet_Postfix() { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { LevelLoader.ApplyCameraDistanceOverride(GameNetworkManager.Instance.localPlayerController, outside: true, inOrbit: true); } } [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void StartOfRoundOnClientConnect_Postfix() { NetworkBundleManager.Instance.OnClientsChangedRefresh(); } [HarmonyPatch(typeof(StartOfRound), "OnClientDisconnect")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void StartOfRoundOnClientDisconnect_Postfix(ulong clientId) { if (clientId != currentClientId) { NetworkBundleManager.Instance.OnClientsChangedRefresh(); } } [HarmonyPatch(typeof(NetworkConnectionManager), "OnClientDisconnectFromServer")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void NetworkConnectionManagerOnClientDisconnectFromServer_Postfix(ulong clientId) { if (clientId != currentClientId) { NetworkBundleManager.Instance.OnClientsChangedRefresh(); } } [HarmonyPatch(typeof(StartMatchLever), "Update")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable StartMatchLever_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Call, (object)typeof(GameNetworkManager).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public).GetGetMethod(), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)typeof(GameNetworkManager).GetField("gameHasStarted", BindingFlags.Instance | BindingFlags.Public), (string)null) }; Label label = default(Label); return new CodeMatcher(instructions, generator).MatchForward(false, array).Advance(3).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)typeof(StartMatchLever).GetField("triggerScript", BindingFlags.Instance | BindingFlags.Public)), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Stfld, (object)typeof(InteractTrigger).GetField("interactable", BindingFlags.Instance | BindingFlags.Public)) }) .MatchForward(false, array) .CreateLabel(ref label) .Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)typeof(StartMatchLever).GetField("triggerScript", BindingFlags.Instance | BindingFlags.Public)), new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("CheckLever", BindingFlags.Static | BindingFlags.NonPublic)), new CodeInstruction(OpCodes.Brtrue, (object)label), new CodeInstruction(OpCodes.Ret, (object)null) }) .InstructionEnumeration(); } private static bool CheckLever(InteractTrigger trigger) { trigger.interactable = NetworkBundleManager.AllowedToLoadLevel && !StartOfRound.travellingToNewLevel; if (!trigger.interactable) { trigger.disabledHoverTip = (StartOfRound.travellingToNewLevel ? "Routing..." : "[ At least one player is loading custom moon! ]"); return false; } return true; } [HarmonyPatch(typeof(DoorwayPairFinder), "GetDoorwayPairs")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool GetDoorwayPairsPatch(DoorwayPairFinder __instance, ref int? maxCount, ref Queue __result) { //IL_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references) __instance.tileOrder = __instance.CalculateOrderedListOfTiles(); IEnumerable enumerable = ((__instance.PreviousTile == null) ? __instance.GetPotentialDoorwayPairsForFirstTile() : __instance.GetPotentialDoorwayPairsForNonFirstTile()); int num = enumerable.Count(); if (maxCount.HasValue) { num = Mathf.Min(num, maxCount.Value); } __result = new Queue(num); foreach (DoorwayPair item in OrderDoorwayPairs(enumerable, num)) { __result.Enqueue(item); } return false; } private static IEnumerable OrderDoorwayPairs(IEnumerable list, int num) { return list.OrderBy((DoorwayPair doorwayPair) => doorwayPair, default(DoorwayPairComparer)).Take(num); } [HarmonyPatch(typeof(StartOfRound), "LoadPlanetsMoldSpreadData")] [HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")] [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPatch(typeof(MoldSpreadManager), "Start")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable MoldSaveData_Transpiler(IEnumerable instructions) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown MethodInfo gameObjectGetter = typeof(GameObject).GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); MethodInfo objectNameGetter = typeof(Object).GetProperty("name", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(); FieldInfo levelIDInfo = typeof(SelectableLevel).GetField("levelID", BindingFlags.Instance | BindingFlags.Public); return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)null, (string)null) }).Repeat((Action)delegate(CodeMatcher matcher) { string text = $"{matcher.Operand}"; if (text.StartsWith("Level{0}", StringComparison.Ordinal)) { matcher.SearchForward((Func)((CodeInstruction ci) => CodeInstructionExtensions.Is(ci, OpCodes.Ldfld, (MemberInfo)levelIDInfo))).SetAndAdvance(OpCodes.Callvirt, (object)gameObjectGetter).SetAndAdvance(OpCodes.Callvirt, (object)objectNameGetter); } else { matcher.Advance(1); } }, (Action)null).InstructionEnumeration(); } } internal static class SafetyPatches { [HarmonyPriority(200)] [HarmonyPatch(typeof(TimeOfDay), "SetWeatherBasedOnVariables")] [HarmonyPrefix] internal static void TimeOfDaySetWeatherBasedOnVariables_Prefix(TimeOfDay __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.currentLevelWeather == 3) { if ((int)__instance.currentWeatherVariable >= (int)__instance.currentWeatherVariable2) { DebugHelper.LogError("TimeOfDay Foggy CurrentWeatherVariable (Int) Was Equal Or Higher Than CurrentWeatherVariable2 (Int). Resetting For Safety!", DebugType.User); __instance.currentWeatherVariable = 3f; __instance.currentWeatherVariable2 = 10f; } else if ((int)__instance.currentWeatherVariable <= 0 || (int)__instance.currentWeatherVariable2 <= 0) { DebugHelper.LogError("TimeOfDay Foggy CurrentWeatherVariable (Int) And/Or CurrentWeatherVariable2 (Int) Were 0. Resetting For Safety!", DebugType.User); __instance.currentWeatherVariable = 3f; __instance.currentWeatherVariable2 = 10f; } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(SoundManager), "ResetValues")] [HarmonyPostfix] internal static void SoundManagerResetValues_Postfix(SoundManager __instance) { ((MonoBehaviour)__instance).StartCoroutine(AttemptToFixPotentialAudioBug(__instance)); } private static IEnumerator AttemptToFixPotentialAudioBug(SoundManager soundManager) { yield return null; soundManager.SetDiageticMixerSnapshot(4, 1000f); yield return null; soundManager.SetDiageticMixerSnapshot(0, 1f); } } public enum PreviewInfoType { Price, Difficulty, Weather, History, All, None, Vanilla, Override } public enum SortInfoType { Price, Difficulty, Tag, LastTraveled, None } public enum FilterInfoType { Price, Weather, Tag, TraveledThisQuota, TraveledThisRun, None } public enum SimulateInfoType { Percentage, Rarity, All } public enum DebugType { User, Developer, IAmBatby, All } public static class Settings { public static PreviewInfoType levelPreviewInfoType = PreviewInfoType.Weather; public static SortInfoType levelPreviewSortType = SortInfoType.None; public static FilterInfoType levelPreviewFilterType = FilterInfoType.None; public static SimulateInfoType levelSimulateInfoType = SimulateInfoType.Percentage; public static DebugType debugType = DebugType.User; public static int moonsCatalogueSplitCount = 3; public static bool injectDynamicMatchingWeights = true; public static string[] bundlesBlacklist; public static bool overrideDungeonGeneratorParameters; public static bool generateAsynchronously = true; public static float maxAsyncFrameMilliseconds = 1f; public static int retryCount = 50; public static string GetOverridePreviewInfo(ExtendedLevel extendedLevel) { return string.Empty; } } internal static class TimeOfDayPatches { [HarmonyPrepare] private static void PrepareTimeOfDayPatches(MethodBase original) { if (original == null) { DebugHelper.Log("Patching TimeOfDay speed multipliers!", DebugType.User); } } [HarmonyPatch(typeof(TimeOfDay), "MoveGlobalTime")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable TimeOfDayMoveGlobalTime_Transpiler(IEnumerable instructions) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown FieldInfo field = typeof(TimeOfDay).GetField("globalTimeSpeedMultiplier", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = typeof(SelectableLevel).GetField("DaySpeedMultiplier", BindingFlags.Instance | BindingFlags.Public); FieldInfo field3 = typeof(TimeOfDay).GetField("currentLevel", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field2, (string)null) }); if (val.IsValid) { DebugHelper.LogWarning("TimeOfDay.MoveGlobalTime() already patched to account for day speed multipliers!", DebugType.Developer); return instructions; } val.Start().MatchForward(true, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogError("Could not match 'globalTimeSpeedMultiplier' field.", DebugType.User); return instructions; } return val.Insert((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)field3), new CodeInstruction(OpCodes.Ldfld, (object)field2), new CodeInstruction(OpCodes.Mul, (object)null) }).InstructionEnumeration(); } [HarmonyPatch(typeof(TimeOfDay), "Update")] [HarmonyPatch(typeof(TimeOfDay), "CalculatePlanetTime")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable TimeOfDayUpdateCalculatePlanetTime_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown FieldInfo field = typeof(SelectableLevel).GetField("DaySpeedMultiplier", BindingFlags.Instance | BindingFlags.Public); CodeMatcher val = new CodeMatcher(instructions, generator).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)field, (string)null), new CodeMatch((Func)((CodeInstruction ins) => ins.opcode == OpCodes.Mul || ins.opcode == OpCodes.Div), (string)null) }); if (val.IsInvalid) { DebugHelper.LogWarning("TimeOfDay.Update() and/or TimeOfDay.CalculatePlanetTime() already patched to account for day speed multipliers!", DebugType.Developer); return instructions; } int pos = val.Pos; val.SearchBack((Func)((CodeInstruction ins) => ins.opcode == OpCodes.Add || ins.opcode == OpCodes.Sub)); if (val.IsInvalid) { DebugHelper.LogError("Could not match operation instruction before 'DaySpeedMultiplier' field.", DebugType.User); return instructions; } return val.RemoveInstructionsInRange(val.Pos + 1, pos).InstructionEnumeration(); } } [Serializable] public class ExtendedDungeonFlowWithRarity(ExtendedDungeonFlow newExtendedDungeonFlow, int newRarity) { internal struct ExtendedDungeonFlowWithRarityComparer : IComparer { public ExtendedDungeonFlowWithRarityComparer(bool ascending = true) { P = ascending; } public readonly int Compare(ExtendedDungeonFlowWithRarity a, ExtendedDungeonFlowWithRarity b) { if (!P) { return b.newRarity - a.newRarity; } return a.newRarity - b.newRarity; } } public ExtendedDungeonFlow extendedDungeonFlow = newExtendedDungeonFlow; public int rarity = newRarity; public bool UpdateRarity(int newRarity) { if (newRarity > newRarity) { newRarity = newRarity; return true; } return false; } } public static class DungeonLoader { [CompilerGenerated] private static class <>O { public static GenerationStatusDelegate <0>__PatchOutOfBoundsTriggers; } internal static GameObject defaultKeyPrefab; internal static void SelectDungeon() { Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow = null; if (((NetworkBehaviour)LethalLevelLoaderNetworkManager.Instance).IsServer) { LethalLevelLoaderNetworkManager.Instance.GetRandomExtendedDungeonFlowServerRpc(); } } internal static void PrepareDungeon() { //IL_007d: 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_0088: Expected O, but got Unknown if ((Object)(object)Patches.RoundManager.dungeonGenerator == (Object)null) { return; } DungeonGenerator generator = Patches.RoundManager.dungeonGenerator.Generator; if (Settings.overrideDungeonGeneratorParameters) { generator.GenerateAsynchronously = Settings.generateAsynchronously; generator.MaxAsyncFrameMilliseconds = Settings.maxAsyncFrameMilliseconds; generator.retryCount = Settings.retryCount; } ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; if ((Object)(object)currentExtendedDungeonFlow == (Object)null || currentExtendedDungeonFlow.ContentType == ContentType.External) { return; } if (currentExtendedDungeonFlow.IsDynamicOutOfBoundsTriggerEnabled) { object obj = <>O.<0>__PatchOutOfBoundsTriggers; if (obj == null) { GenerationStatusDelegate val = PatchOutOfBoundsTriggers; <>O.<0>__PatchOutOfBoundsTriggers = val; obj = (object)val; } generator.OnGenerationStatusChanged += (GenerationStatusDelegate)obj; } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; PatchFireEscapes(generator, currentExtendedLevel); PatchDynamicGlobalProps(generator, currentExtendedDungeonFlow); } public static float GetClampedDungeonSize() { ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; float num = CalculateDungeonMultiplier(currentExtendedLevel, DungeonManager.CurrentExtendedDungeonFlow); if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled) { if (num > currentExtendedDungeonFlow.DynamicDungeonSizeMax) { num = Mathf.Lerp(num, currentExtendedDungeonFlow.DynamicDungeonSizeMax, currentExtendedDungeonFlow.DynamicDungeonSizeLerpRate); } else if (num < currentExtendedDungeonFlow.DynamicDungeonSizeMin) { num = Mathf.Lerp(num, currentExtendedDungeonFlow.DynamicDungeonSizeMin, currentExtendedDungeonFlow.DynamicDungeonSizeLerpRate); } DebugHelper.Log("Current ExtendedLevel: " + currentExtendedLevel.NumberlessPlanetName + " ExtendedLevel DungeonSize Is: " + currentExtendedLevel.SelectableLevel.factorySizeMultiplier + " | Overriding DungeonSize To: " + num, DebugType.User); } else { DebugHelper.Log("CurrentLevel: " + currentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + currentExtendedLevel.SelectableLevel.factorySizeMultiplier + " | Leaving DungeonSize As: " + num, DebugType.User); } return num; } public static float CalculateDungeonMultiplier(ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow) { IndoorMapType[] dungeonFlowTypes = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { if ((Object)(object)val.dungeonFlow == (Object)(object)extendedDungeonFlow.DungeonFlow) { return extendedLevel.SelectableLevel.factorySizeMultiplier / val.MapTileSize * Patches.RoundManager.mapSizeMultiplier; } } return 1f; } internal static List GetEntranceTeleports() { List list = new List(); GameObject[] rootGameObjects = ((Scene)(ref LevelLoader.currentLevelScene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { EntranceTeleport[] componentsInChildren = val.GetComponentsInChildren(false); foreach (EntranceTeleport item in componentsInChildren) { list.Add(item); } } return list; } internal static void PatchFireEscapes(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown string text = "Fire Exit Patch Report, Details Below;\n\n"; List entranceTeleports = GetEntranceTeleports(); if (entranceTeleports.Count == 0) { DebugHelper.LogFatal("No EntranceTeleports Found In The Scene!", DebugType.User); { foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps) { if (globalProp.ID == 1231) { globalProp.Count = new IntRange(0, 0); break; } } return; } } List list = new List(entranceTeleports.Count); for (int i = 0; i < entranceTeleports.Count; i++) { EntranceTeleport val = entranceTeleports[i]; if (val.entranceId == 0) { list.Add(val); entranceTeleports.RemoveAt(i--); } } if (list.Count == 0) { DebugHelper.LogError("No EntranceTeleport For Main Entrance Found In The Scene! A Fire Exit Will Act As Main Entrance Instead...", DebugType.User); } else if (list.Count > 1) { DebugHelper.LogError($"'{list.Count}' EntranceTeleports For Main Entrance Found In The Scene! Only One Will Act As Main Entrance...", DebugType.User); } entranceTeleports.AddRange(list); for (int j = 0; j < entranceTeleports.Count; j++) { entranceTeleports[j].entranceId = entranceTeleports.Count - 1 - j; } text += $"EntranceTeleports Found, {extendedLevel.NumberlessPlanetName} Contains {entranceTeleports.Count} Entrances! ({entranceTeleports.Count - 1} Fire Escapes)\n"; text += $"Main Entrance: {((Object)entranceTeleports[0]).name} (Entrance ID: {entranceTeleports[0].entranceId})\n"; foreach (EntranceTeleport item in entranceTeleports) { if (item.entranceId != 0) { text += $"Alternate Entrance: {((Object)item).name} (Entrance ID: {item.entranceId})\n"; } } foreach (GlobalPropSettings globalProp2 in dungeonGenerator.DungeonFlow.GlobalProps) { if (globalProp2.ID == 1231) { text += $"Found Fire Escape GlobalProp: (ID: 1231), Modifying Spawn rate Count From ({globalProp2.Count.Min},{globalProp2.Count.Max}) To ({entranceTeleports.Count - 1},{entranceTeleports.Count - 1})\n"; globalProp2.Count = new IntRange(entranceTeleports.Count - 1, entranceTeleports.Count - 1); break; } } DebugHelper.Log(text + "\n", DebugType.User); } public static void PatchDynamicGlobalProps(DungeonGenerator dungeonGenerator, ExtendedDungeonFlow extendedDungeonFlow) { foreach (GlobalPropCountOverride globalPropCountOverrides in extendedDungeonFlow.GlobalPropCountOverridesList) { foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps) { if (globalPropCountOverrides.globalPropID == globalProp.ID) { IntRange count = globalProp.Count; count.Min *= Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / Patches.RoundManager.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate)); IntRange count2 = globalProp.Count; count2.Max *= globalProp.Count.Max * Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / Patches.RoundManager.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate)); } } } } public static void PatchOutOfBoundsTriggers(DungeonGenerator generator, GenerationStatus status) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0041: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if ((int)status != 8) { return; } object obj = <>O.<0>__PatchOutOfBoundsTriggers; if (obj == null) { GenerationStatusDelegate val = PatchOutOfBoundsTriggers; <>O.<0>__PatchOutOfBoundsTriggers = val; obj = (object)val; } generator.OnGenerationStatusChanged -= (GenerationStatusDelegate)obj; Dungeon currentDungeon = generator.CurrentDungeon; Transform transform = ((Component)currentDungeon).transform; Bounds bounds = currentDungeon.Bounds; float y = transform.TransformPoint(((Bounds)(ref bounds)).min).y; GameObject[] rootGameObjects = ((Scene)(ref LevelLoader.currentLevelScene)).GetRootGameObjects(); foreach (GameObject val2 in rootGameObjects) { OutOfBoundsTrigger[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (OutOfBoundsTrigger val3 in componentsInChildren) { Vector3 position = ((Component)val3).transform.position; position.y = y; ((Component)val3).transform.position = position; } } } } public static class LevelLoader { internal static AnimationClip defaultShipFlyToMoonClip; internal static AnimationClip defaultShipFlyFromMoonClip; internal static LocalVolumetricFog dustCloudFog; internal static Vector3 defaultDustCloudFogVolumeSize; internal static GameObject defaultQuicksandPrefab; internal static ParticleSystem rainParticles; internal static AudioSource rainyAmbienceSource; internal static AudioClip defaultRainyAmbience; internal static GameObject rainPrefabOverrideInstance; internal static StormyWeather stormyWeather; internal static ParticleSystem defaultStormyLightningStrikeExplosion; internal static ParticleSystem defaultStormyStaticElectricityParticle; internal static AudioClip[] defaultStormyLightningStrikeSFX; internal static AudioClip[] defaultStormyDistantThunderSFX; internal static AudioClip defaultStormyStaticElectricitySFX; internal static ParticleSystem stormyRainParticles; internal static AudioSource stormyRainAmbienceSource; internal static AudioClip defaultStormyRainAmbience; internal static GameObject stormyRainPrefabOverrideInstance; internal static LocalVolumetricFog foggyFog; internal static Vector3 defaultFoggyFogVolumeSize; internal static FloodWeather floodedWeather; internal static QuicksandTrigger floodedWaterTrigger; internal static MeshRenderer floodedWaterRenderer; internal static Material defaultFloodedWaterMaterial; internal static AudioSource floodedAmbienceSource; internal static AudioClip defaultFloodedAmbience; internal static GameObject floodedPrefabOverrideInstance; internal static AudioSource eclipsedMusicSource; internal static AudioClip defaultEclipsedMusic; internal static AudioClip[] timeOfDayCues; internal static AudioClip defaultStartOfDayMusic; internal static AudioClip defaultMidDayMusic; internal static AudioClip defaultLateDayMusic; internal static AudioClip defaultNightMusic; internal static Shader vanillaWaterShader; internal static Shader vanillaWavingGrassShader; internal static LocalKeyword[] vanillaWaterShaderKeywords; internal static LocalKeyword[] vanillaWavingGrassShaderKeywords; internal static Scene currentLevelScene; private static readonly HashSet uniqueMaterials = new HashSet(); private static readonly List tempRenderers = new List(); private static readonly List tempSpawnSyncedObjects = new List(); private static readonly List tempRandomScrapSpawns = new List(); private static readonly List tempRandomMapObjects = new List(); private static readonly List tempBridgeTriggers = new List(); internal static void RefreshShipAnimatorClips(ExtendedLevel extendedLevel, int randomSeed) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown DebugHelper.Log("Refreshing Ship Animator Clips!", DebugType.Developer); Animator shipAnimator = Patches.StartOfRound.shipAnimator; AnimatorOverrideController val = (AnimatorOverrideController)(object)(shipAnimator.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(shipAnimator.runtimeAnimatorController)); Random random = new Random(randomSeed + 33); val["HangarShipLandB"] = GetRandomWeightedClip(extendedLevel.ShipFlyToMoonClips, random); val["ShipLeave"] = GetRandomWeightedClip(extendedLevel.ShipFlyFromMoonClips, random); } private static AnimationClip GetRandomWeightedClip(List clipSelections, Random random = null) { if (clipSelections.Count == 1) { return clipSelections[0].Clip; } int[] array = new int[clipSelections.Count]; for (int i = 0; i < array.Length; i++) { array[i] = clipSelections[i].Rarity; } int randomWeightedIndex = Patches.RoundManager.GetRandomWeightedIndex(array, random); return clipSelections[randomWeightedIndex].Clip; } internal static void RefreshWeatherEffects(ExtendedLevel extendedLevel) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) DebugHelper.Log("Refreshing Weather Effects!", DebugType.Developer); if ((Object)(object)dustCloudFog != (Object)null) { dustCloudFog.parameters.size = extendedLevel.OverrideDustStormVolumeSize; } if ((Object)(object)rainyAmbienceSource != (Object)null) { rainyAmbienceSource.clip = extendedLevel.OverrideRainAmbience; } if ((Object)(object)extendedLevel.OverrideRainPrefab != (Object)null && (Object)(object)rainParticles != (Object)null) { rainPrefabOverrideInstance = Object.Instantiate(extendedLevel.OverrideRainPrefab, ((Component)rainParticles).transform.parent); if ((Object)(object)rainParticles != (Object)null) { ((Component)rainParticles).gameObject.SetActive(false); } SceneManager.sceneUnloaded += CleanupRainyOverride; } if ((Object)(object)stormyRainAmbienceSource != (Object)null) { stormyRainAmbienceSource.clip = extendedLevel.OverrideStormyRainAmbience; } if ((Object)(object)stormyWeather != (Object)null) { if ((Object)(object)extendedLevel.OverrideStormyLightningStrikeExplosion != (Object)null) { stormyWeather.explosionEffectParticle = Object.Instantiate(extendedLevel.OverrideStormyLightningStrikeExplosion, ((Component)stormyWeather).transform); PreventParticleDestroy(stormyWeather.explosionEffectParticle); } if ((Object)(object)extendedLevel.OverrideStormyStaticElectricityParticle != (Object)null) { stormyWeather.staticElectricityParticle = Object.Instantiate(extendedLevel.OverrideStormyStaticElectricityParticle, ((Component)stormyWeather).transform); PreventParticleDestroy(stormyWeather.staticElectricityParticle); } if (extendedLevel.OverrideStormyLightningStrikeSFX != null && extendedLevel.OverrideStormyLightningStrikeSFX.Length != 0) { stormyWeather.strikeSFX = extendedLevel.OverrideStormyLightningStrikeSFX; } if (extendedLevel.OverrideStormyDistantThunderSFX != null && extendedLevel.OverrideStormyDistantThunderSFX.Length != 0) { stormyWeather.distantThunderSFX = extendedLevel.OverrideStormyDistantThunderSFX; } if ((Object)(object)extendedLevel.OverrideStormyStaticElectricitySFX != (Object)null) { stormyWeather.staticElectricityAudio = extendedLevel.OverrideStormyStaticElectricitySFX; } if ((Object)(object)extendedLevel.OverrideStormyRainPrefab != (Object)null && (Object)(object)stormyRainParticles != (Object)null) { stormyRainPrefabOverrideInstance = Object.Instantiate(extendedLevel.OverrideStormyRainPrefab, ((Component)stormyWeather).transform); if ((Object)(object)stormyRainParticles != (Object)null) { ((Component)stormyRainParticles).gameObject.SetActive(false); } } if ((Object)(object)extendedLevel.OverrideStormyLightningStrikeExplosion != (Object)null || (Object)(object)extendedLevel.OverrideStormyStaticElectricityParticle != (Object)null || (Object)(object)stormyRainPrefabOverrideInstance != (Object)null) { SceneManager.sceneUnloaded += CleanupStormyOverride; } } if ((Object)(object)foggyFog != (Object)null) { foggyFog.parameters.size = extendedLevel.OverrideFoggyVolumeSize; } if ((Object)(object)floodedAmbienceSource != (Object)null) { floodedAmbienceSource.clip = extendedLevel.OverrideFloodedAmbience; } if ((Object)(object)extendedLevel.OverrideFloodedPrefab != (Object)null && (Object)(object)floodedWeather != (Object)null) { floodedPrefabOverrideInstance = Object.Instantiate(extendedLevel.OverrideFloodedPrefab, ((Component)floodedWeather).transform); if ((Object)(object)floodedWaterTrigger != (Object)null) { ((Component)floodedWaterTrigger).gameObject.SetActive(false); } if ((Object)(object)floodedWaterRenderer != (Object)null) { ((Component)floodedWaterRenderer).gameObject.SetActive(false); } SceneManager.sceneUnloaded += CleanupFloodedOverride; } if ((Object)(object)eclipsedMusicSource != (Object)null) { eclipsedMusicSource.clip = extendedLevel.OverrideEclipsedMusic; } } private static void CleanupRainyOverride(Scene scene) { SceneManager.sceneUnloaded -= CleanupRainyOverride; if ((Object)(object)rainPrefabOverrideInstance != (Object)null) { Object.Destroy((Object)(object)rainPrefabOverrideInstance); } if ((Object)(object)rainParticles != (Object)null) { ((Component)rainParticles).gameObject.SetActive(true); } } private static void CleanupStormyOverride(Scene scene) { SceneManager.sceneUnloaded -= CleanupStormyOverride; if ((Object)(object)stormyWeather.explosionEffectParticle != (Object)(object)defaultStormyLightningStrikeExplosion) { Object.Destroy((Object)(object)stormyWeather.explosionEffectParticle); stormyWeather.explosionEffectParticle = defaultStormyLightningStrikeExplosion; } if ((Object)(object)stormyWeather.staticElectricityParticle != (Object)(object)defaultStormyStaticElectricityParticle) { Object.Destroy((Object)(object)stormyWeather.staticElectricityParticle); stormyWeather.staticElectricityParticle = defaultStormyStaticElectricityParticle; } if ((Object)(object)stormyRainPrefabOverrideInstance != (Object)null) { Object.Destroy((Object)(object)stormyRainPrefabOverrideInstance); } if ((Object)(object)stormyRainParticles != (Object)null) { ((Component)stormyRainParticles).gameObject.SetActive(true); } } private static void CleanupFloodedOverride(Scene scene) { SceneManager.sceneUnloaded -= CleanupFloodedOverride; if ((Object)(object)floodedPrefabOverrideInstance != (Object)null) { Object.Destroy((Object)(object)floodedPrefabOverrideInstance); } if ((Object)(object)floodedWaterTrigger != (Object)null) { ((Component)floodedWaterTrigger).gameObject.SetActive(true); } if ((Object)(object)floodedWaterRenderer != (Object)null) { ((Component)floodedWaterRenderer).gameObject.SetActive(true); } } private static void PreventParticleDestroy(ParticleSystem particle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 MainModule main = particle.main; ParticleSystemStopAction stopAction = ((MainModule)(ref main)).stopAction; if (stopAction - 1 <= 1) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DebugHelper.LogWarning("Setting particle stop action to None for particle " + ((Object)particle).name + " in " + ((Object)LevelManager.CurrentExtendedLevel).name + " to prevent errors.", DebugType.Developer); } ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; } } internal static void ApplyCameraDistanceOverride(PlayerControllerB player, bool outside, bool inOrbit = false) { if ((Object)(object)player == (Object)null || (Object)(object)player.gameplayCamera == (Object)null) { return; } if (!outside) { ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; if ((Object)(object)currentExtendedDungeonFlow != (Object)null && currentExtendedDungeonFlow.ContentType != ContentType.External) { player.gameplayCamera.farClipPlane = currentExtendedDungeonFlow.OverrideCameraFarPlaneDistanceInside; } } else { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel != (Object)null && currentExtendedLevel.ContentType != ContentType.External) { player.gameplayCamera.farClipPlane = (inOrbit ? currentExtendedLevel.OverrideCameraFarPlaneDistanceInOrbit : currentExtendedLevel.OverrideCameraFarPlaneDistanceOutside); } } } internal static void RefreshTimeOfDayMusic(ExtendedLevel extendedLevel) { if (Patches.TimeOfDay.timeOfDayCues != null && Patches.TimeOfDay.timeOfDayCues.Length == 4) { Patches.TimeOfDay.timeOfDayCues[0] = extendedLevel.OverrideStartOfDayMusic; Patches.TimeOfDay.timeOfDayCues[1] = extendedLevel.OverrideMidDayMusic; Patches.TimeOfDay.timeOfDayCues[2] = extendedLevel.OverrideLateDayMusic; Patches.TimeOfDay.timeOfDayCues[3] = extendedLevel.OverrideNightMusic; } } internal static void RestoreShaders() { Terrain[] activeTerrains = Terrain.activeTerrains; foreach (Terrain val in activeTerrains) { DetailPrototype[] detailPrototypes = val.terrainData.detailPrototypes; foreach (DetailPrototype val2 in detailPrototypes) { RestoreShaders(val2.prototype); } } GameObject[] rootGameObjects = ((Scene)(ref currentLevelScene)).GetRootGameObjects(); foreach (GameObject gameObject in rootGameObjects) { RestoreShaders(gameObject); } uniqueMaterials.Clear(); tempRenderers.Clear(); } private static void RestoreShaders(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } gameObject.GetComponentsInChildren(true, tempRenderers); foreach (Renderer tempRenderer in tempRenderers) { Material[] sharedMaterials = tempRenderer.sharedMaterials; foreach (Material val in sharedMaterials) { if (!((Object)(object)val != (Object)null) || !((Object)(object)val.shader != (Object)null) || !uniqueMaterials.Add(val)) { continue; } if ((Object)(object)vanillaWaterShader != (Object)null) { LocalKeyword[] array = vanillaWaterShaderKeywords; if (array != null && array.Length != 0) { ContentRestorer.TryRestoreShader(val, vanillaWaterShader, vanillaWaterShaderKeywords); } } if ((Object)(object)vanillaWavingGrassShader != (Object)null) { LocalKeyword[] array2 = vanillaWavingGrassShaderKeywords; if (array2 != null && array2.Length != 0) { ContentRestorer.TryRestoreShader(val, vanillaWavingGrassShader, vanillaWavingGrassShaderKeywords); } } } } } internal static void RestoreSceneBlankReferences() { GameObject[] rootGameObjects = ((Scene)(ref currentLevelScene)).GetRootGameObjects(); foreach (GameObject gameObject in rootGameObjects) { RestoreSceneBlankReferences(gameObject); } tempSpawnSyncedObjects.Clear(); tempRandomScrapSpawns.Clear(); tempRandomMapObjects.Clear(); tempBridgeTriggers.Clear(); } private static void RestoreSceneBlankReferences(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } gameObject.GetComponentsInChildren(true, tempSpawnSyncedObjects); foreach (SpawnSyncedObject tempSpawnSyncedObject in tempSpawnSyncedObjects) { ContentRestorer.TryRestoreSpawnSyncedObject(tempSpawnSyncedObject); } gameObject.GetComponentsInChildren(true, tempRandomScrapSpawns); foreach (RandomScrapSpawn tempRandomScrapSpawn in tempRandomScrapSpawns) { ContentRestorer.TryRestoreRandomScrapSpawn(tempRandomScrapSpawn); } gameObject.GetComponentsInChildren(true, tempRandomMapObjects); foreach (RandomMapObject tempRandomMapObject in tempRandomMapObjects) { ContentRestorer.RestoreRandomMapObject(tempRandomMapObject); } gameObject.GetComponentsInChildren(true, tempBridgeTriggers); foreach (BridgeTrigger tempBridgeTrigger in tempBridgeTriggers) { ContentRestorer.RestoreBridgeTrigger(tempBridgeTrigger); } } internal static void ValidateMapPropsContainer() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.FindGameObjectWithTag("MapPropsContainer"); if ((Object)(object)val == (Object)null) { DebugHelper.LogWarning("Could not find a GameObject with a MapPropsContainer tag in the current moon! Creating one to allow landing...", DebugType.User); GameObject val2 = GameObject.FindGameObjectWithTag("OutsideLevelNavMesh"); if ((Object)(object)val2 == (Object)null) { DebugHelper.LogFatal("Could not find a GameObject with an OutsideLevelNavMesh tag in the current moon! There will be issues!", DebugType.User); return; } val = new GameObject("MapPropsContainer"); val.transform.SetParent(val2.transform, false); val.transform.localPosition = new Vector3(-41.7436f, -35.9638f, 35.9276f); val.tag = "MapPropsContainer"; } Patches.RoundManager.mapPropsContainer = val; } internal static void RestoreRuntimeDungeon() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.FindGameObjectWithTag("DungeonGenerator"); if ((Object)(object)val == (Object)null) { DebugHelper.LogWarning("Could not find a GameObject with a DungeonGenerator tag in the current moon! Searching for a RuntimeDungeon...", DebugType.User); GameObject[] rootGameObjects = ((Scene)(ref currentLevelScene)).GetRootGameObjects(); foreach (GameObject val2 in rootGameObjects) { RuntimeDungeon componentInChildren = val2.GetComponentInChildren(false); if ((Object)(object)componentInChildren != (Object)null) { DebugHelper.LogWarning("Found an existing RuntimeDungeon! Assigning DungeonGenerator tag to its GameObject...", DebugType.User); val = ((Component)componentInChildren).gameObject; val.tag = "DungeonGenerator"; break; } } } if ((Object)(object)val == (Object)null) { DebugHelper.LogWarning("Could not find an existing RuntimeDungeon in the current moon! Creating one to allow landing...", DebugType.User); GameObject val3 = new GameObject("LevelGeneration"); SceneManager.MoveGameObjectToScene(val3, currentLevelScene); val3.transform.position = new Vector3(-28.351671f, -1.5914222f, 57.900826f); val = new GameObject("DungeonGenerator", new Type[2] { typeof(RuntimeDungeon), typeof(UnityNavMeshAdapter) }); val.transform.SetParent(val3.transform, false); val.transform.localPosition = new Vector3(229.6013f, -6.12655f, -17.99966f); val.tag = "DungeonGenerator"; GameObject val4 = new GameObject("LevelGenerationRoot"); val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = new Vector3(12f, -218f, 12f); val.GetComponent().Root = val4; } RuntimeDungeon runtimeDungeon = default(RuntimeDungeon); if (!val.TryGetComponent(ref runtimeDungeon)) { DebugHelper.LogWarning("RuntimeDungeon component missing! Creating one to allow landing...", DebugType.User); runtimeDungeon = val.AddComponent(); } UnityNavMeshAdapter navMeshAdapter = default(UnityNavMeshAdapter); if (!val.TryGetComponent(ref navMeshAdapter)) { DebugHelper.LogWarning("UnityNavMeshAdapter component missing! Creating one to allow landing...", DebugType.User); navMeshAdapter = val.AddComponent(); } ValidateRuntimeDungeon(runtimeDungeon, navMeshAdapter); } private static void ValidateRuntimeDungeon(RuntimeDungeon runtimeDungeon, UnityNavMeshAdapter navMeshAdapter) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)runtimeDungeon.Root == (Object)null) { Transform parent = ((Component)runtimeDungeon).transform.GetParent(); for (int i = 0; i < parent.childCount; i++) { if (((Object)parent.GetChild(i)).name.Contains("Root", StringComparison.InvariantCultureIgnoreCase)) { runtimeDungeon.Root = ((Component)parent.GetChild(i)).gameObject; break; } } if ((Object)(object)runtimeDungeon.Root == (Object)null) { DebugHelper.LogWarning("Could not locate LevelGenerationRoot GameObject! Creating one to allow landing...", DebugType.User); Transform transform = new GameObject("LevelGenerationRoot").transform; transform.SetParent(parent, false); transform.localPosition = new Vector3(12f, -218f, 12f); runtimeDungeon.Root = ((Component)transform).gameObject; } } DungeonGenerator val = new DungeonGenerator { allowImmediateRepeats = false, Seed = 255, ShouldRandomizeSeed = true, MaxAttemptCount = 50, UseMaximumPairingAttempts = false, MaxPairingAttempts = 5, UpDirection = (AxisDirection)2, OverrideRepeatMode = false, RepeatMode = (TileRepeatMode)0, OverrideAllowTileRotation = false, AllowTileRotation = false, DebugRender = false, LengthMultiplier = 0.75f, TriggerPlacement = (TriggerPlacementMode)1, TileTriggerLayer = 2, GenerateAsynchronously = false, MaxAsyncFrameMilliseconds = 50f, PauseBetweenRooms = 0.2f, RestrictDungeonToBounds = false }; Bounds tilePlacementBounds = default(Bounds); ((Bounds)(ref tilePlacementBounds)).center = Vector3.zero; ((Bounds)(ref tilePlacementBounds)).extents = Vector3.one * 5f; val.TilePlacementBounds = tilePlacementBounds; val.CollisionSettings = new DungeonCollisionSettings { DisallowOverhangs = false, OverlapThreshold = 0.01f, Padding = 0f, AvoidCollisionsWithOtherDungeons = true }; val.Root = null; val.DungeonFlow = Patches.RoundManager.dungeonFlowTypes[0].dungeonFlow; runtimeDungeon.Generator = val; runtimeDungeon.GenerateOnStart = false; ((BaseAdapter)navMeshAdapter).Priority = 0; navMeshAdapter.BakeMode = (RuntimeNavMeshBakeMode)3; navMeshAdapter.LayerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Room", "Colliders", "NavigationSurface" })); navMeshAdapter.AddNavMeshLinksBetweenRooms = true; navMeshAdapter.NavMeshAgentTypes = new List(1) { new NavMeshAgentLinkInfo { DisableLinkWhenDoorIsClosed = true } }; navMeshAdapter.NavMeshLinkDistanceFromDoorway = 2.5f; navMeshAdapter.AutoGenerateFullRebakeSurfaces = true; navMeshAdapter.FullRebakeTargets = new List(); navMeshAdapter.UseAutomaticLinkDistance = false; navMeshAdapter.AutomaticLinkDistanceOffset = 0.1f; Patches.RoundManager.dungeonGenerator = runtimeDungeon; } } public struct NetworkEnemyTypeReference : INetworkSerializable { private uint m_NetworkEnemyTypeObjectId; private const uint s_NullId = uint.MaxValue; private static List Prefabs => LethalLevelLoaderNetworkManager.networkManager.NetworkConfig.Prefabs.m_Prefabs; public uint NetworkEnemyTypeObjectId { readonly get { return m_NetworkEnemyTypeObjectId; } internal set { m_NetworkEnemyTypeObjectId = value; } } public NetworkEnemyTypeReference(EnemyType enemy) { if ((Object)(object)enemy == (Object)null) { m_NetworkEnemyTypeObjectId = uint.MaxValue; return; } if ((Object)(object)enemy.enemyPrefab == (Object)null || !Object.op_Implicit((Object)(object)enemy.enemyPrefab.GetComponent())) { throw new ArgumentException(((Object)enemy).name + "'s Prefab or Prefab GrabbableObject is Missing!"); } m_NetworkEnemyTypeObjectId = GetIdHashFromEnemyType(enemy); } public readonly bool TryGet(out EnemyType enemy, NetworkManager _ = null) { enemy = Resolve(this); return (Object)(object)enemy != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static EnemyType Resolve(NetworkEnemyTypeReference networkEnemy) { if (networkEnemy.m_NetworkEnemyTypeObjectId == uint.MaxValue) { return null; } return GetEnemyTypeFromNetworkPrefabIdHash(networkEnemy.m_NetworkEnemyTypeObjectId); } public static implicit operator EnemyType(NetworkEnemyTypeReference networkEnemyRef) { return Resolve(networkEnemyRef); } public static implicit operator NetworkEnemyTypeReference(EnemyType enemy) { return new NetworkEnemyTypeReference(enemy); } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer*)(&serializer))->SerializeValue(ref m_NetworkEnemyTypeObjectId, default(ForPrimitives)); } private static EnemyType GetEnemyTypeFromNetworkPrefabIdHash(uint idHash) { EnemyAI val = default(EnemyAI); for (int i = 0; i < Prefabs.Count; i++) { if (Prefabs[i].SourcePrefabGlobalObjectIdHash == idHash && Prefabs[i].Prefab.TryGetComponent(ref val)) { return val.enemyType; } } return null; } private static uint GetIdHashFromEnemyType(EnemyType enemy) { for (int i = 0; i < Prefabs.Count; i++) { if ((Object)(object)Prefabs[i].Prefab == (Object)(object)enemy.enemyPrefab) { return Prefabs[i].SourcePrefabGlobalObjectIdHash; } } return 0u; } } public struct NetworkExtendedLevelReference : INetworkSerializable { private uint m_ExtendedLevelId; private const uint s_NullId = uint.MaxValue; private static List Levels => PatchedContent.ExtendedLevels; public uint ExtendedLevelId { readonly get { return m_ExtendedLevelId; } internal set { m_ExtendedLevelId = value; } } public NetworkExtendedLevelReference(ExtendedLevel level) { if ((Object)(object)level == (Object)null) { m_ExtendedLevelId = uint.MaxValue; return; } if ((Object)(object)level.SelectableLevel == (Object)null) { throw new ArgumentException(((Object)level).name + "'s SelectableLevel is Missing!"); } m_ExtendedLevelId = GetIndexIDFromExtendedLevel(level); } public readonly bool TryGet(out ExtendedLevel level, NetworkManager _ = null) { level = Resolve(this); return (Object)(object)level != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ExtendedLevel Resolve(NetworkExtendedLevelReference level) { if (level.m_ExtendedLevelId == uint.MaxValue) { return null; } return GetExtendedLevelFromIndexID(level.ExtendedLevelId); } public static implicit operator ExtendedLevel(NetworkExtendedLevelReference levelRef) { return Resolve(levelRef); } public static implicit operator NetworkExtendedLevelReference(ExtendedLevel level) { return new NetworkExtendedLevelReference(level); } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer*)(&serializer))->SerializeValue(ref m_ExtendedLevelId, default(ForPrimitives)); } private static ExtendedLevel GetExtendedLevelFromIndexID(uint indexID) { for (int i = 0; i < Levels.Count; i++) { if (Levels[i].SelectableLevel.levelID == indexID) { return Levels[i]; } } return null; } private static uint GetIndexIDFromExtendedLevel(ExtendedLevel level) { return (uint)level.SelectableLevel.levelID; } } public static class ContentTagManager { internal static readonly Dictionary> globalContentTagDictionary = new Dictionary>(); internal static readonly Dictionary> globalContentTagExtendedContentDictionary = new Dictionary>(); internal static readonly Dictionary createdTags = new Dictionary(); internal static void PopulateContentTagData() { globalContentTagDictionary.Clear(); globalContentTagExtendedContentDictionary.Clear(); ExtendedMod vanillaMod = PatchedContent.VanillaMod; List extendedMods = PatchedContent.ExtendedMods; int num = 0; ExtendedMod[] array = new ExtendedMod[1 + extendedMods.Count]; array[num] = vanillaMod; num++; foreach (ExtendedMod item in extendedMods) { array[num] = item; num++; } ExtendedMod[] array2 = array; ExtendedMod[] array3 = array2; foreach (ExtendedMod extendedMod in array3) { foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { foreach (ContentTag contentTag in extendedContent.ContentTags) { if (!globalContentTagDictionary.TryGetValue(contentTag.contentTagName, out var value)) { globalContentTagDictionary.Add(contentTag.contentTagName, new List(1) { contentTag }); } else if (!value.Contains(contentTag)) { value.Add(contentTag); } if (!globalContentTagExtendedContentDictionary.TryGetValue(contentTag.contentTagName, out var value2)) { globalContentTagExtendedContentDictionary.Add(contentTag.contentTagName, new List(1) { extendedContent }); } else if (!value2.Contains(extendedContent)) { value2.Add(extendedContent); } } } } if (Settings.debugType <= DebugType.Developer) { return; } string text = "Global Tag Dictionary Report:"; foreach (KeyValuePair> item2 in globalContentTagDictionary) { text += $"\n\t- Tag: {item2.Key}, Found Matching ContentTags: {item2.Value.Count}"; } DebugHelper.Log(text, DebugType.Developer); } internal static List CreateNewContentTags(List tags) { HashSet hashSet = new HashSet(); foreach (string tag in tags) { if (!string.IsNullOrEmpty(tag)) { if (!createdTags.TryGetValue(tag, out var value)) { value = ContentTag.Create(tag); createdTags.Add(tag, value); } hashSet.Add(value); } } return hashSet.ToList(); } public static List GetAllExtendedContentsByTag(string tag) { if (!globalContentTagExtendedContentDictionary.TryGetValue(tag, out var value)) { return new List(); } return value; } public static bool TryGetContentTagColour(ExtendedContent extendedContent, string tag, out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) color = Color.white; foreach (ContentTag contentTag in extendedContent.ContentTags) { if (string.Equals(contentTag.contentTagName, tag, StringComparison.Ordinal)) { color = contentTag.contentTagColor; return true; } } return false; } internal static void MergeAllExtendedModTags() { Dictionary dictionary = new Dictionary(); HashSet hashSet = new HashSet(); foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { for (int i = 1; i < extendedContent.ContentTags.Count; i++) { ContentTag contentTag = extendedContent.ContentTags[i]; string key = contentTag.contentTagName.ToLowerInvariant(); if (dictionary.TryGetValue(key, out var value) && (Object)(object)contentTag != (Object)(object)value) { hashSet.Add(contentTag); extendedContent.ContentTags[i] = value; } else { dictionary[key] = contentTag; } } } dictionary.Clear(); } foreach (ContentTag item in hashSet) { if (!((Object)(object)item == (Object)(object)ExtendedMod.VanillaContentTag) && !((Object)(object)item == (Object)(object)ExtendedMod.CustomContentTag)) { Object.Destroy((Object)(object)item); } } } } public static class DungeonManager { [CompilerGenerated] private static ExtendedDungeonFlow k__BackingField; public static readonly DungeonEvents GlobalDungeonEvents = new DungeonEvents(); public static ExtendedDungeonFlow CurrentExtendedDungeonFlow { get { if ((Object)(object)Patches.RoundManager == (Object)null || (Object)(object)Patches.RoundManager.dungeonGenerator == (Object)null || Patches.RoundManager.dungeonGenerator.Generator == null || (Object)(object)Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow == (Object)null) { return null; } if (((Object)(object)k__BackingField == (Object)null || (Object)(object)Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow != (Object)(object)k__BackingField.DungeonFlow) && PatchedContent.TryGetExtendedContent(Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow, out k__BackingField)) { DebugHelper.Log("Dungeon switched to: " + ((Object)k__BackingField.DungeonFlow).name, DebugType.IAmBatby); } return k__BackingField; } } internal static void PatchVanillaDungeonLists() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (PatchedContent.CustomExtendedDungeonFlows.Count == 0) { return; } List list = Patches.RoundManager.dungeonFlowTypes.ToList(); List list2 = Patches.RoundManager.firstTimeDungeonAudios.ToList(); foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { customExtendedDungeonFlow.DungeonID = list.Count; IndoorMapType item = new IndoorMapType(customExtendedDungeonFlow.DungeonFlow, customExtendedDungeonFlow.MapTileSize, customExtendedDungeonFlow.FirstTimeDungeonAudio) { restrictBounds = customExtendedDungeonFlow.RestrictBounds, cullingTileDepth = customExtendedDungeonFlow.CullingTileDepth }; list.Add(item); if ((Object)(object)customExtendedDungeonFlow.FirstTimeDungeonAudio != (Object)null && !list2.Contains(customExtendedDungeonFlow.FirstTimeDungeonAudio)) { list2.Add(customExtendedDungeonFlow.FirstTimeDungeonAudio); } } Patches.RoundManager.dungeonFlowTypes = list.ToArray(); Patches.RoundManager.firstTimeDungeonAudios = list2.ToArray(); } public static List GetValidExtendedDungeonFlows(ExtendedLevel extendedLevel, bool debugResults) { DebugStopwatch.StartStopWatch("Get Valid ExtendedDungeonFlows"); List list = new List(); List list2 = new List(); foreach (ExtendedDungeonFlow vanillaExtendedDungeonFlow in PatchedContent.VanillaExtendedDungeonFlows) { list2.Add(new ExtendedDungeonFlowWithRarity(vanillaExtendedDungeonFlow, 0)); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { list2.Add(new ExtendedDungeonFlowWithRarity(customExtendedDungeonFlow, 0)); } foreach (ExtendedDungeonFlowWithRarity item in new List(list2)) { item.newRarity = item.newExtendedDungeonFlow.LevelMatchingProperties.GetDynamicRarity(extendedLevel); if (item.newRarity != 0) { list.Add(item); } } if (debugResults) { string text = "ExtendedLevel <-> ExtendedDungeonFlow Dynamic Matching Report.\n\n"; text = text + "Info For ExtendedLevel: " + ((Object)extendedLevel).name + " | Planet Name: " + extendedLevel.NumberlessPlanetName + " | Content Tags: "; foreach (ContentTag contentTag in extendedLevel.ContentTags) { text = text + contentTag.contentTagName + ", "; } text = text.TrimEnd(',', ' '); text = text + " | Route Price: " + extendedLevel.RoutePrice + " | Current Weather: " + ((object)Unsafe.As(ref extendedLevel.SelectableLevel.currentWeather)/*cast due to .constrained prefix*/).ToString(); text += "\n"; List list3 = list.ConvertAll((ExtendedDungeonFlowWithRarity d) => d.newExtendedDungeonFlow); text += "Unviable ExtendedDungeonFlows: "; foreach (ExtendedDungeonFlowWithRarity item2 in list2) { if (!list3.Contains(item2.newExtendedDungeonFlow)) { text = text + item2.newExtendedDungeonFlow.DungeonName + ", "; } } text = text.TrimEnd(',', ' '); text += "\n"; list.Sort(new ExtendedDungeonFlowWithRarity.ExtendedDungeonFlowWithRarityComparer(ascending: false)); text += "Viable ExtendedDungeonFlows: "; foreach (ExtendedDungeonFlowWithRarity item3 in list) { text = text + item3.newExtendedDungeonFlow.DungeonName + " (" + item3.newRarity + "), "; } text = text.TrimEnd(',', ' '); DebugHelper.Log(text + "\n", DebugType.User); } DebugStopwatch.StopStopWatch("Get Valid ExtendedDungeonFlows"); return list; } internal static void RefreshDungeonFlowIDs() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown List list = new List(); List list2 = new List(); foreach (ExtendedDungeonFlow vanillaExtendedDungeonFlow in PatchedContent.VanillaExtendedDungeonFlows) { vanillaExtendedDungeonFlow.DungeonID = list.Count; list.Add(vanillaExtendedDungeonFlow.DungeonFlow); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { customExtendedDungeonFlow.DungeonID = list.Count; list.Add(customExtendedDungeonFlow.DungeonFlow); } foreach (DungeonFlow item2 in list) { IndoorMapType item = new IndoorMapType(item2, 1f, (AudioClip)null); list2.Add(item); } Patches.RoundManager.dungeonFlowTypes = list2.ToArray(); } internal static bool TryGetExtendedDungeonFlow(DungeonFlow dungeonFlow, out ExtendedDungeonFlow returnExtendedDungeonFlow, ContentType contentType = ContentType.Any) { if (PatchedContent.TryGetExtendedContent(dungeonFlow, out returnExtendedDungeonFlow)) { if (contentType != ContentType.Any) { return contentType == returnExtendedDungeonFlow.ContentType; } return true; } return false; } internal static bool TryGetExtendedDungeonFlow(IndoorMapType indoorMapType, out ExtendedDungeonFlow returnExtendedDungeonFlow, ContentType contentType = ContentType.Any) { return TryGetExtendedDungeonFlow(indoorMapType.dungeonFlow, out returnExtendedDungeonFlow, contentType); } } public static class EnemyManager { public static HashSet TinyEnemyTypes { get; } = new HashSet(); public static HashSet GiantEnemyTypes { get; } = new HashSet(); public static HashSet MediumEnemyTypes { get; } = new HashSet(); public static void RefreshDynamicEnemyTypeRarityOnAllExtendedLevels() { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { InjectCustomEnemyTypesIntoLevelViaDynamicRarity(extendedLevel); } } public static void InjectCustomEnemyTypesIntoLevelViaDynamicRarity(ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow = null, bool debugResults = false) { foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { InjectEnemyOfTypeIntoLevel(customExtendedEnemyType, SpawnableEnemyType.Inside, extendedLevel, extendedDungeonFlow, debugResults); InjectEnemyOfTypeIntoLevel(customExtendedEnemyType, SpawnableEnemyType.Outside, extendedLevel, extendedDungeonFlow, debugResults); InjectEnemyOfTypeIntoLevel(customExtendedEnemyType, SpawnableEnemyType.Daytime, extendedLevel, extendedDungeonFlow, debugResults); } } private static void InjectEnemyOfTypeIntoLevel(ExtendedEnemyType extendedEnemy, SpawnableEnemyType spawnableEnemyType, ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow = null, bool debugResults = false) { //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown List list; switch (spawnableEnemyType) { case SpawnableEnemyType.None: return; case SpawnableEnemyType.Inside: list = extendedLevel.SelectableLevel.Enemies; break; case SpawnableEnemyType.Outside: list = extendedLevel.SelectableLevel.OutsideEnemies; break; case SpawnableEnemyType.Daytime: list = extendedLevel.SelectableLevel.DaytimeEnemies; break; default: list = null; break; } List list2 = list; LevelMatchingProperties levelMatchingProperties = spawnableEnemyType switch { SpawnableEnemyType.Inside => extendedEnemy.InsideLevelMatchingProperties, SpawnableEnemyType.Outside => extendedEnemy.OutsideLevelMatchingProperties, SpawnableEnemyType.Daytime => extendedEnemy.DaytimeLevelMatchingProperties, _ => null, }; DungeonMatchingProperties dungeonMatchingProperties = spawnableEnemyType switch { SpawnableEnemyType.Inside => extendedEnemy.InsideDungeonMatchingProperties, SpawnableEnemyType.Outside => extendedEnemy.OutsideDungeonMatchingProperties, SpawnableEnemyType.Daytime => extendedEnemy.DaytimeDungeonMatchingProperties, _ => null, }; string text = string.Empty; int num = list2.FindIndex((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType == (Object)(object)extendedEnemy.EnemyType); int dynamicRarity = levelMatchingProperties.GetDynamicRarity(extendedLevel); int val = (((Object)(object)extendedDungeonFlow != (Object)null) ? dungeonMatchingProperties.GetDynamicRarity(extendedDungeonFlow) : 0); int num2 = Math.Max(dynamicRarity, val); if (num != -1) { if (num2 > 0) { list2[num].rarity = num2; if (debugResults) { text = "Updated " + spawnableEnemyType.ToString() + " Rarity Of ExtendedEnemyType: " + extendedEnemy.EnemyType.enemyName + " To: " + num2 + " On Moon: " + extendedLevel.NumberlessPlanetName; } } else { list2.RemoveAt(num); if (debugResults) { text = "Removed " + spawnableEnemyType.ToString() + " ExtendedEnemyType: " + extendedEnemy.EnemyType.enemyName + " From Moon: " + extendedLevel.NumberlessPlanetName; } } } else if (num2 > 0) { SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity(extendedEnemy.EnemyType, num2); list2.Add(item); if (debugResults) { text = "Added " + spawnableEnemyType.ToString() + " ExtendedEnemyType: " + extendedEnemy.EnemyType.enemyName + " To Moon: " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + num2; } } if (debugResults && !string.IsNullOrEmpty(text)) { DebugHelper.Log(text, DebugType.Developer); } } internal static void UpdateEnemyIDs() { int num = -1; foreach (ExtendedEnemyType vanillaExtendedEnemyType in PatchedContent.VanillaExtendedEnemyTypes) { if (vanillaExtendedEnemyType.EnemyID > num) { num = vanillaExtendedEnemyType.EnemyID; } } int num2 = 0; foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { customExtendedEnemyType.EnemyID = ++num2 + num; ScanNodeProperties[] componentsInChildren = customExtendedEnemyType.EnemyType.enemyPrefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (!string.IsNullOrEmpty(componentsInChildren[i].headerText) && componentsInChildren[i].headerText.ContainsSanitized(customExtendedEnemyType.EnemyDisplayName, bothWays: true)) { customExtendedEnemyType.ScanNodeProperties = componentsInChildren[i]; } componentsInChildren[i].creatureScanID = customExtendedEnemyType.EnemyID; } if (string.IsNullOrEmpty(customExtendedEnemyType.EnemyDisplayName)) { customExtendedEnemyType.EnemyDisplayName = (((Object)(object)customExtendedEnemyType.ScanNodeProperties != (Object)null) ? customExtendedEnemyType.ScanNodeProperties.headerText : customExtendedEnemyType.EnemyType.enemyName); DebugHelper.LogWarning("EnemyDisplayName field empty for '" + ((Object)customExtendedEnemyType).name + "'! Using '" + customExtendedEnemyType.EnemyDisplayName + "' as fallback...", DebugType.User); } DebugHelper.Log($"Set Enemy ID '{customExtendedEnemyType.EnemyID}' For Custom EnemyType: {customExtendedEnemyType.EnemyType.enemyName}", DebugType.Developer); } } internal static void AddCustomEnemyTypesToTestAllEnemiesLevel() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown QuickMenuManager val = Object.FindAnyObjectByType((FindObjectsInactive)0); if (!((Object)(object)val != (Object)null)) { return; } foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity(customExtendedEnemyType.EnemyType, 300); val.testAllEnemiesLevel.Enemies.Add(item); val.testAllEnemiesLevel.OutsideEnemies.Add(item); val.testAllEnemiesLevel.DaytimeEnemies.Add(item); } } internal static void PopulateEnemySizeLists() { //IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected I4, but got Unknown foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes) { if (!((Object)(object)extendedEnemyType == (Object)null) && !((Object)(object)extendedEnemyType.EnemyType == (Object)null)) { EnemySize enemySize = extendedEnemyType.EnemyType.EnemySize; switch ((int)enemySize) { case 0: TinyEnemyTypes.Add(extendedEnemyType.EnemyType); break; case 1: GiantEnemyTypes.Add(extendedEnemyType.EnemyType); break; case 2: MediumEnemyTypes.Add(extendedEnemyType.EnemyType); break; } } } } } internal enum SpawnableEnemyType { None = -1, Inside, Outside, Daytime } public static class FootstepSurfaceManager { public static readonly Dictionary surfaceTagExtendedFootstepDict = new Dictionary(); internal static void PatchVanillaFootstepSurfaceLists() { if (!Plugin.IsSetupComplete) { MergeExtendedFootstepSurfaces(); } List list = new List(PatchedContent.ExtendedFootstepSurfaces.Count); foreach (ExtendedFootstepSurface extendedFootstepSurface in PatchedContent.ExtendedFootstepSurfaces) { extendedFootstepSurface.SurfaceIndex = list.Count; list.Add(extendedFootstepSurface.FootstepSurface); } Patches.StartOfRound.footstepSurfaces = list.ToArray(); } private static void MergeExtendedFootstepSurfaces() { int num = 0; foreach (ExtendedFootstepSurface extendedFootstepSurface in PatchedContent.ExtendedFootstepSurfaces) { if (surfaceTagExtendedFootstepDict.TryGetValue(extendedFootstepSurface.FootstepSurface.surfaceTag, out var _)) { Object.Destroy((Object)(object)extendedFootstepSurface); num++; } else if (!surfaceTagExtendedFootstepDict.TryAdd(extendedFootstepSurface.FootstepSurface.surfaceTag, extendedFootstepSurface)) { DebugHelper.LogWarning("Could not add custom tag '" + extendedFootstepSurface.FootstepSurface.surfaceTag + "' to surface tag dictionary.", DebugType.Developer); } } if (num > 0) { DebugHelper.Log($"Merged '{num}' ExtendedFootstepSurface assets!", DebugType.Developer); } } public static bool TryGetAndSetFootstepSurfaceIndex(Terrain terrain, int terrainLayer, PlayerControllerB player) { if (TerrainManager.TerrainFootstepsDict.TryGetValue(terrain.terrainData, out var value) && terrainLayer >= 0 && terrainLayer < value.Length) { ExtendedFootstepSurface extendedFootstepSurface = value[terrainLayer]; if ((Object)(object)extendedFootstepSurface != (Object)null) { player.currentFootstepSurfaceIndex = extendedFootstepSurface.SurfaceIndex; player.standingOnTerrain = extendedFootstepSurface.AllowSinking; return true; } } return false; } public static bool TryGetAndSetFootstepSurfaceIndex(Terrain terrain, int terrainLayer, MaskedPlayerEnemy masked) { if (TerrainManager.TerrainFootstepsDict.TryGetValue(terrain.terrainData, out var value) && terrainLayer >= 0 && terrainLayer < value.Length) { ExtendedFootstepSurface extendedFootstepSurface = value[terrainLayer]; if ((Object)(object)extendedFootstepSurface != (Object)null && extendedFootstepSurface.AllowMaskedFootsteps) { masked.currentFootstepSurfaceIndex = extendedFootstepSurface.SurfaceIndex; return true; } } return false; } internal static void SwitchToUntaggedIndex(ref int currentFootstepSurfaceIndex) { if (currentFootstepSurfaceIndex >= 0 && currentFootstepSurfaceIndex < PatchedContent.ExtendedFootstepSurfaces.Count && PatchedContent.ExtendedFootstepSurfaces[currentFootstepSurfaceIndex].ContentType == ContentType.Custom) { currentFootstepSurfaceIndex = 10; } } } public static class ItemManager { internal static void PatchVanillaBuyableItemsLists() { List list = Patches.Terminal.buyableItemsList.ToList(); foreach (ExtendedItem customExtendedItem in PatchedContent.CustomExtendedItems) { if (customExtendedItem.IsBuyableItem && !list.Contains(customExtendedItem.Item)) { if ((Object)(object)customExtendedItem.BuyNode != (Object)null) { customExtendedItem.BuyNode.buyItemIndex = list.Count; } if ((Object)(object)customExtendedItem.BuyConfirmNode != (Object)null) { customExtendedItem.BuyConfirmNode.buyItemIndex = list.Count; } list.Add(customExtendedItem.Item); } } Patches.Terminal.buyableItemsList = list.ToArray(); } public static void RefreshDynamicItemRarityOnAllExtendedLevels() { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { InjectCustomItemsIntoLevelViaDynamicRarity(extendedLevel); } } public static void InjectCustomItemsIntoLevelViaDynamicRarity(ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow = null, bool debugResults = false) { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown foreach (ExtendedItem extendedItem in PatchedContent.CustomExtendedItems) { if (!extendedItem.Item.isScrap) { continue; } string text = string.Empty; int num = extendedLevel.SelectableLevel.spawnableScrap.FindIndex((SpawnableItemWithRarity val2) => (Object)(object)val2.spawnableItem == (Object)(object)extendedItem.Item); int dynamicRarity = extendedItem.LevelMatchingProperties.GetDynamicRarity(extendedLevel); int val = (((Object)(object)extendedDungeonFlow != (Object)null) ? extendedItem.DungeonMatchingProperties.GetDynamicRarity(extendedDungeonFlow) : 0); int num2 = Math.Max(dynamicRarity, val); if (num != -1) { if (num2 > 0) { extendedLevel.SelectableLevel.spawnableScrap[num].rarity = num2; if (debugResults) { text = "Updated Rarity Of: " + extendedItem.Item.itemName + " To: " + num2 + " On Moon: " + extendedLevel.NumberlessPlanetName; } } else { extendedLevel.SelectableLevel.spawnableScrap.RemoveAt(num); if (debugResults) { text = "Removed " + extendedItem.Item.itemName + " From Moon: " + extendedLevel.NumberlessPlanetName; } } } else if (num2 > 0) { SpawnableItemWithRarity item = new SpawnableItemWithRarity(extendedItem.Item, num2); extendedLevel.SelectableLevel.spawnableScrap.Add(item); if (debugResults) { text = "Added " + extendedItem.Item.itemName + " To Moon: " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + num2; } } if (debugResults && !string.IsNullOrEmpty(text)) { DebugHelper.Log(text, DebugType.Developer); } } } internal static int GetAverageScrapValue(ExtendedItem extendedItem) { return Mathf.RoundToInt(Mathf.Lerp((float)extendedItem.Item.minValue, (float)extendedItem.Item.maxValue, 0.5f)); } } public sealed class LethalLevelLoaderNetworkManager : NetworkBehaviour { public class StringContainer : INetworkSerializable { public string SomeText; public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (serializer.IsWriter) { FastBufferWriter fastBufferWriter = serializer.GetFastBufferWriter(); ((FastBufferWriter)(ref fastBufferWriter)).WriteValueSafe(SomeText, false); } else { FastBufferReader fastBufferReader = serializer.GetFastBufferReader(); ((FastBufferReader)(ref fastBufferReader)).ReadValueSafe(ref SomeText, false); } } } public static GameObject networkingManagerPrefab; private static LethalLevelLoaderNetworkManager _instance; public static NetworkManager networkManager; private static readonly List queuedNetworkPrefabs = new List(); public static bool networkHasStarted; public static LethalLevelLoaderNetworkManager Instance { get { if ((Object)(object)_instance == (Object)null) { _instance = Object.FindAnyObjectByType((FindObjectsInactive)0); } if ((Object)(object)_instance == (Object)null) { DebugHelper.LogError("LethalLevelLoaderNetworkManager Could Not Be Found! Returning Null!", DebugType.User); } return _instance; } set { _instance = value; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this) { Object.Destroy((Object)(object)Instance); } Instance = this; ((Object)((Component)this).gameObject).name = "LethalLevelLoaderNetworkManager"; DebugHelper.Log("LethalLevelLoaderNetworkManager Spawned.", DebugType.User); } [Rpc(/*Could not decode attribute arguments.*/)] public void GetRandomExtendedDungeonFlowServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(12573863u, val4, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val3, 12573863u, val4, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; DebugHelper.Log("Getting Random DungeonFlows!", DebugType.User); List validExtendedDungeonFlows = DungeonManager.GetValidExtendedDungeonFlows(LevelManager.CurrentExtendedLevel, debugResults: true); List list = new List(); List list2 = new List(); if (validExtendedDungeonFlows.Count == 0) { DebugHelper.LogError("Loading Facility DungeonFlow to prevent infinite loading!", DebugType.User); StringContainer stringContainer = new StringContainer(); stringContainer.SomeText = ((Object)PatchedContent.ExtendedDungeonFlows[0].DungeonFlow).name; list.Add(stringContainer); list2.Add(300); } else { List dungeonFlows = Patches.RoundManager.GetDungeonFlows(); foreach (ExtendedDungeonFlowWithRarity item in validExtendedDungeonFlows) { StringContainer stringContainer2 = new StringContainer(); stringContainer2.SomeText = ((Object)dungeonFlows[dungeonFlows.IndexOf(item.newExtendedDungeonFlow.DungeonFlow)]).name; list.Add(stringContainer2); list2.Add(item.newRarity); } } SetRandomExtendedDungeonFlowClientRpc(list.ToArray(), list2.ToArray()); } [Rpc(/*Could not decode attribute arguments.*/)] public void GetUpdatedLevelCurrentWeatherServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a5: 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) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3226356970u, val4, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val3, 3226356970u, val4, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; List list = new List(); List list2 = new List(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { StringContainer stringContainer = new StringContainer(); stringContainer.SomeText = ((Object)extendedLevel).name; list.Add(stringContainer); list2.Add(extendedLevel.SelectableLevel.currentWeather); } SetUpdatedLevelCurrentWeatherClientRpc(list.ToArray(), list2.ToArray()); } [Rpc(/*Could not decode attribute arguments.*/)] public void SetUpdatedLevelCurrentWeatherClientRpc(StringContainer[] levelNames, LevelWeatherType[] weatherTypes) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3957821582u, val4, val2, (SendTo)7, (RpcDelivery)0); bool flag = levelNames != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val3)).WriteValueSafe(levelNames, default(ForNetworkSerializable)); } bool flag2 = weatherTypes != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val3)).WriteValueSafe(weatherTypes, default(ForEnums)); } ((NetworkBehaviour)this).__endSendRpc(ref val3, 3957821582u, val4, val2, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; Dictionary dictionary = new Dictionary(); for (int i = 0; i < levelNames.Length; i++) { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (levelNames[i].SomeText == ((Object)extendedLevel).name) { dictionary.Add(extendedLevel, weatherTypes[i]); } } } foreach (KeyValuePair item in dictionary) { if (item.Key.SelectableLevel.currentWeather != item.Value) { DebugHelper.LogWarning("Client Had Differing Current Weather Value For ExtendedLevel: " + item.Key.NumberlessPlanetName + ", Syncing!", DebugType.User); item.Key.SelectableLevel.currentWeather = item.Value; } } } [Rpc(/*Could not decode attribute arguments.*/)] public void SetRandomExtendedDungeonFlowClientRpc(StringContainer[] dungeonFlowNames, int[] rarities) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2948417154u, val4, val2, (SendTo)7, (RpcDelivery)0); bool flag = dungeonFlowNames != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val3)).WriteValueSafe(dungeonFlowNames, default(ForNetworkSerializable)); } bool flag2 = rarities != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val3)).WriteValueSafe(rarities, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendRpc(ref val3, 2948417154u, val4, val2, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; DebugHelper.Log("Setting Random DungeonFlows!", DebugType.User); List list = new List(); List list2 = new List(); Dictionary dictionary = new Dictionary(); int num = 0; foreach (DungeonFlow dungeonFlow in Patches.RoundManager.GetDungeonFlows()) { dictionary.Add(((Object)dungeonFlow).name, num); num++; } for (int i = 0; i < dungeonFlowNames.Length; i++) { IntWithRarity item = new IntWithRarity(dictionary[dungeonFlowNames[i].SomeText], rarities[i], (LevelAmbienceLibrary)null); list.Add(item); } list2 = LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes.ToList(); LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes = list.ToArray(); Patches.RoundManager.GenerateNewFloor(); LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes = list2.ToArray(); } [Rpc(/*Could not decode attribute arguments.*/)] public void GetDungeonFlowSizeServerRpc(RpcParams rpcParams = default(RpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0085: 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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val != null && val.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = new RpcAttributeParams { RequireOwnership = false }; FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2361963607u, rpcParams, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val3, 2361963607u, rpcParams, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; SetDungeonFlowSizeClientRpc(DungeonLoader.GetClampedDungeonSize(), RpcParams.op_Implicit(((NetworkBehaviour)this).RpcTarget.Single(rpcParams.Receive.SenderClientId, (RpcTargetUse)0))); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void SetDungeonFlowSizeClientRpc(float hostSize, RpcParams rpcParams) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val != null && val.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(4136936029u, rpcParams, val2, (SendTo)8, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref hostSize, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 4136936029u, rpcParams, val2, (SendTo)8, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; Patches.RoundManager.dungeonGenerator.Generator.LengthMultiplier = hostSize; Patches.RoundManager.dungeonGenerator.Generate(); } } } [Rpc(/*Could not decode attribute arguments.*/)] internal void SetExtendedLevelValuesServerRpc(ExtendedLevelData extendedLevelData) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1429734586u, val4, val2, (SendTo)2, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref extendedLevelData, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 1429734586u, val4, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; if (PatchedContent.TryGetExtendedContent(extendedLevelData.UniqueIdentifier, out ExtendedLevel _)) { SetExtendedLevelValuesClientRpc(extendedLevelData); } else { DebugHelper.Log("Failed To Send Level Info!", DebugType.User); } } } [Rpc(/*Could not decode attribute arguments.*/)] internal void SetExtendedLevelValuesClientRpc(ExtendedLevelData extendedLevelData) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1926043830u, val4, val2, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref extendedLevelData, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 1926043830u, val4, val2, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; if (PatchedContent.TryGetExtendedContent(extendedLevelData.UniqueIdentifier, out ExtendedLevel extendedContent)) { extendedLevelData.ApplySavedValues(extendedContent); } else { DebugHelper.Log("Failed To Apply Saved Level Info!", DebugType.User); } } } public static void RegisterNetworkPrefab(GameObject prefab) { if (!networkHasStarted) { queuedNetworkPrefabs.Add(prefab); } else { DebugHelper.LogWarning("Attempted To Register NetworkPrefab: " + ((object)prefab)?.ToString() + " After GameNetworkManager Has Started!", DebugType.User); } } public static T SetupNetworkManagerObject() where T : NetworkBehaviour { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("T"); ((Object)val).hideFlags = (HideFlags)61; T result = val.AddComponent(); NetworkObject val2 = val.AddComponent(); byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + "T")); val2.GlobalObjectIdHash = BitConverter.ToUInt32(value, 0); val2.DontDestroyWithOwner = true; val2.SceneMigrationSynchronization = true; val2.DestroyWithScene = true; Object.DontDestroyOnLoad((Object)(object)val); NetworkManager.Singleton.AddNetworkPrefab(val); return result; } internal static void RegisterPrefabs(NetworkManager networkManager) { List list = new List(); foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs) { list.Add(prefab.Prefab); } int num = 0; foreach (GameObject queuedNetworkPrefab in queuedNetworkPrefabs) { if (!list.Contains(queuedNetworkPrefab)) { networkManager.AddNetworkPrefab(queuedNetworkPrefab); list.Add(queuedNetworkPrefab); } else { num++; } } foreach (GameObject item in list) { ContentRestorer.RestoreAudioAssetReferencesInParent(item); } DebugHelper.Log("Skipped Registering " + num + " NetworkObjects As They Were Already Registered.", DebugType.User); networkHasStarted = true; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(12573863u, new RpcReceiveHandler(__rpc_handler_12573863), "GetRandomExtendedDungeonFlowServerRpc"); ((NetworkBehaviour)this).__registerRpc(3226356970u, new RpcReceiveHandler(__rpc_handler_3226356970), "GetUpdatedLevelCurrentWeatherServerRpc"); ((NetworkBehaviour)this).__registerRpc(3957821582u, new RpcReceiveHandler(__rpc_handler_3957821582), "SetUpdatedLevelCurrentWeatherClientRpc"); ((NetworkBehaviour)this).__registerRpc(2948417154u, new RpcReceiveHandler(__rpc_handler_2948417154), "SetRandomExtendedDungeonFlowClientRpc"); ((NetworkBehaviour)this).__registerRpc(2361963607u, new RpcReceiveHandler(__rpc_handler_2361963607), "GetDungeonFlowSizeServerRpc"); ((NetworkBehaviour)this).__registerRpc(4136936029u, new RpcReceiveHandler(__rpc_handler_4136936029), "SetDungeonFlowSizeClientRpc"); ((NetworkBehaviour)this).__registerRpc(1429734586u, new RpcReceiveHandler(__rpc_handler_1429734586), "SetExtendedLevelValuesServerRpc"); ((NetworkBehaviour)this).__registerRpc(1926043830u, new RpcReceiveHandler(__rpc_handler_1926043830), "SetExtendedLevelValuesClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_12573863(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).GetRandomExtendedDungeonFlowServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3226356970(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).GetUpdatedLevelCurrentWeatherServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3957821582(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); StringContainer[] levelNames = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref levelNames, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); LevelWeatherType[] weatherTypes = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref weatherTypes, default(ForEnums)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).SetUpdatedLevelCurrentWeatherClientRpc(levelNames, weatherTypes); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2948417154(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); StringContainer[] dungeonFlowNames = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref dungeonFlowNames, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); int[] rarities = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref rarities, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).SetRandomExtendedDungeonFlowClientRpc(dungeonFlowNames, rarities); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2361963607(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { RpcParams ext = rpcParams.Ext; target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).GetDungeonFlowSizeServerRpc(ext); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4136936029(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { float hostSize = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref hostSize, default(ForPrimitives)); RpcParams ext = rpcParams.Ext; target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).SetDungeonFlowSizeClientRpc(hostSize, ext); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1429734586(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { ExtendedLevelData extendedLevelValuesServerRpc = default(ExtendedLevelData); ((FastBufferReader)(ref reader)).ReadValueSafe(ref extendedLevelValuesServerRpc, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).SetExtendedLevelValuesServerRpc(extendedLevelValuesServerRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1926043830(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { ExtendedLevelData extendedLevelValuesClientRpc = default(ExtendedLevelData); ((FastBufferReader)(ref reader)).ReadValueSafe(ref extendedLevelValuesClientRpc, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).SetExtendedLevelValuesClientRpc(extendedLevelValuesClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "LethalLevelLoaderNetworkManager"; } } public static class LevelManager { [CompilerGenerated] private static ExtendedLevel k__BackingField; public static LevelEvents GlobalLevelEvents = new LevelEvents(); public static List dayHistoryList = new List(); public static int daysTotal; public static int quotasTotal; public static int invalidSaveLevelID = -1; public static readonly Dictionary dynamicRiskLevelDictionary = new Dictionary { { "D-", 0 }, { "D", 0 }, { "D+", 0 }, { "C-", 0 }, { "C", 0 }, { "C+", 0 }, { "B-", 0 }, { "B", 0 }, { "B+", 0 }, { "A-", 0 }, { "A", 0 }, { "A+", 0 }, { "S-", 0 }, { "S", 0 }, { "S+", 0 }, { "S++", 0 }, { "S+++", 0 } }; public static ExtendedLevel CurrentExtendedLevel { get { if ((Object)(object)Patches.StartOfRound == (Object)null || (Object)(object)Patches.StartOfRound.currentLevel == (Object)null) { return null; } if (((Object)(object)k__BackingField == (Object)null || (Object)(object)Patches.StartOfRound.currentLevel != (Object)(object)k__BackingField.SelectableLevel) && PatchedContent.TryGetExtendedContent(Patches.StartOfRound.currentLevel, out k__BackingField)) { DebugHelper.Log("Level switched to: " + k__BackingField.SelectableLevel.PlanetName, DebugType.IAmBatby); } return k__BackingField; } } internal static void PatchVanillaLevelLists() { List list = new List(PatchedContent.ExtendedLevels.Count); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (extendedLevel.ContentType != ContentType.External) { list.Add(extendedLevel.SelectableLevel); } } Patches.StartOfRound.levels = list.ToArray(); TerminalManager.Terminal.moonsCatalogueList = list.ToArray(); } internal static void ObtainShipAnimatorClips(StartOfRound startOfRound) { Animator shipAnimator = startOfRound.shipAnimator; RuntimeAnimatorController runtimeAnimatorController = shipAnimator.runtimeAnimatorController; for (int i = 0; i < runtimeAnimatorController.animationClips.Length; i++) { if (string.Equals(((Object)runtimeAnimatorController.animationClips[i]).name, "HangarShipLandB", StringComparison.Ordinal)) { LevelLoader.defaultShipFlyToMoonClip = runtimeAnimatorController.animationClips[i]; } if (string.Equals(((Object)runtimeAnimatorController.animationClips[i]).name, "ShipLeave", StringComparison.Ordinal)) { LevelLoader.defaultShipFlyFromMoonClip = runtimeAnimatorController.animationClips[i]; } } } internal static void ObtainTimeOfDayClips(TimeOfDay timeOfDay) { LevelLoader.timeOfDayCues = timeOfDay.timeOfDayCues; AudioClip[] timeOfDayCues = LevelLoader.timeOfDayCues; if (timeOfDayCues != null && timeOfDayCues.Length == 4) { LevelLoader.defaultStartOfDayMusic = LevelLoader.timeOfDayCues[0]; LevelLoader.defaultMidDayMusic = LevelLoader.timeOfDayCues[1]; LevelLoader.defaultLateDayMusic = LevelLoader.timeOfDayCues[2]; LevelLoader.defaultNightMusic = LevelLoader.timeOfDayCues[3]; } } internal static void ObtainGrassShaderReference() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) Shader val = Shader.Find("Shader Graphs/WavingGrass"); if ((Object)(object)val != (Object)null) { LevelLoader.vanillaWavingGrassShader = val; LevelLoader.vanillaWavingGrassShaderKeywords = (LocalKeyword[])(object)new LocalKeyword[3] { new LocalKeyword(val, "_ALPHATEST_ON"), new LocalKeyword(val, "_DISABLE_SSR"), new LocalKeyword(val, "_DISABLE_SSR_TRANSPARENT") }; } } public static bool TryGetExtendedLevel(SelectableLevel selectableLevel, out ExtendedLevel returnExtendedLevel, ContentType levelType = ContentType.Any) { if (PatchedContent.TryGetExtendedContent(selectableLevel, out returnExtendedLevel)) { if (levelType != ContentType.Any) { return levelType == returnExtendedLevel.ContentType; } return true; } return false; } public static ExtendedLevel GetExtendedLevel(SelectableLevel selectableLevel) { if (!PatchedContent.TryGetExtendedContent(selectableLevel, out var extendedLevel)) { return null; } return extendedLevel; } public static void PopulateDynamicRiskLevelDictionary() { Dictionary> dictionary = new Dictionary>(); foreach (ExtendedLevel vanillaExtendedLevel in PatchedContent.VanillaExtendedLevels) { DebugHelper.Log("Risk Level Of " + vanillaExtendedLevel.NumberlessPlanetName + " Is: " + vanillaExtendedLevel.SelectableLevel.riskLevel, DebugType.Developer); if (!string.IsNullOrEmpty(vanillaExtendedLevel.SelectableLevel.riskLevel) && !vanillaExtendedLevel.SelectableLevel.riskLevel.Contains("Safe", StringComparison.Ordinal)) { if (!dictionary.TryGetValue(vanillaExtendedLevel.SelectableLevel.riskLevel, out var value)) { dictionary.Add(vanillaExtendedLevel.SelectableLevel.riskLevel, new List(1) { vanillaExtendedLevel.CalculatedDifficultyRating }); } else { value.Add(vanillaExtendedLevel.CalculatedDifficultyRating); } } } foreach (KeyValuePair> item in dictionary) { string text = "Vanilla Risk Level Group (" + item.Key + "): "; if (item.Value != null) { int num = 0; foreach (int item2 in item.Value) { num += item2; } text += $" Average - {(float)num / (float)item.Value.Count}, Values - "; foreach (int item3 in item.Value) { text += $"{item3}, "; } } DebugHelper.Log(text, DebugType.Developer); } foreach (KeyValuePair item4 in new Dictionary(dynamicRiskLevelDictionary)) { foreach (KeyValuePair> item5 in dictionary) { if (!string.Equals(item4.Key, item5.Key, StringComparison.Ordinal)) { continue; } int num2 = 0; foreach (int item6 in item5.Value) { num2 += item6; } int num3 = Mathf.RoundToInt((float)num2 / (float)item5.Value.Count); DebugHelper.Log($"Setting RiskLevel {item5.Key} To {num3}", DebugType.Developer); dynamicRiskLevelDictionary[item4.Key] = num3; } } DebugHelper.Log("Starting To Assign - and + Risk Levels", DebugType.Developer); string[] array = dynamicRiskLevelDictionary.Keys.ToArray(); for (int i = 0; i < array.Length; i++) { string key = string.Empty; string key2 = string.Empty; string text2 = array[i]; if (string.IsNullOrEmpty(text2)) { continue; } DebugHelper.Log("Trying To Assign Value To Risk Level: " + text2, DebugType.Developer); if (text2.Contains('-', StringComparison.Ordinal)) { if (i > 0) { key = array[i - 1]; } string key3 = array[i]; dynamicRiskLevelDictionary[text2] = Mathf.RoundToInt((i == 0) ? ((float)dynamicRiskLevelDictionary[key3] / 2f) : Mathf.Lerp((float)dynamicRiskLevelDictionary[key], (float)dynamicRiskLevelDictionary[key3], 0.66f)); } else if (text2.Contains('+', StringComparison.Ordinal) && !string.Equals(text2, "S+", StringComparison.Ordinal)) { string key3 = array[i - 1]; if (!text2.Contains('S', StringComparison.Ordinal)) { key2 = array[i + 1]; } int num4 = text2.Split('+').Length - 1; dynamicRiskLevelDictionary[text2] = ((num4 > 1) ? (dynamicRiskLevelDictionary[key3] * num4) : Mathf.RoundToInt(Mathf.Lerp((float)dynamicRiskLevelDictionary[key3], (float)dynamicRiskLevelDictionary[key2], 0.33f))); } DebugHelper.Log($"Risk Level: {text2} Was Assigned Calculated Difficulty Of: {dynamicRiskLevelDictionary[text2]}", DebugType.Developer); } } public static void AssignCalculatedRiskLevels() { Dictionary dictionary = new Dictionary(); List list = dynamicRiskLevelDictionary.Values.ToList(); list.Sort(); foreach (int item in list) { foreach (KeyValuePair item2 in dynamicRiskLevelDictionary) { if (item2.Value == item) { dictionary.Add(item, item2.Key); } } } foreach (KeyValuePair item3 in dictionary) { DebugHelper.Log($"Ordered Calculated Risk Level: ({item3.Value}) - {item3.Key}", DebugType.Developer); } foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { if (customExtendedLevel.OverrideDynamicRiskLevelAssignment) { continue; } int calculatedDifficultyRating = customExtendedLevel.CalculatedDifficultyRating; int num = calculatedDifficultyRating; foreach (int item4 in list) { if (Math.Abs(calculatedDifficultyRating - item4) < num) { num = item4; } } if (num > 0) { customExtendedLevel.SelectableLevel.riskLevel = dictionary[num]; } } List list2 = PatchedContent.ExtendedLevels.ToList(); list2.Sort(default(ExtendedLevel.ExtendedLevelDifficultyComparer)); foreach (ExtendedLevel item5 in list2) { DebugHelper.Log(item5.NumberlessPlanetName + " (" + item5.SelectableLevel.riskLevel + ") (" + item5.CalculatedDifficultyRating + ")", DebugType.Developer); } } public static void LogDayHistory() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsSetupComplete || (Object)(object)Patches.StartOfRound == (Object)null || (Object)(object)Patches.RoundManager == (Object)null || (Object)(object)Patches.TimeOfDay == (Object)null) { DebugHelper.LogWarning("Game Seems Uninitialized, Exiting LogDayHistory Early!", DebugType.Developer); return; } DayHistory dayHistory = new DayHistory(); daysTotal++; dayHistory.allViableOptions = DungeonManager.GetValidExtendedDungeonFlows(CurrentExtendedLevel, debugResults: false).ConvertAll((ExtendedDungeonFlowWithRarity i) => i.newExtendedDungeonFlow); dayHistory.extendedLevel = CurrentExtendedLevel; dayHistory.extendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; dayHistory.day = daysTotal; dayHistory.quota = Patches.TimeOfDay.timesFulfilledQuota; dayHistory.weatherEffect = Patches.StartOfRound.currentLevel.currentWeather; string text = "Created New Day History Log! PlanetName: "; text = ((!((Object)(object)dayHistory.extendedLevel != (Object)null)) ? (text + "MISSING EXTENDEDLEVEL ,") : (text + dayHistory.extendedLevel.NumberlessPlanetName + " ,")); text = ((!((Object)(object)dayHistory.extendedDungeonFlow != (Object)null)) ? (text + "MISSING EXTENDEDDUNGEONFLOW ,") : (text + dayHistory.extendedDungeonFlow.DungeonName + " ,")); text = text + "Quota: " + dayHistory.quota + " , Day: " + dayHistory.day + " , Weather: " + ((object)Unsafe.As(ref dayHistory.weatherEffect)/*cast due to .constrained prefix*/).ToString(); DebugHelper.Log(text, DebugType.User); dayHistoryList.Add(dayHistory); } public static int CalculateExtendedLevelDifficultyRating(ExtendedLevel extendedLevel, bool debugResults = false) { int num = 0; string text = "Calculated Difficulty Rating For ExtendedLevel: " + extendedLevel.NumberlessPlanetName + "(" + extendedLevel.SelectableLevel.riskLevel + ") ----- "; int routePrice = extendedLevel.RoutePrice; routePrice += extendedLevel.SelectableLevel.maxTotalScrapValue; num += routePrice; text = text + "Baseline Route Value: " + routePrice + ", "; int num2 = 0; foreach (SpawnableItemWithRarity item in extendedLevel.SelectableLevel.spawnableScrap) { if ((Object)(object)item.spawnableItem != (Object)null && (item.spawnableItem.minValue + item.spawnableItem.maxValue) * 5 != 0 && item.rarity != 0 && item.rarity / 10 != 0) { num2 += (item.spawnableItem.maxValue - item.spawnableItem.minValue) / (item.rarity / 10); } } num += num2; text = text + "Scrap Value: " + num2 + ", "; int num3 = (extendedLevel.SelectableLevel.maxEnemyPowerCount + extendedLevel.SelectableLevel.maxOutsideEnemyPowerCount + extendedLevel.SelectableLevel.maxDaytimeEnemyPowerCount) * 15; num3 *= 2; num += num3; text = text + "Enemy Spawn Value: " + num3 + ", "; float num4 = sumEnemyValues(extendedLevel.SelectableLevel.Enemies); num4 += sumEnemyValues(extendedLevel.SelectableLevel.OutsideEnemies); num4 += sumEnemyValues(extendedLevel.SelectableLevel.DaytimeEnemies); num += Mathf.RoundToInt(num4); text = text + "Enemy Value: " + num4 + ", "; text = text + "Calculated Difficulty Value: " + num + ", "; num += Mathf.RoundToInt((float)num * (extendedLevel.SelectableLevel.factorySizeMultiplier * 0.5f)); text = text + "Factory Size Multiplier: " + extendedLevel.SelectableLevel.factorySizeMultiplier + ", "; text = text + "Multiplied Calculated Difficulty Value: " + num; if (debugResults) { DebugHelper.Log(text, DebugType.Developer); } return num; static float sumEnemyValues(List enemyList) { float num5 = 0f; foreach (SpawnableEnemyWithRarity enemy in enemyList) { if (enemy.rarity > 0 && (Object)(object)enemy.enemyType != (Object)null && enemy.rarity / 10 != 0) { num5 += enemy.enemyType.PowerLevel * 100f / (float)(enemy.rarity / 10); } } return num5; } } } public class DayHistory { public int quota; public int day; public ExtendedLevel extendedLevel; public List allViableOptions; public ExtendedDungeonFlow extendedDungeonFlow; public LevelWeatherType weatherEffect; } internal sealed class NetworkBundleManager : NetworkBehaviour { public static GameObject networkingManagerPrefab; private static NetworkBundleManager _instance; public static NetworkManager networkManager; public List networkSceneInfos; internal Dictionary> assetBundleGroupSceneDict = new Dictionary>(); internal ExtendedLevel currentRouteRequestor; private readonly NetworkVariable allowedToLoadLevel = new NetworkVariable(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private NetworkList playersLoadStatus = new NetworkList(); public static NetworkBundleManager Instance { get { if ((Object)(object)_instance == (Object)null) { _instance = Object.FindAnyObjectByType((FindObjectsInactive)0); } if ((Object)(object)_instance == (Object)null) { DebugHelper.LogError("NetworkBundleManager Could Not Be Found! Returning Null!", DebugType.User); } return _instance; } set { _instance = value; } } internal static bool AllowedToLoadLevel { get { if (!((Object)(object)Instance == (Object)null)) { return Instance.allowedToLoadLevel.Value; } return false; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this) { currentRouteRequestor = Instance.currentRouteRequestor; Object.Destroy((Object)(object)Instance); } Instance = this; ((Object)((Component)this).gameObject).name = "NetworkBundleManager"; DebugHelper.Log("NetworkBundleManger Has Spawned!", DebugType.IAmBatby); if (Plugin.IsLobbyInitialized) { Initialize(); } else { Plugin.onLobbyInitialized -= Initialize; Plugin.onLobbyInitialized += Initialize; } LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundleLoaded.AddListener(Instance.RefreshLoadStatus); LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundleUnloaded.AddListener(Instance.RefreshLoadStatus); if (DawnLibCompatibility.Enabled) { NetworkVariable obj = allowedToLoadLevel; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate)delegate(bool previousValue, bool newValue) { DawnLibCompatibility.RefreshLocalClientBundleState(newValue ? 4 : 0); }); } } public override void OnDestroy() { LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundleLoaded.RemoveListener(Instance.RefreshLoadStatus); LethalLevelLoader.AssetBundles.AssetBundleLoader.OnBundleUnloaded.RemoveListener(Instance.RefreshLoadStatus); ((NetworkBehaviour)this).OnDestroy(); } private void Initialize() { Plugin.onLobbyInitialized -= Initialize; DebugHelper.Log("NetworkBundleManager Initializing.", DebugType.User); GenerateSceneDict(); GenerateAssetBundleGroupDict(); Refresh(); } internal void Refresh() { ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; List routeGroups = GetRouteGroups(currentExtendedLevel); List list = new List(); if ((Object)(object)currentRouteRequestor != (Object)null) { list = GetRouteGroups(currentRouteRequestor); } if ((Object)(object)currentExtendedLevel != (Object)null && ((Object)(object)currentRouteRequestor != (Object)(object)currentExtendedLevel || currentExtendedLevel.ContentType == ContentType.External)) { foreach (AssetBundleGroup item in list) { if (!routeGroups.Contains(item)) { item.TryUnloadGroup(); } } currentRouteRequestor = currentExtendedLevel; } if ((Object)(object)currentExtendedLevel != (Object)null) { TerminalManager.simulateKeyword.specialKeywordResult = currentExtendedLevel.SimulateNode; } foreach (AssetBundleGroup item2 in routeGroups) { if (!list.Contains(item2)) { item2.TryLoadGroup(); } } if (((NetworkBehaviour)this).IsServer) { RequestLoadStatusRefreshServerRpc(); } } internal void OnClientsChangedRefresh() { if (((NetworkBehaviour)this).IsServer && (!((Object)(object)((NetworkBehaviour)this).NetworkManager != (Object)null) || !((NetworkBehaviour)this).NetworkManager.ShutdownInProgress)) { RequestLoadStatusRefreshServerRpc(); } } [Rpc(/*Could not decode attribute arguments.*/)] internal void RequestLoadStatusRefreshServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0085: 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) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = new RpcAttributeParams { RequireOwnership = false }; RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1003568550u, val4, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val3, 1003568550u, val4, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; DebugHelper.Log("Refeshing Loaded Bundles Status!", DebugType.User); playersLoadStatus.Clear(); foreach (ulong connectedClientsId in ((NetworkBehaviour)this).NetworkManager.ConnectedClientsIds) { playersLoadStatus.Add(false); } RequestLoadStatusRefreshClientRpc(); } [Rpc(/*Could not decode attribute arguments.*/)] private void RequestLoadStatusRefreshClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0043: 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_0051: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val != null && val.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = default(RpcAttributeParams); RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2729437277u, val4, val2, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val3, 2729437277u, val4, val2, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; RefreshLoadStatus(); } } } private void RefreshLoadStatus() { bool status = true; foreach (AssetBundleGroup routeGroup in GetRouteGroups(LevelManager.CurrentExtendedLevel)) { if (routeGroup.LoadedStatus == AssetBundleGroupLoadedStatus.Loaded) { continue; } status = false; if (routeGroup.LoadingStatus != AssetBundleGroupLoadingStatus.Loading) { if (DawnLibCompatibility.Enabled) { DawnLibCompatibility.RefreshLocalClientBundleState(2); } routeGroup.TryLoadGroup(); } } DebugHelper.Log("Sending LoadedStatus: " + status + " To Server!", DebugType.User); SetLoadedStatusServerRpc(((NetworkBehaviour)this).NetworkManager.LocalClientId, status); } [Rpc(/*Could not decode attribute arguments.*/)] private void SetLoadedStatusServerRpc(ulong clientID, bool status) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = ((NetworkBehaviour)this).NetworkManager; if (val == null || !val.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val2 = new RpcAttributeParams { RequireOwnership = false }; RpcParams val4 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2843210445u, val4, val2, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val3, clientID); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref status, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 2843210445u, val4, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; ulong clientID2 = clientID; int num = ((NetworkBehaviour)this).NetworkManager.ConnectionManager.ConnectedClientIds.FindIndex((ulong id) => id == clientID2); if (playersLoadStatus.Count <= num) { DebugHelper.LogError("Tried To Set LoadedStatus When List Is Invalid (ClientID: " + clientID2 + ", Index: " + num + "), Resetting.", DebugType.User); RequestLoadStatusRefreshServerRpc(); return; } playersLoadStatus[num] = status; int num2 = 0; foreach (bool item in playersLoadStatus) { if (item) { num2++; } } allowedToLoadLevel.Value = num2 == playersLoadStatus.Count; DebugHelper.Log("LoadedStatus Is Currently: (" + num2 + " / " + playersLoadStatus.Count + ")", DebugType.User); } private List GetRouteGroups(ExtendedLevel route) { if ((Object)(object)route == (Object)null) { return new List(); } HashSet hashSet = new HashSet(); foreach (StringWithRarity sceneSelection in route.SceneSelections) { if (assetBundleGroupSceneDict.TryGetValue(sceneSelection.Name, out var value)) { hashSet.UnionWith(value); } } return hashSet.ToList(); } private void GenerateSceneDict() { networkSceneInfos = new List(); Dictionary levelSceneDict = NetworkScenePatcher.GetLevelSceneDict(); List list = levelSceneDict.Values.ToList(); for (int i = 0; i < levelSceneDict.Count; i++) { if (list.Count > i) { networkSceneInfos.Add(new NetworkSceneInfo(i, list[i])); } } } private void GenerateAssetBundleGroupDict() { assetBundleGroupSceneDict = new Dictionary>(); foreach (AssetBundleGroup assetBundleGroup in LethalLevelLoader.AssetBundles.AssetBundleLoader.Instance.AssetBundleGroups) { foreach (string sceneName in assetBundleGroup.GetSceneNames()) { if (!assetBundleGroupSceneDict.TryGetValue(sceneName, out var value)) { assetBundleGroupSceneDict.Add(sceneName, new List(1) { assetBundleGroup }); } else if (!value.Contains(assetBundleGroup)) { value.Add(assetBundleGroup); } } } } protected override void __initializeVariables() { if (allowedToLoadLevel == null) { throw new Exception("NetworkBundleManager.allowedToLoadLevel cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)allowedToLoadLevel).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)allowedToLoadLevel, "allowedToLoadLevel"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)allowedToLoadLevel); if (playersLoadStatus == null) { throw new Exception("NetworkBundleManager.playersLoadStatus cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)playersLoadStatus).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)playersLoadStatus, "playersLoadStatus"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)playersLoadStatus); ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1003568550u, new RpcReceiveHandler(__rpc_handler_1003568550), "RequestLoadStatusRefreshServerRpc"); ((NetworkBehaviour)this).__registerRpc(2729437277u, new RpcReceiveHandler(__rpc_handler_2729437277), "RequestLoadStatusRefreshClientRpc"); ((NetworkBehaviour)this).__registerRpc(2843210445u, new RpcReceiveHandler(__rpc_handler_2843210445), "SetLoadedStatusServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1003568550(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NetworkBundleManager)(object)target).RequestLoadStatusRefreshServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2729437277(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NetworkBundleManager)(object)target).RequestLoadStatusRefreshClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2843210445(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = target.NetworkManager; if (val != null && val.IsListening) { ulong clientID = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref clientID); bool status = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref status, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((NetworkBundleManager)(object)target).SetLoadedStatusServerRpc(clientID, status); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "NetworkBundleManager"; } } internal static class SaveManager { public static LLLSaveFile currentSaveFile; public static bool parityCheck; internal static void InitializeSave() { if (!LethalLevelLoaderNetworkManager.networkManager.IsServer) { return; } currentSaveFile = new LLLSaveFile(); ((ModDataContainer)currentSaveFile).Load(); if (currentSaveFile.CurrentLevelName != null) { DebugHelper.Log("Initialized LLL Save File, Current Level Was: " + currentSaveFile.CurrentLevelName + ", Current Vanilla Save Is: " + GameNetworkManager.Instance.currentSaveFileName, DebugType.User); } else { DebugHelper.Log("Initialized LLL Save File, Current Level Was: (Empty) , Current Vanilla Save Is: " + GameNetworkManager.Instance.currentSaveFileName, DebugType.User); } if (ES3.KeyExists("CurrentPlanetID", GameNetworkManager.Instance.currentSaveFileName)) { DebugHelper.Log("Vanilla CurrentSaveFileName Has Saved Current Planet ID: " + ES3.Load("CurrentPlanetID", GameNetworkManager.Instance.currentSaveFileName), DebugType.Developer); } int num = ES3.Load("Stats_StepsTaken", GameNetworkManager.Instance.currentSaveFileName, 0); if (num == currentSaveFile.parityStepsTaken) { parityCheck = true; } else { DebugHelper.Log("Vanilla Save File Mismatch, LLL Steps Taken: " + currentSaveFile.parityStepsTaken + ", Vanilla Steps Taken: " + num, DebugType.Developer); currentSaveFile.Reset(); currentSaveFile.parityStepsTaken = num; parityCheck = false; } if (currentSaveFile.extendedLevelSaveData == null) { return; } foreach (ExtendedLevelData extendedLevelSaveDatum in currentSaveFile.extendedLevelSaveData) { LethalLevelLoaderNetworkManager.Instance.SetExtendedLevelValuesServerRpc(extendedLevelSaveDatum); } } internal static void SaveGameValues() { currentSaveFile.itemSaveData = GetAllItemsListItemDataDict(); currentSaveFile.parityStepsTaken = Patches.StartOfRound.gameStats.allStepsTaken; SaveAllLevels(); ((ModDataContainer)currentSaveFile).Save(); } internal static void SaveAllLevels() { currentSaveFile.extendedLevelSaveData = new List(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { currentSaveFile.extendedLevelSaveData.Add(new ExtendedLevelData(extendedLevel)); } } internal static void SaveCurrentSelectableLevel(SelectableLevel selectableLevel) { } internal static void LoadShipGrabbableItems() { if (parityCheck) { List constructedSavedShipItemData = GetConstructedSavedShipItemData(currentSaveFile.itemSaveData); FixMismatchedSavedItemData(constructedSavedShipItemData); OverrideCurrentSaveFileItemData(constructedSavedShipItemData); } } internal static void OverrideCurrentSaveFileItemData(List savedShipItemDatas) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; foreach (SavedShipItemData savedShipItemData in savedShipItemDatas) { list.Add(savedShipItemData.itemAllItemsListIndex); list2.Add(savedShipItemData.itemPosition); if (savedShipItemData.itemScrapValue != -1) { list3.Add(savedShipItemData.itemScrapValue); } if (savedShipItemData.itemAdditionalSavedData != -1) { list4.Add(savedShipItemData.itemAdditionalSavedData); } } if (ES3.KeyExists("shipGrabbableItemIDs", currentSaveFileName)) { ES3.DeleteKey("shipGrabbableItemIDs", currentSaveFileName); } if (ES3.KeyExists("shipGrabbableItemPos", currentSaveFileName)) { ES3.DeleteKey("shipGrabbableItemPos", currentSaveFileName); } if (ES3.KeyExists("shipScrapValues", currentSaveFileName)) { ES3.DeleteKey("shipScrapValues", currentSaveFileName); } if (ES3.KeyExists("shipItemSaveData", currentSaveFileName)) { ES3.DeleteKey("shipItemSaveData", currentSaveFileName); } if (list.Count > 0) { ES3.Save("shipGrabbableItemIDs", list.ToArray(), currentSaveFileName); } if (list2.Count > 0) { ES3.Save("shipGrabbableItemPos", list2.ToArray(), currentSaveFileName); } if (list3.Count > 0) { ES3.Save("shipScrapValues", list3.ToArray(), currentSaveFileName); } if (list4.Count > 0) { ES3.Save("shipItemSaveData", list4.ToArray(), currentSaveFileName); } } internal static void FixMismatchedSavedItemData(List savedShipItemDatas) { Dictionary allItemsListItemDataDict = GetAllItemsListItemDataDict(); int num = 0; foreach (SavedShipItemData savedShipItemData2 in savedShipItemDatas) { int itemAllItemsListIndex = savedShipItemData2.itemAllItemsListIndex; if (!allItemsListItemDataDict.ContainsKey(savedShipItemData2.itemAllItemsListIndex)) { break; } AllItemsListItemData itemAllItemsListData = savedShipItemData2.itemAllItemsListData; if (allItemsListItemDataDict[itemAllItemsListIndex].itemName != itemAllItemsListData.itemName) { break; } num++; } if (num >= savedShipItemDatas.Count) { return; } for (int i = num; i < savedShipItemDatas.Count; i++) { SavedShipItemData savedShipItemData = savedShipItemDatas[i]; int itemAllItemsListIndex2 = savedShipItemData.itemAllItemsListIndex; int num2 = (savedShipItemData.itemAllItemsListIndex = FixAllItemsListIndex(savedShipItemData.itemAllItemsListData, allItemsListItemDataDict)); if (allItemsListItemDataDict.TryGetValue(num2, out var value)) { if (itemAllItemsListIndex2 != num2) { DebugHelper.Log($"Fixing Item ┌ {savedShipItemData.itemAllItemsListData.modName} ┬ {savedShipItemData.itemAllItemsListData.itemName} ┬ {savedShipItemData.itemAllItemsListData.itemObjectName} ┬ #{itemAllItemsListIndex2}", DebugType.User); DebugHelper.Log($" -----> └ {value.modName} ┴ {value.itemName} ┴ {value.itemObjectName} ┴ #{num2}", DebugType.User); } savedShipItemData.itemAllItemsListData = value; if (!value.isScrap && savedShipItemData.itemScrapValue >= 0) { savedShipItemData.itemScrapValue = -1; } else if (value.isScrap && savedShipItemData.itemScrapValue == -1) { savedShipItemData.itemScrapValue = 0; } if (!value.saveItemVariable && savedShipItemData.itemAdditionalSavedData >= 0) { savedShipItemData.itemAdditionalSavedData = -1; } else if (value.saveItemVariable && savedShipItemData.itemAdditionalSavedData == -1) { savedShipItemData.itemAdditionalSavedData = 0; } } else { DebugHelper.Log($"Removing Item: [ {savedShipItemData.itemAllItemsListData.modName} ][ {savedShipItemData.itemAllItemsListData.itemName} ][ {savedShipItemData.itemAllItemsListData.itemObjectName} ][ #{itemAllItemsListIndex2}", DebugType.User); savedShipItemData.itemScrapValue = -1; savedShipItemData.itemAdditionalSavedData = -1; } } } internal static int FixAllItemsListIndex(AllItemsListItemData itemData, Dictionary itemDataDict) { List itemsList = Patches.StartOfRound.allItemsList.itemsList; int num = 0; int result = -1; for (int i = 0; i < itemsList.Count && itemDataDict.ContainsKey(i); i++) { int num2 = 0; AllItemsListItemData allItemsListItemData = itemDataDict[i]; if (allItemsListItemData.itemName == itemData.itemName) { num2 = ((allItemsListItemData.itemNameDuplicateIndex != itemData.itemNameDuplicateIndex) ? (num2 + 8) : (num2 + 16)); } if (allItemsListItemData.itemObjectName == itemData.itemObjectName) { num2 += 4; } if (num2 >= 4) { if (allItemsListItemData.modAuthor == itemData.modAuthor) { num2 += 64; } if (CompareModNames(allItemsListItemData.modName, itemData.modName)) { num2 += 32; } } else { if (allItemsListItemData.modItemsListIndex == itemData.modItemsListIndex && CompareModNames(allItemsListItemData.modName, itemData.modName)) { num2 += 2; } if (allItemsListItemData.allItemsListIndex == itemData.allItemsListIndex) { num2++; } } if (num2 > num) { num = num2; result = i; if (num == 116) { return result; } } } if (num >= 4) { return result; } return int.MaxValue; } internal static Dictionary GetAllItemsListItemDataDict() { Dictionary dictionary = new Dictionary(); int num = 0; foreach (Item items in Patches.StartOfRound.allItemsList.itemsList) { TryGetExtendedItemInfo(items, out var modName, out var modAuthor, out var modItemIndex); int itemNameDuplicateIndex = GetItemNameDuplicateIndex(items, modName); dictionary.Add(num, new AllItemsListItemData(((Object)items).name, items.itemName, modName, modAuthor, num, modItemIndex, itemNameDuplicateIndex, items.isScrap, items.saveItemVariable)); num++; } return dictionary; } internal static bool TryGetExtendedItemInfo(Item item, out string modName, out string modAuthor, out int modItemIndex) { int num = int.MaxValue; modName = ""; modAuthor = ""; modItemIndex = -1; foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { if (num <= extendedMod.ModNameAliases.Count) { continue; } int num2 = 0; foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems) { if ((Object)(object)extendedItem.Item == (Object)(object)item) { modName = string.Join(';', extendedMod.ModNameAliases); modAuthor = extendedMod.AuthorName; modItemIndex = num2; num = extendedMod.ModNameAliases.Count; break; } num2++; } } return modItemIndex > -1; } internal static int GetItemNameDuplicateIndex(Item item, string modName) { if (modName != "") { foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { if (!CompareModNames(extendedMod.ModName, modName)) { continue; } int num = 0; foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems) { if ((Object)(object)extendedItem.Item == (Object)(object)item) { break; } if (extendedItem.Item.itemName == item.itemName) { num++; } } return num; } return 0; } int num2 = 0; foreach (Item items in Patches.StartOfRound.allItemsList.itemsList) { if ((Object)(object)items == (Object)(object)item) { break; } if (items.itemName == item.itemName && !TryGetExtendedItemInfo(item, out var _, out var _, out var _)) { num2++; } } return num2; } internal static bool CompareModNames(string modNameA, string modNameB) { string[] modNamesA = modNameA.Split(';', StringSplitOptions.RemoveEmptyEntries); string[] array = modNameB.Split(';', StringSplitOptions.RemoveEmptyEntries); int i; for (i = 0; i < modNamesA.Length; i++) { int num = Array.FindIndex(array, (string modName) => string.Equals(modName, modNamesA[i], StringComparison.Ordinal)); if (num != -1) { return true; } } return false; } internal static List GetAllItemsListItemDatas(List itemIDs, Dictionary itemDataDict) { List list = new List(); foreach (int itemID in itemIDs) { if (itemDataDict.TryGetValue(itemID, out var value)) { list.Add(value); } else { list.Add(new AllItemsListItemData("", "", "", "", itemID, -1, 0, newIsScrap: false, newSaveItemVariable: false)); } } return list; } internal static List GetConstructedSavedShipItemData(Dictionary itemDataDict) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); if (ES3.KeyExists("shipGrabbableItemIDs", currentSaveFileName)) { list2.AddRange(ES3.Load("shipGrabbableItemIDs", currentSaveFileName)); } if (ES3.KeyExists("shipGrabbableItemPos", currentSaveFileName)) { list3.AddRange(ES3.Load("shipGrabbableItemPos", currentSaveFileName)); } if (ES3.KeyExists("shipScrapValues", currentSaveFileName)) { list4.AddRange(ES3.Load("shipScrapValues", currentSaveFileName)); } if (ES3.KeyExists("shipItemSaveData", currentSaveFileName)) { list5.AddRange(ES3.Load("shipItemSaveData", currentSaveFileName)); } List allItemsListItemDatas = GetAllItemsListItemDatas(list2, itemDataDict); int num = 0; int num2 = 0; for (int i = 0; i < list2.Count; i++) { int newItemAllItemsListIndex = list2[i]; Vector3 newItemPosition = Vector3.zero; int newItemScrapValue = -1; int newItemAdditionalSavedData = -1; AllItemsListItemData newItemAllItemsListData = allItemsListItemDatas[i]; if (list3.Count > i) { newItemPosition = list3[i]; } if (newItemAllItemsListData.isScrap) { newItemScrapValue = ((list4.Count > num) ? list4[num] : 0); num++; } if (newItemAllItemsListData.saveItemVariable) { newItemAdditionalSavedData = ((list5.Count > num2) ? list5[num2] : 0); num2++; } list.Add(new SavedShipItemData(newItemAllItemsListIndex, newItemPosition, newItemScrapValue, newItemAdditionalSavedData, newItemAllItemsListData)); } return list; } } public class SavedShipItemData(int newItemAllItemsListIndex, Vector3 newItemPosition, int newItemScrapValue, int newItemAdditionalSavedData, AllItemsListItemData newItemAllItemsListData) { public int itemAllItemsListIndex = newItemAllItemsListIndex; public Vector3 itemPosition = newItemPosition; public int itemScrapValue = newItemScrapValue; public int itemAdditionalSavedData = newItemAdditionalSavedData; public AllItemsListItemData itemAllItemsListData = newItemAllItemsListData; } public static class TerminalManager { public delegate string PreviewInfoText(ExtendedLevel extendedLevel, PreviewInfoType infoType); public enum LoadNodeActionType { Before, After } public delegate bool LoadNodeAction(ref TerminalNode currentNode, ref TerminalNode loadNode); [CompilerGenerated] private static Terminal k__BackingField; internal static TerminalNode lockedNode; internal static int moonsInCataloguePage; internal static int linesInCataloguePage; internal static float linesToScroll = 20f; internal static TerminalKeyword routeKeyword; internal static TerminalKeyword routeInfoKeyword; internal static TerminalKeyword routeConfirmKeyword; internal static TerminalKeyword routeDenyKeyword; internal static TerminalKeyword moonsKeyword; internal static TerminalKeyword viewKeyword; internal static TerminalKeyword buyKeyword; internal static TerminalNode cancelRouteNode; internal static TerminalNode cancelPurchaseNode; internal static TerminalKeyword previewKeyword; internal static TerminalKeyword sortKeyword; internal static TerminalKeyword filterKeyword; internal static TerminalKeyword simulateKeyword; internal static string currentTagFilter; public static float defaultTerminalFontSize; internal static TerminalKeyword lastParsedVerbKeyword; internal static Dictionary onBeforeLoadNewNodeRegisteredEventsDictionary = new Dictionary(); internal static Dictionary onLoadNewNodeRegisteredEventsDictionary = new Dictionary(); internal static Terminal Terminal { get { if ((Object)(object)k__BackingField == (Object)null) { k__BackingField = Object.FindAnyObjectByType((FindObjectsInactive)0); } return k__BackingField; } } public static MoonsCataloguePage defaultMoonsCataloguePage { get; internal set; } public static MoonsCataloguePage currentMoonsCataloguePage { get; internal set; } public static event PreviewInfoText onBeforePreviewInfoTextAdded; internal static void CacheTerminalReferences() { routeKeyword = Terminal.terminalNodes.allKeywords[27]; routeInfoKeyword = Terminal.terminalNodes.allKeywords[6]; routeConfirmKeyword = Terminal.terminalNodes.allKeywords[3]; routeDenyKeyword = Terminal.terminalNodes.allKeywords[4]; moonsKeyword = Terminal.terminalNodes.allKeywords[21]; viewKeyword = Terminal.terminalNodes.allKeywords[19]; buyKeyword = Terminal.terminalNodes.allKeywords[0]; cancelRouteNode = routeKeyword.compatibleNouns[0].result.terminalOptions[0].result; cancelPurchaseNode = buyKeyword.compatibleNouns[0].result.terminalOptions[1].result; defaultTerminalFontSize = Terminal.screenText.textComponent.fontSize; lockedNode = CreateNewTerminalNode(); ((Object)lockedNode).name = "lockedLevelNode"; lockedNode.acceptAnything = false; lockedNode.clearPreviousText = true; } internal static bool OnBeforeRouteNodeLoaded(ref TerminalNode currentNode, ref TerminalNode loadNode) { TerminalNode result = loadNode.terminalOptions[1].result; if (result.buyRerouteToMoon < 0 || result.buyRerouteToMoon > Patches.StartOfRound.levels.Length - 1) { DebugHelper.LogError("Invalid DisplayPlanetInfo For Route Node: " + ((Object)result).name, DebugType.User); return true; } ExtendedLevel extendedLevel = LevelManager.GetExtendedLevel(Patches.StartOfRound.levels[result.buyRerouteToMoon]); if ((Object)(object)extendedLevel == (Object)null) { DebugHelper.LogError("ExtendedLevel Was Null For Route Node: " + ((Object)result).name, DebugType.User); return true; } if ((Object)(object)currentNode != (Object)null) { DebugHelper.Log($"LockedNodeEventTest: ExtendedLevel Is: {extendedLevel}, CurrentNode Is: {((Object)currentNode).name}, LoadNode Is: {((Object)result).name}", DebugType.User); } else { DebugHelper.Log($"LockedNodeEventTest: ExtendedLevel Is: {extendedLevel}, CurrentNode Is Null, LoadNode Is: {((Object)result).name}", DebugType.User); } if (extendedLevel.IsRouteLocked) { SwapRouteNodeToLockedNode(extendedLevel, ref loadNode); } return true; } internal static void SwapRouteNodeToLockedNode(ExtendedLevel extendedLevel, ref TerminalNode terminalNode) { lockedNode.displayText = ((!string.IsNullOrEmpty(extendedLevel.LockedRouteNodeText)) ? (extendedLevel.LockedRouteNodeText + "\n\n\n") : ("Route to " + extendedLevel.SelectableLevel.PlanetName + " is currently locked.\n\n\n")); terminalNode = lockedNode; } internal static void RefreshExtendedLevelGroups() { currentMoonsCataloguePage.RebuildLevelGroups(defaultMoonsCataloguePage.ExtendedLevelGroups, Settings.moonsCatalogueSplitCount); if (Settings.levelPreviewSortType != SortInfoType.None) { SortMoonsCataloguePage(currentMoonsCataloguePage); } FilterMoonsCataloguePage(currentMoonsCataloguePage); foreach (ExtendedLevelGroup extendedLevelGroup in currentMoonsCataloguePage.ExtendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { if (!extendedLevels.IsRouteHidden) { moonsInCataloguePage++; } } } } internal static bool SetSimulationResultsText(ref TerminalNode currentNode, ref TerminalNode node) { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (node.terminalEvent.ContainsSanitized(extendedLevel.NumberlessPlanetName)) { node.displayText = GetSimulationResultsText(extendedLevel) + "\n\n"; node.clearPreviousText = true; node.isConfirmationNode = true; } } return true; } internal static bool OnBeforeLoadNewNode(ref TerminalNode node) { if (onBeforeLoadNewNodeRegisteredEventsDictionary.TryGetValue(node, out var value)) { DebugHelper.Log($"Running OnBeforeLoadNewNode Event For: {((Object)node).name}, CurrentNode Is: {Terminal.currentNode}", DebugType.Developer); return value(ref Terminal.currentNode, ref node); } DebugHelper.Log("Could Not Find Registered Event For: " + ((Object)node).name, DebugType.Developer); return true; } internal static void OnLoadNewNode(ref TerminalNode node) { if (onLoadNewNodeRegisteredEventsDictionary.TryGetValue(node, out var value)) { DebugHelper.Log("Running OnLoadNewNode Event For: " + ((Object)node).name + ", CurrentNode Is: " + (object)Terminal.currentNode, DebugType.Developer); value(ref Terminal.currentNode, ref node); } else { DebugHelper.Log("Could Not Find Registered Event For: " + ((Object)node).name, DebugType.Developer); } } internal static bool RunLethalLevelLoaderTerminalEvents(TerminalNode node) { return true; } internal static bool TryRefreshMoonsCataloguePage(ref TerminalNode currentNode, ref TerminalNode loadNode) { if ((Object)(object)currentNode == (Object)(object)moonsKeyword.specialKeywordResult) { return RefreshMoonsCataloguePage(ref currentNode, ref loadNode); } return true; } public static bool RefreshMoonsCataloguePage(ref TerminalNode currentNode, ref TerminalNode loadNode) { object result2; object result3; if (((Object)loadNode).name.Contains("preview", StringComparison.OrdinalIgnoreCase) && Enum.TryParse(typeof(PreviewInfoType), GetTerminalEventEnum(loadNode.terminalEvent), out object result)) { Settings.levelPreviewInfoType = (PreviewInfoType)result; } else if (((Object)loadNode).name.Contains("sort", StringComparison.OrdinalIgnoreCase) && Enum.TryParse(typeof(SortInfoType), GetTerminalEventEnum(loadNode.terminalEvent), out result2)) { Settings.levelPreviewSortType = (SortInfoType)result2; } else if (((Object)loadNode).name.Contains("filter", StringComparison.OrdinalIgnoreCase) && Enum.TryParse(typeof(FilterInfoType), GetTerminalEventEnum(loadNode.terminalEvent), out result3)) { Settings.levelPreviewFilterType = (FilterInfoType)result3; currentTagFilter = GetTerminalEventString(loadNode.terminalEvent); } RefreshExtendedLevelGroups(); Terminal.modifyingText = true; ((Selectable)Terminal.screenText).interactable = true; Terminal.screenText.text = Terminal.TextPostProcess("\n\n\n" + GetMoonsTerminalText(), Terminal.currentNode); Terminal.currentText = Terminal.screenText.text; Terminal.textAdded = 0; Terminal.currentNode = moonsKeyword.specialKeywordResult; return false; } internal static void FilterMoonsCataloguePage(MoonsCataloguePage moonsCataloguePage) { List list = new List(); foreach (ExtendedLevelGroup extendedLevelGroup in moonsCataloguePage.ExtendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { if (Settings.levelPreviewFilterType switch { FilterInfoType.Price => extendedLevels.RoutePrice > Terminal.groupCredits, FilterInfoType.Weather => !string.IsNullOrEmpty(GetWeatherConditions(extendedLevels)), FilterInfoType.Tag => !extendedLevels.TryGetTag(currentTagFilter), _ => extendedLevels.IsRouteHidden, }) { list.Add(extendedLevels); } } } int num = 0; foreach (ExtendedLevelGroup extendedLevelGroup2 in moonsCataloguePage.ExtendedLevelGroups) { num += extendedLevelGroup2.extendedLevelsList.RemoveAll(list.Contains); } if (num > 0) { DebugHelper.Log($"Removed '{num}' filtered or hidden levels from the Moons Catalogue.", DebugType.IAmBatby); } if (Settings.levelPreviewFilterType != FilterInfoType.None) { moonsCataloguePage.RebuildLevelGroups(moonsCataloguePage.ExtendedLevelGroups, Settings.moonsCatalogueSplitCount); } } internal static void SortMoonsCataloguePage(MoonsCataloguePage cataloguePage) { if (Settings.levelPreviewSortType == SortInfoType.Price) { cataloguePage.ExtendedLevels.Sort(default(ExtendedLevel.ExtendedLevelRoutePriceComparer)); cataloguePage.RebuildLevelGroups(cataloguePage.ExtendedLevels, Settings.moonsCatalogueSplitCount); } else if (Settings.levelPreviewSortType == SortInfoType.Difficulty) { cataloguePage.ExtendedLevels.Sort(default(ExtendedLevel.ExtendedLevelDifficultyComparer)); cataloguePage.RebuildLevelGroups(cataloguePage.ExtendedLevels, Settings.moonsCatalogueSplitCount); } } public static void AddTerminalNodeEventListener(TerminalNode node, LoadNodeAction action, LoadNodeActionType loadNodeActionType) { if ((Object)(object)node != (Object)null && action != null) { if (loadNodeActionType == LoadNodeActionType.Before && onBeforeLoadNewNodeRegisteredEventsDictionary.TryAdd(node, action)) { DebugHelper.Log("Successfully Registered OnBeforeLoadNode Action: " + action.Method.Name + " To TerminalNode: " + ((Object)node).name, DebugType.Developer); } else if (loadNodeActionType == LoadNodeActionType.After && onLoadNewNodeRegisteredEventsDictionary.TryAdd(node, action)) { DebugHelper.Log("Successfully Registered OnLoadNode Action: " + action.Method.Name + " To TerminalNode: " + ((Object)node).name, DebugType.Developer); } } } internal static string GetMoonsTerminalText() { string text = "Welcome to the exomoons catalogue.\r\nTo route the autopilot to a moon, use the word ROUTE.\r\nTo learn about any moon, use the word INFO.\r\n____________________________\r\n\r\n* The Company Building // Buying at [companyBuyingPercent].\r\n\r\n"; string[] array = moonsKeyword.specialKeywordResult.displayText.Split('\n'); int num = Array.FindIndex(array, (string line) => line.Contains("[planetTime]", StringComparison.Ordinal)); if (num != -1) { text = string.Join('\n', array[..num]) + "\n"; } else { DebugHelper.LogError("Failed To get Moons Catalogue overview text dynamically, falling back to hardcoded English variant.", DebugType.Developer); } return text + GetMoonCatalogDisplayListings() + "\r\n"; } public static string GetMoonCatalogDisplayListings() { string text = string.Empty; int num = 0; foreach (ExtendedLevelGroup extendedLevelGroup in currentMoonsCataloguePage.ExtendedLevelGroups) { string text2 = string.Empty; foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { if (!extendedLevels.IsRouteHidden) { text2 = text2 + "* " + extendedLevels.NumberlessPlanetName + " " + GetExtendedLevelPreviewInfo(extendedLevels) + "\n"; if (++num == Settings.moonsCatalogueSplitCount) { text2 += "\n"; num = 0; } } } if (!string.IsNullOrEmpty(text2)) { text += text2; } } text = text.TrimEnd('\n'); string text3 = Settings.levelPreviewFilterType.ToString().ToUpperInvariant(); if (Settings.levelPreviewFilterType == FilterInfoType.Tag) { text3 = currentTagFilter.ToUpperInvariant(); } return text + "\n____________________________\nPREVIEW: " + Settings.levelPreviewInfoType.ToString().ToUpperInvariant() + " | SORT: " + Settings.levelPreviewSortType.ToString().ToUpperInvariant() + " | FILTER: " + text3 + "\n"; } public static string GetExtendedLevelPreviewInfo(ExtendedLevel extendedLevel) { string text = Settings.levelPreviewInfoType switch { PreviewInfoType.Price => $"(${extendedLevel.RoutePrice})", PreviewInfoType.Difficulty => "(" + extendedLevel.SelectableLevel.riskLevel + ")", PreviewInfoType.Weather => GetWeatherConditions(extendedLevel), PreviewInfoType.History => GetHistoryConditions(extendedLevel) ?? "", PreviewInfoType.All => $"({extendedLevel.SelectableLevel.riskLevel}) (${extendedLevel.RoutePrice}) {GetWeatherConditions(extendedLevel)}", PreviewInfoType.Vanilla => "[planetTime]", PreviewInfoType.Override => Settings.GetOverridePreviewInfo(extendedLevel) ?? "", _ => string.Empty, }; if (extendedLevel.IsRouteLocked) { text += " (Locked)"; } string text2 = TerminalManager.onBeforePreviewInfoTextAdded?.Invoke(extendedLevel, Settings.levelPreviewInfoType); if (!string.IsNullOrEmpty(text2)) { text = text2; } return text; } public static string GetWeatherConditions(ExtendedLevel extendedLevel) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) string result = string.Empty; if ((int)extendedLevel.SelectableLevel.currentWeather != -1) { result = $"({extendedLevel.SelectableLevel.currentWeather})"; } return result; } public static string GetHistoryConditions(ExtendedLevel extendedLevel) { DayHistory dayHistory = LevelManager.dayHistoryList.Find((DayHistory dayHistory2) => (Object)(object)dayHistory2.extendedLevel == (Object)(object)extendedLevel); if (dayHistory == null) { return "(Unexplored)"; } if (Patches.TimeOfDay.timesFulfilledQuota == dayHistory.quota && LevelManager.daysTotal == dayHistory.day) { return "(Explored Yesterday)"; } if (Patches.TimeOfDay.timesFulfilledQuota == dayHistory.quota) { return $"(Explored {LevelManager.daysTotal - dayHistory.day} Ago)"; } if (Patches.TimeOfDay.timesFulfilledQuota - 1 == dayHistory.quota) { return "(Explored Last Quota)"; } return $"Explored {Patches.TimeOfDay.timesFulfilledQuota - dayHistory.quota} Quotas Ago)"; } public static string GetTerminalEventString(string terminalEventString) { return terminalEventString.Split(';', StringSplitOptions.RemoveEmptyEntries)[^1]; } public static string GetTerminalEventEnum(string terminalEventString) { return terminalEventString.Split(';', StringSplitOptions.RemoveEmptyEntries)[0]; } public static string GetSimulationResultsText(ExtendedLevel extendedLevel) { List list = DungeonManager.GetValidExtendedDungeonFlows(extendedLevel, debugResults: true).ToList(); list.Sort(new ExtendedDungeonFlowWithRarity.ExtendedDungeonFlowWithRarityComparer(ascending: false)); string text = "Simulating arrival to " + extendedLevel.SelectableLevel.PlanetName + "\nAnalyzing potential remnants found on surface. \nListing generated probabilities below.\n____________________________ \n\nPOSSIBLE STRUCTURES: \n"; int num = 0; foreach (ExtendedDungeonFlowWithRarity item in list) { num += item.newRarity; } foreach (ExtendedDungeonFlowWithRarity item2 in list) { text = text + "* " + item2.newExtendedDungeonFlow.DungeonName.PadRight(22).Truncate(22) + " // " + GetSimulationDataText(item2.newRarity, num) + "\n"; } return text; } public static string GetSimulationDataText(int rarity, int totalRarity) { string text = string.Empty; if (Settings.levelSimulateInfoType == SimulateInfoType.Percentage) { text = "Chance: " + ((float)rarity / (float)totalRarity * 100f).ToString("#0.00", CultureInfo.InvariantCulture).PadLeft(5) + "%"; } else if (Settings.levelSimulateInfoType == SimulateInfoType.Rarity) { text = "Weight: " + $"{rarity}".PadLeft(4) + " / " + totalRarity; } else if (Settings.levelSimulateInfoType == SimulateInfoType.All) { text = "Weight: " + $"{rarity}".PadRight(5) + ((float)rarity / (float)totalRarity * 100f).ToString("\\(#0.0#", CultureInfo.InvariantCulture).PadLeft(6) + "%)"; } return text.PadLeft(5).Truncate(25); } public static string GetOffsetExtendedLevelName(ExtendedLevel extendedLevel) { int num = 0; string text = string.Empty; foreach (ExtendedLevel extendedLevel2 in currentMoonsCataloguePage.ExtendedLevels) { if (extendedLevel2.NumberlessPlanetName.Length > num) { num = extendedLevel2.NumberlessPlanetName.Length; } } for (int i = 0; i < num - extendedLevel.NumberlessPlanetName.Length; i++) { text += " "; } return text; } internal static TerminalKeyword TryFindAlternativeNoun(Terminal terminal, TerminalKeyword foundKeyword, string playerInput) { if ((Object)(object)foundKeyword != (Object)null && !terminal.hasGottenVerb && foundKeyword.isVerb) { lastParsedVerbKeyword = foundKeyword; } if ((Object)(object)foundKeyword != (Object)null && !foundKeyword.isVerb && terminal.hasGottenVerb && (Object)(object)lastParsedVerbKeyword != (Object)null) { if (!ValidateNounKeyword(lastParsedVerbKeyword, foundKeyword)) { TerminalKeyword[] allKeywords = Terminal.terminalNodes.allKeywords; foreach (TerminalKeyword val in allKeywords) { if (!val.isVerb && (Object)(object)val != (Object)(object)foundKeyword && string.Equals(val.word, playerInput, StringComparison.OrdinalIgnoreCase) && ValidateNounKeyword(lastParsedVerbKeyword, val)) { lastParsedVerbKeyword = null; return val; } } } } return foundKeyword; } internal static bool ValidateNounKeyword(TerminalKeyword verbKeyword, TerminalKeyword nounKeyword) { for (int i = 0; i < verbKeyword.compatibleNouns.Length; i++) { if ((Object)(object)verbKeyword.compatibleNouns[i].noun == (Object)(object)nounKeyword) { return true; } } return false; } public static List GetExtendedLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount) { List list = new List(); int num = 0; int num2 = 0; List list2 = new List(); foreach (ExtendedLevel item in new List(newExtendedLevels)) { list2.Add(item); num2++; num++; if (num == splitCount || num2 == newExtendedLevels.Length) { list.Add(new ExtendedLevelGroup(list2)); list2.Clear(); num = 0; } } return list; } internal static void CreateExtendedLevelGroups() { List list = new List(); foreach (ExtendedLevel vanillaExtendedLevel in PatchedContent.VanillaExtendedLevels) { if (!moonsKeyword.specialKeywordResult.displayText.Contains(vanillaExtendedLevel.NumberlessPlanetName, StringComparison.Ordinal)) { vanillaExtendedLevel.IsRouteHidden = true; list.Add(vanillaExtendedLevel); } } list.Sort(default(ExtendedLevel.ExtendedLevelDifficultyComparer)); DebugHelper.Log("Creating ExtendedLevelGroups", DebugType.Developer); foreach (SelectableLevel item5 in OriginalContent.MoonsCatalogue) { DebugHelper.Log(item5.PlanetName ?? "", DebugType.Developer); } ExtendedLevelGroup item = new ExtendedLevelGroup(OriginalContent.MoonsCatalogue.GetRange(0, 3)); ExtendedLevelGroup item2 = new ExtendedLevelGroup(OriginalContent.MoonsCatalogue.GetRange(3, 3)); ExtendedLevelGroup item3 = new ExtendedLevelGroup(OriginalContent.MoonsCatalogue.GetRange(6, 3)); ExtendedLevelGroup item4 = new ExtendedLevelGroup(list); Dictionary> dictionary = new Dictionary>(); foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { if (!dictionary.TryGetValue(customExtendedLevel.ModName, out var value)) { dictionary.Add(customExtendedLevel.ModName, new List(1) { customExtendedLevel }); } else { value.Add(customExtendedLevel); } } List list2 = new List(); List list3 = new List(); foreach (KeyValuePair> item6 in new Dictionary>(dictionary)) { item6.Value.Sort(default(ExtendedLevel.ExtendedLevelDifficultyComparer)); dictionary[item6.Key] = item6.Value; if (item6.Value.Count == 1) { list2.Add(item6.Value[0]); } else { if (item6.Value.Count == 0) { continue; } foreach (ExtendedLevelGroup extendedLevelGroup in GetExtendedLevelGroups(item6.Value.ToArray(), Settings.moonsCatalogueSplitCount)) { list3.Add(extendedLevelGroup); } } } list2.Sort(default(ExtendedLevel.ExtendedLevelDifficultyComparer)); list3.AddRange(GetExtendedLevelGroups(list2.ToArray(), Settings.moonsCatalogueSplitCount)); list3.Sort(default(ExtendedLevelGroup.ExtendedLevelGroupDifficultyComparer)); List list4 = new List(); list4.Add(item); list4.Add(item2); list4.Add(item3); list4.Add(item4); list4.AddRange(list3); List list5 = list4; string text = "Debugging DefaultExtendedLevelsGroups:\n"; for (int i = 0; i < list5.Count; i++) { text += $"Group #{i} -> "; foreach (ExtendedLevel extendedLevels in list5[i].extendedLevelsList) { text = text + extendedLevels.NumberlessPlanetName + "(" + extendedLevels.ModName + "), "; } text = text.TrimEnd(',', ' '); } DebugHelper.Log(text, DebugType.Developer); defaultMoonsCataloguePage = new MoonsCataloguePage(list5); currentMoonsCataloguePage = new MoonsCataloguePage(new List()); RefreshExtendedLevelGroups(); } internal static void CreateLevelTerminalData(ExtendedLevel extendedLevel, int routePrice) { string text = extendedLevel.NumberlessPlanetName.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "Keyword"; val.word = text.ToLowerInvariant(); val.defaultVerb = routeKeyword; TerminalNode val2; if ((Object)(object)extendedLevel.RouteNode != (Object)null) { val2 = extendedLevel.RouteNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = text + "Route"; val2.displayText = ((!string.IsNullOrEmpty(extendedLevel.OverrideRouteNodeDescription)) ? extendedLevel.OverrideRouteNodeDescription : ("The cost to route to " + extendedLevel.SelectableLevel.PlanetName + " is [totalCost]. It is currently [currentPlanetTime] on this moon.\n\nPlease CONFIRM or DENY.\n\n")); val2.clearPreviousText = true; val2.buyRerouteToMoon = -2; val2.displayPlanetInfo = extendedLevel.SelectableLevel.levelID; val2.itemCost = routePrice; val2.overrideOptions = true; } TerminalNode val3; if ((Object)(object)extendedLevel.RouteConfirmNode != (Object)null) { val3 = extendedLevel.RouteConfirmNode; } else { val3 = CreateNewTerminalNode(); ((Object)val3).name = text + "RouteConfirm"; val3.displayText = ((!string.IsNullOrEmpty(extendedLevel.OverrideRouteConfirmNodeDescription)) ? extendedLevel.OverrideRouteConfirmNodeDescription : ("Routing autopilot to " + extendedLevel.SelectableLevel.PlanetName + " Your new balance is [playerCredits]. \n\nPlease enjoy your flight.")); val3.clearPreviousText = true; val3.buyRerouteToMoon = extendedLevel.SelectableLevel.levelID; val3.itemCost = routePrice; } TerminalNode val4; if ((Object)(object)extendedLevel.InfoNode != (Object)null) { val4 = extendedLevel.InfoNode; } else { val4 = CreateNewTerminalNode(); ((Object)val4).name = text + "Info"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; string text2; if (!string.IsNullOrEmpty(extendedLevel.OverrideInfoNodeDescription)) { text2 = extendedLevel.OverrideInfoNodeDescription; } else { text2 = extendedLevel.SelectableLevel.PlanetName + "\n----------------------\n"; string[] array = extendedLevel.SelectableLevel.LevelDescription.Split('\n'); foreach (string text3 in array) { text2 = text2 + "\n" + text3 + "\n"; } } val4.displayText = text2; } val2.AddCompatibleNoun(routeDenyKeyword, cancelRouteNode); val2.AddCompatibleNoun(routeConfirmKeyword, val3); routeKeyword.AddCompatibleNoun(val, val2); routeInfoKeyword.AddCompatibleNoun(val, val4); extendedLevel.RouteNode = val2; extendedLevel.RouteConfirmNode = val3; extendedLevel.InfoNode = val4; } internal static void CreateTerminalDataForAllExtendedStoryLogs() { foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { foreach (ExtendedStoryLog extendedStoryLog in extendedMod.ExtendedStoryLogs) { CreateStoryLogTerminalData(extendedStoryLog); } } } internal static void CreateStoryLogTerminalData(ExtendedStoryLog newStoryLog) { if (Plugin.IsSetupComplete) { Terminal.logEntryFiles.Add(newStoryLog.assignedNode); return; } string text = newStoryLog.storyLogTitle.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "Keyword"; val.word = newStoryLog.terminalKeywordNoun.Sanitized().RemoveWhitespace(); val.defaultVerb = viewKeyword; TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = $"LogFile{Terminal.logEntryFiles.Count + 1}"; val2.displayText = newStoryLog.storyLogDescription; val2.clearPreviousText = true; val2.creatureName = newStoryLog.storyLogTitle; val2.storyLogFileID = Terminal.logEntryFiles.Count; newStoryLog.newStoryLogID = Terminal.logEntryFiles.Count; newStoryLog.assignedNode = val2; Terminal.logEntryFiles.Add(val2); viewKeyword.AddCompatibleNoun(val, val2); } internal static void CreateItemTerminalData(ExtendedItem extendedItem) { string text = extendedItem.Item.itemName.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "Keyword"; val.word = text.ToLowerInvariant(); val.defaultVerb = buyKeyword; TerminalNode val2; if ((Object)(object)extendedItem.BuyNode != (Object)null) { val2 = extendedItem.BuyNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = text + "Buy"; val2.displayText = ((!string.IsNullOrEmpty(extendedItem.OverrideBuyNodeDescription)) ? extendedItem.OverrideBuyNodeDescription : ("You have requested to order " + ((!string.IsNullOrEmpty(extendedItem.PluralisedItemName)) ? extendedItem.PluralisedItemName : extendedItem.Item.itemName) + ". Amount: [variableAmount].\n Total cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n")); val2.clearPreviousText = true; val2.maxCharactersToType = 15; val2.isConfirmationNode = true; val2.itemCost = extendedItem.Item.creditsWorth; val2.overrideOptions = true; } TerminalNode val3; if ((Object)(object)extendedItem.BuyConfirmNode != (Object)null) { val3 = extendedItem.BuyConfirmNode; } else { val3 = CreateNewTerminalNode(); ((Object)val3).name = text + "BuyConfirm"; val3.displayText = ((!string.IsNullOrEmpty(extendedItem.OverrideBuyConfirmNodeDescription)) ? extendedItem.OverrideBuyConfirmNodeDescription : ("Ordered [variableAmount] " + ((!string.IsNullOrEmpty(extendedItem.PluralisedItemName)) ? extendedItem.PluralisedItemName : extendedItem.Item.itemName) + ". Your new balance is[playerCredits]\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.")); val3.clearPreviousText = true; val3.maxCharactersToType = 35; val3.isConfirmationNode = false; val3.playSyncedClip = 0; } TerminalNode val4 = null; if (!string.IsNullOrEmpty(extendedItem.OverrideInfoNodeDescription)) { if ((Object)(object)extendedItem.BuyInfoNode != (Object)null) { val4 = extendedItem.BuyInfoNode; } else { val4 = CreateNewTerminalNode(); ((Object)val4).name = text + "Info"; val4.clearPreviousText = true; val4.maxCharactersToType = 25; val4.displayText = "\n" + extendedItem.OverrideInfoNodeDescription; } } val2.AddCompatibleNoun(routeConfirmKeyword, val3); val2.AddCompatibleNoun(routeDenyKeyword, cancelPurchaseNode); buyKeyword.AddCompatibleNoun(val, val2); if ((Object)(object)val4 != (Object)null) { routeInfoKeyword.AddCompatibleNoun(val, val4); } extendedItem.BuyNode = val2; extendedItem.BuyConfirmNode = val3; extendedItem.BuyInfoNode = val4; } internal static void CreateEnemyTypeTerminalData(ExtendedEnemyType extendedEnemyType) { if (Plugin.IsSetupComplete) { Patches.Terminal.enemyFiles.Add(extendedEnemyType.EnemyInfoNode); return; } string text = extendedEnemyType.EnemyDisplayName.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "BestiaryKeyword"; val.word = text.ToLowerInvariant(); val.defaultVerb = routeInfoKeyword; TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = text + "BestiaryNode"; val2.displayText = extendedEnemyType.InfoNodeDescription; val2.creatureFileID = extendedEnemyType.EnemyID; val2.creatureName = extendedEnemyType.EnemyDisplayName; val2.playSyncedClip = 2; if ((Object)(object)extendedEnemyType.InfoNodeVideoClip != (Object)null) { val2.displayVideo = extendedEnemyType.InfoNodeVideoClip; val2.loadImageSlowly = true; } extendedEnemyType.EnemyInfoNode = val2; Patches.Terminal.enemyFiles.Add(val2); routeInfoKeyword.AddCompatibleNoun(val, val2); } internal static void CreateBuyableVehicleTerminalData(ExtendedBuyableVehicle extendedBuyableVehicle) { string text = extendedBuyableVehicle.BuyableVehicle.vehicleDisplayName.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "Keyword"; val.word = extendedBuyableVehicle.TerminalKeywordName.ToLowerInvariant(); val.defaultVerb = buyKeyword; TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = text + "Buy"; val2.itemCost = extendedBuyableVehicle.BuyableVehicle.creditsWorth; val2.buyVehicleIndex = extendedBuyableVehicle.VehicleID; val2.isConfirmationNode = true; val2.overrideOptions = true; val2.clearPreviousText = true; val2.maxCharactersToType = 15; val2.displayText = "You have requested to order the " + extendedBuyableVehicle.BuyableVehicle.vehicleDisplayName + ".\n[warranty] Total cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n"; TerminalNode val3 = CreateNewTerminalNode(); ((Object)val3).name = text + "BuyConfirm"; val3.itemCost = extendedBuyableVehicle.BuyableVehicle.creditsWorth; val3.buyVehicleIndex = extendedBuyableVehicle.VehicleID; val3.clearPreviousText = true; val3.maxCharactersToType = 35; val3.playSyncedClip = 0; val3.displayText = "Ordered the " + extendedBuyableVehicle.BuyableVehicle.vehicleDisplayName + ". Your new balance is [playerCredits].\n\nWe are so confident in the quality of this product, it comes with a life-time warranty! If your " + extendedBuyableVehicle.BuyableVehicle.vehicleDisplayName + " is lost or destroyed, you can get one free replacement. Items cannot be purchased while the vehicle is en route.\n\n"; TerminalNode val4 = CreateNewTerminalNode(); ((Object)val4).name = text + "Info"; extendedBuyableVehicle.VehicleBuyNode = val2; extendedBuyableVehicle.VehicleBuyConfirmNode = val3; extendedBuyableVehicle.VehicleInfoNode = val4; val2.AddCompatibleNoun(routeConfirmKeyword, val3); val2.AddCompatibleNoun(routeDenyKeyword, cancelPurchaseNode); buyKeyword.AddCompatibleNoun(val, val2); } internal static void CreateUnlockableItemTerminalData(ExtendedUnlockableItem extendedUnlockableItem) { string text = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized(toLower: false).RemoveWhitespace(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = text + "Keyword"; val.word = text.ToLowerInvariant(); val.defaultVerb = buyKeyword; TerminalNode val2; if ((Object)(object)extendedUnlockableItem.BuyNode != (Object)null) { val2 = extendedUnlockableItem.BuyNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = text + "Buy"; val2.itemCost = extendedUnlockableItem.ItemCost; val2.isConfirmationNode = false; val2.overrideOptions = true; val2.clearPreviousText = true; val2.maxCharactersToType = 15; val2.creatureName = extendedUnlockableItem.UnlockableItem.unlockableName; val2.displayText = ((!string.IsNullOrEmpty(extendedUnlockableItem.OverrideBuyNodeDescription)) ? extendedUnlockableItem.OverrideBuyNodeDescription : ("You have requested to order the " + val2.creatureName + ".\n Total cost of item: [totalCost].\n\nPlease CONFIRM or DENY.\n\n")); } val2.shipUnlockableID = extendedUnlockableItem.UnlockableItemID; TerminalNode val3; if ((Object)(object)extendedUnlockableItem.BuyConfirmNode != (Object)null) { val3 = extendedUnlockableItem.BuyConfirmNode; } else { val3 = CreateNewTerminalNode(); ((Object)val3).name = text + "BuyConfirm"; val3.itemCost = extendedUnlockableItem.ItemCost; val3.isConfirmationNode = false; val3.clearPreviousText = true; val3.buyUnlockable = true; val3.maxCharactersToType = 35; val3.playSyncedClip = 0; val3.creatureName = extendedUnlockableItem.UnlockableItem.unlockableName; val3.displayText = ((!string.IsNullOrEmpty(extendedUnlockableItem.OverrideBuyConfirmNodeDescription)) ? extendedUnlockableItem.OverrideBuyConfirmNodeDescription : ("Ordered the " + val3.creatureName + "! Your new balance is [playerCredits]")); } val3.shipUnlockableID = extendedUnlockableItem.UnlockableItemID; TerminalNode val4 = null; if (!string.IsNullOrEmpty(extendedUnlockableItem.OverrideInfoNodeDescription)) { if ((Object)(object)extendedUnlockableItem.BuyInfoNode != (Object)null) { val4 = extendedUnlockableItem.BuyInfoNode; } else { val4 = CreateNewTerminalNode(); ((Object)val4).name = text + "Info"; val4.clearPreviousText = true; val4.maxCharactersToType = 25; val4.displayText = "\n" + extendedUnlockableItem.OverrideInfoNodeDescription; val4.creatureName = extendedUnlockableItem.UnlockableItem.unlockableName; } } val2.AddCompatibleNoun(routeConfirmKeyword, val3); val2.AddCompatibleNoun(routeDenyKeyword, cancelPurchaseNode); buyKeyword.AddCompatibleNoun(val, val2); if ((Object)(object)val4 != (Object)null) { routeInfoKeyword.AddCompatibleNoun(val, val4); } extendedUnlockableItem.BuyNode = val2; extendedUnlockableItem.BuyConfirmNode = val3; extendedUnlockableItem.BuyInfoNode = val4; extendedUnlockableItem.UnlockableItem.shopSelectionNode = extendedUnlockableItem.BuyNode; } internal static void CreateMoonsFilterTerminalAssets() { int num = Terminal.terminalNodes.allKeywords.Length; foreach (TerminalNode item in CreateTerminalEventNodes("Preview", new List(6) { PreviewInfoType.Price, PreviewInfoType.Difficulty, PreviewInfoType.Weather, PreviewInfoType.History, PreviewInfoType.All, PreviewInfoType.None })) { AddTerminalNodeEventListener(item, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } previewKeyword = Terminal.terminalNodes.allKeywords[num]; int num2 = Terminal.terminalNodes.allKeywords.Length; foreach (TerminalNode item2 in CreateTerminalEventNodes("Sort", new List(3) { SortInfoType.Price, SortInfoType.Difficulty, SortInfoType.None })) { AddTerminalNodeEventListener(item2, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } sortKeyword = Terminal.terminalNodes.allKeywords[num2]; int num3 = Terminal.terminalNodes.allKeywords.Length; foreach (TerminalNode item3 in CreateTerminalEventNodes("Filter", new List(3) { FilterInfoType.Price, FilterInfoType.Weather, FilterInfoType.None })) { AddTerminalNodeEventListener(item3, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } filterKeyword = Terminal.terminalNodes.allKeywords[num3]; List list = new List(); List list2 = new List(); HashSet hashSet = new HashSet(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { hashSet.UnionWith(extendedLevel.ContentTags); } foreach (ContentTag item4 in hashSet) { list.Add($"{item4}"); list2.Add($"Tag;{item4}"); } foreach (TerminalNode item5 in CreateTerminalEventNodes("Filter", list, list2, createNewVerbKeyword: false)) { AddTerminalNodeEventListener(item5, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } List list3 = new List(); foreach (ExtendedLevel extendedLevel2 in PatchedContent.ExtendedLevels) { list3.Add(extendedLevel2.NumberlessPlanetName.Sanitized(toLower: false).RemoveWhitespace()); } int num4 = 0; foreach (TerminalNode item6 in CreateTerminalEventNodes("Simulate", list3)) { AddTerminalNodeEventListener(item6, SetSimulationResultsText, LoadNodeActionType.Before); PatchedContent.ExtendedLevels[num4].SimulateNode = item6; num4++; } simulateKeyword = Terminal.terminalNodes.allKeywords[^(++num4)]; } internal static List CreateTerminalEventNodes(string newVerbKeywordWord, List terminalEventEnumStrings) { List list = new List(); foreach (Enum terminalEventEnumString in terminalEventEnumStrings) { list.Add(terminalEventEnumString.ToString()); } return CreateTerminalEventNodes(newVerbKeywordWord, list); } internal static List CreateTerminalEventNodes(string newVerbKeywordWord, List nounWords, List terminalEventStrings = null, bool createNewVerbKeyword = true) { string sanitizedName = newVerbKeywordWord.Sanitized(toLower: false).RemoveWhitespace(); List list = new List(); TerminalKeyword val = (TerminalKeyword)(createNewVerbKeyword ? ((object)CreateNewTerminalKeyword()) : ((object)Array.Find(Terminal.terminalNodes.allKeywords, (TerminalKeyword keyword) => string.Equals(keyword.word.Sanitized(toLower: false).RemoveWhitespace(), sanitizedName, StringComparison.OrdinalIgnoreCase)))); if ((Object)(object)val == (Object)null) { return list; } val.word = sanitizedName.ToLowerInvariant(); ((Object)val).name = sanitizedName + "Keyword"; val.isVerb = true; if (terminalEventStrings == null) { terminalEventStrings = nounWords; } if (nounWords.Count != terminalEventStrings.Count) { DebugHelper.LogError("Number of event strings does not match number of noun words for TerminalKeyword " + newVerbKeywordWord + "! Some events may not be registered...", DebugType.Developer); } for (int num = 0; num < nounWords.Count && num <= terminalEventStrings.Count; num++) { list.Add(CreateTerminalEventNode(val, nounWords[num], terminalEventStrings[num])); } return list; } internal static TerminalNode CreateTerminalEventNode(TerminalKeyword verbKeyword, string nounWord, string terminalEventString) { TerminalKeyword val = CreateNewTerminalKeyword(); TerminalNode val2 = CreateNewTerminalNode(); ((Object)val).name = verbKeyword.word + GetTerminalEventEnum(nounWord) + "Keyword"; val.word = GetTerminalEventEnum(nounWord).ToLowerInvariant(); val.defaultVerb = verbKeyword; val2.terminalEvent = terminalEventString; ((Object)val2).name = verbKeyword.word + GetTerminalEventEnum(nounWord) + "Node"; verbKeyword.AddCompatibleNoun(val, val2); return val2; } internal static TerminalKeyword CreateNewTerminalKeyword() { TerminalKeyword val = ScriptableObject.CreateInstance(); ((Object)val).name = "NewLethalLevelLoaderTerminalKeyword"; val.compatibleNouns = Array.Empty(); val.defaultVerb = null; TerminalNodesList terminalNodes = Terminal.terminalNodes; TerminalKeyword[] allKeywords = Terminal.terminalNodes.allKeywords; int num = 0; TerminalKeyword[] array = (TerminalKeyword[])(object)new TerminalKeyword[1 + allKeywords.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(allKeywords); readOnlySpan.CopyTo(new Span(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; array[num] = val; terminalNodes.allKeywords = array; return val; } internal static TerminalNode CreateNewTerminalNode() { TerminalNode val = ScriptableObject.CreateInstance(); ((Object)val).name = "NewLethalLevelLoaderTerminalNode"; val.displayText = string.Empty; val.terminalEvent = string.Empty; val.maxCharactersToType = 25; val.buyItemIndex = -1; val.buyRerouteToMoon = -1; val.displayPlanetInfo = -1; val.shipUnlockableID = -1; val.creatureFileID = -1; val.storyLogFileID = -1; val.playSyncedClip = -1; val.terminalOptions = Array.Empty(); return val; } } public static class TerrainManager { public static Terrain CurrentTerrain { get; internal set; } public static float[,,] CurrentTerrainAlphaMaps { get { if (!((Object)(object)CurrentTerrain != (Object)null)) { return null; } return TerrainAlphaMaps[CurrentTerrain]; } } public static Dictionary TerrainAlphaMaps { get; } = new Dictionary(); public static Dictionary TerrainFootstepsDict { get; } = new Dictionary(); internal static void BakeTerrainFootsteps() { Terrain[] activeTerrains = Terrain.activeTerrains; foreach (Terrain val in activeTerrains) { TerrainData terrainData = val.terrainData; float[,,] alphamaps = terrainData.GetAlphamaps(0, 0, terrainData.alphamapWidth, terrainData.alphamapHeight); TerrainAlphaMaps[val] = alphamaps; int num = alphamaps.Length / (terrainData.alphamapWidth * terrainData.alphamapHeight); if (!TerrainFootstepsDict.TryAdd(terrainData, new ExtendedFootstepSurface[num])) { continue; } List list = PatchedContent.ExtendedFootstepSurfaces.FindAll((ExtendedFootstepSurface surface) => surface.IsTerrainMatch(terrainData)); int i2; for (i2 = 0; i2 < num; i2++) { TerrainFootstepsDict[terrainData][i2] = list.Find((ExtendedFootstepSurface surface) => surface.IsTerrainMatch(terrainData, i2)); } } } internal static void SwapTerrainAlphaMap(Terrain terrain) { if (!((Object)(object)CurrentTerrain == (Object)(object)terrain)) { CurrentTerrain = terrain; if (!TerrainAlphaMaps.TryGetValue(terrain, out var value)) { TerrainData terrainData = terrain.terrainData; value = terrainData.GetAlphamaps(0, 0, terrainData.alphamapWidth, terrainData.alphamapHeight); TerrainAlphaMaps[terrain] = value; } Patches.StartOfRound.currentTerrainAlphaMaps = value; Patches.StartOfRound.gotCurrentTerrainAlphamaps = value != null; } } public static bool TryObtainTerrainLayerAtPoint(Vector3 point, Terrain terrain, out int terrainLayer) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0046: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) TerrainData terrainData = terrain.terrainData; Vector3 position = ((Component)terrain).transform.position; terrainLayer = -1; Vector3 zero = Vector3.zero; zero.x = (point.x - position.x) / terrainData.size.x * (float)terrainData.alphamapWidth; zero.z = (point.z - position.z) / terrainData.size.z * (float)terrainData.alphamapHeight; if (!TerrainAlphaMaps.TryGetValue(terrain, out var value)) { return false; } float num = 0f; int num2 = value.Length / (terrainData.alphamapWidth * terrainData.alphamapHeight); for (int i = 0; i < num2; i++) { float num3 = value[(int)zero.z, (int)zero.x, i]; if (num3 == 1f) { terrainLayer = i; return true; } if (num < num3) { num = num3; terrainLayer = i; } } return terrainLayer >= 0; } public static bool TryObtainFootstepSurfaceAtPoint(Vector3 point, Terrain terrain, out ExtendedFootstepSurface footstepSurface) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) footstepSurface = ((TerrainFootstepsDict.TryGetValue(terrain.terrainData, out var value) && TryObtainTerrainLayerAtPoint(point, terrain, out var terrainLayer) && terrainLayer < value.Length) ? value[terrainLayer] : null); return (Object)(object)footstepSurface != (Object)null; } public static bool CanWormEmergeFromPoint(Vector3 point, Terrain terrain) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (TryObtainFootstepSurfaceAtPoint(point, terrain, out var footstepSurface)) { return footstepSurface.AllowEarthLeviathanEmerge; } return false; } internal static void CleanupTerrainFootsteps(Scene _) { SceneManager.sceneUnloaded -= CleanupTerrainFootsteps; CurrentTerrain = null; TerrainAlphaMaps.Clear(); TerrainFootstepsDict.Clear(); if ((Object)(object)Patches.StartOfRound != (Object)null) { Patches.StartOfRound.currentTerrainAlphaMaps = null; Patches.StartOfRound.gotCurrentTerrainAlphamaps = false; } } } public static class UnlockableItemManager { internal static void PatchVanillaUnlockableItemLists() { Patches.StartOfRound.unlockablesList.unlockables = PatchedContent.ExtendedUnlockableItems.ConvertAll((ExtendedUnlockableItem u) => u.UnlockableItem).ToList(); } internal static void SetUnlockableItemIDs() { int num = 0; foreach (ExtendedUnlockableItem vanillaExtendedUnlockableItem in PatchedContent.VanillaExtendedUnlockableItems) { vanillaExtendedUnlockableItem.UnlockableItemID = num++; } foreach (ExtendedUnlockableItem customExtendedUnlockableItem in PatchedContent.CustomExtendedUnlockableItems) { customExtendedUnlockableItem.UnlockableItemID = num++; } foreach (ExtendedUnlockableItem extendedUnlockableItem in PatchedContent.ExtendedUnlockableItems) { if (extendedUnlockableItem.UnlockableItem.unlockableType == 1 && !((Object)(object)extendedUnlockableItem.UnlockableItem.prefabObject == (Object)null) && !extendedUnlockableItem.UnlockableItem.alreadyUnlocked) { AutoParentToShip component = extendedUnlockableItem.UnlockableItem.prefabObject.GetComponent(); component.unlockableID = extendedUnlockableItem.UnlockableItemID; PlaceableShipObject componentInChildren = extendedUnlockableItem.UnlockableItem.prefabObject.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.parentObject = component; componentInChildren.unlockableID = extendedUnlockableItem.UnlockableItemID; } } } } } public static class VehiclesManager { internal static void PatchVanillaVehiclesLists() { List list = new List(PatchedContent.ExtendedBuyableVehicles.Count); List list2 = new List(PatchedContent.ExtendedBuyableVehicles.Count); foreach (ExtendedBuyableVehicle extendedBuyableVehicle in PatchedContent.ExtendedBuyableVehicles) { if ((Object)(object)extendedBuyableVehicle != (Object)null && extendedBuyableVehicle.BuyableVehicle != null && (Object)(object)extendedBuyableVehicle.BuyableVehicle.vehiclePrefab != (Object)null) { list.Add(extendedBuyableVehicle.BuyableVehicle); list2.Add(extendedBuyableVehicle.BuyableVehicle.vehiclePrefab); } } Patches.Terminal.buyableVehicles = list.ToArray(); Patches.StartOfRound.VehiclesList = list2.ToArray(); } internal static void SetBuyableVehicleIDs() { foreach (ExtendedBuyableVehicle extendedBuyableVehicle in PatchedContent.ExtendedBuyableVehicles) { extendedBuyableVehicle.VehicleID = -1; } int num = 0; foreach (ExtendedBuyableVehicle vanillaExtendedBuyableVehicle in PatchedContent.VanillaExtendedBuyableVehicles) { vanillaExtendedBuyableVehicle.VehicleID = num; num++; } foreach (ExtendedBuyableVehicle customExtendedBuyableVehicle in PatchedContent.CustomExtendedBuyableVehicles) { customExtendedBuyableVehicle.VehicleID = num; num++; } VehicleController val = default(VehicleController); foreach (ExtendedBuyableVehicle extendedBuyableVehicle2 in PatchedContent.ExtendedBuyableVehicles) { if (extendedBuyableVehicle2.BuyableVehicle.vehiclePrefab.TryGetComponent(ref val)) { val.vehicleID = extendedBuyableVehicle2.VehicleID; } } } } internal static class WeatherManager { public static ExtendedWeatherEffect CurrentExtendedWeatherEffect; public static Dictionary vanillaExtendedWeatherEffectsDictionary = new Dictionary(); public static void RefreshVanillaWeatherEffects(TimeOfDay timeOfDay) { //IL_0016: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected I4, but got Unknown foreach (ExtendedWeatherEffect vanillaExtendedWeatherEffect in PatchedContent.VanillaExtendedWeatherEffects) { LevelWeatherType baseWeatherType = vanillaExtendedWeatherEffect.BaseWeatherType; vanillaExtendedWeatherEffectsDictionary[baseWeatherType] = vanillaExtendedWeatherEffect; int num = (int)baseWeatherType; if (num >= 0 && num < timeOfDay.effects.Length) { WeatherEffect val = timeOfDay.effects[num]; if (val != null) { RefreshEffectWorldObject(vanillaExtendedWeatherEffect, val.effectObject); RefreshEffectGlobalObject(vanillaExtendedWeatherEffect, val.effectPermanentObject); } } } } private static void RefreshEffectWorldObject(ExtendedWeatherEffect extendedEffect, GameObject worldObject) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown //IL_004d: 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_0067: 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) if ((Object)(object)worldObject == (Object)null) { return; } LevelWeatherType baseWeatherType = extendedEffect.BaseWeatherType; switch (baseWeatherType - -1) { case 1: { LocalVolumetricFog val = default(LocalVolumetricFog); if (worldObject.TryGetComponent(ref val)) { LevelLoader.dustCloudFog = val; if (LevelLoader.defaultDustCloudFogVolumeSize == Vector3.zero) { LevelLoader.defaultDustCloudFogVolumeSize = val.parameters.size; } } break; } case 2: { if ((Object)(object)LevelLoader.defaultQuicksandPrefab == (Object)null) { LevelLoader.defaultQuicksandPrefab = Patches.RoundManager.quicksandPrefab; } LevelLoader.rainyAmbienceSource = worldObject.GetComponentInChildren(true); if ((Object)(object)LevelLoader.defaultRainyAmbience == (Object)null && (Object)(object)LevelLoader.rainyAmbienceSource != (Object)null) { LevelLoader.defaultRainyAmbience = LevelLoader.rainyAmbienceSource.clip; } ParticleSystem[] componentsInChildren = worldObject.GetComponentsInChildren(true); foreach (ParticleSystem val2 in componentsInChildren) { if ((Object)(object)((Component)val2).transform.parent == (Object)(object)worldObject.transform) { LevelLoader.rainParticles = val2; break; } } break; } case 3: { LevelLoader.stormyRainAmbienceSource = worldObject.GetComponentInChildren(true); if ((Object)(object)LevelLoader.defaultStormyRainAmbience == (Object)null && (Object)(object)LevelLoader.stormyRainAmbienceSource != (Object)null) { LevelLoader.defaultStormyRainAmbience = LevelLoader.stormyRainAmbienceSource.clip; } ParticleSystem[] componentsInChildren2 = worldObject.GetComponentsInChildren(true); foreach (ParticleSystem val3 in componentsInChildren2) { if ((Object)(object)((Component)val3).transform.parent == (Object)(object)worldObject.transform) { LevelLoader.stormyRainParticles = val3; break; } } break; } case 6: LevelLoader.eclipsedMusicSource = worldObject.GetComponentInChildren(true); if ((Object)(object)LevelLoader.defaultEclipsedMusic == (Object)null && (Object)(object)LevelLoader.eclipsedMusicSource != (Object)null) { LevelLoader.defaultEclipsedMusic = LevelLoader.eclipsedMusicSource.clip; } break; } extendedEffect.WorldObject = worldObject; } private static void RefreshEffectGlobalObject(ExtendedWeatherEffect extendedEffect, GameObject globalObject) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)globalObject == (Object)null) { return; } LevelWeatherType baseWeatherType = extendedEffect.BaseWeatherType; switch (baseWeatherType - -1) { case 3: { StormyWeather val5 = default(StormyWeather); if (!globalObject.TryGetComponent(ref val5)) { break; } LevelLoader.stormyWeather = val5; if ((Object)(object)val5.explosionEffectParticle != (Object)null) { LevelLoader.defaultStormyLightningStrikeExplosion = val5.explosionEffectParticle; } if ((Object)(object)val5.staticElectricityParticle != (Object)null) { LevelLoader.defaultStormyStaticElectricityParticle = val5.staticElectricityParticle; } if (LevelLoader.defaultStormyLightningStrikeSFX == null) { AudioClip[] strikeSFX = val5.strikeSFX; if (strikeSFX != null && strikeSFX.Length != 0) { LevelLoader.defaultStormyLightningStrikeSFX = val5.strikeSFX.ToArray(); } } if (LevelLoader.defaultStormyDistantThunderSFX == null) { AudioClip[] distantThunderSFX = val5.distantThunderSFX; if (distantThunderSFX != null && distantThunderSFX.Length != 0) { LevelLoader.defaultStormyDistantThunderSFX = val5.distantThunderSFX.ToArray(); } } if ((Object)(object)LevelLoader.defaultStormyStaticElectricitySFX == (Object)null && (Object)(object)val5.staticElectricityAudio != (Object)null) { LevelLoader.defaultStormyStaticElectricitySFX = val5.staticElectricityAudio; } break; } case 4: { LocalVolumetricFog val4 = default(LocalVolumetricFog); if (globalObject.TryGetComponent(ref val4)) { LevelLoader.foggyFog = val4; if (LevelLoader.defaultFoggyFogVolumeSize == Vector3.zero) { LevelLoader.defaultFoggyFogVolumeSize = val4.parameters.size; } } break; } case 5: { FloodWeather val = default(FloodWeather); if (!globalObject.TryGetComponent(ref val)) { break; } LevelLoader.floodedWeather = val; LevelLoader.floodedAmbienceSource = val.waterAudio; if ((Object)(object)LevelLoader.defaultFloodedAmbience == (Object)null && (Object)(object)LevelLoader.floodedAmbienceSource != (Object)null) { LevelLoader.defaultFloodedAmbience = LevelLoader.floodedAmbienceSource.clip; } LevelLoader.floodedWaterTrigger = ((Component)val).GetComponentInChildren(true); MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (MeshRenderer val2 in componentsInChildren) { if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)LevelLoader.floodedWaterTrigger).gameObject) { continue; } LevelLoader.floodedWaterRenderer = val2; if ((Object)(object)LevelLoader.defaultFloodedWaterMaterial != (Object)null) { break; } Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.shader != (Object)null && string.Equals(((Object)val3.shader).name, "Shader Graphs/WaterShaderHDRP", StringComparison.Ordinal)) { LevelLoader.defaultFloodedWaterMaterial = val3; LevelLoader.vanillaWaterShader = val3.shader; LevelLoader.vanillaWaterShaderKeywords = val3.enabledKeywords; break; } } break; } break; } } extendedEffect.GlobalObject = globalObject; } public static void PopulateExtendedLevelEnabledExtendedWeatherEffects() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (extendedLevel.SelectableLevel.randomWeathers != null) { RandomWeatherWithVariables[] randomWeathers = extendedLevel.SelectableLevel.randomWeathers; foreach (RandomWeatherWithVariables val in randomWeathers) { if (vanillaExtendedWeatherEffectsDictionary.TryGetValue(val.weatherType, out var value)) { extendedLevel.EnabledExtendedWeatherEffects.Add(value); } } } foreach (ExtendedWeatherEffect customExtendedWeatherEffect in PatchedContent.CustomExtendedWeatherEffects) { extendedLevel.EnabledExtendedWeatherEffects.Add(customExtendedWeatherEffect); } if (extendedLevel.ContentType == ContentType.Vanilla) { extendedLevel.OverrideDustStormVolumeSize = LevelLoader.defaultDustCloudFogVolumeSize; extendedLevel.OverrideQuicksandPrefab = LevelLoader.defaultQuicksandPrefab; extendedLevel.OverrideRainAmbience = LevelLoader.defaultRainyAmbience; extendedLevel.OverrideStormyLightningStrikeSFX = LevelLoader.defaultStormyLightningStrikeSFX.ToArray(); extendedLevel.OverrideStormyDistantThunderSFX = LevelLoader.defaultStormyDistantThunderSFX.ToArray(); extendedLevel.OverrideStormyStaticElectricitySFX = LevelLoader.defaultStormyStaticElectricitySFX; extendedLevel.OverrideStormyRainAmbience = LevelLoader.defaultStormyRainAmbience; extendedLevel.OverrideFoggyVolumeSize = LevelLoader.defaultFoggyFogVolumeSize; extendedLevel.OverrideFloodedAmbience = LevelLoader.defaultFloodedAmbience; extendedLevel.OverrideEclipsedMusic = LevelLoader.defaultEclipsedMusic; continue; } if (extendedLevel.OverrideDustStormVolumeSize == Vector3.zero) { extendedLevel.OverrideDustStormVolumeSize = LevelLoader.defaultDustCloudFogVolumeSize; } if ((Object)(object)extendedLevel.OverrideQuicksandPrefab == (Object)null) { extendedLevel.OverrideQuicksandPrefab = LevelLoader.defaultQuicksandPrefab; } if ((Object)(object)extendedLevel.OverrideRainAmbience == (Object)null) { extendedLevel.OverrideRainAmbience = LevelLoader.defaultRainyAmbience; } if (extendedLevel.OverrideStormyLightningStrikeSFX == null || extendedLevel.OverrideStormyLightningStrikeSFX.Length == 0) { extendedLevel.OverrideStormyLightningStrikeSFX = LevelLoader.defaultStormyLightningStrikeSFX.ToArray(); } if (extendedLevel.OverrideStormyDistantThunderSFX == null || extendedLevel.OverrideStormyDistantThunderSFX.Length == 0) { extendedLevel.OverrideStormyDistantThunderSFX = LevelLoader.defaultStormyDistantThunderSFX.ToArray(); } if ((Object)(object)extendedLevel.OverrideStormyStaticElectricitySFX == (Object)null) { extendedLevel.OverrideStormyStaticElectricitySFX = LevelLoader.defaultStormyStaticElectricitySFX; } if ((Object)(object)extendedLevel.OverrideStormyRainAmbience == (Object)null) { extendedLevel.OverrideStormyRainAmbience = LevelLoader.defaultStormyRainAmbience; } if (extendedLevel.OverrideFoggyVolumeSize == Vector3.zero) { extendedLevel.OverrideFoggyVolumeSize = LevelLoader.defaultFoggyFogVolumeSize; } if ((Object)(object)extendedLevel.OverrideFloodedAmbience == (Object)null) { extendedLevel.OverrideFloodedAmbience = LevelLoader.defaultFloodedAmbience; } if ((Object)(object)extendedLevel.OverrideEclipsedMusic == (Object)null) { extendedLevel.OverrideEclipsedMusic = LevelLoader.defaultEclipsedMusic; } if (!((Object)(object)extendedLevel.OverrideFloodedPrefab != (Object)null) || !((Object)(object)LevelLoader.vanillaWaterShader != (Object)null)) { continue; } MeshRenderer[] componentsInChildren = extendedLevel.OverrideFloodedPrefab.GetComponentsInChildren(true); foreach (MeshRenderer val2 in componentsInChildren) { Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { if (((Object)sharedMaterials[k]).name == ((Object)LevelLoader.defaultFloodedWaterMaterial).name) { sharedMaterials[k] = LevelLoader.defaultFloodedWaterMaterial; } } ((Renderer)val2).sharedMaterials = sharedMaterials; } } } public static void SetExtendedLevelsWeather(int connectedPlayersOnServer) { //IL_0057: 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_0042: 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) StartOfRound startOfRound = Patches.StartOfRound; List list = PatchedContent.ExtendedLevels.ToList(); foreach (ExtendedLevel item in list) { if (!item.SelectableLevel.overrideWeather) { item.CurrentExtendedWeatherEffect = null; item.SelectableLevel.currentWeather = (LevelWeatherType)(-1); } else { item.SelectableLevel.currentWeather = item.SelectableLevel.overrideWeatherType; } } Random random = new Random(startOfRound.randomMapSeed + 31); float num = 1f; if (connectedPlayersOnServer + 1 > 1 && startOfRound.daysPlayersSurvivedInARow > 2 && startOfRound.daysPlayersSurvivedInARow % 3 == 0) { num = (float)random.Next(15, 25) / 10f; } int num2 = Mathf.Clamp((int)(Mathf.Clamp(startOfRound.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * num, 0f, 1f) * (float)PatchedContent.ExtendedLevels.Count), 0, PatchedContent.ExtendedLevels.Count); for (int i = 0; i < num2; i++) { ExtendedLevel extendedLevel = list[random.Next(0, list.Count)]; if (extendedLevel.SelectableLevel.randomWeathers != null && extendedLevel.SelectableLevel.randomWeathers.Length != 0) { extendedLevel.SelectableLevel.currentWeather = extendedLevel.SelectableLevel.randomWeathers[random.Next(0, extendedLevel.SelectableLevel.randomWeathers.Length)].weatherType; } list.Remove(extendedLevel); } } public static void SetExtendedLevelsExtendedWeatherEffect(int connectedPlayersOnServer) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) StartOfRound startOfRound = Patches.StartOfRound; List list = PatchedContent.ExtendedLevels.ToList(); foreach (ExtendedLevel item in list) { item.CurrentExtendedWeatherEffect = null; if (item.SelectableLevel.overrideWeather && vanillaExtendedWeatherEffectsDictionary.TryGetValue(item.SelectableLevel.overrideWeatherType, out var value)) { item.CurrentExtendedWeatherEffect = value; } } Random random = new Random(startOfRound.randomMapSeed + 31); float num = 1f; if (connectedPlayersOnServer + 1 > 1 && startOfRound.daysPlayersSurvivedInARow > 2 && startOfRound.daysPlayersSurvivedInARow % 3 == 0) { num = (float)random.Next(15, 25) / 10f; } int num2 = Mathf.Clamp((int)(Mathf.Clamp(startOfRound.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * num, 0f, 1f) * (float)PatchedContent.ExtendedLevels.Count), 0, PatchedContent.ExtendedLevels.Count); for (int i = 0; i < num2; i++) { ExtendedLevel extendedLevel = list[random.Next(0, list.Count)]; extendedLevel.CurrentExtendedWeatherEffect = extendedLevel.EnabledExtendedWeatherEffects[random.Next(0, extendedLevel.EnabledExtendedWeatherEffects.Count)]; list.Remove(extendedLevel); } foreach (ExtendedLevel extendedLevel2 in PatchedContent.ExtendedLevels) { if ((Object)(object)extendedLevel2.CurrentExtendedWeatherEffect == (Object)null) { extendedLevel2.SelectableLevel.currentWeather = (LevelWeatherType)(-1); } else if (extendedLevel2.CurrentExtendedWeatherEffect.contentType == ContentType.Vanilla) { extendedLevel2.SelectableLevel.currentWeather = extendedLevel2.CurrentExtendedWeatherEffect.BaseWeatherType; } } } public static ExtendedWeatherEffect GetVanillaExtendedWeatherEffect(LevelWeatherType levelWeatherType) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) foreach (ExtendedWeatherEffect extendedWeatherEffect in PatchedContent.ExtendedWeatherEffects) { if (extendedWeatherEffect.contentType == ContentType.Vanilla && extendedWeatherEffect.BaseWeatherType == levelWeatherType) { return extendedWeatherEffect; } } return null; } } [BepInPlugin("imabatby.lethallevelloader", "LethalLevelLoader", "1.7.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGUID = "imabatby.lethallevelloader"; public const string ModName = "LethalLevelLoader"; public const string ModVersion = "1.7.7"; internal static Plugin Instance; internal static readonly Harmony Harmony = new Harmony("imabatby.lethallevelloader"); internal static ManualLogSource logger; public static bool IsSetupComplete { get; private set; } public static bool IsLobbyInitialized { get; internal set; } public static event Action onBeforeSetup; public static event Action onSetupComplete; public static event Action onLobbyInitialized; private void Awake() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalLevelLoader loaded!!"); Harmony.PatchAll(typeof(Patches)); Harmony.PatchAll(typeof(EventPatches)); Harmony.PatchAll(typeof(SafetyPatches)); LethalLevelLoaderPatcher.onChainloaderFinish += HandleAdditionalCompatibilities; NetworkScenePatcher.Patch(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); GameObject val = new GameObject("LethalLevelLoader AssetBundleLoader"); AssetBundleLoader assetBundleLoader = val.AddComponent(); if (Application.isEditor) { Object.DontDestroyOnLoad((Object)(object)val); } else { ((Object)val).hideFlags = (HideFlags)61; } GameObject val2 = new GameObject("LethalCore-AssetBundleLoader"); LethalLevelLoader.AssetBundles.AssetBundleLoader assetBundleLoader2 = val2.AddComponent(); if (Application.isEditor) { Object.DontDestroyOnLoad((Object)(object)val2); } else { ((Object)val2).hideFlags = (HideFlags)61; } ConfigLoader.BindGeneralConfigs(); LethalBundleManager.Start(); } internal static void OnBeforeSetupInvoke() { IsLobbyInitialized = false; Plugin.onBeforeSetup?.Invoke(); } internal static void CompleteSetup() { DebugHelper.Log("LethalLevelLoader Has Finished Initializing.", DebugType.User); IsSetupComplete = true; Plugin.onSetupComplete?.Invoke(); } internal static void LobbyInitialized() { IsLobbyInitialized = true; Plugin.onLobbyInitialized?.Invoke(); } private static void HandleAdditionalCompatibilities() { Harmony.PatchAll(typeof(TimeOfDayPatches)); if (LethalLibCompatibility.Enabled) { Harmony.PatchAll(typeof(LethalLibCompatibility)); } if (LethalPerformanceCompatibility.Enabled) { Harmony.PatchAll(typeof(LethalPerformanceCompatibility)); } if (DeepSewersCompatibility.Enabled) { DeepSewersCompatibility.FixDeepSewersGeneration(); } DebugHelper.Log("Additional LethalLevelLoader Compatibilities Done.", DebugType.User); } } public struct AssetBundleInfo { private readonly List scenePathsInBundle; private readonly List sceneNamesInBundle; private readonly AssetBundle assetBundle; public string DirectoryPath { get; private set; } public readonly bool IsLoaded => (Object)(object)assetBundle != (Object)null; public readonly bool IsSceneBundle => sceneNamesInBundle.Count > 0; public AssetBundleInfo(string directory, AssetBundle newBundle) { scenePathsInBundle = new List(); sceneNamesInBundle = new List(); DirectoryPath = directory; assetBundle = newBundle; if ((Object)(object)assetBundle != (Object)null && assetBundle.isStreamedSceneAssetBundle) { string[] allScenePaths = assetBundle.GetAllScenePaths(); foreach (string item in allScenePaths) { scenePathsInBundle.Add(item); } } foreach (string item2 in scenePathsInBundle) { List list = sceneNamesInBundle; string text = item2; int num = item2.LastIndexOf('/') + 1; list.Add(text.Substring(num, text.Length - num).Replace(".unity", string.Empty)); } foreach (string item3 in sceneNamesInBundle) { DebugHelper.Log("AssetBundleInfo Has Scene: " + item3, DebugType.User); } } public readonly AssetBundle LoadAndOrGetBundle() { if (IsLoaded) { return assetBundle; } return null; } public readonly bool ContainsScene(string scenePath) { return sceneNamesInBundle.Contains(scenePath); } } public class AssetBundleLoader : MonoBehaviour { public enum LoadingStatus { Inactive, Loading, Complete } public delegate void BundlesFinishedLoading(); public delegate void BundleFinishedLoading(AssetBundle assetBundle); internal static Dictionary assetBundles = new Dictionary(); internal static Dictionary assetBundleLoadTimes = new Dictionary(); internal static TextMeshProUGUI loadingBundlesHeaderText; internal static List AssetBundleInfos { get; private set; } = new List(); public static LoadingStatus CurrentLoadingStatus { get; internal set; } = LoadingStatus.Inactive; internal static bool HaveBundlesFinishedLoading { get { bool result = true; foreach (KeyValuePair assetBundle in assetBundles) { if ((Object)(object)assetBundle.Value == (Object)null) { result = false; } } return result; } } internal static int BundlesFinishedLoadingCount { get { int num = 0; foreach (KeyValuePair assetBundle in assetBundles) { if ((Object)(object)assetBundle.Value != (Object)null) { num++; } } return num; } } public static event BundlesFinishedLoading onBundlesFinishedLoading; public static event BundleFinishedLoading onBundleFinishedLoading; internal static void NetworkRegisterCustomContent(NetworkManager networkManager) { DebugHelper.Log("Registering Bundle Content!", DebugType.User); foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { extendedMod.ExtendedDungeonFlows.RemoveAll((ExtendedDungeonFlow extendedDungeonFlow) => !NetworkRegisterDungeonContent(extendedDungeonFlow, networkManager)); foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems) { LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(extendedItem.Item.spawnPrefab); } foreach (ExtendedEnemyType extendedEnemyType in extendedMod.ExtendedEnemyTypes) { LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(extendedEnemyType.EnemyType.enemyPrefab); } foreach (ExtendedBuyableVehicle extendedBuyableVehicle in extendedMod.ExtendedBuyableVehicles) { LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(extendedBuyableVehicle.BuyableVehicle.vehiclePrefab); LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(extendedBuyableVehicle.BuyableVehicle.secondaryPrefab); } foreach (ExtendedUnlockableItem extendedUnlockableItem in extendedMod.ExtendedUnlockableItems) { if (extendedUnlockableItem.UnlockableItem.unlockableType == 1 && (Object)(object)extendedUnlockableItem.UnlockableItem.prefabObject != (Object)null) { LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(extendedUnlockableItem.UnlockableItem.prefabObject); } } } } internal static void InvokeBundlesFinishedLoading() { AssetBundleLoader.onBundlesFinishedLoading?.Invoke(); } public static bool TryGetAssetBundleInfo(string scenePath, out AssetBundleInfo info) { info = default(AssetBundleInfo); foreach (AssetBundleInfo assetBundleInfo in AssetBundleInfos) { if (assetBundleInfo.IsSceneBundle && assetBundleInfo.ContainsScene(scenePath)) { info = assetBundleInfo; return true; } } return false; } public static void AddOnLethalBundleLoadedListener(Action invokedFunction, string lethalBundleFileName) { if (invokedFunction != null && !string.IsNullOrEmpty(lethalBundleFileName)) { if (!LethalLevelLoader.AssetBundles.AssetBundleLoader.onLethalBundleLoadedRequestDict.TryGetValue(lethalBundleFileName, out var value)) { LethalLevelLoader.AssetBundles.AssetBundleLoader.onLethalBundleLoadedRequestDict.Add(lethalBundleFileName, new List>(1) { invokedFunction }); } else { value.Add(invokedFunction); } } } public static void AddOnExtendedModLoadedListener(Action invokedFunction, string extendedModAuthorName = null, string extendedModModName = null) { if (invokedFunction != null && !string.IsNullOrEmpty(extendedModAuthorName)) { if (!LethalBundleManager.onExtendedModLoadedRequestDict.TryGetValue(extendedModAuthorName, out var value)) { LethalBundleManager.onExtendedModLoadedRequestDict.Add(extendedModAuthorName, new List>(1) { invokedFunction }); } else { value.Add(invokedFunction); } } if (invokedFunction != null && !string.IsNullOrEmpty(extendedModModName)) { if (!LethalBundleManager.onExtendedModLoadedRequestDict.TryGetValue(extendedModModName, out var value2)) { LethalBundleManager.onExtendedModLoadedRequestDict.Add(extendedModModName, new List>(1) { invokedFunction }); } else { value2.Add(invokedFunction); } } } internal static void RegisterNewExtendedContent(ExtendedContent extendedContent, string fallbackName) { LethalBundleManager.RegisterNewExtendedContent(extendedContent, null); } internal static void InitializeBundles() { foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { foreach (ExtendedLevel extendedLevel in extendedMod.ExtendedLevels) { extendedLevel.ContentType = ContentType.Custom; extendedLevel.Initialize(((Object)extendedLevel).name, generateTerminalAssets: true); PatchedContent.ExtendedLevels.Add(extendedLevel); } foreach (ExtendedDungeonFlow extendedDungeonFlow in extendedMod.ExtendedDungeonFlows) { extendedDungeonFlow.ContentType = ContentType.Custom; extendedDungeonFlow.Initialize(); PatchedContent.ExtendedDungeonFlows.Add(extendedDungeonFlow); } foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems) { extendedItem.ContentType = ContentType.Custom; extendedItem.Initialize(); PatchedContent.ExtendedItems.Add(extendedItem); } foreach (ExtendedEnemyType extendedEnemyType in extendedMod.ExtendedEnemyTypes) { extendedEnemyType.ContentType = ContentType.Custom; extendedEnemyType.Initalize(); PatchedContent.ExtendedEnemyTypes.Add(extendedEnemyType); } foreach (ExtendedWeatherEffect extendedWeatherEffect in extendedMod.ExtendedWeatherEffects) { PatchedContent.ExtendedWeatherEffects.Add(extendedWeatherEffect); } foreach (ExtendedBuyableVehicle extendedBuyableVehicle in extendedMod.ExtendedBuyableVehicles) { extendedBuyableVehicle.ContentType = ContentType.Custom; extendedBuyableVehicle.Initialize(); PatchedContent.ExtendedBuyableVehicles.Add(extendedBuyableVehicle); } foreach (ExtendedUnlockableItem extendedUnlockableItem in extendedMod.ExtendedUnlockableItems) { extendedUnlockableItem.ContentType = ContentType.Custom; extendedUnlockableItem.Initialize(); PatchedContent.ExtendedUnlockableItems.Add(extendedUnlockableItem); } foreach (ExtendedFootstepSurface extendedFootstepSurface in extendedMod.ExtendedFootstepSurfaces) { extendedFootstepSurface.ContentType = ContentType.Custom; extendedFootstepSurface.Initialize(); PatchedContent.ExtendedFootstepSurfaces.Add(extendedFootstepSurface); } foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { extendedContent.ContentTags.RemoveAll((ContentTag tag) => string.Equals(tag.contentTagName, ExtendedMod.CustomContentTag.contentTagName, StringComparison.OrdinalIgnoreCase) || string.Equals(tag.contentTagName, ExtendedMod.VanillaContentTag.contentTagName, StringComparison.OrdinalIgnoreCase)); extendedContent.ContentTags.Insert(0, ExtendedMod.CustomContentTag); } } } public static void RegisterExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow) { DebugHelper.LogWarning("AssetBundleLoader.RegisterExtendedDungeonFlow() is deprecated. Please move to PatchedContent.RegisterExtendedDungeonFlow() to prevent issues in following updates.", DebugType.Developer); PatchedContent.RegisterExtendedDungeonFlow(extendedDungeonFlow); } public static void RegisterExtendedLevel(ExtendedLevel extendedLevel) { DebugHelper.LogWarning("AssetBundleLoader.RegisterExtendedLevel() is deprecated. Please move to PatchedContent.RegisterExtendedLevel() to prevent issues in following updates.", DebugType.Developer); PatchedContent.RegisterExtendedLevel(extendedLevel); } internal static void CreateVanillaExtendedLevels(StartOfRound startOfRound) { DebugHelper.Log("Creating ExtendedLevels For Vanilla SelectableLevels", DebugType.Developer); SelectableLevel[] levels = startOfRound.levels; foreach (SelectableLevel val in levels) { ExtendedLevel extendedLevel = ExtendedLevel.Create(val); extendedLevel.UseTerrainFootsteps = ((Object)val).name.StartsWith("Vow", StringComparison.Ordinal) || ((Object)val).name.StartsWith("March", StringComparison.Ordinal) || ((Object)val).name.StartsWith("Adamance", StringComparison.Ordinal); CompatibleNoun[] compatibleNouns = TerminalManager.routeKeyword.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns) { if (((Object)val2.noun).name.Contains(ExtendedLevel.GetNumberlessPlanetName(val))) { extendedLevel.RouteNode = val2.result; extendedLevel.RouteConfirmNode = val2.result.terminalOptions[1].result; extendedLevel.RoutePrice = val2.result.itemCost; break; } } PatchedContent.AllLevelSceneNames.Add(extendedLevel.SelectableLevel.sceneName); extendedLevel.Initialize("Lethal Company", generateTerminalAssets: false); ((Object)extendedLevel).name = extendedLevel.NumberlessPlanetName + "ExtendedLevel"; PatchedContent.ExtendedLevels.Add(extendedLevel); PatchedContent.VanillaMod.RegisterExtendedContent(extendedLevel); } } internal static void CreateVanillaExtendedDungeonFlows() { DebugHelper.Log("Creating ExtendedDungeonFlows For Vanilla DungeonFlows", DebugType.Developer); if (Patches.RoundManager.dungeonFlowTypes != null) { IndoorMapType[] dungeonFlowTypes = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType indoorMapType in dungeonFlowTypes) { CreateVanillaExtendedDungeonFlow(indoorMapType); } } else { DebugHelper.Log("Error! RoundManager dungeonFlowTypes Array Was Null!", DebugType.User); } } internal static void CreateVanillaExtendedItems() { foreach (Item item in OriginalContent.Items) { ExtendedItem extendedItem = ExtendedItem.Create(item, PatchedContent.VanillaMod, ContentType.Vanilla); extendedItem.IsBuyableItem = false; PatchedContent.ExtendedItems.Add(extendedItem); } Terminal terminal = TerminalManager.Terminal; int num = 0; Item[] buyableItemsList = terminal.buyableItemsList; foreach (Item newItem in buyableItemsList) { ExtendedItem extendedItem2 = ExtendedItem.Create(newItem, PatchedContent.VanillaMod, ContentType.Vanilla); extendedItem2.IsBuyableItem = true; CompatibleNoun[] compatibleNouns = TerminalManager.buyKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { if (val.result.buyItemIndex != num) { continue; } extendedItem2.BuyNode = val.result; extendedItem2.BuyConfirmNode = val.result.terminalOptions[0].result; CompatibleNoun[] compatibleNouns2 = TerminalManager.routeInfoKeyword.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns2) { if (val2.noun.word == val.noun.word) { extendedItem2.BuyInfoNode = val2.result; } } } PatchedContent.ExtendedItems.Add(extendedItem2); num++; } } internal static void CreateVanillaExtendedEnemyTypes() { foreach (EnemyType enemy in OriginalContent.Enemies) { ExtendedEnemyType extendedEnemyType = ExtendedEnemyType.Create(enemy, PatchedContent.VanillaMod, ContentType.Vanilla); PatchedContent.ExtendedEnemyTypes.Add(extendedEnemyType); ScanNodeProperties[] componentsInChildren = extendedEnemyType.EnemyType.enemyPrefab.GetComponentsInChildren(true); ScanNodeProperties val = Array.Find(componentsInChildren, (ScanNodeProperties scanNode) => scanNode.creatureScanID >= 0 && scanNode.creatureScanID < Patches.Terminal.enemyFiles.Count); if ((Object)(object)val != (Object)null) { extendedEnemyType.ScanNodeProperties = val; extendedEnemyType.EnemyID = val.creatureScanID; extendedEnemyType.EnemyInfoNode = Patches.Terminal.enemyFiles[val.creatureScanID]; if ((Object)(object)extendedEnemyType.EnemyInfoNode != (Object)null) { extendedEnemyType.InfoNodeVideoClip = extendedEnemyType.EnemyInfoNode.displayVideo; } extendedEnemyType.EnemyDisplayName = val.headerText; } if (string.IsNullOrEmpty(extendedEnemyType.EnemyDisplayName)) { extendedEnemyType.EnemyDisplayName = enemy.enemyName; } } } internal static void CreateVanillaExtendedWeatherEffects(TimeOfDay timeOfDay) { //IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references) for (int i = -1; i < timeOfDay.effects.Length; i++) { LevelWeatherType val = (LevelWeatherType)i; WeatherEffect weatherEffect = ((i >= 0) ? timeOfDay.effects[i] : null); ExtendedWeatherEffect item = ExtendedWeatherEffect.Create(val, weatherEffect, $"{val}", ContentType.Vanilla); PatchedContent.ExtendedWeatherEffects.Add(item); PatchedContent.VanillaMod.ExtendedWeatherEffects.Add(item); } } internal static void CreateVanillaExtendedDungeonFlow(IndoorMapType indoorMapType) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)indoorMapType.dungeonFlow == (Object)null) { DebugHelper.LogError("Vanilla DungeonFlow In RoundManager dungeonFlowTypes Array Was Null!", DebugType.User); return; } string name = ((Object)indoorMapType.dungeonFlow).name; ExtendedDungeonFlow extendedDungeonFlow = ExtendedDungeonFlow.Create(indoorMapType.dungeonFlow, indoorMapType.firstTimeAudio, indoorMapType.restrictBounds, indoorMapType.cullingTileDepth); extendedDungeonFlow.DungeonName = (name.StartsWith("Level1", StringComparison.Ordinal) ? "Facility" : (name.StartsWith("Level2", StringComparison.Ordinal) ? "Haunted Mansion" : (name.StartsWith("Level3", StringComparison.Ordinal) ? "Mineshaft" : (name.StartsWith("Level4", StringComparison.Ordinal) ? "Aquarium" : "Unknown")))); extendedDungeonFlow.ContentTags.Add(ExtendedMod.VanillaContentTag); extendedDungeonFlow.Initialize(); PatchedContent.VanillaMod.RegisterExtendedContent(extendedDungeonFlow); PatchedContent.ExtendedDungeonFlows.Add(extendedDungeonFlow); if (extendedDungeonFlow.DungeonID == -1) { DungeonManager.RefreshDungeonFlowIDs(); } } internal static void CreateVanillaExtendedBuyableVehicles() { BuyableVehicle[] buyableVehicles = Patches.Terminal.buyableVehicles; foreach (BuyableVehicle buyableVehicle in buyableVehicles) { CreateVanillaExtendedBuyableVehicle(buyableVehicle); } } internal static void CreateVanillaExtendedBuyableVehicle(BuyableVehicle buyableVehicle) { ExtendedBuyableVehicle extendedBuyableVehicle = ExtendedBuyableVehicle.Create(buyableVehicle); extendedBuyableVehicle.ContentTags.Add(ExtendedMod.VanillaContentTag); PatchedContent.VanillaMod.RegisterExtendedContent(extendedBuyableVehicle); PatchedContent.ExtendedBuyableVehicles.Add(extendedBuyableVehicle); } internal static void CreateVanillaExtendedUnlockableItems() { foreach (UnlockableItem unlockableItem in OriginalContent.UnlockableItems) { CreateVanillaExtendedUnlockableItem(unlockableItem); } } internal static void CreateVanillaExtendedUnlockableItem(UnlockableItem unlockableItem) { ExtendedUnlockableItem extendedUnlockableItem = ExtendedUnlockableItem.Create(unlockableItem, PatchedContent.VanillaMod, ContentType.Vanilla); extendedUnlockableItem.ContentTags.Add(ExtendedMod.VanillaContentTag); PatchedContent.VanillaMod.RegisterExtendedContent(extendedUnlockableItem); PatchedContent.ExtendedUnlockableItems.Add(extendedUnlockableItem); } internal static void CreateVanillaExtendedFootstepSurfaces() { for (int i = 0; i < OriginalContent.FootstepSurfaces.Count; i++) { FootstepSurface val = OriginalContent.FootstepSurfaces[i]; if (val != null) { bool flag = ((i == 1 || i == 4 || (uint)(i - 7) <= 1u) ? true : false); bool allowSinking = flag; TerrainWithIndices[] associatedTerrains = i switch { 4 => new TerrainWithIndices[3] { new TerrainWithIndices("VowTerrain", 0, 1), new TerrainWithIndices("MarchTerrainNew", 0, 2), new TerrainWithIndices("ConstancyTerrain", 0, 2) }, 5 => new TerrainWithIndices[3] { new TerrainWithIndices("VowTerrain", 2), new TerrainWithIndices("MarchTerrainNew", 1), new TerrainWithIndices("ConstancyTerrain", 1) }, _ => null, }; CreateVanillaExtendedFootstepSurface(OriginalContent.FootstepSurfaces[i], allowSinking, associatedTerrains); } } } internal static void CreateVanillaExtendedFootstepSurface(FootstepSurface footstepSurface, bool allowSinking, TerrainWithIndices[] associatedTerrains) { ExtendedFootstepSurface extendedFootstepSurface = ExtendedFootstepSurface.Create(footstepSurface, allowSinking, associatedTerrains); extendedFootstepSurface.ContentTags.Add(ExtendedMod.VanillaContentTag); extendedFootstepSurface.Initialize(); PatchedContent.VanillaMod.RegisterExtendedContent(extendedFootstepSurface); PatchedContent.ExtendedFootstepSurfaces.Add(extendedFootstepSurface); } internal static bool NetworkRegisterDungeonContent(ExtendedDungeonFlow extendedDungeonFlow, NetworkManager networkManager) { HashSet hashSet = new HashSet(); NetworkObject val = default(NetworkObject); foreach (IndoorMapHazard indoorMapHazard in extendedDungeonFlow.IndoorMapHazards) { if (indoorMapHazard != null && !((Object)(object)indoorMapHazard.hazardType == (Object)null) && !((Object)(object)indoorMapHazard.hazardType.prefabToSpawn == (Object)null) && !hashSet.Contains(indoorMapHazard.hazardType.prefabToSpawn)) { if (!indoorMapHazard.hazardType.prefabToSpawn.TryGetComponent(ref val)) { indoorMapHazard.hazardType.prefabToSpawn.AddComponent(); } LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(indoorMapHazard.hazardType.prefabToSpawn); hashSet.Add(indoorMapHazard.hazardType.prefabToSpawn); } } string text = "Automatically Registered The Following IndoorMapHazards In " + ((Object)extendedDungeonFlow).name + ": "; foreach (GameObject item in hashSet) { text = text + ((Object)item).name + ", "; } DebugHelper.Log(text, DebugType.Developer); if ((Object)(object)extendedDungeonFlow == (Object)null) { DebugHelper.LogError("Cannot Network Register Null ExtendedDungeonFlow!", DebugType.User); return false; } if ((Object)(object)extendedDungeonFlow.DungeonFlow == (Object)null) { DebugHelper.LogError("Cannot Network Register ExtendedDungeonFlow: " + ((Object)extendedDungeonFlow).name + " Due To Null DungeonFlow!", DebugType.User); return false; } HashSet hashSet2 = new HashSet(); foreach (SpawnSyncedObject spawnSyncedObject in extendedDungeonFlow.DungeonFlow.GetSpawnSyncedObjects(extendedDungeonFlow.AllTiles)) { if (!((Object)(object)spawnSyncedObject == (Object)null) && !((Object)(object)spawnSyncedObject.spawnPrefab == (Object)null) && !hashSet.Contains(spawnSyncedObject.spawnPrefab)) { if (ContentRestorer.TryRestoreSpawnSyncedObject(spawnSyncedObject)) { hashSet2.Add(spawnSyncedObject.spawnPrefab); continue; } spawnSyncedObject.spawnPrefab.TryAddComponent(); LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(spawnSyncedObject.spawnPrefab); hashSet.Add(spawnSyncedObject.spawnPrefab); } } text = "Automatically Restored The Following SpawnablePrefabs In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (GameObject item2 in hashSet2) { text = text + ((Object)item2).name + ", "; } DebugHelper.Log(text, DebugType.Developer); text = "Automatically Registered The Following SpawnablePrefabs In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (GameObject item3 in hashSet) { text = text + ((Object)item3).name + ", "; } DebugHelper.Log(text, DebugType.Developer); return true; } } public class ConfigHelper { public const char indexSeparator = ','; public const char keyPairSeparator = ':'; public const char vectorSeparator = '-'; public const string emptyDefaultValues = "Default Values Were Empty"; public static List ConvertToStringWithRarityList(string inputString, Vector2 clampRarity) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0057: Unknown result type (might be due to invalid IL or missing references) string[] array = SplitStringsByIndexSeparator(inputString); if (array.Length == 0) { return new List(); } List list = new List(array.Length); for (int i = 0; i < array.Length; i++) { (string, string) tuple = SplitStringByKeyPairSeparator(array[i]); var (newName, _) = tuple; int.TryParse(tuple.Item2, out var result); if (clampRarity != Vector2.zero) { result = Math.Clamp(result, Mathf.RoundToInt(clampRarity.x), Mathf.RoundToInt(clampRarity.y)); } list.Add(new StringWithRarity(newName, result)); } return list; } public static List ConvertToVector2WithRarityList(string inputString, Vector2 clampRarity) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) string[] array = SplitStringsByIndexSeparator(inputString); if (array.Length == 0) { return new List(); } List list = new List(array.Length); for (int i = 0; i < array.Length; i++) { (string, string) tuple = SplitStringByKeyPairSeparator(array[i]); (string, string) tuple2 = SplitStringByVectorSeparator(tuple.Item1); float.TryParse(tuple2.Item1, out var result); float.TryParse(tuple2.Item2, out var result2); int.TryParse(tuple.Item2, out var result3); if (clampRarity != Vector2.zero) { result3 = Math.Clamp(result3, Mathf.RoundToInt(clampRarity.x), Mathf.RoundToInt(clampRarity.y)); } list.Add(new Vector2WithRarity(new Vector2(result, result2), result3)); } return list; } public static List ConvertToSpawnableEnemyWithRarityList(string inputString, Vector2 clampRarity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown StringWithRarity[] array = ConvertToStringWithRarityList(inputString, clampRarity).ToArray(); if (array.Length == 0) { return new List(); } List list = new List(array.Length); StringWithRarity[] array2 = array; foreach (StringWithRarity stringWithRarity in array2) { foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes) { EnemyType enemyType = extendedEnemyType.EnemyType; bool flag = stringWithRarity.Name.ContainsSanitized(enemyType.enemyName, bothWays: true); if (!flag && (Object)(object)enemyType.enemyPrefab != (Object)null) { ScanNodeProperties componentInChildren = enemyType.enemyPrefab.GetComponentInChildren(false); flag = (Object)(object)componentInChildren != (Object)null && stringWithRarity.Name.ContainsSanitized(componentInChildren.headerText, bothWays: true); } if (flag) { list.Add(new SpawnableEnemyWithRarity(enemyType, stringWithRarity.Rarity)); break; } } } return list; } public static List ConvertToSpawnableItemWithRarityList(string inputString, Vector2 clampRarity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown StringWithRarity[] array = ConvertToStringWithRarityList(inputString, clampRarity).ToArray(); if (array.Length == 0) { return new List(); } List list = new List(array.Length); StringWithRarity[] array2 = array; foreach (StringWithRarity stringWithRarity in array2) { foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems) { Item item = extendedItem.Item; if (stringWithRarity.Name.ContainsSanitized(item.itemName, bothWays: true)) { list.Add(new SpawnableItemWithRarity(item, stringWithRarity.Rarity)); break; } } } return list; } public static string SpawnableEnemiesWithRaritiesToString(SpawnableEnemyWithRarity[] spawnableEnemies) { if (spawnableEnemies.Length == 0) { return "Default Values Were Empty"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < spawnableEnemies.Length; i++) { SpawnableEnemyWithRarity val = spawnableEnemies[i]; stringBuilder.Append(val.enemyType.enemyName + ":" + val.rarity); if (i != spawnableEnemies.Length - 1) { stringBuilder.Append(','); } } return stringBuilder.ToString(); } public static string SpawnableItemsWithRaritiesToString(SpawnableItemWithRarity[] spawnableItems) { if (spawnableItems.Length == 0) { return "Default Values Were Empty"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < spawnableItems.Length; i++) { SpawnableItemWithRarity val = spawnableItems[i]; stringBuilder.Append(val.spawnableItem.itemName + ":" + val.rarity); if (i != spawnableItems.Length - 1) { stringBuilder.Append(','); } } return stringBuilder.ToString(); } public static string StringWithRaritiesToString(StringWithRarity[] names) { if (names.Length == 0) { return "Default Values Were Empty"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < names.Length; i++) { StringWithRarity stringWithRarity = names[i]; stringBuilder.Append(stringWithRarity.Name + ":" + stringWithRarity.Rarity); if (i != names.Length - 1) { stringBuilder.Append(','); } } return stringBuilder.ToString(); } public static string Vector2WithRaritiesToString(Vector2WithRarity[] values) { if (values.Length == 0) { return "Default Values Were Empty"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < values.Length; i++) { Vector2WithRarity vector2WithRarity = values[i]; stringBuilder.Append(vector2WithRarity.Min + 45f + vector2WithRarity.Max + 58f + (float)vector2WithRarity.Rarity); if (i != values.Length - 1) { stringBuilder.Append(','); } } return stringBuilder.ToString(); } public static string[] SplitStringsByIndexSeparator(string inputString) { return SplitStringByCharacter(inputString, ','); } public static (string, string) SplitStringByKeyPairSeparator(string inputString) { return SplitStringPairByCharacter(inputString, ':'); } public static (string, string) SplitStringByVectorSeparator(string inputString) { return SplitStringPairByCharacter(inputString, '-'); } public static (string, string) SplitStringPairByCharacter(string inputString, char separator) { string[] array = SplitStringByCharacter(inputString, separator); if (array.Length != 2) { return (inputString, string.Empty); } return (array[0], array[1]); } public static string[] SplitStringByCharacter(string inputString, char separator) { string[] array = inputString.Split(separator, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim(); } return array; } } public class ContentExtractor { internal static void TryScrapeVanillaItems(StartOfRound startOfRound) { HashSet hashSet = new HashSet(); foreach (Item items in startOfRound.allItemsList.itemsList) { if ((Object)(object)items.spawnPrefab != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.Items, items); hashSet.UnionWith(items.spawnPositionTypes); } } OriginalContent.ItemGroups = hashSet.ToList(); } internal static void TryScrapeVanillaUnlockableItems(StartOfRound startOfRound) { OriginalContent.UnlockableItems = startOfRound.unlockablesList.unlockables.ToList(); } internal static void TryScrapeVanillaFootstepSurfaces(StartOfRound startOfRound) { if (OriginalContent.FootstepSurfaces.Count == 0) { OriginalContent.FootstepSurfaces = startOfRound.footstepSurfaces.ToList(); } } internal static void TryScrapeVanillaContent(StartOfRound startOfRound, RoundManager roundManager) { if (Plugin.IsSetupComplete) { return; } if ((Object)(object)startOfRound != (Object)null) { IndoorMapType[] dungeonFlowTypes = roundManager.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { ContentExtractor.TryAddReference(OriginalContent.DungeonFlows, val.dungeonFlow); } SelectableLevel[] levels = startOfRound.levels; foreach (SelectableLevel selectableLevel in levels) { ExtractSelectableLevelReferences(selectableLevel); } } if ((Object)(object)TerminalManager.Terminal.currentNode != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, TerminalManager.Terminal.currentNode); } foreach (TerminalNode terminalNode in TerminalManager.Terminal.terminalNodes.terminalNodes) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, terminalNode); } foreach (TerminalNode specialNode in TerminalManager.Terminal.terminalNodes.specialNodes) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, specialNode); } foreach (TerminalNode enemyFile in TerminalManager.Terminal.enemyFiles) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, enemyFile); } foreach (TerminalNode logEntryFile in TerminalManager.Terminal.logEntryFiles) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, logEntryFile); } foreach (TerminalNode item in TerminalManager.Terminal.ShipDecorSelection) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, item); } TerminalKeyword[] allKeywords = TerminalManager.Terminal.terminalNodes.allKeywords; foreach (TerminalKeyword val2 in allKeywords) { ContentExtractor.TryAddReference(OriginalContent.TerminalKeywords, val2); if (val2.compatibleNouns != null) { CompatibleNoun[] compatibleNouns = val2.compatibleNouns; foreach (CompatibleNoun val3 in compatibleNouns) { if ((Object)(object)val3.result != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val3.result); } } } if ((Object)(object)val2.specialKeywordResult != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val2.specialKeywordResult); } } foreach (TerminalNode item2 in new List(OriginalContent.TerminalNodes)) { if (item2.terminalOptions == null) { continue; } CompatibleNoun[] terminalOptions = item2.terminalOptions; foreach (CompatibleNoun val4 in terminalOptions) { if ((Object)(object)val4.result != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val4.result); } } } ExtractMemoryLoadedAudioMixerGroups(); ExtractMemoryLoadedReverbPresets(); OriginalContent.SelectableLevels = startOfRound.levels.ToList(); OriginalContent.MoonsCatalogue = TerminalManager.Terminal.moonsCatalogueList.ToList(); } internal static void ObtainSpecialContentReferences() { GrabbableObject[] componentsInChildren = ((Component)Patches.StartOfRound.shipAnimator).GetComponentsInChildren(false); foreach (GrabbableObject val in componentsInChildren) { if ((Object)(object)val.itemProperties != (Object)null && (Object)(object)val.itemProperties.spawnPrefab != (Object)null && !OriginalContent.Items.Contains(val.itemProperties)) { OriginalContent.Items.Add(val.itemProperties); } } NutcrackerEnemyAI val3 = default(NutcrackerEnemyAI); GrabbableObject val4 = default(GrabbableObject); GrabbableObject val5 = default(GrabbableObject); ButlerEnemyAI val6 = default(ButlerEnemyAI); GrabbableObject val7 = default(GrabbableObject); RedLocustBees val8 = default(RedLocustBees); GrabbableObject val9 = default(GrabbableObject); GiantKiwiAI val10 = default(GiantKiwiAI); GrabbableObject val11 = default(GrabbableObject); CadaverGrowthAI val12 = default(CadaverGrowthAI); for (int j = 0; j < OriginalContent.Enemies.Count; j++) { EnemyType val2 = OriginalContent.Enemies[j]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2.enemyPrefab == (Object)null) { continue; } if (val2.enemyPrefab.TryGetComponent(ref val3)) { if ((Object)(object)val3.gunPrefab != (Object)null && val3.gunPrefab.TryGetComponent(ref val4) && (Object)(object)val4.itemProperties != (Object)null && !OriginalContent.Items.Contains(val4.itemProperties)) { OriginalContent.Items.Add(val4.itemProperties); } if ((Object)(object)val3.shotgunShellPrefab != (Object)null && val3.shotgunShellPrefab.TryGetComponent(ref val5) && (Object)(object)val5.itemProperties != (Object)null && !OriginalContent.Items.Contains(val5.itemProperties)) { OriginalContent.Items.Add(val5.itemProperties); } } else if (val2.enemyPrefab.TryGetComponent(ref val6)) { if ((Object)(object)val6.knifePrefab != (Object)null && val6.knifePrefab.TryGetComponent(ref val7) && (Object)(object)val7.itemProperties != (Object)null && !OriginalContent.Items.Contains(val7.itemProperties)) { OriginalContent.Items.Add(val7.itemProperties); } if ((Object)(object)val6.butlerBeesEnemyType != (Object)null && (Object)(object)val6.butlerBeesEnemyType.enemyPrefab != (Object)null && !OriginalContent.Enemies.Contains(val6.butlerBeesEnemyType)) { OriginalContent.Enemies.Add(val6.butlerBeesEnemyType); } } else if (val2.enemyPrefab.TryGetComponent(ref val8)) { if ((Object)(object)val8.hivePrefab != (Object)null && val8.hivePrefab.TryGetComponent(ref val9) && (Object)(object)val9.itemProperties != (Object)null && !OriginalContent.Items.Contains(val9.itemProperties)) { OriginalContent.Items.Add(val9.itemProperties); } } else if (val2.enemyPrefab.TryGetComponent(ref val10)) { if ((Object)(object)val10.eggPrefab != (Object)null && val10.eggPrefab.TryGetComponent(ref val11) && (Object)(object)val11.itemProperties != (Object)null && !OriginalContent.Items.Contains(val11.itemProperties)) { OriginalContent.Items.Add(val11.itemProperties); } } else if (val2.enemyPrefab.TryGetComponent(ref val12) && (Object)(object)val12.bloomEnemyType != (Object)null && (Object)(object)val12.bloomEnemyType.enemyPrefab != (Object)null && !OriginalContent.Enemies.Contains(val12.bloomEnemyType)) { OriginalContent.Enemies.Add(val12.bloomEnemyType); } } foreach (SpawnableEnemyWithRarity weedEnemy in Patches.RoundManager.WeedEnemies) { if (weedEnemy != null && (Object)(object)weedEnemy.enemyType != (Object)null && (Object)(object)weedEnemy.enemyType.enemyPrefab != (Object)null && !OriginalContent.Enemies.Contains(weedEnemy.enemyType)) { OriginalContent.Enemies.Add(weedEnemy.enemyType); } } } internal static void ExtractMemoryLoadedAudioMixerGroups() { AudioMixerGroup[] array = Resources.FindObjectsOfTypeAll(); AudioMixerSnapshot[] array2 = Resources.FindObjectsOfTypeAll(); Dictionary dictionary = new Dictionary(array.Length); Dictionary dictionary2 = new Dictionary(array2.Length); foreach (AudioMixerGroup val in array) { if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name)) { dictionary.TryAdd(((Object)val).name, val); } } OriginalContent.AudioMixerGroups = dictionary.Values.ToList(); foreach (AudioMixerSnapshot val2 in array2) { if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(((Object)val2).name)) { dictionary2.TryAdd(((Object)val2).name, val2); } } OriginalContent.AudioMixerSnapshots = dictionary2.Values.ToList(); } internal static void ExtractMemoryLoadedReverbPresets() { ReverbPreset[] array = Resources.FindObjectsOfTypeAll(); Dictionary dictionary = new Dictionary(array.Length); for (int num = array.Length - 1; num >= 0; num--) { ReverbPreset val = array[num]; if ((Object)(object)val != (Object)null && ((Object)val).name != null) { dictionary.TryAdd(((Object)val).name, val); } } OriginalContent.ReverbPresets = dictionary.Values.ToList(); } internal static void ExtractSelectableLevelReferences(SelectableLevel selectableLevel) { if ((Object)(object)selectableLevel == (Object)null) { return; } foreach (SpawnableEnemyWithRarity enemy in selectableLevel.Enemies) { ContentExtractor.TryAddReference(OriginalContent.Enemies, enemy.enemyType); } foreach (SpawnableEnemyWithRarity outsideEnemy in selectableLevel.OutsideEnemies) { ContentExtractor.TryAddReference(OriginalContent.Enemies, outsideEnemy.enemyType); } foreach (SpawnableEnemyWithRarity daytimeEnemy in selectableLevel.DaytimeEnemies) { ContentExtractor.TryAddReference(OriginalContent.Enemies, daytimeEnemy.enemyType); } if (selectableLevel.specialEnemyRarity != null && (Object)(object)selectableLevel.specialEnemyRarity.overrideEnemy != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.Enemies, selectableLevel.specialEnemyRarity.overrideEnemy); } IndoorMapHazard[] indoorMapHazards = selectableLevel.indoorMapHazards; foreach (IndoorMapHazard val in indoorMapHazards) { ContentExtractor.TryAddReference(OriginalContent.IndoorMapHazards, val.hazardType); } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = selectableLevel.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val2 in spawnableOutsideObjects) { ContentExtractor.TryAddReference(OriginalContent.SpawnableOutsideObjects, val2.spawnableObject); } ContentExtractor.TryAddReference(OriginalContent.LevelAmbienceLibraries, selectableLevel.levelAmbienceClips); } internal static void TryAddReference(List referenceList, T reference) where T : Object { if (!referenceList.Contains(reference)) { referenceList.Add(reference); } } } internal static class ContentTagParser { private static readonly Dictionary importedItemContentTagDictionary = new Dictionary(); private static readonly Dictionary importedLevelContentTagDictionary = new Dictionary(); private static readonly Dictionary importedEnemyContentTagDictionary = new Dictionary(); internal static void ApplyVanillaContentTags() { ApplyImportedItemContentTags(); ApplyImportedSelectableLevelContentTags(); ApplyImportedEnemyTypeContentTags(); } internal static void ImportVanillaContentTags() { ParseContentFile("Items", importedItemContentTagDictionary, 4); ParseContentFile("SelectableLevels", importedLevelContentTagDictionary, 4); ParseContentFile("Enemies", importedEnemyContentTagDictionary, 4); } internal static void ParseContentFile(string fileName, Dictionary importedContentTagDict, int startingLine) { DebugHelper.Log("Parsing Contents Of Content CSV Located At: " + fileName, DebugType.Developer); using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LethalLevelLoader.VanillaContentTags." + fileName + ".csv"); using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8); int num = 0; try { string line; while ((line = streamReader.ReadLine()) != null) { if (++num >= startingLine && TryParseLine(line, out var contentName, out var contentTags)) { importedContentTagDict[contentName] = contentTags; DebugParsedLine(contentName, contentTags); } } } catch (Exception arg) { DebugHelper.LogError($"Could Not Parse File '{fileName}', CSV Tags Will Not Be Applied: {arg}", DebugType.User); } } internal static void ApplyImportedItemContentTags() { int num = 0; List list = PatchedContent.VanillaMod.ExtendedItems.ToList(); foreach (KeyValuePair importedItemData in importedItemContentTagDictionary) { int num2 = list.FindIndex((ExtendedItem extendedItem2) => importedItemData.Key.ContainsSanitized(new string[2] { ((Object)extendedItem2.Item).name, extendedItem2.Item.itemName }, bothWays: true)); if (num2 >= 0) { ExtendedItem extendedItem = list[num2]; DebugHelper.Log($"Applying CSV Tags For Imported Item #{++num} / {importedItemContentTagDictionary.Count}: {importedItemData.Key} To ExtendedItem: {extendedItem.Item.itemName}({((Object)extendedItem.Item).name})", DebugType.Developer); extendedItem.ContentTags.Add(ExtendedMod.VanillaContentTag); extendedItem.ContentTags.AddRange(ContentTagManager.CreateNewContentTags(importedItemData.Value.ToList())); list.RemoveAt(num2); } else { DebugHelper.LogWarning($"Could Not Apply CSV Tags For Imported Item #{++num} / {importedItemContentTagDictionary.Count}: {importedItemData.Key}", DebugType.Developer); } } } internal static void ApplyImportedSelectableLevelContentTags() { int num = 0; List list = PatchedContent.VanillaMod.ExtendedLevels.ToList(); foreach (KeyValuePair importedLevelData in importedLevelContentTagDictionary) { int num2 = list.FindIndex((ExtendedLevel extendedLevel2) => importedLevelData.Key.ContainsSanitized(new string[2] { ((Object)extendedLevel2.SelectableLevel).name, extendedLevel2.SelectableLevel.PlanetName }, bothWays: true)); if (num2 >= 0) { ExtendedLevel extendedLevel = list[num2]; DebugHelper.Log($"Applying CSV Tags For Imported Level #{++num} / {importedLevelContentTagDictionary.Count}: {importedLevelData.Key} To ExtendedLevel: {extendedLevel.SelectableLevel.PlanetName}({((Object)extendedLevel.SelectableLevel).name})", DebugType.Developer); extendedLevel.ContentTags.Add(ExtendedMod.VanillaContentTag); extendedLevel.ContentTags.AddRange(ContentTagManager.CreateNewContentTags(importedLevelData.Value.ToList())); list.RemoveAt(num2); } else { DebugHelper.LogWarning($"Could Not Apply CSV Tags For Imported Level #{++num} / {importedLevelContentTagDictionary.Count}: {importedLevelData.Key}", DebugType.Developer); } } } internal static void ApplyImportedEnemyTypeContentTags() { int num = 0; List list = PatchedContent.VanillaMod.ExtendedEnemyTypes.ToList(); foreach (KeyValuePair importedEnemyData in importedEnemyContentTagDictionary) { int num2 = list.FindIndex((ExtendedEnemyType extendedEnemy) => importedEnemyData.Key.ContainsSanitized(new string[2] { ((Object)extendedEnemy.EnemyType).name, extendedEnemy.EnemyType.enemyName }, bothWays: true)); if (num2 >= 0) { ExtendedEnemyType extendedEnemyType = list[num2]; DebugHelper.Log($"Applying CSV Tags For Imported Enemy #{++num} / {importedEnemyContentTagDictionary.Count}: {importedEnemyData.Key} To ExtendedEnemyType: {extendedEnemyType.EnemyType.enemyName}({((Object)extendedEnemyType.EnemyType).name})", DebugType.Developer); extendedEnemyType.ContentTags.Add(ExtendedMod.VanillaContentTag); extendedEnemyType.ContentTags.AddRange(ContentTagManager.CreateNewContentTags(importedEnemyData.Value.ToList())); list.RemoveAt(num2); } else { DebugHelper.LogWarning($"Could Not Apply CSV Tags For Imported Enemy #{++num} / {importedEnemyContentTagDictionary.Count}: {importedEnemyData.Key}", DebugType.Developer); } } } internal static bool TryParseLine(string line, out string contentName, out string[] contentTags) { contentName = null; contentTags = null; if (string.IsNullOrEmpty(line)) { return false; } string[] array = line.Split(',', StringSplitOptions.RemoveEmptyEntries); if (array.Length < 2) { return false; } contentName = array[0]; contentTags = new string[array.Length - 2]; for (int i = 0; i < contentTags.Length; i++) { contentTags[i] = array[i + 2]; } return true; } internal static void DebugParsedLine(string contentName, string[] contentTags) { if (!string.IsNullOrEmpty(contentName) && contentTags != null && contentTags.Length != 0) { DebugHelper.Log("ContentName: " + contentName + " | ContentTags: " + string.Join(", ", contentTags), DebugType.Developer); } } } internal static class DebugHelper { public static void Log(string log, DebugType debugType) { if (!string.IsNullOrEmpty(log) && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogInfo((object)log); } else { Debug.Log((object)("LethalLevelLoader Fallback Logger: " + log)); } } } public static void LogWarning(string log, DebugType debugType) { if (!string.IsNullOrEmpty(log) && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogWarning((object)log); } else { Debug.LogWarning((object)("LethalLevelLoader Fallback Logger: " + log)); } } } public static void LogError(string log, DebugType debugType) { if (!string.IsNullOrEmpty(log) && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogError((object)log); } else { Debug.LogError((object)("LethalLevelLoader Fallback Logger: " + log)); } } } public static void LogError(Exception exception, DebugType debugType) { if (exception != null && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogError((object)exception); } else { Debug.LogError((object)("LethalLevelLoader Fallback Logger: " + exception)); } } } public static void LogFatal(string log, DebugType debugType) { if (!string.IsNullOrEmpty(log) && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogFatal((object)log); } else { Debug.LogError((object)("(FATAL!) LethalLevelLoader Fallback Logger: " + log)); } } } public static void LogFatal(Exception exception, DebugType debugType) { if (exception != null && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogFatal((object)exception); } else { Debug.LogError((object)("(FATAL!) LethalLevelLoader Fallback Logger: " + exception)); } } } public static void LogDebug(string log, DebugType debugType) { if (!string.IsNullOrEmpty(log) && Settings.debugType >= debugType) { if (Plugin.logger != null) { Plugin.logger.LogDebug((object)log); } else { Debug.Log((object)("(Debug) LethalLevelLoader Fallback Logger: " + log)); } } } public static void DebugExtendedMod(ExtendedMod extendedMod) { string text = "Debug Report For ExtendedMod: " + extendedMod.ModName + " by " + extendedMod.AuthorName + ":\n\n"; List extendedContents = extendedMod.ExtendedContents; text += $"ExtendedContents: Count - {extendedContents.Count}\n\n"; foreach (ExtendedContent item in extendedContents) { text = text + ((Object)item).name + " (" + ((object)item).GetType().Name + ")\n"; } Log(text, DebugType.Developer); } public static void DebugAllContentTags() { if (Settings.debugType < DebugType.Developer) { return; } ExtendedMod vanillaMod = PatchedContent.VanillaMod; List extendedMods = PatchedContent.ExtendedMods; int num = 0; ExtendedMod[] array = new ExtendedMod[1 + extendedMods.Count]; array[num] = vanillaMod; num++; foreach (ExtendedMod item in extendedMods) { array[num] = item; num++; } ExtendedMod[] array2 = array; ExtendedMod[] array3 = array2; foreach (ExtendedMod extendedMod in array3) { Dictionary> dictionary = new Dictionary>(); foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { foreach (ContentTag contentTag in extendedContent.ContentTags) { if (dictionary.TryGetValue(contentTag, out var value)) { value.Add(extendedContent); continue; } dictionary.Add(contentTag, new List(1) { extendedContent }); } } string empty = string.Empty; if (dictionary.Count > 0) { empty = extendedMod.ModName + " Had The Following Content Tags:\n"; foreach (KeyValuePair> item2 in dictionary) { empty = empty + "\n - Tag: " + item2.Key.contentTagName + " | Associated Contents: "; int num2 = 0; foreach (ExtendedContent item3 in item2.Value) { empty = empty + ((Object)item3).name + ", "; num2++; } empty = empty.TrimEnd(',', ' '); } } else { empty = extendedMod.ModName + " Had No Content Tags."; } Log(empty + "\n", DebugType.Developer); } } } internal static class DebugStopwatch { private static string currentText = string.Empty; private static Stopwatch currentStopwatch; internal static void StartStopWatch(string newStopWatchText) { if (currentStopwatch != null) { StopStopWatch(currentText); } currentStopwatch = Stopwatch.StartNew(); currentText = newStopWatchText; } internal static void StopStopWatch(string stopWatchText) { if (currentStopwatch != null) { currentStopwatch.Stop(); DebugHelper.Log($"[Debug Stopwatch] {stopWatchText} : {currentStopwatch.Elapsed.TotalSeconds:0.##} Seconds. ({currentStopwatch.ElapsedMilliseconds}ms)", DebugType.IAmBatby); currentText = string.Empty; currentStopwatch = null; } } } public static class PrefabHelper { internal static Lazy _prefabParent; internal static GameObject prefabParent => _prefabParent.Value; static PrefabHelper() { _prefabParent = new Lazy((Func)delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown GameObject val = new GameObject("LethalLibGeneratedPrefabs") { hideFlags = (HideFlags)61 }; val.SetActive(false); return val; }); } public static GameObject CreatePrefab(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown GameObject val = new GameObject(name) { hideFlags = (HideFlags)61 }; val.transform.SetParent(prefabParent.transform); return val; } public static GameObject CreateNetworkPrefab(string name) { GameObject val = CreatePrefab(name); val.AddComponent(); byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + name)); val.GetComponent().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0); return val; } } } namespace LethalLevelLoader.Tools { internal static class ConfigLoader { public static string debugLevelsString = string.Empty; public static string debugDungeonsString = string.Empty; public static ConfigFile configFile; internal static void BindConfigs() { foreach (ExtendedDungeonFlow vanillaExtendedDungeonFlow in PatchedContent.VanillaExtendedDungeonFlows) { ExtendedDungeonConfig extendedDungeonConfig = new ExtendedDungeonConfig(configFile, "Vanilla Dungeon: " + vanillaExtendedDungeonFlow.DungeonName.StripSpecialCharacters() + " (" + ((Object)vanillaExtendedDungeonFlow.DungeonFlow).name + ")", 7); extendedDungeonConfig.BindConfigs(vanillaExtendedDungeonFlow); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { ExtendedDungeonConfig extendedDungeonConfig2 = new ExtendedDungeonConfig(configFile, "Custom Dungeon: " + customExtendedDungeonFlow.DungeonName.StripSpecialCharacters(), 9); extendedDungeonConfig2.BindConfigs(customExtendedDungeonFlow); if (customExtendedDungeonFlow.dynamicLevelTagsList.Count > 0 || customExtendedDungeonFlow.dynamicRoutePricesList.Count > 0 || customExtendedDungeonFlow.dynamicCurrentWeatherList.Count > 0 || customExtendedDungeonFlow.manualPlanetNameReferenceList.Count > 0 || customExtendedDungeonFlow.manualContentSourceNameReferenceList.Count > 0) { DebugHelper.LogWarning("ExtendedDungeonFlow: " + ((Object)customExtendedDungeonFlow).name + ": ExtendedDungeonFlow dynamic and manual match reference lists are Obsolete and will be removed in following releases, Please use ExtendedDungeonFlow.LevelMatchingProperties instead.", DebugType.Developer); customExtendedDungeonFlow.LevelMatchingProperties.ApplyValues(null, customExtendedDungeonFlow.manualContentSourceNameReferenceList, newPlanetNames: customExtendedDungeonFlow.manualPlanetNameReferenceList, newLevelTags: customExtendedDungeonFlow.dynamicLevelTagsList, newRoutePrices: customExtendedDungeonFlow.dynamicRoutePricesList, newCurrentWeathers: customExtendedDungeonFlow.dynamicCurrentWeatherList); } } foreach (ExtendedLevel vanillaExtendedLevel in PatchedContent.VanillaExtendedLevels) { ExtendedLevelConfig extendedLevelConfig = new ExtendedLevelConfig(configFile, "Vanilla Level: " + vanillaExtendedLevel.SelectableLevel.PlanetName.StripSpecialCharacters(), 6); extendedLevelConfig.BindConfigs(vanillaExtendedLevel); } foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { ExtendedLevelConfig extendedLevelConfig2 = new ExtendedLevelConfig(configFile, "Custom Level: " + customExtendedLevel.SelectableLevel.PlanetName.StripSpecialCharacters(), 8); extendedLevelConfig2.BindConfigs(customExtendedLevel); } configFile.SaveOnConfigSet = true; configFile.Save(); debugLevelsString = string.Empty; debugDungeonsString = string.Empty; } internal static void BindGeneralConfigs() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "LethalLevelLoader.cfg"), false) { SaveOnConfigSet = false }; GeneralSettingsConfig generalSettingsConfig = new GeneralSettingsConfig(configFile, " - LethalLevelLoader Settings -", 5); generalSettingsConfig.BindConfigs(); DebugHelper.Log("Config Level Set As: " + Settings.debugType, DebugType.User); } internal static string GetConfigCategory(string categoryName, string contentName) { return categoryName + contentName; } } public class GeneralSettingsConfig : ConfigTemplate { private ConfigEntry previewInfoTypeToggle; private ConfigEntry sortInfoTypeToggle; private ConfigEntry filterInfoTypeToggle; private ConfigEntry simulateInfoTypeToggle; private ConfigEntry debugTypeToggle; private ConfigEntry moonsCatalogueSplitCount; private ConfigEntry injectDynamicMatchingWeights; private ConfigEntry bundlesBlacklist; private ConfigEntry overrideDungeonGeneratorParameters; private ConfigEntry generateAsynchronously; private ConfigEntry maxAsyncFrameMilliseconds; private ConfigEntry retryCount; public GeneralSettingsConfig(ConfigFile newConfigFile, string newCategory, int newSortingPriority) : base(newConfigFile, newCategory, newSortingPriority) { } public void BindConfigs() { debugTypeToggle = BindValue("LethalLevelLoader Debugging Mode", "Controls what type of debug logs you recieve, If you use mods, Keep this set to User, If you create content with LethalLeveLoader, set this to Developer", DebugType.User); previewInfoTypeToggle = BindValue("Terminal >Moons PreviewInfo Default", "What LethalLevelLoader displays next to each moon in the >moons Terminal listing.", PreviewInfoType.Weather); sortInfoTypeToggle = BindValue("Terminal >Moons SortInfo Default", "How LethalLevelLoader sorts each moon in the >moons Terminal listing.", SortInfoType.None); filterInfoTypeToggle = BindValue("Terminal >Moons FilterInfo Default", "How LethalLevelLoader filters each moon in the >moons Terminal listing.", FilterInfoType.None); simulateInfoTypeToggle = BindValue("Terminal >Simulate Results Type Default", "The format used to display odds using the >simulate Terminal keyword.", SimulateInfoType.Percentage); moonsCatalogueSplitCount = BindValue("Moons Catalogue Group Split Count", "The amount of moons that will be in each automatically generated group.", 3); injectDynamicMatchingWeights = BindValue("Inject Dynamic Matching Weights", "Enable dynamic weights injection on every landing, based on Level & Dungeon MatchingProperties set by mod authors.", genericValue: true); bundlesBlacklist = BindValue("Bundle Loading Blacklist", "A list of bundles to skip from loading completely. NOTE: Not all bundles may be fine to skip, some may expect specific assets to be always loaded.", "examplebundle.lethalbundle"); overrideDungeonGeneratorParameters = BindValue("Override DungeonGenerator Parameters", "Enable this to allow the following three settings to function.", genericValue: false); generateAsynchronously = BindValue("Generate Asynchronously", "Enable or disable asynchronous generation.", genericValue: true); maxAsyncFrameMilliseconds = BindValue("Max Async Frame Milliseconds", "Maximum delay every frame during generation, in milliseconds.", 1f); retryCount = BindValue("Retry Count", "Maximum number of generation attempts before failing to generate.", 50); Settings.debugType = debugTypeToggle.Value; Settings.levelPreviewInfoType = previewInfoTypeToggle.Value; Settings.levelPreviewSortType = sortInfoTypeToggle.Value; Settings.levelPreviewFilterType = filterInfoTypeToggle.Value; Settings.levelSimulateInfoType = simulateInfoTypeToggle.Value; if (moonsCatalogueSplitCount.Value > 0) { Settings.moonsCatalogueSplitCount = moonsCatalogueSplitCount.Value; } Settings.injectDynamicMatchingWeights = injectDynamicMatchingWeights.Value; Settings.bundlesBlacklist = ConfigHelper.SplitStringsByIndexSeparator(bundlesBlacklist.Value); Settings.overrideDungeonGeneratorParameters = overrideDungeonGeneratorParameters.Value; Settings.generateAsynchronously = generateAsynchronously.Value; Settings.maxAsyncFrameMilliseconds = maxAsyncFrameMilliseconds.Value; Settings.retryCount = retryCount.Value; } } public class ExtendedDungeonConfig : ConfigTemplate { public ConfigEntry enableContentConfiguration; public ConfigEntry manualLevelNames; public ConfigEntry manualModNames; public ConfigEntry enableDynamicDungeonSizeRestriction; public ConfigEntry minimumDungeonSizeMultiplier; public ConfigEntry maximumDungeonSizeMultiplier; public ConfigEntry restrictDungeonSizeScaler; public ConfigEntry dynamicLevelTags; public ConfigEntry dynamicRoutePrices; public ConfigEntry disabledWarning; public ExtendedDungeonConfig(ConfigFile newConfigFile, string newCategory, int sortingPriority) : base(newConfigFile, newCategory, sortingPriority) { } public void BindConfigs(ExtendedDungeonFlow extendedDungeonFlow) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) if (extendedDungeonFlow.GenerateAutomaticConfigurationOptions) { enableContentConfiguration = BindValue("Enable Content Configuration", "Enable This To Utilise Any Of The Configuration Options For '" + ((Object)extendedDungeonFlow.DungeonFlow).name + "'", genericValue: false); subCategory = "General Settings - "; enableDynamicDungeonSizeRestriction = BindValue("Enable Dynamic Dungeon Size Restriction", "Enable this to allow the following three settings to function.", extendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled); minimumDungeonSizeMultiplier = BindValue("Minimum Dungeon Size Multiplier", "If The Level's Dungeon Size Multiplier Is Below This Value, The Size Multiplier Will Be Restricted Based On The RestrictDungeonSizeScaler Setting", extendedDungeonFlow.DynamicDungeonSizeMinMax.x); maximumDungeonSizeMultiplier = BindValue("Maximum Dungeon Size Multiplier", "If The Level's Dungeon Size Multiplier Is Above This Value, The Size Multiplier Will Be Restricted Based On The RestrictDungeonSizeScaler Setting", extendedDungeonFlow.DynamicDungeonSizeMinMax.y); string text = "If The Level's Dungeon Size Multiplier Is Above Or Below The Previous Two Settings, The Dungeon Size Multiplier Will Be Set To The Value Between The Level's Dungeon Size Multiplier And This Value.\n"; text += "Example #1: If Set To 0, The Dungeon Size Will Not Be Higher Than Maximum Dungeon Size Multiplier.\n"; text += "Example #2: If Set To 0.5, The Dungeon Size Will Be Between The Maxiumum Dungeon Size Multiplier And The Level's Dungeon Size Multiplier.\n"; text += "Example #3: If Set To 1, The Dungeon Size Will Be The Level's Dungeon Size Multiplier With No Changes Applied.\n"; text += "(Minimum, 0, Maximum: 1)"; restrictDungeonSizeScaler = BindValue("Restrict Dungeon Size Scaler", text, extendedDungeonFlow.DynamicDungeonSizeLerpRate); subCategory = "Dungeon Injection Settings - "; manualModNames = BindValue("Manual Mod Names List", "Add this Dungeon to any Level's randomisaton pool in a specific mod based on matching Mod Names. (Minimum: 0, Maximum: 9999)", ConfigHelper.StringWithRaritiesToString(extendedDungeonFlow.LevelMatchingProperties.modNames.ToArray())); manualLevelNames = BindValue("Manual Level Names List", "Add this Dungeon to a Level's randomisaton pool based on matching Level Names. (Minimum: 0, Maximum: 9999)", ConfigHelper.StringWithRaritiesToString(extendedDungeonFlow.LevelMatchingProperties.planetNames.ToArray())); dynamicLevelTags = BindValue("Dynamic Level Tags List", "Add this Dungeon to a Level's randomisaton pool based on matching Level Tags. (Minimum: 0, Maximum: 9999)", ConfigHelper.StringWithRaritiesToString(extendedDungeonFlow.LevelMatchingProperties.levelTags.ToArray())); dynamicRoutePrices = BindValue("Dynamic Route Price List", "Add this Dungeon to a Level's randomisaton pool based on matching Route Prices. (Minimum: 0, Maximum: 9999)", ConfigHelper.Vector2WithRaritiesToString(extendedDungeonFlow.LevelMatchingProperties.currentRoutePrice.ToArray())); if (!enableContentConfiguration.Value) { return; } DebugHelper.Log(extendedDungeonFlow.DungeonName + " enabled content configuration", DebugType.Developer); extendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled = enableDynamicDungeonSizeRestriction.Value; extendedDungeonFlow.DynamicDungeonSizeMinMax = new Vector2(minimumDungeonSizeMultiplier.Value, maximumDungeonSizeMultiplier.Value); extendedDungeonFlow.DynamicDungeonSizeLerpRate = restrictDungeonSizeScaler.Value; extendedDungeonFlow.LevelMatchingProperties.modNames = ConfigHelper.ConvertToStringWithRarityList(manualModNames.Value, new Vector2(0f, 9999f)); extendedDungeonFlow.LevelMatchingProperties.planetNames = ConfigHelper.ConvertToStringWithRarityList(manualLevelNames.Value, new Vector2(0f, 9999f)); extendedDungeonFlow.LevelMatchingProperties.currentRoutePrice = ConfigHelper.ConvertToVector2WithRarityList(dynamicRoutePrices.Value, new Vector2(0f, 9999f)); extendedDungeonFlow.LevelMatchingProperties.levelTags = ConfigHelper.ConvertToStringWithRarityList(dynamicLevelTags.Value, new Vector2(0f, 9999f)); foreach (StringWithRarity item in ConfigHelper.ConvertToStringWithRarityList(dynamicLevelTags.Value, new Vector2(0f, 9999f))) { DebugHelper.Log(item.Name + " | " + item.Rarity, DebugType.Developer); } if (extendedDungeonFlow.ContentType == ContentType.Vanilla) { ConfigLoader.debugDungeonsString = ConfigLoader.debugDungeonsString + extendedDungeonFlow.DungeonName + "(" + ((Object)extendedDungeonFlow.DungeonFlow).name + "), "; } else if (extendedDungeonFlow.ContentType == ContentType.Custom) { ConfigLoader.debugDungeonsString = ConfigLoader.debugDungeonsString + extendedDungeonFlow.DungeonName + ", "; } } else { string text2 = "The author of this content has chosen not to allow for LethalLevelLoader to generate a custom configuration template for them.\n"; text2 += "This is likely due to said content author providing alternative configuration options in their own Config."; enableContentConfiguration = BindValue("Content Author Disabled Automatic Configuration File Warning", text2, genericValue: false); } } } public class ExtendedLevelConfig : ConfigTemplate { public ConfigEntry enableContentConfiguration; public ConfigEntry routePrice; public ConfigEntry daySpeedMultiplier; public ConfigEntry doesPlanetHaveTime; public ConfigEntry isLevelHidden; public ConfigEntry isLevelRegistered; public ConfigEntry minScrapItemSpawns; public ConfigEntry maxScrapItemSpawns; public ConfigEntry minTotalScrapValue; public ConfigEntry maxTotalScrapValue; public ConfigEntry scrapOverrides; public ConfigEntry maxInsideEnemyPowerCount; public ConfigEntry maxOutsideDaytimeEnemyPowerCount; public ConfigEntry maxOutsideNighttimeEnemyPowerCount; public ConfigEntry insideEnemiesOverrides; public ConfigEntry outsideDaytimeEnemiesOverrides; public ConfigEntry outsideNighttimeEnemiesOverrides; public ConfigEntry disabledWarning; public ExtendedLevelConfig(ConfigFile newConfigFile, string newCategory, int sortingPriority) : base(newConfigFile, newCategory, sortingPriority) { } public void BindConfigs(ExtendedLevel extendedLevel) { //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) SelectableLevel selectableLevel = extendedLevel.SelectableLevel; if (extendedLevel.GenerateAutomaticConfigurationOptions) { enableContentConfiguration = BindValue("Enable Content Configuration", "Enable This To Utilise Any Of The Configuration Options For '" + extendedLevel.NumberlessPlanetName + "'", genericValue: false); subCategory = "General Settings - "; routePrice = BindValue("Planet Route Price", "Override The Route Price For This Level.", extendedLevel.RoutePrice); daySpeedMultiplier = BindValue("Day Speed Multiplier", "Override The Day Speed Multiplier For This Level.", selectableLevel.DaySpeedMultiplier); doesPlanetHaveTime = BindValue("Does Planet Have Time", "Override If Time Passes In This Level.", selectableLevel.planetHasTime); isLevelHidden = BindValue("Is Level Hidden In Terminal", "Override If The Level Is Listed In The Moons Catalogue", extendedLevel.IsRouteHidden); isLevelRegistered = BindValue("Is Level Registered In Terminal", "Override If The Level Is Registered In The Terminal. Use This To Disable Specific Levels (Only Works For Custom Levels)", genericValue: true); subCategory = "Scrap Settings - "; minScrapItemSpawns = BindValue("Minimum Scrap Item Spawns", "Override How Many Item's Will Spawn In This Level.", selectableLevel.minScrap); maxScrapItemSpawns = BindValue("Maximum Scrap Item Spawns", "Override How Many Item's Can Spawn In This Level.", selectableLevel.maxScrap); minTotalScrapValue = BindValue("Minimum Total Scrap Value", "Override How Much Total Value The Spawned Scrap Will Amount To In This Level.", selectableLevel.minTotalScrapValue); maxTotalScrapValue = BindValue("Maximum Total Scrap Value", "Override How Much Total Value The Spawned Scrap Could Amount To In This Level.", selectableLevel.maxTotalScrapValue); scrapOverrides = BindValue("Scrap Spawning List", "Add To Or Override The Spawnable Scrap Pool. (Minimum: 0, Maximum: 100)", ConfigHelper.SpawnableItemsWithRaritiesToString(selectableLevel.spawnableScrap.ToArray())); subCategory = "Enemy Settings - "; maxInsideEnemyPowerCount = BindValue("Maximum Inside Enemy Power Count", "Override The Maximum Power Used To Spawn Enemies Inside The Dungeon.", selectableLevel.maxEnemyPowerCount); maxOutsideDaytimeEnemyPowerCount = BindValue("Maximum Outside, Daytime Enemy Power Count", "Override The Maximum Power Used To Spawn Enemies Outside During The Day.", selectableLevel.maxDaytimeEnemyPowerCount); maxOutsideNighttimeEnemyPowerCount = BindValue("Maximum Outside, Nighttime Enemy Power Count", "Override The Maximum Power Used To Spawn Enemies Outside During The Night.", selectableLevel.maxOutsideEnemyPowerCount); insideEnemiesOverrides = BindValue("Inside Enemies Spawning List", "Add To Or Override The Inside Enemy Spawn Pool. (Minimum: 0, Maximum: 100)", ConfigHelper.SpawnableEnemiesWithRaritiesToString(selectableLevel.Enemies.ToArray())); outsideDaytimeEnemiesOverrides = BindValue("Outside Daytime Enemies Spawning List", "Add To Or Override The Outside, Daytime Enemy Spawn Pool. (Minimum: 0, Maximum: 100)", ConfigHelper.SpawnableEnemiesWithRaritiesToString(selectableLevel.DaytimeEnemies.ToArray())); outsideNighttimeEnemiesOverrides = BindValue("Outside Nighttime Enemies Spawning List", "Add To Or Override The Outside, Nighttime Enemy Spawn Pool. (Minimum: 0, Maximum: 100)", ConfigHelper.SpawnableEnemiesWithRaritiesToString(selectableLevel.OutsideEnemies.ToArray())); if (!enableContentConfiguration.Value) { return; } extendedLevel.RoutePrice = routePrice.Value; selectableLevel.DaySpeedMultiplier = daySpeedMultiplier.Value; selectableLevel.planetHasTime = doesPlanetHaveTime.Value; extendedLevel.IsRouteHidden = isLevelHidden.Value; if (!isLevelRegistered.Value) { foreach (CompatibleNoun item in new List(TerminalManager.routeKeyword.compatibleNouns)) { if ((Object)(object)item.result == (Object)(object)extendedLevel.RouteNode) { List list = TerminalManager.routeKeyword.compatibleNouns.ToList(); list.Remove(item); TerminalManager.routeKeyword.compatibleNouns = list.ToArray(); extendedLevel.IsRouteRemoved = true; } } } selectableLevel.minScrap = minScrapItemSpawns.Value; selectableLevel.maxScrap = maxScrapItemSpawns.Value; selectableLevel.minTotalScrapValue = minTotalScrapValue.Value; selectableLevel.maxTotalScrapValue = maxTotalScrapValue.Value; selectableLevel.spawnableScrap = ConfigHelper.ConvertToSpawnableItemWithRarityList(scrapOverrides.Value, new Vector2(0f, 100f)); selectableLevel.maxEnemyPowerCount = maxInsideEnemyPowerCount.Value; selectableLevel.maxDaytimeEnemyPowerCount = maxOutsideDaytimeEnemyPowerCount.Value; selectableLevel.maxOutsideEnemyPowerCount = maxOutsideNighttimeEnemyPowerCount.Value; selectableLevel.Enemies = ConfigHelper.ConvertToSpawnableEnemyWithRarityList(insideEnemiesOverrides.Value, new Vector2(0f, 100f)); selectableLevel.DaytimeEnemies = ConfigHelper.ConvertToSpawnableEnemyWithRarityList(outsideDaytimeEnemiesOverrides.Value, new Vector2(0f, 100f)); selectableLevel.OutsideEnemies = ConfigHelper.ConvertToSpawnableEnemyWithRarityList(outsideNighttimeEnemiesOverrides.Value, new Vector2(0f, 100f)); ConfigLoader.debugLevelsString = ConfigLoader.debugLevelsString + selectableLevel.PlanetName + ", "; } else { string text = "The author of this content has chosen not to allow for LethalLevelLoader to generate a custom configuration template for them.\n"; text += "This is likely due to said content author providing alternative configuration options in their own Config."; enableContentConfiguration = BindValue("Content Author Disabled Automatic Configuration File Warning", text, genericValue: false); } } } public abstract class ConfigTemplate { public ConfigFile configFile; public string subCategory = string.Empty; public int sortingPriority; [CompilerGenerated] private string k__BackingField = string.Empty; public string Category { get { return GetSortingSpaces() + k__BackingField; } [CompilerGenerated] set { k__BackingField = value; } } public ConfigTemplate(ConfigFile newConfigFile, string newCategory, int newSortingPriority) { configFile = newConfigFile; Category = newCategory; sortingPriority = newSortingPriority; } public ConfigEntry BindValue(string configTitle, string configDescription, T genericValue) { return configFile.Bind(Category, subCategory + configTitle, genericValue, configDescription); } public string GetSortingSpaces() { string text = string.Empty; for (int i = 0; i < sortingPriority; i++) { text += "\u200b"; } return text; } } internal static class ContentRestorer { internal static readonly Dictionary cachedNetworkPrefabs = new Dictionary(); internal static readonly HashSet objectsToDestroy = new HashSet(); internal static void RestoreVanillaDungeonAssetReferences(ExtendedDungeonFlow extendedDungeonFlow) { if ((Object)(object)extendedDungeonFlow == (Object)null) { DebugHelper.LogError("Tried To Restore Vanilla Assets For Null ExtendedDungeonFlow! Returning!", DebugType.User); return; } if ((Object)(object)extendedDungeonFlow.DungeonFlow == (Object)null) { DebugHelper.LogError("Tried To Restore Vanilla Assets For ExtendedDungeonFlow " + extendedDungeonFlow.DungeonName + " But DungeonFlow Was Null! Returning!", DebugType.User); return; } List list = new List(); Tile[] allTiles = extendedDungeonFlow.AllTiles; foreach (Tile val in allTiles) { ((Component)val).GetComponentsInChildren(true, list); foreach (RandomScrapSpawn item in list) { TryRestoreRandomScrapSpawn(item); } RestoreAudioAssetReferencesInParent(((Component)val).gameObject); } foreach (RandomMapObject randomMapObject in extendedDungeonFlow.DungeonFlow.GetRandomMapObjects(extendedDungeonFlow.AllTiles)) { RestoreRandomMapObject(randomMapObject); } } internal static void RestoreVanillaLevelAssetReferences(ExtendedLevel extendedLevel) { //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Expected O, but got Unknown if ((Object)(object)extendedLevel == (Object)null) { DebugHelper.LogError("Tried To Restore Vanilla Assets For Null ExtendedLevel! Returning!", DebugType.User); return; } if (extendedLevel.ContentType == ContentType.External) { return; } if ((Object)(object)extendedLevel.SelectableLevel == (Object)null) { DebugHelper.LogError("Tried To Restore Vanilla Assets For ExtendedLevel " + extendedLevel.NumberlessPlanetName + " But SelectableLevel Was Null! Returning!", DebugType.User); return; } DebugHelper.Log("Restoring Vanilla References for SelectableLevel: " + ((Object)extendedLevel.SelectableLevel).name, DebugType.IAmBatby); foreach (SpawnableItemWithRarity item2 in extendedLevel.SelectableLevel.spawnableScrap) { Item spawnableItem = item2?.spawnableItem; if ((Object)(object)spawnableItem == (Object)null) { continue; } if ((Object)(object)spawnableItem.spawnPrefab != (Object)null) { for (int i = 0; i < item2.spawnableItem.spawnPositionTypes?.Count; i++) { ItemGroup targetItemGroup = item2.spawnableItem.spawnPositionTypes[i]; if ((Object)(object)targetItemGroup != (Object)null) { ItemGroup val = OriginalContent.ItemGroups.Find((ItemGroup itemGroup) => string.Equals(((Object)itemGroup).name, ((Object)targetItemGroup).name, StringComparison.Ordinal)); if ((Object)(object)val != (Object)null) { spawnableItem.spawnPositionTypes[i] = ContentRestorer.RestoreAsset((Object)(object)targetItemGroup, val, debugAction: false, destroyOnReplace: true); } } } } else { Item val2 = OriginalContent.Items.Find((Item val9) => string.Equals(((Object)val9).name, ((Object)spawnableItem).name, StringComparison.Ordinal)); if ((Object)(object)val2 != (Object)null) { item2.spawnableItem = ContentRestorer.RestoreAsset((Object)(object)spawnableItem, val2, debugAction: false, destroyOnReplace: true); } } } int num = extendedLevel.SelectableLevel.spawnableScrap.RemoveAll((SpawnableItemWithRarity val9) => val9 == null || (Object)(object)val9.spawnableItem == (Object)null || (Object)(object)val9.spawnableItem.spawnPrefab == (Object)null); if (num > 0) { DebugHelper.LogWarning($"Removed '{num}' missing or empty scrap spawns in SelectableLevel: {((Object)extendedLevel.SelectableLevel).name}", DebugType.User); } int num2 = extendedLevel.SelectableLevel.Enemies.RemoveAll(ShouldRemoveEnemyRarity); num2 += extendedLevel.SelectableLevel.OutsideEnemies.RemoveAll(ShouldRemoveEnemyRarity); num2 += extendedLevel.SelectableLevel.DaytimeEnemies.RemoveAll(ShouldRemoveEnemyRarity); if (num2 > 0) { DebugHelper.LogWarning($"Removed '{num2}' missing or empty enemy spawns in SelectableLevel: {((Object)extendedLevel.SelectableLevel).name}", DebugType.User); } OverrideEnemyRarity specialEnemy = extendedLevel.SelectableLevel.specialEnemyRarity; if (specialEnemy != null && (Object)(object)specialEnemy.overrideEnemy != (Object)null && (Object)(object)specialEnemy.overrideEnemy.enemyPrefab == (Object)null) { EnemyType val3 = OriginalContent.Enemies.Find((EnemyType enemy) => string.Equals(((Object)enemy).name, ((Object)specialEnemy.overrideEnemy).name, StringComparison.Ordinal)); if ((Object)(object)val3 == (Object)null) { extendedLevel.SelectableLevel.specialEnemyRarity = null; DebugHelper.LogWarning("Removed missing or empty OverrideEnemyRarity in SelectableLevel: " + ((Object)extendedLevel.SelectableLevel).name, DebugType.User); } else { specialEnemy.overrideEnemy = ContentRestorer.RestoreAsset((Object)(object)specialEnemy.overrideEnemy, val3, debugAction: false, destroyOnReplace: true); } } NetworkObject val4 = default(NetworkObject); if (extendedLevel.SelectableLevel.indoorMapHazards == null || extendedLevel.SelectableLevel.indoorMapHazards.Length == 0) { SpawnableMapObject[] spawnableMapObjects = extendedLevel.SelectableLevel.spawnableMapObjects; if (spawnableMapObjects != null && spawnableMapObjects.Length != 0) { List list = new List(extendedLevel.SelectableLevel.spawnableMapObjects.Length); SpawnableMapObject[] spawnableMapObjects2 = extendedLevel.SelectableLevel.spawnableMapObjects; foreach (SpawnableMapObject spawnableMapObject in spawnableMapObjects2) { if (spawnableMapObject != null && !((Object)(object)spawnableMapObject.prefabToSpawn == (Object)null) && !spawnableMapObject.prefabToSpawn.TryGetComponent(ref val4)) { IndoorMapHazardType val5 = OriginalContent.IndoorMapHazards.Find((IndoorMapHazardType mapHazard) => string.Equals(((Object)mapHazard.prefabToSpawn).name, ((Object)spawnableMapObject.prefabToSpawn).name, StringComparison.Ordinal)); if ((Object)(object)val5 != (Object)null) { IndoorMapHazard item = new IndoorMapHazard { hazardType = val5, numberToSpawn = spawnableMapObject.numberToSpawn }; list.Add(item); } } } extendedLevel.SelectableLevel.indoorMapHazards = list.ToArray(); if (list.Count > 0) { DebugHelper.Log($"Converted '{list.Count}' SpawnableMapObjects to IndoorMapHazard spawns in SelectableLevel: {((Object)extendedLevel.SelectableLevel).name}", DebugType.Developer); } goto IL_06db; } } IndoorMapHazard[] indoorMapHazards = extendedLevel.SelectableLevel.indoorMapHazards; if (indoorMapHazards != null && indoorMapHazards.Length != 0) { List list2 = extendedLevel.SelectableLevel.indoorMapHazards.ToList(); foreach (IndoorMapHazard indoorMapHazard in list2) { if (indoorMapHazard != null && !((Object)(object)indoorMapHazard.hazardType == (Object)null) && (!((Object)(object)indoorMapHazard.hazardType.prefabToSpawn != (Object)null) || !indoorMapHazard.hazardType.prefabToSpawn.TryGetComponent(ref val4))) { IndoorMapHazardType val6 = OriginalContent.IndoorMapHazards.Find((IndoorMapHazardType mapHazard) => string.Equals(((Object)mapHazard).name, ((Object)indoorMapHazard.hazardType).name, StringComparison.Ordinal)); if ((Object)(object)val6 != (Object)null) { indoorMapHazard.hazardType = ContentRestorer.RestoreAsset((Object)(object)indoorMapHazard.hazardType, val6, debugAction: false, destroyOnReplace: true); } } } NetworkObject val9 = default(NetworkObject); int num4 = list2.RemoveAll((IndoorMapHazard mapHazard) => mapHazard == null || (Object)(object)mapHazard.hazardType == (Object)null || (Object)(object)mapHazard.hazardType.prefabToSpawn == (Object)null || !mapHazard.hazardType.prefabToSpawn.TryGetComponent(ref val9)); if (num4 > 0) { extendedLevel.SelectableLevel.indoorMapHazards = list2.ToArray(); DebugHelper.LogWarning($"Removed '{num4}' missing or empty IndoorMapHazard spawns in SelectableLevel: {((Object)extendedLevel.SelectableLevel).name}", DebugType.User); } } goto IL_06db; IL_06db: List list3 = extendedLevel.SelectableLevel.spawnableOutsideObjects.ToList(); foreach (SpawnableOutsideObjectWithRarity spawnableOutsideObject in list3) { if (spawnableOutsideObject != null && !((Object)(object)spawnableOutsideObject.spawnableObject == (Object)null) && !((Object)(object)spawnableOutsideObject.spawnableObject.prefabToSpawn != (Object)null)) { SpawnableOutsideObject val7 = OriginalContent.SpawnableOutsideObjects.Find((SpawnableOutsideObject outsideObject) => string.Equals(((Object)outsideObject).name, ((Object)spawnableOutsideObject.spawnableObject).name, StringComparison.Ordinal)); if ((Object)(object)val7 != (Object)null) { spawnableOutsideObject.spawnableObject = ContentRestorer.RestoreAsset((Object)(object)spawnableOutsideObject.spawnableObject, val7, debugAction: false, destroyOnReplace: true); } } } int num5 = list3.RemoveAll((SpawnableOutsideObjectWithRarity outsideObject) => outsideObject == null || (Object)(object)outsideObject.spawnableObject == (Object)null || (Object)(object)outsideObject.spawnableObject.prefabToSpawn == (Object)null); if (num5 > 0) { extendedLevel.SelectableLevel.spawnableOutsideObjects = list3.ToArray(); DebugHelper.LogWarning($"Removed '{num5}' missing or empty SpawnableOutsideObject spawns in SelectableLevel: {((Object)extendedLevel.SelectableLevel).name}", DebugType.User); } if ((Object)(object)extendedLevel.SelectableLevel.levelAmbienceClips != (Object)null) { LevelAmbienceLibrary val8 = OriginalContent.LevelAmbienceLibraries.Find((LevelAmbienceLibrary ambienceLibrary) => string.Equals(((Object)ambienceLibrary).name, ((Object)extendedLevel.SelectableLevel.levelAmbienceClips).name, StringComparison.Ordinal)); if ((Object)(object)val8 != (Object)null) { extendedLevel.SelectableLevel.levelAmbienceClips = ContentRestorer.RestoreAsset((Object)(object)extendedLevel.SelectableLevel.levelAmbienceClips, val8, debugAction: false, destroyOnReplace: true); } } static bool ShouldRemoveEnemyRarity(SpawnableEnemyWithRarity enemyRarity) { if (enemyRarity == null || (Object)(object)enemyRarity.enemyType == (Object)null) { return true; } if ((Object)(object)enemyRarity.enemyType.enemyPrefab != (Object)null) { return false; } EnemyType val9 = OriginalContent.Enemies.Find((EnemyType enemy) => string.Equals(((Object)enemy).name, ((Object)enemyRarity.enemyType).name, StringComparison.Ordinal)); if ((Object)(object)val9 == (Object)null) { return true; } enemyRarity.enemyType = ContentRestorer.RestoreAsset((Object)(object)enemyRarity.enemyType, val9, debugAction: false, destroyOnReplace: true); return false; } } internal static void RestoreVanillaItemAssetReferences() { EnemyType val = OriginalContent.Enemies.Find((EnemyType enemy) => string.Equals(enemy.enemyName, "RadMech", StringComparison.Ordinal)); if ((Object)(object)val != (Object)null) { LungProp[] array = Resources.FindObjectsOfTypeAll(); foreach (LungProp val2 in array) { if ((Object)(object)val2.radMechEnemyType == (Object)(object)val) { continue; } if ((Object)(object)val2.radMechEnemyType == (Object)null) { val2.radMechEnemyType = val; } else if (string.Equals(((Object)val2.radMechEnemyType).name, "RadMech", StringComparison.Ordinal)) { if ((Object)(object)val2.radMechEnemyType.enemyPrefab != (Object)null || (Object)(object)val2.radMechEnemyType.nestSpawnPrefab != (Object)null) { DebugHelper.LogWarning("LungProp " + ((Object)val2).name + " Bundles An Additional RadMech Enemy! Fields radMechEnemyType And nestSpawnPrefab Should Be Empty!", DebugType.User); } val2.radMechEnemyType = ContentRestorer.RestoreAsset((Object)(object)val2.radMechEnemyType, val, debugAction: false, destroyOnReplace: true); } } } else { DebugHelper.LogError("Could Not Find Vanilla RadMech Enemy Reference To Assign To LungProp Items!", DebugType.User); } EnemyType val3 = OriginalContent.Enemies.Find((EnemyType enemy) => string.Equals(enemy.enemyName, "Masked", StringComparison.Ordinal)); if ((Object)(object)val3 != (Object)null) { HauntedMaskItem[] array2 = Resources.FindObjectsOfTypeAll(); foreach (HauntedMaskItem val4 in array2) { if ((Object)(object)val4.mimicEnemy == (Object)(object)val3) { continue; } if ((Object)(object)val4.mimicEnemy == (Object)null) { val4.mimicEnemy = val3; } else if (string.Equals(((Object)val4.mimicEnemy).name, "MaskedPlayerEnemy", StringComparison.Ordinal)) { if ((Object)(object)val4.mimicEnemy.enemyPrefab != (Object)null) { DebugHelper.LogWarning("HauntedMaskItem " + ((Object)val4).name + " Bundles An Additional Masked Enemy! Field mimicEnemy Should Be Empty!", DebugType.User); } val4.mimicEnemy = ContentRestorer.RestoreAsset((Object)(object)val4.mimicEnemy, val3, debugAction: false, destroyOnReplace: true); } } } else { DebugHelper.LogError("Could Not Find Vanilla Masked Enemy Reference To Assign To HauntedMaskItem Items!", DebugType.User); } } internal static void RestoreAudioAssetReferencesInParent(GameObject parent) { AudioSource[] componentsInChildren = parent.GetComponentsInChildren(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val.outputAudioMixerGroup == (Object)null) { if (((Object)((Component)val).gameObject).name != null) { DebugHelper.LogWarning("Audio Restoration Warning: " + ((Object)((Component)val).gameObject).name + " Has Missing AudioMixerGroup", DebugType.Developer); } } else { TryRestoreAudioSource(val); } } AudioReverbTrigger[] componentsInChildren2 = parent.GetComponentsInChildren(true); foreach (AudioReverbTrigger val2 in componentsInChildren2) { if ((Object)(object)val2.reverbPreset == (Object)null) { DebugHelper.LogWarning("Audio Restoration Warning: " + ((Object)((Component)val2).gameObject).name + " Has Missing ReverbPreset", DebugType.Developer); } else { foreach (ReverbPreset reverbPreset in OriginalContent.ReverbPresets) { if ((Object)(object)reverbPreset != (Object)null && ((Object)reverbPreset).name != null && ((Object)val2.reverbPreset).name == ((Object)reverbPreset).name) { DebugHelper.Log("Restoring ReverbPreset: " + ((Object)val2.reverbPreset).name + " In AudioReverbTrigger: " + ((Object)((Component)val2).gameObject).name, DebugType.Developer); val2.reverbPreset = ContentRestorer.RestoreAsset((Object)(object)val2.reverbPreset, reverbPreset, debugAction: false, destroyOnReplace: true); } } } switchToAudio[] audioChanges = val2.audioChanges; foreach (switchToAudio val3 in audioChanges) { if ((Object)(object)val3.audio == (Object)null) { DebugHelper.LogWarning("Audio Restoration Warning: " + ((Object)((Component)val2).gameObject).name + " Has Missing AudioChange AudioSource", DebugType.Developer); } else { TryRestoreAudioSource(val3.audio); } if ((Object)(object)val3.changeToClip == (Object)null) { DebugHelper.LogWarning("Audio Restoration Warning: " + ((Object)((Component)val2).gameObject).name + " Has Missing AudioChange AudioClip", DebugType.Developer); } } } } internal static void TryRestoreAudioSource(AudioSource audioSource) { if (!((Object)(object)audioSource.outputAudioMixerGroup == (Object)null)) { AudioMixerGroup targetMixerGroup = audioSource.outputAudioMixerGroup; AudioMixerGroup val = OriginalContent.AudioMixerGroups.Find((AudioMixerGroup vanillaMixerGroup) => string.Equals(((Object)vanillaMixerGroup).name, ((Object)targetMixerGroup).name, StringComparison.Ordinal)); if ((Object)(object)val != (Object)null) { audioSource.outputAudioMixerGroup = val; } } } internal static void TryRestoreShader(Material customMaterial, Shader vanillaShader, LocalKeyword[] enabledKeywords = null) { if (!((Object)(object)vanillaShader == (Object)null) && !((Object)(object)customMaterial == (Object)null) && !((Object)(object)customMaterial.shader == (Object)null) && !((Object)(object)customMaterial.shader == (Object)(object)vanillaShader) && !string.IsNullOrEmpty(((Object)customMaterial.shader).name) && string.Equals(((Object)customMaterial.shader).name, ((Object)vanillaShader).name, StringComparison.Ordinal)) { customMaterial.shader = vanillaShader; if (enabledKeywords != null) { customMaterial.enabledKeywords = enabledKeywords; } } } internal static bool TryRestoreNetworkPrefab(GameObject prefab, out GameObject registeredPrefab) { registeredPrefab = null; if ((Object)(object)prefab == (Object)null || string.IsNullOrEmpty(((Object)prefab).name)) { return false; } if (!cachedNetworkPrefabs.TryGetValue(((Object)prefab).name, out registeredPrefab)) { foreach (NetworkPrefab prefab2 in NetworkManager.Singleton.NetworkConfig.Prefabs.m_Prefabs) { if (string.Equals(((Object)prefab2.Prefab).name, ((Object)prefab).name, StringComparison.Ordinal)) { cachedNetworkPrefabs.Add(((Object)prefab).name, prefab2.Prefab); registeredPrefab = ContentRestorer.RestoreAsset((Object)(object)prefab, prefab2.Prefab, debugAction: false, destroyOnReplace: true); break; } } } return (Object)(object)registeredPrefab != (Object)null; } internal static bool TryRestoreSpawnSyncedObject(SpawnSyncedObject spawnSyncedObject) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown if ((Object)(object)spawnSyncedObject == (Object)null) { return false; } if ((Object)(object)spawnSyncedObject.spawnPrefab == (Object)(object)((Component)spawnSyncedObject).gameObject) { DebugHelper.LogWarning("SpawnSyncedObject '" + ((Object)spawnSyncedObject).name + "' in '" + ((Object)((Component)spawnSyncedObject).transform.root).name + "' contains a reference to itself! Replacing with a blank object to avoid issues...", DebugType.Developer); spawnSyncedObject.spawnPrefab = new GameObject(((Object)spawnSyncedObject).name); } if (TryRestoreNetworkPrefab(spawnSyncedObject.spawnPrefab, out var registeredPrefab)) { spawnSyncedObject.spawnPrefab = registeredPrefab; return true; } return false; } internal static bool TryRestoreRandomScrapSpawn(RandomScrapSpawn randomScrapSpawn) { if ((Object)(object)randomScrapSpawn != (Object)null && (Object)(object)randomScrapSpawn.spawnableItems != (Object)null && !string.IsNullOrEmpty(((Object)randomScrapSpawn.spawnableItems).name)) { ItemGroup val = OriginalContent.ItemGroups.Find((ItemGroup itemGroup) => string.Equals(((Object)itemGroup).name, ((Object)randomScrapSpawn.spawnableItems).name, StringComparison.Ordinal)); if ((Object)(object)val != (Object)null) { randomScrapSpawn.spawnableItems = ContentRestorer.RestoreAsset((Object)(object)randomScrapSpawn.spawnableItems, val, debugAction: false, destroyOnReplace: true); return true; } } return false; } internal static void RestoreRandomMapObject(RandomMapObject randomMapObject) { if ((Object)(object)randomMapObject == (Object)null) { return; } if (randomMapObject.spawnablePrefabs == null) { randomMapObject.spawnablePrefabs = new List(); } for (int i = 0; i < randomMapObject.spawnablePrefabs.Count; i++) { GameObject spawnablePrefab = randomMapObject.spawnablePrefabs[i]; if ((Object)(object)spawnablePrefab == (Object)null) { DebugHelper.LogWarning("Map Object Restoration Warning: " + ((Object)randomMapObject).name + " Has Missing RandomMapObject", DebugType.Developer); randomMapObject.spawnablePrefabs.RemoveAt(i--); continue; } IndoorMapHazardType val = OriginalContent.IndoorMapHazards.Find((IndoorMapHazardType hazardType) => (Object)(object)hazardType != (Object)null && (Object)(object)hazardType.prefabToSpawn != (Object)null && ((Object)hazardType.prefabToSpawn).name == ((Object)spawnablePrefab).name); if ((Object)(object)val != (Object)null) { randomMapObject.spawnablePrefabs[i] = ContentRestorer.RestoreAsset((Object)(object)spawnablePrefab, val.prefabToSpawn, debugAction: false, destroyOnReplace: true); } } } internal static void RestoreBridgeTrigger(BridgeTrigger bridgeTrigger) { if ((Object)(object)bridgeTrigger == (Object)null) { return; } if (bridgeTrigger.giantTypes == null || bridgeTrigger.giantTypes.Length == 0) { bridgeTrigger.giantTypes = EnemyManager.GiantEnemyTypes.ToArray(); return; } List list = bridgeTrigger.giantTypes.ToList(); for (int i = 0; i < list.Count; i++) { EnemyType val = bridgeTrigger.giantTypes[i]; if ((Object)(object)val == (Object)null) { DebugHelper.LogWarning("Bridge Trigger Object Restoration Warning: " + ((Object)bridgeTrigger).name + " Has Missing EnemyType", DebugType.Developer); list.RemoveAt(i--); } else { if (EnemyManager.GiantEnemyTypes.Contains(val)) { continue; } bool flag = false; foreach (EnemyType giantEnemyType in EnemyManager.GiantEnemyTypes) { if (string.Equals(((Object)val).name, ((Object)giantEnemyType).name, StringComparison.Ordinal)) { list[i] = ContentRestorer.RestoreAsset((Object)(object)list[i], giantEnemyType, debugAction: false, destroyOnReplace: true); flag = true; break; } } if (!flag) { DebugHelper.LogWarning("Bridge Trigger Object Restoration Warning: " + ((Object)bridgeTrigger).name + " Has Missing EnemyType " + ((Object)list[i]).name, DebugType.Developer); list.RemoveAt(i--); } } } } internal static T RestoreAsset(Object currentAsset, T newAsset, bool debugAction = false, bool destroyOnReplace = true) where T : Object { if (currentAsset != (Object)null && (Object)(object)newAsset != (Object)null) { if (currentAsset == (Object)(object)newAsset) { return newAsset; } if (debugAction) { DebugHelper.Log("Restoring " + ((object)currentAsset).GetType().ToString() + ": Old Asset Name: " + currentAsset.name + " , New Asset Name: ", DebugType.Developer); } if (destroyOnReplace) { objectsToDestroy.Add(currentAsset); } } else { DebugHelper.LogWarning("Asset Restoration Failed, Null Reference Found!", DebugType.Developer); } return newAsset; } internal static void DestroyRestoredAssets(bool debugAction = false) { foreach (Object item in objectsToDestroy) { if (!(item == (Object)null)) { if (debugAction) { DebugHelper.Log("Destroying: " + item.name, DebugType.Developer); } Object.DestroyImmediate(item); } } objectsToDestroy.Clear(); } } } namespace LethalLevelLoader.NetworkStructs { public struct NetworkItemReference : INetworkSerializable { private uint m_NetworkItemObjectId; private const uint s_NullId = uint.MaxValue; private static List Prefabs => LethalLevelLoaderNetworkManager.networkManager.NetworkConfig.Prefabs.m_Prefabs; public uint NetworkItemObjectId { readonly get { return m_NetworkItemObjectId; } internal set { m_NetworkItemObjectId = value; } } public NetworkItemReference(Item item) { if ((Object)(object)item == (Object)null) { m_NetworkItemObjectId = uint.MaxValue; return; } if ((Object)(object)item.spawnPrefab == (Object)null || !Object.op_Implicit((Object)(object)item.spawnPrefab.GetComponent())) { throw new ArgumentException(((Object)item).name + "'s Prefab or Prefab GrabbableObject is Missing!"); } m_NetworkItemObjectId = GetIdHashFromItem(item); } public readonly bool TryGet(out Item item, NetworkManager _ = null) { item = Resolve(this); return (Object)(object)item != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Item Resolve(NetworkItemReference networkItemRef) { if (networkItemRef.m_NetworkItemObjectId == uint.MaxValue) { return null; } return GetItemFromNetworkPrefabIdHash(networkItemRef.m_NetworkItemObjectId); } public static implicit operator Item(NetworkItemReference networkItemRef) { return Resolve(networkItemRef); } public static implicit operator NetworkItemReference(Item item) { return new NetworkItemReference(item); } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer*)(&serializer))->SerializeValue(ref m_NetworkItemObjectId, default(ForPrimitives)); } private static Item GetItemFromNetworkPrefabIdHash(uint idHash) { GrabbableObject val = default(GrabbableObject); for (int i = 0; i < Prefabs.Count; i++) { if (Prefabs[i].SourcePrefabGlobalObjectIdHash == idHash && Prefabs[i].Prefab.TryGetComponent(ref val)) { return val.itemProperties; } } return null; } private static uint GetIdHashFromItem(Item item) { for (int i = 0; i < Prefabs.Count; i++) { if ((Object)(object)Prefabs[i].Prefab == (Object)(object)item.spawnPrefab) { return Prefabs[i].SourcePrefabGlobalObjectIdHash; } } return 0u; } } } namespace LethalLevelLoader.Compatibility { internal static class DawnLibCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.github.teamxiaolan.dawnlib"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void RegisterDawnExtendedLevels() { foreach (DawnMoonInfo value in ((Registry)(object)LethalContent.Moons).Values) { if (((DawnBaseInfo)(object)value).Key.IsVanilla() || ((DawnBaseInfo)(object)value).HasTag(NamespacedKey.From("dawn_lib", "is_external"))) { continue; } ExtendedMod extendedMod = ExtendedMod.Create(ConvertToLLLFormat(((DawnBaseInfo)(object)value).Key.Namespace)); ExtendedLevel extendedLevel = ExtendedLevel.Create(value.Level); extendedLevel.RouteNode = value.RouteNode; extendedLevel.RouteConfirmNode = value.ReceiptNode; extendedLevel.RoutePrice = value.DawnPurchaseInfo.Cost.Provide(); PatchedContent.AllLevelSceneNames.AddRange(value.Scenes.ConvertAll((IMoonSceneInfo sceneInfo) => sceneInfo.SceneName)); extendedLevel.ContentType = ContentType.External; extendedLevel.Initialize(string.Empty, generateTerminalAssets: true); ((Object)extendedLevel).name = extendedLevel.NumberlessPlanetName + "ExtendedLevel"; foreach (NamespacedKey item in ((DawnBaseInfo)(object)value).AllTags()) { string text = ConvertToLLLFormat(item.Key); if (extendedLevel.TryAddTag(text)) { DebugHelper.Log("Added tag: " + text, DebugType.Developer); } } extendedLevel.GenerateAutomaticConfigurationOptions = false; extendedLevel.IsRouteRemoved = true; PatchedContent.ExtendedLevels.Add(extendedLevel); extendedMod.RegisterExtendedContent(extendedLevel); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void RefreshLocalClientBundleState(int state) { if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)) { PlayerControllerReference val = PlayerControllerReference.op_Implicit(GameNetworkManager.Instance.localPlayerController); if (Enum.IsDefined(typeof(BundleState), state)) { NetworkSingleton.Instance.PlayerSetBundleStateRpc(val, (BundleState)state); } } } internal static string ConvertToLLLFormat(string dawnFormatString) { string text = string.Empty; string[] array = dawnFormatString.Split('_', StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { text = text + char.ToUpperInvariant(text2[0]) + text2.Substring(1); } return text; } } internal static class DeepSewersCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("MW.MagicWesleyInteriors"); _enabled = valueOrDefault; } return _enabled.Value; } } internal static void FixDeepSewersGeneration() { AssetBundleLoader.AddOnExtendedModLoadedListener(delegate(ExtendedMod extendedMod) { ExtendedDungeonFlow extendedDungeonFlow = extendedMod.ExtendedDungeonFlows.Find((ExtendedDungeonFlow extendedDungeonFlow2) => string.Equals(((Object)extendedDungeonFlow2).name, "DeepSewersExtended", StringComparison.Ordinal)); if ((Object)(object)extendedDungeonFlow != (Object)null && extendedDungeonFlow.AllTiles.Length != 0) { Tile val = extendedDungeonFlow.AllTiles[0]; if ((Object)(object)val != (Object)null) { val.OverrideAutomaticTileBounds = false; val.RecalculateBounds(); } } }, "Magic Wesley", "Magic WesleysMod"); } } internal static class LethalLibCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("evaisa.lethallib"); _enabled = valueOrDefault; } return _enabled.Value; } } [HarmonyPrepare] private static void PrepareLethalLibCompatibility(MethodBase original) { if (original == null) { DebugHelper.Log("LethalLib found! Enabling compatibility patches...", DebugType.User); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] [HarmonyPatch(typeof(Dungeon), "RoundManager_GenerateNewFloor")] [HarmonyTranspiler] [HarmonyPriority(200)] internal static IEnumerable Dungeon_GenerateNewFloor_Transpiler(IEnumerable instructions) { //IL_0002: 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_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null) }); if (val.IsInvalid) { DebugHelper.LogWarning("Could not match 'orig(self)' call in 'Dungeon.RoundManager_GenerateNewFloor' hook.", DebugType.User); return instructions; } List list = val.InstructionsInRange(val.Pos, val.Pos + 2); list.Add(new CodeInstruction(OpCodes.Ret, (object)null)); return val.Start().Insert((IEnumerable)list).InstructionEnumeration(); } } internal static class LethalPerformanceCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("LethalPerformance"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] [HarmonyPatch(typeof(Patch_NavMeshSurface), "FindDungeon")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void MoonCachingPatchFindDungeon_Postfix(ref bool __result) { if (__result) { return; } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (!((Object)(object)currentExtendedLevel == (Object)null) && currentExtendedLevel.ContentType != ContentType.External && !((Object)(object)currentExtendedLevel.SelectableLevel == (Object)null) && currentExtendedLevel.SelectableLevel.spawnEnemiesAndScrap) { LevelLoader.RestoreRuntimeDungeon(); if ((Object)(object)Patches.RoundManager != (Object)null) { MoonCachingPatch.s_RuntimeDungeon.SetInstance(Patches.RoundManager.dungeonGenerator); } __result = (Object)(object)MoonCachingPatch.s_RuntimeDungeon.Instance != (Object)null; } } } } namespace LethalLevelLoader.AssetBundles { public enum AssetBundleGroupLoadedStatus { Unloaded, Partial, Loaded } public enum AssetBundleGroupLoadingStatus { None, Mixed, Loading, Unloading } public class AssetBundleGroup { private readonly List assetBundleInfos = new List(); public ExtendedEvent OnGroupLoaded = new ExtendedEvent(); public ExtendedEvent OnGroupUnloaded = new ExtendedEvent(); public ExtendedEvent OnGroupLoadStatusChanged = new ExtendedEvent(); public string GroupName { get; private set; } = string.Empty; public AssetBundleGroupLoadedStatus LoadedStatus { get { int num = 0; int num2 = 0; foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { if (!assetBundleInfo.IsAssetBundleLoaded) { num2++; if (num > 0) { return AssetBundleGroupLoadedStatus.Partial; } } else { num++; if (num2 > 0) { return AssetBundleGroupLoadedStatus.Partial; } } } if (num == assetBundleInfos.Count) { return AssetBundleGroupLoadedStatus.Loaded; } return AssetBundleGroupLoadedStatus.Unloaded; } } public AssetBundleGroupLoadingStatus LoadingStatus { get { AssetBundleLoadingStatus assetBundleLoadingStatus = AssetBundleLoadingStatus.None; foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { if (assetBundleInfo.ActiveLoadingStatus == AssetBundleLoadingStatus.Loading) { if (assetBundleLoadingStatus == AssetBundleLoadingStatus.Unloading) { return AssetBundleGroupLoadingStatus.Mixed; } assetBundleLoadingStatus = AssetBundleLoadingStatus.Loading; } else if (assetBundleInfo.ActiveLoadingStatus == AssetBundleLoadingStatus.Unloading) { if (assetBundleLoadingStatus == AssetBundleLoadingStatus.Loading) { return AssetBundleGroupLoadingStatus.Mixed; } assetBundleLoadingStatus = AssetBundleLoadingStatus.Unloading; } } return assetBundleLoadingStatus switch { AssetBundleLoadingStatus.Loading => AssetBundleGroupLoadingStatus.Loading, AssetBundleLoadingStatus.Unloading => AssetBundleGroupLoadingStatus.Unloading, _ => AssetBundleGroupLoadingStatus.None, }; } } public float ActiveProgress { get { float num = 0f; float num2 = 1f * (float)assetBundleInfos.Count; foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { num += assetBundleInfo.ActiveProgress; } return Mathf.InverseLerp(0f, num2, num); } } public AssetBundleGroup(AssetBundleInfo newInfo) { Initialize(newInfo); } public AssetBundleGroup(params AssetBundleInfo[] newInfos) { Initialize(newInfos); } public AssetBundleGroup(List newInfos) { Initialize(newInfos.ToArray()); } private void Initialize(params AssetBundleInfo[] newInfos) { for (int i = 0; i < newInfos.Length; i++) { if (newInfos[i] != null) { assetBundleInfos.Add(newInfos[i]); } } foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { assetBundleInfo.OnBundleLoaded.AddListener(OnAssetBundleInfoLoadChanged); assetBundleInfo.OnBundeUnloaded.AddListener(OnAssetBundleInfoLoadChanged); } GroupName = AssetBundleUtilities.GetDisplayName(assetBundleInfos); } private void OnAssetBundleInfoLoadChanged(AssetBundleInfo assetBundleInfo) { if (LoadedStatus == AssetBundleGroupLoadedStatus.Loaded) { OnGroupLoaded.Invoke(); } else if (LoadedStatus == AssetBundleGroupLoadedStatus.Unloaded) { OnGroupUnloaded.Invoke(); } else if (LoadedStatus == AssetBundleGroupLoadedStatus.Partial) { foreach (AssetBundleInfo assetBundleInfo2 in assetBundleInfos) { if (assetBundleInfo2.IsHotReloadable && assetBundleInfo2.IsAssetBundleLoaded) { break; } } OnGroupUnloaded?.Invoke(); } OnGroupLoadStatusChanged.Invoke(); } internal List GetAssetBundleInfos() { return new List(assetBundleInfos); } public List LoadAllAssets() where T : Object { List list = new List(); for (int i = 0; i < assetBundleInfos.Count; i++) { if (assetBundleInfos[i].AssetBundleMode == AssetBundleType.Standard) { list.AddRange(assetBundleInfos[i].LoadAllAssets()); } } return list; } public void TryLoadGroup() { foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { if (!assetBundleInfo.IsAssetBundleLoaded) { assetBundleInfo.TryLoadBundle(); } } } public void TryUnloadGroup() { foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { if (assetBundleInfo.IsAssetBundleLoaded) { assetBundleInfo.TryUnloadBundle(); } } } public bool ContainsAssetBundleFile(string fullFilePath) { for (int i = 0; i < assetBundleInfos.Count; i++) { if (string.Equals(assetBundleInfos[i].AssetBundleFilePath, fullFilePath, StringComparison.Ordinal)) { return true; } } return false; } public bool Contains(Object unityObject) { for (int i = 0; i < assetBundleInfos.Count; i++) { if (assetBundleInfos[i].Contains(unityObject)) { return true; } } return false; } public bool Contains(string sceneNameOrPath) { for (int i = 0; i < assetBundleInfos.Count; i++) { if (assetBundleInfos[i].Contains(sceneNameOrPath)) { return true; } } return false; } public List GetSceneNames() { List list = new List(); foreach (AssetBundleInfo assetBundleInfo in assetBundleInfos) { list.AddRange(assetBundleInfo.GetSceneNames()); } return list; } } public enum AssetBundleType { Unknown, Standard, Streaming } public enum AssetBundleLoadingStatus { None, Loading, Unloading } public class AssetBundleInfo { private bool hasInitialized; private AssetBundle assetBundle; private readonly MonoBehaviour coroutineHandler; private AssetBundleCreateRequest activeLoadRequest; private AssetBundleUnloadOperation activeUnloadRequest; private Stopwatch bundleLoadStopwatch; private Stopwatch bundleUnloadStopwatch; private List allAssetPaths; private List streamingBundleScenePaths; private List sceneNames; public ExtendedEvent OnBundleLoaded; public ExtendedEvent OnBundeUnloaded; private static readonly WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame(); public string LastLoadTime => AssetBundleUtilities.GetStopWatchTime(bundleLoadStopwatch); public float LastTimeLoaded { get; private set; } public string LastUnloadTime => AssetBundleUtilities.GetStopWatchTime(bundleUnloadStopwatch); public float LastTimeUnloaded { get; private set; } public string AssetBundleName { get; private set; } public AssetBundleType AssetBundleMode { get; private set; } public bool IsAssetBundleLoaded => (Object)(object)assetBundle != (Object)null; public string AssetBundleFileName { get; private set; } public string AssetBundleFilePath { get; private set; } public bool IsHotReloadable { get; set; } public float ActiveProgress { get { if (activeLoadRequest != null) { return ((AsyncOperation)activeLoadRequest).progress; } if (activeUnloadRequest != null) { return ((AsyncOperation)activeUnloadRequest).progress; } if (IsAssetBundleLoaded) { return 1f; } return 0f; } } public AssetBundleLoadingStatus ActiveLoadingStatus { get { if (activeLoadRequest != null) { return AssetBundleLoadingStatus.Loading; } if (activeUnloadRequest != null) { return AssetBundleLoadingStatus.Unloading; } return AssetBundleLoadingStatus.None; } } public AssetBundleInfo(MonoBehaviour newCoroutineHandler, string filePath, string fileName) { coroutineHandler = newCoroutineHandler; bundleLoadStopwatch = new Stopwatch(); bundleUnloadStopwatch = new Stopwatch(); allAssetPaths = new List(); streamingBundleScenePaths = new List(); sceneNames = new List(); AssetBundleName = "UNKNOWN"; AssetBundleFileName = fileName; AssetBundleFilePath = filePath; OnBundleLoaded = new ExtendedEvent(); OnBundeUnloaded = new ExtendedEvent(); base..ctor(); } public AssetBundleInfo(MonoBehaviour newCoroutineHandler, string filePath) : this(newCoroutineHandler, filePath, "UNKNOWN") { AssetBundleFileName = filePath.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)[^1]; } public void Initialize() { if (hasInitialized) { return; } hasInitialized = true; if ((Object)(object)assetBundle == (Object)null && AssetBundleLoader.knownSceneBundles.TryGetValue(AssetBundleFileName, out var value)) { IsHotReloadable = true; AssetBundleMode = AssetBundleType.Streaming; AssetBundleName = value.bundleName; sceneNames = Array.ConvertAll(value.scenePaths, AssetBundleUtilities.GetSceneName).ToList(); streamingBundleScenePaths.AddRange(value.scenePaths); allAssetPaths.AddRange(value.scenePaths); return; } AssetBundleName = ((Object)assetBundle).name; sceneNames = AssetBundleUtilities.GetSceneNamesFromLoadedAssetBundle(assetBundle); if (assetBundle.isStreamedSceneAssetBundle) { AssetBundleMode = AssetBundleType.Streaming; streamingBundleScenePaths = assetBundle.GetAllScenePaths().ToList(); allAssetPaths = streamingBundleScenePaths.ToList(); Dictionary knownSceneBundles = AssetBundleLoader.knownSceneBundles; string assetBundleFileName = AssetBundleFileName; LethalBundleManifest value2 = new LethalBundleManifest(); string assetBundleFilePath = AssetBundleFilePath; int num = AssetBundleFilePath.LastIndexOf(Path.DirectorySeparatorChar) + 1; value2.fileName = assetBundleFilePath.Substring(num, assetBundleFilePath.Length - num); value2.bundleName = AssetBundleName; value2.timestamp = File.GetLastWriteTime(AssetBundleFilePath).Ticks; value2.scenePaths = streamingBundleScenePaths.ToArray(); knownSceneBundles[assetBundleFileName] = value2; DebugHelper.Log("Adding " + AssetBundleFileName + " to known bundles.", DebugType.Developer); } else { AssetBundleMode = AssetBundleType.Standard; allAssetPaths = assetBundle.GetAllAssetNames().ToList(); } } public bool TryLoadBundle() { if (IsAssetBundleLoaded) { OnBundleLoaded.Invoke(this); return true; } if (!IsAssetBundleLoaded && activeLoadRequest == null) { coroutineHandler.StartCoroutine(LoadBundleRequest()); return true; } DebugHelper.Log("Failed To Load: " + AssetBundleFileName, DebugType.User); return false; } public bool TryUnloadBundle() { if (!IsHotReloadable) { return false; } if (!IsAssetBundleLoaded) { OnBundeUnloaded.Invoke(this); return true; } if (activeUnloadRequest == null) { coroutineHandler.StartCoroutine(UnloadBundleRequest()); return true; } DebugHelper.Log("Failed To Unload: " + AssetBundleFileName, DebugType.User); return false; } private IEnumerator LoadBundleRequest() { bundleLoadStopwatch = Stopwatch.StartNew(); string text = Path.Combine(Application.streamingAssetsPath, AssetBundleFilePath); activeLoadRequest = AssetBundle.LoadFromFileAsync(text); yield return activeLoadRequest; if ((Object)(object)assetBundle != (Object)null || (((AsyncOperation)activeLoadRequest).isDone && (Object)(object)activeLoadRequest.assetBundle != (Object)null)) { assetBundle = activeLoadRequest.assetBundle; if (!hasInitialized) { Initialize(); } activeLoadRequest = null; bundleLoadStopwatch.Stop(); LastTimeLoaded = Time.time; DebugHelper.Log(AssetBundleFileName + " Loaded (" + LastLoadTime + ")!", DebugType.User); OnBundleLoaded.Invoke(this); yield break; } activeLoadRequest = null; bundleLoadStopwatch.Stop(); LastTimeLoaded = Time.time; DebugHelper.LogError("AssetBundleInfo: " + AssetBundleFileName + " failed to load or is already loaded. Skipping...", DebugType.User); if (DawnLibCompatibility.Enabled) { DawnLibCompatibility.RefreshLocalClientBundleState(3); } if (!hasInitialized) { AssetBundleLoader.Instance.AssetBundleInfos.Remove(this); } } private IEnumerator UnloadBundleRequest() { bundleUnloadStopwatch = Stopwatch.StartNew(); yield return waitForEndOfFrame; activeUnloadRequest = assetBundle.UnloadAsync(true); yield return activeUnloadRequest; if (((AsyncOperation)activeUnloadRequest).isDone) { Object.Destroy((Object)(object)assetBundle); assetBundle = null; activeUnloadRequest = null; bundleUnloadStopwatch.Stop(); LastTimeUnloaded = Time.time; DebugHelper.Log(AssetBundleFileName + " Unloaded (" + LastUnloadTime + ")", DebugType.User); OnBundeUnloaded.Invoke(this); } } public List LoadAllAssets() where T : Object { AssetBundleType assetBundleMode = AssetBundleMode; if ((assetBundleMode == AssetBundleType.Unknown || assetBundleMode == AssetBundleType.Streaming) ? true : false) { return new List(); } if (!IsAssetBundleLoaded || (Object)(object)assetBundle == (Object)null) { return new List(); } return assetBundle.LoadAllAssets().ToList(); } public List GetSceneNames() { return sceneNames.ToList(); } public bool Contains(string sceneNameOrPath) { if (!IsAssetBundleLoaded) { return false; } if (AssetBundleMode == AssetBundleType.Standard) { return false; } if (string.IsNullOrEmpty(sceneNameOrPath)) { return false; } if (!streamingBundleScenePaths.Contains(sceneNameOrPath)) { return sceneNames.Contains(sceneNameOrPath); } return true; } public bool Contains(Object unityObject) { if (!IsAssetBundleLoaded) { return false; } if (AssetBundleMode == AssetBundleType.Streaming) { return false; } if (unityObject == (Object)null || unityObject.name == null) { return false; } return assetBundle.Contains(unityObject.name); } } internal sealed class AssetBundleLoader : MonoBehaviour { private static AssetBundleLoader instance; internal static DirectoryInfo pluginsFolder = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.Parent; internal List AssetBundleInfos = new List(); public static ExtendedEvent OnBeforeProcessBundles = new ExtendedEvent(); public static ExtendedEvent OnBundlesFinishedProcessing = new ExtendedEvent(); public static ExtendedEvent OnBundleLoaded = new ExtendedEvent(); public static ExtendedEvent OnBundleUnloaded = new ExtendedEvent(); private static readonly Dictionary<(string, string), List>> processedCallbacksDict = new Dictionary<(string, string), List>>(); internal static Dictionary>> onLethalBundleLoadedRequestDict = new Dictionary>>(); [CompilerGenerated] private static string k__BackingField; internal static Dictionary knownSceneBundles = new Dictionary(); private static int processedBundleCount; private static int requestedBundleCount; public static AssetBundleLoader Instance { get { if ((Object)(object)instance == (Object)null) { instance = Object.FindAnyObjectByType((FindObjectsInactive)0); } return instance; } } internal List AssetBundleGroups { get; private set; } = new List(); internal static string KnownSceneBundlesPath { get { if (string.IsNullOrEmpty(k__BackingField)) { k__BackingField = Paths.CachePath + Path.DirectorySeparatorChar + "scenebundles.txt"; } return k__BackingField; } } internal static bool AllowLoading { get; set; } = true; private void OnEnable() { instance = this; OnBundlesFinishedProcessing.AddListener(LethalLevelLoader.AssetBundleLoader.InvokeBundlesFinishedLoading); } public static bool LoadAllBundlesRequest(DirectoryInfo directory = null, string specifiedFileName = null, string specifiedFileExtension = null, ParameterEvent onProcessedCallback = null) { if (!AllowLoading) { DebugHelper.LogError("Cannot Process LoadAllBundles() Request As We Cannot Load Bundles At This Time.", DebugType.User); return false; } int num = 0; if (directory == null) { directory = pluginsFolder; } if (specifiedFileExtension == null) { specifiedFileExtension = ".*"; } if (specifiedFileName == null) { specifiedFileName = "*"; } string[] files = Directory.GetFiles(directory.FullName, specifiedFileName + specifiedFileExtension, SearchOption.AllDirectories); foreach (string text in files) { num++; } if (num == 0) { DebugHelper.Log("No Files Found, Cancelling LoadAllBundlesRequest!", DebugType.User); return false; } LoadAllBundles(directory, specifiedFileName, specifiedFileExtension, onProcessedCallback); return true; } private static IEnumerator ClearCacheRoutine() { yield return Resources.UnloadUnusedAssets(); Caching.ClearCache(); GC.Collect(); yield return Resources.UnloadUnusedAssets(); } internal static void ClearCache() { ((MonoBehaviour)Instance).StartCoroutine(ClearCacheRoutine()); } private static void LoadAllBundles(DirectoryInfo directory = null, string specifiedFileName = null, string specifiedFileExtension = null, ParameterEvent onProcessedCallback = null) { AllowLoading = false; processedBundleCount = 0; requestedBundleCount = 0; if (directory == null) { directory = pluginsFolder; } if (specifiedFileExtension == null) { specifiedFileExtension = ".*"; } if (specifiedFileName == null) { specifiedFileName = "*"; } string text = ((specifiedFileName == "*") ? string.Empty : specifiedFileName); string text2 = ((specifiedFileExtension == ".*") ? string.Empty : specifiedFileExtension); string item = text.ToLowerInvariant() + text2.ToLowerInvariant(); if (onProcessedCallback != null) { if (!processedCallbacksDict.TryGetValue((directory.FullName, item), out var value)) { processedCallbacksDict.Add((directory.FullName, item), new List>(1) { onProcessedCallback }); } else { value.Add(onProcessedCallback); } } string[] files = Directory.GetFiles(directory.FullName, specifiedFileName + specifiedFileExtension, SearchOption.AllDirectories); foreach (string text3 in files) { string text4 = "UNKNOWN"; if (text3.Contains(Path.DirectorySeparatorChar)) { text4 = text3.Substring(text3.LastIndexOf(Path.DirectorySeparatorChar) + 1); } string[] bundlesBlacklist = Settings.bundlesBlacklist; if (bundlesBlacklist != null && bundlesBlacklist.Length != 0 && Array.IndexOf(Settings.bundlesBlacklist, text4) != -1) { DebugHelper.Log("Bundle '" + text4 + "' found in blacklist, it will not be loaded...", DebugType.User); continue; } requestedBundleCount++; AssetBundleInfo assetBundleInfo = new AssetBundleInfo((MonoBehaviour)(object)Instance, text3, text4); assetBundleInfo.OnBundleLoaded.AddListener(OnAssetBundleLoadChanged); Instance.AssetBundleInfos.Add(assetBundleInfo); } if (requestedBundleCount > 0) { OnBeforeProcessBundles.Invoke(); OnBundleLoaded.AddListener(ProcessInitialBundleLoading); { foreach (AssetBundleInfo assetBundleInfo2 in Instance.AssetBundleInfos) { if (knownSceneBundles.TryGetValue(assetBundleInfo2.AssetBundleFileName, out var value2)) { if (value2.timestamp == File.GetLastWriteTime(assetBundleInfo2.AssetBundleFilePath).Ticks) { DebugHelper.Log("Skipping streaming bundle '" + value2.bundleName + "', as it will be loaded later!", DebugType.User); assetBundleInfo2.Initialize(); requestedBundleCount--; processedBundleCount++; continue; } DebugHelper.Log("Found different version of bundle '" + value2.bundleName + "', it will not be skipped.", DebugType.User); } assetBundleInfo2.TryLoadBundle(); } return; } } DebugHelper.Log("No Bundles Found!", DebugType.User); AllowLoading = true; OnBundlesFinishedProcessing.Invoke(); } private static void OnAssetBundleLoadChanged(AssetBundleInfo info) { if (info.IsAssetBundleLoaded) { OnBundleLoaded.Invoke(info); return; } OnBundleUnloaded.Invoke(info); if (Plugin.IsSetupComplete) { ClearCache(); } } private static void ProcessInitialBundleLoading(AssetBundleInfo info) { DebugHelper.Log("Processing Bundle: " + info.AssetBundleName, DebugType.IAmBatby); if (info.AssetBundleMode == AssetBundleType.Streaming) { info.IsHotReloadable = true; } processedBundleCount++; if (processedBundleCount == instance.AssetBundleInfos.Count) { DebugHelper.Log("Finished Processing Bundles!", DebugType.User); processedBundleCount = 0; OnBundleLoaded.RemoveListener(ProcessInitialBundleLoading); OnInitialBundlesProcessed(); } } private static void OnInitialBundlesProcessed() { Instance.AssetBundleGroups.Clear(); List list = new List(); Dictionary> dictionary = new Dictionary>(); List> list2 = new List>(); foreach (AssetBundleInfo assetBundleInfo in Instance.AssetBundleInfos) { List sceneNames = assetBundleInfo.GetSceneNames(); if (sceneNames.Count > 0) { foreach (string item in sceneNames) { if (!dictionary.ContainsKey(item)) { dictionary.Add(item, new List()); } } } else { list2.Add(new List { assetBundleInfo }); } } foreach (KeyValuePair> item2 in dictionary) { UniqueSceneGroup uniqueSceneGroup = new UniqueSceneGroup(item2.Key); list.Add(uniqueSceneGroup); foreach (AssetBundleInfo item3 in item2.Value) { uniqueSceneGroup.TryAdd(item3, item3.GetSceneNames()); } } foreach (AssetBundleInfo assetBundleInfo2 in Instance.AssetBundleInfos) { List sceneNames2 = assetBundleInfo2.GetSceneNames(); foreach (UniqueSceneGroup item4 in list) { if (item4.TryAdd(assetBundleInfo2, sceneNames2)) { break; } } } List> list3 = list.ConvertAll((UniqueSceneGroup s) => s.AssetBundleInfosInGroup); list3.AddRange(list2); foreach (List item5 in list3) { if (item5.Count <= 0) { continue; } AssetBundleGroup assetBundleGroup = new AssetBundleGroup(item5); Instance.AssetBundleGroups.Add(assetBundleGroup); foreach (KeyValuePair<(string, string), List>> item6 in processedCallbacksDict) { using List.Enumerator enumerator9 = assetBundleGroup.GetAssetBundleInfos().GetEnumerator(); if (!enumerator9.MoveNext()) { continue; } AssetBundleInfo current9 = enumerator9.Current; if (!current9.AssetBundleFilePath.Contains(item6.Key.Item1) || !current9.AssetBundleFileName.Contains(item6.Key.Item2)) { continue; } foreach (ParameterEvent item7 in item6.Value) { item7(assetBundleGroup); } } foreach (KeyValuePair>> item8 in onLethalBundleLoadedRequestDict) { foreach (AssetBundleInfo assetBundleInfo3 in assetBundleGroup.GetAssetBundleInfos()) { if (!string.Equals(assetBundleInfo3.AssetBundleName, item8.Key, StringComparison.Ordinal)) { continue; } AssetBundle val = null; foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (string.Equals(((Object)allLoadedAssetBundle).name, assetBundleInfo3.AssetBundleName, StringComparison.Ordinal)) { val = allLoadedAssetBundle; break; } } if (!((Object)(object)val != (Object)null)) { break; } foreach (Action item9 in item8.Value) { item9(val); } break; } } string text = "Generated New AssetBundleGroup, Contained BundleInfos Are,\n"; foreach (AssetBundleInfo assetBundleInfo4 in assetBundleGroup.GetAssetBundleInfos()) { text = text + "\n" + assetBundleInfo4.AssetBundleName; } DebugHelper.Log(text, DebugType.IAmBatby); } AllowLoading = true; OnBundlesFinishedProcessing.Invoke(); foreach (AssetBundleInfo assetBundleInfo5 in Instance.AssetBundleInfos) { assetBundleInfo5.TryUnloadBundle(); } } public static int GetAssetBundleLoadingCount() { int num = 0; foreach (AssetBundleInfo assetBundleInfo in Instance.AssetBundleInfos) { if (assetBundleInfo.ActiveLoadingStatus == AssetBundleLoadingStatus.Loading) { num++; } } return num; } private static List GetAssetBundleInfos() { return Instance.AssetBundleInfos.ToList(); } private static List GetAssetBundleInfos(AssetBundleType modeFilter) { List assetBundleInfos = GetAssetBundleInfos(); assetBundleInfos.RemoveAll((AssetBundleInfo a) => a.AssetBundleMode != modeFilter); return assetBundleInfos; } private static List GetAssetBundleInfos(bool isLoadedFilter) { List assetBundleInfos = GetAssetBundleInfos(); assetBundleInfos.RemoveAll((AssetBundleInfo a) => a.IsAssetBundleLoaded != isLoadedFilter); return assetBundleInfos; } } internal sealed class UniqueSceneGroup { private readonly List scenesInGroup = new List(); internal List AssetBundleInfosInGroup { get; } = new List(); internal string UniqueSceneName { get; private set; } = string.Empty; internal UniqueSceneGroup(string newUniqueSceneName) { UniqueSceneName = newUniqueSceneName; scenesInGroup.Add(UniqueSceneName); } internal bool TryAdd(AssetBundleInfo info, List infoScenes) { if (AssetBundleInfosInGroup.Contains(info)) { return true; } if (infoScenes.Contains(UniqueSceneName)) { Add(info, infoScenes); return true; } foreach (string infoScene in infoScenes) { if (scenesInGroup.Contains(infoScene)) { Add(info, infoScenes); return true; } } return false; } private void Add(AssetBundleInfo info, List infoScenes) { if (!AssetBundleInfosInGroup.Contains(info)) { AssetBundleInfosInGroup.Add(info); } foreach (string infoScene in infoScenes) { if (!scenesInGroup.Contains(infoScene)) { scenesInGroup.Add(infoScene); } } } } public static class AssetBundleUtilities { private static readonly Regex sceneNameRegex = new Regex("(?!.*[\\\\\\/]).+(?=\\.unity)", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled | RegexOptions.CultureInvariant); public static string GetSceneName(string scenePath) { if (string.IsNullOrEmpty(scenePath)) { return "Invalid Scene Path"; } Match match = sceneNameRegex.Match(scenePath); if (match.Success) { return match.Value; } return "Invalid Scene Path"; } public static string GetStopWatchTime(Stopwatch watch) { return $"{watch.Elapsed.TotalSeconds:0.##}s"; } internal static List GetSceneNamesFromLoadedAssetBundle(AssetBundle assetBundle) { List list = new List(); if ((Object)(object)assetBundle == (Object)null) { return list; } if (assetBundle.isStreamedSceneAssetBundle) { string[] allScenePaths = assetBundle.GetAllScenePaths(); foreach (string scenePath in allScenePaths) { list.Add(GetSceneName(scenePath)); } } else { ExtendedMod[] array = assetBundle.LoadAllAssets(); foreach (ExtendedMod extendedMod in array) { foreach (ExtendedLevel extendedLevel2 in extendedMod.ExtendedLevels) { if ((Object)(object)extendedLevel2.SelectableLevel != (Object)null && !string.IsNullOrEmpty(extendedLevel2.SelectableLevel.sceneName)) { list.Add(extendedLevel2.SelectableLevel.sceneName); } foreach (StringWithRarity sceneSelection in extendedLevel2.SceneSelections) { if (!list.Contains(sceneSelection.Name)) { list.Add(sceneSelection.Name); } } } } ExtendedLevel[] array2 = assetBundle.LoadAllAssets(); foreach (ExtendedLevel extendedLevel in array2) { foreach (StringWithRarity sceneSelection2 in extendedLevel.SceneSelections) { if (!list.Contains(sceneSelection2.Name)) { list.Add(sceneSelection2.Name); } } if ((Object)(object)extendedLevel.SelectableLevel != (Object)null && !string.IsNullOrEmpty(extendedLevel.SelectableLevel.sceneName)) { list.Add(extendedLevel.SelectableLevel.sceneName); } } } return list; } internal static string GetDisplayName(List bundleInfos) { if (bundleInfos.Count == 0) { return string.Empty; } AssetBundleInfo assetBundleInfo = null; foreach (AssetBundleInfo bundleInfo in bundleInfos) { if (assetBundleInfo == null) { assetBundleInfo = bundleInfo; } else if (bundleInfo.GetSceneNames().Count > assetBundleInfo.GetSceneNames().Count) { assetBundleInfo = bundleInfo; } else if (bundleInfo.GetSceneNames().Count == assetBundleInfo.GetSceneNames().Count && assetBundleInfo.AssetBundleMode == AssetBundleType.Streaming && bundleInfo.AssetBundleMode == AssetBundleType.Standard) { assetBundleInfo = bundleInfo; } } string text = assetBundleInfo.AssetBundleName; if (text.Contains('.')) { text = text.TrimEnd('.'); } char[] array = text.ToCharArray(); array[0] = char.ToUpperInvariant(array[0]); return new string(array); } } public struct LethalBundleManifest { public string fileName; public string bundleName; public long timestamp; public string[] scenePaths; public static int ManifestVersion { get; } = 2; public LethalBundleManifest(string bundleManifest) { fileName = null; bundleName = null; timestamp = 0L; scenePaths = null; string[] array = bundleManifest.Split(';'); if (array.Length > 3) { fileName = array[0]; bundleName = array[1]; timestamp = long.Parse(array[2], CultureInfo.InvariantCulture); scenePaths = array[3].Split(','); } } public LethalBundleManifest() { fileName = null; bundleName = null; timestamp = 0L; scenePaths = null; } public override readonly string ToString() { return fileName + ";" + bundleName + ";" + timestamp + ";" + string.Join(',', scenePaths); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace LethalLevelLoader.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }