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.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using DunGen; using DunGen.Adapters; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalLevelLoader; using LethalLevelLoader.AssetBundles; using LethalLevelLoader.Compatibility; using LethalLevelLoader.NetcodePatcher; using LethalLevelLoader.Tools; using LethalLib.Modules; using LethalModDataLib.Base; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; 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("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [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.6.9.0")] [assembly: AssemblyInformationalVersion("1.6.9-dev.7+f1491200aeed665062fd6fc4756ac849e69a7129")] [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] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public enum ContentType { Vanilla, Custom, Any, External } internal static class HookHelper { public class DisposableHookCollection { private List ilHooks = new List(); private 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.ContainsKey(buildIndex)) { return buildIndexToScenePath[buildIndex]; } return SceneUtility.GetScenePathByBuildIndex(buildIndex); } private static int GetBuildIndexByScenePath(string scenePath) { int num = SceneUtility.GetBuildIndexByScenePath(scenePath); if (num == -1 && scenePathToBuildIndex.ContainsKey(scenePath)) { num = scenePathToBuildIndex[scenePath]; } 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.ContainsKey(sceneHash)) { return sceneHashToScenePath[sceneHash]; } 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 List assetBundleGroups = new List(); private static Dictionary> obtainedExtendedModsDict = new Dictionary>(); private static 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() { DebugHelper.Log("LethalBundleManger: 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 { LethalBundleManifest.ManifestVersion.ToString() }; list.AddRange(LethalLevelLoader.AssetBundles.AssetBundleLoader.knownSceneBundles.Values.Select((LethalBundleManifest manifest) => manifest.ToString())); 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)) { if (!value.Contains(extendedMod)) { value.Add(extendedMod); } } else { obtainedExtendedModsDict.Add(source, new List { extendedMod }); } } List list = new List(extendedMod.ExtendedContents); extendedMod.UnregisterAllExtendedContent(); foreach (ExtendedContent item in list) { 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 { ExtendedWeatherEffect extendedWeatherEffect = extendedContent as ExtendedWeatherEffect; if (extendedWeatherEffect == null) { 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()); } } } 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.First(); } DebugHelper.Log("Creating New ExtendedMod: " + contentSourceName, DebugType.Developer); ExtendedMod extendedMod2 = ExtendedMod.Create(contentSourceName); obtainedExtendedModsList.Add(extendedMod2); if (obtainedExtendedModsDict.TryGetValue(source, out var value2)) { if (!value2.Contains(extendedMod2)) { value2.Add(extendedMod2); } } else { obtainedExtendedModsDict.Add(source, new List { extendedMod2 }); } return extendedMod2; } internal static void FinialiseFoundContent() { foreach (ExtendedMod obtainedExtendedMods in obtainedExtendedModsList) { PatchedContent.ExtendedMods.Add(obtainedExtendedMods); DebugHelper.DebugExtendedMod(obtainedExtendedMods); } PatchedContent.ExtendedMods = new List(PatchedContent.ExtendedMods.OrderBy((ExtendedMod o) => o.ModName).ToList()); 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 class ExtendedContent : ScriptableObject { public ExtendedMod ExtendedMod { get; internal set; } public ContentType ContentType { get; internal set; } public List ContentTagStrings { get; internal set; } = new List(); [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(); internal virtual void TryCreateMatchingProperties() { } 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 { [SerializeField] private string _name; [SerializeField] [Range(0f, 300f)] private int _rarity; [HideInInspector] public string Name { get { return _name; } set { _name = value; } } [HideInInspector] public int Rarity { get { return _rarity; } set { _rarity = value; } } [HideInInspector] public StringWithRarity(string newName, int newRarity) { _name = newName; _rarity = newRarity; } } [Serializable] public class Vector2WithRarity { [SerializeField] private Vector2 _minMax; [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(Vector2 vector2, int newRarity) { //IL_000c: 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) _minMax.x = vector2.x; _minMax.y = vector2.y; _rarity = newRarity; } public Vector2WithRarity(float newMin, float newMax, int newRarity) { _minMax.x = newMin; _minMax.y = newMax; _rarity = newRarity; } } [CreateAssetMenu(fileName = "ExtendedDungeonFlow", menuName = "Lethal Level Loader/Extended Content/ExtendedDungeonFlow", order = 21)] public class ExtendedDungeonFlow : ExtendedContent { [Space(5f)] [Tooltip("Overrides vanilla camera Far Plane Clip Distance, The highest value between current Level and Interior will be used.")] [Range(0f, 10000f)] [SerializeField] public float OverrideCameraMaxDistance = 400f; [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] [HideInInspector] public int dungeonDefaultRarity; [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] public float MapTileSize { get; set; } = 1f; [field: SerializeField] public AudioClip FirstTimeDungeonAudio { get; set; } [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: Tooltip("When above Vector3.zero this value will restrict the max bounds of the interior.")] [field: SerializeField] public Vector3 OverrideRestrictedTilePlacementBounds { get; set; } = Vector3.zero; public bool OverrideTilePlacementBounds { get { //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) Vector3 overrideRestrictedTilePlacementBounds = OverrideRestrictedTilePlacementBounds; return ((Vector3)(ref overrideRestrictedTilePlacementBounds)).sqrMagnitude > 1f; } } [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(10f)] [field: Header("Misc. Settings")] [field: SerializeField] public bool GenerateAutomaticConfigurationOptions { get; set; } = true; [Obsolete] [HideInInspector] [field: SerializeField] public List SpawnableMapObjects { get; set; } = new List(); 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) { ExtendedDungeonFlow extendedDungeonFlow = ScriptableObject.CreateInstance(); extendedDungeonFlow.DungeonFlow = newDungeonFlow; extendedDungeonFlow.FirstTimeDungeonAudio = newFirstTimeDungeonAudio; if ((Object)(object)extendedDungeonFlow.LevelMatchingProperties == (Object)null) { extendedDungeonFlow.LevelMatchingProperties = LevelMatchingProperties.Create(extendedDungeonFlow); } return extendedDungeonFlow; } internal void Reset() { ConvertObsoleteValues(); } internal void Initialize() { if ((Object)(object)LevelMatchingProperties == (Object)null) { LevelMatchingProperties = LevelMatchingProperties.Create(this); } GetDungeonFlowID(); if (DungeonName == null || DungeonName == string.Empty) { 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; } if (base.ContentType != 0) { return; } IndoorMapType[] dungeonFlowTypes = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { if ((Object)(object)val.dungeonFlow == (Object)(object)DungeonFlow) { DungeonID = Patches.RoundManager.dungeonFlowTypes.ToList().IndexOf(val); } } } 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 void ConvertObsoleteValues() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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; } 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); } if (Application.isEditor) { SpawnableMapObjects.Clear(); } } } [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(); } 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); } } } [CreateAssetMenu(fileName = "ExtendedFootstepSurface", menuName = "Lethal Level Loader/Extended Content/ExtendedFootstepSurface", order = 27)] public class ExtendedFootstepSurface : ExtendedContent { public FootstepSurface footstepSurface; public List associatedMaterials; } [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); } } internal override void TryCreateMatchingProperties() { if ((Object)(object)LevelMatchingProperties == (Object)null) { LevelMatchingProperties = LevelMatchingProperties.Create(this); } if ((Object)(object)DungeonMatchingProperties == (Object)null) { DungeonMatchingProperties = DungeonMatchingProperties.Create(this); } } 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 { [Space(5f)] [SerializeField] private int routePrice; [Space(5f)] [Tooltip("Overrides vanilla camera Far Plane Clip Distance, The highest value between current Level and Interior will be used.")] [Range(0f, 10000f)] [SerializeField] public float OverrideCameraMaxDistance = 400f; [Space(25f)] [Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")] [Obsolete] public SelectableLevel selectableLevel; [Obsolete] [Space(5f)] public string contentSourceName = string.Empty; [Obsolete] [Space(5f)] public List levelTags = new List(); [field: Header("General Settings")] [field: SerializeField] public SelectableLevel SelectableLevel { get; set; } [field: Header("Extended Feature Settings")] [field: SerializeField] public bool OverrideDynamicRiskLevelAssignment { 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 AnimationClip ShipFlyToMoonClip { get; set; } [field: SerializeField] public AnimationClip ShipFlyFromMoonClip { get; set; } [field: Space(5f)] [field: SerializeField] public List SceneSelections { get; set; } = new List(); [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("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; 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 => GetNumberlessPlanetName(SelectableLevel); public int CalculatedDifficultyRating => LevelManager.CalculateExtendedLevelDifficultyRating(this); public bool IsCurrentLevel => (Object)(object)LevelManager.CurrentExtendedLevel == (Object)(object)this; public bool IsLevelLoaded { get { //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) Scene sceneByName = SceneManager.GetSceneByName(SelectableLevel.sceneName); return ((Scene)(ref sceneByName)).isLoaded; } } [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 newContentSourceName, bool generateTerminalAssets) { bool flag = false; foreach (StringWithRarity sceneSelection in SceneSelections) { if (sceneSelection.Name == SelectableLevel.sceneName) { flag = true; } } if (!flag) { 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 ((Object)(object)ShipFlyToMoonClip == (Object)null) { ShipFlyToMoonClip = LevelLoader.defaultShipFlyToMoonClip; } if ((Object)(object)ShipFlyFromMoonClip == (Object)null) { ShipFlyFromMoonClip = LevelLoader.defaultShipFlyFromMoonClip; } 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.Vanilla) { GetVanillaInfoNode(); } SetExtendedDungeonFlowMatches(); } internal 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); } } internal static string GetNumberlessPlanetName(SelectableLevel selectableLevel) { if ((Object)(object)selectableLevel != (Object)null) { return new string(selectableLevel.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray()); } return string.Empty; } internal void SetLevelID() { if (base.ContentType == ContentType.Custom) { SelectableLevel.levelID = PatchedContent.ExtendedLevels.IndexOf(this); if ((Object)(object)RouteNode != (Object)null) { RouteNode.displayPlanetInfo = SelectableLevel.levelID; } if ((Object)(object)RouteConfirmNode != (Object)null) { RouteConfirmNode.buyRerouteToMoon = SelectableLevel.levelID; } } } internal void SetExtendedDungeonFlowMatches() { IntWithRarity[] dungeonFlowTypes = SelectableLevel.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes) { if (DungeonManager.TryGetExtendedDungeonFlow(Patches.RoundManager.dungeonFlowTypes[val.id].dungeonFlow, out var returnExtendedDungeonFlow)) { returnExtendedDungeonFlow.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, val.rarity)); } } if (!(SelectableLevel.sceneName == "Level4March")) { return; } IndoorMapType[] dungeonFlowTypes2 = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType val2 in dungeonFlowTypes2) { if (((Object)val2.dungeonFlow).name == "Level1Flow3Exits" && DungeonManager.TryGetExtendedDungeonFlow(val2.dungeonFlow, out var returnExtendedDungeonFlow2)) { returnExtendedDungeonFlow2.LevelMatchingProperties.planetNames.Add(new StringWithRarity(NumberlessPlanetName, 300)); } } } internal void GetVanillaInfoNode() { CompatibleNoun[] compatibleNouns = TerminalManager.routeInfoKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { if (val.noun.word == NumberlessPlanetName.ToLower()) { 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 { [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 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("newExtendedContent", ((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Unimplemented Registration Check!"); } throw new ArgumentException("newExtendedContent", ((Object)newExtendedContent).name + " (" + ((object)newExtendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Already Being Registered To This Mod!"); } throw new ArgumentNullException("newExtendedContent", "Null ExtendedContent Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check!"); } internal void RegisterExtendedContent(ExtendedLevel extendedLevel) { extendedLevel.ConvertObsoleteValues(); TryThrowInvalidContentException(extendedLevel, Validators.ValidateExtendedContent(extendedLevel)); ExtendedLevels.Add(extendedLevel); extendedLevel.ContentTags.Add(ContentTag.Create("Custom")); extendedLevel.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedDungeonFlow extendedDungeonFlow) { extendedDungeonFlow.ConvertObsoleteValues(); TryThrowInvalidContentException(extendedDungeonFlow, Validators.ValidateExtendedContent(extendedDungeonFlow)); ExtendedDungeonFlows.Add(extendedDungeonFlow); extendedDungeonFlow.ContentTags.Add(ContentTag.Create("Custom")); extendedDungeonFlow.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedItem extendedItem) { TryThrowInvalidContentException(extendedItem, Validators.ValidateExtendedContent(extendedItem)); ExtendedItems.Add(extendedItem); extendedItem.ContentTags.Add(ContentTag.Create("Custom")); extendedItem.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedEnemyType extendedEnemyType) { TryThrowInvalidContentException(extendedEnemyType, Validators.ValidateExtendedContent(extendedEnemyType)); ExtendedEnemyTypes.Add(extendedEnemyType); extendedEnemyType.ContentTags.Add(ContentTag.Create("Custom")); extendedEnemyType.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedWeatherEffect extendedWeatherEffect) { TryThrowInvalidContentException(extendedWeatherEffect, Validators.ValidateExtendedContent(extendedWeatherEffect)); ExtendedWeatherEffects.Add(extendedWeatherEffect); extendedWeatherEffect.ContentTags.Add(ContentTag.Create("Custom")); extendedWeatherEffect.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedFootstepSurface extendedFootstepSurface) { TryThrowInvalidContentException(extendedFootstepSurface, Validators.ValidateExtendedContent(extendedFootstepSurface)); ExtendedFootstepSurfaces.Add(extendedFootstepSurface); extendedFootstepSurface.ContentTags.Add(ContentTag.Create("Custom")); extendedFootstepSurface.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedStoryLog extendedStoryLog) { TryThrowInvalidContentException(extendedStoryLog, Validators.ValidateExtendedContent(extendedStoryLog)); ExtendedStoryLogs.Add(extendedStoryLog); extendedStoryLog.ContentTags.Add(ContentTag.Create("Custom")); extendedStoryLog.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedBuyableVehicle extendedBuyableVehicle) { TryThrowInvalidContentException(extendedBuyableVehicle, Validators.ValidateExtendedContent(extendedBuyableVehicle)); ExtendedBuyableVehicles.Add(extendedBuyableVehicle); extendedBuyableVehicle.ContentTags.Add(ContentTag.Create("Custom")); extendedBuyableVehicle.ExtendedMod = this; } internal void RegisterExtendedContent(ExtendedUnlockableItem extendedUnlockableItem) { TryThrowInvalidContentException(extendedUnlockableItem, Validators.ValidateExtendedContent(extendedUnlockableItem)); ExtendedUnlockableItems.Add(extendedUnlockableItem); extendedUnlockableItem.ContentTags.Add(ContentTag.Create("Custom")); extendedUnlockableItem.ExtendedMod = this; } 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("extendedContent", ((Object)extendedContent).name + " (" + ((object)extendedContent).GetType().Name + ") Could Not Be Registered To ExtendedMod: " + ModName + " Due To Failed Validation Check! " + result.Item2); } } 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() { ExtendedLevels.Sort((ExtendedLevel s1, ExtendedLevel s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedDungeonFlows.Sort((ExtendedDungeonFlow s1, ExtendedDungeonFlow s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedItems.Sort((ExtendedItem s1, ExtendedItem s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedEnemyTypes.Sort((ExtendedEnemyType s1, ExtendedEnemyType s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedWeatherEffects.Sort((ExtendedWeatherEffect s1, ExtendedWeatherEffect s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedFootstepSurfaces.Sort((ExtendedFootstepSurface s1, ExtendedFootstepSurface s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedStoryLogs.Sort((ExtendedStoryLog s1, ExtendedStoryLog s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedBuyableVehicles.Sort((ExtendedBuyableVehicle s1, ExtendedBuyableVehicle s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); ExtendedUnlockableItems.Sort((ExtendedUnlockableItem s1, ExtendedUnlockableItem s2) => ((Object)s1).name.CompareTo(((Object)s2).name)); } } [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] public string storyLogDescription = string.Empty; [HideInInspector] internal int newStoryLogID; [HideInInspector] internal TerminalNode assignedNode; } [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); } } 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; } } [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_0024: Unknown result type (might be due to invalid IL or missing references) ExtendedWeatherEffect extendedWeatherEffect = ScriptableObject.CreateInstance(); extendedWeatherEffect.WeatherDisplayName = newWeatherDisplayName; ((Object)extendedWeatherEffect).name = extendedWeatherEffect.WeatherDisplayName + "ExtendedWeatherEffect"; extendedWeatherEffect.BaseWeatherType = levelWeatherType; extendedWeatherEffect.WorldObject = worldObject; extendedWeatherEffect.GlobalObject = globalObject; return extendedWeatherEffect; } } 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 string UniqueIdentifier => uniqueIdentifier; 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 ExtendedLevelData(ExtendedLevel extendedLevel) { uniqueIdentifier = string.Empty; uniqueIdentifier = extendedLevel.UniqueIdentificationName; isHidden = extendedLevel.IsRouteHidden; isLocked = extendedLevel.IsRouteLocked; } public 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; public Color contentTagColor; 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 + "ContentTag"; 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); } } [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)(LevelWeatherType)(ref extendedLevel.SelectableLevel.currentWeather)).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 { comparingString }, matchingStrings); } internal static int GetHighestRarityViaMatchingNormalizedTags(List comparingTags, List matchingStrings) { List comparingStrings = comparingTags.Select((ContentTag t) => t.contentTagName).ToList(); return GetHighestRarityViaMatchingNormalizedStrings(comparingStrings, 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 { private List extendedLevelGroups; public List ExtendedLevelGroups => extendedLevelGroups; public List ExtendedLevels { get { List list = new List(); foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { list.Add(extendedLevels); } } return list; } } public MoonsCataloguePage(List newExtendedLevelGroupList) { extendedLevelGroups = new List(); extendedLevelGroups.Clear(); foreach (ExtendedLevelGroup newExtendedLevelGroup in newExtendedLevelGroupList) { extendedLevelGroups.Add(new ExtendedLevelGroup(newExtendedLevelGroup.extendedLevelsList)); } } public void RebuildLevelGroups(List newExtendedLevelGroups, int splitCount) { List list = new List(); foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { list.Add(extendedLevels); } } RebuildLevelGroups(list.ToArray(), splitCount); } public void RebuildLevelGroups(List newExtendedLevels, int splitCount) { RebuildLevelGroups(newExtendedLevels.ToArray(), splitCount); } public void RebuildLevelGroups(IOrderedEnumerable orderedExtendedLevels, int splitCount) { RebuildLevelGroups(orderedExtendedLevels.ToArray(), splitCount); } public void RebuildLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount) { extendedLevelGroups = TerminalManager.GetExtendedLevelGroups(newExtendedLevels, splitCount); } public void RefreshLevelGroups(List newLevelGroups) { extendedLevelGroups.Clear(); foreach (ExtendedLevelGroup newLevelGroup in newLevelGroups) { if (newLevelGroup.extendedLevelsList.Count != 0) { extendedLevelGroups.Add(new ExtendedLevelGroup(newLevelGroup.extendedLevelsList)); } } } } [Serializable] public class ExtendedLevelGroup { public List extendedLevelsList; public int AverageCalculatedDifficulty => GetAverageCalculatedDifficulty(); public ExtendedLevelGroup(List newExtendedLevelsList) { extendedLevelsList = new List(newExtendedLevelsList); } public ExtendedLevelGroup(List newSelectableLevelsList) { extendedLevelsList = new List(); foreach (SelectableLevel newSelectableLevels in newSelectableLevelsList) { extendedLevelsList.Add(LevelManager.GetExtendedLevel(newSelectableLevels)); } } public int GetAverageCalculatedDifficulty() { List list = new List(); foreach (ExtendedLevel extendedLevels in extendedLevelsList) { list.Add(extendedLevels.CalculatedDifficultyRating); } return (int)list.Average(); } } 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 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 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 = new List(ExtendedMods.OrderBy((ExtendedMod o) => o.ModName).ToList()); 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 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 class EventPatches { internal static DayMode previousDayMode = (DayMode)(-1); internal static bool firedDawnEvent = false; private static EnemyVent cachedSelectedVent; internal static void InvokeExtendedEvent(ExtendedEvent extendedEvent, T eventParameter) { extendedEvent.Invoke(eventParameter); } internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLevelLoaded) { previousDayMode = (DayMode)(-1); LevelManager.CurrentExtendedLevel.LevelEvents.onLevelLoaded.Invoke(); LevelManager.GlobalLevelEvents.onLevelLoaded.Invoke(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StoryLog), "CollectLog")] [HarmonyPrefix] internal static void StoryLogCollectLog_Prefix(StoryLog __instance) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && ((NetworkBehaviour)__instance).IsServer) { LevelManager.CurrentExtendedLevel.LevelEvents.onStoryLogCollected.Invoke(__instance); LevelManager.GlobalLevelEvents.onStoryLogCollected.Invoke(__instance); } } [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) { List param = Object.FindObjectsOfType().ToList(); DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedScrapObjects.Invoke(param); DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects.Invoke(param); } } [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) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onEnemySpawnedFromVent.Invoke((cachedSelectedVent, Patches.RoundManager.SpawnedEnemies.Last())); DungeonManager.GlobalDungeonEvents.onEnemySpawnedFromVent.Invoke((cachedSelectedVent, Patches.RoundManager.SpawnedEnemies.Last())); cachedSelectedVent = null; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPostfix] internal static void RoundManagerSpawnMapObjects_Postfix() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)) { return; } List list = new List(); Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.SelectableLevel.sceneName); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { SpawnableMapObject[] spawnableMapObjects = LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects; foreach (SpawnableMapObject val2 in spawnableMapObjects) { if (((Object)val).name.ContainsSanitized(((Object)val2.prefabToSpawn).name)) { list.Add(val); } } } DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onSpawnedMapObjects.Invoke(list); DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects.Invoke(list); } [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 (((NetworkBehaviour)__instance).IsServer && __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 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 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 ex) { DebugHelper.LogWarning(ex.Message, 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) { 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) { 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) { return dungeonFlow.GetRandomMapObjects(dungeonFlow.GetTiles()); } public static IEnumerable GetRandomMapObjects(this DungeonFlow _, IEnumerable allTiles) { 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) { return dungeonFlow.GetSpawnSyncedObjects(dungeonFlow.GetTiles()); } public static IEnumerable GetSpawnSyncedObjects(this DungeonFlow _, IEnumerable allTiles) { 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()); } foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights) { hashSet.UnionWith(blockerPrefabWeight.GameObject.GetComponentsInChildren()); } } hashSet.UnionWith(((Component)allTile).gameObject.GetComponentsInChildren()); } 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; } 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (terminalNode.terminalOptions == null) { terminalNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; } 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 comparison, bool bothWays = false) { (string, string) tuple = (input.Sanitized(), comparison.Sanitized()); if (!tuple.Item1.Contains(tuple.Item2)) { if (bothWays) { return tuple.Item2.Contains(tuple.Item1); } 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) { return roundManager.dungeonFlowTypes.Select((IndoorMapType i) => i.dungeonFlow).ToList(); } } internal class LethalLibPatches { [HarmonyPriority(200)] [HarmonyPatch(typeof(Dungeon), "RoundManager_Start")] [HarmonyPrefix] internal static bool Dungeon_Start_Prefix(Action orig, RoundManager self) { DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_Start() Function To Prevent Conflicts", DebugType.User); orig(self); return false; } [HarmonyPriority(200)] [HarmonyPatch(typeof(Dungeon), "RoundManager_GenerateNewFloor")] [HarmonyPrefix] internal static bool Dungeon_GenerateNewFloor_Prefix(Action orig, RoundManager self) { DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_GenerateNewFloor() Function To Prevent Conflicts", DebugType.User); orig(self); return false; } } internal static class Patches { internal const int priority = 200; internal static string delayedSceneLoadingName = string.Empty; internal static List allSceneNamesCalledToLoad = new List(); internal static Dictionary playerCameras = new Dictionary(); internal static ulong currentClientId; public static ExtendedEvent OnBeforeVanillaContentCollected = new ExtendedEvent(); public static ExtendedEvent OnAfterVanillaContentCollected = new ExtendedEvent(); public static ExtendedEvent OnAfterCustomContentRestored = new ExtendedEvent(); public static bool hasInitiallyChangedLevel; internal static bool ranLethalLevelLoaderTerminalEvent; private static readonly HashSet temporaryIndoorMapHazards = new HashSet(); private static FootstepSurface previousFootstepSurface; 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(PreInitSceneScript), "ChooseLaunchOption")] [HarmonyPrefix] internal static bool PreInitSceneScriptChooseLaunchOption_Prefix() { return true; } [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; } LethalLevelLoaderNetworkManager.networkManager = ((Component)__instance).GetComponent(); NetworkBundleManager.networkManager = ((Component)__instance).GetComponent(); foreach (NetworkPrefab prefab in ((Component)__instance).GetComponent().NetworkConfig.Prefabs.Prefabs) { if (((Object)prefab.Prefab).name.Contains("EntranceTeleport") && (Object)(object)prefab.Prefab.GetComponent() != (Object)null) { OriginalContent.AudioMixers.Add(prefab.Prefab.GetComponent().outputAudioMixerGroup.audioMixer); } } GameObject val = PrefabHelper.CreateNetworkPrefab("LethalLevelLoaderNetworkManagerTest"); val.AddComponent(); val.GetComponent().SceneMigrationSynchronization = true; val.GetComponent().DestroyWithScene = false; LethalLevelLoaderNetworkManager.networkingManagerPrefab = val; LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val); DebugHelper.Log("Creating NetworkBundleManager", DebugType.IAmBatby); GameObject val2 = PrefabHelper.CreateNetworkPrefab("NetworkBundleManager"); val2.AddComponent(); val2.GetComponent().SceneMigrationSynchronization = true; val2.GetComponent().DestroyWithScene = false; NetworkBundleManager.networkingManagerPrefab = val2; LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val2); AssetBundleLoader.NetworkRegisterCustomContent(((Component)__instance).GetComponent()); LethalLevelLoaderNetworkManager.RegisterPrefabs(((Component)__instance).GetComponent()); } [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void GameNetworkManagerSaveGameValues_Postfix(GameNetworkManager __instance) { if (__instance.isHostingGame && StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.isChallengeFile) { SaveManager.SaveGameValues(); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void StartOfRoundAwake_Prefix(StartOfRound __instance) { Plugin.OnBeforeSetupInvoke(); StartOfRound = __instance; RoundManager = Object.FindFirstObjectByType((FindObjectsInactive)0); Terminal = Object.FindFirstObjectByType((FindObjectsInactive)0); TimeOfDay = Object.FindFirstObjectByType((FindObjectsInactive)0); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += EventPatches.OnSceneLoaded; 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.TryScrapeVanillaContent(StartOfRound, RoundManager); ContentExtractor.ObtainSpecialItemReferences(); OnAfterVanillaContentCollected.Invoke(); } if (LethalLevelLoaderNetworkManager.networkManager.IsServer || LethalLevelLoaderNetworkManager.networkManager.IsHost) { Object.Instantiate(LethalLevelLoaderNetworkManager.networkingManagerPrefab).GetComponent().Spawn(false); Object.Instantiate(NetworkBundleManager.networkingManagerPrefab).GetComponent().Spawn(false); } RoundManager.firstTimeDungeonAudios = CollectionExtensions.AddItem((IEnumerable)RoundManager.firstTimeDungeonAudios.ToList(), RoundManager.firstTimeDungeonAudios[0]).ToArray(); DebugStopwatch.StartStopWatch("Fix AudioSource Settings"); AudioSource[] array = Resources.FindObjectsOfTypeAll(); foreach (AudioSource val in array) { val.spatialize = false; } playerCameras.Clear(); Camera[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Camera val2 in array2) { if ((Object)(object)val2.targetTexture != (Object)null && ((Object)val2.targetTexture).name == "PlayerScreen") { playerCameras.Add(val2, val2.farClipPlane); } } if ((Object)(object)DungeonLoader.defaultKeyPrefab == (Object)null) { DungeonLoader.defaultKeyPrefab = RoundManager.keyPrefab; } if (!Plugin.IsSetupComplete) { TerminalManager.CacheTerminalReferences(); LevelManager.ObtainShipAnimatorClips(StartOfRound); LevelManager.ObtainTimeOfDayClips(TimeOfDay); DebugStopwatch.StartStopWatch("Create Vanilla ExtendedContent"); AssetBundleLoader.CreateVanillaExtendedDungeonFlows(); AssetBundleLoader.CreateVanillaExtendedLevels(StartOfRound); AssetBundleLoader.CreateVanillaExtendedItems(); AssetBundleLoader.CreateVanillaExtendedEnemyTypes(); AssetBundleLoader.CreateVanillaExtendedBuyableVehicles(); AssetBundleLoader.CreateVanillaExtendedUnlockableItems(StartOfRound); DebugStopwatch.StartStopWatch("Initialize Custom ExtendedContent"); AssetBundleLoader.InitializeBundles(); PatchedContent.PopulateContentDictionaries(); if (DawnLibCompatibility.Enabled) { DawnLibCompatibility.RegisterDawnExtendedLevels(); } foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { customExtendedLevel.SetLevelID(); } string text = "LethalLevelLoader Loaded The Following ExtendedLevels:\n"; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { text = text + (PatchedContent.ExtendedLevels.IndexOf(extendedLevel) + 1) + ". " + extendedLevel.SelectableLevel.PlanetName + " (" + extendedLevel.ContentType.ToString() + ")\n"; } DebugHelper.Log(text, DebugType.User); text = "LethalLevelLoader Loaded The Following ExtendedDungeonFlows:\n"; foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { text = text + (PatchedContent.ExtendedDungeonFlows.IndexOf(extendedDungeonFlow) + 1) + ". " + extendedDungeonFlow.DungeonName + " (" + ((Object)extendedDungeonFlow.DungeonFlow).name + ") (" + extendedDungeonFlow.ContentType.ToString() + ")\n"; } DebugHelper.Log(text, DebugType.User); DebugStopwatch.StartStopWatch("Restore Content"); foreach (ExtendedLevel customExtendedLevel2 in PatchedContent.CustomExtendedLevels) { ContentRestorer.RestoreVanillaLevelAssetReferences(customExtendedLevel2); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { ContentRestorer.RestoreVanillaDungeonAssetReferences(customExtendedDungeonFlow); } 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(); ItemManager.GetExtendedItemPriceData(); ItemManager.GetExtendedItemWeightData(); } DebugStopwatch.StartStopWatch("Bind Configs"); ConfigLoader.BindConfigs(); DebugStopwatch.StartStopWatch("Patch Base game Lists"); LevelManager.PatchVanillaLevelLists(); DungeonManager.PatchVanillaDungeonLists(); EnemyManager.UpdateEnemyIDs(); foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { TerminalManager.CreateEnemyTypeTerminalData(customExtendedEnemyType); } if (!Plugin.IsSetupComplete) { EnemyManager.AddCustomEnemyTypesToTestAllEnemiesLevel(); } DebugStopwatch.StartStopWatch("ExtendedItem Injection"); ItemManager.RefreshDynamicItemRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("ExtendedEnemyType Injection"); EnemyManager.RefreshDynamicEnemyTypeRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("ExtendedBuyableVehicle Injection"); VehiclesManager.PatchVanillaVehiclesLists(); VehiclesManager.SetBuyableVehicleIDs(); foreach (ExtendedBuyableVehicle customExtendedBuyableVehicle in PatchedContent.CustomExtendedBuyableVehicles) { TerminalManager.CreateBuyableVehicleTerminalData(customExtendedBuyableVehicle); } if (!Plugin.IsSetupComplete) { DebugStopwatch.StartStopWatch("ExtendedUnlockableItem Injection"); UnlockableItemManager.PatchVanillaUnlockableItemLists(); UnlockableItemManager.SetUnlockableItemIDs(); foreach (ExtendedUnlockableItem customExtendedUnlockableItem in PatchedContent.CustomExtendedUnlockableItems) { TerminalManager.CreateUnlockableItemTerminalData(customExtendedUnlockableItem); } } DebugStopwatch.StartStopWatch("Create ExtendedLevelGroups & Filter Assets"); TerminalManager.CreateExtendedLevelGroups(); if (!Plugin.IsSetupComplete) { TerminalManager.CreateMoonsFilterTerminalAssets(); CompatibleNoun[] compatibleNouns = TerminalManager.routeKeyword.compatibleNouns; foreach (CompatibleNoun val3 in compatibleNouns) { TerminalManager.AddTerminalNodeEventListener(val3.result, TerminalManager.OnBeforeRouteNodeLoaded, TerminalManager.LoadNodeActionType.Before); } TerminalManager.CreateTerminalDataForAllExtendedStoryLogs(); TerminalManager.AddTerminalNodeEventListener(TerminalManager.moonsKeyword.specialKeywordResult, TerminalManager.RefreshMoonsCataloguePage, TerminalManager.LoadNodeActionType.After); } else { foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { if (extendedMod.ExtendedItems.Count > 0) { List list = Terminal.buyableItemsList.ToList(); foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems) { if (extendedItem.IsBuyableItem) { list.Add(extendedItem.Item); } } Terminal.buyableItemsList = list.ToArray(); } if (extendedMod.ExtendedEnemyTypes.Count > 0) { foreach (ExtendedEnemyType extendedEnemyType in extendedMod.ExtendedEnemyTypes) { Terminal.enemyFiles.Add(extendedEnemyType.EnemyInfoNode); } } if (extendedMod.ExtendedStoryLogs.Count > 0) { foreach (ExtendedStoryLog extendedStoryLog in extendedMod.ExtendedStoryLogs) { Terminal.logEntryFiles.Add(extendedStoryLog.assignedNode); } } if (extendedMod.ExtendedBuyableVehicles.Count <= 0) { continue; } List list2 = Terminal.buyableVehicles.ToList(); foreach (ExtendedBuyableVehicle extendedBuyableVehicle in extendedMod.ExtendedBuyableVehicles) { list2.Add(extendedBuyableVehicle.BuyableVehicle); } Terminal.buyableVehicles = list2.ToArray(); } } LevelLoader.defaultFootstepSurfaces = new List(StartOfRound.footstepSurfaces).ToArray(); 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 bool StartOfRoundChangeLevel_Prefix(ref int levelID) { if (!LethalLevelLoaderNetworkManager.networkManager.IsServer) { return true; } 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 = StartOfRound.levels.ToList().IndexOf(extendedLevel.SelectableLevel); hasInitiallyChangedLevel = true; return true; } } } if (!hasInitiallyChangedLevel && !string.IsNullOrEmpty(SaveManager.currentSaveFile.CurrentLevelName) && !SaveManager.currentSaveFile.CurrentLevelName.Contains("Experimentation") && (levelID >= StartOfRound.levels.Length || levelID > OriginalContent.SelectableLevels.Count)) { levelID = 0; } hasInitiallyChangedLevel = true; return 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; 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")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool TerminalScrollMouse_Prefix(PlayerControllerB __instance, CallbackContext context) { if (!__instance.inTerminalMenu || TerminalManager.moonsInCataloguePage == 0) { return true; } float num = 15f / (float)TerminalManager.moonsInCataloguePage; float num2 = ((CallbackContext)(ref context)).ReadValue(); Scrollbar terminalScrollVertical = __instance.terminalScrollVertical; terminalScrollVertical.value += num * num2; return false; } internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (!((Object)(object)currentExtendedLevel == (Object)null) && currentExtendedLevel.IsLevelLoaded && currentExtendedLevel.ContentType != ContentType.External) { Scene sceneByName = SceneManager.GetSceneByName(currentExtendedLevel.SelectableLevel.sceneName); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); foreach (GameObject parent in rootGameObjects) { ContentRestorer.RestoreAudioAssetReferencesInParent(parent); } } } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPrefix] [HarmonyPriority(200)] internal static void GenerateNewLevelClientRpc_Prefix(RoundManager __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)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) { RestoreRuntimeDungeon(); } } private static void RestoreRuntimeDungeon() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) GameObject val = GameObject.FindGameObjectWithTag("DungeonGenerator"); RuntimeDungeon val2 = default(RuntimeDungeon); if (!val.TryGetComponent(ref val2)) { RuntimeDungeon val3 = val.AddComponent(); UnityNavMeshAdapter val4 = ((Component)val3).gameObject.AddComponent(); Transform child = ((Component)val3).transform.GetParent().GetChild(1); if (!((Object)(object)child == (Object)null)) { val3.Root = ((Component)child).gameObject; val4.BakeMode = (RuntimeNavMeshBakeMode)3; val4.LayerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Default", "Room", "Colliders", "NavigationSurface" })); DungeonGenerator generator = val3.Generator; generator.AllowTilePooling = true; generator.GenerateAsynchronously = true; } } } [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) { 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 = currentExtendedLevel.SceneSelections.Select((StringWithRarity s) => s.Rarity).ToArray(); 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) && !(currentExtendedLevel.SelectableLevel.sceneName == sceneName)) { if (currentExtendedLevel.SceneSelections.Select((StringWithRarity scene) => scene.Name).Contains(sceneName)) { currentExtendedLevel.SelectableLevel.sceneName = sceneName; } else if (sceneName != "SampleSceneRelay") { DebugHelper.LogError("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(DungeonGenerator __instance) { 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.LogError("Critical Failure! DungeonGenerator DungeonFlow Is Null!", DebugType.User); } } [HarmonyPatch(typeof(RoundManager), "Generator_OnGenerationStatusChanged")] [HarmonyPrefix] [HarmonyPriority(200)] internal static bool OnGenerationStatusChanged_Prefix(RoundManager __instance, 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if ((int)status == 8 && !__instance.dungeonCompletedGenerating) { __instance.FinishGeneratingLevel(); __instance.dungeonGenerator.Generator.OnGenerationStatusChanged -= new GenerationStatusDelegate(__instance.Generator_OnGenerationStatusChanged); Debug.Log((object)"Dungeon has finished generating on this client after multiple frames"); } return false; } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyTranspiler] public static IEnumerable GenerateNewLevelClientRpcTranspiler(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 GenerateNewFloorTranspiler(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) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { 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 = LevelManager.CurrentExtendedLevel.OverrideQuicksandPrefab; } [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void RoundManagerFinishGeneratingNewLevelClientRpc_Prefix() { //IL_0027: 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) if (!((Object)(object)TimeOfDay.sunAnimator == (Object)null)) { LevelLoader.RefreshFootstepSurfaces(); LevelLoader.BakeSceneColliderMaterialData(((Component)TimeOfDay.sunAnimator).gameObject.scene); if ((Object)(object)LevelLoader.vanillaWaterShader != (Object)null) { LevelLoader.TryRestoreWaterShaders(((Component)TimeOfDay.sunAnimator).gameObject.scene); } ApplyCamerDistanceOverride(); } } internal static void ApplyCamerDistanceOverride() { float num = 0f; if (LevelManager.CurrentExtendedLevel.OverrideCameraMaxDistance > 400f || ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.OverrideCameraMaxDistance > 400f)) { num = Mathf.Max(LevelManager.CurrentExtendedLevel.OverrideCameraMaxDistance, DungeonManager.CurrentExtendedDungeonFlow.OverrideCameraMaxDistance); } foreach (KeyValuePair playerCamera in playerCameras) { playerCamera.Key.farClipPlane = Mathf.Max(playerCamera.Value, num); } } [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")] [HarmonyPostfix] [HarmonyPriority(200)] internal static void PlayerControllerBGetCurrentMaterialStandingOn_Postfix(PlayerControllerB __instance) { if (!LevelLoader.TryGetFootstepSurface(((RaycastHit)(ref __instance.hit)).collider, out var footstepSurface)) { return; } for (int i = 0; i < StartOfRound.footstepSurfaces.Length; i++) { FootstepSurface val = StartOfRound.footstepSurfaces[i]; if (val != null && val == footstepSurface) { __instance.currentFootstepSurfaceIndex = i; break; } } } [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(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}")) { 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 class SafetyPatches { internal const int harmonyPriority = 250; [HarmonyPriority(250)] [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPrefix] internal static void StartOfRoundChangeLevel_Prefix(ref int levelID) { } [HarmonyPriority(250)] [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; } } } } 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 string GetOverridePreviewInfo(ExtendedLevel extendedLevel) { return string.Empty; } } [Serializable] public class ExtendedDungeonFlowWithRarity { public ExtendedDungeonFlow extendedDungeonFlow; public int rarity; public ExtendedDungeonFlowWithRarity(ExtendedDungeonFlow newExtendedDungeonFlow, int newRarity) { extendedDungeonFlow = newExtendedDungeonFlow; rarity = newRarity; } public bool UpdateRarity(int newRarity) { if (newRarity > rarity) { rarity = 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_0034: 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_0044: 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_0062: 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_006d: Expected O, but got Unknown DungeonGenerator generator = Patches.RoundManager.dungeonGenerator.Generator; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; generator.retryCount = 50; if (currentExtendedDungeonFlow.OverrideTilePlacementBounds) { generator.RestrictDungeonToBounds = true; generator.TilePlacementBounds = new Bounds(Vector3.zero, currentExtendedDungeonFlow.OverrideRestrictedTilePlacementBounds); } 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; } PatchFireEscapes(generator, currentExtendedLevel, SceneManager.GetSceneByName(currentExtendedLevel.SelectableLevel.sceneName)); PatchDynamicGlobalProps(generator, currentExtendedDungeonFlow); } public static float GetClampedDungeonSize() { ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; float num = CalculateDungeonMultiplier(LevelManager.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: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " ExtendedLevel DungeonSize Is: " + LevelManager.CurrentExtendedLevel.SelectableLevel.factorySizeMultiplier + " | Overriding DungeonSize To: " + num, DebugType.User); } else { DebugHelper.Log("CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + LevelManager.CurrentExtendedLevel.SelectableLevel.factorySizeMultiplier + " | Leaving DungeonSize As: " + num, DebugType.User); } return num; } public static float CalculateDungeonMultiplier(ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow) { IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { if ((Object)(object)val.dungeonFlow == (Object)(object)extendedDungeonFlow.DungeonFlow) { return extendedLevel.SelectableLevel.factorySizeMultiplier / val.MapTileSize * RoundManager.Instance.mapSizeMultiplier; } } return 1f; } internal static void PatchDungeonSize(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow) { } internal static List GetEntranceTeleports(Scene scene) { List list = new List(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { EntranceTeleport[] componentsInChildren = val.GetComponentsInChildren(); foreach (EntranceTeleport item in componentsInChildren) { list.Add(item); } } return list; } internal static void PatchFireEscapes(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel, Scene scene) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown string text = "Fire Exit Patch Report, Details Below;\n\n"; if (!DungeonManager.TryGetExtendedDungeonFlow(dungeonGenerator.DungeonFlow, out var _)) { return; } List list = (from o in GetEntranceTeleports(scene) orderby o.entranceId select o).ToList(); foreach (EntranceTeleport item in list) { item.entranceId = list.IndexOf(item); } text = text + "EntranceTeleport's Found, " + extendedLevel.NumberlessPlanetName + " Contains " + list.Count + " Entrances! ( " + (list.Count - 1) + " Fire Escapes) \n"; text = text + "Main Entrance: " + ((Object)((Component)list[0]).gameObject).name + " (Entrance ID: " + list[0].entranceId + ")\n"; foreach (EntranceTeleport item2 in list) { if (item2.entranceId != 0) { text = text + "Alternate Entrance: " + ((Object)((Component)item2).gameObject).name + " (Entrance ID: " + item2.entranceId + ")\n"; } } foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps) { if (globalProp.ID == 1231) { text = text + "Found Fire Escape GlobalProp: (ID: 1231), Modifying Spawn rate Count From (" + globalProp.Count.Min + "," + globalProp.Count.Max + ") To (" + (list.Count - 1) + "," + (list.Count - 1) + ")\n"; globalProp.Count = new IntRange(list.Count - 1, list.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) { globalProp.Count.Min = globalProp.Count.Min * Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / Patches.RoundManager.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate)); globalProp.Count.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_0037: 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_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) 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; Transform transform = ((Component)generator.CurrentDungeon).transform; Bounds bounds = generator.CurrentDungeon.Bounds; float y = transform.TransformPoint(((Bounds)(ref bounds)).min).y; Scene sceneByName = SceneManager.GetSceneByName(StartOfRound.Instance.currentLevel.sceneName); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).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 List customLevelMeshCollidersList = new List(); 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 FootstepSurface[] defaultFootstepSurfaces; internal static Dictionary> cachedLevelColliderMaterialDictionary = new Dictionary>(); internal static Dictionary> cachedLevelMaterialColliderDictionary = new Dictionary>(); internal static Dictionary activeExtendedFootstepSurfaceDictionary = new Dictionary(); internal static LayerMask triggerMask; internal static Shader vanillaWaterShader; internal static async void EnableMeshColliders() { List list = new List(); int num = 0; MeshCollider[] array = Object.FindObjectsOfType(); foreach (MeshCollider val in array) { if (((Object)((Component)val).gameObject).name.Contains(" (LLL Tracked)")) { list.Add(val); } } Task[] array2 = new Task[list.Count]; foreach (MeshCollider item in list) { array2[num] = EnableMeshCollider(item); num++; } await Task.WhenAll(array2); } internal static async Task EnableMeshCollider(MeshCollider meshCollider) { ((Collider)meshCollider).enabled = true; ((Object)((Component)meshCollider).gameObject).name.Replace(" (LLL Tracked)", ""); await Task.Yield(); } internal static void RefreshShipAnimatorClips(ExtendedLevel extendedLevel) { //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 val2 = (AnimatorOverrideController)(object)(shipAnimator.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(shipAnimator.runtimeAnimatorController)); val2["HangarShipLandB"] = extendedLevel.ShipFlyToMoonClip; val2["ShipLeave"] = extendedLevel.ShipFlyFromMoonClip; } 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 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 RefreshFootstepSurfaces() { List list = new List(defaultFootstepSurfaces); foreach (ExtendedFootstepSurface extendedFootstepSurface in LevelManager.CurrentExtendedLevel.ExtendedMod.ExtendedFootstepSurfaces) { extendedFootstepSurface.footstepSurface.surfaceTag = "Untagged"; list.Add(extendedFootstepSurface.footstepSurface); } Patches.StartOfRound.footstepSurfaces = list.ToArray(); } internal static void TryRestoreWaterShaders(Scene scene) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) List list = new List(); MeshRenderer[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (MeshRenderer val in array) { if (!(((Component)val).gameObject.scene == scene)) { continue; } Material[] sharedMaterials = ((Renderer)val).sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(((Object)val2).name) && !list.Contains(val2)) { list.Add(val2); } } } foreach (Material item in list) { ContentRestorer.TryRestoreWaterShader(item); } } internal static void BakeSceneColliderMaterialData(Scene scene) { //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) cachedLevelColliderMaterialDictionary.Clear(); cachedLevelMaterialColliderDictionary.Clear(); activeExtendedFootstepSurfaceDictionary = GetActiveExtendedFoostepSurfaceDictionary(); triggerMask = LayerMask.op_Implicit(LayerMask.NameToLayer("Triggers")); List list = new List(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { Collider[] components = val.GetComponents(); foreach (Collider val2 in components) { if (ValidateCollider(val2) && !list.Contains(val2)) { list.Add(val2); } } Collider[] componentsInChildren = val.GetComponentsInChildren(); foreach (Collider val3 in componentsInChildren) { if (ValidateCollider(val3) && !list.Contains(val3)) { list.Add(val3); } } } MeshRenderer val4 = default(MeshRenderer); foreach (Collider item in list) { if (!((Component)item).TryGetComponent(ref val4)) { continue; } List list2 = new List(); Material[] sharedMaterials = ((Renderer)val4).sharedMaterials; foreach (Material val5 in sharedMaterials) { if ((Object)(object)val5 != (Object)null && !string.IsNullOrEmpty(((Object)val5).name)) { list2.Add(val5); } } if (!cachedLevelColliderMaterialDictionary.ContainsKey(item)) { cachedLevelColliderMaterialDictionary.Add(item, new List(list2)); } foreach (Material item2 in list2) { if (!cachedLevelMaterialColliderDictionary.ContainsKey(((Object)item2).name)) { cachedLevelMaterialColliderDictionary.Add(((Object)item2).name, new List { item }); } else if (!cachedLevelMaterialColliderDictionary[((Object)item2).name].Contains(item)) { cachedLevelMaterialColliderDictionary[((Object)item2).name].Add(item); } } } } internal static bool ValidateCollider(Collider collider) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null) { return false; } if (!((Component)collider).gameObject.activeSelf) { return false; } if (collider.isTrigger) { return false; } if (((Component)collider).gameObject.layer == LayerMask.op_Implicit(triggerMask)) { return false; } if (!((Component)collider).gameObject.CompareTag("Untagged")) { return false; } return true; } internal static Dictionary GetActiveExtendedFoostepSurfaceDictionary() { Dictionary dictionary = new Dictionary(); foreach (ExtendedFootstepSurface extendedFootstepSurface in LevelManager.CurrentExtendedLevel.ExtendedMod.ExtendedFootstepSurfaces) { foreach (Material associatedMaterial in extendedFootstepSurface.associatedMaterials) { if ((Object)(object)associatedMaterial != (Object)null && !string.IsNullOrEmpty(((Object)associatedMaterial).name) && !dictionary.ContainsKey(((Object)associatedMaterial).name)) { dictionary.Add(((Object)associatedMaterial).name, extendedFootstepSurface.footstepSurface); } } } return dictionary; } public static bool TryGetFootstepSurface(Collider collider, out FootstepSurface footstepSurface) { footstepSurface = null; if ((Object)(object)collider == (Object)null) { return false; } if (cachedLevelColliderMaterialDictionary.TryGetValue(collider, out var value) && value != null) { foreach (Material item in value) { if ((Object)(object)item != (Object)null && !string.IsNullOrEmpty(((Object)item).name)) { activeExtendedFootstepSurfaceDictionary.TryGetValue(((Object)item).name, out footstepSurface); } } } return footstepSurface != null; } } public struct NetworkEnemyTypeReference : INetworkSerializable { private uint m_NetworkEnemyTypeObjectId; private static uint s_NullId = uint.MaxValue; private List m_Prefabs => LethalLevelLoaderNetworkManager.networkManager.NetworkConfig.Prefabs.m_Prefabs; public uint NetworkEnemyTypeObjectId { get { return m_NetworkEnemyTypeObjectId; } internal set { m_NetworkEnemyTypeObjectId = value; } } public NetworkEnemyTypeReference(EnemyType enemy) { m_NetworkEnemyTypeObjectId = 0u; if ((Object)(object)enemy == (Object)null) { m_NetworkEnemyTypeObjectId = s_NullId; 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 bool TryGet(out EnemyType enemy, NetworkManager networkManager = null) { enemy = Resolve(this); return (Object)(object)enemy != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static EnemyType Resolve(NetworkEnemyTypeReference networkEnemy) { if (networkEnemy.m_NetworkEnemyTypeObjectId == s_NullId) { return null; } return networkEnemy.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 EnemyType GetEnemyTypeFromNetworkPrefabIdHash(uint idHash) { EnemyAI val = default(EnemyAI); for (int i = 0; i < m_Prefabs.Count; i++) { if (m_Prefabs[i].SourcePrefabGlobalObjectIdHash == idHash && m_Prefabs[i].Prefab.TryGetComponent(ref val)) { return val.enemyType; } } return null; } private uint GetIdHashFromEnemyType(EnemyType enemy) { for (int i = 0; i < m_Prefabs.Count; i++) { if ((Object)(object)m_Prefabs[i].Prefab == (Object)(object)enemy.enemyPrefab) { return m_Prefabs[i].SourcePrefabGlobalObjectIdHash; } } return 0u; } } public struct NetworkExtendedLevelReference : INetworkSerializable { private uint m_ExtendedLevelId; private static uint s_NullId = uint.MaxValue; private List m_Levels => PatchedContent.ExtendedLevels; public uint ExtendedLevelId { get { return m_ExtendedLevelId; } internal set { m_ExtendedLevelId = value; } } public NetworkExtendedLevelReference(ExtendedLevel level) { m_ExtendedLevelId = 0u; if ((Object)(object)level == (Object)null) { m_ExtendedLevelId = s_NullId; return; } if ((Object)(object)level.SelectableLevel == (Object)null) { throw new ArgumentException(((Object)level).name + "'s SelectableLevel is Missing!"); } m_ExtendedLevelId = GetIndexIDFromExtendedLevel(level); } public bool TryGet(out ExtendedLevel level, NetworkManager networkManager = null) { level = Resolve(this); return (Object)(object)level != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ExtendedLevel Resolve(NetworkExtendedLevelReference level) { if (level.m_ExtendedLevelId == s_NullId) { return null; } return level.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 ExtendedLevel GetExtendedLevelFromIndexID(uint indexID) { for (int i = 0; i < m_Levels.Count; i++) { if (m_Levels[i].SelectableLevel.levelID == indexID) { return m_Levels[i]; } } return null; } private uint GetIndexIDFromExtendedLevel(ExtendedLevel level) { return (uint)level.SelectableLevel.levelID; } } public static class ContentTagManager { internal static Dictionary> globalContentTagDictionary = new Dictionary>(); internal static Dictionary> globalcontentTagExtendedContentDictionary = new Dictionary>(); internal static void PopulateContentTagData() { List list = new List(); Dictionary> dictionary = new Dictionary>(); List list2 = new List(); foreach (ExtendedMod item in PatchedContent.ExtendedMods.Concat(new List { PatchedContent.VanillaMod })) { foreach (ExtendedContent extendedContent in item.ExtendedContents) { foreach (ContentTag contentTag in extendedContent.ContentTags) { if (!list2.Contains(contentTag)) { list2.Add(contentTag); } } } } foreach (ContentTag item2 in list2) { if (dictionary.TryGetValue(item2.contentTagName, out var value)) { value.Add(item2); continue; } dictionary.Add(item2.contentTagName, new List { item2 }); } globalContentTagDictionary = new Dictionary>(dictionary); foreach (ExtendedMod item3 in PatchedContent.ExtendedMods.Concat(new List { PatchedContent.VanillaMod })) { foreach (ExtendedContent extendedContent2 in item3.ExtendedContents) { foreach (ContentTag contentTag2 in extendedContent2.ContentTags) { if (globalcontentTagExtendedContentDictionary.TryGetValue(contentTag2.contentTagName, out var value2)) { value2.Add(extendedContent2); continue; } globalcontentTagExtendedContentDictionary.Add(contentTag2.contentTagName, new List { extendedContent2 }); } } } string text = "Global Tag Dictionary Report\n\n"; foreach (KeyValuePair> item4 in dictionary) { text = text + "\nTag: " + item4.Key + ", Found Matching ContentTags: " + item4.Value.Count; } DebugHelper.Log(text, DebugType.Developer); } internal static List CreateNewContentTags(List tags) { List list = new List(); foreach (string tag in tags) { if (!string.IsNullOrEmpty(tag)) { list.Add(ContentTag.Create(tag)); } } return list; } public static List GetAllExtendedContentsByTag(string tag) { if (globalcontentTagExtendedContentDictionary.TryGetValue(tag, out var value)) { return value; } return new List(); } 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_0031: 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) color = Color.white; foreach (ContentTag contentTag in extendedContent.ContentTags) { if (contentTag.contentTagName == tag) { color = contentTag.contentTagColor; return true; } } return false; } internal static void MergeAllExtendedModTags() { foreach (ExtendedMod item in PatchedContent.ExtendedMods.Concat(new List { PatchedContent.VanillaMod })) { MergeExtendedModTags(item); } } internal static void MergeExtendedModTags(ExtendedMod extendedMod) { Dictionary> dictionary = new Dictionary>(); Dictionary dictionary2 = 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 { extendedContent }); } } foreach (ContentTag key in dictionary.Keys) { foreach (ContentTag key2 in dictionary.Keys) { if (key.contentTagName.ToLower() == key2.contentTagName.ToLower() && !dictionary2.ContainsKey(key2)) { dictionary2.Add(key2, key); } } } foreach (ExtendedContent extendedContent2 in extendedMod.ExtendedContents) { foreach (KeyValuePair item in dictionary2) { if (extendedContent2.ContentTags.Contains(item.Key)) { extendedContent2.ContentTags[extendedContent2.ContentTags.IndexOf(item.Key)] = item.Value; } } } } } public class DungeonManager { public static DungeonEvents GlobalDungeonEvents = new DungeonEvents(); public static ExtendedDungeonFlow CurrentExtendedDungeonFlow { get { ExtendedDungeonFlow result = null; if ((Object)(object)Patches.RoundManager != (Object)null && (Object)(object)Patches.RoundManager.dungeonGenerator != (Object)null && TryGetExtendedDungeonFlow(Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow, out var returnExtendedDungeonFlow)) { result = returnExtendedDungeonFlow; } return result; } } internal static void PatchVanillaDungeonLists() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { customExtendedDungeonFlow.DungeonID = Patches.RoundManager.dungeonFlowTypes.Length; IndoorMapType val = new IndoorMapType(customExtendedDungeonFlow.DungeonFlow, customExtendedDungeonFlow.MapTileSize, customExtendedDungeonFlow.FirstTimeDungeonAudio); Patches.RoundManager.dungeonFlowTypes = CollectionExtensions.AddItem((IEnumerable)Patches.RoundManager.dungeonFlowTypes, val).ToArray(); if ((Object)(object)customExtendedDungeonFlow.FirstTimeDungeonAudio != (Object)null) { Patches.RoundManager.firstTimeDungeonAudios = CollectionExtensions.AddItem((IEnumerable)Patches.RoundManager.firstTimeDungeonAudios, customExtendedDungeonFlow.FirstTimeDungeonAudio).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.rarity = item.extendedDungeonFlow.LevelMatchingProperties.GetDynamicRarity(extendedLevel); if (item.rarity != 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)(LevelWeatherType)(ref extendedLevel.SelectableLevel.currentWeather)).ToString(); text += "\n"; List list3 = list.Select((ExtendedDungeonFlowWithRarity d) => d.extendedDungeonFlow).ToList(); text += "Unviable ExtendedDungeonFlows: "; foreach (ExtendedDungeonFlowWithRarity item2 in list2) { if (!list3.Contains(item2.extendedDungeonFlow)) { text = text + item2.extendedDungeonFlow.DungeonName + ", "; } } text = text.TrimEnd(',', ' '); text += "\n"; list = list.OrderBy((ExtendedDungeonFlowWithRarity e) => e.rarity).Reverse().ToList(); text += "Viable ExtendedDungeonFlows: "; foreach (ExtendedDungeonFlowWithRarity item3 in list) { text = text + item3.extendedDungeonFlow.DungeonName + " (" + item3.rarity + "), "; } 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) { returnExtendedDungeonFlow = null; List list = null; if ((Object)(object)dungeonFlow == (Object)null) { return false; } switch (contentType) { case ContentType.Any: list = PatchedContent.ExtendedDungeonFlows; break; case ContentType.Custom: list = PatchedContent.CustomExtendedDungeonFlows; break; case ContentType.Vanilla: list = PatchedContent.VanillaExtendedDungeonFlows; break; } foreach (ExtendedDungeonFlow item in list) { if ((Object)(object)item.DungeonFlow == (Object)(object)dungeonFlow) { returnExtendedDungeonFlow = item; } } return (Object)(object)returnExtendedDungeonFlow != (Object)null; } internal static bool TryGetExtendedDungeonFlow(IndoorMapType indoorMapType, out ExtendedDungeonFlow returnExtendedDungeonFlow, ContentType contentType = ContentType.Any) { return TryGetExtendedDungeonFlow(indoorMapType.dungeonFlow, out returnExtendedDungeonFlow, contentType); } } public class EnemyManager { 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() { List vanillaExtendedEnemyTypes = PatchedContent.VanillaExtendedEnemyTypes; List customExtendedEnemyTypes = PatchedContent.CustomExtendedEnemyTypes; int num = -1; foreach (ExtendedEnemyType item in vanillaExtendedEnemyTypes) { if (item.EnemyID > num) { num = item.EnemyID; } } int num2 = 1; foreach (ExtendedEnemyType item2 in customExtendedEnemyTypes) { ScanNodeProperties componentInChildren = item2.EnemyType.enemyPrefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { item2.ScanNodeProperties = componentInChildren; item2.ScanNodeProperties.creatureScanID = num + num2; item2.EnemyID = num + num2; DebugHelper.Log("Setting Custom EnemyType: " + item2.EnemyType.enemyName + " ID To: " + (num + num2), DebugType.Developer); } num2++; } } 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 struct EnemyData { public EnemyAI enemyAI; public GameObject gamePrefab; public GameObject networkPrefab; } internal enum SpawnableEnemyType { None = -1, Inside, Outside, Daytime } public static class ItemManager { 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 item) => (Object)(object)item.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 item2 = new SpawnableItemWithRarity(extendedItem.Item, num2); extendedLevel.SelectableLevel.spawnableScrap.Add(item2); 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 void GetExtendedItemPriceData() { } public static void GetExtendedItemWeightData() { } internal static int GetAverageScrapValue(ExtendedItem extendedItem) { return Mathf.RoundToInt(Mathf.Lerp((float)extendedItem.Item.minValue, (float)extendedItem.Item.maxValue, 0.5f)); } } public 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 List queuedNetworkPrefabs = new List(); public static bool networkHasStarted; public static LethalLevelLoaderNetworkManager Instance { get { if ((Object)(object)_instance == (Object)null) { _instance = Object.FindObjectOfType(); } 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(12573863u, val3, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val4, 12573863u, val3, 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.extendedDungeonFlow.DungeonFlow)]).name; list.Add(stringContainer2); list2.Add(item.rarity); } } 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(3226356970u, val3, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val4, 3226356970u, val3, 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(3957821582u, val3, val2, (SendTo)7, (RpcDelivery)0); bool flag = levelNames != null; ((FastBufferWriter)(ref val4)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val4)).WriteValueSafe(levelNames, default(ForNetworkSerializable)); } bool flag2 = weatherTypes != null; ((FastBufferWriter)(ref val4)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val4)).WriteValueSafe(weatherTypes, default(ForEnums)); } ((NetworkBehaviour)this).__endSendRpc(ref val4, 3957821582u, val3, 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(2948417154u, val3, val2, (SendTo)7, (RpcDelivery)0); bool flag = dungeonFlowNames != null; ((FastBufferWriter)(ref val4)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val4)).WriteValueSafe(dungeonFlowNames, default(ForNetworkSerializable)); } bool flag2 = rarities != null; ((FastBufferWriter)(ref val4)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val4)).WriteValueSafe(rarities, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendRpc(ref val4, 2948417154u, val3, 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 = new List(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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(1429734586u, val3, val2, (SendTo)2, (RpcDelivery)0); ((FastBufferWriter)(ref val4)).WriteValueSafe(ref extendedLevelData, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val4, 1429734586u, val3, 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(1926043830u, val3, val2, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val4)).WriteValueSafe(ref extendedLevelData, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val4, 1926043830u, val3, 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.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++; } } 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; } } protected internal override string __getTypeName() { return "LethalLevelLoaderNetworkManager"; } } public class LevelManager { 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 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 { ExtendedLevel result = null; if ((Object)(object)Patches.StartOfRound != (Object)null && TryGetExtendedLevel(Patches.StartOfRound.currentLevel, out var returnExtendedLevel)) { result = returnExtendedLevel; } return result; } } internal static void PatchVanillaLevelLists() { Patches.StartOfRound.levels = (from level in PatchedContent.ExtendedLevels where level.ContentType != ContentType.External select level.SelectableLevel).ToArray(); TerminalManager.Terminal.moonsCatalogueList = Patches.StartOfRound.levels.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 (((Object)runtimeAnimatorController.animationClips[i]).name == "HangarShipLandB") { LevelLoader.defaultShipFlyToMoonClip = runtimeAnimatorController.animationClips[i]; } else if (((Object)runtimeAnimatorController.animationClips[i]).name == "ShipLeave") { 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]; } } public static bool TryGetExtendedLevel(SelectableLevel selectableLevel, out ExtendedLevel returnExtendedLevel, ContentType levelType = ContentType.Any) { returnExtendedLevel = null; List list = null; if ((Object)(object)selectableLevel == (Object)null) { return false; } if (levelType == ContentType.Any) { list = PatchedContent.ExtendedLevels; } else if ((levelType == ContentType.Custom || levelType == ContentType.External) ? true : false) { list = PatchedContent.CustomExtendedLevels; } else if (levelType == ContentType.Vanilla) { list = PatchedContent.VanillaExtendedLevels; } returnExtendedLevel = list.Find((ExtendedLevel extendedLevel) => (Object)(object)extendedLevel.SelectableLevel == (Object)(object)selectableLevel); return (Object)(object)returnExtendedLevel != (Object)null; } public static ExtendedLevel GetExtendedLevel(SelectableLevel selectableLevel) { ExtendedLevel result = null; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if ((Object)(object)extendedLevel.SelectableLevel == (Object)(object)selectableLevel) { result = extendedLevel; } } return result; } public static void RegisterExtendedFootstepSurfaces(ExtendedLevel extendedLevel) { } public static void RefreshCachedFootstepSurfaceData() { } 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 (!vanillaExtendedLevel.SelectableLevel.riskLevel.Contains("Safe") && !string.IsNullOrEmpty(vanillaExtendedLevel.SelectableLevel.riskLevel)) { if (dictionary.TryGetValue(vanillaExtendedLevel.SelectableLevel.riskLevel, out var value)) { value.Add(vanillaExtendedLevel.CalculatedDifficultyRating); continue; } dictionary.Add(vanillaExtendedLevel.SelectableLevel.riskLevel, new List { vanillaExtendedLevel.CalculatedDifficultyRating }); } } foreach (KeyValuePair> item in dictionary) { string text = "Vanilla Risk Level Group (" + item.Key + "): "; if (item.Value != null) { text = text + " Average - " + item.Value.Average() + ", Values - "; foreach (int item2 in item.Value) { text = text + item2 + ", "; } } DebugHelper.Log(text, DebugType.Developer); } foreach (KeyValuePair item3 in new Dictionary(dynamicRiskLevelDictionary)) { foreach (KeyValuePair> item4 in dictionary) { if (item3.Key.Equals(item4.Key)) { DebugHelper.Log("Setting RiskLevel " + item4.Key + " To " + (int)item4.Value.Average(), DebugType.Developer); dynamicRiskLevelDictionary[item3.Key] = Mathf.RoundToInt((float)item4.Value.Average()); } } } DebugHelper.Log("Starting To Assign - and + Risk Levels", DebugType.Developer); int num = 0; foreach (KeyValuePair item5 in new Dictionary(dynamicRiskLevelDictionary)) { string key = string.Empty; string empty = string.Empty; string key2 = string.Empty; DebugHelper.Log("Trying To Assign Value To Risk Level: " + item5.Key, DebugType.Developer); if (item5.Key.Contains("-")) { if (num != 0) { key = dynamicRiskLevelDictionary.Keys.ToList()[num - 2]; } empty = dynamicRiskLevelDictionary.Keys.ToList()[num + 1]; if (num == 0) { dynamicRiskLevelDictionary[item5.Key] = dynamicRiskLevelDictionary[empty] / 2; } else { dynamicRiskLevelDictionary[item5.Key] = Mathf.RoundToInt(Mathf.Lerp((float)dynamicRiskLevelDictionary[key], (float)dynamicRiskLevelDictionary[empty], 0.66f)); } } else if (item5.Key.Contains("+") && !item5.Key.Equals("S+")) { empty = dynamicRiskLevelDictionary.Keys.ToList()[num - 1]; if (!item5.Key.Contains("S")) { key2 = dynamicRiskLevelDictionary.Keys.ToList()[num + 2]; } if (item5.Key.Equals("S++")) { dynamicRiskLevelDictionary[item5.Key] = dynamicRiskLevelDictionary[empty] * 2; } else if (item5.Key.Equals("S+++")) { dynamicRiskLevelDictionary[item5.Key] = dynamicRiskLevelDictionary[empty] * 3; } else { dynamicRiskLevelDictionary[item5.Key] = Mathf.RoundToInt(Mathf.Lerp((float)dynamicRiskLevelDictionary[empty], (float)dynamicRiskLevelDictionary[key2], 0.33f)); } } DebugHelper.Log("Risk Level: " + item5.Key + " Was Assigned Calculated Difficulty Of: " + dynamicRiskLevelDictionary[item5.Key], DebugType.Developer); num++; } foreach (KeyValuePair item6 in new Dictionary(dynamicRiskLevelDictionary)) { DebugHelper.Log("Dynamic Risk Level Pair: " + item6.Key + " (" + item6.Value + ")", DebugType.Developer); } } public static void AssignCalculatedRiskLevels() { Dictionary dictionary = new Dictionary(); List list = new List(dynamicRiskLevelDictionary.Values); 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) { int customLevelCalculatedDifficultyRating = customExtendedLevel.CalculatedDifficultyRating; int num = list[0]; num = list.OrderBy((int item) => Math.Abs(customLevelCalculatedDifficultyRating - item)).First(); if (num != 0) { customExtendedLevel.SelectableLevel.riskLevel = dictionary[num]; } } } List list2 = new List(PatchedContent.ExtendedLevels).OrderBy((ExtendedLevel o) => o.CalculatedDifficultyRating).ToList(); foreach (ExtendedLevel item4 in list2) { DebugHelper.Log(item4.NumberlessPlanetName + " (" + item4.SelectableLevel.riskLevel + ") (" + item4.CalculatedDifficultyRating + ")", DebugType.Developer); } } public static void LogDayHistory() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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)TimeOfDay.Instance == (Object)null) { DebugHelper.LogWarning("Game Seems Uninitialized, Exiting LogDayHistory Early!", DebugType.Developer); return; } DayHistory dayHistory = new DayHistory(); daysTotal++; dayHistory.allViableOptions = (from e in DungeonManager.GetValidExtendedDungeonFlows(CurrentExtendedLevel, debugResults: false) select e.extendedDungeonFlow).ToList(); dayHistory.extendedLevel = CurrentExtendedLevel; dayHistory.extendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; dayHistory.day = daysTotal; dayHistory.quota = TimeOfDay.Instance.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)(LevelWeatherType)(ref dayHistory.weatherEffect)).ToString(); DebugHelper.Log(text, DebugType.User); if (dayHistoryList == null) { dayHistoryList = new List(); } 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 = 0f; foreach (SpawnableEnemyWithRarity item2 in extendedLevel.SelectableLevel.Enemies.Concat(extendedLevel.SelectableLevel.OutsideEnemies).Concat(extendedLevel.SelectableLevel.DaytimeEnemies)) { if (item2.rarity != 0 && (Object)(object)item2.enemyType != (Object)null && item2.rarity / 10 != 0) { num4 += item2.enemyType.PowerLevel * 100f / (float)(item2.rarity / 10); } } 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; } } public class DayHistory { public int quota; public int day; public ExtendedLevel extendedLevel; public List allViableOptions; public ExtendedDungeonFlow extendedDungeonFlow; public LevelWeatherType weatherEffect; } internal 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 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.FindObjectOfType(); } 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); } 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) { 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(1003568550u, val3, val2, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val4, 1003568550u, val3, 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(2729437277u, val3, val2, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val4, 2729437277u, val3, 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) { status = false; if (routeGroup.LoadingStatus != AssetBundleGroupLoadingStatus.Loading) { 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 val3 = default(RpcParams); FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendRpc(2843210445u, val3, val2, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val4, clientID); ((FastBufferWriter)(ref val4)).WriteValueSafe(ref status, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val4, 2843210445u, val3, val2, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; int num = ((NetworkBehaviour)this).NetworkManager.ConnectedClientsIds.ToList().IndexOf(clientID); if (playersLoadStatus.Count <= num) { DebugHelper.LogError("Tried To Set LoadedStatus When List Is Invalid (ClientID: " + clientID + ", 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) { List list = new List(); if ((Object)(object)route == (Object)null) { return list; } List list2 = route.SceneSelections.Select((StringWithRarity s) => s.Name).ToList(); foreach (string item in list2) { if (!assetBundleGroupSceneDict.TryGetValue(item, out var value)) { continue; } foreach (AssetBundleGroup item2 in value) { if (!list.Contains(item2)) { list.Add(item2); } } } return list; } private void GenerateSceneDict() { networkSceneInfos = new List(); Dictionary levelSceneDict = NetworkScenePatcher.GetLevelSceneDict(); List list = new List(levelSceneDict.Values); 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)) { if (!value.Contains(assetBundleGroup)) { value.Add(assetBundleGroup); } } else { assetBundleGroupSceneDict.Add(sceneName, new List { 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; } } 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.ContainsKey(num2)) { AllItemsListItemData itemAllItemsListData2 = allItemsListItemDataDict[num2]; if (itemAllItemsListIndex2 != num2) { DebugHelper.Log($"Fixing Item ┌ {savedShipItemData.itemAllItemsListData.modName} ┬ {savedShipItemData.itemAllItemsListData.itemName} ┬ {savedShipItemData.itemAllItemsListData.itemObjectName} ┬ #{itemAllItemsListIndex2}", DebugType.User); DebugHelper.Log($" -----> └ {itemAllItemsListData2.modName} ┴ {itemAllItemsListData2.itemName} ┴ {itemAllItemsListData2.itemObjectName} ┴ #{num2}", DebugType.User); } savedShipItemData.itemAllItemsListData = itemAllItemsListData2; if (!itemAllItemsListData2.isScrap && savedShipItemData.itemScrapValue >= 0) { savedShipItemData.itemScrapValue = -1; } else if (itemAllItemsListData2.isScrap && savedShipItemData.itemScrapValue == -1) { savedShipItemData.itemScrapValue = 0; } if (!itemAllItemsListData2.saveItemVariable && savedShipItemData.itemAdditionalSavedData >= 0) { savedShipItemData.itemAdditionalSavedData = -1; } else if (itemAllItemsListData2.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[] first = modNameA.Split(';'); string[] second = modNameB.Split(';'); return first.Intersect(second).Any(); } internal static List GetAllItemsListItemDatas(List itemIDs, Dictionary itemDataDict) { List list = new List(); foreach (int itemID in itemIDs) { if (itemDataDict.ContainsKey(itemID)) { list.Add(itemDataDict[itemID]); } else { list.Add(new AllItemsListItemData("", "", "", "", itemID, -1, 0, newIsScrap: false, newSaveItemVariable: false)); } } return list; } internal static List GetConstructedSavedShipItemData(Dictionary itemDataDict) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; List list2 = null; List list3 = null; List list4 = null; List list5 = null; list2 = ((!ES3.KeyExists("shipGrabbableItemIDs", currentSaveFileName)) ? new List() : ES3.Load("shipGrabbableItemIDs", currentSaveFileName).ToList()); list3 = ((!ES3.KeyExists("shipGrabbableItemPos", currentSaveFileName)) ? new List() : ES3.Load("shipGrabbableItemPos", currentSaveFileName).ToList()); list4 = ((!ES3.KeyExists("shipScrapValues", currentSaveFileName)) ? new List() : ES3.Load("shipScrapValues", currentSaveFileName).ToList()); list5 = ((!ES3.KeyExists("shipItemSaveData", currentSaveFileName)) ? new List() : ES3.Load("shipItemSaveData", currentSaveFileName).ToList()); 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 { public int itemAllItemsListIndex; public Vector3 itemPosition; public int itemScrapValue; public int itemAdditionalSavedData; public AllItemsListItemData itemAllItemsListData; public SavedShipItemData(int newItemAllItemsListIndex, Vector3 newItemPosition, int newItemScrapValue, int newItemAdditionalSavedData, AllItemsListItemData newItemAllItemsListData) { //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) itemAllItemsListIndex = newItemAllItemsListIndex; itemPosition = newItemPosition; itemScrapValue = newItemScrapValue; itemAdditionalSavedData = newItemAdditionalSavedData; itemAllItemsListData = newItemAllItemsListData; } } public 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); private static Terminal _terminal; internal static TerminalNode lockedNode; internal static int moonsInCataloguePage; 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)_terminal == (Object)null) { _terminal = Object.FindFirstObjectByType((FindObjectsInactive)0); } return _terminal; } } 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 > StartOfRound.Instance.levels.Length - 1) { DebugHelper.LogError("Invalid DisplayPlanetInfo For Route Node: " + ((Object)result).name, DebugType.User); return true; } ExtendedLevel extendedLevel = LevelManager.GetExtendedLevel(StartOfRound.Instance.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: " + ((object)extendedLevel)?.ToString() + ", CurrentNode Is: " + ((Object)currentNode).name + ", LoadNode Is: " + ((Object)result).name, DebugType.User); } else { DebugHelper.Log("LockedNodeEventTest: ExtendedLevel Is: " + ((object)extendedLevel)?.ToString() + ", 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) { if (extendedLevel.LockedRouteNodeText != string.Empty) { lockedNode.displayText = extendedLevel.LockedRouteNodeText + "\n\n\n"; } else { lockedNode.displayText = "Route to " + extendedLevel.SelectableLevel.PlanetName + " is currently locked.\n\n\n"; } terminalNode = lockedNode; } internal static void RefreshExtendedLevelGroups() { currentMoonsCataloguePage.ExtendedLevelGroups.Clear(); currentMoonsCataloguePage = new MoonsCataloguePage(defaultMoonsCataloguePage.ExtendedLevelGroups); 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: " + (object)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") && Enum.TryParse(typeof(PreviewInfoType), GetTerminalEventEnum(loadNode.terminalEvent), out object result)) { Settings.levelPreviewInfoType = (PreviewInfoType)result; } else if (((Object)loadNode).name.Contains("sort") && Enum.TryParse(typeof(SortInfoType), GetTerminalEventEnum(loadNode.terminalEvent), out result2)) { Settings.levelPreviewSortType = (SortInfoType)result2; } else if (((Object)loadNode).name.Contains("filter") && 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 item in new List(extendedLevelGroup.extendedLevelsList)) { bool flag = item.IsRouteHidden; if (Settings.levelPreviewFilterType.Equals(FilterInfoType.Price)) { flag = item.RoutePrice > Terminal.groupCredits; } else if (Settings.levelPreviewFilterType.Equals(FilterInfoType.Weather)) { flag = GetWeatherConditions(item) != string.Empty; } else if (Settings.levelPreviewFilterType.Equals(FilterInfoType.Tag)) { flag = !item.TryGetTag(currentTagFilter); } if (flag) { list.Add(item); } } } foreach (ExtendedLevelGroup extendedLevelGroup2 in moonsCataloguePage.ExtendedLevelGroups) { foreach (ExtendedLevel item2 in list) { if (extendedLevelGroup2.extendedLevelsList.Contains(item2)) { extendedLevelGroup2.extendedLevelsList.Remove(item2); } } } if (Settings.levelPreviewFilterType != FilterInfoType.None) { moonsCataloguePage.RebuildLevelGroups(new List(moonsCataloguePage.ExtendedLevelGroups), Settings.moonsCatalogueSplitCount); } } internal static void SortMoonsCataloguePage(MoonsCataloguePage cataloguePage) { if (Settings.levelPreviewSortType.Equals(SortInfoType.Price)) { cataloguePage.RebuildLevelGroups(cataloguePage.ExtendedLevels.OrderBy((ExtendedLevel o) => o.RoutePrice), Settings.moonsCatalogueSplitCount); } else if (Settings.levelPreviewSortType.Equals(SortInfoType.Difficulty)) { cataloguePage.RebuildLevelGroups(cataloguePage.ExtendedLevels.OrderBy((ExtendedLevel o) => o.CalculatedDifficultyRating), Settings.moonsCatalogueSplitCount); } } internal static void SetStoryLogAuthorPostProcessText() { } public static void AddTerminalNodeEventListener(TerminalNode node, LoadNodeAction action, LoadNodeActionType loadNodeActionType) { if ((Object)(object)node != (Object)null && action != null) { if (loadNodeActionType == LoadNodeActionType.Before && !onBeforeLoadNewNodeRegisteredEventsDictionary.ContainsKey(node)) { onBeforeLoadNewNodeRegisteredEventsDictionary.Add(node, action); DebugHelper.Log("Successfully Registered OnBeforeLoadNode Action: " + action.Method.Name + " To TerminalNode: " + ((Object)node).name, DebugType.Developer); } else if (loadNodeActionType == LoadNodeActionType.After && !onLoadNewNodeRegisteredEventsDictionary.ContainsKey(node)) { onLoadNewNodeRegisteredEventsDictionary.Add(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 displayText = moonsKeyword.specialKeywordResult.displayText; if (displayText.Contains("\n\n")) { displayText = displayText.Substring(displayText.IndexOf("\n\n")); displayText = displayText.SkipToLetters(); if (displayText.Contains("\n\n")) { displayText = displayText.Substring(displayText.IndexOf("\n\n")); if (moonsKeyword.specialKeywordResult.displayText.Contains(displayText)) { displayText = displayText.Substring(displayText.IndexOf("\n\n")); displayText = moonsKeyword.specialKeywordResult.displayText.Replace(displayText, string.Empty) + "\n\n"; } else { DebugHelper.LogError("Failed To get Moons Catalogue overview text dynamically, falling back to hardcoded English variant.", DebugType.Developer); displayText = text; } } else { DebugHelper.LogError("Failed To get Moons Catalogue overview text dynamically, falling back to hardcoded English variant.", DebugType.Developer); displayText = text; } } else { DebugHelper.LogError("Failed To get Moons Catalogue overview text dynamically, falling back to hardcoded English variant.", DebugType.Developer); displayText = text; } return displayText + 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; } } if (text.Contains('\n')) { text.Replace(text.Substring(text.LastIndexOf('\n')), string.Empty); } string text3 = Settings.levelPreviewFilterType.ToString().ToUpper(); if (Settings.levelPreviewFilterType == FilterInfoType.Tag) { text3 = currentTagFilter.ToUpper(); } return text + "\n____________________________\nPREVIEW: " + Settings.levelPreviewInfoType.ToString().ToUpper() + " | SORT: " + Settings.levelPreviewSortType.ToString().ToUpper() + " | FILTER: " + text3 + "\n"; } public static string GetExtendedLevelPreviewInfo(ExtendedLevel extendedLevel) { string text = string.Empty; string empty = string.Empty; if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.Weather)) { text = GetWeatherConditions(extendedLevel); } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.Price)) { text = empty + "($" + extendedLevel.RoutePrice + ")"; } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.Difficulty)) { text = empty + "(" + extendedLevel.SelectableLevel.riskLevel + ")"; } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.History)) { text = empty + GetHistoryConditions(extendedLevel); } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.All)) { text = empty + "(" + extendedLevel.SelectableLevel.riskLevel + ") ($" + extendedLevel.RoutePrice + ") " + GetWeatherConditions(extendedLevel); } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.Vanilla)) { text = empty + "[planetTime]"; } else if (Settings.levelPreviewInfoType.Equals(PreviewInfoType.Override)) { text = empty + Settings.GetOverridePreviewInfo(extendedLevel); } if (extendedLevel.IsRouteLocked) { text += " (Locked)"; } string text2 = TerminalManager.onBeforePreviewInfoTextAdded?.Invoke(extendedLevel, Settings.levelPreviewInfoType); if (text2 != null && text2 != string.Empty) { 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 string result = string.Empty; if ((int)extendedLevel.SelectableLevel.currentWeather != -1) { result = "(" + ((object)(LevelWeatherType)(ref extendedLevel.SelectableLevel.currentWeather)).ToString() + ")"; } return result; } public static string GetHistoryConditions(ExtendedLevel extendedLevel) { DayHistory dayHistory = null; foreach (DayHistory dayHistory2 in LevelManager.dayHistoryList) { if ((Object)(object)dayHistory2.extendedLevel == (Object)(object)extendedLevel) { dayHistory = dayHistory2; } } if (dayHistory == null) { return "(Unexplored)"; } if (TimeOfDay.Instance.timesFulfilledQuota == dayHistory.quota && LevelManager.daysTotal == dayHistory.day) { return "(Explored Yesterday)"; } if (TimeOfDay.Instance.timesFulfilledQuota == dayHistory.quota) { return "(Explored " + (LevelManager.daysTotal - dayHistory.day) + " Ago)"; } if (TimeOfDay.Instance.timesFulfilledQuota - 1 == dayHistory.quota) { return "(Explored Last Quota)"; } return "Explored " + (TimeOfDay.Instance.timesFulfilledQuota - dayHistory.quota) + " Quota's Ago)"; } public static string GetTerminalEventString(string terminalEventString) { string result = string.Empty; if (terminalEventString.Contains(";")) { result = terminalEventString.Substring(terminalEventString.IndexOf(";") + 1); } return result; } public static string GetTerminalEventEnum(string terminalEventString) { if (terminalEventString.Contains(";")) { terminalEventString = terminalEventString.Replace(terminalEventString.Substring(terminalEventString.IndexOf(";")), ""); } return terminalEventString; } public static string GetSimulationResultsText(ExtendedLevel extendedLevel) { List list = new List((from o in DungeonManager.GetValidExtendedDungeonFlows(extendedLevel, debugResults: true) orderby -o.rarity select o).ToList()); 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.rarity; } foreach (ExtendedDungeonFlowWithRarity item2 in list) { text = text + "* " + item2.extendedDungeonFlow.DungeonName.PadRight(22).Truncate(22) + " // " + GetSimulationDataText(item2.rarity, 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 && val.word == playerInput && 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)) { vanillaExtendedLevel.IsRouteHidden = true; list.Add(vanillaExtendedLevel); } } list = list.OrderBy((ExtendedLevel l) => l.CalculatedDifficultyRating).ToList(); DebugHelper.Log("Creating ExtendedLevelGroups", DebugType.Developer); foreach (SelectableLevel item5 in OriginalContent.MoonsCatalogue) { DebugHelper.Log(item5.PlanetName.ToString(), 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)) { value.Add(customExtendedLevel); continue; } dictionary.Add(customExtendedLevel.ModName, new List { customExtendedLevel }); } List first = new List { item, item2, item3, item4 }; List list2 = new List(); List list3 = new List(); List list4 = new List(); foreach (KeyValuePair> item6 in new Dictionary>(dictionary)) { dictionary[item6.Key] = item6.Value.OrderBy((ExtendedLevel o) => o.CalculatedDifficultyRating).ToList(); if (item6.Value.Count == 1) { list4.Add(item6.Value[0]); } else { if (item6.Value.Count == 0) { continue; } foreach (ExtendedLevelGroup extendedLevelGroup in GetExtendedLevelGroups(item6.Value.ToArray(), Settings.moonsCatalogueSplitCount)) { list2.Add(extendedLevelGroup); } } } list4 = list4.OrderBy((ExtendedLevel o) => o.CalculatedDifficultyRating).ToList(); list3 = GetExtendedLevelGroups(list4.ToArray(), Settings.moonsCatalogueSplitCount); List second = (from o in list2.Concat(list3) orderby o.AverageCalculatedDifficulty select o).ToList(); List list5 = first.Concat(second).ToList(); string text = "Debugging DefaultExtendedLevelsGroup\n"; int num = 0; foreach (ExtendedLevelGroup item7 in list5) { text = text + "Group #" + num + " "; foreach (ExtendedLevel extendedLevels in item7.extendedLevelsList) { text = text + extendedLevels.NumberlessPlanetName + "(" + extendedLevels.ModName + ") , "; } text += "\n"; num++; } DebugHelper.Log(text, DebugType.Developer); defaultMoonsCataloguePage = new MoonsCataloguePage(list5); currentMoonsCataloguePage = new MoonsCataloguePage(new List()); RefreshExtendedLevelGroups(); } internal static void CreateLevelTerminalData(ExtendedLevel extendedLevel, int routePrice) { TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = extendedLevel.NumberlessPlanetName.Sanitized() + "Keyword"; val.word = extendedLevel.TerminalNoun; val.defaultVerb = routeKeyword; TerminalNode val2; if ((Object)(object)extendedLevel.RouteNode != (Object)null) { val2 = extendedLevel.RouteNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = extendedLevel.NumberlessPlanetName.Sanitized() + "Route"; if (extendedLevel.OverrideRouteNodeDescription != string.Empty) { val2.displayText = extendedLevel.OverrideRouteNodeDescription; } else { val2.displayText = "The cost to route to " + extendedLevel.SelectableLevel.PlanetName + " is [totalCost]. It is currently [currentPlanetTime] on this moon."; TerminalNode obj = val2; obj.displayText += "\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 = extendedLevel.NumberlessPlanetName.Sanitized() + "RouteConfirm"; if (extendedLevel.OverrideRouteConfirmNodeDescription != string.Empty) { val3.displayText = extendedLevel.OverrideRouteConfirmNodeDescription; } else { val3.displayText = "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 = extendedLevel.NumberlessPlanetName.Sanitized() + "Info"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; string text; if (extendedLevel.OverrideInfoNodeDescription != string.Empty) { text = extendedLevel.OverrideInfoNodeDescription; } else { text = extendedLevel.SelectableLevel.PlanetName + "\n----------------------\n"; List list = new List(); string text2 = extendedLevel.SelectableLevel.LevelDescription; while (text2.Contains("\n")) { string text3 = text2.Substring(text2.IndexOf("\n")); list.Add(text2.Replace(text3, "")); if (text3.Contains("\n")) { text2 = text3.Substring(text3.IndexOf("\n") + 1); } } list.Add(text2); foreach (string item in list) { text = text + "\n" + item + "\n"; } } val4.displayText = text; } 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) { TerminalKeyword val = CreateNewTerminalKeyword(); val.word = newStoryLog.terminalKeywordNoun; ((Object)val).name = newStoryLog.terminalKeywordNoun + "Keyword"; 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) { int buyItemIndex = Terminal.buyableItemsList.Count(); TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = extendedItem.Item.itemName.Sanitized() + "Keyword"; val.word = extendedItem.Item.itemName.Sanitized(); val.defaultVerb = buyKeyword; TerminalNode val2; if ((Object)(object)extendedItem.BuyNode != (Object)null) { val2 = extendedItem.BuyNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = extendedItem.Item.itemName.Sanitized() + "Buy"; if (extendedItem.OverrideBuyNodeDescription != string.Empty) { val2.displayText = extendedItem.OverrideBuyNodeDescription; } else { if (!string.IsNullOrEmpty(extendedItem.PluralisedItemName)) { val2.displayText = "You have requested to order " + extendedItem.PluralisedItemName + ". Amount: [variableAmount]."; } else { val2.displayText = "You have requested to order " + extendedItem.Item.itemName + ". Amount: [variableAmount]."; } TerminalNode obj = val2; obj.displayText += "\n Total cost of items: [totalCost]."; TerminalNode obj2 = val2; obj2.displayText += "\n\nPlease CONFIRM or DENY.\n\n"; } val2.clearPreviousText = true; val2.maxCharactersToType = 15; val2.isConfirmationNode = true; val2.itemCost = extendedItem.Item.creditsWorth; val2.overrideOptions = true; } val2.buyItemIndex = buyItemIndex; TerminalNode val3; if ((Object)(object)extendedItem.BuyConfirmNode != (Object)null) { val3 = extendedItem.BuyConfirmNode; } else { val3 = CreateNewTerminalNode(); ((Object)val3).name = extendedItem.Item.itemName.Sanitized() + "BuyConfirm"; if (extendedItem.OverrideBuyConfirmNodeDescription != string.Empty) { val3.displayText = extendedItem.OverrideBuyConfirmNodeDescription; } else { if (!string.IsNullOrEmpty(extendedItem.PluralisedItemName)) { val3.displayText = "Ordered [variableAmount] " + extendedItem.PluralisedItemName + ". Your new balance is"; } else { val3.displayText = "Ordered [variableAmount] " + extendedItem.Item.itemName + ". Your new balance is"; } TerminalNode obj3 = val3; obj3.displayText += "[playerCredits]"; TerminalNode obj4 = val3; obj4.displayText += "\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; } val3.buyItemIndex = buyItemIndex; TerminalNode val4 = null; if (!string.IsNullOrEmpty(extendedItem.OverrideInfoNodeDescription)) { if ((Object)(object)extendedItem.BuyInfoNode != (Object)null) { val4 = extendedItem.BuyInfoNode; } else { val4 = CreateNewTerminalNode(); ((Object)val4).name = extendedItem.Item.itemName.Sanitized() + "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; Terminal.buyableItemsList = CollectionExtensions.AddItem((IEnumerable)Terminal.buyableItemsList, extendedItem.Item).ToArray(); } internal static void CreateEnemyTypeTerminalData(ExtendedEnemyType extendedEnemyType) { TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = ((Object)extendedEnemyType).name + "BestiaryKeyword"; val.word = extendedEnemyType.EnemyDisplayName.ToLower(); val.defaultVerb = routeInfoKeyword; TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = ((Object)extendedEnemyType).name + "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) { TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = ((Object)extendedBuyableVehicle).name + "Keyword"; val.word = extendedBuyableVehicle.TerminalKeywordName.ToLower(); val.defaultVerb = buyKeyword; TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = ((Object)extendedBuyableVehicle).name + "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 = ((Object)extendedBuyableVehicle).name + "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 = ((Object)extendedBuyableVehicle).name + "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) { TerminalKeyword val = CreateNewTerminalKeyword(); ((Object)val).name = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized() + "Keyword"; val.word = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized(); val.defaultVerb = buyKeyword; TerminalNode val2; if ((Object)(object)extendedUnlockableItem.BuyNode != (Object)null) { val2 = extendedUnlockableItem.BuyNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized() + "Buy"; val2.itemCost = extendedUnlockableItem.ItemCost; val2.isConfirmationNode = false; val2.overrideOptions = true; val2.clearPreviousText = true; val2.maxCharactersToType = 15; val2.creatureName = extendedUnlockableItem.UnlockableItem.unlockableName; if (extendedUnlockableItem.OverrideBuyNodeDescription != string.Empty) { val2.displayText = extendedUnlockableItem.OverrideBuyNodeDescription; } else { val2.displayText = "You have requested to order the " + val2.creatureName + "."; TerminalNode obj = val2; obj.displayText += "\n Total cost of item: [totalCost]."; TerminalNode obj2 = val2; obj2.displayText += "\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 = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized() + "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; if (extendedUnlockableItem.OverrideBuyConfirmNodeDescription != string.Empty) { val3.displayText = extendedUnlockableItem.OverrideBuyConfirmNodeDescription; } else { val3.displayText = "Ordered the " + val3.creatureName + "! "; TerminalNode obj3 = val3; obj3.displayText += "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 = extendedUnlockableItem.UnlockableItem.unlockableName.Sanitized() + "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 RegisterStoryLog(TerminalKeyword terminalKeyword, TerminalNode terminalNode) { } internal static void CreateMoonsFilterTerminalAssets() { int num = Terminal.terminalNodes.allKeywords.Length; foreach (TerminalNode item in CreateTerminalEventNodes("preview", new List { 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 { 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 { FilterInfoType.Price, FilterInfoType.Weather, FilterInfoType.None })) { AddTerminalNodeEventListener(item3, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } filterKeyword = Terminal.terminalNodes.allKeywords[num3]; List list = new List(); List list2 = new List(); List list3 = new List(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { foreach (ContentTag contentTag in extendedLevel.ContentTags) { if (!list3.Contains(contentTag.contentTagName)) { list3.Add(contentTag.contentTagName); } } } foreach (string item4 in list3) { list.Add(item4); list2.Add("Tag;" + item4); } foreach (TerminalNode item5 in CreateTerminalEventNodes("filter", list, list2, createNewVerbKeyword: false)) { AddTerminalNodeEventListener(item5, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } List list4 = new List(); foreach (ExtendedLevel extendedLevel2 in PatchedContent.ExtendedLevels) { list4.Add(extendedLevel2.TerminalNoun); } int num4 = 0; foreach (TerminalNode item6 in CreateTerminalEventNodes("simulate", list4)) { 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) { List list = new List(); TerminalKeyword val = null; if (createNewVerbKeyword) { val = CreateNewTerminalKeyword(); } else { TerminalKeyword[] allKeywords = Terminal.terminalNodes.allKeywords; foreach (TerminalKeyword val2 in allKeywords) { if (val2.isVerb && val2.word == newVerbKeywordWord.ToLower()) { val = val2; } } } val.word = newVerbKeywordWord.ToLower(); ((Object)val).name = newVerbKeywordWord.ToLower() + "Keyword"; val.isVerb = true; if (terminalEventStrings == null) { terminalEventStrings = nounWords; } foreach (string nounWord in nounWords) { list.Add(CreateTerminalEventNode(val, nounWord, terminalEventStrings[nounWords.IndexOf(nounWord)])); } 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).ToLower(); 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 = (CompatibleNoun[])(object)new CompatibleNoun[0]; val.defaultVerb = null; Terminal.terminalNodes.allKeywords = CollectionExtensions.AddItem((IEnumerable)Terminal.terminalNodes.allKeywords, val).ToArray(); 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 = (CompatibleNoun[])(object)new CompatibleNoun[0]; return val; } } public static class UnlockableItemManager { internal static void PatchVanillaUnlockableItemLists() { Patches.StartOfRound.unlockablesList.unlockables = PatchedContent.ExtendedUnlockableItems.Select((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() { Patches.Terminal.buyableVehicles = PatchedContent.ExtendedBuyableVehicles.Select((ExtendedBuyableVehicle v) => v.BuyableVehicle).ToArray(); Patches.StartOfRound.VehiclesList = PatchedContent.ExtendedBuyableVehicles.Select((ExtendedBuyableVehicle v) => v.BuyableVehicle.vehiclePrefab).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 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_002f: Expected I4, but got Unknown //IL_0047: 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_0061: 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) if ((Object)(object)worldObject == (Object)null) { return; } LevelWeatherType baseWeatherType = extendedEffect.BaseWeatherType; switch ((int)baseWeatherType) { case 0: { LocalVolumetricFog val = default(LocalVolumetricFog); if (worldObject.TryGetComponent(ref val)) { LevelLoader.dustCloudFog = val; if (LevelLoader.defaultDustCloudFogVolumeSize == Vector3.zero) { LevelLoader.defaultDustCloudFogVolumeSize = val.parameters.size; } } break; } case 1: { 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 2: { 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 5: 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_0025: Expected I4, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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 - 2) { case 0: { 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 1: { LocalVolumetricFog val4 = default(LocalVolumetricFog); if (globalObject.TryGetComponent(ref val4)) { LevelLoader.foggyFog = val4; if (LevelLoader.defaultFoggyFogVolumeSize == Vector3.zero) { LevelLoader.defaultFoggyFogVolumeSize = val4.parameters.size; } } break; } case 2: { 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)val3.shader).name == "Shader Graphs/WaterShaderHDRP") { LevelLoader.defaultFloodedWaterMaterial = val3; LevelLoader.vanillaWaterShader = val3.shader; 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 = new List(PatchedContent.ExtendedLevels); 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 = new List(PatchedContent.ExtendedLevels); 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.6.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] [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.6.9"; internal static Plugin Instance; internal static AssetBundle MainAssets; internal static readonly Harmony Harmony = new Harmony("imabatby.lethallevelloader"); internal static ManualLogSource logger; internal static GameObject networkManagerPrefab; public static bool IsSetupComplete { get; private set; } = false; public static bool IsLobbyInitialized { get; internal set; } = false; public static event Action onBeforeSetup; public static event Action onSetupComplete; public static event Action onLobbyInitialized; private void Awake() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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(LethalLevelLoaderNetworkManager)); Harmony.PatchAll(typeof(DungeonLoader)); Harmony.PatchAll(typeof(Patches)); Harmony.PatchAll(typeof(EventPatches)); Harmony.PatchAll(typeof(SafetyPatches)); TrySoftPatch("evaisa.lethallib", typeof(LethalLibPatches)); 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(); } internal static void TrySoftPatch(string pluginName, Type type) { if (Chainloader.PluginInfos.ContainsKey(pluginName)) { Harmony.CreateClassProcessor(type, true).Patch(); DebugHelper.Log(pluginName + "found, enabling compatability patches.", DebugType.User); } } } public struct AssetBundleInfo { private List scenePathsInBundle; private List sceneNamesInBundle; private AssetBundle assetBundle; public string DirectoryPath { get; private set; } public bool IsLoaded => (Object)(object)assetBundle != (Object)null; public 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) { sceneNamesInBundle.Add(item2.Substring(item2.LastIndexOf("/") + 1).Replace(".unity", string.Empty)); } foreach (string item3 in sceneNamesInBundle) { DebugHelper.Log("AssetBundleInfo Has Scene: " + item3, DebugType.User); } } public AssetBundle LoadAndOrGetBundle() { if (IsLoaded) { return assetBundle; } return null; } public bool ContainsScene(string scenePath) { return sceneNamesInBundle.Contains(scenePath); } private void LoadBundle() { } private void UnloadBundle() { } } public class AssetBundleLoader : MonoBehaviour { public enum LoadingStatus { Inactive, Loading, Complete } public delegate void BundlesFinishedLoading(); public delegate void BundleFinishedLoading(AssetBundle assetBundle); public static AssetBundleLoader Instance; internal Plugin pluginInstace; public const string specifiedFileExtension = "*.lethalbundle"; internal static DirectoryInfo lethalLibFile = new DirectoryInfo(Assembly.GetExecutingAssembly().Location); internal static DirectoryInfo lethalLibFolder; internal static DirectoryInfo pluginsFolder; internal static Dictionary obtainedExtendedModsDictionary = new Dictionary(); internal static Dictionary assetBundles = new Dictionary(); internal static Dictionary assetBundleLoadTimes = new Dictionary(); internal static TextMeshProUGUI loadingBundlesHeaderText; internal static bool noBundlesFound = false; internal static bool hasRequestedToLoadMainMenu; internal static Dictionary cachedNetworkPrefabs = new Dictionary(); 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; } internal static void RegisterNewExtendedMod() { } public static void AddOnLethalBundleLoadedListener(Action invokedFunction, string lethalBundleFileName) { if (invokedFunction != null && !string.IsNullOrEmpty(lethalBundleFileName)) { if (!LethalLevelLoader.AssetBundles.AssetBundleLoader.onLethalBundleLoadedRequestDict.ContainsKey(lethalBundleFileName)) { LethalLevelLoader.AssetBundles.AssetBundleLoader.onLethalBundleLoadedRequestDict.Add(lethalBundleFileName, new List> { invokedFunction }); } else { LethalLevelLoader.AssetBundles.AssetBundleLoader.onLethalBundleLoadedRequestDict[lethalBundleFileName].Add(invokedFunction); } } } public static void AddOnExtendedModLoadedListener(Action invokedFunction, string extendedModAuthorName = null, string extendedModModName = null) { if (invokedFunction != null && !string.IsNullOrEmpty(extendedModAuthorName)) { if (!LethalBundleManager.onExtendedModLoadedRequestDict.ContainsKey(extendedModAuthorName)) { LethalBundleManager.onExtendedModLoadedRequestDict.Add(extendedModAuthorName, new List> { invokedFunction }); } else { LethalBundleManager.onExtendedModLoadedRequestDict[extendedModAuthorName].Add(invokedFunction); } } if (invokedFunction != null && !string.IsNullOrEmpty(extendedModModName)) { if (!LethalBundleManager.onExtendedModLoadedRequestDict.ContainsKey(extendedModModName)) { LethalBundleManager.onExtendedModLoadedRequestDict.Add(extendedModModName, new List> { invokedFunction }); } else { LethalBundleManager.onExtendedModLoadedRequestDict[extendedModModName].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; PatchedContent.ExtendedBuyableVehicles.Add(extendedBuyableVehicle); } foreach (ExtendedUnlockableItem extendedUnlockableItem in extendedMod.ExtendedUnlockableItems) { extendedUnlockableItem.ContentType = ContentType.Custom; extendedUnlockableItem.Initialize(); PatchedContent.ExtendedUnlockableItems.Add(extendedUnlockableItem); } } } 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); 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() { if (Patches.RoundManager.dungeonFlowTypes != null) { IndoorMapType[] dungeonFlowTypes = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { CreateVanillaExtendedDungeonFlow(val.dungeonFlow); } } 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 componentInChildren = extendedEnemyType.EnemyType.enemyPrefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { extendedEnemyType.ScanNodeProperties = componentInChildren; extendedEnemyType.EnemyID = componentInChildren.creatureScanID; extendedEnemyType.EnemyInfoNode = Patches.Terminal.enemyFiles[extendedEnemyType.EnemyID]; if ((Object)(object)extendedEnemyType.EnemyInfoNode != (Object)null) { extendedEnemyType.InfoNodeVideoClip = extendedEnemyType.EnemyInfoNode.displayVideo; } extendedEnemyType.EnemyDisplayName = componentInChildren.headerText; } else { 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(DungeonFlow dungeonFlow) { AudioClip newFirstTimeDungeonAudio = null; string dungeonName = string.Empty; if (((Object)dungeonFlow).name.Contains("Level1")) { dungeonName = "Facility"; newFirstTimeDungeonAudio = Patches.RoundManager.firstTimeDungeonAudios[0]; } else if (((Object)dungeonFlow).name.Contains("Level2")) { dungeonName = "Haunted Mansion"; newFirstTimeDungeonAudio = Patches.RoundManager.firstTimeDungeonAudios[1]; } else if (((Object)dungeonFlow).name.Contains("Level3")) { dungeonName = "Mineshaft"; } ExtendedDungeonFlow extendedDungeonFlow = ExtendedDungeonFlow.Create(dungeonFlow, newFirstTimeDungeonAudio); extendedDungeonFlow.DungeonName = dungeonName; 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); PatchedContent.VanillaMod.RegisterExtendedContent(extendedBuyableVehicle); PatchedContent.ExtendedBuyableVehicles.Add(extendedBuyableVehicle); } internal static void CreateVanillaExtendedUnlockableItems(StartOfRound startOfRound) { foreach (UnlockableItem unlockableItem in OriginalContent.UnlockableItems) { CreateVanillaExtendedUnlockableItem(unlockableItem); } } internal static void CreateVanillaExtendedUnlockableItem(UnlockableItem unlockableItem) { ExtendedUnlockableItem extendedUnlockableItem = ExtendedUnlockableItem.Create(unlockableItem, PatchedContent.VanillaMod, ContentType.Vanilla); PatchedContent.VanillaMod.RegisterExtendedContent(extendedUnlockableItem); PatchedContent.ExtendedUnlockableItems.Add(extendedUnlockableItem); } internal static bool NetworkRegisterDungeonContent(ExtendedDungeonFlow extendedDungeonFlow, NetworkManager networkManager) { HashSet hashSet = new HashSet(); HashSet hashSet2 = 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(((Object)indoorMapHazard.hazardType.prefabToSpawn).name)) { continue; } if (!cachedNetworkPrefabs.TryGetValue(((Object)indoorMapHazard.hazardType.prefabToSpawn).name, out var value)) { foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs) { if (((Object)prefab.Prefab).name == ((Object)indoorMapHazard.hazardType.prefabToSpawn).name) { cachedNetworkPrefabs.Add(((Object)indoorMapHazard.hazardType.prefabToSpawn).name, prefab.Prefab); indoorMapHazard.hazardType.prefabToSpawn = prefab.Prefab; hashSet2.Add(((Object)indoorMapHazard.hazardType.prefabToSpawn).name); break; } } if (!hashSet2.Contains(((Object)indoorMapHazard.hazardType.prefabToSpawn).name)) { if (!indoorMapHazard.hazardType.prefabToSpawn.TryGetComponent(ref val)) { indoorMapHazard.hazardType.prefabToSpawn.AddComponent(); } LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(indoorMapHazard.hazardType.prefabToSpawn); hashSet.Add(((Object)indoorMapHazard.hazardType.prefabToSpawn).name); } } else { indoorMapHazard.hazardType.prefabToSpawn = value; } } string text = "Automatically Restored The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow).name + ": "; foreach (string item in hashSet2) { text = text + item + ", "; } DebugHelper.Log(text, DebugType.Developer); text = "Automatically Registered The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow).name + ": "; foreach (string item2 in hashSet) { text = text + item2 + ", "; } 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; } foreach (SpawnSyncedObject spawnSyncedObject in extendedDungeonFlow.DungeonFlow.GetSpawnSyncedObjects(extendedDungeonFlow.AllTiles)) { if ((Object)(object)spawnSyncedObject == (Object)null || (Object)(object)spawnSyncedObject.spawnPrefab == (Object)null || hashSet.Contains(((Object)spawnSyncedObject.spawnPrefab).name)) { continue; } if (!cachedNetworkPrefabs.TryGetValue(((Object)spawnSyncedObject.spawnPrefab).name, out var value2)) { foreach (NetworkPrefab prefab2 in networkManager.NetworkConfig.Prefabs.m_Prefabs) { if (((Object)prefab2.Prefab).name == ((Object)spawnSyncedObject.spawnPrefab).name) { cachedNetworkPrefabs.Add(((Object)spawnSyncedObject.spawnPrefab).name, prefab2.Prefab); spawnSyncedObject.spawnPrefab = prefab2.Prefab; hashSet2.Add(((Object)spawnSyncedObject.spawnPrefab).name); break; } } if (!hashSet2.Contains(((Object)spawnSyncedObject.spawnPrefab).name)) { if (!spawnSyncedObject.spawnPrefab.TryGetComponent(ref val)) { spawnSyncedObject.spawnPrefab.AddComponent(); } LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(spawnSyncedObject.spawnPrefab); hashSet.Add(((Object)spawnSyncedObject.spawnPrefab).name); } } else { spawnSyncedObject.spawnPrefab = value2; } } text = "Automatically Restored The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (string item3 in hashSet2) { text = text + item3 + ", "; } DebugHelper.Log(text, DebugType.Developer); text = "Automatically Registered The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (string item4 in hashSet) { text = text + item4 + ", "; } DebugHelper.Log(text, DebugType.Developer); return true; } internal static void SetVanillaLevelTags(ExtendedLevel vanillaLevel) { IntWithRarity[] dungeonFlowTypes = vanillaLevel.SelectableLevel.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes) { if (DungeonManager.TryGetExtendedDungeonFlow(Patches.RoundManager.dungeonFlowTypes[val.id].dungeonFlow, out var returnExtendedDungeonFlow)) { returnExtendedDungeonFlow.LevelMatchingProperties.planetNames.Add(new StringWithRarity(vanillaLevel.NumberlessPlanetName, val.rarity)); } } if (vanillaLevel.SelectableLevel.sceneName == "Level4March") { IndoorMapType[] dungeonFlowTypes2 = Patches.RoundManager.dungeonFlowTypes; foreach (IndoorMapType val2 in dungeonFlowTypes2) { if (((Object)val2.dungeonFlow).name == "Level1Flow3Exits" && DungeonManager.TryGetExtendedDungeonFlow(val2.dungeonFlow, out var returnExtendedDungeonFlow2)) { returnExtendedDungeonFlow2.LevelMatchingProperties.planetNames.Add(new StringWithRarity(vanillaLevel.NumberlessPlanetName, 300)); } } } CompatibleNoun[] compatibleNouns = TerminalManager.routeInfoKeyword.compatibleNouns; foreach (CompatibleNoun val3 in compatibleNouns) { if (val3.noun.word == vanillaLevel.NumberlessPlanetName.ToLower()) { vanillaLevel.InfoNode = val3.result; break; } } } internal static string GetSceneName(string scenePath) { return scenePath.Substring(scenePath.LastIndexOf('/') + 1).Replace(".unity", ""); } internal static void CreateLoadingBundlesHeaderText(PreInitSceneScript preInitSceneScript) { //IL_003a: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0189: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(((Component)preInitSceneScript.headerText).gameObject, ((TMP_Text)preInitSceneScript.headerText).transform.parent); RectTransform component = val.GetComponent(); TextMeshProUGUI component2 = val.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0f, 0f); component.offsetMin = new Vector2(0f, -150f); component.offsetMax = new Vector2(0f, -150f); component.anchoredPosition = new Vector2(0f, -150f); if (CurrentLoadingStatus != 0) { ((TMP_Text)component2).text = "Loading Bundles: " + assetBundles.First().Key + " (" + BundlesFinishedLoadingCount + " // " + assetBundles.Count + ")"; } else { ((TMP_Text)component2).text = "Loading Bundles: (" + (assetBundles.Count - (assetBundles.Count - BundlesFinishedLoadingCount)) + " // " + assetBundles.Count + ")"; } ((Graphic)component2).color = new Color(0.641f, 0.641f, 0.641f, 1f); ((TMP_Text)component2).fontSize = 20f; ((TMP_Text)component2).overflowMode = (TextOverflowModes)0; ((TMP_Text)component2).enableWordWrapping = false; ((TMP_Text)component2).alignment = (TextAlignmentOptions)514; loadingBundlesHeaderText = component2; onBundleFinishedLoading += UpdateLoadingBundlesHeaderText; } internal static void UpdateLoadingBundlesHeaderText(AssetBundle _) { if ((Object)(object)loadingBundlesHeaderText != (Object)null) { if (CurrentLoadingStatus != 0) { ((TMP_Text)loadingBundlesHeaderText).text = "Loading Bundles: " + assetBundles.First().Key + " (" + (assetBundles.Count - (assetBundles.Count - BundlesFinishedLoadingCount)) + " // " + assetBundles.Count + ")"; } else { ((TMP_Text)loadingBundlesHeaderText).text = "Loaded Bundles: (" + (assetBundles.Count - (assetBundles.Count - BundlesFinishedLoadingCount)) + " // " + assetBundles.Count + ")"; } } } public static Tile[] GetAllTilesInDungeonFlow(DungeonFlow dungeonFlow) { DebugHelper.LogWarning("AssetBundleLoader.GetAllTilesInDungeonFlow() is deprecated. Please move to dungeonFlow.GetTiles() to prevent issues in following updates.", DebugType.Developer); return dungeonFlow.GetTiles().ToArray(); } public static RandomMapObject[] GetAllMapObjectsInTiles(Tile[] tiles) { DebugHelper.LogWarning("AssetBundleLoader.GetAllMapObjectsInTiles() is deprecated. Please move to dungeonFlow.GetRandomMapObjects() to prevent issues in following updates.", DebugType.Developer); return new List().ToArray(); } public static SpawnSyncedObject[] GetAllSpawnSyncedObjectsInTiles(Tile[] tiles) { DebugHelper.LogWarning("AssetBundleLoader.GetAllSpawnSyncedObjectsInTiles() is deprecated. Please move to dungeonFlow.GetSpawnSyncedObjects() to prevent issues in following updates.", DebugType.Developer); return new List().ToArray(); } } 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) { List list = new List(Resources.FindObjectsOfTypeAll()); foreach (Item items in startOfRound.allItemsList.itemsList) { if (!((Object)(object)items.spawnPrefab != (Object)null)) { continue; } ContentExtractor.TryAddReference(OriginalContent.Items, items); foreach (ItemGroup spawnPositionType in items.spawnPositionTypes) { if (list.Contains(spawnPositionType)) { OriginalContent.ItemGroups.Add(spawnPositionType); list.Remove(spawnPositionType); } } } OriginalContent.ItemGroups = OriginalContent.ItemGroups.Distinct().ToList(); } internal static void TryScrapeVanillaUnlockableItems(StartOfRound startOfRound) { foreach (UnlockableItem unlockable in startOfRound.unlockablesList.unlockables) { if (!OriginalContent.UnlockableItems.Contains(unlockable)) { OriginalContent.UnlockableItems.Add(unlockable); } } } 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); } IndoorMapType[] dungeonFlowTypes2 = roundManager.dungeonFlowTypes; foreach (IndoorMapType val2 in dungeonFlowTypes2) { ExtractDungeonFlowReferences(val2.dungeonFlow); } } 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 val3 in allKeywords) { ContentExtractor.TryAddReference(OriginalContent.TerminalKeywords, val3); if (val3.compatibleNouns != null) { CompatibleNoun[] compatibleNouns = val3.compatibleNouns; foreach (CompatibleNoun val4 in compatibleNouns) { if ((Object)(object)val4.result != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val4.result); } } } if ((Object)(object)val3.specialKeywordResult != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val3.specialKeywordResult); } } foreach (TerminalNode item2 in new List(OriginalContent.TerminalNodes)) { if (item2.terminalOptions == null) { continue; } CompatibleNoun[] terminalOptions = item2.terminalOptions; foreach (CompatibleNoun val5 in terminalOptions) { if ((Object)(object)val5.result != (Object)null) { ContentExtractor.TryAddReference(OriginalContent.TerminalNodes, val5.result); } } } ExtractMemoryLoadedAudioMixerGroups(); ReverbPreset[] array = Resources.FindObjectsOfTypeAll(); foreach (ReverbPreset reference in array) { ContentExtractor.TryAddReference(OriginalContent.ReverbPresets, reference); } OriginalContent.ReverbPresets.Reverse(); OriginalContent.SelectableLevels = new List(startOfRound.levels.ToList()); OriginalContent.MoonsCatalogue = new List(TerminalManager.Terminal.moonsCatalogueList.ToList()); } internal static void TryScrapeCustomContent() { } internal static void ObtainSpecialItemReferences() { GrabbableObject[] componentsInChildren = ((Component)Patches.StartOfRound.shipAnimator).gameObject.GetComponentsInChildren(); foreach (GrabbableObject val in componentsInChildren) { if ((Object)(object)val.itemProperties != (Object)null && !OriginalContent.Items.Contains(val.itemProperties) && (Object)(object)val.itemProperties.spawnPrefab != (Object)null) { OriginalContent.Items.Add(val.itemProperties); } } foreach (EnemyType enemy in OriginalContent.Enemies) { if (((Object)enemy).name == "Nutcracker_0") { NutcrackerEnemyAI component = enemy.enemyPrefab.GetComponent(); if ((Object)(object)component != (Object)null) { OriginalContent.Items.Add(component.gunPrefab.GetComponent().itemProperties); OriginalContent.Items.Add(component.shotgunShellPrefab.GetComponent().itemProperties); } } else if (((Object)enemy).name == "Butler_0") { ButlerEnemyAI component2 = enemy.enemyPrefab.GetComponent(); if ((Object)(object)component2 != (Object)null) { OriginalContent.Items.Add(component2.knifePrefab.GetComponent().itemProperties); } } else if (((Object)enemy).name == "RedLocustBees") { RedLocustBees component3 = enemy.enemyPrefab.GetComponent(); if ((Object)(object)component3 != (Object)null) { OriginalContent.Items.Add(component3.hivePrefab.GetComponent().itemProperties); } } } } internal static void ExtractMemoryLoadedAudioMixerGroups() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown Object[] array = Resources.FindObjectsOfTypeAll(typeof(AudioMixer)); for (int i = 0; i < array.Length; i++) { AudioMixer val = (AudioMixer)array[i]; if (!OriginalContent.AudioMixers.Contains(val)) { ContentExtractor.TryAddReference(PatchedContent.AudioMixers, val); } } Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(AudioMixerGroup)); for (int j = 0; j < array2.Length; j++) { AudioMixerGroup val2 = (AudioMixerGroup)array2[j]; if (OriginalContent.AudioMixers.Contains(val2.audioMixer)) { ContentExtractor.TryAddReference(OriginalContent.AudioMixerGroups, val2); } else { ContentExtractor.TryAddReference(PatchedContent.AudioMixerGroups, val2); } } Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(AudioMixerSnapshot)); for (int k = 0; k < array3.Length; k++) { AudioMixerSnapshot val3 = (AudioMixerSnapshot)array3[k]; if (OriginalContent.AudioMixers.Contains(val3.audioMixer)) { ContentExtractor.TryAddReference(OriginalContent.AudioMixerSnapshots, val3); } else { ContentExtractor.TryAddReference(PatchedContent.AudioMixerSnapshots, val3); } } } internal static void ExtractSelectableLevelReferences(SelectableLevel selectableLevel) { 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); } 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 ExtractDungeonFlowReferences(DungeonFlow dungeonFlow) { } internal static void TryAddReference(List referenceList, T reference) where T : Object { if (!referenceList.Contains(reference)) { referenceList.Add(reference); } } } internal static class ContentTagParser { internal static Dictionary> importedItemContentTagDictionary = new Dictionary>(); internal static Dictionary> importedLevelContentTagDictionary = new Dictionary>(); internal static Dictionary> importedEnemyContentTagDictionary = new Dictionary>(); internal static void ApplyVanillaContentTags() { ApplyImportedItemContentTags(); ApplyImportedSelectableLevelContentTags(); ApplyImportedEnemyTypeContentTags(); } internal static void ImportVanillaContentTags() { ParseContentFile("Items", importedItemContentTagDictionary, 5); ParseContentFile("SelectableLevels", importedLevelContentTagDictionary, 3); ParseContentFile("Enemies", importedEnemyContentTagDictionary, 3); } internal static void ParseContentFile(string fileName, Dictionary> importedContentTagDict, int startingLine) { DebugHelper.Log("Parsing Contents Of Content CSV Located At: " + fileName, DebugType.Developer); int num = 0; try { StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("LethalLevelLoader.VanillaContentTags." + fileName + ".csv")); string text = streamReader.ReadLine(); num++; while (text != null) { if (num > startingLine) { (string, List) parsedLine = ParseLine(text); importedContentTagDict.Add(parsedLine.Item1, parsedLine.Item2); DebugParsedLine(parsedLine); } text = streamReader.ReadLine(); num++; } streamReader.Close(); if (num > startingLine) { (string, List) parsedLine2 = ParseLine(text); importedContentTagDict.Add(parsedLine2.Item1, parsedLine2.Item2); DebugParsedLine(parsedLine2); } } catch { } } internal static void ApplyImportedItemContentTags() { int num = 0; List list = new List(); foreach (KeyValuePair> item in importedItemContentTagDictionary) { foreach (ExtendedItem extendedItem in PatchedContent.VanillaMod.ExtendedItems) { if (((Object)extendedItem.Item).name.ContainsSanitized(item.Key, bothWays: true)) { DebugHelper.Log("Applying CSV Tags For Imported Item #" + (num + 1) + " / " + (importedItemContentTagDictionary.Count - 1) + ": " + item.Key + " To ExtendedItem: " + extendedItem.Item.itemName + "(" + ((Object)extendedItem.Item).name + ")", DebugType.Developer); extendedItem.ContentTags = ContentTagManager.CreateNewContentTags(item.Value.Concat(new List { "Vanilla" }).ToList()); list.Add(num); break; } } num++; } for (int i = 0; i < importedItemContentTagDictionary.Count; i++) { if (!list.Contains(i) && importedItemContentTagDictionary.Keys.ToList()[i] != string.Empty) { DebugHelper.LogWarning("Could Not Apply CSV Tags For Imported Item: " + importedItemContentTagDictionary.Keys.ToList()[i], DebugType.Developer); } } } internal static void ApplyImportedSelectableLevelContentTags() { int num = 0; List list = new List(); foreach (KeyValuePair> item in importedLevelContentTagDictionary) { foreach (ExtendedLevel extendedLevel in PatchedContent.VanillaMod.ExtendedLevels) { if (((Object)extendedLevel.SelectableLevel).name.ContainsSanitized(item.Key, bothWays: true)) { DebugHelper.Log("Applying CSV Tags For Imported Level #" + (num + 1) + " / " + (importedLevelContentTagDictionary.Count - 1) + ": " + item.Key + " To SelectableLevel: " + extendedLevel.SelectableLevel.PlanetName + "(" + ((Object)extendedLevel.SelectableLevel).name + ")", DebugType.Developer); extendedLevel.ContentTags = ContentTagManager.CreateNewContentTags(item.Value.Concat(new List { "Vanilla" }).ToList()); list.Add(num); break; } } num++; } for (int i = 0; i < importedLevelContentTagDictionary.Count; i++) { if (!list.Contains(i) && importedLevelContentTagDictionary.Keys.ToList()[i] != string.Empty) { DebugHelper.LogWarning("Could Not Apply CSV Tags For Imported SelectableLevel: " + importedLevelContentTagDictionary.Keys.ToList()[i], DebugType.Developer); } } } internal static void ApplyImportedEnemyTypeContentTags() { int num = 0; List list = new List(); foreach (KeyValuePair> item in importedEnemyContentTagDictionary) { foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.VanillaMod.ExtendedEnemyTypes) { if (((Object)extendedEnemyType.EnemyType).name.ContainsSanitized(item.Key, bothWays: true)) { DebugHelper.Log("Applying CSV Tags For Imported Enemy #" + (num + 1) + " / " + (importedEnemyContentTagDictionary.Count - 1) + ": " + item.Key + " To EnemyType: " + extendedEnemyType.EnemyType.enemyName + "(" + ((Object)extendedEnemyType.EnemyType).name + ")", DebugType.Developer); extendedEnemyType.ContentTags = ContentTagManager.CreateNewContentTags(item.Value.Concat(new List { "Vanilla" }).ToList()); list.Add(num); break; } } num++; } } internal static (string, List) ParseLine(string line) { string empty = string.Empty; string item = string.Empty; List list = new List(); if (!string.IsNullOrEmpty(line) && line.Contains(",")) { item = line.Replace(line.Substring(line.IndexOf(",")), string.Empty); empty = line.Substring(line.IndexOf(",") + 1); empty = empty.SkipToLetters(); string empty2 = string.Empty; while (empty.Contains(",")) { empty2 = empty.Replace(empty.Substring(empty.IndexOf(",")), string.Empty).SkipToLetters(); list.Add(empty2); empty = ((empty.Length <= 1) ? string.Empty : empty.Substring(empty.IndexOf(",") + 1)); } } for (int i = 0; i < list.Count; i++) { list[i] = new string((from c in list[i].ToCharArray() where char.IsLetter(c) select c).ToArray()); } List list2 = new List(); for (int j = 0; j < list.Count; j++) { if (!string.IsNullOrEmpty(list[j])) { list2.Add(list[j]); } } return (item, list2); } internal static void DebugParsedLine((string, List) parsedLine) { DebugParsedLine(parsedLine.Item1, parsedLine.Item2); } internal static void DebugParsedLine(string contentName, List contentTags) { if (string.IsNullOrEmpty(contentName) || contentTags.Count <= 0) { return; } string text = "ContentName: " + contentName + " | Content Tags: "; string text2 = string.Empty; foreach (string contentTag in contentTags) { text2 = text2 + ", " + contentTag; } DebugHelper.Log(text + text2.SkipToLetters(), DebugType.Developer); } } internal static class DebugHelper { private class CodeInstructionFormatter { private int _instructionIndexPadLength; public CodeInstructionFormatter(int instructionCount) { _instructionIndexPadLength = instructionCount.ToString().Length; } public string Format(CodeInstruction instruction, int index) { return $" IL_{index.ToString().PadLeft(_instructionIndexPadLength, '0')}: {instruction}"; } } public static string logAuthor = "Batby"; public static Dictionary extendedLevelLogReports = new Dictionary(); public static Dictionary extendedDungeonFlowLogReports = new Dictionary(); 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 DebugTerminalKeyword(TerminalKeyword terminalKeyword) { if ((Object)(object)terminalKeyword != (Object)null) { string text = "Info For (" + terminalKeyword.word + ") TerminalKeyword!\n\n"; text = text + "Word: " + terminalKeyword.word + "\n"; text = text + "isVerb?: " + terminalKeyword.isVerb + "\n"; text += "CompatibleNouns :\n"; if (terminalKeyword.compatibleNouns != null) { CompatibleNoun[] compatibleNouns = terminalKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { text = ((val == null || !((Object)(object)val.noun != (Object)null) || !((Object)(object)val.result != (Object)null)) ? (text + "Could not debug CompatibleNoun as it was null!\n") : (text + val.noun.word + " | " + ((object)val.result)?.ToString() + "\n")); } } text = text + "SpecialKeywordResult: " + ((object)terminalKeyword.specialKeywordResult)?.ToString() + "\n"; text = text + "AccessTerminalObjects?: " + terminalKeyword.accessTerminalObjects + "\n"; text = ((!((Object)(object)terminalKeyword.defaultVerb != (Object)null) || terminalKeyword.defaultVerb.word == null) ? (text + "Could not debug DefaultVerb as it was null!\n") : (text + "DefaultVerb: " + terminalKeyword.defaultVerb.word + "\n")); Log(text + "\n\n", DebugType.Developer); } else { Log("Could not debug TerminalKeyword as it was null!", DebugType.Developer); } } public static void DebugTerminalNode(TerminalNode terminalNode) { string text = "Info For (" + ((Object)terminalNode).name + ") TerminalNode!\n\n"; text = text + "Display Text: " + terminalNode.displayText + "\n"; text = text + "Terminal Event: " + terminalNode.terminalEvent + "\n"; text = text + "Accept Anything?: " + terminalNode.acceptAnything + "\n"; text = text + "Override Options?: " + terminalNode.overrideOptions + "\n"; text = text + "Display Planet Info (LevelID): " + terminalNode.displayPlanetInfo + "\n"; text = text + "Buy Reroute To Moon (LevelID): " + terminalNode.buyRerouteToMoon + "\n"; text = text + "Is Confirmation Node?: " + terminalNode.isConfirmationNode + "\n"; text += "Terminal Options (CompatibleNouns) :\n"; CompatibleNoun[] terminalOptions = terminalNode.terminalOptions; foreach (CompatibleNoun val in terminalOptions) { text = text + ((object)val.noun)?.ToString() + " | " + ((object)val.result)?.ToString() + "\n"; } Log(text + "\n\n", DebugType.Developer); } public static void DebugInjectedLevels() { string text = "Injected Levels List: \n\n"; int num = 0; if ((Object)(object)Patches.StartOfRound != (Object)null) { SelectableLevel[] levels = Patches.StartOfRound.levels; foreach (SelectableLevel val in levels) { text = text + num + ". " + val.PlanetName + " (" + val.levelID + ") \n"; num++; } text = text + "Current Level Is: " + Patches.StartOfRound.currentLevel.PlanetName + " (" + Patches.StartOfRound.currentLevel.levelID + ") \n"; } Log(text + "\n\n", DebugType.Developer); } public static void DebugAllLevels() { string text = "All Levels List: \n\n"; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { text = text + extendedLevel.SelectableLevel.PlanetName + " (" + extendedLevel.SelectableLevel.levelID + ") \n"; } Log(text + "\n", DebugType.Developer); } public static void DebugVanillaLevels() { string text = "Vanilla Levels List: \n\n"; foreach (ExtendedLevel vanillaExtendedLevel in PatchedContent.VanillaExtendedLevels) { text = text + vanillaExtendedLevel.SelectableLevel.PlanetName + " (" + vanillaExtendedLevel.SelectableLevel.levelID + ") \n"; } Log(text + "\n", DebugType.Developer); } public static void DebugCustomLevels() { string text = "Custom Levels List: \n\n"; foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { text = text + customExtendedLevel.SelectableLevel.PlanetName + " (" + customExtendedLevel.SelectableLevel.levelID + ") \n"; } Log(text + "\n", DebugType.Developer); } public static void DebugScrapedVanillaContent() { //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown Log("Obtained (" + OriginalContent.SelectableLevels.Count + " / 9) Vanilla SelectableLevel References", DebugType.Developer); Log("Obtained (" + OriginalContent.DungeonFlows.Count + " / 4) Vanilla DungeonFlow References", DebugType.Developer); Log("Obtained (" + OriginalContent.Items.Count + " / 68) Vanilla Item References", DebugType.Developer); Log("Obtained (" + OriginalContent.ItemGroups.Count + " / 3) Vanilla Item Group References", DebugType.Developer); Log("Obtained (" + OriginalContent.Enemies.Count + " / 20) Vanilla Enemy References", DebugType.Developer); Log("Obtained (" + OriginalContent.SpawnableOutsideObjects.Count + " / 11) Vanilla Outside Object References", DebugType.Developer); Log("Obtained (" + OriginalContent.IndoorMapHazards.Count + " / 3) Vanilla Inside Object References", DebugType.Developer); Log("Obtained (" + OriginalContent.AudioMixers.Count + " / 2) Vanilla Audio Mixer References", DebugType.Developer); Log("Obtained (" + OriginalContent.AudioMixerGroups.Count + " / 9) Vanilla Audio Mixing Group References", DebugType.Developer); Log("Obtained (" + OriginalContent.AudioMixerSnapshots.Count + " / 6) Vanilla Audio Mixing Snapshot References", DebugType.Developer); Log("Obtained (" + OriginalContent.LevelAmbienceLibraries.Count + " / 3) Vanilla Ambience Library References", DebugType.Developer); Log("Obtained (" + OriginalContent.ReverbPresets.Count + " / 8) Vanilla Reverb References", DebugType.Developer); Log("Obtained (" + OriginalContent.TerminalKeywords.Count + " / 121) Vanilla Terminal Keyword References", DebugType.Developer); Log("Obtained (" + OriginalContent.TerminalNodes.Count + " / 186) Vanilla Terminal Node References", DebugType.Developer); Object[] array = Resources.FindObjectsOfTypeAll(typeof(TerminalNode)); for (int i = 0; i < array.Length; i++) { TerminalNode val = (TerminalNode)array[i]; if (!OriginalContent.TerminalNodes.Contains(val)) { Log("Missing Terminal Node: " + ((Object)val).name, DebugType.Developer); } } } public static void DebugAudioMixerGroups() { } public static void DebugSelectableLevelReferences(ExtendedLevel extendedLevel) { string text = "Logging SelectableLevel References For Moon: " + extendedLevel.NumberlessPlanetName + " (" + extendedLevel.ContentType.ToString() + ").\n"; text += "Inside Enemies\n\n"; foreach (SpawnableEnemyWithRarity enemy in extendedLevel.SelectableLevel.Enemies) { text = text + "Enemy Type: " + enemy.enemyType.enemyName + " , Rarity: " + enemy.rarity + " , Prefab Status: " + ((Object)(object)enemy.enemyType.enemyPrefab != (Object)null) + "\n"; } text += "Outside Enemies (Nighttime)\n\n"; foreach (SpawnableEnemyWithRarity outsideEnemy in extendedLevel.SelectableLevel.OutsideEnemies) { text = text + "Enemy Type: " + outsideEnemy.enemyType.enemyName + " , Rarity: " + outsideEnemy.rarity + " , Prefab Status: " + ((Object)(object)outsideEnemy.enemyType.enemyPrefab != (Object)null) + "\n"; } text += "Outside Enemies (daytime)\n\n"; foreach (SpawnableEnemyWithRarity daytimeEnemy in extendedLevel.SelectableLevel.DaytimeEnemies) { text = text + "Enemy Type: " + daytimeEnemy.enemyType.enemyName + " , Rarity: " + daytimeEnemy.rarity + " , Prefab Status: " + ((Object)(object)daytimeEnemy.enemyType.enemyPrefab != (Object)null) + "\n"; } Log(text + "\n", DebugType.Developer); } public static void DebugDungeonFlows(List dungeonFlowList) { string text = "Dungen Flow Report: \n\n"; foreach (DungeonFlow dungeonFlow in dungeonFlowList) { text = text + ((Object)dungeonFlow).name + "\n"; } } public static string GetDungeonFlowsLog(List dungeonFlowList) { string text = string.Empty; foreach (DungeonFlow dungeonFlow in dungeonFlowList) { text = text + ((Object)dungeonFlow).name + "\n"; } return text; } public static void DebugAllExtendedDungeons() { string text = "All ExtendedDungeons: \n\n"; foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { text += ((Object)extendedDungeonFlow.DungeonFlow).name; } Log(text, DebugType.Developer); text = "Vanilla ExtendedDungeons: \n\n"; foreach (ExtendedDungeonFlow vanillaExtendedDungeonFlow in PatchedContent.VanillaExtendedDungeonFlows) { text += ((Object)vanillaExtendedDungeonFlow.DungeonFlow).name; } Log(text, DebugType.Developer); text = "Custom ExtendedDungeons: \n\n"; foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { text += ((Object)customExtendedDungeonFlow.DungeonFlow).name; } Log(text, DebugType.Developer); } public static void DebugPlanetWeatherRandomisation(int players, List selectableLevelsList) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) StartOfRound startOfRound = Patches.StartOfRound; List list = new List(selectableLevelsList); foreach (SelectableLevel item in list) { item.currentWeather = (LevelWeatherType)(-1); } Random random = new Random(startOfRound.randomMapSeed + 31); float num = 1f; if (players + 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)list.Count), 0, list.Count); string empty = string.Empty; empty += "Start Of SetPlanetWeather() Prefix.\n"; empty += "Planet Weather Being Set! Details Below;\n\n"; empty = empty + "RandomMapSeed Is: " + startOfRound.randomMapSeed + "\n"; empty = empty + "Planet Random Is: " + random?.ToString() + "\n"; empty = empty + "Player Random Is: " + num + "\n"; empty = empty + "Result From PlanetWeatherRandomCurve Is: " + num2 + "\n"; empty += "All SelectableLevels In StartOfRound: \n\n"; foreach (SelectableLevel item2 in list) { empty = empty + item2.PlanetName + " | " + ((object)(LevelWeatherType)(ref item2.currentWeather)).ToString() + " | " + item2.overrideWeather + "\n"; RandomWeatherWithVariables[] randomWeathers = item2.randomWeathers; foreach (RandomWeatherWithVariables val in randomWeathers) { empty = empty + ((object)(LevelWeatherType)(ref val.weatherType)).ToString() + " | " + val.weatherVariable + " | " + val.weatherVariable2 + "\n"; } empty += "\n"; } empty += "SelectableLevels Chosen Using Random Variables Should Be: \n\n"; for (int j = 0; j < num2; j++) { SelectableLevel val2 = list[random.Next(0, list.Count)]; empty = empty + "SelectableLevel Chosen! Planet Name Is: " + val2.PlanetName; if (val2.randomWeathers != null && val2.randomWeathers.Length != 0) { int num3 = random.Next(0, val2.randomWeathers.Length); empty = empty + " --- Selected For Weather Change! Setting WeatherType From: " + ((object)(LevelWeatherType)(ref val2.currentWeather)).ToString() + " To: " + ((object)(LevelWeatherType)(ref val2.randomWeathers[num3].weatherType)).ToString() + "\n"; empty = empty + " Random Selection Results Were: " + num3 + " (Range: 0 - " + val2.randomWeathers.Length + ") Level RandomWeathers Choices Were: \n "; int num4 = 0; RandomWeatherWithVariables[] randomWeathers2 = val2.randomWeathers; foreach (RandomWeatherWithVariables val3 in randomWeathers2) { empty = empty + num4 + " . - " + ((object)(LevelWeatherType)(ref val3.weatherType)).ToString() + ", "; num4++; } empty += "\n\n"; } else { empty += "\n"; } list.Remove(val2); } empty += "End Of SetPlanetWeather() Prefix.\n\n"; Log(empty, DebugType.Developer); } internal static void DebugExtendedLevelGroups(List extendedLevelGroups) { } public static void DebugExtendedDungeonFlowTiles(ExtendedDungeonFlow extendedDungeonFlow) { string text = "Logging All Tiles In DungeonFlow: " + extendedDungeonFlow.DungeonName + "\n"; foreach (Tile tile in extendedDungeonFlow.DungeonFlow.GetTiles()) { text = text + ((Object)((Component)tile).gameObject).name + "\n"; } Log(text, DebugType.Developer); } public static void DebugExtendedDungeonSpawnSyncedObjects(ExtendedDungeonFlow extendedDungeonFlow) { string text = "Logging All SpawnSyncedObjects In DungeonFlow: " + extendedDungeonFlow.DungeonName + "\n"; foreach (SpawnSyncedObject spawnSyncedObject in extendedDungeonFlow.DungeonFlow.GetSpawnSyncedObjects(extendedDungeonFlow.AllTiles)) { text = text + ((Object)((Component)spawnSyncedObject).gameObject).name + " | " + ((Object)spawnSyncedObject.spawnPrefab.gameObject).name + "\n"; } Log(text, DebugType.Developer); } public static void DebugExtendedDungeonFlowRandomMapObjects(ExtendedDungeonFlow extendedDungeonFlow) { string text = "Logging All RandomMapObjects In DungeonFlow: " + extendedDungeonFlow.DungeonName + "\n"; foreach (RandomMapObject randomMapObject in extendedDungeonFlow.DungeonFlow.GetRandomMapObjects(extendedDungeonFlow.AllTiles)) { text = text + ((Object)((Component)randomMapObject).gameObject).name + " | " + ((Object)randomMapObject.spawnablePrefabs[0].gameObject).name + "\n"; } Log(text, DebugType.Developer); } internal static void DebugMoonsCataloguePage(MoonsCataloguePage moonsCataloguePage) { string text = "Finished Refreshing Current Moons Catalogue, Results Are\n"; foreach (ExtendedLevelGroup extendedLevelGroup in moonsCataloguePage.ExtendedLevelGroups) { text += "\n"; foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { text = text + moonsCataloguePage.ExtendedLevelGroups.IndexOf(extendedLevelGroup) + " - " + extendedLevels.NumberlessPlanetName + "\n"; } } Log(text, DebugType.Developer); } internal static void DebugStringToStringWithRarityListParser(string inputString) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string text = "Debugging String To StringWithRarity List Parser.\n"; text = text + "Input String Is: (" + inputString + ")\n"; List list = ConfigHelper.ConvertToStringWithRarityList(inputString, Vector2.zero); text += "Parsed StringWithRarities; \n"; foreach (StringWithRarity item in list) { text = text + "String: " + item.Name + " , Rarity: " + item.Rarity; bool flag = false; foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (extendedLevel.NumberlessPlanetName.ToLower().Contains(item.Name.ToLower()) || item.Name.ToLower().Contains(extendedLevel.NumberlessPlanetName.ToLower())) { text = text + " | Found Loaded ExtendedLevel: " + extendedLevel.SelectableLevel.PlanetName + " From Parsed String: " + item.Name + "\n"; flag = true; } } if (!flag) { text += "\n"; } } Log(text, DebugType.Developer); } internal static void DebugStringToVector2WithRarityListParser(string inputString) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string text = "Debugging String To Vector2WithRarity List Parser.\n"; text = text + "Input String Is: (" + inputString + ")\n"; List list = ConfigHelper.ConvertToVector2WithRarityList(inputString, Vector2.zero); text += "Parsed Vector2WithRarities; \n"; foreach (Vector2WithRarity item in list) { text = text + "Min: " + item.Min + " , Max: " + item.Max + " , Rarity: " + item.Rarity + "\n"; } Log(text, DebugType.Developer); } internal static void DebugStringToSpawnableEnemiesWithRarityListParser(string inputString) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string text = "Debugging String To SpawnableEnemyWithRarity List Parser.\n"; text = text + "Input String Is: (" + inputString + ")\n"; List list = ConfigHelper.ConvertToSpawnableEnemyWithRarityList(inputString, Vector2.zero); text += "Parsed SpawnableEnemyWithRarities; \n"; foreach (SpawnableEnemyWithRarity item in list) { text = ((!((Object)(object)item.enemyType != (Object)null)) ? (text + "EnemyType Was Null, Skipping!\n") : (text + "Enemy Name: " + item.enemyType.enemyName + " , Rarity: " + item.rarity + "\n")); } Log(text, DebugType.Developer); } internal static void DebugAudioAssets() { Log("Debugging Vanilla Audio Assets", DebugType.Developer); foreach (AudioMixer audioMixer in OriginalContent.AudioMixers) { Log("Vanilla AudioMixer: " + ((Object)audioMixer).name, DebugType.Developer); } foreach (AudioMixerGroup audioMixerGroup in OriginalContent.AudioMixerGroups) { Log("Vanilla AudioMixerGroup: " + ((Object)audioMixerGroup).name + " | " + ((Object)audioMixerGroup.audioMixer).name, DebugType.Developer); } foreach (AudioMixerSnapshot audioMixerSnapshot in OriginalContent.AudioMixerSnapshots) { Log("Vanilla AudioMixerSnapshot: " + ((Object)audioMixerSnapshot).name + " | " + ((Object)audioMixerSnapshot.audioMixer).name, DebugType.Developer); } Log("Debugging Custom Audio Assets", DebugType.Developer); foreach (AudioMixer audioMixer2 in PatchedContent.AudioMixers) { Log("Custom AudioMixer: " + ((Object)audioMixer2).name, DebugType.Developer); } foreach (AudioMixerGroup audioMixerGroup2 in PatchedContent.AudioMixerGroups) { Log("Custom AudioMixerGroup: " + ((Object)audioMixerGroup2).name + " | " + ((Object)audioMixerGroup2.audioMixer).name, DebugType.Developer); } foreach (AudioMixerSnapshot audioMixerSnapshot2 in PatchedContent.AudioMixerSnapshots) { Log("Custom AudioMixerSnapshot: " + ((Object)audioMixerSnapshot2).name + " | " + ((Object)audioMixerSnapshot2.audioMixer).name, DebugType.Developer); } } public static void DebugSpawnScrap(ExtendedLevel extendedLevel) { foreach (SpawnableItemWithRarity item in extendedLevel.SelectableLevel.spawnableScrap) { if ((Object)(object)item.spawnableItem.spawnPrefab != (Object)null) { Log(extendedLevel.SelectableLevel.spawnableScrap.IndexOf(item) + " - " + ((Object)item.spawnableItem).name + ((Object)item.spawnableItem.spawnPrefab).name, DebugType.Developer); } else { Log(extendedLevel.SelectableLevel.spawnableScrap.IndexOf(item) + " - " + ((Object)item.spawnableItem).name + "(Null)", DebugType.Developer); } } } public static void DebugExtendedMod(ExtendedMod extendedMod) { string text = "Debug Report For ExtendedMod: " + extendedMod.ModName + " by " + extendedMod.AuthorName + "\n"; text = text + "\nExtendedContents: Count - " + extendedMod.ExtendedContents.Count + "\n"; foreach (ExtendedContent extendedContent in extendedMod.ExtendedContents) { text = text + "\n" + ((Object)extendedContent).name + " (" + ((object)extendedContent).GetType().Name + ")"; } Log(text + "\n", DebugType.Developer); } public static void DebugAllContentTags() { foreach (ExtendedMod item in PatchedContent.ExtendedMods.Concat(new List { PatchedContent.VanillaMod })) { List list = new List(); Dictionary> dictionary = new Dictionary>(); foreach (ExtendedContent extendedContent in item.ExtendedContents) { foreach (ContentTag contentTag in extendedContent.ContentTags) { if (dictionary.TryGetValue(contentTag, out var value)) { value.Add(extendedContent); continue; } dictionary.Add(contentTag, new List { extendedContent }); } } string empty = string.Empty; if (dictionary.Count > 0) { empty = item.ModName + " Had The Following Content Tags, \n"; foreach (KeyValuePair> item2 in dictionary) { empty = empty + "\nTag: " + item2.Key.contentTagName + " | Associated Contents: "; int num = 0; foreach (ExtendedContent item3 in item2.Value) { empty += ((Object)item3).name; if (num != item2.Value.Count - 1) { empty += ", "; } num++; } } } else { empty = item.ModName + " Had No Content Tags."; } Log(empty + "\n", DebugType.Developer); } } public static void DebugCachedLevelColliderData() { string text = "Cached Level Collider-Material Data\n\n"; foreach (KeyValuePair> item in LevelLoader.cachedLevelColliderMaterialDictionary) { text = text + "\nCollider: " + ((Object)((Component)item.Key).gameObject).name + " - Materials: "; foreach (Material item2 in item.Value) { text += ((Object)item2).name; if ((Object)(object)item2 != (Object)(object)item.Value.Last()) { text += ", "; } } } Log(text, DebugType.User); text = "Cached Level Material-Collider Data\n\n"; foreach (KeyValuePair> item3 in LevelLoader.cachedLevelMaterialColliderDictionary) { text = text + "\n" + item3.Key + " (" + item3.Value.Count + ")"; } Log(text, DebugType.User); } public static void LogDebugInstructionsFrom(CodeMatcher matcher) { string name = new StackTrace().GetFrame(1).GetMethod().Name; CodeInstructionFormatter @object = new CodeInstructionFormatter(matcher.Length); StringBuilder stringBuilder = new StringBuilder("'" + name + "' Matcher Instructions:\n").AppendLine(string.Join("\n", matcher.InstructionEnumeration().Select(@object.Format))).AppendLine("End of matcher instructions."); Log(stringBuilder.ToString(), DebugType.Developer); } } [Serializable] public class ExtendedLevelLogReport { public ExtendedLevel extendedLevel; public ExtendedLevelLogReport(ExtendedLevel newExtendedLevel) { extendedLevel = newExtendedLevel; } } [Serializable] public class ExtendedDungeonFlowLogReport { } internal class DebugOrderOfExecution { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void StartOfRound_Awake(StartOfRound __instance) { DebugHelper.Log("OrderOfExecution: StartOfRound Awake", DebugType.Developer); } [HarmonyPatch(typeof(StartOfRound), "OnEnable")] [HarmonyPrefix] public static void StartOfRound_OnEnable(StartOfRound __instance) { DebugHelper.Log("OrderOfExecution: StartOfRound OnEnable", DebugType.Developer); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPrefix] public static void StartOfRound_Start(StartOfRound __instance) { DebugHelper.Log("OrderOfExecution: StartOfRound Start", DebugType.Developer); } [HarmonyPatch(typeof(RoundManager), "Awake")] [HarmonyPrefix] public static void RoundManager_Awake(RoundManager __instance) { DebugHelper.Log("OrderOfExecution: RoundManager Awake", DebugType.Developer); } [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] public static void RoundManager_Start(RoundManager __instance) { DebugHelper.Log("OrderOfExecution: RoundManager Start", DebugType.Developer); } [HarmonyPatch(typeof(TimeOfDay), "Awake")] [HarmonyPrefix] public static void TimeOfDay_Awake(TimeOfDay __instance) { DebugHelper.Log("OrderOfExecution: TimeOfDay Awake", DebugType.Developer); } [HarmonyPatch(typeof(TimeOfDay), "Start")] [HarmonyPrefix] public static void TimeOfDay_Start(TimeOfDay __instance) { DebugHelper.Log("OrderOfExecution: TimeOfDay Start", DebugType.Developer); } [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPrefix] public static void Terminal_Awake(Terminal __instance) { DebugHelper.Log("OrderOfExecution: Terminal Awake", DebugType.Developer); } [HarmonyPatch(typeof(Terminal), "OnEnable")] [HarmonyPrefix] public static void Terminal_OnEnable(Terminal __instance) { DebugHelper.Log("OrderOfExecution: Terminal OnEnable", DebugType.Developer); } [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPrefix] public static void StartOfRound_Start(Terminal __instance) { DebugHelper.Log("OrderOfExecution: Terminal Start", DebugType.Developer); } } internal static class DebugStopwatch { private static Dictionary stopWatchDict = new Dictionary(); internal static void StartStopWatch(string newStopWatchText, bool stopPreviousStopWatch = true) { if (!stopWatchDict.ContainsKey(newStopWatchText)) { if (stopPreviousStopWatch && stopWatchDict.Count > 0) { StopStopWatch(stopWatchDict.Keys.ToList()[stopWatchDict.Count - 1]); } Stopwatch stopwatch = new Stopwatch(); stopWatchDict.Add(newStopWatchText, stopwatch); stopwatch.Start(); } } internal static void StopStopWatch(string stopWatchText) { if (stopWatchDict.ContainsKey(stopWatchText)) { Stopwatch stopwatch = stopWatchDict[stopWatchText]; stopwatch.Stop(); DebugHelper.Log($"[Debug Stopwatch] {stopWatchText} : {stopwatch.Elapsed.TotalSeconds:0.##} Seconds. ({stopwatch.ElapsedMilliseconds}ms)", DebugType.IAmBatby); stopWatchDict.Remove(stopWatchText); } } } public 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_000b: Expected O, but got Unknown GameObject val = new GameObject("LethalLibGeneratedPrefabs"); ((Object)val).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_0007: Expected O, but got Unknown GameObject val = new GameObject(name); ((Object)val).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; } } public static class Validators { public static bool ValidateExtendedContent(ExtendedContent extendedContent) { (bool, string) tuple = (false, string.Empty); if (extendedContent is ExtendedLevel extendedLevel) { tuple = ValidateExtendedContent(extendedLevel); } else if (extendedContent is ExtendedDungeonFlow extendedDungeonFlow) { tuple = ValidateExtendedContent(extendedDungeonFlow); } else if (extendedContent is ExtendedItem extendedItem) { tuple = ValidateExtendedContent(extendedItem); } else if (extendedContent is ExtendedEnemyType extendedEnemyType) { tuple = ValidateExtendedContent(extendedEnemyType); } else if (extendedContent is ExtendedFootstepSurface extendedFootstepSurface) { tuple = ValidateExtendedContent(extendedFootstepSurface); } else if (extendedContent is ExtendedStoryLog extendedStoryLog) { tuple = ValidateExtendedContent(extendedStoryLog); } else if (extendedContent is ExtendedBuyableVehicle extendedBuyableVehicle) { tuple = ValidateExtendedContent(extendedBuyableVehicle); } else if (extendedContent is ExtendedUnlockableItem extendedUnlockableItem) { tuple = ValidateExtendedContent(extendedUnlockableItem); } if (!tuple.Item1) { DebugHelper.Log(tuple.Item2, DebugType.Developer); } return tuple.Item1; } public static (bool result, string log) ValidateExtendedContent(ExtendedItem extendedItem) { if ((Object)(object)extendedItem == (Object)null) { return (false, "ExtendedItem Was Null"); } if ((Object)(object)extendedItem.Item == (Object)null) { return (false, "Item Was Null"); } if ((Object)(object)extendedItem.Item.spawnPrefab == (Object)null) { return (false, "SpawnPrefab Was Null"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedLevel extendedLevel) { if ((Object)(object)extendedLevel == (Object)null) { return (false, "ExtendedLevel Was Null"); } if ((Object)(object)extendedLevel.SelectableLevel == (Object)null) { return (false, "SelectableLevel Was Null"); } if (string.IsNullOrEmpty(extendedLevel.SelectableLevel.sceneName)) { return (false, "SelectableLevel SceneName Was Null Or Empty"); } if ((Object)(object)extendedLevel.SelectableLevel.planetPrefab == (Object)null) { return (false, "SelectableLevel PlanetPrefab Was Null"); } if ((Object)(object)extendedLevel.SelectableLevel.planetPrefab.GetComponent() == (Object)null) { return (false, "SelectableLevel PlanetPrefab Animator Was Null"); } if ((Object)(object)extendedLevel.SelectableLevel.planetPrefab.GetComponent().runtimeAnimatorController == (Object)null) { return (false, "SelectableLevel PlanetPrefab Animator AnimatorController Was Null"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedDungeonFlow extendedDungeonFlow) { return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedEnemyType extendedEnemyType) { if ((Object)(object)extendedEnemyType == (Object)null) { return (false, "ExtendedEnemyType Was Null"); } if ((Object)(object)extendedEnemyType.EnemyType == (Object)null) { return (false, "EnemyType Was Null"); } if ((Object)(object)extendedEnemyType.EnemyType.enemyPrefab == (Object)null) { return (false, "EnemyPrefab Was Null"); } if (!Object.op_Implicit((Object)(object)extendedEnemyType.EnemyType.enemyPrefab.GetComponent())) { return (false, "EnemyPrefab Did Not Contain A NetworkObject"); } EnemyAI val = extendedEnemyType.EnemyType.enemyPrefab.GetComponent(); if ((Object)(object)val == (Object)null) { val = extendedEnemyType.EnemyType.enemyPrefab.GetComponentInChildren(); } if ((Object)(object)val == (Object)null) { return (false, "EnemyPrefab Did Not Contain A Component Deriving From EnemyAI"); } if ((Object)(object)val.enemyType == (Object)null) { return (false, "EnemyAI.enemyType Was Null"); } if ((Object)(object)val.enemyType != (Object)(object)extendedEnemyType.EnemyType) { return (false, "EnemyAI.enemyType Did Not Match ExtendedEnemyType.EnemyType"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedWeatherEffect extendedWeatherEffect) { return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedFootstepSurface extendedFootstepSurface) { if (extendedFootstepSurface.footstepSurface == null) { return (false, "FootstepSurface Was Null"); } if (extendedFootstepSurface.associatedMaterials == null) { return (false, "Associated Materials List Was Null"); } if (extendedFootstepSurface.associatedMaterials.Count == 0) { return (false, "Associated Materials List Was Empty"); } if (extendedFootstepSurface.footstepSurface.clips == null) { return (false, "FootstepSurface Clips Array Was Null"); } if (extendedFootstepSurface.footstepSurface.clips.Length == 0) { return (false, "FootstepSurface Clips Array Was Empty"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedStoryLog extendedStoryLog) { if (string.IsNullOrEmpty(extendedStoryLog.sceneName)) { return (false, "StoryLog SceneName Was Null Or Empty"); } if (string.IsNullOrEmpty(extendedStoryLog.terminalKeywordNoun)) { return (false, "StoryLog TerminalKeywordNoun Was Null Or Empty"); } if (string.IsNullOrEmpty(extendedStoryLog.storyLogTitle)) { return (false, "StoryLog Title Was Null Or Empty"); } if (string.IsNullOrEmpty(extendedStoryLog.storyLogDescription)) { return (false, "StoryLog Description Was Null Or Empty"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedBuyableVehicle extendedBuyableVehicle) { if ((Object)(object)extendedBuyableVehicle.BuyableVehicle.vehiclePrefab == (Object)null) { return (false, "Vehicle Prefab Was Null Or Empty"); } if ((Object)(object)extendedBuyableVehicle.BuyableVehicle.secondaryPrefab == (Object)null) { return (false, "Vehicle Secondary Prefab Was Null Or Empty"); } if ((Object)(object)extendedBuyableVehicle.BuyableVehicle.vehiclePrefab.GetComponent() == (Object)null) { return (false, "Vehicle Prefab Is Missing NetworkObject Component"); } if ((Object)(object)extendedBuyableVehicle.BuyableVehicle.secondaryPrefab.GetComponent() == (Object)null) { return (false, "Vehicle Secondary Prefab Is Missing NetworkObject Component"); } return (true, string.Empty); } public static (bool result, string log) ValidateExtendedContent(ExtendedUnlockableItem extendedUnlockableItem) { if (extendedUnlockableItem.UnlockableItem.unlockableType == 1 && !extendedUnlockableItem.UnlockableItem.alreadyUnlocked) { if ((Object)(object)extendedUnlockableItem.UnlockableItem.prefabObject == (Object)null) { return (false, "Unlockable Item Prefab Was Null Or Empty"); } NetworkObject val = default(NetworkObject); if (!extendedUnlockableItem.UnlockableItem.prefabObject.TryGetComponent(ref val)) { return (false, "Unlockable Item Prefab Is Missing NetworkObject Component"); } AutoParentToShip val2 = default(AutoParentToShip); if (!extendedUnlockableItem.UnlockableItem.prefabObject.TryGetComponent(ref val2)) { return (false, "Unlockable Item Prefab Is Missing AutoParentToShip Component"); } } else if (extendedUnlockableItem.UnlockableItem.unlockableType == 0 && (Object)(object)extendedUnlockableItem.UnlockableItem.suitMaterial == (Object)null) { return (false, "Unlockable Suit Is Missing Suit Material"); } return (true, string.Empty); } } } 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; 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); 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"); injectDynamicMatchingWeights = BindValue("Inject Dynamic Matching Weights", "Enable dynamic weights injection on every landing, based on Level & Dungeon MatchingProperties set by mod authors.", genericValue: true); 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); } } 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 = new List(TerminalManager.routeKeyword.compatibleNouns); 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 class ConfigTemplate { public ConfigFile configFile; public string subCategory = string.Empty; public int sortingPriority; private string _category = string.Empty; public string Category { get { return GetSortingSpaces() + _category; } set { _category = 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 HashSet objectsToDestroy = new HashSet(); internal static void RestoreVanillaDungeonAssetReferences(ExtendedDungeonFlow extendedDungeonFlow) { if ((Object)(object)extendedDungeonFlow == (Object)null) { DebugHelper.LogError("Tried To Restore Null Vanilla ExtendedDungeonFlow! Returning!", DebugType.User); return; } if ((Object)(object)extendedDungeonFlow.DungeonFlow == (Object)null) { DebugHelper.LogError("Tried To Restore Null Vanilla 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 randomScrapSpawn in list) { if ((Object)(object)randomScrapSpawn.spawnableItems != (Object)null && ((Object)randomScrapSpawn.spawnableItems).name != null) { ItemGroup val2 = OriginalContent.ItemGroups.Find((ItemGroup itemGroup) => ((Object)itemGroup).name == ((Object)randomScrapSpawn.spawnableItems).name); if ((Object)(object)val2 != (Object)null) { randomScrapSpawn.spawnableItems = ContentRestorer.RestoreAsset((Object)(object)randomScrapSpawn.spawnableItems, val2, debugAction: false, destroyOnReplace: false); } } } RestoreAudioAssetReferencesInParent(((Component)val).gameObject); } foreach (RandomMapObject randomMapObject in extendedDungeonFlow.DungeonFlow.GetRandomMapObjects(extendedDungeonFlow.AllTiles)) { for (int j = 0; j < randomMapObject.spawnablePrefabs?.Count; j++) { GameObject spawnablePrefab = randomMapObject.spawnablePrefabs[j]; if ((Object)(object)spawnablePrefab == (Object)null) { DebugHelper.LogWarning("Map Object Restoration Warning: " + ((Object)((Component)randomMapObject).gameObject).name + " Has Missing RandomMapObject", DebugType.Developer); randomMapObject.spawnablePrefabs.RemoveAt(j--); continue; } IndoorMapHazardType val3 = 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)val3 != (Object)null) { randomMapObject.spawnablePrefabs[j] = ContentRestorer.RestoreAsset((Object)(object)spawnablePrefab, val3.prefabToSpawn, debugAction: false, destroyOnReplace: false); } } } } internal static void RestoreVanillaLevelAssetReferences(ExtendedLevel extendedLevel) { //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown foreach (SpawnableItemWithRarity item2 in new List(extendedLevel.SelectableLevel.spawnableScrap)) { if ((Object)(object)item2.spawnableItem == (Object)null) { extendedLevel.SelectableLevel.spawnableScrap.Remove(item2); continue; } foreach (Item item3 in OriginalContent.Items) { if (((Object)item2.spawnableItem).name == ((Object)item3).name) { item2.spawnableItem = ContentRestorer.RestoreAsset((Object)(object)item2.spawnableItem, item3, debugAction: false, destroyOnReplace: true); } } } foreach (EnemyType enemy in OriginalContent.Enemies) { foreach (SpawnableEnemyWithRarity item4 in extendedLevel.SelectableLevel.Enemies.Concat(extendedLevel.SelectableLevel.DaytimeEnemies).Concat(extendedLevel.SelectableLevel.OutsideEnemies)) { if ((Object)(object)item4.enemyType != (Object)null && !string.IsNullOrEmpty(((Object)item4.enemyType).name) && ((Object)item4.enemyType).name == ((Object)enemy).name) { item4.enemyType = ContentRestorer.RestoreAsset((Object)(object)item4.enemyType, enemy, debugAction: false, destroyOnReplace: true); } } } if (extendedLevel.SelectableLevel.indoorMapHazards == null || extendedLevel.SelectableLevel.indoorMapHazards.Length == 0) { List list = new List(extendedLevel.SelectableLevel.spawnableMapObjects.Length); SpawnableMapObject[] spawnableMapObjects = extendedLevel.SelectableLevel.spawnableMapObjects; foreach (SpawnableMapObject val in spawnableMapObjects) { foreach (IndoorMapHazardType indoorMapHazard in OriginalContent.IndoorMapHazards) { if ((Object)(object)val.prefabToSpawn != (Object)null && (Object)(object)indoorMapHazard != (Object)null && (Object)(object)indoorMapHazard.prefabToSpawn != (Object)null && ((Object)val.prefabToSpawn).name == ((Object)indoorMapHazard.prefabToSpawn).name) { IndoorMapHazard item = new IndoorMapHazard { hazardType = indoorMapHazard, numberToSpawn = val.numberToSpawn }; list.Add(item); } } } extendedLevel.SelectableLevel.indoorMapHazards = list.ToArray(); } else { IndoorMapHazard[] indoorMapHazards = extendedLevel.SelectableLevel.indoorMapHazards; foreach (IndoorMapHazard val2 in indoorMapHazards) { foreach (IndoorMapHazardType indoorMapHazard2 in OriginalContent.IndoorMapHazards) { if ((Object)(object)val2.hazardType != (Object)null && (Object)(object)indoorMapHazard2 != (Object)null && ((Object)val2.hazardType).name == ((Object)indoorMapHazard2).name) { val2.hazardType = indoorMapHazard2; break; } } } } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = extendedLevel.SelectableLevel.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val3 in spawnableOutsideObjects) { foreach (SpawnableOutsideObject spawnableOutsideObject in OriginalContent.SpawnableOutsideObjects) { if ((Object)(object)val3.spawnableObject != (Object)null && ((Object)val3.spawnableObject).name == ((Object)spawnableOutsideObject).name) { val3.spawnableObject = ContentRestorer.RestoreAsset((Object)(object)val3.spawnableObject, spawnableOutsideObject, debugAction: false, destroyOnReplace: true); } } } foreach (LevelAmbienceLibrary levelAmbienceLibrary in OriginalContent.LevelAmbienceLibraries) { if ((Object)(object)extendedLevel.SelectableLevel.levelAmbienceClips != (Object)null && ((Object)extendedLevel.SelectableLevel.levelAmbienceClips).name == ((Object)levelAmbienceLibrary).name) { extendedLevel.SelectableLevel.levelAmbienceClips = ContentRestorer.RestoreAsset((Object)(object)extendedLevel.SelectableLevel.levelAmbienceClips, levelAmbienceLibrary, debugAction: false, destroyOnReplace: true); } } } 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) { return; } AudioMixerGroup outputAudioMixerGroup = audioSource.outputAudioMixerGroup; AudioMixer audioMixer = audioSource.outputAudioMixerGroup.audioMixer; AudioMixerGroup val = null; AudioMixer val2 = null; foreach (AudioMixer audioMixer2 in OriginalContent.AudioMixers) { if (((Object)audioMixer).name == ((Object)audioMixer2).name) { val2 = ContentRestorer.RestoreAsset((Object)(object)audioMixer, audioMixer2, debugAction: false, destroyOnReplace: false); } } foreach (AudioMixerGroup audioMixerGroup in OriginalContent.AudioMixerGroups) { if (((Object)outputAudioMixerGroup).name == ((Object)audioMixerGroup).name) { val = ContentRestorer.RestoreAsset((Object)(object)outputAudioMixerGroup, audioMixerGroup, debugAction: false, destroyOnReplace: false); } } if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { audioSource.outputAudioMixerGroup = val; } } 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(); } internal static void TryRestoreWaterShader(Material customMaterial) { if (!((Object)(object)customMaterial == (Object)null) && !((Object)(object)customMaterial.shader == (Object)null) && !string.IsNullOrEmpty(((Object)customMaterial.shader).name) && !((Object)(object)customMaterial.shader == (Object)(object)LevelLoader.vanillaWaterShader) && ((Object)customMaterial.shader).name == ((Object)LevelLoader.vanillaWaterShader).name) { customMaterial.shader = LevelLoader.vanillaWaterShader; customMaterial.DisableKeyword("_BLENDMODE_ALPHA"); customMaterial.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); customMaterial.EnableKeyword("_ENABLE_FOG_ON_TRANSPARENT"); customMaterial.EnableKeyword("_DISABLE_SSR_TRANSPARENT"); } } 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; } } } namespace LethalLevelLoader.NetworkStructs { public struct NetworkItemReference : INetworkSerializable { private uint m_NetworkItemObjectId; private static uint s_NullId = uint.MaxValue; public uint NetworkItemObjectId { get { return m_NetworkItemObjectId; } internal set { m_NetworkItemObjectId = value; } } private List m_Prefabs => LethalLevelLoaderNetworkManager.networkManager.NetworkConfig.Prefabs.m_Prefabs; public NetworkItemReference(Item item) { m_NetworkItemObjectId = 0u; if ((Object)(object)item == (Object)null) { m_NetworkItemObjectId = s_NullId; 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 bool TryGet(out Item item, NetworkManager networkManager = null) { item = Resolve(this); return (Object)(object)item != (Object)null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Item Resolve(NetworkItemReference networkItemRef) { if (networkItemRef.m_NetworkItemObjectId == s_NullId) { return null; } return networkItemRef.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 Item GetItemFromNetworkPrefabIdHash(uint idHash) { GrabbableObject val = default(GrabbableObject); for (int i = 0; i < m_Prefabs.Count; i++) { if (m_Prefabs[i].SourcePrefabGlobalObjectIdHash == idHash && m_Prefabs[i].Prefab.TryGetComponent(ref val)) { return val.itemProperties; } } return null; } private uint GetIdHashFromItem(Item item) { for (int i = 0; i < m_Prefabs.Count; i++) { if ((Object)(object)m_Prefabs[i].Prefab == (Object)(object)item.spawnPrefab) { return m_Prefabs[i].SourcePrefabGlobalObjectIdHash; } } return 0u; } } } namespace LethalLevelLoader.Compatibility { internal static class DawnLibCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); 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.Add(extendedLevel.SelectableLevel.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); } } 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; } } } namespace LethalLevelLoader.AssetBundles { public enum AssetBundleGroupLoadedStatus { Unloaded, Partial, Loaded } public enum AssetBundleGroupLoadingStatus { None, Mixed, Loading, Unloading } public class AssetBundleGroup { private 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 (assetBundleInfos[i].AssetBundleFilePath.Equals(fullFilePath)) { 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 { [CompilerGenerated] private sealed class d__55 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AssetBundleInfo <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; AssetBundleInfo assetBundleInfo = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; assetBundleInfo.bundleLoadStopwatch = Stopwatch.StartNew(); string text = Path.Combine(Application.streamingAssetsPath, assetBundleInfo.AssetBundleFilePath); assetBundleInfo.activeLoadRequest = AssetBundle.LoadFromFileAsync(text); <>2__current = assetBundleInfo.activeLoadRequest; <>1__state = 1; return true; } case 1: <>1__state = -1; if ((Object)(object)assetBundleInfo.assetBundle != (Object)null || (((AsyncOperation)assetBundleInfo.activeLoadRequest).isDone && (Object)(object)assetBundleInfo.activeLoadRequest.assetBundle != (Object)null)) { assetBundleInfo.assetBundle = assetBundleInfo.activeLoadRequest.assetBundle; if (!assetBundleInfo.hasInitialized) { assetBundleInfo.Initialize(); } assetBundleInfo.activeLoadRequest = null; assetBundleInfo.bundleLoadStopwatch.Stop(); assetBundleInfo.LastTimeLoaded = Time.time; DebugHelper.Log(assetBundleInfo.AssetBundleFileName + " Loaded (" + assetBundleInfo.LastLoadTime + ")!", DebugType.User); assetBundleInfo.OnBundleLoaded.Invoke(assetBundleInfo); } else { assetBundleInfo.activeLoadRequest = null; assetBundleInfo.bundleLoadStopwatch.Stop(); assetBundleInfo.LastTimeLoaded = Time.time; DebugHelper.LogError("AssetBundleInfo: " + assetBundleInfo.AssetBundleFileName + " failed to load or is already loaded. Skipping...", DebugType.User); AssetBundleLoader.Instance.AssetBundleInfos.Remove(assetBundleInfo); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__57 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AssetBundleInfo <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__57(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; AssetBundleInfo assetBundleInfo = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; assetBundleInfo.bundleUnloadStopwatch = Stopwatch.StartNew(); <>2__current = waitForEndOfFrame; <>1__state = 1; return true; case 1: <>1__state = -1; assetBundleInfo.activeUnloadRequest = assetBundleInfo.assetBundle.UnloadAsync(true); <>2__current = assetBundleInfo.activeUnloadRequest; <>1__state = 2; return true; case 2: <>1__state = -1; if (((AsyncOperation)assetBundleInfo.activeUnloadRequest).isDone) { Object.Destroy((Object)(object)assetBundleInfo.assetBundle); assetBundleInfo.assetBundle = null; assetBundleInfo.activeUnloadRequest = null; assetBundleInfo.bundleUnloadStopwatch.Stop(); assetBundleInfo.LastTimeUnloaded = Time.time; DebugHelper.Log(assetBundleInfo.AssetBundleFileName + " Unloaded (" + assetBundleInfo.LastUnloadTime + ")", DebugType.User); assetBundleInfo.OnBundeUnloaded.Invoke(assetBundleInfo); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private bool hasInitialized; private AssetBundle assetBundle; private MonoBehaviour coroutineHandler; private AssetBundleCreateRequest activeLoadRequest; private AssetBundleUnloadOperation activeUnloadRequest; private Stopwatch bundleLoadStopwatch; private Stopwatch bundleUnloadStopwatch; private List allAssetPaths = new List(); private List streamingBundleScenePaths = new List(); private List sceneNames = new List(); public ExtendedEvent OnBundleLoaded = new ExtendedEvent(); public ExtendedEvent OnBundeUnloaded = new ExtendedEvent(); 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; } = "UNKNOWN"; public AssetBundleType AssetBundleMode { get; private set; } public bool IsAssetBundleLoaded => (Object)(object)assetBundle != (Object)null; public string AssetBundleFileName { get; private set; } = "UNKNOWN"; public string AssetBundleFilePath { get; private set; } = string.Empty; 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) : this(newCoroutineHandler, filePath, "UNKNOWN") { if (filePath.Contains(Path.DirectorySeparatorChar)) { AssetBundleFileName = filePath.Substring(filePath.LastIndexOf(Path.DirectorySeparatorChar) + 1); } } public AssetBundleInfo(MonoBehaviour newCoroutineHandler, string filePath, string fileName) { coroutineHandler = newCoroutineHandler; AssetBundleFilePath = filePath; AssetBundleFileName = fileName; bundleLoadStopwatch = new Stopwatch(); bundleUnloadStopwatch = new Stopwatch(); } 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 = value.scenePaths.Select(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 = new List(assetBundle.GetAllScenePaths()); allAssetPaths = new List(streamingBundleScenePaths); 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 = new List(assetBundle.GetAllAssetNames()); } } 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; } [IteratorStateMachine(typeof(d__55))] private IEnumerator LoadBundleRequest() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__55(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__57))] private IEnumerator UnloadBundleRequest() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__57(0) { <>4__this = this }; } public List LoadAllAssets() where T : Object { if (AssetBundleMode == AssetBundleType.Unknown || AssetBundleMode == AssetBundleType.Streaming) { return new List(); } if (!IsAssetBundleLoaded || (Object)(object)assetBundle == (Object)null) { return new List(); } return new List(assetBundle.LoadAllAssets()); } public List GetSceneNames() { return new List(sceneNames); } 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 class AssetBundleLoader : MonoBehaviour { [CompilerGenerated] private sealed class d__29 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; AsyncOperation val = Resources.UnloadUnusedAssets(); <>2__current = val; <>1__state = 1; return true; } case 1: { <>1__state = -1; Caching.ClearCache(); GC.Collect(); AsyncOperation val = Resources.UnloadUnusedAssets(); <>2__current = val; <>1__state = 2; return true; } case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static AssetBundleLoader instance; internal static DirectoryInfo pluginsFolder = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.Parent; private Dictionary assetBundleInfoDirectoryDict = new Dictionary(); 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 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; private bool onCooldown; public static AssetBundleLoader Instance { get { if ((Object)(object)instance == (Object)null) { instance = Object.FindFirstObjectByType(); } 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; } [IteratorStateMachine(typeof(d__29))] private IEnumerator ClearCacheRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__29(0); } internal static void ClearCache() { ((MonoBehaviour)Instance).StartCoroutine(Instance.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)) { value.Add(onProcessedCallback); } else { processedCallbacksDict.Add((directory.FullName, item), new List> { 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; } } } foreach (List item5 in list.Select((UniqueSceneGroup s) => s.AssetBundleInfosInGroup).Concat(list2)) { if (!ValidatePotentialAssetBundleGroup(item5)) { 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 info in assetBundleGroup.GetAssetBundleInfos()) { if (!(info.AssetBundleName == item8.Key)) { continue; } AssetBundle val = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func)((AssetBundle bundle) => ((Object)bundle).name == info.AssetBundleName)); 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 assetBundleInfo3 in assetBundleGroup.GetAssetBundleInfos()) { text = text + "\n" + assetBundleInfo3.AssetBundleName; } DebugHelper.Log(text, DebugType.IAmBatby); } AllowLoading = true; OnBundlesFinishedProcessing.Invoke(); foreach (AssetBundleInfo assetBundleInfo4 in Instance.AssetBundleInfos) { assetBundleInfo4.TryUnloadBundle(); } } private static bool ValidatePotentialAssetBundleGroup(List assetBundleInfos) { if (assetBundleInfos.Count == 0) { return false; } return true; } 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 new List(Instance.AssetBundleInfos); } private static List GetAssetBundleInfos(AssetBundleType modeFilter) { return Instance.AssetBundleInfos.Where((AssetBundleInfo a) => a.AssetBundleMode == modeFilter).ToList(); } private static List GetAssetBundleInfos(bool isLoadedFilter) { return Instance.AssetBundleInfos.Where((AssetBundleInfo a) => a.IsAssetBundleLoaded == isLoadedFilter).ToList(); } } internal class UniqueSceneGroup { private List scenesInGroup = new List(); internal List AssetBundleInfosInGroup { get; private set; } = 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.ToString("F2") + "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); } internal static string GetLoadingPercentage(AssetBundleGroup group) { return GetLoadingPercentage(group.ActiveProgress); } internal static string GetLoadingPercentage(AssetBundleInfo info) { return GetLoadingPercentage(info.ActiveProgress); } internal static string GetLoadingPercentage(float progress) { string text = progress.ToString("F2"); if (text.Contains("0.")) { text = text.Replace("0.", "0"); } else if (text.Contains(".")) { text = text.Replace(".", string.Empty); } if (text == "00") { text = "000"; } return text + "%"; } } 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]); 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 { } }