using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DunGen; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalLevelLoader; 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.SceneManagement; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalLevelLoader")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A Custom API to support the manual and dynamic integration of custom levels and dungeons in Lethal Company.")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+462fc571e35e253f6b289405a27816eedac575eb")] [assembly: AssemblyProduct("LethalLevelLoader")] [assembly: AssemblyTitle("LethalLevelLoader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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 } 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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(); private static Dictionary scenePathToBuildIndex = new Dictionary(); private static Dictionary buildIndexToScenePath = new Dictionary(); private static Dictionary sceneHashToScenePath = new Dictionary(); private static HookHelper.DisposableHookCollection hooks = new HookHelper.DisposableHookCollection(); internal static bool patched { get; private set; } public static void AddScenePath(string scenePath) { if (!scenePaths.Contains(scenePath)) { DebugHelper.Log("Adding ScenePath: " + scenePath, DebugType.User); scenePaths.Add(scenePath); } } internal static void Patch() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0034: 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0034: 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(); orig(self); int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings; for (int i = 0; i < scenePaths.Count; i++) { int num = sceneCountInBuildSettings + i; string text = scenePaths[i]; 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); } } 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_0005: Unknown result type (might be due to invalid IL or missing references) bool flag = orig(self, sceneIndex, sceneName, loadSceneMode); return true; } } namespace LethalLevelLoader { public class ExtendedContent : ScriptableObject { public ExtendedMod ExtendedMod { get; internal set; } public ContentType ContentType { get; internal set; } = ContentType.Vanilla; 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; 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) _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(25f)] [Header("Obsolete (Legacy Fields, Will Be Removed In The Future)")] [Obsolete] public bool generateAutomaticConfigurationOptions = true; [Obsolete] public bool enableDynamicDungeonSizeRestriction = false; [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; [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: SerializeField] public GameObject OverrideKeyPrefab { get; set; } [field: SerializeField] public List SpawnableMapObjects { 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; [field: Space(10f)] [field: Header("Misc. Settings")] [field: SerializeField] public bool GenerateAutomaticConfigurationOptions { get; set; } = true; 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(); 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 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]; } if ((Object)(object)OverrideKeyPrefab == (Object)null) { OverrideKeyPrefab = DungeonLoader.defaultKeyPrefab; } } 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_012f: Unknown result type (might be due to invalid IL or missing references) 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; } } } [Serializable] public class GlobalPropCountOverride { public int globalPropID; [Range(0f, 1f)] public float globalPropCountScaleRate = 0f; } [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 LevelMatchingProperties DaytimeLevelMatchingProperties { 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.SkipToLetters().RemoveWhitespace() + "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)DaytimeLevelMatchingProperties == (Object)null) { DaytimeLevelMatchingProperties = LevelMatchingProperties.Create(this); } } } [CreateAssetMenu(fileName = "ExtendedFootstepSurface", menuName = "Lethal Level Loader/Extended Content/ExtendedFootstepSurface", order = 27)] public class ExtendedFootstepSurface : ExtendedContent { public FootstepSurface footstepSurface; public List associatedMaterials; public List associatedGameObjects; internal int arrayIndex; } [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.SkipToLetters().RemoveWhitespace() + "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(); 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 = 0; [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; } = false; [field: Space(5f)] [field: SerializeField] public GameObject OverrideQuicksandPrefab { get; set; } [field: Space(5f)] [field: SerializeField] public bool IsRouteHidden { get; set; } = false; [field: SerializeField] public bool IsRouteLocked { get; set; } = false; [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("Terminal Route Override Settings")] [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 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 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)OverrideQuicksandPrefab == (Object)null) { OverrideQuicksandPrefab = LevelLoader.defaultQuicksandPrefab; } if (base.ContentType == ContentType.Custom) { ((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; } = ModMergeSetting.MatchingAuthorName; [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(); 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); } return list; } } internal static ExtendedMod Create(string modName) { ExtendedMod extendedMod = ScriptableObject.CreateInstance(); extendedMod.ModName = modName; ((Object)extendedMod).name = modName.Sanitized() + "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.SkipToLetters().RemoveWhitespace() + "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.SkipToLetters().RemoveWhitespace() + "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; } 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 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); } 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(); } internal void SortRegisteredContent() { 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)); } internal void Example() { AssetBundle val = null; ExtendedDungeonFlow extendedDungeonFlow = val.LoadAsset("Assets/CoolDungeonFlow"); ExtendedEnemyType extendedEnemyType = val.LoadAsset("Assets/Ghost"); ExtendedMod extendedMod = Create("BatbysMod", "IAmBatby", new ExtendedContent[2] { extendedDungeonFlow, extendedEnemyType }); PatchedContent.RegisterExtendedMod(extendedMod); } } [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; } [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_0001: 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_0027: 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 string CurrentLevelName { get; internal set; } = string.Empty; public void Reset() { CurrentLevelName = string.Empty; parityStepsTaken = 0; itemSaveData = new Dictionary(); } } 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; } } [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_000f: 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) ContentTag contentTag = ScriptableObject.CreateInstance(); contentTag.contentTagName = tag; contentTag.contentTagColor = color; ((Object)contentTag).name = tag + "ContentTag"; return contentTag; } public static ContentTag Create(string tag) { //IL_0002: 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.Sanitized().Contains(item.Sanitized()) || item.Sanitized().Contains(matchingString.Name.Sanitized()))) { 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 static class PatchedContent { 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) { if (extendedLevel.ContentType == ContentType.Custom) { list.Add(extendedLevel); } } return list; } } public static List SeletectableLevels { 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) { if (extendedLevel.ContentType == ContentType.Custom) { 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 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; } AssetBundleLoader.RegisterNewExtendedContent(extendedDungeonFlow, ((Object)extendedDungeonFlow).name); } public static void RegisterExtendedLevel(ExtendedLevel extendedLevel) { AssetBundleLoader.RegisterNewExtendedContent(extendedLevel, ((Object)extendedLevel).name); } public static void RegisterExtendedMod(ExtendedMod extendedMod) { DebugHelper.Log("Registering ExtendedMod: " + extendedMod.ModName + " Manually.", DebugType.Developer); AssetBundleLoader.RegisterExtendedMod(extendedMod); } internal static void SortExtendedMods() { ExtendedMods = new List(ExtendedMods.OrderBy((ExtendedMod o) => o.ModName).ToList()); foreach (ExtendedMod extendedMod in ExtendedMods) { extendedMod.SortRegisteredContent(); } } } public static class OriginalContent { 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 Enemies { get; internal set; } = new List(); public static List SpawnableOutsideObjects { get; internal set; } = new List(); public static List SpawnableMapObjects { 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_0021: 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_002a: 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) 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.Sanitized().Contains(((Object)val2.prefabToSpawn).name.Sanitized())) { 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() { LevelManager.CurrentExtendedLevel.LevelEvents.onShipLand.Invoke(); LevelManager.GlobalLevelEvents.onShipLand.Invoke(); DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onShipLand.Invoke(); DungeonManager.GlobalDungeonEvents.onShipLand.Invoke(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] [HarmonyPrefix] internal static void StartOfRoundShipLeave_Prefix() { LevelManager.CurrentExtendedLevel.LevelEvents.onShipLeave.Invoke(); LevelManager.GlobalLevelEvents.onShipLeave.Invoke(); 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) { if (!((NetworkBehaviour)__instance).IsHost) { return; } if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { PlayerControllerB item = Patches.StartOfRound.allPlayerScripts[playerObj]; if (__instance.isEntranceToBuilding) { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerEnterDungeon.Invoke((__instance, item)); DungeonManager.GlobalDungeonEvents.onPlayerEnterDungeon.Invoke((__instance, item)); } else { DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onPlayerExitDungeon.Invoke((__instance, item)); DungeonManager.GlobalDungeonEvents.onPlayerExitDungeon.Invoke((__instance, item)); } } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { PlayerControllerB item2 = Patches.StartOfRound.allPlayerScripts[playerObj]; if (__instance.isEntranceToBuilding) { LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerEnterDungeon.Invoke((__instance, item2)); LevelManager.GlobalLevelEvents.onPlayerEnterDungeon.Invoke((__instance, item2)); } else { LevelManager.CurrentExtendedLevel.LevelEvents.onPlayerExitDungeon.Invoke((__instance, item2)); LevelManager.GlobalLevelEvents.onPlayerExitDungeon.Invoke((__instance, item2)); } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(LungProp), "EquipItem")] [HarmonyPrefix] internal static void LungPropEquipItem_Postfix(LungProp __instance) { if (((NetworkBehaviour)__instance).IsServer) { 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) if ((int)previousDayMode == -1 || previousDayMode != __result) { LevelManager.CurrentExtendedLevel.LevelEvents.onDayModeToggle.Invoke(__result); LevelManager.GlobalLevelEvents.onDayModeToggle.Invoke(__result); } previousDayMode = __result; } } public class ExtendedEvent { public delegate void ParameterEvent(T param); public bool HasListeners => Listeners != 0; public int Listeners { get; internal set; } private event ParameterEvent onParameterEvent; public void Invoke(T param) { this.onParameterEvent?.Invoke(param); } public void AddListener(ParameterEvent listener) { onParameterEvent += listener; Listeners++; } public void RemoveListener(ParameterEvent listener) { onParameterEvent -= listener; Listeners--; } } public class ExtendedEvent { public delegate void Event(); public bool HasListeners => Listeners != 0; public int Listeners { get; internal set; } private event Event onEvent; public void Invoke() { this.onEvent?.Invoke(); } public void AddListener(Event listener) { onEvent += listener; Listeners++; } public void RemoveListener(Event listener) { onEvent -= listener; Listeners--; } } public static class Extensions { public static List GetTiles(this DungeonFlow dungeonFlow) { List list = new List(); foreach (GraphNode node in dungeonFlow.Nodes) { foreach (TileSet tileSet in node.TileSets) { list.AddRange(GetTilesInTileSet(tileSet)); } } foreach (GraphLine line in dungeonFlow.Lines) { foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes) { foreach (TileSet branchCapTileSet in dungeonArchetype.BranchCapTileSets) { list.AddRange(GetTilesInTileSet(branchCapTileSet)); } foreach (TileSet tileSet2 in dungeonArchetype.TileSets) { list.AddRange(GetTilesInTileSet(tileSet2)); } } } foreach (Tile item in new List(list)) { if ((Object)(object)item == (Object)null) { list.Remove(item); } } return list; } public static List GetTilesInTileSet(TileSet tileSet) { List list = new List(); if (tileSet.TileWeights != null && tileSet.TileWeights.Weights != null) { foreach (GameObjectChance weight in tileSet.TileWeights.Weights) { Tile[] componentsInChildren = weight.Value.GetComponentsInChildren(); foreach (Tile item in componentsInChildren) { list.Add(item); } } } return list; } public static List GetRandomMapObjects(this DungeonFlow dungeonFlow) { List list = new List(); foreach (Tile tile in dungeonFlow.GetTiles()) { RandomMapObject[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (RandomMapObject item in componentsInChildren) { list.Add(item); } } return list; } public static List GetSpawnSyncedObjects(this DungeonFlow dungeonFlow) { List list = new List(); foreach (Tile tile in dungeonFlow.GetTiles()) { Doorway[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (Doorway val in componentsInChildren) { foreach (GameObjectWeight connectorPrefabWeight in val.ConnectorPrefabWeights) { SpawnSyncedObject[] componentsInChildren2 = connectorPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item in componentsInChildren2) { list.Add(item); } } foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights) { SpawnSyncedObject[] componentsInChildren3 = blockerPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item2 in componentsInChildren3) { list.Add(item2); } } } SpawnSyncedObject[] componentsInChildren4 = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item3 in componentsInChildren4) { list.Add(item3); } } return list; } 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; } CompatibleNoun val = new CompatibleNoun(); val.noun = newNoun; val.result = newResult; terminalKeyword.compatibleNouns = CollectionExtensions.AddItem((IEnumerable)terminalKeyword.compatibleNouns, val).ToArray(); } public static void AddCompatibleNoun(this TerminalNode terminalNode, TerminalKeyword newNoun, TerminalNode newResult) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (terminalNode.terminalOptions == null) { terminalNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; } CompatibleNoun val = new CompatibleNoun(); val.noun = newNoun; val.result = 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 string Sanitized(this string currentString) { return new string(currentString.SkipToLetters().RemoveWhitespace().ToLowerInvariant()); } public static string RemoveWhitespace(this string input) { return new string((from c in input.ToCharArray() where !char.IsWhiteSpace(c) select c).ToArray()); } public static string SkipToLetters(this string input) { return new string(input.SkipWhile((char c) => !char.IsLetter(c)).ToArray()); } public static string StripSpecialCharacters(this string input) { string text = string.Empty; for (int i = 0; i < input.Length; i++) { char c = input[i]; if ((!".,?!@#$%^&*()_+-=';:'\"".ToCharArray().Contains(c) && char.IsLetterOrDigit(c)) || c.ToString() == " ") { text += c; } } return text; } public static List GetDungeonFlows(this RoundManager roundManager) { return roundManager.dungeonFlowTypes.Select((IndoorMapType i) => i.dungeonFlow).ToList(); } } internal static class Patches { private class DoorwayPairComparer : IComparer { public int Compare(DoorwayPair x, DoorwayPair y) { int num = ((DoorwayPair)(ref y)).TileWeight.CompareTo(((DoorwayPair)(ref x)).TileWeight); if (num == 0) { return ((DoorwayPair)(ref y)).DoorwayWeight.CompareTo(((DoorwayPair)(ref x)).DoorwayWeight); } return num; } } internal const int harmonyPriority = 200; internal static string delayedSceneLoadingName = string.Empty; internal static List allSceneNamesCalledToLoad = new List(); public static bool hasInitiallyChangedLevel; internal static bool ranLethalLevelLoaderTerminalEvent; private static List tempoarySpawnableMapObjectList = new List(); internal static GameObject previousHit; internal static FootstepSurface previouslyAssignedFootstepSurface; 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); } if (AssetBundleLoader.noBundlesFound) { AssetBundleLoader.CurrentLoadingStatus = AssetBundleLoader.LoadingStatus.Complete; AssetBundleLoader.OnBundlesFinishedLoadingInvoke(); } 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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); if (true) { 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 (AssetBundleLoader.CurrentLoadingStatus == AssetBundleLoader.LoadingStatus.Loading) { DebugHelper.LogWarning("SceneManager has attempted to load " + sceneName + " Scene before AssetBundles have finished loading. Pausing request until LethalLeveLoader is ready to proceed.", DebugType.User); delayedSceneLoadingName = sceneName; AssetBundleLoader.onBundlesFinishedLoading -= LoadMainMenu; AssetBundleLoader.onBundlesFinishedLoading += 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; } [HarmonyPriority(200)] [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPrefix] internal static void GameNetworkManagerStart_Prefix(GameNetworkManager __instance) { if (Plugin.IsSetupComplete) { return; } LethalLevelLoaderNetworkManager.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().DontDestroyWithOwner = true; val.GetComponent().SceneMigrationSynchronization = true; val.GetComponent().DestroyWithScene = false; Object.DontDestroyOnLoad((Object)(object)val); LethalLevelLoaderNetworkManager.networkingManagerPrefab = val; LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val); AssetBundleLoader.NetworkRegisterCustomContent(((Component)__instance).GetComponent()); LethalLevelLoaderNetworkManager.RegisterPrefabs(((Component)__instance).GetComponent()); } [HarmonyPriority(200)] [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPostfix] internal static void GameNetworkManagerSaveGameValues_Postfix(GameNetworkManager __instance) { if (__instance.isHostingGame && StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.isChallengeFile) { SaveManager.SaveGameValues(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] internal static void StartOfRoundAwake_Prefix(StartOfRound __instance) { Plugin.OnBeforeSetupInvoke(); StartOfRound = __instance; RoundManager = Object.FindFirstObjectByType(); Terminal = Object.FindFirstObjectByType(); TimeOfDay = Object.FindFirstObjectByType(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += EventPatches.OnSceneLoaded; if (!Plugin.IsSetupComplete) { StartOfRound.allItemsList.itemsList.RemoveAt(2); DebugStopwatch.StartStopWatch("Scrape Vanilla Content"); ContentExtractor.TryScrapeVanillaItems(StartOfRound); ContentExtractor.TryScrapeVanillaContent(StartOfRound, RoundManager); ContentExtractor.ObtainSpecialItemReferences(); } if (((Component)GameNetworkManager.Instance).GetComponent().IsServer) { Object.Instantiate(LethalLevelLoaderNetworkManager.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; } if (!Plugin.IsSetupComplete) { TerminalManager.CacheTerminalReferences(); LevelManager.InitalizeShipAnimatorOverrideController(); DungeonLoader.defaultKeyPrefab = RoundManager.keyPrefab; LevelLoader.defaultQuicksandPrefab = RoundManager.quicksandPrefab; DebugStopwatch.StartStopWatch("Create Vanilla ExtendedContent"); AssetBundleLoader.CreateVanillaExtendedDungeonFlows(); AssetBundleLoader.CreateVanillaExtendedLevels(StartOfRound); AssetBundleLoader.CreateVanillaExtendedItems(); AssetBundleLoader.CreateVanillaExtendedEnemyTypes(); DebugStopwatch.StartStopWatch("Initalize Custom ExtendedContent"); AssetBundleLoader.InitializeBundles(); 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(); 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 Basegame Lists"); LevelManager.PatchVanillaLevelLists(); DungeonManager.PatchVanillaDungeonLists(); EnemyManager.UpdateEnemyIDs(); foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { TerminalManager.CreateEnemyTypeTerminalData(customExtendedEnemyType); } EnemyManager.AddCustomEnemyTypesToTestAllEnemiesLevel(); DebugStopwatch.StartStopWatch("ExtendedItem Injection"); ItemManager.RefreshDynamicItemRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("ExtendedEnemyType Injection"); EnemyManager.RefreshDynamicEnemyTypeRarityOnAllExtendedLevels(); DebugStopwatch.StartStopWatch("Create ExtendedLevelGroups & Filter Assets"); TerminalManager.CreateExtendedLevelGroups(); if (!Plugin.IsSetupComplete) { TerminalManager.CreateMoonsFilterTerminalAssets(); CompatibleNoun[] compatibleNouns = TerminalManager.routeKeyword.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns) { TerminalManager.AddTerminalNodeEventListener(val2.result, TerminalManager.OnBeforeRouteNodeLoaded, TerminalManager.LoadNodeActionType.Before); } TerminalManager.CreateTerminalDataForAllExtendedStoryLogs(); TerminalManager.AddTerminalNodeEventListener(TerminalManager.moonsKeyword.specialKeywordResult, TerminalManager.RefreshMoonsCataloguePage, TerminalManager.LoadNodeActionType.After); } DebugStopwatch.StartStopWatch("Initalize Save"); if (LethalLevelLoaderNetworkManager.networkManager.IsServer) { SaveManager.InitializeSave(); } DebugStopwatch.StopStopWatch("Initalize Save"); if (!Plugin.IsSetupComplete) { AssetBundleLoader.CreateVanillaExtendedWeatherEffects(StartOfRound, TimeOfDay); WeatherManager.PopulateVanillaExtendedWeatherEffectsDictionary(); WeatherManager.PopulateExtendedLevelEnabledExtendedWeatherEffects(); Plugin.CompleteSetup(); StartOfRound.SetPlanetsWeather(0); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")] [HarmonyPrefix] 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; } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] [HarmonyTranspiler] internal static IEnumerable StartOfRoundOnPlayerConnectedClientRpc_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(StartOfRound), "SetPlanetsWeather", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostWeatherSelection", (Type[])null, (Type[])null))).Advance(-1) .SetInstruction(new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)) .Advance(-1) .SetOpcodeAndAdvance(OpCodes.Nop); return val.InstructionEnumeration(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")] [HarmonyTranspiler] internal static IEnumerable TimeOfDayOnDayChanged_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(StartOfRound), "SetPlanetsWeather", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostWeatherSelection", (Type[])null, (Type[])null))).Advance(-1) .SetInstruction(new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)) .Advance(-1) .SetOpcodeAndAdvance(OpCodes.Nop); return val.InstructionEnumeration(); } private static void InjectHostWeatherSelection(bool requestWeathers) { if (requestWeathers) { LethalLevelLoaderNetworkManager.Instance.GetUpdatedLevelCurrentWeatherServerRpc(); } else if (LethalLevelLoaderNetworkManager.networkManager.IsServer) { StartOfRound.SetPlanetsWeather(0); LethalLevelLoaderNetworkManager.Instance.GetUpdatedLevelCurrentWeather(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPrefix] 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; } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPostfix] public static void StartOfRoundChangeLevel_Postfix(int levelID) { if (LethalLevelLoaderNetworkManager.networkManager.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 = RoundManager.currentLevel.PlanetName; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")] [HarmonyPrefix] internal static void StartOfRoundLoadShipGrabbableItems_Prefix() { SaveManager.LoadShipGrabbableItems(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "ParseWord")] [HarmonyPostfix] 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; } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "RunTerminalEvents")] [HarmonyPrefix] internal static bool TerminalRunTerminalEvents_Prefix(Terminal __instance, TerminalNode node) { return TerminalManager.OnBeforeLoadNewNode(ref node); } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "LoadNewNode")] [HarmonyPrefix] internal static bool TerminalLoadNewNode_Prefix(Terminal __instance, ref TerminalNode node) { Terminal.screenText.textComponent.fontSize = TerminalManager.defaultTerminalFontSize; return TerminalManager.OnBeforeLoadNewNode(ref node); } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "LoadNewNode")] [HarmonyPostfix] internal static void TerminalLoadNewNode_Postfix(Terminal __instance, ref TerminalNode node) { TerminalManager.OnLoadNewNode(ref node); } internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //IL_002f: 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) if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLevelLoaded) { Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.SelectableLevel.sceneName); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { LevelLoader.UpdateStoryLogs(LevelManager.CurrentExtendedLevel, val); ContentRestorer.RestoreAudioAssetReferencesInParent(val); } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyPrefix] internal static void StartOfRoundStartGame_Prefix() { if (!LethalLevelLoaderNetworkManager.networkManager.IsServer) { return; } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if ((Object)(object)currentExtendedLevel == (Object)null) { return; } currentExtendedLevel.SelectableLevel.sceneName = string.Empty; RoundManager.InitializeRandomNumberGenerators(); int num = 1; foreach (StringWithRarity sceneSelection in LevelManager.CurrentExtendedLevel.SceneSelections) { DebugHelper.Log("Scene Selection #" + num + " \"" + sceneSelection.Name + "\" (" + sceneSelection.Rarity + ")", DebugType.Developer); num++; } List list = LevelManager.CurrentExtendedLevel.SceneSelections.Select((StringWithRarity s) => s.Rarity).ToList(); int randomWeightedIndex = RoundManager.GetRandomWeightedIndex(list.ToArray(), RoundManager.LevelRandom); currentExtendedLevel.SelectableLevel.sceneName = LevelManager.CurrentExtendedLevel.SceneSelections[randomWeightedIndex].Name; DebugHelper.Log("Selected SceneName: " + currentExtendedLevel.SelectableLevel.sceneName + " For ExtendedLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName, DebugType.Developer); } [HarmonyPriority(200)] [HarmonyPatch(typeof(DungeonGenerator), "Generate")] [HarmonyPrefix] internal static void DungeonGeneratorGenerate_Prefix(DungeonGenerator __instance) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DungeonLoader.PrepareDungeon(); } LevelManager.LogDayHistory(); if ((Object)(object)RoundManager.dungeonGenerator.Generator.DungeonFlow == (Object)null) { DebugHelper.LogError("Critical Failure! DungeonGenerator DungeonFlow Is Null!", DebugType.User); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "Generator_OnGenerationStatusChanged")] [HarmonyPrefix] internal static bool OnGenerationStatusChanged_Prefix(RoundManager __instance, GenerationStatus status) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if ((int)status == 6 && !__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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(RoundManager), "GenerateNewFloor", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostDungeonFlowSelection", (Type[])null, (Type[])null))).Advance(-1) .SetInstruction(new CodeInstruction(OpCodes.Nop, (object)null)); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] [HarmonyTranspiler] public static IEnumerable GenerateNewFloorTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func)((CodeInstruction instructions) => CodeInstructionExtensions.Calls(instructions, AccessTools.Method(typeof(RuntimeDungeon), "Generate", (Type[])null, (Type[])null)))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Patches), "InjectHostDungeonSizeSelection", (Type[])null, (Type[])null))).Advance(-1) .SetInstruction(new CodeInstruction(OpCodes.Nop, (object)null)); return val.InstructionEnumeration(); } public static void InjectHostDungeonSizeSelection(RoundManager roundManager) { roundManager.dungeonGenerator.Generate(); } internal static void InjectHostDungeonFlowSelection() { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DungeonLoader.SelectDungeon(); } else { RoundManager.GenerateNewFloor(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SetLockedDoors")] [HarmonyPrefix] internal static void RoundManagerSetLockedDoors_Prefix() { RoundManager.keyPrefab = DungeonManager.CurrentExtendedDungeonFlow.OverrideKeyPrefab; } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnOutsideHazards")] [HarmonyPrefix] internal static void RoundManagerSpawnOutsideHazards_Prefix() { RoundManager.quicksandPrefab = LevelManager.CurrentExtendedLevel.OverrideQuicksandPrefab; } [HarmonyPriority(200)] [HarmonyPatch(typeof(StoryLog), "Start")] [HarmonyPrefix] internal static void StoryLogStart_Prefix(StoryLog __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) 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; } } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPrefix] internal static void RoundManagerSpawnMapObjects_Prefix() { List list = new List(LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects); foreach (SpawnableMapObject spawnableMapObject in DungeonManager.CurrentExtendedDungeonFlow.SpawnableMapObjects) { list.Add(spawnableMapObject); tempoarySpawnableMapObjectList.Add(spawnableMapObject); } LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects = list.ToArray(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPostfix] internal static void RoundManagerSpawnMapObjects_Postfix() { List list = new List(LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects); foreach (SpawnableMapObject tempoarySpawnableMapObject in tempoarySpawnableMapObjectList) { list.Remove(tempoarySpawnableMapObject); } LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects = list.ToArray(); tempoarySpawnableMapObjectList.Clear(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(PlayerControllerB), "GetCurrentMaterialStandingOn")] [HarmonyPrefix] internal static bool PlayerControllerBGetCurrentMaterialStandingOn_Prefix(PlayerControllerB __instance) { return true; } [HarmonyPriority(200)] [HarmonyPatch(typeof(PlayerControllerB), "GetCurrentMaterialStandingOn")] [HarmonyPostfix] internal static void PlayerControllerBGetCurrentMaterialStandingOn_Postfix(PlayerControllerB __instance) { } [HarmonyPriority(200)] [HarmonyPatch(typeof(DoorwayPairFinder), "GetDoorwayPairs")] [HarmonyPrefix] public static bool GetDoorwayPairsPatch(ref DoorwayPairFinder __instance, int? maxCount, ref Queue __result) { //IL_0068: 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) __instance.tileOrder = __instance.CalculateOrderedListOfTiles(); IEnumerable enumerable = ((__instance.PreviousTile == null) ? __instance.GetPotentialDoorwayPairsForFirstTile() : __instance.GetPotentialDoorwayPairsForNonFirstTile()); int num = enumerable.Count(); if (maxCount.HasValue) { num = Mathf.Min(num, maxCount.Value); } __result = new Queue(num); IEnumerable enumerable2 = OrderDoorwayPairs(enumerable, num); foreach (DoorwayPair item in enumerable2) { __result.Enqueue(item); } return false; } private static IEnumerable OrderDoorwayPairs(IEnumerable list, int num) { return list.OrderBy((DoorwayPair x) => x, new DoorwayPairComparer()).Take(num); } } internal class SafetyPatches { internal const int harmonyPriority = 250; private static List tempoarySpawnableMapObjectList = new List(); [HarmonyPriority(250)] [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPrefix] internal static void StartOfRoundChangeLevel_Prefix(ref int levelID) { } [HarmonyPriority(250)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPrefix] internal static bool RoundManagerSpawnMapObjects_Prefix() { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_01f8: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown if (GameObject.FindGameObjectsWithTag("MapPropsContainer") == null) { DebugHelper.LogError("ExtendedLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " Is Missing A \"MapPropsContainer\" Tagged GameObject. \nPreventing Spawning Of Interior RandomMapObjects To Prevent Gamebreaking Error!", DebugType.User); return false; } RandomMapObject[] array = Object.FindObjectsOfType(); if (array.Length == 0) { DebugHelper.LogError("ExtendedDungeonFlow: " + DungeonManager.CurrentExtendedDungeonFlow.DungeonName + " Spawned 0 RandomMapObjects. \nPreventing Spawning Of Interior RandomMapObjects To Prevent Gamebreaking Error!", DebugType.User); return false; } List list = new List(LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects); List list2 = new List(); RandomMapObject[] array2 = array; foreach (RandomMapObject val in array2) { foreach (GameObject spawnablePrefab in val.spawnablePrefabs) { if ((Object)(object)spawnablePrefab != (Object)null && !list2.Contains(spawnablePrefab)) { list2.Add(spawnablePrefab); } } } List list3 = new List(list2); SpawnableMapObject[] spawnableMapObjects = LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects; foreach (SpawnableMapObject val2 in spawnableMapObjects) { if ((Object)(object)val2.prefabToSpawn != (Object)null && list3.Contains(val2.prefabToSpawn)) { list3.Remove(val2.prefabToSpawn); } } foreach (GameObject item in list3) { DebugHelper.Log("ExtendedDungeonFlow: " + DungeonManager.CurrentExtendedDungeonFlow.DungeonName + " Spawned RandomMapObject Prefab: " + ((Object)item).name + " That Was Not Found In Current ExtendedLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + ". Temporarily Injecting RandomMapObject Into Level!", DebugType.Developer); SpawnableMapObject val3 = new SpawnableMapObject(); AnimationCurve numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0f), new Keyframe(0f, 0f) }); val3.prefabToSpawn = item; val3.numberToSpawn = numberToSpawn; list.Add(val3); tempoarySpawnableMapObjectList.Add(val3); } LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects = list.ToArray(); return true; } [HarmonyPriority(250)] [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] [HarmonyPostfix] internal static void RoundManagerSpawnMapObjects_Postfix() { List list = new List(LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects); foreach (SpawnableMapObject tempoarySpawnableMapObject in tempoarySpawnableMapObjectList) { list.Remove(tempoarySpawnableMapObject); } LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableMapObjects = list.ToArray(); tempoarySpawnableMapObjectList.Clear(); } [HarmonyPriority(250)] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPrefix] internal static bool RoundManagerSpawnScrapInLevel_Prefix() { List list = new List(); foreach (SpawnableItemWithRarity item in LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableScrap) { if ((Object)(object)item.spawnableItem == (Object)null || item.rarity == 0) { list.Add(item); } } if (list.Count != 0) { DebugHelper.LogError("Removed: " + list.Count + " SpawnableItemWithRarities From CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " Due To Invalid Properties To Prevent Errors.", DebugType.User); } foreach (SpawnableItemWithRarity item2 in list) { LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableScrap.Remove(item2); } if (LevelManager.CurrentExtendedLevel.SelectableLevel.spawnableScrap.Count == 0) { DebugHelper.LogError("Current ExtendedLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " Requested 0 SpawnableScrap, Returning Early To Prevent Errors", DebugType.User); return false; } return true; } [HarmonyPriority(250)] [HarmonyPatch(typeof(TimeOfDay), "SetWeatherBasedOnVariables")] [HarmonyPrefix] internal static void TimeOfDaySetWeatherBasedOnVariables_Prefix(TimeOfDay __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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 Safetey!", 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 Safetey!", DebugType.User); __instance.currentWeatherVariable = 3f; __instance.currentWeatherVariable2 = 10f; } } } [HarmonyPriority(250)] [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(250)] [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; } } 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 } 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 bool allDungeonFlowsRequireMatching = false; public static int moonsCatalogueSplitCount = 3; 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 { internal static GameObject defaultKeyPrefab; internal static void SelectDungeon() { Patches.RoundManager.dungeonGenerator.Generator.DungeonFlow = null; if (((NetworkBehaviour)LethalLevelLoaderNetworkManager.Instance).IsServer) { LethalLevelLoaderNetworkManager.Instance.GetRandomExtendedDungeonFlow(); } } internal static void PrepareDungeon() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator generator = Patches.RoundManager.dungeonGenerator.Generator; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; PatchFireEscapes(generator, currentExtendedLevel, SceneManager.GetSceneByName(currentExtendedLevel.SelectableLevel.sceneName)); PatchDynamicGlobalProps(generator, currentExtendedDungeonFlow); } public static float GetClampedDungeonSize() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; float num = CalculateDungeonMutliplier(LevelManager.CurrentExtendedLevel, DungeonManager.CurrentExtendedDungeonFlow); if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled) { if (num > currentExtendedDungeonFlow.DynamicDungeonSizeMinMax.y) { num = Mathf.Lerp(num, currentExtendedDungeonFlow.DynamicDungeonSizeMinMax.y, currentExtendedDungeonFlow.DynamicDungeonSizeLerpRate); } else if (num < currentExtendedDungeonFlow.DynamicDungeonSizeMinMax.x) { num = Mathf.Lerp(num, currentExtendedDungeonFlow.DynamicDungeonSizeMinMax.x, currentExtendedDungeonFlow.DynamicDungeonSizeLerpRate); } DebugHelper.Log("Current ExtendedLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " ExtendedLevel DungeonSize Is: " + LevelManager.CurrentExtendedLevel.SelectableLevel.factorySizeMultiplier + " | Overrriding 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 CalculateDungeonMutliplier(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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown string text = "Fire Exit Patch Report, Details Below;\n\n"; if (!DungeonManager.TryGetExtendedDungeonFlow(dungeonGenerator.DungeonFlow, out var returnExtendedDungeonFlow)) { return; } List list = (from o in GetEntranceTeleports(scene) orderby o.entranceId select o).ToList(); foreach (EntranceTeleport item in list) { item.entranceId = list.IndexOf(item); item.dungeonFlowId = returnExtendedDungeonFlow.DungeonID; } 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 + ") (Dungeon ID: " + list[0].dungeonFlowId + ")\n"; foreach (EntranceTeleport item2 in list) { if (item2.entranceId != 0) { text = text + "Alternate Entrance: " + ((Object)((Component)item2).gameObject).name + " (Entrance ID: " + item2.entranceId + ") (Dungeon ID: " + item2.dungeonFlowId + ")\n"; } } foreach (GlobalPropSettings globalProp in dungeonGenerator.DungeonFlow.GlobalProps) { if (globalProp.ID == 1231) { text = text + "Found Fire Escape GlobalProp: (ID: 1231), Modifying Spawnrate 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 class LevelLoader { internal static List customLevelMeshCollidersList = new List(); internal static AnimatorOverrideController shipAnimatorOverrideController; internal static AnimationClip defaultShipFlyToMoonClip; internal static AnimationClip defaultShipFlyFromMoonClip; internal static GameObject defaultQuicksandPrefab; internal static async void EnableMeshColliders() { List instansiatedCustomLevelMeshColliders = new List(); int counter = 0; MeshCollider[] array = Object.FindObjectsOfType(); foreach (MeshCollider meshCollider in array) { if (((Object)((Component)meshCollider).gameObject).name.Contains(" (LLL Tracked)")) { instansiatedCustomLevelMeshColliders.Add(meshCollider); } } Task[] meshColliderEnableTasks = new Task[instansiatedCustomLevelMeshColliders.Count]; foreach (MeshCollider meshCollider2 in instansiatedCustomLevelMeshColliders) { meshColliderEnableTasks[counter] = EnableMeshCollider(meshCollider2); counter++; } await Task.WhenAll(meshColliderEnableTasks); } 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 UpdateStoryLogs(ExtendedLevel extendedLevel, GameObject sceneRootObject) { } internal static void RefreshShipAnimatorClips(ExtendedLevel extendedLevel) { DebugHelper.Log("Refreshing Ship Animator Clips!", DebugType.Developer); shipAnimatorOverrideController["HangarShipLandB"] = extendedLevel.ShipFlyToMoonClip; shipAnimatorOverrideController["ShipLeave"] = extendedLevel.ShipFlyFromMoonClip; } } 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { customExtendedDungeonFlow.DungeonID = Patches.RoundManager.dungeonFlowTypes.Length; IndoorMapType val = new IndoorMapType(); val.dungeonFlow = customExtendedDungeonFlow.DungeonFlow; val.MapTileSize = customExtendedDungeonFlow.MapTileSize; 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.Remove(text.LastIndexOf(", ")); 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.Remove(text.LastIndexOf(", ")); 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.Remove(text.LastIndexOf(", ")); DebugHelper.Log(text + "\n", DebugType.User); } DebugStopwatch.StopStopWatch("Get Valid ExtendedDungeonFlows"); return list; } internal static void RefreshDungeonFlowIDs() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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 item in list) { IndoorMapType val = new IndoorMapType(); val.dungeonFlow = item; val.MapTileSize = 1f; list2.Add(val); } 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, bool debugResults = false) { foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { string empty = string.Empty; SpawnableEnemyWithRarity val = null; SpawnableEnemyWithRarity val2 = null; SpawnableEnemyWithRarity val3 = null; foreach (SpawnableEnemyWithRarity enemy in extendedLevel.SelectableLevel.Enemies) { if ((Object)(object)enemy.enemyType == (Object)(object)customExtendedEnemyType) { val = enemy; } } foreach (SpawnableEnemyWithRarity outsideEnemy in extendedLevel.SelectableLevel.OutsideEnemies) { if ((Object)(object)outsideEnemy.enemyType == (Object)(object)customExtendedEnemyType) { val2 = outsideEnemy; } } foreach (SpawnableEnemyWithRarity daytimeEnemy in extendedLevel.SelectableLevel.DaytimeEnemies) { if ((Object)(object)daytimeEnemy.enemyType == (Object)(object)customExtendedEnemyType) { val3 = daytimeEnemy; } } int dynamicRarity = customExtendedEnemyType.InsideLevelMatchingProperties.GetDynamicRarity(extendedLevel); int dynamicRarity2 = customExtendedEnemyType.OutsideLevelMatchingProperties.GetDynamicRarity(extendedLevel); int dynamicRarity3 = customExtendedEnemyType.DaytimeLevelMatchingProperties.GetDynamicRarity(extendedLevel); if (dynamicRarity2 > 0) { DebugHelper.Log("Custom ExtendedEnemyType: " + customExtendedEnemyType.EnemyDisplayName + " Has: " + dynamicRarity2 + " OutsideLevelRarity On Moon: " + extendedLevel.NumberlessPlanetName, DebugType.Developer); } if (dynamicRarity3 > 0) { DebugHelper.Log("Custom ExtendedEnemyType: " + customExtendedEnemyType.EnemyDisplayName + " Has: " + dynamicRarity3 + " DaytimeLevelRarity On Moon: " + extendedLevel.NumberlessPlanetName, DebugType.Developer); } if (!TryInjectEnemyIntoPool(extendedLevel.SelectableLevel.Enemies, customExtendedEnemyType, dynamicRarity, out var spawnableEnemyWithRarity)) { extendedLevel.SelectableLevel.Enemies.Remove(spawnableEnemyWithRarity); } if (!TryInjectEnemyIntoPool(extendedLevel.SelectableLevel.OutsideEnemies, customExtendedEnemyType, dynamicRarity2, out var spawnableEnemyWithRarity2)) { extendedLevel.SelectableLevel.OutsideEnemies.Remove(spawnableEnemyWithRarity2); } if (!TryInjectEnemyIntoPool(extendedLevel.SelectableLevel.DaytimeEnemies, customExtendedEnemyType, dynamicRarity3, out var spawnableEnemyWithRarity3)) { extendedLevel.SelectableLevel.DaytimeEnemies.Remove(spawnableEnemyWithRarity3); } } } internal static bool TryInjectEnemyIntoPool(List enemyPool, ExtendedEnemyType extendedEnemy, int newRarity, out SpawnableEnemyWithRarity spawnableEnemyWithRarity) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown spawnableEnemyWithRarity = null; foreach (SpawnableEnemyWithRarity item in enemyPool) { if ((Object)(object)item.enemyType == (Object)(object)extendedEnemy.EnemyType) { spawnableEnemyWithRarity = item; } } if (spawnableEnemyWithRarity != null) { if (newRarity > 0) { spawnableEnemyWithRarity.rarity = newRarity; } } else { SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity(); val.enemyType = extendedEnemy.EnemyType; val.rarity = newRarity; spawnableEnemyWithRarity = val; enemyPool.Add(val); } if (spawnableEnemyWithRarity.rarity == 0) { return false; } return true; } 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown QuickMenuManager val = Object.FindAnyObjectByType(); if (!((Object)(object)val != (Object)null)) { return; } foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { SpawnableEnemyWithRarity val2 = new SpawnableEnemyWithRarity(); val2.enemyType = customExtendedEnemyType.EnemyType; val2.rarity = 300; val.testAllEnemiesLevel.Enemies.Add(val2); val.testAllEnemiesLevel.OutsideEnemies.Add(val2); val.testAllEnemiesLevel.DaytimeEnemies.Add(val2); } } } internal struct EnemyData { public EnemyAI enemyAI; public GameObject gamePrefab; public GameObject networkPrefab; } public static class ItemManager { public static void RefreshDynamicItemRarityOnAllExtendedLevels() { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { InjectCustomItemsIntoLevelViaDynamicRarity(extendedLevel); } } public static void InjectCustomItemsIntoLevelViaDynamicRarity(ExtendedLevel extendedLevel, bool debugResults = false) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown foreach (ExtendedItem customExtendedItem in PatchedContent.CustomExtendedItems) { if (!customExtendedItem.Item.isScrap) { continue; } string empty = string.Empty; SpawnableItemWithRarity val = null; foreach (SpawnableItemWithRarity item in extendedLevel.SelectableLevel.spawnableScrap) { if ((Object)(object)item.spawnableItem == (Object)(object)customExtendedItem) { val = item; } } int num = 0; int dynamicRarity = customExtendedItem.LevelMatchingProperties.GetDynamicRarity(extendedLevel); num = dynamicRarity; if (val != null) { if (num > 0) { val.rarity = num; empty = "Updated Rarity Of: " + customExtendedItem.Item.itemName + " To: " + num + " On Planet: " + extendedLevel.NumberlessPlanetName; } else { extendedLevel.SelectableLevel.spawnableScrap.Remove(val); empty = "Removed " + customExtendedItem.Item.itemName + " From Planet: " + extendedLevel.NumberlessPlanetName; } } else { SpawnableItemWithRarity val2 = new SpawnableItemWithRarity(); val2.spawnableItem = customExtendedItem.Item; val2.rarity = num; extendedLevel.SelectableLevel.spawnableScrap.Add(val2); empty = "Added " + customExtendedItem.Item.itemName + " To Planet: " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + num; } if (debugResults) { DebugHelper.Log(empty, 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_002a: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (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(); ((Object)((Component)this).gameObject).name = "LethalLevelLoaderNetworkManager"; Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } [ServerRpc(RequireOwnership = false)] public void GetUpdatedLevelCurrentWeatherServerRpc() { GetUpdatedLevelCurrentWeather(); } public void GetUpdatedLevelCurrentWeather() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) 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()); } [ClientRpc] public void SetUpdatedLevelCurrentWeatherClientRpc(StringContainer[] levelNames, LevelWeatherType[] weatherTypes) { SetUpdatedLevelCurrentWeather(levelNames, weatherTypes); } public void SetUpdatedLevelCurrentWeather(StringContainer[] levelNames, LevelWeatherType[] weatherTypes) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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) 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; } } } public void GetRandomExtendedDungeonFlow() { 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("No ExtendedDungeonFlow's could be found! This should only happen if the Host's requireMatchesOnAllDungeonFlows is set to true!", DebugType.User); 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()); } [ClientRpc] public void SetRandomExtendedDungeonFlowClientRpc(StringContainer[] dungeonFlowNames, int[] rarities) { SetRandomExtendedDungeonFlow(dungeonFlowNames, rarities); } public void SetRandomExtendedDungeonFlow(StringContainer[] dungeonFlowNames, int[] rarities) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown 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 val = new IntWithRarity(); val.Add(dictionary[dungeonFlowNames[i].SomeText], rarities[i]); list.Add(val); } list2 = new List(LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes.ToList()); LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes = list.ToArray(); Patches.RoundManager.GenerateNewFloor(); LevelManager.CurrentExtendedLevel.SelectableLevel.dungeonFlowTypes = list2.ToArray(); } [ServerRpc] public void GetDungeonFlowSizeServerRpc() { SetDungeonFlowSizeClientRpc(DungeonLoader.GetClampedDungeonSize()); } [ClientRpc] public void SetDungeonFlowSizeClientRpc(float hostSize) { Patches.RoundManager.dungeonGenerator.Generator.LengthMultiplier = hostSize; Patches.RoundManager.dungeonGenerator.Generate(); } 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); } } 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; } } 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 List cachedFootstepSurfaceTagsList = new List(); public static List cachedExtendedFootstepSurfaceMaterialsList = new List(); public static List cachedExtendedFootstepSurfaceGameObjectsList = new List(); public static Dictionary cachedFootstepSurfacesDictionary = new Dictionary(); 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 = PatchedContent.SeletectableLevels.ToArray(); TerminalManager.Terminal.moonsCatalogueList = PatchedContent.MoonsCatalogue.ToArray(); } internal static void InitalizeShipAnimatorOverrideController() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown Animator shipAnimator = Patches.StartOfRound.shipAnimator; List list = new List(); Transform[] componentsInChildren = ((Component)shipAnimator).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!list.Contains(((Component)val).gameObject)) { list.Add(((Component)val).gameObject); } } AnimatorOverrideController val2 = (LevelLoader.shipAnimatorOverrideController = new AnimatorOverrideController(shipAnimator.runtimeAnimatorController)); LevelLoader.defaultShipFlyToMoonClip = val2["HangarShipLandB"]; LevelLoader.defaultShipFlyFromMoonClip = val2["ShipLeave"]; AnimationClip[] animationClips = shipAnimator.runtimeAnimatorController.animationClips; foreach (AnimationClip val3 in animationClips) { val2[((Object)val3).name] = val3; } shipAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)val2; } 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; } switch (levelType) { case ContentType.Any: list = PatchedContent.ExtendedLevels; break; case ContentType.Custom: list = PatchedContent.CustomExtendedLevels; break; case ContentType.Vanilla: list = PatchedContent.VanillaExtendedLevels; break; } foreach (ExtendedLevel item in list) { if ((Object)(object)item.SelectableLevel == (Object)(object)selectableLevel) { returnExtendedLevel = item; } } 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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.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 ExtendedDungeonFlow extendedDungeonFlow; public LevelWeatherType weatherEffect; } internal static class SaveManager { public static LLLSaveFile currentSaveFile; public static bool parityCheck; internal static void InitializeSave() { if (LethalLevelLoaderNetworkManager.networkManager.IsServer) { 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; return; } DebugHelper.Log("Vanilla Save File Mismatch, LLL Steps Taken: " + currentSaveFile.parityStepsTaken + ", Vanilla Steps Taken: " + num, DebugType.Developer); currentSaveFile.Reset(); currentSaveFile.parityStepsTaken = num; parityCheck = false; } } internal static void SaveGameValues() { currentSaveFile.itemSaveData = GetAllItemsListItemDataDict(); currentSaveFile.parityStepsTaken = Patches.StartOfRound.gameStats.allStepsTaken; ((ModDataContainer)currentSaveFile).Save(); } 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_004b: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_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) 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 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 string currentTagFilter; internal 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.FindObjectOfType(); } 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.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); } internal static bool SetSimulationResultsText(ref TerminalNode currentNode, ref TerminalNode node) { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (node.terminalEvent.StripSpecialCharacters().Sanitized().ToLower() .Contains(extendedLevel.NumberlessPlanetName.StripSpecialCharacters().Sanitized().ToLower())) { 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.screenText.textComponent.fontSize = defaultTerminalFontSize - 0.1f * (float)(currentMoonsCataloguePage.ExtendedLevels.Count - OriginalContent.MoonsCatalogue.Count); Terminal.currentText = Terminal.TextPostProcess("\n\n\n" + GetMoonsTerminalText(), Terminal.currentNode); 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; 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 (!string.IsNullOrEmpty(text2)) { text = text + text2 + "\n"; } } if (text.Contains("\n")) { text.Replace(text.Substring(text.LastIndexOf("\n")), ""); } 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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 + " // Chance: " + GetSimulationDataText(item2.rarity, num) + "\n"; } return text; } public static string GetSimulationDataText(int rarity, int totalRarity) { string result = string.Empty; if (Settings.levelSimulateInfoType == SimulateInfoType.Percentage) { result = ((float)rarity / (float)totalRarity * 100f).ToString("F2") + "%"; } else if (Settings.levelSimulateInfoType == SimulateInfoType.Rarity) { result = rarity + " // " + totalRarity; } return result; } 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]); 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.StripSpecialCharacters().Sanitized() + "Keyword"; val.word = extendedLevel.NumberlessPlanetName.StripSpecialCharacters().Sanitized(); val.defaultVerb = routeKeyword; TerminalNode val2; if ((Object)(object)extendedLevel.RouteNode != (Object)null) { val2 = extendedLevel.RouteNode; } else { val2 = CreateNewTerminalNode(); ((Object)val2).name = extendedLevel.NumberlessPlanetName.StripSpecialCharacters().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.StripSpecialCharacters().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.StripSpecialCharacters().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; 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.StripSpecialCharacters().Sanitized() + "Keyword"; val.word = extendedItem.Item.itemName.StripSpecialCharacters().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.StripSpecialCharacters().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.buyItemIndex = buyItemIndex; val2.isConfirmationNode = true; val2.itemCost = extendedItem.Item.creditsWorth; val2.overrideOptions = true; } TerminalNode val3; if ((Object)(object)extendedItem.BuyConfirmNode != (Object)null) { val3 = extendedItem.BuyConfirmNode; } else { val3 = CreateNewTerminalNode(); ((Object)val3).name = extendedItem.Item.itemName.StripSpecialCharacters().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.buyItemIndex = buyItemIndex; val3.isConfirmationNode = false; } 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.StripSpecialCharacters().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(); TerminalNode val2 = CreateNewTerminalNode(); ((Object)val2).name = ((Object)extendedEnemyType).name + "BestiaryNode"; val2.displayText = extendedEnemyType.InfoNodeDescription; val2.creatureFileID = extendedEnemyType.EnemyID; val2.creatureName = extendedEnemyType.EnemyDisplayName; 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 RegisterStoryLog(TerminalKeyword terminalKeyword, TerminalNode terminalNode) { } internal static void CreateMoonsFilterTerminalAssets() { 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); } foreach (TerminalNode item2 in CreateTerminalEventNodes("sort", new List { SortInfoType.Price, SortInfoType.Difficulty, SortInfoType.None })) { AddTerminalNodeEventListener(item2, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } foreach (TerminalNode item3 in CreateTerminalEventNodes("filter", new List { FilterInfoType.Price, FilterInfoType.Weather, FilterInfoType.None })) { AddTerminalNodeEventListener(item3, TryRefreshMoonsCataloguePage, LoadNodeActionType.Before); } 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.NumberlessPlanetName.StripSpecialCharacters().Sanitized()); } foreach (TerminalNode item6 in CreateTerminalEventNodes("simulate", list4)) { AddTerminalNodeEventListener(item6, SetSimulationResultsText, LoadNodeActionType.Before); } } 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; } } internal class WeatherManager { public static ExtendedWeatherEffect CurrentExtendedWeatherEffect; public static Dictionary vanillaExtendedWeatherEffectsDictionary = new Dictionary(); public static void PopulateVanillaExtendedWeatherEffectsDictionary() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) foreach (ExtendedWeatherEffect item in PatchedContent.VanillaExtendedWeatherEffects.OrderBy((ExtendedWeatherEffect w) => (int)w.BaseWeatherType)) { vanillaExtendedWeatherEffectsDictionary.Add(item.BaseWeatherType, item); } } public static void PopulateExtendedLevelEnabledExtendedWeatherEffects() { //IL_004c: 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); } } } public static void SetExtendedLevelsWeather(int connectedPlayersOnServer) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_004e: 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) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_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) foreach (ExtendedWeatherEffect extendedWeatherEffect in PatchedContent.ExtendedWeatherEffects) { if (extendedWeatherEffect.contentType == ContentType.Vanilla && extendedWeatherEffect.BaseWeatherType == levelWeatherType) { return extendedWeatherEffect; } } return null; } } [BepInPlugin("imabatby.lethallevelloader", "LethalLevelLoader", "1.2.0.1")] [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.2.0.1"; 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 event Action onBeforeSetup; public static event Action onSetupComplete; private void Awake() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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)); NetworkScenePatcher.Patch(); NetcodePatch(); GameObject val = new GameObject("LethalLevelLoader AssetBundleLoader"); val.AddComponent().LoadBundles(); ((Object)val).hideFlags = (HideFlags)61; AssetBundleLoader.onBundlesFinishedLoading += AssetBundleLoader.LoadContentInBundles; ConfigLoader.BindGeneralConfigs(); } internal static void OnBeforeSetupInvoke() { Plugin.onBeforeSetup?.Invoke(); } internal static void CompleteSetup() { DebugHelper.Log("LethalLevelLoader Has Finished Initializing.", DebugType.User); IsSetupComplete = true; Plugin.onSetupComplete?.Invoke(); } private void NetcodePatch() { try { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } catch { DebugHelper.Log("NetcodePatcher did a big fucksie wuckise!", DebugType.Developer); } } } 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 Dictionary>> onLethalBundleLoadedRequestDictionary = new Dictionary>>(); internal static Dictionary>> onExtendedModLoadedRequestDictionary = new Dictionary>>(); internal static TextMeshProUGUI loadingBundlesHeaderText; internal static bool noBundlesFound = false; internal static bool hasRequestedToLoadMainMenu; 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) { foreach (ExtendedDungeonFlow extendedDungeonFlow in extendedMod.ExtendedDungeonFlows) { 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); } } } internal void LoadBundles() { DebugHelper.Log("Finding LethalBundles!", DebugType.User); CurrentLoadingStatus = LoadingStatus.Loading; Instance = this; onBundlesFinishedLoading += OnBundlesFinishedLoading; PatchedContent.VanillaMod = ExtendedMod.Create("LethalCompany", "Zeekerss"); lethalLibFolder = lethalLibFile.Parent; pluginsFolder = lethalLibFile.Parent.Parent; int num = 0; string[] files = Directory.GetFiles(pluginsFolder.FullName, "*.lethalbundle", SearchOption.AllDirectories); foreach (string text in files) { num++; FileInfo fileInfo = new FileInfo(text); assetBundles.Add(fileInfo.Name, null); UpdateLoadingBundlesHeaderText(null); ((MonoBehaviour)this).StartCoroutine(Instance.LoadBundle(text, fileInfo.Name)); } if (num == 0) { DebugHelper.Log("No Bundles Found!", DebugType.User); noBundlesFound = true; CurrentLoadingStatus = LoadingStatus.Complete; AssetBundleLoader.onBundlesFinishedLoading?.Invoke(); } } internal static void OnBundlesFinishedLoadingInvoke() { AssetBundleLoader.onBundlesFinishedLoading?.Invoke(); } private IEnumerator LoadBundle(string bundleFile, string fileName) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); AssetBundleCreateRequest newBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, bundleFile)); yield return newBundleRequest; AssetBundle newBundle = newBundleRequest.assetBundle; if ((Object)(object)newBundle != (Object)null) { assetBundles[fileName] = newBundle; if (!newBundle.isStreamedSceneAssetBundle) { ExtendedMod[] extendedMods = newBundle.LoadAllAssets(); if (extendedMods != null && extendedMods.Length != 0 && (Object)(object)extendedMods[0] != (Object)null) { RegisterExtendedMod(extendedMods[0]); } else { DebugHelper.Log("No ExtendedMod Found In Bundle: " + ((Object)newBundle).name + ". Forcefully Loading ExtendedContent!", DebugType.User); ExtendedContent[] array = newBundle.LoadAllAssets(); foreach (ExtendedContent extendedContent in array) { RegisterNewExtendedContent(extendedContent, ((Object)newBundle).name); } } } AssetBundleLoader.onBundleFinishedLoading?.Invoke(newBundle); if (HaveBundlesFinishedLoading) { CurrentLoadingStatus = LoadingStatus.Complete; AssetBundleLoader.onBundlesFinishedLoading?.Invoke(); } stopWatch.Stop(); try { assetBundleLoadTimes.Add(bundleFile.Substring(bundleFile.LastIndexOf("\\") + 1), $"{stopWatch.Elapsed.TotalSeconds:0.##} Seconds. ({stopWatch.ElapsedMilliseconds}ms)"); yield break; } catch (Exception ex) { DebugHelper.LogError(ex, DebugType.User); yield break; } } DebugHelper.LogError("Failed To Load Bundle: " + bundleFile, DebugType.User); assetBundles.Remove(fileName); } internal static void RegisterExtendedMod(ExtendedMod extendedMod) { DebugHelper.Log("Found ExtendedMod: " + ((Object)extendedMod).name, DebugType.User); extendedMod.ModNameAliases.Add(extendedMod.ModName); ExtendedMod extendedMod2 = null; foreach (ExtendedMod value in obtainedExtendedModsDictionary.Values) { if (extendedMod.ModMergeSetting == ModMergeSetting.MatchingModName && value.ModMergeSetting == ModMergeSetting.MatchingModName) { if (value.ModName == extendedMod.ModName) { extendedMod2 = value; } } else if (extendedMod.ModMergeSetting == ModMergeSetting.MatchingAuthorName && value.ModMergeSetting == ModMergeSetting.MatchingAuthorName && value.AuthorName == extendedMod.AuthorName) { extendedMod2 = value; } } 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; } } obtainedExtendedModsDictionary.Add(extendedMod.AuthorName, 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 RegisterNewExtendedMod() { } public static void AddOnLethalBundleLoadedListener(Action invokedFunction, string lethalBundleFileName) { if (invokedFunction != null && !string.IsNullOrEmpty(lethalBundleFileName)) { if (!onLethalBundleLoadedRequestDictionary.ContainsKey(lethalBundleFileName)) { onLethalBundleLoadedRequestDictionary.Add(lethalBundleFileName, new List> { invokedFunction }); } else { onLethalBundleLoadedRequestDictionary[lethalBundleFileName].Add(invokedFunction); } } } public static void AddOnExtendedModLoadedListener(Action invokedFunction, string extendedModAuthorName = null, string extendedModModName = null) { if (invokedFunction != null && !string.IsNullOrEmpty(extendedModAuthorName)) { if (!onExtendedModLoadedRequestDictionary.ContainsKey(extendedModAuthorName)) { onExtendedModLoadedRequestDictionary.Add(extendedModAuthorName, new List> { invokedFunction }); } else { onExtendedModLoadedRequestDictionary[extendedModAuthorName].Add(invokedFunction); } } if (invokedFunction != null && !string.IsNullOrEmpty(extendedModModName)) { if (!onExtendedModLoadedRequestDictionary.ContainsKey(extendedModModName)) { onExtendedModLoadedRequestDictionary.Add(extendedModModName, new List> { invokedFunction }); } else { onExtendedModLoadedRequestDictionary[extendedModModName].Add(invokedFunction); } } } internal static void OnBundlesFinishedLoading() { foreach (KeyValuePair item in obtainedExtendedModsDictionary) { PatchedContent.ExtendedMods.Add(item.Value); DebugHelper.DebugExtendedMod(item.Value); } PatchedContent.ExtendedMods = new List(PatchedContent.ExtendedMods.OrderBy((ExtendedMod o) => o.ModName).ToList()); foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods) { extendedMod.SortRegisteredContent(); } foreach (KeyValuePair>> item2 in onLethalBundleLoadedRequestDictionary) { if (!assetBundles.ContainsKey(item2.Key)) { continue; } foreach (Action item3 in item2.Value) { item3(assetBundles[item2.Key]); } } foreach (KeyValuePair>> item4 in onExtendedModLoadedRequestDictionary) { foreach (ExtendedMod extendedMod2 in PatchedContent.ExtendedMods) { if (!extendedMod2.ModNameAliases.Contains(item4.Key)) { continue; } foreach (Action item5 in item4.Value) { item5(extendedMod2); } } } } internal static void RegisterNewExtendedContent(ExtendedContent extendedContent, string fallbackName) { if ((Object)(object)extendedContent == (Object)null) { DebugHelper.LogError("Failed to register new ExtendedContent as it was null!", DebugType.User); return; } ExtendedMod extendedMod = null; if (extendedContent is ExtendedLevel extendedLevel) { if (string.IsNullOrEmpty(extendedLevel.contentSourceName)) { extendedLevel.contentSourceName = fallbackName; } extendedMod = GetOrCreateExtendedMod(extendedLevel.contentSourceName); } else if (extendedContent is ExtendedDungeonFlow extendedDungeonFlow) { if (string.IsNullOrEmpty(extendedDungeonFlow.contentSourceName)) { extendedDungeonFlow.contentSourceName = fallbackName; } extendedMod = GetOrCreateExtendedMod(extendedDungeonFlow.contentSourceName); } else if (extendedContent is ExtendedItem extendedItem) { extendedMod = GetOrCreateExtendedMod(extendedItem.Item.itemName.RemoveWhitespace()); } else if (extendedContent is ExtendedEnemyType extendedEnemyType) { extendedMod = GetOrCreateExtendedMod(extendedEnemyType.EnemyType.enemyName.RemoveWhitespace()); } else { ExtendedWeatherEffect extendedWeatherEffect = extendedContent as ExtendedWeatherEffect; if (extendedWeatherEffect == null) { } } if (!((Object)(object)extendedMod != (Object)null)) { return; } try { extendedMod.RegisterExtendedContent(extendedContent); } catch (Exception exception) { DebugHelper.LogError(exception, DebugType.User); } } internal static ExtendedMod GetOrCreateExtendedMod(string contentSourceName) { if (obtainedExtendedModsDictionary.TryGetValue(contentSourceName, out var value)) { return value; } DebugHelper.Log("Creating New ExtendedMod: " + contentSourceName, DebugType.Developer); ExtendedMod extendedMod = ExtendedMod.Create(contentSourceName); obtainedExtendedModsDictionary.Add(contentSourceName, extendedMod); return extendedMod; } internal static void LoadContentInBundles() { List list = obtainedExtendedModsDictionary.Values.OrderBy((ExtendedMod o) => o.ModName).ToList(); List list2 = new List(); foreach (ExtendedMod item in list) { foreach (ExtendedLevel item2 in new List(item.ExtendedLevels)) { if (!list2.Contains(item2.SelectableLevel.sceneName)) { list2.Add(item2.SelectableLevel.sceneName); } foreach (StringWithRarity sceneSelection in item2.SceneSelections) { if (!list2.Contains(sceneSelection.Name)) { list2.Add(sceneSelection.Name); } } } } foreach (ExtendedMod item3 in list) { foreach (ExtendedLevel item4 in new List(item3.ExtendedLevels)) { bool flag = false; string text = "Could Not Find Scene File For ExtendedLevel: " + ((Object)item4.SelectableLevel).name + ", Unregistering Early. \nSelectable Scene Name Is: " + item4.SelectableLevel.sceneName + ". Scenes Found In Bundles Are: \n"; foreach (KeyValuePair assetBundle in assetBundles) { if (!((Object)(object)assetBundle.Value != (Object)null) || !assetBundle.Value.isStreamedSceneAssetBundle) { continue; } string[] allScenePaths = assetBundle.Value.GetAllScenePaths(); foreach (string scenePath in allScenePaths) { text = text + ", " + GetSceneName(scenePath); if (list2.Contains(GetSceneName(scenePath))) { flag = true; NetworkScenePatcher.AddScenePath(GetSceneName(scenePath)); if (!PatchedContent.AllLevelSceneNames.Contains(GetSceneName(scenePath))) { PatchedContent.AllLevelSceneNames.Add(GetSceneName(scenePath)); } } } } if (!flag) { DebugHelper.LogError(text, DebugType.User); item3.UnregisterExtendedContent(item4); } } } foreach (string allLevelSceneName in PatchedContent.AllLevelSceneNames) { DebugHelper.Log("Loaded SceneName: " + allLevelSceneName, DebugType.Developer); } } 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); } } } 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(StartOfRound startOfRound, TimeOfDay timeOfDay) { //IL_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0050: 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_0038: Unknown result type (might be due to invalid IL or missing references) foreach (LevelWeatherType value in Enum.GetValues(typeof(LevelWeatherType))) { LevelWeatherType val = value; ExtendedWeatherEffect item = (((int)val == -1) ? ExtendedWeatherEffect.Create(val, null, null, ((object)(LevelWeatherType)(ref val)).ToString(), ContentType.Vanilla) : ExtendedWeatherEffect.Create(val, timeOfDay.effects[val], ((object)(LevelWeatherType)(ref val)).ToString(), 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]; } 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 NetworkRegisterDungeonContent(ExtendedDungeonFlow extendedDungeonFlow, NetworkManager networkManager) { if ((Object)(object)extendedDungeonFlow == (Object)null) { DebugHelper.LogError("Cannot Network Register Null ExtendedDungeonFlow!", DebugType.User); return; } if ((Object)(object)extendedDungeonFlow.DungeonFlow == (Object)null) { DebugHelper.LogError("Cannot Network Register ExtendedDungeonFlow: " + ((Object)extendedDungeonFlow).name + " Due To Null DungeonFlow!", DebugType.User); return; } List list = new List(); List list2 = new List(); List list3 = new List(); foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs) { list3.Add(prefab.Prefab); } List spawnSyncedObjects = extendedDungeonFlow.DungeonFlow.GetSpawnSyncedObjects(); foreach (GameObject item in list3) { foreach (SpawnSyncedObject item2 in new List(spawnSyncedObjects)) { if ((Object)(object)item2.spawnPrefab != (Object)null && ((Object)item2.spawnPrefab).name == ((Object)item).name) { item2.spawnPrefab = item; spawnSyncedObjects.Remove(item2); if (!list.Contains(((Object)item).name)) { list.Add(((Object)item).name); } } } } foreach (SpawnSyncedObject item3 in spawnSyncedObjects) { if ((Object)(object)item3 != (Object)null && (Object)(object)item3.spawnPrefab != (Object)null) { if ((Object)(object)item3.spawnPrefab.GetComponent() == (Object)null) { item3.spawnPrefab.AddComponent(); } LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(item3.spawnPrefab); if (!list2.Contains(((Object)item3.spawnPrefab).name)) { list2.Add(((Object)item3.spawnPrefab).name); } } } string text = "Automatically Restored The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (string item4 in list) { text = text + item4 + ", "; } DebugHelper.Log(text, DebugType.Developer); text = "Automatically Registered The Following SpawnablePrefab's In " + ((Object)extendedDungeonFlow.DungeonFlow).name + ": "; foreach (string item5 in list2) { text = text + item5 + ", "; } DebugHelper.Log(text, DebugType.Developer); } 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_003b: 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_0067: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) 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 string indexSeperator = ","; public const string keyPairSeperator = ":"; public const string vectorSeperator = "-"; public const string illegalCharacters = ".,?!@#$%^&*()_+-=';:'\""; public static List ConvertToStringWithRarityList(string newInputString, Vector2 clampRarity) { //IL_004d: 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_0060: 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) List list = new List(); List list2 = SplitStringsByIndexSeperator(newInputString); foreach (string item2 in list2) { (string, string) tuple = SplitStringByKeyPairSeperator(item2); string item = tuple.Item1; int num = 0; if (int.TryParse(tuple.Item2, out var result)) { num = result; } if (clampRarity != Vector2.zero) { Math.Clamp(num, Mathf.RoundToInt(clampRarity.x), Mathf.RoundToInt(clampRarity.y)); } list.Add(new StringWithRarity(item, num)); } return list; } public static List ConvertToVector2WithRarityList(string newInputString, Vector2 clampRarity) { //IL_0093: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = SplitStringsByIndexSeperator(newInputString); foreach (string item in list2) { (string, string) tuple = SplitStringByKeyPairSeperator(item); (string, string) tuple2 = SplitStringByVectorSeperator(tuple.Item1); float num = 0f; float num2 = 0f; int num3 = 0; if (float.TryParse(tuple2.Item1, out var result)) { num = result; } if (float.TryParse(tuple2.Item2, out var result2)) { num2 = result2; } if (int.TryParse(tuple.Item2, out var result3)) { num3 = result3; } if (clampRarity != Vector2.zero) { Math.Clamp(num3, Mathf.RoundToInt(clampRarity.x), Mathf.RoundToInt(clampRarity.y)); } list.Add(new Vector2WithRarity(new Vector2(num, num2), num3)); } return list; } public static List ConvertToSpawnableEnemyWithRarityList(string newInputString, Vector2 clampRarity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown List list = ConvertToStringWithRarityList(newInputString, clampRarity); List list2 = new List(); foreach (EnemyType item in OriginalContent.Enemies.Concat(PatchedContent.Enemies)) { foreach (StringWithRarity item2 in new List(list)) { if (item.enemyName.ToLower().Contains(item2.Name.ToLower())) { SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity(); val.enemyType = item; val.rarity = item2.Rarity; list2.Add(val); list.Remove(item2); } } } foreach (EnemyType item3 in OriginalContent.Enemies.Concat(PatchedContent.Enemies)) { foreach (StringWithRarity item4 in new List(list)) { if ((Object)(object)item3.enemyPrefab != (Object)null) { ScanNodeProperties componentInChildren = item3.enemyPrefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && (componentInChildren.headerText.ToLower().Contains(item4.Name.ToLower()) || item4.Name.ToLower().Contains(componentInChildren.headerText.ToLower()))) { SpawnableEnemyWithRarity val2 = new SpawnableEnemyWithRarity(); val2.enemyType = item3; val2.rarity = item4.Rarity; list2.Add(val2); list.Remove(item4); } } } } return list2; } public static List ConvertToSpawnableItemWithRarityList(string newInputString, Vector2 clampRarity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown List list = ConvertToStringWithRarityList(newInputString, clampRarity); List list2 = new List(); foreach (Item item in OriginalContent.Items.Concat(PatchedContent.Items)) { foreach (StringWithRarity item2 in new List(list)) { if (SanitizeString(item.itemName).Contains(SanitizeString(item2.Name)) || SanitizeString(item2.Name).Contains(SanitizeString(item.itemName))) { DebugHelper.Log("Vanilla Item Name: " + SanitizeString(item.itemName) + " , Parsed Item Name: " + SanitizeString(item2.Name), DebugType.Developer); SpawnableItemWithRarity val = new SpawnableItemWithRarity(); val.spawnableItem = item; val.rarity = item2.Rarity; list2.Add(val); list.Remove(item2); } } } return list2; } public static string SpawnableEnemiesWithRaritiesToString(List spawnableEnemiesList) { string text = string.Empty; foreach (SpawnableEnemyWithRarity spawnableEnemies in spawnableEnemiesList) { text = text + spawnableEnemies.enemyType.enemyName + ":" + spawnableEnemies.rarity + ","; } if (text.Contains(",") && text.LastIndexOf(",") == text.Length - 1) { text = text.Remove(text.LastIndexOf(","), 1); } if (text == string.Empty) { text = "Default Values Were Empty"; } return text; } public static string SpawnableItemsWithRaritiesToString(List spawnableItemsList) { string text = string.Empty; foreach (SpawnableItemWithRarity spawnableItems in spawnableItemsList) { text = text + spawnableItems.spawnableItem.itemName + ":" + spawnableItems.rarity + ","; } if (text.Contains(",") && text.LastIndexOf(",") == text.Length - 1) { text = text.Remove(text.LastIndexOf(","), 1); } if (text == string.Empty) { text = "Default Values Were Empty"; } return text; } public static string StringWithRaritiesToString(List names) { string text = string.Empty; foreach (StringWithRarity name in names) { text = text + name.Name + ":" + name.Rarity + ","; } if (text.Contains(",") && text.LastIndexOf(",") == text.Length - 1) { text = text.Remove(text.LastIndexOf(","), 1); } if (text == string.Empty) { text = "Default Values Were Empty"; } return text; } public static string Vector2WithRaritiesToString(List values) { string text = string.Empty; foreach (Vector2WithRarity value in values) { text = text + value.Min + "-" + value.Max + ":" + value.Rarity + ","; } if (text.Contains(",") && text.LastIndexOf(",") == text.Length - 1) { text = text.Remove(text.LastIndexOf(","), 1); } if (text == string.Empty) { text = "Default Values Were Empty"; } return text; } public static List SplitStringsByIndexSeperator(string newInputString) { List list = new List(); string text = newInputString; while (text.Contains(",")) { string text2 = text.Substring(text.IndexOf(",")); list.Add(text.Replace(text2, "")); if (text2.Contains(",")) { text = text2.Substring(text2.IndexOf(",") + 1); } } list.Add(text); return list; } public static (string, string) SplitStringByKeyPairSeperator(string inputString) { return SplitStringByCharacter(inputString, ":"); } public static (string, string) SplitStringByVectorSeperator(string inputString) { return SplitStringByCharacter(inputString, "-"); } public static (string, string) SplitStringByCharacter(string newInputString, string splitValue) { if (!newInputString.Contains(splitValue)) { return (newInputString, string.Empty); } string empty = string.Empty; string empty2 = string.Empty; empty = newInputString.Replace(newInputString.Substring(newInputString.IndexOf(splitValue)), ""); empty2 = newInputString.Substring(newInputString.IndexOf(splitValue) + 1); return (empty, empty2); } public static string SanitizeString(string inputString) { return inputString.SkipToLetters().RemoveWhitespace().ToLower(); } } 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 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.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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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); } SpawnableMapObject[] spawnableMapObjects = selectableLevel.spawnableMapObjects; foreach (SpawnableMapObject val in spawnableMapObjects) { ContentExtractor.TryAddReference(OriginalContent.SpawnableMapObjects, val.prefabToSpawn); } 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.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower() || extendedItem.Item.itemName.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower()) { 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.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower() || extendedLevel.NumberlessPlanetName.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower()) { 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.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower() || extendedEnemyType.EnemyType.enemyName.RemoveWhitespace().StripSpecialCharacters().ToLower() == item.Key.RemoveWhitespace().StripSpecialCharacters().ToLower()) { 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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.SpawnableMapObjects.Count + " / 2) 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_0025: 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()) { 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()) { 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_001a: 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_001a: 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_001a: 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 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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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); } 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) { 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); } } } 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); } if (debugLevelsString.Contains(", ") && debugLevelsString.LastIndexOf(", ") == debugLevelsString.Length - 2) { debugLevelsString = debugLevelsString.Remove(debugLevelsString.LastIndexOf(", "), 2); } if (debugDungeonsString.Contains(", ") && debugDungeonsString.LastIndexOf(", ") == debugDungeonsString.Length - 2) { debugDungeonsString = debugDungeonsString.Remove(debugDungeonsString.LastIndexOf(", "), 2); } debugLevelsString = string.Empty; debugDungeonsString = string.Empty; } internal static void BindGeneralConfigs() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "LethalLevelLoader.cfg"), 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 requireMatchesOnAllDungeonFlows; 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); requireMatchesOnAllDungeonFlows = BindValue("Require Matches On All Possible DungeonFlows", "By default any Dungeons requested by the loading level will skip the matching process and be in the possible selection pool, Set this to false to disable this feature", 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.allDungeonFlowsRequireMatching = requireMatchesOnAllDungeonFlows.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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: 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 Below.", 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)); 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)); 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)); 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)); if (!enableContentConfiguration.Value) { return; } DebugHelper.Log(extendedDungeonFlow.DungeonName + " enabled content configeration", DebugType.Developer); extendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled = enableContentConfiguration.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_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0409: 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 Below.", 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)); 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)); 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)); 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)); 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(); } } } 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 = 0; 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 List objectsToDestroy = new List(); 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; } foreach (Tile tile in extendedDungeonFlow.DungeonFlow.GetTiles()) { RandomScrapSpawn[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (RandomScrapSpawn val in componentsInChildren) { foreach (ItemGroup itemGroup in OriginalContent.ItemGroups) { if ((Object)(object)itemGroup != (Object)null && (Object)(object)val.spawnableItems != (Object)null && ((Object)val.spawnableItems).name != null && ((Object)itemGroup).name != null && ((Object)val.spawnableItems).name == ((Object)itemGroup).name) { val.spawnableItems = RestoreAsset((Object)(object)val.spawnableItems, itemGroup, debugAction: false, destroyOnReplace: false); } } } } foreach (RandomMapObject randomMapObject in extendedDungeonFlow.DungeonFlow.GetRandomMapObjects()) { foreach (GameObject item in new List(randomMapObject.spawnablePrefabs)) { foreach (GameObject spawnableMapObject in OriginalContent.SpawnableMapObjects) { if ((Object)(object)spawnableMapObject != (Object)null && (Object)(object)item != (Object)null && ((Object)item).name != null && ((Object)spawnableMapObject).name != null && ((Object)item).name == ((Object)spawnableMapObject).name) { randomMapObject.spawnablePrefabs[randomMapObject.spawnablePrefabs.IndexOf(item)] = RestoreAsset((Object)(object)randomMapObject.spawnablePrefabs[randomMapObject.spawnablePrefabs.IndexOf(item)], spawnableMapObject, debugAction: false, destroyOnReplace: false); } } } } foreach (Tile tile2 in extendedDungeonFlow.DungeonFlow.GetTiles()) { RestoreAudioAssetReferencesInParent(((Component)tile2).gameObject); } } internal static void RestoreVanillaLevelAssetReferences(ExtendedLevel extendedLevel) { foreach (SpawnableItemWithRarity item in new List(extendedLevel.SelectableLevel.spawnableScrap)) { if ((Object)(object)item.spawnableItem == (Object)null) { extendedLevel.SelectableLevel.spawnableScrap.Remove(item); continue; } foreach (Item item2 in OriginalContent.Items) { if (((Object)item.spawnableItem).name == ((Object)item2).name) { item.spawnableItem = RestoreAsset((Object)(object)item.spawnableItem, item2); } } } foreach (EnemyType enemy in OriginalContent.Enemies) { foreach (SpawnableEnemyWithRarity item3 in extendedLevel.SelectableLevel.Enemies.Concat(extendedLevel.SelectableLevel.DaytimeEnemies).Concat(extendedLevel.SelectableLevel.OutsideEnemies)) { if ((Object)(object)item3.enemyType != (Object)null && item3.enemyType.enemyName == enemy.enemyName) { item3.enemyType = RestoreAsset((Object)(object)item3.enemyType, enemy); } } } SpawnableMapObject[] spawnableMapObjects = extendedLevel.SelectableLevel.spawnableMapObjects; foreach (SpawnableMapObject val in spawnableMapObjects) { foreach (GameObject spawnableMapObject in OriginalContent.SpawnableMapObjects) { if ((Object)(object)val.prefabToSpawn != (Object)null && ((Object)val.prefabToSpawn).name == ((Object)spawnableMapObject).name) { val.prefabToSpawn = RestoreAsset((Object)(object)val.prefabToSpawn, spawnableMapObject); } } } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = extendedLevel.SelectableLevel.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val2 in spawnableOutsideObjects) { foreach (SpawnableOutsideObject spawnableOutsideObject in OriginalContent.SpawnableOutsideObjects) { if ((Object)(object)val2.spawnableObject != (Object)null && ((Object)val2.spawnableObject).name == ((Object)spawnableOutsideObject).name) { val2.spawnableObject = RestoreAsset((Object)(object)val2.spawnableObject, spawnableOutsideObject); } } } 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 = RestoreAsset((Object)(object)extendedLevel.SelectableLevel.levelAmbienceClips, levelAmbienceLibrary); } } } 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)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 = RestoreAsset((Object)(object)val2.reverbPreset, reverbPreset); } } } 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 = RestoreAsset((Object)(object)audioMixer, audioMixer2, debugAction: false, destroyOnReplace: false); } } foreach (AudioMixerGroup audioMixerGroup in OriginalContent.AudioMixerGroups) { if (((Object)outputAudioMixerGroup).name == ((Object)audioMixerGroup).name) { val = 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 (debugAction) { DebugHelper.Log("Destroying: " + item.name, DebugType.Developer); } Object.DestroyImmediate(item); } objectsToDestroy.Clear(); } internal static T RestoreAsset(Object currentAsset, T newAsset, bool debugAction = false, bool destroyOnReplace = true) { if (currentAsset != (Object)null && newAsset != null) { if (debugAction && currentAsset.name != null) { DebugHelper.Log("Restoring " + ((object)currentAsset).GetType().ToString() + ": Old Asset Name: " + currentAsset.name + " , New Asset Name: ", DebugType.Developer); } if (destroyOnReplace && !objectsToDestroy.Contains(currentAsset)) { objectsToDestroy.Add(currentAsset); } } else { DebugHelper.LogWarning("Asset Restoration Failed, Null Reference Found!", DebugType.Developer); } return newAsset; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }