Decompiled source of LethalLevelLoaderFixedV50 v1.1.1
LethalLevelLoader.dll
Decompiled 8 months ago
The result has been truncated due to the large size, download it to view full contents!
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.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.NetcodePatcher; using LethalLevelLoader.Tools; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: 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: 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+000b8e4347b8a76a05c261af0d6b9205e60e1e95")] [assembly: AssemblyProduct("LethalLevelLoader")] [assembly: AssemblyTitle("LethalLevelLoader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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<ILHook> ilHooks = new List<ILHook>(); private List<Hook> hooks = new List<Hook>(); public void Clear() { foreach (Hook hook in hooks) { hook.Dispose(); } hooks.Clear(); foreach (ILHook ilHook in ilHooks) { ilHook.Dispose(); } ilHooks.Clear(); } public void ILHook<T>(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<T>(methodName, parameters), to)); } public void Hook<T>(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<T>(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<T>(string name, Type[] parameters = null) { return EzGetMethod(typeof(T), name, parameters); } } public static class NetworkScenePatcher { [CompilerGenerated] private static class <>O { public static Action<Action<NetworkSceneManager>, NetworkSceneManager> <0>__GenerateScenesInBuild_Hook; public static Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string> <1>__SceneNameFromHash_Hook; public static Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, NetworkSceneManager, int, string, LoadSceneMode, bool> <2>__ValidateSceneBeforeLoading_Hook; public static Manipulator <3>__ReplaceBuildIndexByScenePath; public static Manipulator <4>__ReplaceScenePathByBuildIndex; public static Func<int, string> <5>__GetScenePathByBuildIndex; public static Func<string, int> <6>__GetBuildIndexByScenePath; } private static List<string> scenePaths = new List<string>(); private static Dictionary<string, int> scenePathToBuildIndex = new Dictionary<string, int>(); private static Dictionary<int, string> buildIndexToScenePath = new Dictionary<int, string>(); private static Dictionary<uint, string> sceneHashToScenePath = new Dictionary<uint, string>(); 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)) { Debug.LogError((object)("Can not add scene path " + scenePath + " to the network scene patcher! (already exists in scene paths list)")); } else { 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<NetworkSceneManager>("GenerateScenesInBuild", new Action<Action<NetworkSceneManager>, NetworkSceneManager>(GenerateScenesInBuild_Hook)); hooks.Hook<NetworkSceneManager>("SceneNameFromHash", new Func<Func<NetworkSceneManager, uint, string>, NetworkSceneManager, uint, string>(SceneNameFromHash_Hook)); hooks.Hook<NetworkSceneManager>("ValidateSceneBeforeLoading", new Func<Func<NetworkSceneManager, int, string, LoadSceneMode, bool>, 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<NetworkSceneManager>("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<NetworkSceneManager>("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<NetworkSceneManager>("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<int, string>(GetScenePathByBuildIndex)); while (val.TryGotoNext(new Func<Instruction, bool>[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<string, int>(GetBuildIndexByScenePath)); while (val.TryGotoNext(new Func<Instruction, bool>[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<NetworkSceneManager> 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); Debug.Log((object)("Added modded scene path: " + text)); } } private static string SceneNameFromHash_Hook(Func<NetworkSceneManager, uint, string> 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<NetworkSceneManager, int, string, LoadSceneMode, bool> orig, NetworkSceneManager self, int sceneIndex, string sceneName, LoadSceneMode loadSceneMode) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Debug.LogWarning((object)(orig(self, sceneIndex, sceneName, loadSceneMode) ? ("Validation check success for scene: " + sceneName) : ("Bypassed validation check for scene " + sceneName))); return true; } } public static class Utils { public static IndoorMapType ToIndoorMapType(this DungeonFlow value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return new IndoorMapType { dungeonFlow = value, MapTileSize = 0f }; } } namespace LethalLevelLoader { [CreateAssetMenu(menuName = "LethalLevelLoader/ExtendedDungeonFlow")] public class ExtendedDungeonFlow : ScriptableObject { [Header("Extended DungeonFlow Settings")] public string contentSourceName = string.Empty; [Space(5f)] public string dungeonDisplayName = string.Empty; [Space(5f)] public DungeonFlow dungeonFlow; [Space(5f)] public AudioClip dungeonFirstTimeAudio; [Space(10f)] [Header("Dynamic DungeonFlow Injections Settings")] public List<StringWithRarity> dynamicLevelTagsList = new List<StringWithRarity>(); [Space(5f)] public List<Vector2WithRarity> dynamicRoutePricesList = new List<Vector2WithRarity>(); [Space(5f)] public List<StringWithRarity> dynamicCurrentWeatherList = new List<StringWithRarity>(); [Space(5f)] public List<StringWithRarity> manualPlanetNameReferenceList = new List<StringWithRarity>(); [Space(5f)] public List<StringWithRarity> manualContentSourceNameReferenceList = new List<StringWithRarity>(); [Space(10f)] [Header("Dynamic Dungeon Size Multiplier Lerp Settings")] public bool enableDynamicDungeonSizeRestriction = false; public float dungeonSizeMin = 1f; public float dungeonSizeMax = 1f; [Range(0f, 1f)] public float dungeonSizeLerpPercentage = 1f; [Space(10f)] [Header("Dynamic DungeonFlow Modification Settings")] public List<GlobalPropCountOverride> globalPropCountOverridesList = new List<GlobalPropCountOverride>(); [Space(10f)] [Header("Misc. Settings")] public bool generateAutomaticConfigurationOptions = true; [Space(10f)] [Header("Experimental Settings (Currently Unused As Of LethalLevelLoader 1.1.0")] public GameObject mainEntrancePropPrefab; [Space(5f)] public GameObject fireExitPropPrefab; [Space(5f)] public Animator mainEntrancePropAnimator; [Space(5f)] public Animator fireExitPropAnimator; [HideInInspector] public ContentType dungeonType; [HideInInspector] public int dungeonID; [HideInInspector] public int dungeonDefaultRarity; [HideInInspector] public DungeonEvents dungeonEvents = new DungeonEvents(); internal static ExtendedDungeonFlow Create(DungeonFlow newDungeonFlow, AudioClip newFirstTimeDungeonAudio, string contentSourceName) { ExtendedDungeonFlow extendedDungeonFlow = ScriptableObject.CreateInstance<ExtendedDungeonFlow>(); extendedDungeonFlow.dungeonFlow = newDungeonFlow; extendedDungeonFlow.dungeonFirstTimeAudio = newFirstTimeDungeonAudio; extendedDungeonFlow.contentSourceName = contentSourceName; return extendedDungeonFlow; } internal void Initialize(ContentType newDungeonType) { dungeonType = newDungeonType; GetDungeonFlowID(); if (dungeonDisplayName == null || dungeonDisplayName == string.Empty) { dungeonDisplayName = ((Object)dungeonFlow).name; } ((Object)this).name = ((Object)dungeonFlow).name.Replace("Flow", "") + "ExtendedDungeonFlow"; if ((Object)(object)dungeonFirstTimeAudio == (Object)null) { DebugHelper.LogWarning("Custom Dungeon: " + dungeonDisplayName + " Is Missing A DungeonFirstTimeAudio Reference! Assigning Facility Audio To Prevent Errors."); dungeonFirstTimeAudio = RoundManager.Instance.firstTimeDungeonAudios[0]; } } private void GetDungeonFlowID() { if (dungeonType == ContentType.Custom) { dungeonID = PatchedContent.ExtendedDungeonFlows.Count; } if (dungeonType == ContentType.Vanilla) { dungeonID = RoundManager.Instance.dungeonFlowTypes.ToList().FindIndex((IndoorMapType el) => (Object)(object)el.dungeonFlow == (Object)(object)dungeonFlow); } } } [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; } } [Serializable] public class GlobalPropCountOverride { public int globalPropID; [Range(0f, 1f)] public float globalPropCountScaleRate = 0f; } [Serializable] public class DungeonEvents { public ExtendedEvent<RoundManager> onBeforeDungeonGenerate = new ExtendedEvent<RoundManager>(); public ExtendedEvent<List<GameObject>> onSpawnedSyncedObjects = new ExtendedEvent<List<GameObject>>(); public ExtendedEvent<List<GameObject>> onSpawnedMapObjects = new ExtendedEvent<List<GameObject>>(); public ExtendedEvent<List<GrabbableObject>> onSpawnedScrapObjects = new ExtendedEvent<List<GrabbableObject>>(); 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<bool> onPowerSwitchToggle = new ExtendedEvent<bool>(); public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>(); } [CreateAssetMenu(menuName = "LethalLevelLoader/ExtendedLevel")] public class ExtendedLevel : ScriptableObject { [Header("Extended Level Settings")] [Space(5f)] public string contentSourceName = string.Empty; [Space(5f)] public SelectableLevel selectableLevel; [Space(5f)] [SerializeField] private int routePrice = 0; [Space(5f)] public bool isHidden = false; [Space(5f)] public bool isLocked = false; [Space(5f)] public string lockedNodeText = string.Empty; [Space(10f)] public List<StoryLogData> storyLogs = new List<StoryLogData>(); [Space(10f)] [Header("Dynamic DungeonFlow Injections Settings")] [Space(5f)] public ContentType allowedDungeonContentTypes = ContentType.Any; [Space(5f)] public List<string> levelTags = new List<string>(); [HideInInspector] public ContentType levelType; [SerializeField] [TextArea] public string infoNodeDescripton = string.Empty; [HideInInspector] public TerminalNode routeNode; [HideInInspector] public TerminalNode routeConfirmNode; [HideInInspector] public TerminalNode infoNode; [Space(10f)] [Header("Misc. Settings")] [Space(5f)] public bool generateAutomaticConfigurationOptions = true; [HideInInspector] public LevelEvents levelEvents = new LevelEvents(); internal bool isLethalExpansion = false; 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!"); return routePrice; } set { routeNode.itemCost = value; routeConfirmNode.itemCost = value; routePrice = value; } } [HideInInspector] public string NumberlessPlanetName => GetNumberlessPlanetName(selectableLevel); public bool IsLoaded { 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; } } internal static ExtendedLevel Create(SelectableLevel newSelectableLevel, ContentType newContentType) { ExtendedLevel extendedLevel = ScriptableObject.CreateInstance<ExtendedLevel>(); extendedLevel.levelType = newContentType; extendedLevel.selectableLevel = newSelectableLevel; return extendedLevel; } internal void Initialize(string newContentSourceName, bool generateTerminalAssets) { if (levelType == ContentType.Vanilla && selectableLevel.levelID > 8) { DebugHelper.LogWarning("LethalExpansion SelectableLevel " + NumberlessPlanetName + " Found, Setting To LevelType: Custom."); levelType = ContentType.Custom; contentSourceName = "Lethal Expansion"; levelTags.Clear(); isLethalExpansion = true; } if (contentSourceName == string.Empty) { contentSourceName = newContentSourceName; } if (levelType == ContentType.Custom) { levelTags.Add("Custom"); } if (!isLethalExpansion) { SetLevelID(); } if (generateTerminalAssets) { TerminalManager.CreateLevelTerminalData(this, routePrice); } if (levelType == ContentType.Custom) { ((Object)this).name = NumberlessPlanetName.StripSpecialCharacters() + "ExtendedLevel"; ((Object)selectableLevel).name = NumberlessPlanetName.StripSpecialCharacters() + "Level"; } } 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 (levelType == 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; } } } } [Serializable] public class LevelEvents { public ExtendedEvent onLevelLoaded = new ExtendedEvent(); public ExtendedEvent onNighttime = new ExtendedEvent(); public ExtendedEvent<EnemyAI> onDaytimeEnemySpawn = new ExtendedEvent<EnemyAI>(); public ExtendedEvent<EnemyAI> onNighttimeEnemySpawn = new ExtendedEvent<EnemyAI>(); public ExtendedEvent<StoryLog> onStoryLogCollected = new ExtendedEvent<StoryLog>(); public ExtendedEvent<LungProp> onApparatusTaken = new ExtendedEvent<LungProp>(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerEnterDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent<(EntranceTeleport, PlayerControllerB)> onPlayerExitDungeon = new ExtendedEvent<(EntranceTeleport, PlayerControllerB)>(); public ExtendedEvent<bool> onPowerSwitchToggle = new ExtendedEvent<bool>(); } [Serializable] public class StoryLogData { public int storyLogID; public string terminalWord = string.Empty; public string storyLogTitle = string.Empty; [TextArea] public string storyLogDescription = string.Empty; [HideInInspector] internal int newStoryLogID; } public class MoonsCataloguePage { private List<ExtendedLevelGroup> extendedLevelGroups; public List<ExtendedLevelGroup> ExtendedLevelGroups => extendedLevelGroups; public List<ExtendedLevel> ExtendedLevels { get { List<ExtendedLevel> list = new List<ExtendedLevel>(); foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { list.Add(extendedLevels); } } return list; } } public MoonsCataloguePage(List<ExtendedLevelGroup> newExtendedLevelGroupList) { extendedLevelGroups = new List<ExtendedLevelGroup>(); extendedLevelGroups.Clear(); foreach (ExtendedLevelGroup newExtendedLevelGroup in newExtendedLevelGroupList) { extendedLevelGroups.Add(new ExtendedLevelGroup(newExtendedLevelGroup.extendedLevelsList)); } } public void RebuildLevelGroups(List<ExtendedLevelGroup> newExtendedLevelGroups, int splitCount) { List<ExtendedLevel> list = new List<ExtendedLevel>(); foreach (ExtendedLevelGroup extendedLevelGroup in extendedLevelGroups) { foreach (ExtendedLevel extendedLevels in extendedLevelGroup.extendedLevelsList) { list.Add(extendedLevels); } } RebuildLevelGroups(list.ToArray(), splitCount); } public void RebuildLevelGroups(List<ExtendedLevel> newExtendedLevels, int splitCount) { RebuildLevelGroups(newExtendedLevels.ToArray(), splitCount); } public void RebuildLevelGroups(IOrderedEnumerable<ExtendedLevel> orderedExtendedLevels, int splitCount) { RebuildLevelGroups(orderedExtendedLevels.ToArray(), splitCount); } public void RebuildLevelGroups(ExtendedLevel[] newExtendedLevels, int splitCount) { List<ExtendedLevelGroup> list = new List<ExtendedLevelGroup>(); int num = 0; int num2 = 0; List<ExtendedLevel> list2 = new List<ExtendedLevel>(); foreach (ExtendedLevel item in new List<ExtendedLevel>(newExtendedLevels)) { list2.Add(item); num2++; num++; if (num == splitCount || num2 == newExtendedLevels.Length) { list.Add(new ExtendedLevelGroup(list2)); list2.Clear(); num = 0; } } extendedLevelGroups = list; } public void RefreshLevelGroups(List<ExtendedLevelGroup> 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<ExtendedLevel> extendedLevelsList; public ExtendedLevelGroup(List<ExtendedLevel> newExtendedLevelsList) { extendedLevelsList = new List<ExtendedLevel>(newExtendedLevelsList); } public ExtendedLevelGroup(List<SelectableLevel> newSelectableLevelsList) { extendedLevelsList = new List<ExtendedLevel>(); foreach (SelectableLevel newSelectableLevels in newSelectableLevelsList) { extendedLevelsList.Add(LevelManager.GetExtendedLevel(newSelectableLevels)); } } } public static class PatchedContent { public static List<ExtendedLevel> ExtendedLevels { get; internal set; } = new List<ExtendedLevel>(); public static List<ExtendedLevel> VanillaExtendedLevels { get { List<ExtendedLevel> list = new List<ExtendedLevel>(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { if (extendedLevel.levelType == ContentType.Vanilla) { list.Add(extendedLevel); } } return list; } } public static List<ExtendedLevel> CustomExtendedLevels { get { List<ExtendedLevel> list = new List<ExtendedLevel>(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { if (extendedLevel.levelType == ContentType.Custom) { list.Add(extendedLevel); } } return list; } } public static List<SelectableLevel> SeletectableLevels { get { List<SelectableLevel> list = new List<SelectableLevel>(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { list.Add(extendedLevel.selectableLevel); } return list; } } public static List<SelectableLevel> MoonsCatalogue { get { List<SelectableLevel> list = new List<SelectableLevel>(); foreach (SelectableLevel item in OriginalContent.MoonsCatalogue) { list.Add(item); } foreach (ExtendedLevel extendedLevel in ExtendedLevels) { if (extendedLevel.levelType == ContentType.Custom) { list.Add(extendedLevel.selectableLevel); } } return list; } } public static List<ExtendedDungeonFlow> ExtendedDungeonFlows { get; internal set; } = new List<ExtendedDungeonFlow>(); public static List<ExtendedDungeonFlow> VanillaExtendedDungeonFlows { get { List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>(); foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { if (extendedDungeonFlow.dungeonType == ContentType.Vanilla) { list.Add(extendedDungeonFlow); } } return list; } } public static List<ExtendedDungeonFlow> CustomExtendedDungeonFlows { get { List<ExtendedDungeonFlow> list = new List<ExtendedDungeonFlow>(); foreach (ExtendedDungeonFlow extendedDungeonFlow in ExtendedDungeonFlows) { if (extendedDungeonFlow.dungeonType == ContentType.Custom) { list.Add(extendedDungeonFlow); } } return list; } } public static List<string> AllExtendedLevelTags { get { List<string> list = new List<string>(); foreach (ExtendedLevel extendedLevel in ExtendedLevels) { foreach (string levelTag in extendedLevel.levelTags) { if (!list.Contains(levelTag)) { list.Add(levelTag); } } } return list; } } public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>(); public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>(); public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>(); public static List<Item> Items { get; internal set; } = new List<Item>(); public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>(); public static void RegisterExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow) { AssetBundleLoader.obtainedExtendedDungeonFlowsList.Add(extendedDungeonFlow); } public static void RegisterExtendedLevel(ExtendedLevel extendedLevel) { AssetBundleLoader.obtainedExtendedLevelsList.Add(extendedLevel); } } public static class OriginalContent { public static List<SelectableLevel> SelectableLevels { get; internal set; } = new List<SelectableLevel>(); public static List<SelectableLevel> MoonsCatalogue { get; internal set; } = new List<SelectableLevel>(); public static List<DungeonFlow> DungeonFlows { get; internal set; } = new List<DungeonFlow>(); public static List<Item> Items { get; internal set; } = new List<Item>(); public static List<ItemGroup> ItemGroups { get; internal set; } = new List<ItemGroup>(); public static List<EnemyType> Enemies { get; internal set; } = new List<EnemyType>(); public static List<SpawnableOutsideObject> SpawnableOutsideObjects { get; internal set; } = new List<SpawnableOutsideObject>(); public static List<GameObject> SpawnableMapObjects { get; internal set; } = new List<GameObject>(); public static List<AudioMixer> AudioMixers { get; internal set; } = new List<AudioMixer>(); public static List<AudioMixerGroup> AudioMixerGroups { get; internal set; } = new List<AudioMixerGroup>(); public static List<AudioMixerSnapshot> AudioMixerSnapshots { get; internal set; } = new List<AudioMixerSnapshot>(); public static List<LevelAmbienceLibrary> LevelAmbienceLibraries { get; internal set; } = new List<LevelAmbienceLibrary>(); public static List<ReverbPreset> ReverbPresets { get; internal set; } = new List<ReverbPreset>(); public static List<TerminalKeyword> TerminalKeywords { get; internal set; } = new List<TerminalKeyword>(); public static List<TerminalNode> TerminalNodes { get; internal set; } = new List<TerminalNode>(); } internal class EventPatches { private static EnemyVent cachedSelectedVent; internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLoaded) { LevelManager.CurrentExtendedLevel.levelEvents.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); } } [HarmonyPriority(201)] [HarmonyPatch(typeof(DungeonGenerator), "Generate")] [HarmonyPrefix] internal static void DungeonGeneratorGenerate_Prefix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onBeforeDungeonGenerate.Invoke(RoundManager.Instance); } } [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); } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.levelEvents.onPowerSwitchToggle.Invoke(on); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPostfix] internal static void RoundManagerSpawnScrapInLevel_Postfix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedScrapObjects.HasListeners) { DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedScrapObjects.Invoke(Object.FindObjectsOfType<GrabbableObject>().ToList()); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "SpawnSyncedProps")] [HarmonyPostfix] internal static void RoundManagerSpawnSyncedProps_Postfix() { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedSyncedObjects.HasListeners) { DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onSpawnedSyncedObjects.Invoke(RoundManager.Instance.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, RoundManager.Instance.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<GameObject> list = new List<GameObject>(); 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); } [HarmonyPriority(200)] [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")] [HarmonyPrefix] internal static void EntranceTeleportTeleportPlayerServerRpc_Prefix(EntranceTeleport __instance) { if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (__instance.isEntranceToBuilding) { DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onPlayerEnterDungeon.Invoke((__instance, localPlayerController)); } else { DungeonManager.CurrentExtendedDungeonFlow.dungeonEvents.onPlayerExitDungeon.Invoke((__instance, localPlayerController)); } } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { PlayerControllerB localPlayerController2 = GameNetworkManager.Instance.localPlayerController; if (__instance.isEntranceToBuilding) { LevelManager.CurrentExtendedLevel.levelEvents.onPlayerEnterDungeon.Invoke((__instance, localPlayerController2)); } else { LevelManager.CurrentExtendedLevel.levelEvents.onPlayerExitDungeon.Invoke((__instance, localPlayerController2)); } } } [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); } if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LevelManager.CurrentExtendedLevel.levelEvents.onApparatusTaken.Invoke(__instance); } } } } public class ExtendedEvent<T> { 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<Tile> GetTiles(this DungeonFlow dungeonFlow) { List<Tile> list = new List<Tile>(); 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<Tile>(list)) { if ((Object)(object)item == (Object)null) { list.Remove(item); } } return list; } public static List<Tile> GetTilesInTileSet(TileSet tileSet) { List<Tile> list = new List<Tile>(); if (tileSet.TileWeights != null && tileSet.TileWeights.Weights != null) { foreach (GameObjectChance weight in tileSet.TileWeights.Weights) { Tile[] componentsInChildren = weight.Value.GetComponentsInChildren<Tile>(); foreach (Tile item in componentsInChildren) { list.Add(item); } } } return list; } public static List<RandomMapObject> GetRandomMapObjects(this DungeonFlow dungeonFlow) { List<RandomMapObject> list = new List<RandomMapObject>(); foreach (Tile tile in dungeonFlow.GetTiles()) { RandomMapObject[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<RandomMapObject>(); foreach (RandomMapObject item in componentsInChildren) { list.Add(item); } } return list; } public static List<SpawnSyncedObject> GetSpawnSyncedObjects(this DungeonFlow dungeonFlow) { List<SpawnSyncedObject> list = new List<SpawnSyncedObject>(); foreach (Tile tile in dungeonFlow.GetTiles()) { Doorway[] componentsInChildren = ((Component)tile).gameObject.GetComponentsInChildren<Doorway>(); foreach (Doorway val in componentsInChildren) { foreach (GameObjectWeight connectorPrefabWeight in val.ConnectorPrefabWeights) { SpawnSyncedObject[] componentsInChildren2 = connectorPrefabWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>(); foreach (SpawnSyncedObject item in componentsInChildren2) { list.Add(item); } } foreach (GameObjectWeight blockerPrefabWeight in val.BlockerPrefabWeights) { SpawnSyncedObject[] componentsInChildren3 = blockerPrefabWeight.GameObject.GetComponentsInChildren<SpawnSyncedObject>(); foreach (SpawnSyncedObject item2 in componentsInChildren3) { list.Add(item2); } } } SpawnSyncedObject[] componentsInChildren4 = ((Component)tile).gameObject.GetComponentsInChildren<SpawnSyncedObject>(); 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<CompatibleNoun>((IEnumerable<CompatibleNoun>)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<CompatibleNoun>((IEnumerable<CompatibleNoun>)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; } } internal static class Patches { internal const int harmonyPriority = 200; internal static string delayedSceneLoadingName = string.Empty; internal static List<string> allSceneNamesCalledToLoad = new List<string>(); [HarmonyPriority(200)] [HarmonyPatch(typeof(PreInitSceneScript), "Awake")] [HarmonyPrefix] internal static void PreInitSceneScriptAwake_Prefix(PreInitSceneScript __instance) { if (!Plugin.hasVanillaBeenPatched) { AssetBundleLoader.CreateLoadingBundlesHeaderText(__instance); AudioSource val = default(AudioSource); if (((Component)__instance).TryGetComponent<AudioSource>(ref val)) { OriginalContent.AudioMixers.Add(val.outputAudioMixerGroup.audioMixer); } AssetBundleLoader.LoadBundles(__instance); AssetBundleLoader.onBundlesFinishedLoading += AssetBundleLoader.LoadContentInBundles; } } [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<string> 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."); return false; } if (AssetBundleLoader.loadingStatus == 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."); 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."); 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.hasVanillaBeenPatched) { return; } foreach (NetworkPrefab prefab in ((Component)__instance).GetComponent<NetworkManager>().NetworkConfig.Prefabs.m_Prefabs) { if (((Object)prefab.Prefab).name.Contains("EntranceTeleport") && (Object)(object)prefab.Prefab.GetComponent<AudioSource>() != (Object)null) { OriginalContent.AudioMixers.Add(prefab.Prefab.GetComponent<AudioSource>().outputAudioMixerGroup.audioMixer); } } GameObject val = NetworkPrefabs.CreateNetworkPrefab("LethalLevelLoaderNetworkManagerTest"); val.AddComponent<LethalLevelLoaderNetworkManager>(); val.GetComponent<NetworkObject>().DontDestroyWithOwner = true; val.GetComponent<NetworkObject>().SceneMigrationSynchronization = true; val.GetComponent<NetworkObject>().DestroyWithScene = false; Object.DontDestroyOnLoad((Object)(object)val); LethalLevelLoaderNetworkManager.networkingManagerPrefab = val; AssetBundleLoader.RegisterCustomContent(((Component)__instance).GetComponent<NetworkManager>()); LethalLevelLoaderNetworkManager.RegisterPrefabs(((Component)__instance).GetComponent<NetworkManager>()); } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] internal static void StartOfRoundAwake_Prefix(StartOfRound __instance) { if (!Plugin.hasVanillaBeenPatched) { ContentExtractor.TryScrapeVanillaItems(__instance); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "Awake")] [HarmonyPostfix] internal static void RoundManagerAwake_Postfix(RoundManager __instance) { if (((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().IsServer) { LethalLevelLoaderNetworkManager component = Object.Instantiate<GameObject>(LethalLevelLoaderNetworkManager.networkingManagerPrefab).GetComponent<LethalLevelLoaderNetworkManager>(); ((Component)component).GetComponent<NetworkObject>().Spawn(false); } RoundManager.Instance.firstTimeDungeonAudios = CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)RoundManager.Instance.firstTimeDungeonAudios.ToList(), RoundManager.Instance.firstTimeDungeonAudios[0]).ToArray(); if (Plugin.hasVanillaBeenPatched) { return; } ContentExtractor.TryScrapeVanillaContent(__instance); TerminalManager.CacheTerminalReferences(); AssetBundleLoader.CreateVanillaExtendedDungeonFlows(); AssetBundleLoader.CreateVanillaExtendedLevels(StartOfRound.Instance); AssetBundleLoader.InitializeBundles(); 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.levelType.ToString() + ")\n"; } DebugHelper.Log(text); text = "LethalLevelLoader Loaded The Following ExtendedDungeonFlows:\n"; foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { text = text + (PatchedContent.ExtendedDungeonFlows.IndexOf(extendedDungeonFlow) + 1) + ". " + extendedDungeonFlow.dungeonDisplayName + " (" + ((Object)extendedDungeonFlow.dungeonFlow).name + ") (" + extendedDungeonFlow.dungeonType.ToString() + ")\n"; } DebugHelper.Log(text); } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] internal static void RoundManagerStart_Prefix() { if (!Plugin.hasVanillaBeenPatched) { foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { ContentRestorer.RestoreVanillaLevelAssetReferences(customExtendedLevel); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { ContentRestorer.RestoreVanillaDungeonAssetReferences(customExtendedDungeonFlow); } TerminalManager.CreateMoonsFilterTerminalAssets(); ConfigLoader.BindConfigs(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += EventPatches.OnSceneLoaded; } AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>(); foreach (AudioSource val in array) { val.spatialize = false; } LevelManager.ValidateLevelLists(); LevelManager.PatchVanillaLevelLists(); DungeonManager.PatchVanillaDungeonLists(); LevelManager.RefreshCustomExtendedLevelIDs(); TerminalManager.CreateExtendedLevelGroups(); if (LevelManager.invalidSaveLevelID != -1 && StartOfRound.Instance.levels.Length > LevelManager.invalidSaveLevelID) { DebugHelper.Log("Setting CurrentLevel to previously saved ID that was not loaded at the time of save loading."); DebugHelper.Log(LevelManager.invalidSaveLevelID + " / " + StartOfRound.Instance.levels.Length); StartOfRound.Instance.ChangeLevelServerRpc(LevelManager.invalidSaveLevelID, TerminalManager.Terminal.groupCredits); LevelManager.invalidSaveLevelID = -1; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPostfix] internal static void RoundManagerStart_Postfix() { if (!Plugin.hasVanillaBeenPatched) { ContentExtractor.TryScrapeCustomContent(); Plugin.hasVanillaBeenPatched = true; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(StartOfRound), "ChangeLevel")] [HarmonyPrefix] internal static void StartOfRoundChangeLevel_Prefix(ref int levelID) { if (levelID >= StartOfRound.Instance.levels.Length) { DebugHelper.LogWarning("Lethal Company attempted to load a saved current level that has not yet been loaded"); DebugHelper.LogWarning(levelID + " / " + StartOfRound.Instance.levels.Length); LevelManager.invalidSaveLevelID = levelID; levelID = 0; } } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPostfix] internal static void TerminalStart_Postfix() { LevelManager.RefreshLethalExpansionMoons(); } [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(TerminalNode node) { return TerminalManager.RunLethalLevelLoaderTerminalEvents(node); } [HarmonyPriority(200)] [HarmonyPatch(typeof(Terminal), "LoadNewNode")] [HarmonyPrefix] internal static void TerminalLoadNewNode_Prefix(Terminal __instance, ref TerminalNode node) { if ((Object)(object)node == (Object)(object)TerminalManager.moonsKeyword.specialKeywordResult) { TerminalManager.RefreshExtendedLevelGroups(); node.displayText = TerminalManager.GetMoonsTerminalText(); } else { if (!((Object)(object)__instance.currentNode == (Object)(object)TerminalManager.moonsKeyword.specialKeywordResult)) { return; } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if ((Object)(object)extendedLevel.routeNode == (Object)(object)node && extendedLevel.isLocked) { TerminalManager.SwapRouteNodeToLockedNode(extendedLevel, ref node); } } } } internal static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //IL_0050: 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) if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null && LevelManager.CurrentExtendedLevel.IsLoaded && LevelManager.CurrentExtendedLevel.levelType == ContentType.Custom && !LevelManager.CurrentExtendedLevel.isLethalExpansion) { 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(DungeonGenerator), "Generate")] [HarmonyPrefix] internal static void DungeonGeneratorGenerate_Prefix(DungeonGenerator __instance) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DungeonLoader.PrepareDungeon(); } LevelManager.LogDayHistory(); } [HarmonyPriority(200)] [HarmonyPatch(typeof(RoundManager), "Generator_OnGenerationStatusChanged")] [HarmonyPrefix] internal static bool OnGenerationStatusChanged_Prefix(RoundManager __instance, GenerationStatus status) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown DebugHelper.Log(((object)(GenerationStatus)(ref status)).ToString()); 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<CodeInstruction> GenerateNewLevelClientRpcTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown DebugHelper.Log("Transpiling GenerateNewLevelClientRpc"); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((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<CodeInstruction> GenerateNewFloorTranspiler(IEnumerable<CodeInstruction> 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, bool>)((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) { if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { LethalLevelLoaderNetworkManager.Instance.GetDungeonFlowSizeServerRpc(); } else { roundManager.dungeonGenerator.Generate(); } } internal static void InjectHostDungeonFlowSelection() { DebugHelper.Log("Injecting Host Dungeon Flow Selection"); if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) { DebugHelper.Log("TryAddCurrentVanillaLevelDungeonFlow"); DungeonManager.TryAddCurrentVanillaLevelDungeonFlow(RoundManager.Instance.dungeonGenerator.Generator, LevelManager.CurrentExtendedLevel); DebugHelper.Log("Selecting Custom Dungeon Flow"); DungeonLoader.SelectDungeon(); DebugHelper.Log("GenerateNewFloor"); } else { DebugHelper.Log("Selecting Vanilla Dungeon Flow"); RoundManager.Instance.GenerateNewFloor(); } } [HarmonyPriority(200)] [HarmonyPatch(typeof(Dungeon), "RoundManager_Start")] [HarmonyPrefix] internal static bool Dungeon_Start_Prefix(orig_Start orig, RoundManager self) { DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_Start() Function To Prevent Conflicts"); orig.Invoke(self); return false; } [HarmonyPriority(200)] [HarmonyPatch(typeof(Dungeon), "RoundManager_GenerateNewFloor")] [HarmonyPrefix] internal static bool Dungeon_GenerateNewFloor_Prefix(orig_GenerateNewFloor orig, RoundManager self) { DebugHelper.LogWarning("Disabling LethalLib Dungeon.RoundManager_GenerateNewFloor() Function To Prevent Conflicts"); orig.Invoke(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 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 bool allDungeonFlowsRequireMatching = false; 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 void SelectDungeon() { RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow = null; if (((NetworkBehaviour)LethalLevelLoaderNetworkManager.Instance).IsServer) { LethalLevelLoaderNetworkManager.Instance.GetRandomExtendedDungeonFlowServerRpc(); } } internal static void PrepareDungeon() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator generator = RoundManager.Instance.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() { float num = LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier * RoundManager.Instance.mapSizeMultiplier; if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null && DungeonManager.CurrentExtendedDungeonFlow.enableDynamicDungeonSizeRestriction) { ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow; ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (currentExtendedLevel.selectableLevel.factorySizeMultiplier > currentExtendedDungeonFlow.dungeonSizeMax) { num = Mathf.Lerp(currentExtendedLevel.selectableLevel.factorySizeMultiplier, currentExtendedDungeonFlow.dungeonSizeMax, currentExtendedDungeonFlow.dungeonSizeLerpPercentage) * RoundManager.Instance.mapSizeMultiplier; } else if (currentExtendedLevel.selectableLevel.factorySizeMultiplier < currentExtendedDungeonFlow.dungeonSizeMin) { num = Mathf.Lerp(currentExtendedLevel.selectableLevel.factorySizeMultiplier, currentExtendedDungeonFlow.dungeonSizeMin, currentExtendedDungeonFlow.dungeonSizeLerpPercentage) * RoundManager.Instance.mapSizeMultiplier; } DebugHelper.Log("CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier + " | Overrriding DungeonSize To: " + num / RoundManager.Instance.mapSizeMultiplier + " (" + num + ")"); } else { DebugHelper.Log("CurrentLevel: " + LevelManager.CurrentExtendedLevel.NumberlessPlanetName + " DungeonSize Is: " + LevelManager.CurrentExtendedLevel.selectableLevel.factorySizeMultiplier + " | Leaving DungeonSize As: " + num / RoundManager.Instance.mapSizeMultiplier + " (" + num + ")"); } return num; } internal static void PatchDungeonSize(DungeonGenerator dungeonGenerator, ExtendedLevel extendedLevel, ExtendedDungeonFlow extendedDungeonFlow) { } internal static List<EntranceTeleport> GetEntranceTeleports(Scene scene) { List<EntranceTeleport> list = new List<EntranceTeleport>(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { EntranceTeleport[] componentsInChildren = val.GetComponentsInChildren<EntranceTeleport>(); 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<EntranceTeleport> 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"); } 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 / RoundManager.Instance.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate)); globalProp.Count.Max = globalProp.Count.Max * Mathf.RoundToInt(Mathf.Lerp(1f, dungeonGenerator.LengthMultiplier / RoundManager.Instance.mapSizeMultiplier, globalPropCountOverrides.globalPropCountScaleRate)); } } } } } public class LevelLoader { internal static List<MeshCollider> customLevelMeshCollidersList = new List<MeshCollider>(); internal static async void EnableMeshColliders() { List<MeshCollider> instansiatedCustomLevelMeshColliders = new List<MeshCollider>(); int counter = 0; MeshCollider[] array = Object.FindObjectsOfType<MeshCollider>(); 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) { StoryLog[] componentsInChildren = sceneRootObject.GetComponentsInChildren<StoryLog>(); foreach (StoryLog val in componentsInChildren) { foreach (StoryLogData storyLog in extendedLevel.storyLogs) { if (val.storyLogID == storyLog.storyLogID) { val.storyLogID = storyLog.newStoryLogID; } } } } } public class DungeonManager { public static ExtendedDungeonFlow CurrentExtendedDungeonFlow { get { ExtendedDungeonFlow result = null; if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.dungeonGenerator != (Object)null && TryGetExtendedDungeonFlow(RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow, out var returnExtendedDungeonFlow)) { result = returnExtendedDungeonFlow; } return result; } } internal static void PatchVanillaDungeonLists() { foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { customExtendedDungeonFlow.dungeonID = RoundManager.Instance.dungeonFlowTypes.Length; RoundManager.Instance.dungeonFlowTypes = CollectionExtensions.AddItem<IndoorMapType>((IEnumerable<IndoorMapType>)RoundManager.Instance.dungeonFlowTypes, customExtendedDungeonFlow.dungeonFlow.ToIndoorMapType()).ToArray(); if ((Object)(object)customExtendedDungeonFlow.dungeonFirstTimeAudio != (Object)null) { RoundManager.Instance.firstTimeDungeonAudios = CollectionExtensions.AddItem<AudioClip>((IEnumerable<AudioClip>)RoundManager.Instance.firstTimeDungeonAudios, customExtendedDungeonFlow.dungeonFirstTimeAudio).ToArray(); } } } internal static void AddExtendedDungeonFlow(ExtendedDungeonFlow extendedDungeonFlow) { PatchedContent.ExtendedDungeonFlows.Add(extendedDungeonFlow); } internal static void TryAddCurrentVanillaLevelDungeonFlow(DungeonGenerator dungeonGenerator, ExtendedLevel currentExtendedLevel) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown if ((Object)(object)dungeonGenerator.DungeonFlow != (Object)null && !RoundManager.Instance.dungeonFlowTypes.ToList().Any((IndoorMapType el) => (Object)(object)el.dungeonFlow == (Object)(object)dungeonGenerator.DungeonFlow)) { DebugHelper.Log("Level: " + currentExtendedLevel.selectableLevel.PlanetName + " Contains DungeonFlow: " + ((Object)dungeonGenerator.DungeonFlow).name + " In DungeonGenerator That Was Not Found In RoundManager, Adding!"); AssetBundleLoader.CreateVanillaExtendedDungeonFlow(dungeonGenerator.DungeonFlow); if (TryGetExtendedDungeonFlow(dungeonGenerator.DungeonFlow, out var returnExtendedDungeonFlow)) { IntWithRarity val = new IntWithRarity(); val.id = returnExtendedDungeonFlow.dungeonID; val.rarity = 300; currentExtendedLevel.selectableLevel.dungeonFlowTypes = CollectionExtensions.AddItem<IntWithRarity>((IEnumerable<IntWithRarity>)currentExtendedLevel.selectableLevel.dungeonFlowTypes, val).ToArray(); } } } internal static List<ExtendedDungeonFlowWithRarity> GetValidExtendedDungeonFlows(ExtendedLevel extendedLevel, bool debugResults) { string text = "Trying To Find All Matching DungeonFlows For Level: " + extendedLevel.NumberlessPlanetName + "\n"; List<ExtendedDungeonFlowWithRarity> list = new List<ExtendedDungeonFlowWithRarity>(); List<ExtendedDungeonFlowWithRarity> list2 = new List<ExtendedDungeonFlowWithRarity>(); if (extendedLevel.allowedDungeonContentTypes == ContentType.Vanilla || extendedLevel.allowedDungeonContentTypes == ContentType.Any) { IntWithRarity[] dungeonFlowTypes = extendedLevel.selectableLevel.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes) { if (TryGetExtendedDungeonFlow(RoundManager.Instance.dungeonFlowTypes[val.id].dungeonFlow, out var returnExtendedDungeonFlow)) { if (!Settings.allDungeonFlowsRequireMatching) { list.Add(new ExtendedDungeonFlowWithRarity(returnExtendedDungeonFlow, val.rarity)); } else { list2.Add(new ExtendedDungeonFlowWithRarity(returnExtendedDungeonFlow, val.rarity)); } } } } if (extendedLevel.allowedDungeonContentTypes == ContentType.Custom || extendedLevel.allowedDungeonContentTypes == ContentType.Any) { foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { list2.Add(new ExtendedDungeonFlowWithRarity(customExtendedDungeonFlow, 0)); } } text += "Potential DungeonFlows Collected, List Below: \n"; foreach (ExtendedDungeonFlowWithRarity item in list.Concat(list2)) { text = text + item.extendedDungeonFlow.dungeonDisplayName + " - " + item.rarity + ", "; } text = text + "\n\nSelectableLevel - " + extendedLevel.selectableLevel.PlanetName + " Level Tags: "; foreach (string levelTag in extendedLevel.levelTags) { text = text + levelTag + ", "; } text += "\n"; foreach (ExtendedDungeonFlowWithRarity item2 in list) { text = text + "\nDungeonFlow " + (list.IndexOf(item2) + 1) + ". : " + ((Object)item2.extendedDungeonFlow.dungeonFlow).name + " - Matched " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + item2.rarity + " Based On The Levels DungeonFlowTypes!\n"; } foreach (ExtendedDungeonFlowWithRarity item3 in new List<ExtendedDungeonFlowWithRarity>(list2)) { string text2 = string.Empty; ExtendedDungeonFlow extendedDungeonFlow = item3.extendedDungeonFlow; if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(extendedLevel.contentSourceName, extendedDungeonFlow.manualContentSourceNameReferenceList))) { text2 = " Based On Content Source Name!"; } if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(extendedLevel.NumberlessPlanetName, extendedDungeonFlow.manualPlanetNameReferenceList))) { text2 = " Based On Planet Name!"; } if (item3.UpdateRarity(GetHighestRarityViaMatchingWithinRanges(extendedLevel.RoutePrice, extendedDungeonFlow.dynamicRoutePricesList))) { text2 = " Based On Route Price!"; } if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedStrings(extendedLevel.levelTags, extendedDungeonFlow.dynamicLevelTagsList))) { text2 = " Based On Level Tags!"; } if (item3.UpdateRarity(GetHighestRarityViaMatchingNormalizedString(((object)(LevelWeatherType)(ref extendedLevel.selectableLevel.currentWeather)).ToString(), extendedDungeonFlow.dynamicCurrentWeatherList))) { text2 = " Based On Current Weather!"; } if (text2 != string.Empty) { text = text + "\nDungeonFlow " + (list2.IndexOf(item3) + 1) + ". : " + ((Object)extendedDungeonFlow.dungeonFlow).name + " - Matched " + extendedLevel.NumberlessPlanetName + " With A Rarity Of: " + item3.rarity + text2 + "\n"; } if (item3.rarity != 0) { list.Add(item3); } } if (debugResults) { DebugHelper.Log(text + "\nMatching DungeonFlows Collected, Count Is: " + list.Count + "\n\n"); } return list; } internal static void RefreshDungeonFlowIDs() { DebugHelper.Log("Re-Adjusting DungeonFlowTypes Array For Late Arriving Vanilla DungeonFlow"); List<DungeonFlow> list = new List<DungeonFlow>(); 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); } RoundManager.Instance.dungeonFlowTypes = list.Select(Utils.ToIndoorMapType).ToArray(); } internal static int GetHighestRarityViaMatchingWithinRanges(int comparingValue, List<Vector2WithRarity> 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<StringWithRarity> matchingStrings) { return GetHighestRarityViaMatchingNormalizedStrings(new List<string> { comparingString }, matchingStrings); } internal static int GetHighestRarityViaMatchingNormalizedStrings(List<string> comparingStrings, List<StringWithRarity> matchingStrings) { int num = 0; foreach (StringWithRarity matchingString in matchingStrings) { foreach (string item in new List<string>(comparingStrings)) { if (matchingString.Rarity >= num && (matchingString.Name.Sanitized().Contains(item.Sanitized()) || item.Sanitized().Contains(matchingString.Name.Sanitized()))) { num = matchingString.Rarity; } } } return num; } internal static bool TryGetExtendedDungeonFlow(DungeonFlow dungeonFlow, out ExtendedDungeonFlow returnExtendedDungeonFlow, ContentType contentType = ContentType.Any) { returnExtendedDungeonFlow = null; List<ExtendedDungeonFlow> 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; } } public class LethalLevelLoaderNetworkManager : NetworkBehaviour { public static GameObject networkingManagerPrefab; private static LethalLevelLoaderNetworkManager _instance; private static List<GameObject> queuedNetworkPrefabs = new List<GameObject>(); public static bool networkHasStarted; public static LethalLevelLoaderNetworkManager Instance { get { if ((Object)(object)_instance == (Object)null) { _instance = Object.FindObjectOfType<LethalLevelLoaderNetworkManager>(); } if ((Object)(object)_instance == (Object)null) { DebugHelper.LogWarning("LethalLevelLoaderNetworkManager Could Not Be Found! Returning Null!"); } 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] public void GetRandomExtendedDungeonFlowServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(12573863u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 12573863u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } DebugHelper.Log("Getting Random DungeonFlows!"); List<ExtendedDungeonFlowWithRarity> validExtendedDungeonFlows = DungeonManager.GetValidExtendedDungeonFlows(LevelManager.CurrentExtendedLevel, debugResults: true); List<int> list = new List<int>(); List<int> list2 = new List<int>(); 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!"); DebugHelper.LogError("Loading Facility DungeonFlow to prevent infinite loading!"); list.Add(0); list2.Add(300); } else { foreach (ExtendedDungeonFlowWithRarity extendedDungeonFlowWithRarity in validExtendedDungeonFlows) { list.Add(RoundManager.Instance.dungeonFlowTypes.ToList().FindIndex((IndoorMapType el) => (Object)(object)el.dungeonFlow == (Object)(object)extendedDungeonFlowWithRarity.extendedDungeonFlow.dungeonFlow)); list2.Add(extendedDungeonFlowWithRarity.rarity); } } SetRandomExtendedDungeonFlowClientRpc(list.ToArray(), list2.ToArray()); } [ClientRpc] public void SetRandomExtendedDungeonFlowClientRpc(int[] dungeonFlowIDs, int[] rarities) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1934987400u, val, (RpcDelivery)0); bool flag = dungeonFlowIDs != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(dungeonFlowIDs, default(ForPrimitives)); } bool flag2 = rarities != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(rarities, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1934987400u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { DebugHelper.Log("Setting Random DungeonFlows!"); List<IntWithRarity> list = new List<IntWithRarity>(); List<IntWithRarity> list2 = new List<IntWithRarity>(); for (int i = 0; i < dungeonFlowIDs.Length; i++) { IntWithRarity val3 = new IntWithRarity(); val3.Add(dungeonFlowIDs[i], rarities[i]); list.Add(val3); } list2 = new List<IntWithRarity>(LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes.ToList()); LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes = list.ToArray(); RoundManager.Instance.GenerateNewFloor(); LevelManager.CurrentExtendedLevel.selectableLevel.dungeonFlowTypes = list2.ToArray(); } } [ServerRpc] public void GetDungeonFlowSizeServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1367970965u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1367970965u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { SetDungeonFlowSizeClientRpc(DungeonLoader.GetClampedDungeonSize()); } } [ClientRpc] public void SetDungeonFlowSizeClientRpc(float hostSize) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0083: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1778200789u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref hostSize, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1778200789u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { RoundManager.Instance.dungeonGenerator.Generator.LengthMultiplier = hostSize; RoundManager.Instance.dungeonGenerator.Generate(); } } } public static void RegisterNetworkPrefab(GameObject prefab) { if (!networkHasStarted) { queuedNetworkPrefabs.Add(prefab); } else { DebugHelper.Log("Attempted To Register NetworkPrefab: " + ((object)prefab)?.ToString() + " After GameNetworkManager Has Started!"); } } internal static void RegisterPrefabs(NetworkManager networkManager) { List<GameObject> list = new List<GameObject>(); foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs) { list.Add(prefab.Prefab); } int num = 0; foreach (GameObject queuedNetworkPrefab in queuedNetworkPrefabs) { if (!list.Contains(queuedNetworkPrefab)) { networkManager.AddNetworkPrefab(queuedNetworkPrefab); list.Add(queuedNetworkPrefab); } else { num++; } } DebugHelper.Log("Skipped Registering " + num + " NetworkObjects As They Were Already Registered."); networkHasStarted = true; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_LethalLevelLoaderNetworkManager() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(12573863u, new RpcReceiveHandler(__rpc_handler_12573863)); NetworkManager.__rpc_func_table.Add(1934987400u, new RpcReceiveHandler(__rpc_handler_1934987400)); NetworkManager.__rpc_func_table.Add(1367970965u, new RpcReceiveHandler(__rpc_handler_1367970965)); NetworkManager.__rpc_func_table.Add(1778200789u, new RpcReceiveHandler(__rpc_handler_1778200789)); } private static void __rpc_handler_12573863(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).GetRandomExtendedDungeonFlowServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1934987400(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int[] dungeonFlowIDs = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref dungeonFlowIDs, default(ForPrimitives)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); int[] rarities = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref rarities, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)2; ((LethalLevelLoaderNetworkManager)(object)target).SetRandomExtendedDungeonFlowClientRpc(dungeonFlowIDs, rarities); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1367970965(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { target.__rpc_exec_stage = (__RpcExecStage)1; ((LethalLevelLoaderNetworkManager)(object)target).GetDungeonFlowSizeServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void