using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; using AIGraph; using AK; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using ChainedPuzzles; using Enemies; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.BaseClasses.CustomTerminalDefinition; using ExtraObjectiveSetup.Expedition; using ExtraObjectiveSetup.Expedition.Gears; using ExtraObjectiveSetup.Expedition.IndividualGeneratorGroup; using ExtraObjectiveSetup.ExtendedWardenEvents; using ExtraObjectiveSetup.Instances; using ExtraObjectiveSetup.Instances.ChainedPuzzle; using ExtraObjectiveSetup.JSON; using ExtraObjectiveSetup.JSON.Extensions; using ExtraObjectiveSetup.JSON.MTFOPartialData; using ExtraObjectiveSetup.JSON.PData; using ExtraObjectiveSetup.Objectives.ActivateSmallHSU; using ExtraObjectiveSetup.Objectives.GeneratorCluster; using ExtraObjectiveSetup.Objectives.IndividualGenerator; using ExtraObjectiveSetup.Objectives.ObjectiveCounter; using ExtraObjectiveSetup.Objectives.TerminalUplink; using ExtraObjectiveSetup.Tweaks.BossEvents; using ExtraObjectiveSetup.Tweaks.Scout; using ExtraObjectiveSetup.Tweaks.TerminalPosition; using ExtraObjectiveSetup.Tweaks.TerminalTweak; using ExtraObjectiveSetup.Utils; using FloLib.Networks.Replications; using GTFO.API; using GTFO.API.Extensions; using GTFO.API.JSON.Converters; using GTFO.API.Utilities; using GameData; using Gear; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LevelGeneration; using Localization; using MTFO.API; using Microsoft.CodeAnalysis; using Player; using SNetwork; using StateMachines; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Inas07.ExtraObjectiveSetup")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+338427ff3dcce6bd448f60cc822cf00046a20b66")] [assembly: AssemblyProduct("Inas07.ExtraObjectiveSetup")] [assembly: AssemblyTitle("Inas07.ExtraObjectiveSetup")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExtraObjectiveSetup { public static class EOSNetworking { public const uint INVALID_ID = 0u; public const uint FOREVER_REPLICATOR_ID_START = 1000u; public const uint REPLICATOR_ID_START = 10000u; private static uint currentForeverID; private static uint currentID; private static HashSet foreverUsedIDs; private static HashSet usedIDs; public static uint AllotReplicatorID() { while (currentID >= 10000 && usedIDs.Contains(currentID)) { currentID++; } if (currentID < 10000) { EOSLogger.Error("Replicator ID depleted. How?"); return 0u; } uint num = currentID; usedIDs.Add(num); currentID++; return num; } public static bool TryAllotID(uint id) { return usedIDs.Add(id); } public static uint AllotForeverReplicatorID() { while (currentForeverID < 10000 && foreverUsedIDs.Contains(currentForeverID)) { currentForeverID++; } if (currentForeverID >= 10000) { EOSLogger.Error("Forever Replicator ID depleted."); return 0u; } uint num = currentForeverID; foreverUsedIDs.Add(num); currentForeverID++; return num; } private static void Clear() { usedIDs.Clear(); currentID = 10000u; } public static void ClearForever() { foreverUsedIDs.Clear(); currentForeverID = 1000u; } static EOSNetworking() { currentForeverID = 1000u; currentID = 10000u; foreverUsedIDs = new HashSet(); usedIDs = new HashSet(); LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } public sealed class BatchBuildManager { private Dictionary OnBatchStart = new Dictionary(); private Dictionary OnBatchDone = new Dictionary(); public static BatchBuildManager Current { get; private set; } public void Init() { //IL_0033: 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) if (OnBatchStart.Count < 1) { foreach (object value in Enum.GetValues(typeof(BatchName))) { OnBatchStart[(BatchName)value] = null; } } if (OnBatchDone.Count >= 1) { return; } foreach (object value2 in Enum.GetValues(typeof(BatchName))) { OnBatchDone[(BatchName)value2] = null; } } public void Add_OnBatchDone(BatchName batchName, Action action) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Dictionary onBatchDone = OnBatchDone; onBatchDone[batchName] = (Action)Delegate.Combine(onBatchDone[batchName], action); } public void Remove_OnBatchDone(BatchName batchName, Action action) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Dictionary onBatchDone = OnBatchDone; onBatchDone[batchName] = (Action)Delegate.Remove(onBatchDone[batchName], action); } public Action Get_OnBatchDone(BatchName batchName) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return OnBatchDone[batchName]; } public void Add_OnBatchStart(BatchName batchName, Action action) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Dictionary onBatchStart = OnBatchStart; onBatchStart[batchName] = (Action)Delegate.Combine(onBatchStart[batchName], action); } public void Remove_OnBatchStart(BatchName batchName, Action action) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Dictionary onBatchStart = OnBatchStart; onBatchStart[batchName] = (Action)Delegate.Remove(onBatchStart[batchName], action); } public Action Get_OnBatchStart(BatchName batchName) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return OnBatchStart[batchName]; } private BatchBuildManager() { } static BatchBuildManager() { Current = new BatchBuildManager(); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Inas.ExtraObjectiveSetup", "ExtraObjectiveSetup", "1.6.15")] [BepInIncompatibility("Amor.ExcellentObjectiveSetup")] public class EntryPoint : BasePlugin { public const string AUTHOR = "Inas"; public const string PLUGIN_NAME = "ExtraObjectiveSetup"; public const string VERSION = "1.6.15"; private Harmony m_Harmony; public override void Load() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown m_Harmony = new Harmony("ExtraObjectiveSetup"); m_Harmony.PatchAll(); SetupManagers(); } private void SetupManagers() { BatchBuildManager.Current.Init(); IndividualGeneratorObjectiveManager.Current.Init(); GeneratorClusterObjectiveManager.Current.Init(); HSUActivatorObjectiveManager.Current.Init(); UplinkObjectiveManager.Current.Init(); TerminalPositionOverrideManager.Current.Init(); ScoutScreamEventManager.Current.Init(); BossDeathEventManager.Current.Init(); ExpeditionDefinitionManager.Current.Init(); ExpeditionGearManager.Current.Init(); ExpeditionIGGroupManager.Current.Init(); GeneratorClusterInstanceManager.Current.Init(); HSUActivatorInstanceManager.Current.Init(); PowerGeneratorInstanceManager.Current.Init(); TerminalInstanceManager.Current.Init(); ObjectiveCounterManager.Current.Init(); } } } namespace ExtraObjectiveSetup.Utils { public static class EOSTerminalUtils { public static List FindTerminal(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, Predicate predicate) { //IL_0005: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0075: Unknown result type (might be due to invalid IL or missing references) LG_Zone val = default(LG_Zone); if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, localIndex, ref val) || (Object)(object)val == (Object)null) { EOSLogger.Error($"SelectTerminal: Could NOT find zone {(dimensionIndex, layerType, localIndex)}"); return null; } if (val.TerminalsSpawnedInZone.Count <= 0) { EOSLogger.Error($"SelectTerminal: Could not find any terminals in zone {(dimensionIndex, layerType, localIndex)}"); return null; } List list = new List(); Enumerator enumerator = val.TerminalsSpawnedInZone.GetEnumerator(); while (enumerator.MoveNext()) { LG_ComputerTerminal current = enumerator.Current; if (predicate != null) { if (predicate(current)) { list.Add(current); } } else { list.Add(current); } } return list; } public static TerminalLogFileData GetLocalLog(this LG_ComputerTerminal terminal, string logName) { Dictionary localLogs = terminal.GetLocalLogs(); logName = logName.ToUpperInvariant(); if (!localLogs.ContainsKey(logName)) { return null; } return localLogs[logName]; } public static void ResetInitialOutput(this LG_ComputerTerminal terminal) { terminal.m_command.ClearOutputQueueAndScreenBuffer(); terminal.m_command.AddInitialTerminalOutput(); if (terminal.IsPasswordProtected) { terminal.m_command.AddPasswordProtectedOutput((Il2CppStringArray)null); } } public static List GetUniqueCommandEvents(this LG_ComputerTerminal terminal, string command) { List result = new List(); if ((Object)(object)terminal.ConnectedReactor != (Object)null) { return result; } int num = terminal.SpawnNode.m_zone.TerminalsSpawnedInZone.IndexOf(terminal); AIG_CourseNode spawnNode = terminal.SpawnNode; ExpeditionZoneData val = ((spawnNode != null) ? spawnNode.m_zone.m_settings.m_zoneData : null) ?? null; if (val == null) { EOSLogger.Error("GetCommandEvents: Cannot find target zone data."); return result; } if (num < 0 || num >= val.TerminalPlacements.Count) { EOSLogger.Debug($"GetCommandEvents: TerminalDataIndex({num}), TargetZoneData.TerminalPlacements.Count == ({val.TerminalPlacements.Count}) - maybe a custom terminal, skipped"); return result; } Enumerator enumerator = val.TerminalPlacements[num].UniqueCommands.GetEnumerator(); while (enumerator.MoveNext()) { CustomTerminalCommand current = enumerator.Current; if (current.Command.ToLower().Equals(command.ToLower())) { return current.CommandEvents.ToManaged(); } } EOSLogger.Error("GetCommandEvents: command '" + command + "' not found on " + terminal.ItemKey); return result; } public static LG_ComputerTerminal SelectPasswordTerminal(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, eSeedType seedType, int staticSeed = 1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected I4, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if ((int)seedType == 0) { EOSLogger.Error($"SelectTerminal: unsupported seed type {seedType}"); return null; } List list = FindTerminal(dimensionIndex, layerType, localIndex, (LG_ComputerTerminal x) => !x.HasPasswordPart); if (list == null) { EOSLogger.Error($"SelectTerminal: Could not find zone {(dimensionIndex, layerType, localIndex)}!"); return null; } if (list.Count <= 0) { EOSLogger.Error($"SelectTerminal: Could not find any terminals without a password part in zone {(dimensionIndex, layerType, localIndex)}, putting the password on random (session) already used terminal."); LG_Zone val = default(LG_Zone); Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, localIndex, ref val); return val.TerminalsSpawnedInZone[Builder.SessionSeedRandom.Range(0, val.TerminalsSpawnedInZone.Count, "NO_TAG")]; } switch (seedType - 1) { case 0: return list[Builder.SessionSeedRandom.Range(0, list.Count, "NO_TAG")]; case 1: return list[Builder.BuildSeedRandom.Range(0, list.Count, "NO_TAG")]; case 2: Random.InitState(staticSeed); return list[Random.Range(0, list.Count)]; default: EOSLogger.Error("SelectTerminal: did not have a valid SeedType!!"); return null; } } public static void BuildPassword(LG_ComputerTerminal terminal, TerminalPasswordData data) { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Expected O, but got Unknown //IL_04ce: Expected O, but got Unknown if (!data.PasswordProtected) { return; } if (terminal.IsPasswordProtected) { EOSLogger.Error("EOSTerminalUtils.BuildPassword: " + terminal.PublicName + " is already password-protected!"); return; } if (!data.GeneratePassword) { terminal.LockWithPassword(data.Password, new string[1] { data.PasswordHintText }); return; } if (data.TerminalZoneSelectionDatas.Count <= 0) { EOSLogger.Error($"Tried to generate a password for terminal {terminal.PublicName} with no {typeof(TerminalZoneSelectionData).Name}!! This is not allowed."); return; } string codeWord = SerialGenerator.GetCodeWord(); string passwordHintText = data.PasswordHintText; string text = "[Forgot your password?] Backup security key(s) located in logs on "; int num = data.PasswordPartCount; if (codeWord.Length % num != 0) { EOSLogger.Error($"Build() password.Length ({codeWord.Length}) not divisible by passwordParts ({num}). Defaulting to 1."); num = 1; } string[] array = ((num > 1) ? Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)StringUtils.SplitIntoChunksArray(codeWord, codeWord.Length / num)) : new string[1] { codeWord }); string text2 = ""; if (data.ShowPasswordPartPositions) { for (int i = 0; i < array[0].Length; i++) { text2 += "-"; } } HashSet hashSet = new HashSet(); LG_Zone val = default(LG_Zone); for (int j = 0; j < num; j++) { int index = j % data.TerminalZoneSelectionDatas.Count; List list = data.TerminalZoneSelectionDatas[index]; int index2 = Builder.SessionSeedRandom.Range(0, list.Count, "NO_TAG"); CustomTerminalZoneSelectionData customTerminalZoneSelectionData = list[index2]; LG_ComputerTerminal val2; if ((int)customTerminalZoneSelectionData.SeedType == 0) { if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(customTerminalZoneSelectionData.DimensionIndex, customTerminalZoneSelectionData.LayerType, customTerminalZoneSelectionData.LocalIndex, ref val) || (Object)(object)val == (Object)null) { EOSLogger.Error($"BuildPassword: seedType {0} specified but cannot find zone {customTerminalZoneSelectionData.GlobalZoneIndexTuple()}"); } if (val.TerminalsSpawnedInZone.Count <= 0) { EOSLogger.Error($"BuildPassword: seedType {0} specified but cannot find terminal zone {customTerminalZoneSelectionData.GlobalZoneIndexTuple()}"); } val2 = val.TerminalsSpawnedInZone[customTerminalZoneSelectionData.TerminalIndex]; } else { val2 = SelectPasswordTerminal(customTerminalZoneSelectionData.DimensionIndex, customTerminalZoneSelectionData.LayerType, customTerminalZoneSelectionData.LocalIndex, customTerminalZoneSelectionData.SeedType); } if ((Object)(object)val2 == (Object)null) { EOSLogger.Error($"BuildPassword: CRITICAL ERROR, could not get a LG_ComputerTerminal for password part ({j + 1}/{num}) for {terminal.PublicName} backup log."); continue; } string text3 = ""; string text4; if (data.ShowPasswordPartPositions) { for (int k = 0; k < j; k++) { text3 += text2; } text4 = text3 + array[j]; for (int l = j; l < num - 1; l++) { text4 += text2; } } else { text4 = array[j]; } string value = (data.ShowPasswordPartPositions ? $"0{j + 1}" : $"0{Builder.SessionSeedRandom.Range(0, 9, "NO_TAG")}"); TerminalLogFileData val3 = new TerminalLogFileData { FileName = $"key{value}_{LG_TerminalPasswordLinkerJob.GetTerminalNumber(terminal)}{(val2.HasPasswordPart ? "_1" : "")}.LOG", FileContent = new LocalizedText { UntranslatedText = string.Format(Text.Get((num > 1) ? 1431221909u : 2260297836u), text4), Id = 0u } }; val2.AddLocalLog(val3, true); if (!hashSet.Contains(val2)) { if (j > 0) { text += ", "; } text = text + val2.PublicName + " in " + val2.SpawnNode.m_zone.AliasName; } hashSet.Add(val2); val2.HasPasswordPart = true; } string text5 = text + "."; if (data.ShowPasswordLength) { terminal.LockWithPassword(codeWord, new string[3] { passwordHintText, text5, "Char[" + codeWord.Length + "]" }); } else { terminal.LockWithPassword(codeWord, new string[2] { passwordHintText, text5 }); } } public static void AddUniqueCommand(LG_ComputerTerminal terminal, CustomCommand cmd) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if (terminal.m_command.m_commandsPerString.ContainsKey(cmd.Command)) { EOSLogger.Error("Duplicate command name: '" + cmd.Command + "', cannot add command"); return; } TERM_Command val = default(TERM_Command); if (!terminal.m_command.TryGetUniqueCommandSlot(ref val)) { EOSLogger.Error("Cannot get more unique command slot, max: 5"); return; } terminal.m_command.AddCommand(val, cmd.Command, cmd.CommandDesc, cmd.SpecialCommandRule, ListExtensions.ToIl2Cpp(cmd.CommandEvents), ListExtensions.ToIl2Cpp(cmd.PostCommandOutputs)); for (int i = 0; i < cmd.CommandEvents.Count; i++) { WardenObjectiveEventData val2 = cmd.CommandEvents[i]; if (val2.ChainPuzzle == 0) { continue; } ChainedPuzzleDataBlock block = GameDataBlockBase.GetBlock(val2.ChainPuzzle); if (block == null) { continue; } LG_Area val3; Transform val4; if (terminal.SpawnNode != null) { val3 = terminal.SpawnNode.m_area; val4 = terminal.m_wardenObjectiveSecurityScanAlign; } else { LG_WardenObjective_Reactor connectedReactor = terminal.ConnectedReactor; object obj; if (connectedReactor == null) { obj = null; } else { AIG_CourseNode spawnNode = connectedReactor.SpawnNode; obj = ((spawnNode != null) ? spawnNode.m_area : null); } if (obj == null) { obj = null; } val3 = (LG_Area)obj; LG_WardenObjective_Reactor connectedReactor2 = terminal.ConnectedReactor; val4 = ((connectedReactor2 != null) ? connectedReactor2.m_chainedPuzzleAlign : null) ?? null; } if ((Object)(object)val3 == (Object)null) { EOSLogger.Error("Terminal Source Area is not found! Cannot create chained puzzle for command " + cmd.Command + "!"); continue; } ChainedPuzzleInstance val5 = ChainedPuzzleManager.CreatePuzzleInstance(block, val3, val4.position, val4, val2.UseStaticBioscanPoints); List events = ListExtensions.ToIl2Cpp(cmd.CommandEvents.GetRange(i, cmd.CommandEvents.Count - i)); val5.OnPuzzleSolved += Action.op_Implicit((Action)delegate { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(events, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray)null); }); terminal.SetChainPuzzleForCommand(val, i, val5); } } } public static class EOSUtils { public static List ToManaged(this List il2cppList) { List list = new List(); Enumerator enumerator = il2cppList.GetEnumerator(); while (enumerator.MoveNext()) { T current = enumerator.Current; list.Add(current); } return list; } public static void ResetProgress(this ChainedPuzzleInstance chainedPuzzle) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (chainedPuzzle.Data.DisableSurvivalWaveOnComplete) { chainedPuzzle.m_sound = new CellSoundPlayer(chainedPuzzle.m_parent.position); } foreach (iChainedPuzzleCore item in (Il2CppArrayBase)(object)chainedPuzzle.m_chainedPuzzleCores) { ResetChild(item); } if (SNet.IsMaster) { pChainedPuzzleState state = chainedPuzzle.m_stateReplicator.State; pChainedPuzzleState val = default(pChainedPuzzleState); val.status = (eChainedPuzzleStatus)0; val.currentSurvivalWave_EventID = state.currentSurvivalWave_EventID; val.isSolved = false; val.isActive = false; pChainedPuzzleState val2 = val; chainedPuzzle.m_stateReplicator.InteractWithState(val2, new pChainedPuzzleInteraction { type = (eChainedPuzzleInteraction)2 }); } static void ResetChild(iChainedPuzzleCore ICore) { CP_Bioscan_Core val3 = ((Il2CppObjectBase)ICore).TryCast(); if ((Object)(object)val3 != (Object)null) { ((Il2CppObjectBase)val3.m_spline).Cast(); ((Il2CppObjectBase)val3.PlayerScanner).Cast().ResetScanProgression(0f); val3.Deactivate(); } else { CP_Cluster_Core val4 = ((Il2CppObjectBase)ICore).TryCast(); if ((Object)(object)val4 == (Object)null) { EOSLogger.Error("ResetChild: found iChainedPuzzleCore that is neither CP_Bioscan_Core nor CP_Cluster_Core..."); } else { ((Il2CppObjectBase)val4.m_spline).Cast(); foreach (iChainedPuzzleCore item2 in (Il2CppArrayBase)(object)val4.m_childCores) { ResetChild(item2); } val4.Deactivate(); } } } } } public class EOSColor { public float r { get; set; } public float g { get; set; } public float b { get; set; } public float a { get; set; } = 1f; public Color ToUnityColor() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(r, g, b, a); } } public static class VanillaTMPPros { public const string VANILLA_CP_PREFAB_PATH = "Assets/AssetPrefabs/Complex/Generic/ChainedPuzzles/CP_Bioscan_sustained_RequireAll.prefab"; public static GameObject Instantiate(GameObject parent = null) { GameObject loadedAsset = AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Generic/ChainedPuzzles/CP_Bioscan_sustained_RequireAll.prefab"); if ((Object)(object)loadedAsset == (Object)null) { EOSLogger.Error("VanillaTMPPros.Instantiate: Cannot find TMPPro from vanilla CP!"); return null; } GameObject gameObject = ((Component)loadedAsset.transform.GetChild(0).GetChild(1).GetChild(0)).gameObject; if (!((Object)(object)parent != (Object)null)) { return Object.Instantiate(gameObject.gameObject); } return Object.Instantiate(gameObject.gameObject, parent.transform); } } public class Vec4 : Vec3 { [JsonPropertyOrder(-9)] public float w { get; set; } public Vector4 ToVector4() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Vector4(base.x, base.y, base.z, w); } } public class Vec3 { [JsonPropertyOrder(-10)] public float x { get; set; } [JsonPropertyOrder(-10)] public float y { get; set; } [JsonPropertyOrder(-10)] public float z { get; set; } public Vector3 ToVector3() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, y, z); } public Quaternion ToQuaternion() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(x, y, z); } } public static class EOSLogger { private static ManualLogSource logger = Logger.CreateLogSource("ExtraObjectiveSetup"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } } namespace ExtraObjectiveSetup.Tweaks.TerminalTweak { public struct TerminalState { public bool Enabled; public TerminalState() { Enabled = true; } public TerminalState(bool Enabled) { this.Enabled = true; this.Enabled = Enabled; } public TerminalState(TerminalState o) { Enabled = true; Enabled = o.Enabled; } } public class TerminalWrapper { public LG_ComputerTerminal lgTerminal { get; private set; } public StateReplicator stateReplicator { get; private set; } private void ChangeStateUnsynced(bool enabled) { EOSLogger.Debug($"{lgTerminal.ItemKey} state, enabled: {enabled}"); lgTerminal.OnProximityExit(); Interact_ComputerTerminal componentInChildren = ((Component)lgTerminal).GetComponentInChildren(true); bool flag = enabled; if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = flag; ((Interact_Base)componentInChildren).SetActive(flag); } lgTerminal.m_interfaceScreen.SetActive(flag); lgTerminal.m_loginScreen.SetActive(flag); if ((Object)(object)lgTerminal.m_text != (Object)null) { ((Behaviour)lgTerminal.m_text).enabled = flag; } if (!flag) { PlayerAgent localInteractionSource = lgTerminal.m_localInteractionSource; if ((Object)(object)localInteractionSource != (Object)null && localInteractionSource.FPItemHolder.InTerminalTrigger) { lgTerminal.ExitFPSView(); } } } public void ChangeState(bool enabled) { ChangeStateUnsynced(enabled); if (SNet.IsMaster) { stateReplicator.SetState(new TerminalState { Enabled = enabled }); } } private void OnStateChanged(TerminalState oldState, TerminalState newState, bool isRecall) { if (isRecall) { ChangeStateUnsynced(newState.Enabled); } } public static TerminalWrapper Instantiate(LG_ComputerTerminal lgTerminal, uint replicatorID) { if ((Object)(object)lgTerminal == (Object)null || replicatorID == 0) { return null; } TerminalWrapper terminalWrapper = new TerminalWrapper(); terminalWrapper.lgTerminal = lgTerminal; terminalWrapper.stateReplicator = StateReplicator.Create(replicatorID, new TerminalState { Enabled = true }, (LifeTimeType)1, (IStateReplicatorHolder)null); terminalWrapper.stateReplicator.OnStateChanged += terminalWrapper.OnStateChanged; return terminalWrapper; } private TerminalWrapper() { } } } namespace ExtraObjectiveSetup.Tweaks.TerminalPosition { public class TerminalPosition : BaseInstanceDefinition { public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); } internal class TerminalPositionOverrideManager : InstanceDefinitionManager { public static TerminalPositionOverrideManager Current; protected override string DEFINITION_NAME => "TerminalPosition"; private TerminalPositionOverrideManager() { } static TerminalPositionOverrideManager() { Current = new TerminalPositionOverrideManager(); } } } namespace ExtraObjectiveSetup.Tweaks.Scout { public class EventsOnZoneScoutScream : GlobalZoneIndex { public bool SuppressVanillaScoutWave { get; set; } public List EventsOnScoutScream { get; set; } = new List(); } internal class ScoutScreamEventManager : ZoneDefinitionManager { public static ScoutScreamEventManager Current; protected override string DEFINITION_NAME => "EventsOnScoutScream"; private ScoutScreamEventManager() { } static ScoutScreamEventManager() { Current = new ScoutScreamEventManager(); } } } namespace ExtraObjectiveSetup.Tweaks.BossEvents { public struct FiniteBDEState { public int ApplyToHibernateCount; public int ApplyToWaveCount; public FiniteBDEState() { ApplyToHibernateCount = int.MaxValue; ApplyToWaveCount = int.MaxValue; } public FiniteBDEState(FiniteBDEState other) { ApplyToHibernateCount = int.MaxValue; ApplyToWaveCount = int.MaxValue; ApplyToHibernateCount = other.ApplyToHibernateCount; ApplyToHibernateCount = other.ApplyToWaveCount; } public FiniteBDEState(int ApplyToHibernateCount, int ApplyToWaveCount) { this.ApplyToHibernateCount = int.MaxValue; this.ApplyToWaveCount = int.MaxValue; this.ApplyToHibernateCount = ApplyToHibernateCount; this.ApplyToWaveCount = ApplyToWaveCount; } } public class EventsOnZoneBossDeath : GlobalZoneIndex { public bool ApplyToHibernate { get; set; } = true; public int ApplyToHibernateCount { get; set; } = int.MaxValue; public bool ApplyToWave { get; set; } public int ApplyToWaveCount { get; set; } = int.MaxValue; public List BossIDs { get; set; } = new List { 29u, 36u, 37u }; public List EventsOnBossDeath { get; set; } = new List(); [JsonIgnore] public StateReplicator FiniteBDEStateReplicator { get; private set; } [JsonIgnore] public int RemainingWaveBDE { get { if (FiniteBDEStateReplicator == null) { return ApplyToWaveCount; } return FiniteBDEStateReplicator.State.ApplyToWaveCount; } } [JsonIgnore] public int RemainingHibernateBDE { get { if (FiniteBDEStateReplicator == null) { return ApplyToHibernateCount; } return FiniteBDEStateReplicator.State.ApplyToHibernateCount; } } public void SetupReplicator(uint replicatorID) { if (ApplyToHibernateCount != int.MaxValue || ApplyToWaveCount != int.MaxValue) { FiniteBDEStateReplicator = StateReplicator.Create(replicatorID, new FiniteBDEState { ApplyToHibernateCount = ApplyToHibernateCount, ApplyToWaveCount = ApplyToWaveCount }, (LifeTimeType)1, (IStateReplicatorHolder)null); FiniteBDEStateReplicator.OnStateChanged += OnStateChanged; } } private void OnStateChanged(FiniteBDEState oldState, FiniteBDEState newState, bool isRecall) { } internal void Destroy() { FiniteBDEStateReplicator = null; } } internal class BossDeathEventManager : ZoneDefinitionManager { public enum Mode { HIBERNATE, WAVE } public static BossDeathEventManager Current; public const int UNLIMITED_COUNT = int.MaxValue; private ConcurrentDictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), EventsOnZoneBossDeath> LevelBDEs { get; } = new ConcurrentDictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), EventsOnZoneBossDeath>(); protected override string DEFINITION_NAME => "EventsOnBossDeath"; public bool TryConsumeBDEventsExecutionTimes(EventsOnZoneBossDeath def, Mode mode) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return TryConsumeBDEventsExecutionTimes(def.DimensionIndex, def.LayerType, def.LocalIndex, mode); } public bool TryConsumeBDEventsExecutionTimes(eDimensionIndex dimensionIndex, LG_LayerType layer, eLocalZoneIndex localIndex, Mode mode) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!LevelBDEs.ContainsKey((dimensionIndex, layer, localIndex))) { EOSLogger.Error($"BossDeathEventManager: got an unregistered entry: {(dimensionIndex, layer, localIndex, mode)}"); return false; } EventsOnZoneBossDeath eventsOnZoneBossDeath = LevelBDEs[(dimensionIndex, layer, localIndex)]; int num = ((mode == Mode.HIBERNATE) ? eventsOnZoneBossDeath.RemainingHibernateBDE : eventsOnZoneBossDeath.RemainingWaveBDE); if (num == int.MaxValue) { return true; } if (num > 0) { FiniteBDEState state = eventsOnZoneBossDeath.FiniteBDEStateReplicator.State; if (SNet.IsMaster) { eventsOnZoneBossDeath.FiniteBDEStateReplicator.SetState(new FiniteBDEState { ApplyToHibernateCount = ((mode == Mode.HIBERNATE) ? (num - 1) : state.ApplyToHibernateCount), ApplyToWaveCount = ((mode == Mode.WAVE) ? (num - 1) : state.ApplyToWaveCount) }); } return true; } return false; } private void Clear() { foreach (EventsOnZoneBossDeath value in LevelBDEs.Values) { value.Destroy(); } LevelBDEs.Clear(); } private void SetupForCurrentExpedition() { if (!definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return; } foreach (EventsOnZoneBossDeath definition in definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions) { if (LevelBDEs.ContainsKey(definition.GlobalZoneIndexTuple())) { EOSLogger.Error($"BossDeathEvent: found duplicate setup for zone {definition.GlobalZoneIndexTuple()}, will overwrite!"); } if (definition.ApplyToHibernateCount != int.MaxValue || definition.ApplyToWaveCount != int.MaxValue) { uint num = EOSNetworking.AllotReplicatorID(); if (num != 0) { definition.SetupReplicator(num); } else { EOSLogger.Error("BossDeathEvent: replicator ID depleted, cannot setup replicator!"); } } LevelBDEs[definition.GlobalZoneIndexTuple()] = definition; } } private BossDeathEventManager() { LevelAPI.OnBuildStart += delegate { Clear(); SetupForCurrentExpedition(); }; LevelAPI.OnLevelCleanup += Clear; } static BossDeathEventManager() { Current = new BossDeathEventManager(); } } } namespace ExtraObjectiveSetup.Patches { [HarmonyPatch] internal class Patch_CheckAndExecuteEventsOnTrigger { [HarmonyPrefix] [HarmonyPatch(typeof(WardenObjectiveManager), "CheckAndExecuteEventsOnTrigger", new Type[] { typeof(WardenObjectiveEventData), typeof(eWardenObjectiveEventTrigger), typeof(bool), typeof(float) })] private static bool Pre_CheckAndExecuteEventsOnTrigger(WardenObjectiveEventData eventToTrigger, eWardenObjectiveEventTrigger trigger, bool ignoreTrigger, float currentDuration) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected I4, but got Unknown if (eventToTrigger == null || (!ignoreTrigger && eventToTrigger.Trigger != trigger) || ((double)currentDuration != 0.0 && eventToTrigger.Delay <= currentDuration)) { return true; } uint num = (uint)(int)eventToTrigger.Type; if (!EOSWardenEventManager.Current.HasEventDefinition(num)) { return true; } string value = (EOSWardenEventManager.Current.IsVanillaEventID(num) ? "overriding vanilla event implementation..." : "executing..."); EOSLogger.Debug($"WardenEvent: found definition for event ID {num}, {value}"); EOSWardenEventManager.Current.ExecuteEvent(eventToTrigger, currentDuration); return false; } } [HarmonyPatch] internal class Patch_EventsOnBossDeath { private static HashSet ExecutedForInstances; [HarmonyPostfix] [HarmonyPatch(typeof(EnemySync), "OnSpawn")] private static void Post_SpawnEnemy(EnemySync __instance, pEnemySpawnData spawnData) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_00c1: 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_00c8: Invalid comparison between Unknown and I4 //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode val = default(AIG_CourseNode); if (!((pCourseNode)(ref spawnData.courseNode)).TryGet(ref val) || val == null) { EOSLogger.Error("Failed to get spawnnode for a boss! Skipped EventsOnBossDeath for it"); return; } LG_Zone zone = val.m_zone; EventsOnZoneBossDeath def = BossDeathEventManager.Current.GetDefinition(zone.DimensionIndex, zone.Layer.m_type, zone.LocalIndex); if (def == null) { return; } EnemyAgent enemy = __instance.m_agent; if (!def.BossIDs.Contains(((GameDataBlockBase)(object)enemy.EnemyData).persistentID) || ((((int)spawnData.mode != 4 && (int)spawnData.mode != 3) || !def.ApplyToHibernate) && ((int)spawnData.mode != 1 || !def.ApplyToWave))) { return; } BossDeathEventManager.Mode mode = (((int)spawnData.mode != 4) ? BossDeathEventManager.Mode.WAVE : BossDeathEventManager.Mode.HIBERNATE); enemy.OnDeadCallback += Action.op_Implicit((Action)delegate { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)GameStateManager.CurrentStateName == 10) { if (!BossDeathEventManager.Current.TryConsumeBDEventsExecutionTimes(def, mode)) { EOSLogger.Debug($"EventsOnBossDeath: execution times depleted for {def.GlobalZoneIndexTuple()}, {mode}"); } else { ushort globalID = ((Agent)enemy).GlobalID; if (ExecutedForInstances.Contains(globalID)) { ExecutedForInstances.Remove(globalID); } else { def.EventsOnBossDeath.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); ExecutedForInstances.Add(globalID); } } } }); EOSLogger.Debug($"EventsOnBossDeath: added for enemy with id {((GameDataBlockBase)(object)enemy.EnemyData).persistentID}, mode: {spawnData.mode}"); } static Patch_EventsOnBossDeath() { ExecutedForInstances = new HashSet(); LevelAPI.OnLevelCleanup += ExecutedForInstances.Clear; } } [HarmonyPatch] internal class Patch_EventsOnZoneScoutScream { [HarmonyPrefix] [HarmonyPatch(typeof(ES_ScoutScream), "CommonUpdate")] private static bool Pre_ES_ScoutScream_CommonUpdate(ES_ScoutScream __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode courseNode = ((Agent)((ES_Base)__instance).m_enemyAgent).CourseNode; EventsOnZoneScoutScream definition = ScoutScreamEventManager.Current.GetDefinition(courseNode.m_dimension.DimensionIndex, courseNode.LayerType, courseNode.m_zone.LocalIndex); if (definition == null) { return true; } if ((int)__instance.m_state != 3 || __instance.m_stateDoneTimer >= Clock.Time) { return true; } if (definition.EventsOnScoutScream != null && definition.EventsOnScoutScream.Count > 0) { EOSLogger.Debug($"EventsOnZoneScoutScream: found config for {definition.GlobalZoneIndexTuple()}, executing events."); definition.EventsOnScoutScream.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } if (!definition.SuppressVanillaScoutWave) { if (SNet.IsMaster && ((Agent)((ES_Base)__instance).m_enemyAgent).CourseNode != null) { if (RundownManager.ActiveExpedition.Expedition.ScoutWaveSettings != 0 && RundownManager.ActiveExpedition.Expedition.ScoutWavePopulation != 0) { ushort num = default(ushort); Mastermind.Current.TriggerSurvivalWave(((Agent)((ES_Base)__instance).m_enemyAgent).CourseNode, RundownManager.ActiveExpedition.Expedition.ScoutWaveSettings, RundownManager.ActiveExpedition.Expedition.ScoutWavePopulation, ref num, (SurvivalWaveSpawnType)0, 0f, 2f, true, false, default(Vector3), ""); } else { Debug.LogError(Object.op_Implicit("ES_ScoutScream, a scout is screaming but we can't spawn a wave because the the scout settings are not set for this expedition! ScoutWaveSettings: " + RundownManager.ActiveExpedition.Expedition.ScoutWaveSettings + " ScoutWavePopulation: " + RundownManager.ActiveExpedition.Expedition.ScoutWavePopulation)); } } } else { EOSLogger.Debug("Vanilla scout wave suppressed."); } if (SNet.IsMaster) { ((ES_Base)__instance).m_enemyAgent.AI.m_behaviour.ChangeState((EB_States)5); } ((MachineState)(object)__instance).m_machine.ChangeState(2); __instance.m_state = (ScoutScreamState)4; return false; } } } namespace ExtraObjectiveSetup.Patches.Uplink { [HarmonyPatch] internal static class CorruptedUplinkConfirm { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalCorruptedUplinkConfirm")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_TerminalCorruptedUplinkConfirm(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2, ref bool __result) { LG_ComputerTerminal receiver = __instance.m_terminal; LG_ComputerTerminal sender = __instance.m_terminal.CorruptedUplinkReceiver; if ((Object)(object)sender == (Object)null) { EOSLogger.Error("TerminalCorruptedUplinkConfirm() critical failure because terminal does not have a CorruptedUplinkReceiver (sender)."); __result = false; return false; } if (sender.m_isWardenObjective) { return true; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(sender); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(sender); UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); receiver.m_command.AddOutput((TerminalLineType)0, string.Format(Text.Get(2816126705u), sender.PublicName), 0f, (TerminalSoundType)0, (TerminalSoundType)0); if ((Object)(object)sender.ChainedPuzzleForWardenObjective != (Object)null) { ChainedPuzzleInstance chainedPuzzleForWardenObjective = sender.ChainedPuzzleForWardenObjective; chainedPuzzleForWardenObjective.OnPuzzleSolved += Action.op_Implicit((Action)delegate { receiver.m_command.StartTerminalUplinkSequence(string.Empty, true); UplinkObjectiveManager.Current.ChangeState(sender, new UplinkState { Status = UplinkStatus.InProgress, CurrentRoundIndex = 0 }); }); sender.m_command.AddOutput("", true); sender.m_command.AddOutput(Text.Get(3268596368u), true); sender.m_command.AddOutput(Text.Get(2277987284u), true); receiver.m_command.AddOutput("", true); receiver.m_command.AddOutput(Text.Get(3268596368u), true); receiver.m_command.AddOutput(Text.Get(2277987284u), true); if (SNet.IsMaster) { sender.ChainedPuzzleForWardenObjective.AttemptInteract((eChainedPuzzleInteraction)0); } } else { receiver.m_command.StartTerminalUplinkSequence(string.Empty, true); UplinkObjectiveManager.Current.ChangeState(sender, new UplinkState { Status = UplinkStatus.InProgress, CurrentRoundIndex = 0 }); } __result = true; return false; } } [HarmonyPatch] internal static class CorruptedUplinkConnect { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalCorruptedUplinkConnect")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_TerminalCorruptedUplinkConnect(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2, ref bool __result) { //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown LG_ComputerTerminal terminal = __instance.m_terminal; if (terminal.m_isWardenObjective) { return true; } __result = false; LG_ComputerTerminal corruptedUplinkReceiver = terminal.CorruptedUplinkReceiver; if ((Object)(object)corruptedUplinkReceiver == (Object)null) { EOSLogger.Error("TerminalCorruptedUplinkConnect() critical failure because terminal does not have a CorruptedUplinkReceiver."); return false; } if (LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != 0 && LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != terminal.SyncID) { __instance.AddOngoingUplinkOutput(); __result = false; return false; } LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId = terminal.SyncID; (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(terminal); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(terminal); UplinkDefinition definition = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (definition.UseUplinkAddress) { param1 = param1.ToUpper(); EOSLogger.Debug("TerminalCorruptedUplinkConnect, param1: " + param1 + ", TerminalUplink: " + ((Object)terminal.UplinkPuzzle).ToString()); } else { param1 = terminal.UplinkPuzzle.TerminalUplinkIP.ToUpper(); EOSLogger.Debug("TerminalCorruptedUplinkConnect, not using uplink address, TerminalUplink: " + ((Object)terminal.UplinkPuzzle).ToString()); } if (!definition.UseUplinkAddress || param1 == terminal.UplinkPuzzle.TerminalUplinkIP) { if (corruptedUplinkReceiver.m_command.HasRegisteredCommand((TERM_Command)27)) { terminal.m_command.AddUplinkCorruptedOutput(); } else { terminal.m_command.AddUplinkCorruptedOutput(); terminal.m_command.AddOutput("", true); terminal.m_command.AddOutput((TerminalLineType)4, string.Format(Text.Get(3492863045u), corruptedUplinkReceiver.PublicName), 3f, (TerminalSoundType)0, (TerminalSoundType)0); terminal.m_command.AddOutput((TerminalLineType)0, Text.Get(2761366063u), 0.6f, (TerminalSoundType)0, (TerminalSoundType)0); terminal.m_command.AddOutput("", true); terminal.m_command.AddOutput((TerminalLineType)0, Text.Get(3435969025u), 0.8f, (TerminalSoundType)0, (TerminalSoundType)0); corruptedUplinkReceiver.m_command.AddCommand((TERM_Command)27, "UPLINK_CONFIRM", new LocalizedText { UntranslatedText = Text.Get(112719254u), Id = 0u }, (TERM_CommandRule)2); corruptedUplinkReceiver.m_command.AddOutput((TerminalLineType)0, string.Format(Text.Get(1173595354u), terminal.PublicName), 0f, (TerminalSoundType)0, (TerminalSoundType)0); } } else { terminal.m_command.AddUplinkWrongAddressError(param1); } return false; } } [HarmonyPatch] internal static class StartTerminalUplinkSequence { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "StartTerminalUplinkSequence")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_StartTerminalUplinkSequence(LG_ComputerTerminalCommandInterpreter __instance, string uplinkIp, bool corrupted) { if (!corrupted) { LG_ComputerTerminal uplinkTerminal = __instance.m_terminal; if (uplinkTerminal.m_isWardenObjective) { return true; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(uplinkTerminal); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(uplinkTerminal); UplinkDefinition uplinkConfig = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); uplinkTerminal.m_command.AddOutput((TerminalLineType)4, string.Format(Text.Get(2583360288u), uplinkIp), 3f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.TerminalUplinkSequenceOutputs(uplinkTerminal, false); uplinkTerminal.m_command.OnEndOfQueue = Action.op_Implicit((Action)delegate { EOSLogger.Debug("UPLINK CONNECTION DONE!"); uplinkTerminal.UplinkPuzzle.Connected = true; uplinkTerminal.UplinkPuzzle.CurrentRound.ShowGui = true; uplinkTerminal.UplinkPuzzle.OnStartSequence(); uplinkConfig.EventsOnCommence.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); int num2 = uplinkConfig.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == 0); ((num2 != -1) ? uplinkConfig.RoundOverrides[num2] : null)?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); }); } else { LG_ComputerTerminal terminal = __instance.m_terminal; LG_ComputerTerminal sender = __instance.m_terminal.CorruptedUplinkReceiver; if (sender.m_isWardenObjective) { return true; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex2 = TerminalInstanceManager.Current.GetGlobalZoneIndex(sender); uint zoneInstanceIndex2 = TerminalInstanceManager.Current.GetZoneInstanceIndex(sender); UplinkDefinition uplinkConfig2 = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex2, zoneInstanceIndex2); sender.m_command.AddOutput((TerminalLineType)4, string.Format(Text.Get(2056072887u), sender.PublicName), 3f, (TerminalSoundType)0, (TerminalSoundType)0); sender.m_command.AddOutput("", true); terminal.m_command.AddOutput((TerminalLineType)4, string.Format(Text.Get(2056072887u), sender.PublicName), 3f, (TerminalSoundType)0, (TerminalSoundType)0); terminal.m_command.AddOutput("", true); terminal.m_command.TerminalUplinkSequenceOutputs(sender, false); terminal.m_command.TerminalUplinkSequenceOutputs(terminal, true); terminal.m_command.OnEndOfQueue = Action.op_Implicit((Action)delegate { EOSLogger.Debug("UPLINK CONNECTION DONE!"); sender.UplinkPuzzle.Connected = true; sender.UplinkPuzzle.CurrentRound.ShowGui = true; sender.UplinkPuzzle.OnStartSequence(); uplinkConfig2.EventsOnCommence.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); int num = uplinkConfig2.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == 0); ((num != -1) ? uplinkConfig2.RoundOverrides[num] : null)?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); }); } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "StartTerminalUplinkSequence")] private static void Post_LG_ComputerTerminalCommandInterpreter_StartTerminalUplinkSequence(LG_ComputerTerminalCommandInterpreter __instance, bool corrupted) { if (!corrupted) { LG_ComputerTerminal terminal = __instance.m_terminal; if (!terminal.m_isWardenObjective) { return; } UplinkDefinition uplinkConfig = UplinkObjectiveManager.Current.GetWardenDefinition(__instance.m_terminal); if (uplinkConfig == null) { return; } LG_ComputerTerminalCommandInterpreter command = terminal.m_command; command.OnEndOfQueue += Action.op_Implicit((Action)delegate { uplinkConfig.EventsOnCommence.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); int num2 = uplinkConfig.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == 0); ((num2 != -1) ? uplinkConfig.RoundOverrides[num2] : null)?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); }); return; } LG_ComputerTerminal terminal2 = __instance.m_terminal; LG_ComputerTerminal corruptedUplinkReceiver = __instance.m_terminal.CorruptedUplinkReceiver; if (!corruptedUplinkReceiver.m_isWardenObjective) { return; } UplinkDefinition uplinkConfig2 = UplinkObjectiveManager.Current.GetWardenDefinition(corruptedUplinkReceiver); if (uplinkConfig2 == null) { return; } LG_ComputerTerminalCommandInterpreter command2 = terminal2.m_command; command2.OnEndOfQueue += Action.op_Implicit((Action)delegate { uplinkConfig2.EventsOnCommence.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); int num = uplinkConfig2.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == 0); ((num != -1) ? uplinkConfig2.RoundOverrides[num] : null)?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); }); } } [HarmonyPatch] internal static class TerminalUplinkConnect { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalUplinkConnect")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_TerminalUplinkConnect(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2, ref bool __result) { LG_ComputerTerminal terminal = __instance.m_terminal; if (terminal.m_isWardenObjective) { return true; } if (LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != 0 && LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != terminal.SyncID) { __instance.AddOngoingUplinkOutput(); return false; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(__instance.m_terminal); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(terminal); UplinkDefinition definition = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (!definition.UseUplinkAddress) { param1 = __instance.m_terminal.UplinkPuzzle.TerminalUplinkIP; } if (!definition.UseUplinkAddress || param1 == __instance.m_terminal.UplinkPuzzle.TerminalUplinkIP) { __instance.m_terminal.TrySyncSetCommandRule((TERM_Command)25, (TERM_CommandRule)1); if ((Object)(object)__instance.m_terminal.ChainedPuzzleForWardenObjective != (Object)null) { ChainedPuzzleInstance chainedPuzzleForWardenObjective = __instance.m_terminal.ChainedPuzzleForWardenObjective; chainedPuzzleForWardenObjective.OnPuzzleSolved += Action.op_Implicit((Action)delegate { __instance.StartTerminalUplinkSequence(param1, false); }); __instance.AddOutput("", true); __instance.AddOutput(Text.Get(3268596368u), true); __instance.AddOutput(Text.Get(3041541194u), true); if (SNet.IsMaster) { __instance.m_terminal.ChainedPuzzleForWardenObjective.AttemptInteract((eChainedPuzzleInteraction)0); } } else { __instance.StartTerminalUplinkSequence(param1, false); } __result = true; } else { __instance.AddUplinkWrongAddressError(param1); __result = false; } return false; } } [HarmonyPatch] internal static class TerminalUplinkSequenceOutput { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalUplinkSequenceOutputs")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_TerminalUplinkSequenceOutputs(LG_ComputerTerminal terminal, bool corrupted) { if (terminal.m_isWardenObjective) { return true; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(terminal); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(terminal); UplinkDefinition definition = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (definition == null) { if (!((Object)(object)terminal.CorruptedUplinkReceiver != (Object)null)) { return true; } LG_ComputerTerminal corruptedUplinkReceiver = terminal.CorruptedUplinkReceiver; globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(corruptedUplinkReceiver); zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(corruptedUplinkReceiver); definition = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (definition == null || definition.DisplayUplinkWarning) { return true; } } terminal.m_command.AddOutput((TerminalLineType)3, Text.Get(3418104670u), 3f, (TerminalSoundType)0, (TerminalSoundType)0); terminal.m_command.AddOutput("", true); if (!corrupted) { terminal.m_command.AddOutput(string.Format(Text.Get(947485599u), terminal.UplinkPuzzle.CurrentRound.CorrectPrefix), true); } return false; } } [HarmonyPatch] internal static class TerminalUplinkVerify { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalUplinkVerify")] private static bool Pre_LG_ComputerTerminalCommandInterpreter_TerminalUplinkVerify(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2, ref bool __result, out List __state) { __state = null; if (__instance.m_terminal.m_isWardenObjective) { UplinkDefinition wardenDefinition = UplinkObjectiveManager.Current.GetWardenDefinition(__instance.m_terminal); if (wardenDefinition == null) { return true; } TerminalUplinkPuzzle puzzle = __instance.m_terminal.UplinkPuzzle; if (puzzle.Connected && !puzzle.Solved && puzzle.CurrentRound.CorrectCode.ToUpper() == param1.ToUpper()) { __state = wardenDefinition.RoundOverrides.Find((UplinkRound round) => round.RoundIndex == puzzle.m_roundIndex + 1)?.EventsOnRound; wardenDefinition.RoundOverrides.Find((UplinkRound round) => round.RoundIndex == puzzle.m_roundIndex)?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)2, false, 0f); }); } return true; } TerminalUplinkPuzzle uplinkPuzzle = __instance.m_terminal.UplinkPuzzle; (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(__instance.m_terminal); uint zoneInstanceIndex = TerminalInstanceManager.Current.GetZoneInstanceIndex(__instance.m_terminal); UplinkDefinition definition = UplinkObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); int CurrentRoundIndex = uplinkPuzzle.m_roundIndex; int num = definition.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == CurrentRoundIndex); UplinkRound roundOverride = ((num != -1) ? definition.RoundOverrides[num] : null); TimeSettings timeSettings = ((num != -1) ? roundOverride.OverrideTimeSettings : definition.DefaultTimeSettings); float num2 = ((timeSettings.TimeToStartVerify >= 0f) ? timeSettings.TimeToStartVerify : definition.DefaultTimeSettings.TimeToStartVerify); float timeToCompleteVerify = ((timeSettings.TimeToCompleteVerify >= 0f) ? timeSettings.TimeToCompleteVerify : definition.DefaultTimeSettings.TimeToCompleteVerify); float num3 = ((timeSettings.TimeToRestoreFromFail >= 0f) ? timeSettings.TimeToRestoreFromFail : definition.DefaultTimeSettings.TimeToRestoreFromFail); if (uplinkPuzzle.Connected) { __instance.AddOutput((TerminalLineType)3, Text.Get(2734004688u), num2, (TerminalSoundType)0, (TerminalSoundType)0); if (!uplinkPuzzle.Solved && uplinkPuzzle.CurrentRound.CorrectCode.ToUpper() == param1.ToUpper()) { __instance.AddOutput(string.Format(Text.Get(1221800228u), uplinkPuzzle.CurrentProgress), true); if (uplinkPuzzle.TryGoToNextRound()) { int newRoundIndex = uplinkPuzzle.m_roundIndex; int num4 = definition.RoundOverrides.FindIndex((UplinkRound o) => o.RoundIndex == newRoundIndex); UplinkRound newRoundOverride = ((num4 != -1) ? definition.RoundOverrides[num4] : null); roundOverride?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)2, false, 0f); }); if (roundOverride != null && (Object)(object)roundOverride.ChainedPuzzleToEndRoundInstance != (Object)null) { TextDataBlock block = GameDataBlockBase.GetBlock("InGame.UplinkTerminal.ScanRequiredToProgress"); if (block != null) { __instance.AddOutput((TerminalLineType)4, Text.Get(((GameDataBlockBase)(object)block).persistentID), 0f, (TerminalSoundType)0, (TerminalSoundType)0); } ChainedPuzzleInstance chainedPuzzleToEndRoundInstance = roundOverride.ChainedPuzzleToEndRoundInstance; chainedPuzzleToEndRoundInstance.OnPuzzleSolved += Action.op_Implicit((Action)delegate { __instance.AddOutput((TerminalLineType)4, Text.Get(27959760u), timeToCompleteVerify, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); __instance.AddOutput(string.Format(Text.Get(4269617288u), uplinkPuzzle.CurrentProgress, uplinkPuzzle.CurrentRound.CorrectPrefix), true); __instance.OnEndOfQueue = Action.op_Implicit((Action)delegate { EOSLogger.Log("UPLINK VERIFICATION GO TO NEXT ROUND!"); uplinkPuzzle.CurrentRound.ShowGui = true; newRoundOverride?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); UplinkObjectiveManager.Current.ChangeState(__instance.m_terminal, new UplinkState { Status = UplinkStatus.InProgress, CurrentRoundIndex = uplinkPuzzle.m_roundIndex }); }); }); if (SNet.IsMaster) { roundOverride.ChainedPuzzleToEndRoundInstance.AttemptInteract((eChainedPuzzleInteraction)0); } } else { __instance.AddOutput((TerminalLineType)4, Text.Get(27959760u), timeToCompleteVerify, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); __instance.AddOutput(string.Format(Text.Get(4269617288u), uplinkPuzzle.CurrentProgress, uplinkPuzzle.CurrentRound.CorrectPrefix), true); __instance.OnEndOfQueue = Action.op_Implicit((Action)delegate { EOSLogger.Log("UPLINK VERIFICATION GO TO NEXT ROUND!"); uplinkPuzzle.CurrentRound.ShowGui = true; newRoundOverride?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); UplinkObjectiveManager.Current.ChangeState(__instance.m_terminal, new UplinkState { Status = UplinkStatus.InProgress, CurrentRoundIndex = uplinkPuzzle.m_roundIndex }); }); } } else { __instance.AddOutput((TerminalLineType)3, Text.Get(1780488547u), 3f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); __instance.OnEndOfQueue = Action.op_Implicit((Action)delegate { roundOverride?.EventsOnRound.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)2, false, 0f); }); uplinkPuzzle.CurrentRound.ShowGui = false; if (roundOverride != null && (Object)(object)roundOverride.ChainedPuzzleToEndRoundInstance != (Object)null) { ChainedPuzzleInstance chainedPuzzleToEndRoundInstance2 = roundOverride.ChainedPuzzleToEndRoundInstance; chainedPuzzleToEndRoundInstance2.OnPuzzleSolved += Action.op_Implicit((Action)delegate { __instance.AddOutput((TerminalLineType)0, string.Format(Text.Get(3928683780u), uplinkPuzzle.TerminalUplinkIP), 2f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); __instance.OnEndOfQueue = Action.op_Implicit((Action)delegate { EOSLogger.Error("UPLINK VERIFICATION SEQUENCE DONE!"); LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId = 0u; uplinkPuzzle.Solved = true; Action onPuzzleSolved2 = uplinkPuzzle.OnPuzzleSolved; if (onPuzzleSolved2 != null) { onPuzzleSolved2.Invoke(); } UplinkObjectiveManager.Current.ChangeState(__instance.m_terminal, new UplinkState { Status = UplinkStatus.Finished, CurrentRoundIndex = uplinkPuzzle.m_roundIndex }); }); }); if (SNet.IsMaster) { roundOverride.ChainedPuzzleToEndRoundInstance.AttemptInteract((eChainedPuzzleInteraction)0); } } else { __instance.AddOutput((TerminalLineType)0, string.Format(Text.Get(3928683780u), uplinkPuzzle.TerminalUplinkIP), 2f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); EOSLogger.Error("UPLINK VERIFICATION SEQUENCE DONE!"); LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId = 0u; uplinkPuzzle.Solved = true; Action onPuzzleSolved = uplinkPuzzle.OnPuzzleSolved; if (onPuzzleSolved != null) { onPuzzleSolved.Invoke(); } UplinkObjectiveManager.Current.ChangeState(__instance.m_terminal, new UplinkState { Status = UplinkStatus.Finished, CurrentRoundIndex = uplinkPuzzle.m_roundIndex }); } }); } } else if (uplinkPuzzle.Solved) { __instance.AddOutput("", true); __instance.AddOutput((TerminalLineType)1, Text.Get(4080876165u), 0f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput((TerminalLineType)0, Text.Get(4104839742u), 6f, (TerminalSoundType)0, (TerminalSoundType)0); } else { __instance.AddOutput("", true); __instance.AddOutput((TerminalLineType)1, string.Format(Text.Get(507647514u), uplinkPuzzle.CurrentRound.CorrectPrefix), 0f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput((TerminalLineType)0, Text.Get(4104839742u), num3, (TerminalSoundType)0, (TerminalSoundType)0); } } else { __instance.AddOutput("", true); __instance.AddOutput(Text.Get(403360908u), true); } __result = false; return false; } [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalUplinkVerify")] private static void Post_LG_ComputerTerminalCommandInterpreter_TerminalUplinkVerify(LG_ComputerTerminalCommandInterpreter __instance, List __state) { if (__state == null) { return; } __instance.OnEndOfQueue += Action.op_Implicit((Action)delegate { __state.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)1, false, 0f); }); }); } } [HarmonyPatch] internal static class UplinkGUI_Update { [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminal), "Update")] private static void Post_LG_ComputerTerminal_Update(LG_ComputerTerminal __instance) { if (!__instance.m_isWardenObjective && __instance.UplinkPuzzle != null) { __instance.UplinkPuzzle.UpdateGUI(false); } } } } namespace ExtraObjectiveSetup.Patches.PowerGenerator { [HarmonyPatch] internal static class Patch_LG_PowerGeneratorCluster { [HarmonyPostfix] [HarmonyPatch(typeof(LG_PowerGeneratorCluster), "Setup")] private static void Post_PowerGeneratorCluster_Setup(LG_PowerGeneratorCluster __instance) { uint instanceIndex = GeneratorClusterInstanceManager.Current.Register(__instance); (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = GeneratorClusterInstanceManager.Current.GetGlobalZoneIndex(__instance); GeneratorClusterDefinition definition = GeneratorClusterObjectiveManager.Current.GetDefinition(globalZoneIndex, instanceIndex); if (definition == null) { return; } EOSLogger.Debug("Found LG_PowerGeneratorCluster and its definition! Building this Generator cluster..."); __instance.m_serialNumber = SerialGenerator.GetUniqueSerialNo(); __instance.m_itemKey = "GENERATOR_CLUSTER_" + __instance.m_serialNumber; __instance.m_terminalItem = GOUtil.GetInterfaceFromComp(__instance.m_terminalItemComp); __instance.m_terminalItem.Setup(__instance.m_itemKey, (AIG_CourseNode)null); __instance.m_terminalItem.FloorItemStatus = (eFloorInventoryObjectStatus)4; if (__instance.SpawnNode != null) { __instance.m_terminalItem.FloorItemLocation = __instance.SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7); } List list = new List((IEnumerable)__instance.m_generatorAligns); uint numberOfGenerators = definition.NumberOfGenerators; __instance.m_generators = Il2CppReferenceArray.op_Implicit((LG_PowerGenerator_Core[])(object)new LG_PowerGenerator_Core[numberOfGenerators]); if (list.Count >= numberOfGenerators) { for (int i = 0; i < numberOfGenerators; i++) { int index = Builder.BuildSeedRandom.Range(0, list.Count, "NO_TAG"); LG_PowerGenerator_Core val = GOUtil.SpawnChildAndGetComp(__instance.m_generatorPrefab, list[index]); ((Il2CppArrayBase)(object)__instance.m_generators)[i] = val; val.SpawnNode = __instance.SpawnNode; PowerGeneratorInstanceManager.Current.MarkAsGCGenerator(__instance, val); val.Setup(); val.SetCanTakePowerCell(true); Debug.Log(Object.op_Implicit("Spawning generator at alignIndex: " + index)); list.RemoveAt(index); } } else { Debug.LogError(Object.op_Implicit("LG_PowerGeneratorCluster does NOT have enough generator aligns to support the warden objective! Has " + list.Count + " needs " + numberOfGenerators)); } __instance.ObjectiveItemSolved = true; if (definition.EndSequenceChainedPuzzle != 0) { GeneratorClusterObjectiveManager.Current.RegisterForChainedPuzzleBuild(__instance, definition); } } } [HarmonyPatch] internal static class Patch_LG_PowerGenerator_Core_SyncStatusChanged { [HarmonyPostfix] [HarmonyPatch(typeof(LG_PowerGenerator_Core), "SyncStatusChanged")] private static void Post_SyncStatusChanged(LG_PowerGenerator_Core __instance, pPowerGeneratorState state, bool isDropinState) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) uint zoneInstanceIndex = PowerGeneratorInstanceManager.Current.GetZoneInstanceIndex(__instance); (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = PowerGeneratorInstanceManager.Current.GetGlobalZoneIndex(__instance); LG_PowerGeneratorCluster parentGeneratorCluster = PowerGeneratorInstanceManager.Current.GetParentGeneratorCluster(__instance); GeneratorClusterDefinition generatorClusterDefinition = null; if ((Object)(object)parentGeneratorCluster != (Object)null) { uint zoneInstanceIndex2 = GeneratorClusterInstanceManager.Current.GetZoneInstanceIndex(parentGeneratorCluster); (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex2 = GeneratorClusterInstanceManager.Current.GetGlobalZoneIndex(parentGeneratorCluster); generatorClusterDefinition = GeneratorClusterObjectiveManager.Current.GetDefinition(globalZoneIndex2, zoneInstanceIndex2); } ePowerGeneratorStatus status = state.status; if (generatorClusterDefinition != null) { EOSLogger.Log($"LG_PowerGeneratorCluster.powerGenerator.OnSyncStatusChanged! status: {status}, isDropinState: {isDropinState}"); if ((int)status == 0) { uint num = 0u; for (int i = 0; i < ((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators).Length; i++) { if ((int)((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators)[i].m_stateReplicator.State.status == 0) { num++; } } EOSLogger.Log($"Generator Cluster PowerCell inserted ({num} / {((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators).Count})"); List> eventsOnInsertCell = generatorClusterDefinition.EventsOnInsertCell; int num2 = (int)(num - 1); if (!isDropinState) { if (num2 >= 0 && num2 < eventsOnInsertCell.Count) { EOSLogger.Log($"Executing events ({num} / {((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators).Count}). Event count: {eventsOnInsertCell[num2].Count}"); eventsOnInsertCell[num2].ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } if (num == ((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators).Count && !parentGeneratorCluster.m_endSequenceTriggered) { EOSLogger.Log("All generators powered, executing end sequence"); ((MonoBehaviour)__instance).StartCoroutine(parentGeneratorCluster.ObjectiveEndSequence()); parentGeneratorCluster.m_endSequenceTriggered = true; } } else if (num != ((Il2CppArrayBase)(object)parentGeneratorCluster.m_generators).Count) { parentGeneratorCluster.m_endSequenceTriggered = false; } } else if (isDropinState) { parentGeneratorCluster.m_endSequenceTriggered = false; } } IndividualGeneratorDefinition definition = IndividualGeneratorObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (definition != null && definition.EventsOnInsertCell != null && (int)status == 0 && !isDropinState) { definition.EventsOnInsertCell.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } ExpeditionIGGroup expeditionIGGroup = ExpeditionIGGroupManager.Current.FindGroupDefOf(__instance); if (expeditionIGGroup == null) { return; } int num3 = 0; foreach (LG_PowerGenerator_Core generatorInstance in expeditionIGGroup.GeneratorInstances) { if ((int)generatorInstance.m_stateReplicator.State.status == 0) { num3++; } } if (isDropinState) { return; } if (num3 == expeditionIGGroup.GeneratorInstances.Count && expeditionIGGroup.PlayEndSequenceOnGroupComplete) { Coroutine val = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ExpeditionIGGroupManager.PlayGroupEndSequence(expeditionIGGroup)), (Action)null); WorldEventManager.m_worldEventEventCoroutines.Add(val); return; } int num4 = num3 - 1; if (num4 >= 0 && num4 < expeditionIGGroup.EventsOnInsertCell.Count) { expeditionIGGroup.EventsOnInsertCell[num4].ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } } } [HarmonyPatch] internal static class Patch_LG_PowerGenerator_Core_Setup { [HarmonyPostfix] [HarmonyPatch(typeof(LG_PowerGenerator_Core), "Setup")] private static void Post_PowerGenerator_Setup(LG_PowerGenerator_Core __instance) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) iCarryItemInteractionTarget powerCellInteraction = __instance.m_powerCellInteraction; powerCellInteraction.AttemptCarryItemInsert += Action.op_Implicit((Action)delegate(SNet_Player p, Item item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Item val2 = default(Item); if (PlayerBackpackManager.TryGetItemInLevelFromItemData(item.Get_pItemData(), ref val2)) { ((Il2CppObjectBase)val2).Cast().CanWarp = false; } else { EOSLogger.Error($"Inserting sth other than PowerCell ({item.PublicName}) into {__instance.m_itemKey}, how?"); } }); if (PowerGeneratorInstanceManager.Current.IsGCGenerator(__instance)) { return; } uint num = PowerGeneratorInstanceManager.Current.Register(__instance); (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = PowerGeneratorInstanceManager.Current.GetGlobalZoneIndex(__instance); IndividualGeneratorDefinition definition = IndividualGeneratorObjectiveManager.Current.GetDefinition(globalZoneIndex, num); if (definition != null) { Vector3 val = definition.Position.ToVector3(); Quaternion rotation = definition.Rotation.ToQuaternion(); if (val != Vector3.zero) { ((Component)__instance).transform.position = val; ((Component)__instance).transform.rotation = rotation; __instance.m_sound.UpdatePosition(val); EOSLogger.Debug("LG_PowerGenerator_Core: modified position / rotation"); } if (definition.ForceAllowPowerCellInsertion) { __instance.SetCanTakePowerCell(true); } EOSLogger.Debug($"LG_PowerGenerator_Core: overriden, instance {num} in {globalZoneIndex}"); } } [HarmonyPostfix] [HarmonyPatch(typeof(LG_PowerGenerator_Core), "SyncStatusChanged")] private static void Post_SyncStatusChanged(LG_PowerGenerator_Core __instance, pPowerGeneratorState state, bool isDropinState) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 uint zoneInstanceIndex = PowerGeneratorInstanceManager.Current.GetZoneInstanceIndex(__instance); (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = PowerGeneratorInstanceManager.Current.GetGlobalZoneIndex(__instance); IndividualGeneratorDefinition definition = IndividualGeneratorObjectiveManager.Current.GetDefinition(globalZoneIndex, zoneInstanceIndex); if (!(definition == null || definition.EventsOnInsertCell == null || (int)state.status > 0 || isDropinState) && definition.EventsOnInsertCell.Count > 0) { definition.EventsOnInsertCell.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } } } } namespace ExtraObjectiveSetup.Patches.Terminal { [HarmonyPatch] internal static class Patch_FixHiddenCommandExecution { [HarmonyPrefix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")] private static void Pre_TerminalInterpreter_ReceiveCommand(LG_ComputerTerminalCommandInterpreter __instance, ref TERM_Command cmd) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected I4, but got Unknown TERM_Command val = cmd; switch (val - 1) { case 0: case 1: case 2: case 3: case 11: case 13: case 14: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 31: case 32: case 33: case 42: if (__instance.m_terminal.CommandIsHidden(cmd)) { cmd = (TERM_Command)10; } break; case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 12: case 15: case 16: case 29: case 30: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: break; } } } [HarmonyPatch] internal static class Patch_FixReactorTerminalNullSpawnNode { [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static bool Pre(LG_ComputerTerminal __instance, ref AIG_CourseNode __result) { if ((Object)(object)__instance.ConnectedReactor != (Object)null && __instance.m_terminalItem.SpawnNode == null) { __result = __instance.ConnectedReactor.SpawnNode; return false; } return true; } } [HarmonyPatch] internal static class Patch_FixRepeatablePuzzleBugs { [HarmonyPrefix] [HarmonyPatch(typeof(CP_Cluster_Core), "OnSyncStateChange")] private static bool Pre_CheckEventsOnPuzzleSolved(CP_Cluster_Core __instance, eClusterStatus newStatus, bool isDropinState) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 pClusterState currentState = __instance.m_sync.GetCurrentState(); if (isDropinState && (int)newStatus == 3) { __instance.m_spline.SetVisible(false); for (int i = 0; i < ((Il2CppArrayBase)(object)__instance.m_childCores).Length; i++) { ((Il2CppArrayBase)(object)__instance.m_childCores)[i].Deactivate(); } return false; } if (!isDropinState && (int)currentState.status == 3 && (int)newStatus == 1) { __instance.m_spline.Reveal(0f); return false; } return true; } } [HarmonyPatch] internal static class Patch_LG_ComputerTerminal_Setup { [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminal), "Setup")] private static void Post_LG_ComputerTerminal_Setup(LG_ComputerTerminal __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) uint instanceIndex = TerminalInstanceManager.Current.Register(__instance); TerminalInstanceManager.Current.SetupTerminalWrapper(__instance); if (__instance.SpawnNode == null) { return; } (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = TerminalInstanceManager.Current.GetGlobalZoneIndex(__instance); TerminalPosition definition = TerminalPositionOverrideManager.Current.GetDefinition(globalZoneIndex, instanceIndex); if (definition != null) { if (definition.Position.ToVector3() != Vector3.zeroVector) { ((Component)__instance).transform.position = definition.Position.ToVector3(); ((Component)__instance).transform.rotation = definition.Rotation.ToQuaternion(); } EOSLogger.Debug($"TerminalPositionOverride: {definition.LocalIndex}, {definition.LayerType}, {definition.DimensionIndex}, TerminalIndex {definition.InstanceIndex}"); } } [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminal), "SetupAsWardenObjectiveTerminalUplink")] [HarmonyPatch(typeof(LG_ComputerTerminal), "SetupAsWardenObjectiveCorruptedTerminalUplink")] private static void Post_LG_ComputerTerminal_UplinkSetup(LG_ComputerTerminal __instance) { TerminalInstanceManager.Current.RegisterWardenUplink(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(TerminalUplinkPuzzle), "Setup")] private static void Post_LG_ComputerTerminal_SyncedPuzzle(TerminalUplinkPuzzle __instance, LG_ComputerTerminal terminal) { if (!terminal.m_isWardenObjective) { return; } UplinkDefinition def = UplinkObjectiveManager.Current.GetWardenDefinition(terminal); if (def == null) { return; } __instance.OnPuzzleSolved += Action.op_Implicit((Action)delegate { def.EventsOnComplete?.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); }); } } [HarmonyPatch] internal static class Patch_RepeatableCommandEventFix { [HarmonyPostfix] [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "SetupCommandEvents")] private static void Post_ResetRepeatableUniqueCommandChainedPuzzle(LG_ComputerTerminalCommandInterpreter __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) LG_ComputerTerminal terminal = __instance.m_terminal; ChainedPuzzleInstance val = default(ChainedPuzzleInstance); foreach (TERM_Command uNIQUE_CMD in TerminalInstanceManager.UNIQUE_CMDS) { if (!__instance.m_commandsPerEnum.ContainsKey(uNIQUE_CMD)) { continue; } string text = __instance.m_commandsPerEnum[uNIQUE_CMD]; if ((int)__instance.m_terminal.GetCommandRule(uNIQUE_CMD) != 0) { continue; } List uniqueCommandEvents = __instance.m_terminal.GetUniqueCommandEvents(text); for (int i = 0; i < uniqueCommandEvents.Count; i++) { if (uniqueCommandEvents[i].ChainPuzzle != 0) { if (__instance.m_terminal.TryGetChainPuzzleForCommand(uNIQUE_CMD, i, ref val) && (Object)(object)val != (Object)null) { ChainedPuzzleInstance obj = val; obj.OnPuzzleSolved += Action.op_Implicit((Action)val.ResetProgress); } EOSLogger.Debug($"TerminalTweak: {terminal.ItemKey}, command {text} set to be repeatable!"); } } } } } } namespace ExtraObjectiveSetup.Patches.LGFactory { [HarmonyPatch] internal class Patch_LG_Factory_NextBatch { [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(LG_Factory), "NextBatch")] private static void Prefix(LG_Factory __instance) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_batchStep > -1) { BatchName currentBatchName = __instance.m_currentBatchName; BatchBuildManager.Current.Get_OnBatchDone(currentBatchName)?.Invoke(); } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch(typeof(LG_Factory), "NextBatch")] private static void Postfix(LG_Factory __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) BatchBuildManager.Current.Get_OnBatchStart(__instance.m_currentBatchName)?.Invoke(); } } } namespace ExtraObjectiveSetup.Patches.HSUActivator { [HarmonyPatch] internal class SetupFromCustomGeomorph { [HarmonyPostfix] [HarmonyPatch(typeof(LG_HSUActivator_Core), "SetupFromCustomGeomorph")] private static void Post_LG_HSUActivator_Core_SetupFromCustomGeomorph(LG_HSUActivator_Core __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) uint instanceIndex = HSUActivatorInstanceManager.Current.Register(__instance); HSUActivatorDefinition definition = HSUActivatorObjectiveManager.Current.GetDefinition(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, instanceIndex); if (definition == null) { return; } if (__instance.m_isWardenObjective) { EOSLogger.Error("BuildCustomHSUActivator: the HSUActivator has been set up by vanilla! Aborting custom setup..."); EOSLogger.Error($"HSUActivator in {__instance.SpawnNode.m_zone.LocalIndex}, {__instance.SpawnNode.LayerType}, {__instance.SpawnNode.m_dimension.DimensionIndex}"); return; } __instance.m_linkedItemGoingIn = __instance.SpawnPickupItemOnAlign(definition.ItemFromStart, __instance.m_itemGoingInAlign, false, -1); __instance.m_linkedItemComingOut = __instance.SpawnPickupItemOnAlign(definition.ItemAfterActivation, __instance.m_itemComingOutAlign, false, -1); LG_LevelInteractionManager.DeregisterTerminalItem(((Component)__instance.m_linkedItemGoingIn).GetComponentInChildren()); LG_LevelInteractionManager.DeregisterTerminalItem(((Component)__instance.m_linkedItemComingOut).GetComponentInChildren()); __instance.m_linkedItemGoingIn.SetPickupInteractionEnabled(false); __instance.m_linkedItemComingOut.SetPickupInteractionEnabled(false); __instance.m_insertHSUInteraction.OnInteractionSelected = Action.op_Implicit((Action)delegate { }); __instance.m_sequencerInsertItem.OnSequenceDone = Action.op_Implicit((Action)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) pHSUActivatorState state2 = __instance.m_stateReplicator.State; if (!state2.isSequenceIncomplete) { EOSLogger.Log(">>>>>> HSUInsertSequenceDone! Sequence was already complete"); } state2.isSequenceIncomplete = false; __instance.m_stateReplicator.SetStateUnsynced(state2); EOSLogger.Log(">>>>>> HSUInsertSequenceDone!"); if (__instance.m_triggerExtractSequenceRoutine != null) { ((MonoBehaviour)__instance).StopCoroutine(__instance.m_triggerExtractSequenceRoutine); } }); __instance.m_sequencerExtractItem.OnSequenceDone = Action.op_Implicit((Action)delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) SNet_StateReplicator stateReplicator = __instance.m_stateReplicator; pHSUActivatorState state = __instance.m_stateReplicator.State; state.isSequenceIncomplete = true; stateReplicator.SetStateUnsynced(state); if (SNet.IsMaster) { __instance.AttemptInteract(new pHSUActivatorInteraction { type = (eHSUActivatorInteractionType)2 }); } }); EOSLogger.Debug($"HSUActivator: {(definition.DimensionIndex, definition.LayerType, definition.LocalIndex, definition.InstanceIndex)}, custom setup complete"); } } [HarmonyPatch] internal class SyncStatusChanged { [HarmonyPrefix] [HarmonyPatch(typeof(LG_HSUActivator_Core), "SyncStatusChanged")] private static bool Pre_LG_HSUActivator_Core_SyncStatusChanged(LG_HSUActivator_Core __instance, pHSUActivatorState newState, bool isRecall) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected I4, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_isWardenObjective) { return true; } uint zoneInstanceIndex = HSUActivatorInstanceManager.Current.GetZoneInstanceIndex(__instance); if (zoneInstanceIndex == uint.MaxValue) { EOSLogger.Error($"Found unregistered HSUActivator!! {HSUActivatorInstanceManager.Current.GetGlobalZoneIndex(__instance)}"); return true; } HSUActivatorDefinition definition = HSUActivatorObjectiveManager.Current.GetDefinition(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, zoneInstanceIndex); if (definition == null) { return true; } if (__instance.m_triggerExtractSequenceRoutine != null) { ((MonoBehaviour)__instance).StopCoroutine(__instance.m_triggerExtractSequenceRoutine); } bool goingInVisibleForPostCulling = __instance.m_goingInVisibleForPostCulling; bool comingOutVisibleForPostCulling = __instance.m_comingOutVisibleForPostCulling; EOSLogger.Debug("LG_HSUActivator_Core.OnSyncStatusChanged " + ((object)(eHSUActivatorStatus)(ref newState.status)).ToString()); eHSUActivatorStatus status = newState.status; switch ((int)status) { case 0: __instance.m_insertHSUInteraction.SetActive(true); __instance.ResetItem(__instance.m_itemGoingInAlign, __instance.m_linkedItemGoingIn, false, false, true, ref goingInVisibleForPostCulling); __instance.ResetItem(__instance.m_itemComingOutAlign, __instance.m_linkedItemComingOut, false, false, true, ref comingOutVisibleForPostCulling); __instance.m_sequencerWaitingForItem.StartSequence(); __instance.m_sequencerInsertItem.StopSequence(); __instance.m_sequencerExtractItem.StopSequence(); __instance.m_sequencerExtractionDone.StopSequence(); break; case 1: __instance.m_insertHSUInteraction.SetActive(false); __instance.ResetItem(__instance.m_itemGoingInAlign, __instance.m_linkedItemGoingIn, true, false, true, ref goingInVisibleForPostCulling); __instance.ResetItem(__instance.m_itemComingOutAlign, __instance.m_linkedItemComingOut, false, false, true, ref comingOutVisibleForPostCulling); __instance.m_sequencerWaitingForItem.StopSequence(); if (!isRecall) { __instance.m_sequencerInsertItem.StartSequence(); definition.EventsOnHSUActivation.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); ChainedPuzzleInstance chainedPuzzleOnActivationInstance = definition.ChainedPuzzleOnActivationInstance; if (SNet.IsMaster && (Object)(object)chainedPuzzleOnActivationInstance != (Object)null) { definition.ChainedPuzzleOnActivationInstance.AttemptInteract((eChainedPuzzleInteraction)0); } } __instance.m_sequencerExtractItem.StopSequence(); __instance.m_sequencerExtractionDone.StopSequence(); break; case 2: __instance.m_insertHSUInteraction.SetActive(false); __instance.ResetItem(__instance.m_itemGoingInAlign, __instance.m_linkedItemGoingIn, !__instance.m_showItemComingOut, false, true, ref goingInVisibleForPostCulling); __instance.ResetItem(__instance.m_itemComingOutAlign, __instance.m_linkedItemComingOut, __instance.m_showItemComingOut, false, true, ref comingOutVisibleForPostCulling); __instance.m_sequencerWaitingForItem.StopSequence(); __instance.m_sequencerInsertItem.StopSequence(); __instance.m_sequencerExtractItem.StartSequence(); __instance.m_sequencerExtractionDone.StopSequence(); break; case 3: __instance.m_insertHSUInteraction.SetActive(false); __instance.ResetItem(__instance.m_itemGoingInAlign, __instance.m_linkedItemGoingIn, !__instance.m_showItemComingOut, false, true, ref goingInVisibleForPostCulling); __instance.ResetItem(__instance.m_itemComingOutAlign, __instance.m_linkedItemComingOut, __instance.m_showItemComingOut, definition.TakeOutItemAfterActivation, false, ref comingOutVisibleForPostCulling); __instance.m_sequencerWaitingForItem.StopSequence(); __instance.m_sequencerInsertItem.StopSequence(); __instance.m_sequencerExtractItem.StopSequence(); __instance.m_sequencerExtractionDone.StartSequence(); if (newState.isSequenceIncomplete) { __instance.HSUInsertSequenceDone(); } break; } return false; } } } namespace ExtraObjectiveSetup.Patches.Expedition { [HarmonyPatch] internal class GearManager_LoadOfflineGearDatas { [HarmonyPostfix] [HarmonyPatch(typeof(GearManager), "LoadOfflineGearDatas")] private static void Post_GearManager_LoadOfflineGearDatas(GearManager __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown ExpeditionGearManager.Current.VanillaGearManager = __instance; foreach (var gearSlot in ExpeditionGearManager.Current.GearSlots) { Enumerator enumerator2 = ((Il2CppArrayBase>)(object)__instance.m_gearPerSlot)[(int)gearSlot.inventorySlot].GetEnumerator(); while (enumerator2.MoveNext()) { GearIDRange current2 = enumerator2.Current; uint offlineGearPID = ExpeditionGearManager.GetOfflineGearPID(current2); gearSlot.loadedGears.Add(offlineGearPID, current2); } } } } [HarmonyPatch] [HarmonyWrapSafe] internal class DisabelMap { } [HarmonyPatch] internal class RundownManager_SetActiveExpedition { [HarmonyPostfix] [HarmonyPatch(typeof(RundownManager), "SetActiveExpedition")] private static void Post_RundownManager_SetActiveExpedition(RundownManager __instance, pActiveExpedition expPackage, ExpeditionInTierData expTierData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)expPackage.tier != 99) { ExpeditionGearManager.Current.SetupAllowedGearsForActiveExpedition(); } } } } namespace ExtraObjectiveSetup.Patches.ChainedPuzzle { [HarmonyPatch] internal static class ChainedPuzzleManager_CreatePuzzleInstance { [HarmonyPostfix] [HarmonyPatch(typeof(ChainedPuzzleManager), "CreatePuzzleInstance", new Type[] { typeof(ChainedPuzzleDataBlock), typeof(LG_Area), typeof(LG_Area), typeof(Vector3), typeof(Transform), typeof(bool) })] private static void Post_ChainedPuzzleInstance_Setup(ChainedPuzzleInstance __result) { ChainedPuzzleInstanceManager.Current.Register(__result); } } [HarmonyPatch] internal static class ChainedPuzzleInstance_OnStateChange { [HarmonyPostfix] [HarmonyPatch(typeof(ChainedPuzzleInstance), "OnStateChange")] private static void Post_ChainedPuzzleOnActivationInstance_OnStateChange(ChainedPuzzleInstance __instance, pChainedPuzzleState oldState, pChainedPuzzleState newState, bool isRecall) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ChainedPuzzleInstanceManager.Current.Get_OnStateChange(__instance)?.Invoke(oldState, newState, isRecall); } } } namespace ExtraObjectiveSetup.Objectives.TerminalUplink { public enum UplinkTerminal { SENDER, RECEIVER } public class Terminal { public eDimensionIndex DimensionIndex { get; set; } public LG_LayerType LayerType { get; set; } public eLocalZoneIndex LocalIndex { get; set; } public uint InstanceIndex { get; set; } = uint.MaxValue; } public class UplinkRound { public int RoundIndex { get; set; } = -1; public uint ChainedPuzzleToEndRound { get; set; } public UplinkTerminal BuildChainedPuzzleOn { get; set; } [JsonIgnore] public ChainedPuzzleInstance ChainedPuzzleToEndRoundInstance { get; set; } public TimeSettings OverrideTimeSettings { get; set; } = new TimeSettings { TimeToStartVerify = -1f, TimeToCompleteVerify = -1f, TimeToRestoreFromFail = -1f }; public List EventsOnRound { get; set; } = new List(); } public class TimeSettings { public float TimeToStartVerify { get; set; } = 5f; public float TimeToCompleteVerify { get; set; } = 6f; public float TimeToRestoreFromFail { get; set; } = 6f; } public class UplinkDefinition : BaseInstanceDefinition { public int WardenObjectiveIndex { get; set; } = -1; public bool DisplayUplinkWarning { get; set; } = true; public bool SetupAsCorruptedUplink { get; set; } public Terminal CorruptedUplinkReceiver { get; set; } = new Terminal(); public bool UseUplinkAddress { get; set; } = true; public Terminal UplinkAddressLogPosition { get; set; } = new Terminal(); public uint ChainedPuzzleToStartUplink { get; set; } public uint NumberOfVerificationRounds { get; set; } = 1u; public TimeSettings DefaultTimeSettings { get; set; } = new TimeSettings(); public List RoundOverrides { get; set; } = new List { new UplinkRound() }; public List EventsOnCommence { get; set; } = new List(); public List EventsOnComplete { get; set; } = new List(); } internal sealed class UplinkObjectiveManager : InstanceDefinitionManager { private TextDataBlock UplinkAddrLogContentBlock; private Dictionary> stateReplicators = new Dictionary>(); private List builtRoundPuzzles = new List(); public static UplinkObjectiveManager Current { get; private set; } private Dictionary wardenUplinkDefs { get; } = new Dictionary(); protected override string DEFINITION_NAME { get; } = "TerminalUplink"; protected override void AddDefinitions(InstanceDefinitionsForLevel definitions) { Sort(definitions); definitions.Definitions.ForEach(delegate(UplinkDefinition u) { u.RoundOverrides.Sort(delegate(UplinkRound r1, UplinkRound r2) { if (r1.RoundIndex == r2.RoundIndex) { return 0; } return (r1.RoundIndex >= r2.RoundIndex) ? 1 : (-1); }); }); base.AddDefinitions(definitions); } public UplinkDefinition GetWardenDefinition(LG_ComputerTerminal terminal) { return wardenUplinkDefs.GetValueOrDefault(((Il2CppObjectBase)terminal).Pointer); } private void Build(UplinkDefinition def) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Expected O, but got Unknown //IL_0455: Expected O, but got Unknown //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) if (def.WardenObjectiveIndex >= 0) { LG_ComputerTerminal wardenUplink = TerminalInstanceManager.Current.GetWardenUplink(def.LayerType, def.WardenObjectiveIndex); if ((Object)(object)wardenUplink == (Object)null || !wardenUplink.m_isWardenObjective || ((int)wardenUplink.WardenObjectiveType != 1 && (int)wardenUplink.WardenObjectiveType != 2)) { EOSLogger.Error($"BuildUplink: warden objective uplink not built, aborting! (Null: {(Object)(object)wardenUplink == (Object)null}, IsWarden: {((wardenUplink != null) ? new bool?(wardenUplink.m_isWardenObjective) : null)}, ObjectiveType: {((wardenUplink != null) ? new TERM_WO_Type?(wardenUplink.WardenObjectiveType) : null)})"); } else { wardenUplinkDefs.TryAdd(((Il2CppObjectBase)wardenUplink).Pointer, def); } return; } LG_ComputerTerminal uplinkTerminal = TerminalInstanceManager.Current.GetInstance(def.DimensionIndex, def.LayerType, def.LocalIndex, def.InstanceIndex); if ((Object)(object)uplinkTerminal == (Object)null) { return; } if (uplinkTerminal.m_isWardenObjective) { EOSLogger.Error("BuildUplink: terminal uplink already built (by vanilla or custom build), aborting!"); return; } if (def.SetupAsCorruptedUplink) { LG_ComputerTerminal instance = TerminalInstanceManager.Current.GetInstance(def.CorruptedUplinkReceiver.DimensionIndex, def.CorruptedUplinkReceiver.LayerType, def.CorruptedUplinkReceiver.LocalIndex, def.CorruptedUplinkReceiver.InstanceIndex); if ((Object)(object)instance == (Object)null) { EOSLogger.Error("BuildUplink: SetupAsCorruptedUplink specified but didn't find the receiver terminal!"); return; } if (((Il2CppObjectBase)instance).Pointer == ((Il2CppObjectBase)uplinkTerminal).Pointer) { EOSLogger.Error("BuildUplink: Don't specify uplink sender and receiver on the same terminal"); return; } uplinkTerminal.CorruptedUplinkReceiver = instance; instance.CorruptedUplinkReceiver = uplinkTerminal; } uplinkTerminal.UplinkPuzzle = new TerminalUplinkPuzzle(); SetupUplinkPuzzle(uplinkTerminal.UplinkPuzzle, uplinkTerminal, def); TerminalUplinkPuzzle uplinkPuzzle = uplinkTerminal.UplinkPuzzle; uplinkPuzzle.OnPuzzleSolved += Action.op_Implicit((Action)delegate { def.EventsOnComplete?.ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); }); uplinkTerminal.m_command.AddCommand((TERM_Command)(((Object)(object)uplinkTerminal.CorruptedUplinkReceiver == (Object)null) ? 25 : 33), def.UseUplinkAddress ? "UPLINK_CONNECT" : "UPLINK_ESTABLISH", new LocalizedText { UntranslatedText = Text.Get(3914968919u), Id = 3914968919u }, (TERM_CommandRule)0); uplinkTerminal.m_command.AddCommand((TERM_Command)26, "UPLINK_VERIFY", new LocalizedText { UntranslatedText = Text.Get(1728022075u), Id = 1728022075u }, (TERM_CommandRule)0); if (def.UseUplinkAddress) { LG_ComputerTerminal val = null; EOSLogger.Debug("BuildUplinkOverride: UseUplinkAddress"); val = TerminalInstanceManager.Current.GetInstance(def.UplinkAddressLogPosition.DimensionIndex, def.UplinkAddressLogPosition.LayerType, def.UplinkAddressLogPosition.LocalIndex, def.UplinkAddressLogPosition.InstanceIndex); if ((Object)(object)val == (Object)null) { EOSLogger.Error("BuildUplinkOverride: didn't find the terminal to put the uplink address log, will put on uplink terminal"); val = uplinkTerminal; } val.AddLocalLog(new TerminalLogFileData { FileName = $"UPLINK_ADDR_{uplinkTerminal.m_serialNumber}.LOG", FileContent = new LocalizedText { UntranslatedText = string.Format((UplinkAddrLogContentBlock != null) ? Text.Get(((GameDataBlockBase)(object)UplinkAddrLogContentBlock).persistentID) : "Available uplink address for TERMINAL_{0}: {1}", uplinkTerminal.m_serialNumber, uplinkTerminal.UplinkPuzzle.TerminalUplinkIP), Id = 0u } }, true); val.m_command.ClearOutputQueueAndScreenBuffer(); val.m_command.AddInitialTerminalOutput(); } if (def.ChainedPuzzleToStartUplink != 0) { ChainedPuzzleDataBlock block = GameDataBlockBase.GetBlock(def.ChainedPuzzleToStartUplink); if (block == null) { EOSLogger.Error($"BuildTerminalUplink: ChainedPuzzleToActive with id {def.ChainedPuzzleToStartUplink} is specified but no ChainedPuzzleDataBlock definition is found... Won't build"); uplinkTerminal.m_chainPuzzleForWardenObjective = null; } else { uplinkTerminal.m_chainPuzzleForWardenObjective = ChainedPuzzleManager.CreatePuzzleInstance(block, uplinkTerminal.SpawnNode.m_area, uplinkTerminal.m_wardenObjectiveSecurityScanAlign.position, uplinkTerminal.m_wardenObjectiveSecurityScanAlign); if (def.SetupAsCorruptedUplink) { uplinkTerminal.m_chainPuzzleForWardenObjective.Add_OnStateChange(delegate(pChainedPuzzleState oldState, pChainedPuzzleState newState, bool isRecall) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if (oldState.status != newState.status && (int)newState.status == 2 && !isRecall) { uplinkTerminal.CorruptedUplinkReceiver.m_command.StartTerminalUplinkSequence(string.Empty, true); ChangeState(uplinkTerminal, new UplinkState { Status = UplinkStatus.InProgress, CurrentRoundIndex = 0 }); } }); } else { uplinkTerminal.m_chainPuzzleForWardenObjective.Add_OnStateChange(delegate(pChainedPuzzleState oldState, pChainedPuzzleState newState, bool isRecall) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if (oldState.status != newState.status && (int)newState.status == 2 && !isRecall) { uplinkTerminal.m_command.StartTerminalUplinkSequence(uplinkTerminal.UplinkPuzzle.TerminalUplinkIP, false); } }); } } } foreach (UplinkRound roundOverride in def.RoundOverrides) { if (roundOverride.ChainedPuzzleToEndRound == 0) { continue; } ChainedPuzzleDataBlock block2 = GameDataBlockBase.GetBlock(roundOverride.ChainedPuzzleToEndRound); if (block2 != null) { LG_ComputerTerminal val2 = null; switch (roundOverride.BuildChainedPuzzleOn) { case UplinkTerminal.SENDER: val2 = uplinkTerminal; break; case UplinkTerminal.RECEIVER: if (def.SetupAsCorruptedUplink && (Object)(object)uplinkTerminal.CorruptedUplinkReceiver != (Object)null) { val2 = uplinkTerminal.CorruptedUplinkReceiver; break; } EOSLogger.Error($"ChainedPuzzleToEndRound: {roundOverride.ChainedPuzzleToEndRound} specified to build on receiver but this is not a properly setup-ed corr-uplink! Will build ChainedPuzzle on sender side"); val2 = uplinkTerminal; break; default: EOSLogger.Error($"Unimplemented enum UplinkTerminal type {roundOverride.BuildChainedPuzzleOn}"); continue; } roundOverride.ChainedPuzzleToEndRoundInstance = ChainedPuzzleManager.CreatePuzzleInstance(block2, val2.SpawnNode.m_area, val2.m_wardenObjectiveSecurityScanAlign.position, val2.m_wardenObjectiveSecurityScanAlign); builtRoundPuzzles.Add(roundOverride); } else { EOSLogger.Error($"ChainedPuzzleToEndRound: {roundOverride.ChainedPuzzleToEndRound} specified but didn't find its ChainedPuzzleDatablock definition! Will not build!"); } } SetupUplinkReplicator(uplinkTerminal); EOSLogger.Debug($"BuildUplink: built on {(def.DimensionIndex, def.LayerType, def.LocalIndex, def.InstanceIndex)}"); } private void SetupUplinkPuzzle(TerminalUplinkPuzzle uplinkPuzzle, LG_ComputerTerminal terminal, UplinkDefinition def) { //IL_0030: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown uplinkPuzzle.m_rounds = ListExtensions.ToIl2Cpp(new List()); uplinkPuzzle.TerminalUplinkIP = SerialGenerator.GetIpAddress(); uplinkPuzzle.m_roundIndex = 0; uplinkPuzzle.m_lastRoundIndexToUpdateGui = -1; uplinkPuzzle.m_position = ((Component)terminal).transform.position; uplinkPuzzle.IsCorrupted = def.SetupAsCorruptedUplink && (Object)(object)terminal.CorruptedUplinkReceiver != (Object)null; uplinkPuzzle.m_terminal = terminal; uint num = Math.Max(def.NumberOfVerificationRounds, 1u); for (int i = 0; i < num; i++) { int num2 = 6; TerminalUplinkPuzzleRound val = new TerminalUplinkPuzzleRound { CorrectIndex = Builder.SessionSeedRandom.Range(0, num2, "NO_TAG"), Prefixes = Il2CppStringArray.op_Implicit(new string[num2]), Codes = Il2CppStringArray.op_Implicit(new string[num2]) }; for (int j = 0; j < num2; j++) { ((Il2CppArrayBase)(object)val.Codes)[j] = SerialGenerator.GetCodeWord(); ((Il2CppArrayBase)(object)val.Prefixes)[j] = SerialGenerator.GetCodeWordPrefix(); } uplinkPuzzle.m_rounds.Add(val); } } private void SetupUplinkReplicator(LG_ComputerTerminal uplinkTerminal) { uint num = EOSNetworking.AllotReplicatorID(); if (num == 0) { EOSLogger.Error("BuildUplink: Cannot create state replicator!"); return; } StateReplicator val = StateReplicator.Create(num, new UplinkState { Status = UplinkStatus.Unfinished }, (LifeTimeType)1, (IStateReplicatorHolder)null); val.OnStateChanged += delegate(UplinkState oldState, UplinkState newState, bool isRecall) { if (oldState.Status != newState.Status) { EOSLogger.Log($"Uplink - OnStateChanged: {oldState.Status} -> {newState.Status}"); switch (newState.Status) { case UplinkStatus.Unfinished: uplinkTerminal.UplinkPuzzle.CurrentRound.ShowGui = false; uplinkTerminal.UplinkPuzzle.Connected = false; uplinkTerminal.UplinkPuzzle.Solved = false; uplinkTerminal.UplinkPuzzle.m_roundIndex = 0; break; case UplinkStatus.InProgress: uplinkTerminal.UplinkPuzzle.CurrentRound.ShowGui = true; uplinkTerminal.UplinkPuzzle.Connected = true; uplinkTerminal.UplinkPuzzle.Solved = false; uplinkTerminal.UplinkPuzzle.m_roundIndex = newState.CurrentRoundIndex; break; case UplinkStatus.Finished: uplinkTerminal.UplinkPuzzle.CurrentRound.ShowGui = false; uplinkTerminal.UplinkPuzzle.Connected = true; uplinkTerminal.UplinkPuzzle.Solved = true; uplinkTerminal.UplinkPuzzle.m_roundIndex = uplinkTerminal.UplinkPuzzle.m_rounds.Count - 1; break; } } }; stateReplicators[((Il2CppObjectBase)uplinkTerminal).Pointer] = val; EOSLogger.Debug("BuildUplink: Replicator created"); } internal void ChangeState(LG_ComputerTerminal terminal, UplinkState newState) { if (!stateReplicators.ContainsKey(((Il2CppObjectBase)terminal).Pointer)) { EOSLogger.Error(terminal.ItemKey + " doesn't have a registered StateReplicator!"); } else if (SNet.IsMaster) { stateReplicators[((Il2CppObjectBase)terminal).Pointer].SetState(newState); } } private void OnBuildDone() { if (definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { if (UplinkAddrLogContentBlock == null) { UplinkAddrLogContentBlock = GameDataBlockBase.GetBlock("InGame.UplinkTerminal.UplinkAddrLog"); } definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions.ForEach(Build); } } private void Clear() { builtRoundPuzzles.ForEach(delegate(UplinkRound r) { r.ChainedPuzzleToEndRoundInstance = null; }); builtRoundPuzzles.Clear(); wardenUplinkDefs.Clear(); stateReplicators.Clear(); } static UplinkObjectiveManager() { Current = new UplinkObjectiveManager(); } private UplinkObjectiveManager() { LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnBuildStart += Clear; } } public enum UplinkStatus { Unfinished, InProgress, Finished } public struct UplinkState { public UplinkStatus Status { get; set; } public int CurrentRoundIndex { get; set; } public UplinkState() { Status = UplinkStatus.Unfinished; CurrentRoundIndex = 0; } public UplinkState(UplinkState o) { Status = UplinkStatus.Unfinished; CurrentRoundIndex = 0; CurrentRoundIndex = o.CurrentRoundIndex; Status = o.Status; } } } namespace ExtraObjectiveSetup.Objectives.ObjectiveCounter { public struct CounterStatus { public int Count; public CounterStatus() { Count = 0; } } public class Counter { public ObjectiveCounterDefinition def { get; private set; } public string WorldEventObjectFilter => def.WorldEventObjectFilter; public int CurrentCount => StateReplicator?.State.Count ?? 0; public StateReplicator StateReplicator { get; private set; } private void OnStateChanged(CounterStatus oldStatus, CounterStatus newStatus, bool isRecall) { } private void ReachTo(int count) { def.OnReached.FindAll((OnCounter Counter) => Counter.Count == count).ForEach(delegate(OnCounter Counter) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(ListExtensions.ToIl2Cpp(Counter.EventsOnReached), (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray)null); }); EOSLogger.Debug($"Counter '{WorldEventObjectFilter}' reached to {count}"); } public void Increment(int by) { if (by > 0) { int num = CurrentCount + by; for (int i = CurrentCount + 1; i <= num; i++) { ReachTo(i); } StateReplicator.SetStateUnsynced(new CounterStatus { Count = num }); } } public void Decrement(int by) { if (by > 0) { int num = CurrentCount - by; for (int num2 = CurrentCount - 1; num2 >= num; num2--) { ReachTo(num2); } StateReplicator.SetStateUnsynced(new CounterStatus { Count = num }); } } internal bool TrySetupReplicator() { uint num = EOSNetworking.AllotReplicatorID(); if (num == 0) { return false; } StateReplicator = StateReplicator.Create(num, new CounterStatus { Count = def.StartingCount }, (LifeTimeType)1, (IStateReplicatorHolder)null); StateReplicator.OnStateChanged += OnStateChanged; return true; } public Counter(ObjectiveCounterDefinition def) { this.def = def; } } public enum CounterWardenEvent { ChangeCounter = 500 } public class OnCounter { public int Count { get; set; } = -1; public List EventsOnReached { get; set; } = new List(); } public class ObjectiveCounterDefinition { public string WorldEventObjectFilter { get; set; } = string.Empty; public int StartingCount { get; set; } public List OnReached { get; set; } = new List { new OnCounter() }; } public class ObjectiveCounterManager : GenericExpeditionDefinitionManager { public static ObjectiveCounterManager Current { get; } private Dictionary Counters { get; } = new Dictionary(); protected override string DEFINITION_NAME => "ObjectiveCounter"; private void Build(ObjectiveCounterDefinition def) { if (Counters.ContainsKey(def.WorldEventObjectFilter)) { EOSLogger.Error("Build Counter: counter '" + def.WorldEventObjectFilter + "' already exists..."); return; } Counter counter = new Counter(def); if (!counter.TrySetupReplicator()) { EOSLogger.Error("Build Counter: counter '" + def.WorldEventObjectFilter + "' failed to setup state replicator! What's going wrong?"); return; } Counters[def.WorldEventObjectFilter] = counter; EOSLogger.Debug("Build Counter: counter '" + def.WorldEventObjectFilter + "' setup completed"); } public void ChangeCounter(string worldEventObjectFilter, int by) { if (!Counters.ContainsKey(worldEventObjectFilter)) { EOSLogger.Error("ChangeCounter: " + worldEventObjectFilter + " is not defined"); } else if (by != 0) { Counter counter = Counters[worldEventObjectFilter]; if (by > 0) { counter.Increment(by); } else { counter.Decrement(-by); } } } private void ChangeCounter(WardenObjectiveEventData e) { string worldEventObjectFilter = e.WorldEventObjectFilter; int count = e.Count; ChangeCounter(worldEventObjectFilter, count); } private void BuildCounters() { if (base.definitions.ContainsKey(base.CurrentMainLevelLayout)) { base.definitions[base.CurrentMainLevelLayout].Definitions.ForEach(Build); } } private void Clear() { Counters.Clear(); } private ObjectiveCounterManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnBuildDone += BuildCounters; EOSWardenEventManager.Current.AddEventDefinition(CounterWardenEvent.ChangeCounter.ToString(), 500u, ChangeCounter); } static ObjectiveCounterManager() { Current = new ObjectiveCounterManager(); } } } namespace ExtraObjectiveSetup.Objectives.IndividualGenerator { internal sealed class IndividualGeneratorObjectiveManager : InstanceDefinitionManager { public static IndividualGeneratorObjectiveManager Current { get; private set; } protected override string DEFINITION_NAME { get; } = "IndividualGenerator"; private IndividualGeneratorObjectiveManager() { } static IndividualGeneratorObjectiveManager() { Current = new IndividualGeneratorObjectiveManager(); } } public class IndividualGeneratorDefinition : BaseInstanceDefinition { public bool ForceAllowPowerCellInsertion { get; set; } public List EventsOnInsertCell { get; set; } = new List(); public Vec3 Position { get; set; } = new Vec3(); public Vec3 Rotation { get; set; } = new Vec3(); } } namespace ExtraObjectiveSetup.Objectives.GeneratorCluster { public class GeneratorClusterDefinition : BaseInstanceDefinition { public uint NumberOfGenerators { get; set; } public List> EventsOnInsertCell { get; set; } = new List> { new List() }; public uint EndSequenceChainedPuzzle { get; set; } public List EventsOnEndSequenceChainedPuzzleComplete { get; set; } = new List(); } internal sealed class GeneratorClusterObjectiveManager : InstanceDefinitionManager { private List<(LG_PowerGeneratorCluster, GeneratorClusterDefinition)> chainedPuzzleToBuild = new List<(LG_PowerGeneratorCluster, GeneratorClusterDefinition)>(); public static GeneratorClusterObjectiveManager Current { get; private set; } protected override string DEFINITION_NAME { get; } = "GeneratorCluster"; protected override void AddDefinitions(InstanceDefinitionsForLevel definitions) { Sort(definitions); base.AddDefinitions(definitions); } internal void RegisterForChainedPuzzleBuild(LG_PowerGeneratorCluster __instance, GeneratorClusterDefinition GeneratorClusterConfig) { chainedPuzzleToBuild.Add((__instance, GeneratorClusterConfig)); } private void BuildChainedPuzzleMidObjective() { //IL_006e: 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_00af: 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) foreach (var item2 in chainedPuzzleToBuild) { LG_PowerGeneratorCluster item = item2.Item1; GeneratorClusterDefinition config = item2.Item2; ChainedPuzzleDataBlock block = GameDataBlockBase.GetBlock(config.EndSequenceChainedPuzzle); if (block == null) { continue; } EOSLogger.Debug($"GeneratorCluster: Building EndSequenceChainedPuzzle for LG_PowerGeneratorCluster in {item.SpawnNode.m_zone.LocalIndex}, {item.SpawnNode.LayerType}, {item.SpawnNode.m_dimension.DimensionIndex}"); item.m_chainedPuzzleMidObjective = ChainedPuzzleManager.CreatePuzzleInstance(block, item.SpawnNode.m_area, item.m_chainedPuzzleAlignMidObjective.position, item.m_chainedPuzzleAlignMidObjective); item.m_chainedPuzzleMidObjective.Add_OnStateChange(delegate(pChainedPuzzleState _, pChainedPuzzleState newState, bool isRecall) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)newState.status == 2 && !isRecall) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(ListExtensions.ToIl2Cpp(config.EventsOnEndSequenceChainedPuzzleComplete), (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray)null); } }); } } private void OnBuildDone() { BuildChainedPuzzleMidObjective(); } private void OnLevelCleanup() { chainedPuzzleToBuild.Clear(); } private GeneratorClusterObjectiveManager() { LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnLevelCleanup += OnLevelCleanup; LevelAPI.OnBuildStart += OnLevelCleanup; } static GeneratorClusterObjectiveManager() { Current = new GeneratorClusterObjectiveManager(); } } } namespace ExtraObjectiveSetup.Objectives.ActivateSmallHSU { public class HSUActivatorDefinition : BaseInstanceDefinition { public List EventsOnHSUActivation { get; set; } = new List(); public uint ItemFromStart { get; set; } public uint ItemAfterActivation { get; set; } public bool RequireItemAfterActivationInExitScan { get; set; } public bool TakeOutItemAfterActivation { get; set; } = true; public uint ChainedPuzzleOnActivation { get; set; } [JsonIgnore] public ChainedPuzzleInstance ChainedPuzzleOnActivationInstance { get; set; } public Vec3 ChainedPuzzleStartPosition { get; set; } = new Vec3(); public List EventsOnActivationScanSolved { get; set; } = new List(); } internal sealed class HSUActivatorObjectiveManager : InstanceDefinitionManager { private Dictionary m_HSUActivatorPuzzles = new Dictionary(); public static HSUActivatorObjectiveManager Current { get; private set; } protected override string DEFINITION_NAME { get; } = "ActivateSmallHSU"; protected override void AddDefinitions(InstanceDefinitionsForLevel definitions) { Sort(definitions); base.AddDefinitions(definitions); } private void BuildHSUActivatorChainedPuzzle(HSUActivatorDefinition def) { //IL_0019: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) LG_HSUActivator_Core instance = HSUActivatorInstanceManager.Current.GetInstance(def.DimensionIndex, def.LayerType, def.LocalIndex, def.InstanceIndex); if ((Object)(object)instance == (Object)null) { EOSLogger.Error($"Found unused HSUActivator config: {(def.DimensionIndex, def.LayerType, def.LocalIndex, def.InstanceIndex)}"); return; } if (def.RequireItemAfterActivationInExitScan) { LG_AnimationSequencer sequencerExtractionDone = instance.m_sequencerExtractionDone; sequencerExtractionDone.OnSequenceDone += Action.op_Implicit((Action)delegate { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) WardenObjectiveManager.AddObjectiveItemAsRequiredForExitScan(true, (iWardenObjectiveItem[])(object)new iWardenObjectiveItem[1] { new iWardenObjectiveItem(((Il2CppObjectBase)instance.m_linkedItemComingOut).Pointer) }); EOSLogger.Debug($"HSUActivator: {(def.DimensionIndex, def.LayerType, def.LocalIndex, def.InstanceIndex)} - added required item for extraction scan"); }); } if (def.TakeOutItemAfterActivation) { LG_AnimationSequencer sequencerExtractionDone2 = instance.m_sequencerExtractionDone; sequencerExtractionDone2.OnSequenceDone += Action.op_Implicit((Action)delegate { instance.LinkedItemComingOut.m_navMarkerPlacer.SetMarkerVisible(true); }); } if (def.ChainedPuzzleOnActivation != 0) { ChainedPuzzleDataBlock block = GameDataBlockBase.GetBlock(def.ChainedPuzzleOnActivation); if (block == null) { EOSLogger.Error("HSUActivator: ChainedPuzzleOnActivation is specified but ChainedPuzzleDatablock definition is not found, won't build"); return; } Vector3 val = def.ChainedPuzzleStartPosition.ToVector3(); if (val == Vector3.zeroVector) { val = instance.m_itemGoingInAlign.position; } ChainedPuzzleInstance val2 = ChainedPuzzleManager.CreatePuzzleInstance(block, instance.SpawnNode.m_area, val, ((Component)instance.SpawnNode.m_area).transform); def.ChainedPuzzleOnActivationInstance = val2; m_HSUActivatorPuzzles[((Il2CppObjectBase)val2).Pointer] = def; val2.Add_OnStateChange(delegate(pChainedPuzzleState _, pChainedPuzzleState newState, bool isRecall) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)newState.status == 2 && !isRecall) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(ListExtensions.ToIl2Cpp(def.EventsOnActivationScanSolved), (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray)null); if (def.TakeOutItemAfterActivation) { instance.m_triggerExtractSequenceRoutine = ((MonoBehaviour)instance).StartCoroutine(instance.TriggerRemoveSequence()); } } }); EOSLogger.Debug($"HSUActivator: ChainedPuzzleOnActivation ID: {def.ChainedPuzzleOnActivation} specified and created"); } else if (def.TakeOutItemAfterActivation) { instance.m_triggerExtractSequenceRoutine = ((MonoBehaviour)instance).StartCoroutine(instance.TriggerRemoveSequence()); } } private void OnBuildDone() { if (definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions.ForEach(BuildHSUActivatorChainedPuzzle); } } private void OnLevelCleanup() { foreach (HSUActivatorDefinition value in m_HSUActivatorPuzzles.Values) { value.ChainedPuzzleOnActivationInstance = null; } m_HSUActivatorPuzzles.Clear(); } internal HSUActivatorDefinition GetHSUActivatorDefinition(ChainedPuzzleInstance chainedPuzzle) { if (!m_HSUActivatorPuzzles.TryGetValue(((Il2CppObjectBase)chainedPuzzle).Pointer, out var value)) { return null; } return value; } static HSUActivatorObjectiveManager() { Current = new HSUActivatorObjectiveManager(); } private HSUActivatorObjectiveManager() { LevelAPI.OnBuildDone += OnBuildDone; LevelAPI.OnLevelCleanup += OnLevelCleanup; LevelAPI.OnBuildStart += OnLevelCleanup; } } } namespace ExtraObjectiveSetup.JSON { public static class InjectLibUtil { public const string PLUGIN_GUID = "GTFO.InjectLib"; public static JsonConverter InjectLibConnector { get; private set; } public static bool IsLoaded { get; private set; } static InjectLibUtil() { if (!((BaseChainloader)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("GTFO.InjectLib", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } InjectLibConnector = (JsonConverter)Activator.CreateInstance(obj.GetTypes().First((Type t) => t.Name == "InjectLibConnector") ?? throw new Exception("Unable to Find InjectLibConnector Class")); IsLoaded = true; } catch (Exception value2) { EOSLogger.Error($"Exception thrown while reading data from GTFO.AWO: {value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { EOSLogger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } public sealed class MyVector3Converter : JsonConverter { public override bool HandleNull => false; public override Vector3 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 vector = Vector3.zero; switch (reader.TokenType) { case JsonTokenType.StartObject: { int currentDepth = reader.CurrentDepth; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject && reader.CurrentDepth == currentDepth) { EOSLogger.Warning($"Parsed Vector3 : {vector}"); return vector; } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException("Expected PropertyName token"); } string? @string = reader.GetString(); reader.Read(); switch (@string.ToLowerInvariant()) { case "x": vector.x = reader.GetSingle(); break; case "y": vector.y = reader.GetSingle(); break; case "z": vector.z = reader.GetSingle(); break; } } throw new JsonException("Expected EndObject token"); } case JsonTokenType.String: { string text = reader.GetString().Trim(); if (TryParseVector3(text, out vector)) { return vector; } throw new JsonException("Vector3 format is not right: " + text); } default: throw new JsonException($"Vector3Json type: {reader.TokenType} is not implemented!"); } } private static bool TryParseVector3(string input, out Vector3 vector) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) float[] array = default(float[]); if (!RegexUtils.TryParseVectorString(input, ref array)) { vector = Vector3.zero; return false; } if (array.Length < 3) { vector = Vector3.zero; return false; } vector = new Vector3(array[0], array[1], array[2]); return true; } public override void Write(Utf8JsonWriter writer, Vector3 value, JsonSerializerOptions options) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) writer.WriteStringValue($"({value.x} {value.y} {value.z})"); } } public sealed class WritableLocalizedTextConverter : JsonConverter { public static WritableLocalizedTextConverter Converter { get; } = new WritableLocalizedTextConverter(); public override bool HandleNull => false; public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (MTFOPartialDataUtil.LocalizedTextConverter != null) { return ((JsonConverter)MTFOPartialDataUtil.LocalizedTextConverter).Read(ref reader, typeToConvert, options); } throw new NotImplementedException(); } public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options) { if (value.Id != 0) { JsonSerializer.Serialize(writer, value.Id, options); } else { JsonSerializer.Serialize(writer, value.UntranslatedText, options); } } } public static class EOSJson { private static readonly JsonSerializerOptions _setting; static EOSJson() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); _setting.Converters.Add(new MyVector3Converter()); if (MTFOPartialDataUtil.IsLoaded && InjectLibUtil.IsLoaded) { _setting.Converters.Add(InjectLibUtil.InjectLibConnector); _setting.Converters.Add((JsonConverter)new LocalizedTextConverter()); EOSLogger.Log("InjectLib (AWO) && PartialData support found!"); return; } if (MTFOPartialDataUtil.IsLoaded) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); _setting.Converters.Add(WritableLocalizedTextConverter.Converter); EOSLogger.Log("PartialData support found!"); return; } if (InjectLibUtil.IsLoaded) { _setting.Converters.Add(InjectLibUtil.InjectLibConnector); EOSLogger.Log("InjectLib (AWO) support found!"); } _setting.Converters.Add((JsonConverter)new LocalizedTextConverter()); } public static T Deserialize(string json) { return JsonSerializer.Deserialize(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize(T value) { return JsonSerializer.Serialize(value, _setting); } } } namespace ExtraObjectiveSetup.JSON.PData { public class PDataGUID { public string GUID { get; set; } public uint ID { get; set; } } } namespace ExtraObjectiveSetup.JSON.MTFOPartialData { public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public const string ID_FILE_NAME = "_persistentID.json"; private static Dictionary pdataGUID; public static JsonConverter PersistentIDConverter { get; private set; } public static JsonConverter LocalizedTextConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; LocalizedTextConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; pdataGUID = null; if (!((BaseChainloader)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type type2 = types.First((Type t) => t.Name == "PartialDataManager"); if ((object)type2 == null) { throw new Exception("Unable to Find PartialDataManager Class"); } Type type3 = types.First((Type t) => t.Name == "LocalizedTextConverter") ?? throw new Exception("Unable to Find LocalizedTextConverter Class"); PropertyInfo property = type2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = type2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = type2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type3); IsLoaded = true; } catch (Exception value2) { EOSLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } internal static void ReadPDataGUID() { if (pdataGUID != null) { return; } if (!IsLoaded) { EOSLogger.Error("ReadPDataGUID: invoked when not loaded, which is a broken operation"); return; } string path = Path.Combine(PartialDataPath, "_persistentID.json"); if (!File.Exists(path)) { EOSLogger.Error("ReadPDataGUID: PartialData GUID file not found"); return; } List list = EOSJson.Deserialize>(File.ReadAllText(path)); pdataGUID = new Dictionary(); foreach (PDataGUID item in list) { if (!pdataGUID.TryAdd(item.GUID, item.ID)) { EOSLogger.Error("ReadPDataGUID: cannot add '" + item.GUID + "', probably there's a duplicate"); } } EOSLogger.Log($"ReadPDataGUID: Loaded {pdataGUID.Count} PData GUID"); } public static bool TryGetID(string guid, out uint id) { id = 0u; return pdataGUID?.TryGetValue(guid, out id) ?? false; } public static string ConvertAllGUID(string json) { if (!IsLoaded) { EOSLogger.Error("MTFOPartialDataUtil.ConvertAllGUID: partial data is not loaded"); return json; } JsonNode jsonNode = JsonNode.Parse(json, default(JsonNodeOptions), new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); foreach (var item in (from i in jsonNode.DescendantItemsAndSelf() where i.name != null && i.node is JsonValue select i).ToList()) { if (item.Item1.GetValue().ValueKind == JsonValueKind.String && item.Item3 != null && TryGetID(item.Item1.ToString(), out var id) && id != 0) { JsonObject obj = (JsonObject)item.Item4; obj.Remove(item.Item3); obj.Add(item.Item3, (JsonNode)id); } } return jsonNode.ToString(); } } } namespace ExtraObjectiveSetup.JSON.Extensions { public static class JsonExtensions { public static IEnumerable Descendants(this JsonNode? root) { return root.DescendantsAndSelf(includeSelf: false); } public static IEnumerable DescendantsAndSelf(this JsonNode? root, bool includeSelf = true) { return from i in root.DescendantItemsAndSelf(includeSelf) select i.node; } public static IEnumerable<(JsonNode? node, int? index, string? name, JsonNode? parent)> DescendantItemsAndSelf(this JsonNode? root, bool includeSelf = true) { return RecursiveEnumerableExtensions.Traverse<(JsonNode, int?, string, JsonNode)>((root, null, null, null), delegate((JsonNode node, int? index, string name, JsonNode parent) i) { JsonNode item2 = i.node; if (item2 is JsonObject o) { return from p in o.AsDictionary() select (p.Value, null, p.Key.AsNullableReference(), i.node.AsNullableReference()); } return (IEnumerable<(JsonNode node, int? index, string name, JsonNode parent)>)((item2 is JsonArray source) ? ((IEnumerable)((IEnumerable)source).Select((Func)((JsonNode item, int index) => (item, index.AsNullableValue(), null, i.node.AsNullableReference())))) : ((IEnumerable)i.ToEmptyEnumerable())); }, includeSelf); } private static IEnumerable ToEmptyEnumerable(this T item) { return Enumerable.Empty(); } private static T? AsNullableReference(this T item) where T : class { return item; } private static T? AsNullableValue(this T item) where T : struct { return item; } private static IDictionary AsDictionary(this JsonObject o) { return o; } } public static class RecursiveEnumerableExtensions { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; private bool includeSelf; public bool <>3__includeSelf; private T root; public T <>3__root; private Func> children; public Func> <>3__children; private Stack> 5__2; private IEnumerator 5__3; T IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (includeSelf) { <>2__current = root; <>1__state = 1; return true; } goto IL_0050; case 1: <>1__state = -1; goto IL_0050; case 2: { <>1__state = -3; 5__2.Push(children(5__3.Current).GetEnumerator()); goto IL_010a; } IL_010a: 5__3 = null; goto IL_0111; IL_0050: 5__2 = new Stack>(); <>1__state = -3; 5__2.Push(children(root).GetEnumerator()); goto IL_0111; IL_0111: if (5__2.Count != 0) { 5__3 = 5__2.Peek(); if (!5__3.MoveNext()) { 5__2.Pop(); 5__3.Dispose(); goto IL_010a; } <>2__current = 5__3.Current; <>1__state = 2; return true; } <>m__Finally1(); return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; foreach (IEnumerator item in 5__2) { item.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.root = <>3__root; d__.children = <>3__children; d__.includeSelf = <>3__includeSelf; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0<>))] public static IEnumerable Traverse(T root, Func> children, bool includeSelf = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2) { <>3__root = root, <>3__children = children, <>3__includeSelf = includeSelf }; } } } namespace ExtraObjectiveSetup.Instances { public sealed class HSUActivatorInstanceManager : InstanceManager { public static HSUActivatorInstanceManager Current { get; private set; } public override (eDimensionIndex, LG_LayerType, eLocalZoneIndex) GetGlobalZoneIndex(LG_HSUActivator_Core instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return (instance.SpawnNode.m_dimension.DimensionIndex, instance.SpawnNode.LayerType, instance.SpawnNode.m_zone.LocalIndex); } private HSUActivatorInstanceManager() { } static HSUActivatorInstanceManager() { Current = new HSUActivatorInstanceManager(); } } public sealed class GeneratorClusterInstanceManager : InstanceManager { public static GeneratorClusterInstanceManager Current { get; private set; } public override (eDimensionIndex, LG_LayerType, eLocalZoneIndex) GetGlobalZoneIndex(LG_PowerGeneratorCluster instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return (instance.SpawnNode.m_dimension.DimensionIndex, instance.SpawnNode.LayerType, instance.SpawnNode.m_zone.LocalIndex); } static GeneratorClusterInstanceManager() { Current = new GeneratorClusterInstanceManager(); } } public sealed class PowerGeneratorInstanceManager : InstanceManager { private Dictionary gcGenerators = new Dictionary(); public static PowerGeneratorInstanceManager Current { get; private set; } public override (eDimensionIndex, LG_LayerType, eLocalZoneIndex) GetGlobalZoneIndex(LG_PowerGenerator_Core instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return (instance.SpawnNode.m_dimension.DimensionIndex, instance.SpawnNode.LayerType, instance.SpawnNode.m_zone.LocalIndex); } public override uint Register((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, LG_PowerGenerator_Core instance) { if (gcGenerators.ContainsKey(((Il2CppObjectBase)instance).Pointer)) { EOSLogger.Error("PowerGeneratorInstanceManager: Trying to register a GC Generator, which is an invalid operation"); return uint.MaxValue; } return base.Register(globalZoneIndex, instance); } public void MarkAsGCGenerator(LG_PowerGeneratorCluster parent, LG_PowerGenerator_Core child) { if (IsRegistered(child)) { EOSLogger.Error("PowerGeneratorInstanceManager: Trying to mark a registered Generator as GC Generator, which is an invalid operation"); } else { gcGenerators[((Il2CppObjectBase)child).Pointer] = parent; } } public bool IsGCGenerator(LG_PowerGenerator_Core instance) { return gcGenerators.ContainsKey(((Il2CppObjectBase)instance).Pointer); } public LG_PowerGeneratorCluster GetParentGeneratorCluster(LG_PowerGenerator_Core instance) { if (!gcGenerators.TryGetValue(((Il2CppObjectBase)instance).Pointer, out var value)) { return null; } return value; } private void OutputLevelInstanceInfo() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(); foreach (var item in RegisteredZones()) { StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(8, 3, stringBuilder2); handler.AppendFormatted(item.zone); handler.AppendLiteral(", "); handler.AppendFormatted(item.layer); handler.AppendLiteral(", Dim "); handler.AppendFormatted(item.dim); stringBuilder3.AppendLine(ref handler); List instancesInZone = GetInstancesInZone(item); for (int i = 0; i < instancesInZone.Count; i++) { LG_PowerGenerator_Core val = instancesInZone[i]; stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(28, 2, stringBuilder2); handler.AppendLiteral("GENERATOR_"); handler.AppendFormatted(val.m_serialNumber); handler.AppendLiteral(". Instance index: "); handler.AppendFormatted(i); stringBuilder4.AppendLine(ref handler); } stringBuilder.AppendLine(); } if (!string.IsNullOrWhiteSpace(stringBuilder.ToString())) { EOSLogger.Debug(stringBuilder.ToString()); } } private void Clear() { gcGenerators.Clear(); } private PowerGeneratorInstanceManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnEnterLevel += OutputLevelInstanceInfo; } static PowerGeneratorInstanceManager() { Current = new PowerGeneratorInstanceManager(); } } public sealed class TerminalInstanceManager : InstanceManager { public enum TerminalWardenEvents { EOSSetTerminalCommand = 600, EOSToggleTerminalState } public static TerminalInstanceManager Current { get; private set; } public static ImmutableList UNIQUE_CMDS { get; } private Dictionary UniqueCommandChainPuzzles { get; } = new Dictionary(); private Dictionary> WardenUplinks { get; } = new Dictionary>(); private Dictionary Wrappers { get; } = new Dictionary(); public LG_ComputerTerminal GetWardenUplink(LG_LayerType layer, int objectiveIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (WardenUplinks.TryGetValue(layer, out var value)) { if (objectiveIndex < 0 || objectiveIndex >= value.Count) { return null; } return value[objectiveIndex]; } return null; } public override (eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone) GetGlobalZoneIndex(LG_ComputerTerminal instance) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (instance.SpawnNode == null) { if ((Object)(object)instance.ConnectedReactor != (Object)null) { AIG_CourseNode spawnNode = instance.ConnectedReactor.SpawnNode; return (spawnNode.m_dimension.DimensionIndex, spawnNode.LayerType, spawnNode.m_zone.LocalIndex); } throw new ArgumentException("LG_ComputerTerminal: both SpawnNode and ConnectedReactor are null!"); } return (instance.SpawnNode.m_dimension.DimensionIndex, instance.SpawnNode.LayerType, instance.SpawnNode.m_zone.LocalIndex); } public override uint Register(LG_ComputerTerminal instance) { if (instance.SpawnNode == null) { EOSLogger.Error("Trying to register reactor terminal. Use TerminalInstanceManager.RegisterReactorTerminal instead."); return uint.MaxValue; } return Register(GetGlobalZoneIndex(instance), instance); } public uint RegisterReactorTerminal(LG_WardenObjective_Reactor reactor) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)reactor.m_terminal == (Object)null) { EOSLogger.Error("RegisterReactorTerminal: reactor has no terminal"); return uint.MaxValue; } uint num = Register((reactor.SpawnNode.m_dimension.DimensionIndex, reactor.SpawnNode.LayerType, reactor.SpawnNode.m_zone.LocalIndex), reactor.m_terminal); EOSLogger.Debug($"Registered reactor terminal, {reactor.PublicName} - {reactor.m_terminal.PublicName}, instance index: {num}"); return num; } public int RegisterWardenUplink(LG_ComputerTerminal terminal) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) LG_LayerType layerType = terminal.SpawnNode.LayerType; if (!WardenUplinks.TryGetValue(layerType, out var value)) { WardenUplinks.Add(layerType, value = new List()); } value.Add(terminal); return value.Count - 1; } public void SetupTerminalWrapper(LG_ComputerTerminal terminal) { if (Wrappers.ContainsKey(((Il2CppObjectBase)terminal).Pointer)) { EOSLogger.Error("TerminalInstanceManager: " + terminal.ItemKey + " is already setup with wrapper..."); return; } uint num = EOSNetworking.AllotReplicatorID(); if (num == 0) { EOSLogger.Error("TerminalStateManager: replicator ID depleted, cannot setup terminal..."); return; } TerminalWrapper value = TerminalWrapper.Instantiate(terminal, num); Wrappers[((Il2CppObjectBase)terminal).Pointer] = value; } public TerminalWrapper GetTerminalWrapper(LG_ComputerTerminal terminal) { if (!Wrappers.ContainsKey(((Il2CppObjectBase)terminal).Pointer)) { return null; } return Wrappers[((Il2CppObjectBase)terminal).Pointer]; } private void Clear() { UniqueCommandChainPuzzles.Clear(); Wrappers.Clear(); WardenUplinks.Clear(); } private void GatherUniqueCommandChainPuzzles() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) ChainedPuzzleInstance val = default(ChainedPuzzleInstance); foreach (List value in index2Instance.Values) { foreach (LG_ComputerTerminal item in value) { foreach (TERM_Command uNIQUE_CMD in UNIQUE_CMDS) { if (!item.m_command.m_commandsPerEnum.ContainsKey(uNIQUE_CMD)) { continue; } string command = item.m_command.m_commandsPerEnum[uNIQUE_CMD]; List uniqueCommandEvents = item.GetUniqueCommandEvents(command); for (int i = 0; i < uniqueCommandEvents.Count; i++) { if (item.TryGetChainPuzzleForCommand(uNIQUE_CMD, i, ref val)) { UniqueCommandChainPuzzles[((Il2CppObjectBase)val).Pointer] = item; } } } } } } public bool TryGetParentTerminal(ChainedPuzzleInstance cpInstance, out LG_ComputerTerminal terminal) { return UniqueCommandChainPuzzles.TryGetValue(((Il2CppObjectBase)cpInstance).Pointer, out terminal); } public bool TryGetParentTerminal(IntPtr pointer, out LG_ComputerTerminal terminal) { return UniqueCommandChainPuzzles.TryGetValue(pointer, out terminal); } public void SetTerminalCommand(WardenObjectiveEventData e) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) LG_LayerType layer = e.Layer; eLocalZoneIndex localIndex = e.LocalIndex; eDimensionIndex dimensionIndex = e.DimensionIndex; LG_ComputerTerminal instance = GetInstance(dimensionIndex, layer, localIndex, (uint)e.Count); if ((Object)(object)instance == (Object)null) { EOSLogger.Error($"SetTerminalCommand_Custom: Cannot find reactor for {layer} or instance index ({(dimensionIndex, layer, localIndex, e.Count)})"); return; } if (e.Enabled) { instance.TrySyncSetCommandShow(e.TerminalCommand); } else { instance.TrySyncSetCommandHidden(e.TerminalCommand); } EOSLogger.Debug($"SetTerminalCommand: Terminal_{instance.m_serialNumber}, command '{e.TerminalCommand}' enabled ? {e.Enabled}"); } public void ToggleTerminalState(WardenObjectiveEventData e) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_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) bool enabled = e.Enabled; LG_ComputerTerminal instance = GetInstance(e.DimensionIndex, e.Layer, e.LocalIndex, (uint)e.Count); if ((Object)(object)instance == (Object)null) { EOSLogger.Error($"ToggleTerminalState: terminal with index {(e.DimensionIndex, e.Layer, e.LocalIndex, e.Count)} not found"); return; } TerminalWrapper terminalWrapper = GetTerminalWrapper(instance); if (terminalWrapper == null) { EOSLogger.Error($"ToggleTerminalState: internal error: terminal wrapper not found - {(e.DimensionIndex, e.Layer, e.LocalIndex, e.Count)}"); } else { terminalWrapper.ChangeState(enabled); } } private TerminalInstanceManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; LevelAPI.OnEnterLevel += GatherUniqueCommandChainPuzzles; EOSWardenEventManager.Current.AddEventDefinition(TerminalWardenEvents.EOSSetTerminalCommand.ToString(), 600u, SetTerminalCommand); EOSWardenEventManager.Current.AddEventDefinition(TerminalWardenEvents.EOSToggleTerminalState.ToString(), 601u, ToggleTerminalState); } static TerminalInstanceManager() { Current = new TerminalInstanceManager(); UNIQUE_CMDS = new List { (TERM_Command)38, (TERM_Command)39, (TERM_Command)40, (TERM_Command)41, (TERM_Command)42 }.ToImmutableList(); } } } namespace ExtraObjectiveSetup.Instances.ChainedPuzzle { public static class ChainedPuzzleInstanceManagerHelper { public static void Add_OnStateChange(this ChainedPuzzleInstance instance, Action action) { ChainedPuzzleInstanceManager.Current.Add_OnStateChange(instance, action); } public static void Remove_OnStateChange(this ChainedPuzzleInstance instance, Action action) { ChainedPuzzleInstanceManager.Current.Remove_OnStateChange(instance, action); } } public class ChainedPuzzleInstanceManager : InstanceManager { public static ChainedPuzzleInstanceManager Current { get; } = new ChainedPuzzleInstanceManager(); private Dictionary> Puzzles_OnStateChange { get; } = new Dictionary>(); public override (eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone) GetGlobalZoneIndex(ChainedPuzzleInstance instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode courseNode = instance.m_sourceArea.m_courseNode; return (courseNode.m_dimension.DimensionIndex, courseNode.LayerType, courseNode.m_zone.LocalIndex); } public override uint Register((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, ChainedPuzzleInstance instance) { uint num = base.Register(globalZoneIndex, instance); if (num != uint.MaxValue) { Puzzles_OnStateChange[((Il2CppObjectBase)instance).Pointer] = null; } return num; } public void Add_OnStateChange(ChainedPuzzleInstance instance, Action action) { Add_OnStateChange(((Il2CppObjectBase)instance).Pointer, action); } public void Add_OnStateChange(IntPtr pointer, Action action) { if (Puzzles_OnStateChange.ContainsKey(pointer)) { Dictionary> puzzles_OnStateChange = Puzzles_OnStateChange; puzzles_OnStateChange[pointer] = (Action)Delegate.Combine(puzzles_OnStateChange[pointer], action); } else { EOSLogger.Error("ChainedPuzzleInstanceManager: passed in pointer is an unregistered ChainedPuzzleInstance, or is not a ChainedPuzzle"); } } public void Remove_OnStateChange(ChainedPuzzleInstance instance, Action action) { Remove_OnStateChange(((Il2CppObjectBase)instance).Pointer, action); } public void Remove_OnStateChange(IntPtr pointer, Action action) { if (Puzzles_OnStateChange.ContainsKey(pointer)) { Dictionary> puzzles_OnStateChange = Puzzles_OnStateChange; puzzles_OnStateChange[pointer] = (Action)Delegate.Remove(puzzles_OnStateChange[pointer], action); } else { EOSLogger.Error("ChainedPuzzleInstanceManager: passed in pointer is an unregistered ChainedPuzzleInstance, or is not a ChainedPuzzle"); } } public Action Get_OnStateChange(ChainedPuzzleInstance instance) { return Get_OnStateChange(((Il2CppObjectBase)instance).Pointer); } public Action Get_OnStateChange(IntPtr pointer) { if (!Puzzles_OnStateChange.TryGetValue(pointer, out var value)) { return null; } return value; } private void Clear() { Puzzles_OnStateChange.Clear(); } private ChainedPuzzleInstanceManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } } namespace ExtraObjectiveSetup.ExtendedWardenEvents { public class EOSWardenEventManager { [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public WardenObjectiveEventData e; public EOSWardenEventManager <>4__this; public float currentDuration; private uint 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; EOSWardenEventManager eOSWardenEventManager = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; 5__2 = (uint)(int)e.Type; if (!eOSWardenEventManager.eventDefinition.ContainsKey(5__2)) { return false; } float num2 = Mathf.Max(e.Delay - currentDuration, 0f); if (num2 > 0f) { <>2__current = (object)new WaitForSeconds(num2); <>1__state = 1; return true; } break; } case 1: <>1__state = -1; break; } if (WorldEventManager.GetCondition(e.Condition.ConditionIndex) != e.Condition.IsTrue) { return false; } WardenObjectiveManager.DisplayWardenIntel(e.Layer, e.WardenIntel); if (e.DialogueID != 0) { PlayerDialogManager.WantToStartDialog(e.DialogueID, -1, false, false); } if (e.SoundID != 0) { WardenObjectiveManager.Current.m_sound.Post(e.SoundID, true); string text = ((Object)e.SoundSubtitle).ToString(); if (!string.IsNullOrWhiteSpace(text)) { GuiManager.PlayerLayer.ShowMultiLineSubtitle(text); } } eOSWardenEventManager.eventDefinition[5__2]?.Invoke(e); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Dictionary eventNames2ID = new Dictionary(); private Dictionary eventID2Name = new Dictionary(); private Dictionary> eventDefinition = new Dictionary>(); private readonly ImmutableHashSet vanillaEventIDs = Enum.GetValues().ToImmutableHashSet(); private const uint AWOEventIdsStart = 10000u; public static EOSWardenEventManager Current { get; private set; } public bool IsVanillaEventID(uint eventID) { return vanillaEventIDs.Contains((eWardenObjectiveEventType)eventID); } private bool IsAWOEventID(uint eventID) { return eventID >= 10000; } public bool AddEventDefinition(string eventName, uint eventID, Action definition) { if (IsAWOEventID(eventID)) { EOSLogger.Error($"EventID {eventID} is already used by AWO"); return false; } if (IsVanillaEventID(eventID)) { EOSLogger.Warning($"EventID {eventID}: overriding vanilla event!"); } string text = eventName.ToLowerInvariant(); if (eventNames2ID.ContainsKey(text) || eventID2Name.ContainsKey(eventID)) { EOSLogger.Error($"AddEventDefinition: duplicate event name '{eventName}' or id '{eventID}'"); return false; } eventNames2ID[text] = eventID; eventID2Name[eventID] = text; eventDefinition[eventID] = definition; EOSLogger.Debug($"EOSWardenEventManager: added event with name '{eventName}', id '{eventID}'"); return true; } internal void ExecuteEvent(WardenObjectiveEventData e, float currentDuration) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown uint num = (uint)(int)e.Type; if (!eventDefinition.ContainsKey(num)) { EOSLogger.Error($"ExecuteEvent: event ID {num} doesn't have a definition"); } else { Coroutine val = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Handle(e, currentDuration)), (Action)null); WorldEventManager.m_worldEventEventCoroutines.Add(val); } } public bool HasEventDefinition(string eventName) { return eventNames2ID.ContainsKey(eventName.ToLowerInvariant()); } public bool HasEventDefinition(uint eventID) { return eventDefinition.ContainsKey(eventID); } [IteratorStateMachine(typeof(d__15))] private IEnumerator Handle(WardenObjectiveEventData e, float currentDuration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this, e = e, currentDuration = currentDuration }; } private EOSWardenEventManager() { } static EOSWardenEventManager() { Current = new EOSWardenEventManager(); } } } namespace ExtraObjectiveSetup.Expedition { public class ExpeditionDefinition { public uint MainLevelLayout { get; set; } public ExpeditionGearsDefinition ExpeditionGears { get; set; } = new ExpeditionGearsDefinition(); public List GeneratorGroups { get; set; } = new List { new ExpeditionIGGroup() }; } public sealed class ExpeditionDefinitionManager { private Dictionary definitions = new Dictionary(); private readonly LiveEditListener liveEditListener; public const string DEFINITION_NAME = "ExtraExpeditionSettings"; public static ExpeditionDefinitionManager Current { get; private set; } public uint CurrentMainLevelLayout => RundownManager.ActiveExpedition.LevelLayoutData; public string DEFINITION_PATH { get; private set; } = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup", "ExtraExpeditionSettings"); private void AddDefinitions(ExpeditionDefinition definitions) { if (definitions != null) { if (this.definitions.ContainsKey(definitions.MainLevelLayout)) { EOSLogger.Log("Replaced MainLevelLayout {0}", definitions.MainLevelLayout); } this.definitions[definitions.MainLevelLayout] = definitions; } } private void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { ExpeditionDefinition expeditionDefinition = EOSJson.Deserialize(content); AddDefinitions(expeditionDefinition); }); } public ExpeditionDefinition GetDefinition(uint MainLevelLayout) { if (!definitions.ContainsKey(MainLevelLayout)) { return null; } return definitions[MainLevelLayout]; } public void Init() { } private ExpeditionDefinitionManager() { //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown string path = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new ExpeditionDefinition())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { ExpeditionDefinition expeditionDefinition = EOSJson.Deserialize(File.ReadAllText(item)); AddDefinitions(expeditionDefinition); } catch (Exception value) { EOSLogger.Error($"ExpeditionDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static ExpeditionDefinitionManager() { Current = new ExpeditionDefinitionManager(); } } } namespace ExtraObjectiveSetup.Expedition.IndividualGeneratorGroup { public class ExpeditionIGGroup { public List Generators { get; set; } = new List(); [JsonIgnore] public List GeneratorInstances { get; set; } = new List(); public bool PlayEndSequenceOnGroupComplete { get; set; } public List> EventsOnInsertCell { get; set; } = new List> { new List() }; } internal class ExpeditionIGGroupManager { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ExpeditionIGGroup IGGroup; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(4f); <>1__state = 1; return true; case 1: <>1__state = -1; CellSound.Post(EVENTS.DISTANT_EXPLOSION_SEQUENCE); <>2__current = (object)new WaitForSeconds(2f); <>1__state = 2; return true; case 2: <>1__state = -1; EnvironmentStateManager.AttemptSetExpeditionLightMode(false); CellSound.Post(EVENTS.LIGHTS_OFF_GLOBAL); <>2__current = (object)new WaitForSeconds(3f); <>1__state = 3; return true; case 3: <>1__state = -1; 5__2 = 0; goto IL_0108; case 4: { <>1__state = -1; int num2 = 5__2 + 1; 5__2 = num2; goto IL_0108; } case 5: { <>1__state = -1; EnvironmentStateManager.AttemptSetExpeditionLightMode(true); int num = IGGroup.GeneratorInstances.Count - 1; if (num >= 0 && num < IGGroup.EventsOnInsertCell.Count) { IGGroup.EventsOnInsertCell[num].ForEach(delegate(WardenObjectiveEventData e) { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f); }); } return false; } IL_0108: if (5__2 < IGGroup.GeneratorInstances.Count) { IGGroup.GeneratorInstances[5__2].TriggerPowerFailureSequence(); <>2__current = (object)new WaitForSeconds(Random.Range(0.3f, 1f)); <>1__state = 4; return true; } <>2__current = (object)new WaitForSeconds(4f); <>1__state = 5; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private List<(HashSet group, ExpeditionIGGroup groupDef)> generatorGroups = new List<(HashSet, ExpeditionIGGroup)>(); public static ExpeditionIGGroupManager Current { get; private set; } private List GatherIGs(ExpeditionIGGroup IGGroup) { List result = new List(); IGGroup.Generators.ForEach(delegate(BaseInstanceDefinition index) { LG_PowerGenerator_Core instance = PowerGeneratorInstanceManager.Current.GetInstance(index.GlobalZoneIndexTuple(), index.InstanceIndex); if ((Object)(object)instance == (Object)null) { EOSLogger.Error($"generator instance not found! Instance index: {index}"); } else { result.Add(instance); } }); IGGroup.GeneratorInstances = result; return result; } public ExpeditionIGGroup FindGroupDefOf(LG_PowerGenerator_Core core) { foreach (var generatorGroup in generatorGroups) { if (generatorGroup.group.Contains(((Il2CppObjectBase)core).Pointer)) { return generatorGroup.groupDef; } } return null; } [IteratorStateMachine(typeof(d__7))] internal static IEnumerator PlayGroupEndSequence(ExpeditionIGGroup IGGroup) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { IGGroup = IGGroup }; } private void Configure(LG_PowerGenerator_Core core) { } internal void BuildIGGroupsLogic() { ExpeditionDefinition definition = ExpeditionDefinitionManager.Current.GetDefinition(ExpeditionDefinitionManager.Current.CurrentMainLevelLayout); if (definition == null || definition.GeneratorGroups == null || definition.GeneratorGroups.Count < 1) { return; } foreach (ExpeditionIGGroup generatorGroup in definition.GeneratorGroups) { List list = GatherIGs(generatorGroup); generatorGroups.Add((list.ConvertAll((LG_PowerGenerator_Core core) => ((Il2CppObjectBase)core).Pointer).ToHashSet(), generatorGroup)); foreach (LG_PowerGenerator_Core item in list) { Configure(item); } } } public void Init() { } private void Clear() { foreach (var generatorGroup in generatorGroups) { generatorGroup.groupDef.GeneratorInstances.Clear(); } generatorGroups.Clear(); } private ExpeditionIGGroupManager() { LevelAPI.OnBuildDone += BuildIGGroupsLogic; LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } static ExpeditionIGGroupManager() { Current = new ExpeditionIGGroupManager(); } } } namespace ExtraObjectiveSetup.Expedition.Gears { public class ExpeditionGearManager { private Mode mode = Mode.DISALLOW; private HashSet GearIds = new HashSet(); public readonly IList<(InventorySlot inventorySlot, Dictionary loadedGears)> GearSlots = new List<(InventorySlot, Dictionary)> { ((InventorySlot)1, new Dictionary()), ((InventorySlot)2, new Dictionary()), ((InventorySlot)10, new Dictionary()), ((InventorySlot)3, new Dictionary()) }.ToImmutableList(); public static ExpeditionGearManager Current { get; private set; } public GearManager VanillaGearManager { get; internal set; } private void ClearLoadedGears() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown foreach (var gearSlot in GearSlots) { ((Il2CppArrayBase>)(object)VanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot].Clear(); } } private bool IsGearAllowed(uint playerOfflineGearDBPID) { switch (mode) { case Mode.ALLOW: return GearIds.Contains(playerOfflineGearDBPID); case Mode.DISALLOW: return !GearIds.Contains(playerOfflineGearDBPID); default: EOSLogger.Error($"Unimplemented Mode: {mode}, will allow gears anyway..."); return true; } } private void AddGearForCurrentExpedition() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected I4, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) foreach (var gearSlot in GearSlots) { List val = ((Il2CppArrayBase>)(object)VanillaGearManager.m_gearPerSlot)[(int)gearSlot.inventorySlot]; Dictionary item = gearSlot.loadedGears; if (item.Count == 0) { EOSLogger.Debug($"No gear has been loaded for {gearSlot.inventorySlot}."); continue; } foreach (uint key in item.Keys) { if (IsGearAllowed(key)) { val.Add(item[key]); } } if (val.Count == 0) { EOSLogger.Error($"No gear is allowed for {gearSlot.inventorySlot}, there must be at least 1 allowed gear!"); val.Add(item.First().Value); } } } private void ResetPlayerSelectedGears() { //IL_00c4: Expected O, but got Unknown //IL_00dd: 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_002a: Expected I4, but got Unknown VanillaGearManager.RescanFavorites(); foreach (var gearSlot in GearSlots) { int num = (int)gearSlot.inventorySlot; try { if (((Il2CppArrayBase)(object)VanillaGearManager.m_lastEquippedGearPerSlot)[num] != null) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase)(object)VanillaGearManager.m_lastEquippedGearPerSlot)[num]); } else if (((Il2CppArrayBase>)(object)VanillaGearManager.m_favoriteGearPerSlot)[num].Count > 0) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase>)(object)VanillaGearManager.m_favoriteGearPerSlot)[num][0]); } else if (((Il2CppArrayBase>)(object)VanillaGearManager.m_gearPerSlot)[num].Count > 0) { PlayerBackpackManager.EquipLocalGear(((Il2CppArrayBase>)(object)VanillaGearManager.m_gearPerSlot)[num][0]); } } catch (Il2CppException val) { Il2CppException val2 = val; EOSLogger.Error($"Error attempting to equip gear for slot {gearSlot.inventorySlot}:\n{((Exception)(object)val2).StackTrace}"); } } } private void ConfigExpeditionGears() { mode = Mode.DISALLOW; GearIds.Clear(); ExpeditionDefinition definition = ExpeditionDefinitionManager.Current.GetDefinition(ExpeditionDefinitionManager.Current.CurrentMainLevelLayout); if (definition != null && definition.ExpeditionGears != null) { mode = definition.ExpeditionGears.Mode; definition.ExpeditionGears.GearIds.ForEach(delegate(uint id) { GearIds.Add(id); }); } } internal void SetupAllowedGearsForActiveExpedition() { ConfigExpeditionGears(); ClearLoadedGears(); AddGearForCurrentExpedition(); ResetPlayerSelectedGears(); } public void Init() { } private ExpeditionGearManager() { } public static uint GetOfflineGearPID(GearIDRange gearIDRange) { string playfabItemInstanceId = gearIDRange.PlayfabItemInstanceId; if (!playfabItemInstanceId.Contains("OfflineGear_ID_")) { EOSLogger.Error("Find PlayfabItemInstanceId without substring 'OfflineGear_ID_'! " + playfabItemInstanceId); return 0u; } try { return uint.Parse(playfabItemInstanceId.Substring("OfflineGear_ID_".Length)); } catch { EOSLogger.Error("Caught exception while trying to parse persistentID of PlayerOfflineGearDB from GearIDRange, which means itemInstanceId could be ill-formated"); return 0u; } } static ExpeditionGearManager() { Current = new ExpeditionGearManager(); } } public enum Mode { ALLOW, DISALLOW } public class ExpeditionGearsDefinition { public Mode Mode { get; set; } = Mode.DISALLOW; public List GearIds { get; set; } = new List { 0u }; } } namespace ExtraObjectiveSetup.BaseClasses { public abstract class GenericDefinitionManager where T : new() { private readonly LiveEditListener liveEditListener; public uint CurrentMainLevelLayout { get { ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; if (activeExpedition == null) { return 0u; } return activeExpedition.LevelLayoutData; } } protected Dictionary> definitions { get; set; } = new Dictionary>(); protected abstract string DEFINITION_NAME { get; } public string DEFINITION_PATH { get; private set; } protected virtual void AddDefinitions(GenericDefinition definition) { if (definition != null) { if (definitions.ContainsKey(definition.ID)) { EOSLogger.Log("Replaced ID {0}", definition.ID); } definitions[definition.ID] = definition; } } protected virtual void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { GenericDefinition definition = EOSJson.Deserialize>(content); AddDefinitions(definition); }); } public GenericDefinition GetDefinition(uint ID) { if (!definitions.ContainsKey(ID)) { return null; } return definitions[ID]; } public virtual void Init() { } public GenericDefinitionManager() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown string text = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } DEFINITION_PATH = Path.Combine(text, DEFINITION_NAME); if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new GenericDefinition())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { GenericDefinition definition = EOSJson.Deserialize>(File.ReadAllText(item)); AddDefinitions(definition); } catch (Exception value) { EOSLogger.Error($"GenericDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static GenericDefinitionManager() { } } public class GenericDefinition where T : new() { public uint ID { get; set; } public T Definition { get; set; } = new T(); } public class RundownWiseDefinition where T : new() { public int RundownID { get; set; } = -1; public List Definitions { get; set; } = new List { new T() }; } public abstract class RundownWiseDefinitionManager where T : new() { public const int INVALID_RUNDOWN_ID = -1; public const int APPLY_TO_ALL_RUNDOWN_ID = 0; private readonly LiveEditListener liveEditListener; protected Dictionary> definitions { get; set; } = new Dictionary>(); protected abstract string DEFINITION_NAME { get; } public string DEFINITION_PATH { get; private set; } protected virtual void AddDefinitions(RundownWiseDefinition definitions) { if (definitions != null && definitions.RundownID != -1) { if (this.definitions.ContainsKey(definitions.RundownID)) { EOSLogger.Log($"Replaced RundownID: '{definitions.RundownID}' ({0} means 'apply to all rundowns')"); } this.definitions[definitions.RundownID] = definitions; } } protected virtual void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { RundownWiseDefinition rundownWiseDefinition = EOSJson.Deserialize>(content); AddDefinitions(rundownWiseDefinition); }); } public RundownWiseDefinition GetDefinition(uint RundownID) { if (!definitions.TryGetValue((int)RundownID, out var value)) { return null; } return value; } public virtual void Init() { } public RundownWiseDefinitionManager() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown string text = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } DEFINITION_PATH = Path.Combine(text, DEFINITION_NAME); if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new GenericExpeditionDefinition())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { RundownWiseDefinition rundownWiseDefinition = EOSJson.Deserialize>(File.ReadAllText(item)); AddDefinitions(rundownWiseDefinition); } catch (Exception value) { EOSLogger.Error($"RundownWiseDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static RundownWiseDefinitionManager() { } } public abstract class GenericExpeditionDefinitionManager where T : new() { private readonly LiveEditListener liveEditListener; public uint CurrentMainLevelLayout { get { ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; if (activeExpedition == null) { return 0u; } return activeExpedition.LevelLayoutData; } } protected Dictionary> definitions { get; set; } = new Dictionary>(); protected abstract string DEFINITION_NAME { get; } public string DEFINITION_PATH { get; private set; } protected virtual void AddDefinitions(GenericExpeditionDefinition definitions) { if (definitions != null) { if (this.definitions.ContainsKey(definitions.MainLevelLayout)) { EOSLogger.Log("Replaced MainLevelLayout {0}", definitions.MainLevelLayout); } this.definitions[definitions.MainLevelLayout] = definitions; } } protected virtual void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { GenericExpeditionDefinition genericExpeditionDefinition = EOSJson.Deserialize>(content); AddDefinitions(genericExpeditionDefinition); }); } public GenericExpeditionDefinition GetDefinition(uint MainLevelLayout) { if (!definitions.ContainsKey(MainLevelLayout)) { return null; } return definitions[MainLevelLayout]; } public virtual void Init() { } public GenericExpeditionDefinitionManager() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown string text = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } DEFINITION_PATH = Path.Combine(text, DEFINITION_NAME); if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new GenericExpeditionDefinition())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { GenericExpeditionDefinition genericExpeditionDefinition = EOSJson.Deserialize>(File.ReadAllText(item)); AddDefinitions(genericExpeditionDefinition); } catch (Exception value) { EOSLogger.Error($"GenericExpeditionDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static GenericExpeditionDefinitionManager() { } } public class GenericExpeditionDefinition where T : new() { public uint MainLevelLayout { get; set; } public List Definitions { get; set; } = new List { new T() }; } public class BaseInstanceDefinition : GlobalZoneIndex { [JsonPropertyOrder(-8)] public uint InstanceIndex { get; set; } = uint.MaxValue; public override string ToString() { return $"{GlobalZoneIndexTuple()}, Instance_{InstanceIndex}"; } } public class InstanceDefinitionsForLevel where T : BaseInstanceDefinition, new() { public uint MainLevelLayout { get; set; } public List Definitions { get; set; } = new List { new T() }; } public class GlobalZoneIndex { [JsonPropertyOrder(-10)] public eDimensionIndex DimensionIndex { get; set; } [JsonPropertyOrder(-10)] public LG_LayerType LayerType { get; set; } [JsonPropertyOrder(-10)] public eLocalZoneIndex LocalIndex { get; set; } public (eDimensionIndex, LG_LayerType, eLocalZoneIndex) GlobalZoneIndexTuple() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return (DimensionIndex, LayerType, LocalIndex); } public override string ToString() { return $"{new Func<(eDimensionIndex, LG_LayerType, eLocalZoneIndex)>(GlobalZoneIndexTuple)}"; } } public class ZoneDefinitionsForLevel where T : GlobalZoneIndex, new() { public uint MainLevelLayout { get; set; } public List Definitions { get; set; } = new List { new T() }; } public abstract class ZoneDefinitionManager where T : GlobalZoneIndex, new() { protected Dictionary> definitions = new Dictionary>(); protected readonly LiveEditListener liveEditListener; public static string MODULE_CUSTOM_FOLDER { get; private set; } protected abstract string DEFINITION_NAME { get; } protected string DEFINITION_PATH { get; private set; } protected void Sort(ZoneDefinitionsForLevel levelDefs) { levelDefs.Definitions.Sort(delegate(T u1, T u2) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (u1.DimensionIndex != u2.DimensionIndex) { if (u1.DimensionIndex >= u2.DimensionIndex) { return 1; } return -1; } if (u1.LayerType != u2.LayerType) { if (u1.LayerType >= u2.LayerType) { return 1; } return -1; } return (u1.LocalIndex != u2.LocalIndex) ? ((u1.LocalIndex >= u2.LocalIndex) ? 1 : (-1)) : 0; }); } protected virtual void AddDefinitions(ZoneDefinitionsForLevel definitions) { if (definitions != null) { if (this.definitions.ContainsKey(definitions.MainLevelLayout)) { EOSLogger.Log("Replaced MainLevelLayout {0}", definitions.MainLevelLayout); } this.definitions[definitions.MainLevelLayout] = definitions; } } protected virtual void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { ZoneDefinitionsForLevel zoneDefinitionsForLevel = EOSJson.Deserialize>(content); AddDefinitions(zoneDefinitionsForLevel); }); } public virtual List GetDefinitionsForLevel(uint MainLevelLayout) { if (!definitions.ContainsKey(MainLevelLayout)) { return null; } return definitions[MainLevelLayout].Definitions; } public virtual T GetDefinition((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return GetDefinition(globalIndex.Item1, globalIndex.Item2, globalIndex.Item3); } public virtual T GetDefinition(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return null; } return definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions.Find((T def) => def.DimensionIndex == dimensionIndex && def.LayerType == layerType && def.LocalIndex == localIndex); } public virtual void Init() { } protected ZoneDefinitionManager() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown if (!Directory.Exists(MODULE_CUSTOM_FOLDER)) { Directory.CreateDirectory(MODULE_CUSTOM_FOLDER); } DEFINITION_PATH = Path.Combine(MODULE_CUSTOM_FOLDER, DEFINITION_NAME); if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new ZoneDefinitionsForLevel())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { ZoneDefinitionsForLevel zoneDefinitionsForLevel = EOSJson.Deserialize>(File.ReadAllText(item)); AddDefinitions(zoneDefinitionsForLevel); } catch (Exception value) { EOSLogger.Error($"ZoneDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static ZoneDefinitionManager() { MODULE_CUSTOM_FOLDER = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); } } public abstract class InstanceDefinitionManager where T : BaseInstanceDefinition, new() { protected Dictionary> definitions = new Dictionary>(); protected readonly LiveEditListener liveEditListener; public static string MODULE_CUSTOM_FOLDER { get; private set; } protected abstract string DEFINITION_NAME { get; } protected string DEFINITION_PATH { get; private set; } protected void Sort(InstanceDefinitionsForLevel levelDefs) { levelDefs.Definitions.Sort(delegate(T u1, T u2) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (u1.DimensionIndex != u2.DimensionIndex) { if (u1.DimensionIndex >= u2.DimensionIndex) { return 1; } return -1; } if (u1.LayerType != u2.LayerType) { if (u1.LayerType >= u2.LayerType) { return 1; } return -1; } if (u1.LocalIndex != u2.LocalIndex) { if (u1.LocalIndex >= u2.LocalIndex) { return 1; } return -1; } return (u1.InstanceIndex != u2.InstanceIndex) ? ((u1.InstanceIndex >= u2.InstanceIndex) ? (-1) : (-1)) : 0; }); } protected virtual void AddDefinitions(InstanceDefinitionsForLevel definitions) { if (definitions != null) { if (this.definitions.ContainsKey(definitions.MainLevelLayout)) { EOSLogger.Log("Replaced MainLevelLayout {0}", definitions.MainLevelLayout); } this.definitions[definitions.MainLevelLayout] = definitions; } } protected virtual void FileChanged(LiveEditEventArgs e) { EOSLogger.Warning("LiveEdit File Changed: " + e.FullPath); LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { InstanceDefinitionsForLevel instanceDefinitionsForLevel = EOSJson.Deserialize>(content); AddDefinitions(instanceDefinitionsForLevel); }); } public virtual List GetDefinitionsForLevel(uint MainLevelLayout) { if (!definitions.ContainsKey(MainLevelLayout)) { return null; } return definitions[MainLevelLayout].Definitions; } public T GetDefinition((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalIndex, uint instanceIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return GetDefinition(globalIndex.Item1, globalIndex.Item2, globalIndex.Item3, instanceIndex); } public virtual T GetDefinition(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, uint instanceIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData)) { return null; } return definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions.Find((T def) => def.DimensionIndex == dimensionIndex && def.LayerType == layerType && def.LocalIndex == localIndex && def.InstanceIndex == instanceIndex); } public virtual void Init() { } protected InstanceDefinitionManager() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown if (!Directory.Exists(MODULE_CUSTOM_FOLDER)) { Directory.CreateDirectory(MODULE_CUSTOM_FOLDER); } DEFINITION_PATH = Path.Combine(MODULE_CUSTOM_FOLDER, DEFINITION_NAME); if (!Directory.Exists(DEFINITION_PATH)) { Directory.CreateDirectory(DEFINITION_PATH); StreamWriter streamWriter = File.CreateText(Path.Combine(DEFINITION_PATH, "Template.json")); streamWriter.WriteLine(EOSJson.Serialize(new InstanceDefinitionsForLevel())); streamWriter.Flush(); streamWriter.Close(); } foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories)) { try { InstanceDefinitionsForLevel instanceDefinitionsForLevel = EOSJson.Deserialize>(File.ReadAllText(item)); AddDefinitions(instanceDefinitionsForLevel); } catch (Exception value) { EOSLogger.Error($"InstanceDefinitionManager: an exception was thrown while reading files:\n{value}"); } } liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true); liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } static InstanceDefinitionManager() { MODULE_CUSTOM_FOLDER = Path.Combine(MTFOPathAPI.CustomPath, "ExtraObjectiveSetup"); } } public abstract class InstanceManager where T : Object { protected Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), Dictionary> instances2Index = new Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), Dictionary>(); protected Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), List> index2Instance = new Dictionary<(eDimensionIndex, LG_LayerType, eLocalZoneIndex), List>(); public const uint INVALID_INSTANCE_INDEX = uint.MaxValue; public virtual uint Register((eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex, T instance) { if (instance == null) { return uint.MaxValue; } Dictionary dictionary = null; List list = null; if (!instances2Index.ContainsKey(globalZoneIndex)) { dictionary = new Dictionary(); list = new List(); instances2Index[globalZoneIndex] = dictionary; index2Instance[globalZoneIndex] = list; } else { dictionary = instances2Index[globalZoneIndex]; list = index2Instance[globalZoneIndex]; } if (dictionary.ContainsKey(((Il2CppObjectBase)(object)instance).Pointer)) { EOSLogger.Error($"InstanceManager<{typeof(T)}>: trying to register duplicate instance! Skipped...."); return uint.MaxValue; } uint count = (uint)dictionary.Count; dictionary[((Il2CppObjectBase)(object)instance).Pointer] = count; list.Add(instance); return count; } public virtual uint Register(T instance) { return Register(GetGlobalZoneIndex(instance), instance); } public uint GetZoneInstanceIndex(T instance) { (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = GetGlobalZoneIndex(instance); if (!instances2Index.ContainsKey(globalZoneIndex)) { return uint.MaxValue; } Dictionary dictionary = instances2Index[globalZoneIndex]; if (!dictionary.ContainsKey(((Il2CppObjectBase)(object)instance).Pointer)) { return uint.MaxValue; } return dictionary[((Il2CppObjectBase)(object)instance).Pointer]; } public T GetInstance((eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone) globalZoneIndex, uint instanceIndex) { if (!index2Instance.ContainsKey(globalZoneIndex)) { return default(T); } List list = index2Instance[globalZoneIndex]; if (instanceIndex >= list.Count) { return default(T); } return list[(int)instanceIndex]; } public T GetInstance(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, uint instanceIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetInstance((dimensionIndex, layerType, localIndex), instanceIndex); } public List GetInstancesInZone((eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone) globalZoneIndex) { if (!index2Instance.ContainsKey(globalZoneIndex)) { return null; } return index2Instance[globalZoneIndex]; } public List GetInstancesInZone(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetInstancesInZone((dimensionIndex, layerType, localIndex)); } public bool IsRegistered(T instance) { (eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = GetGlobalZoneIndex(instance); if (!instances2Index.ContainsKey(globalZoneIndex)) { return false; } return instances2Index[globalZoneIndex].ContainsKey(((Il2CppObjectBase)(object)instance).Pointer); } public IEnumerable<(eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone)> RegisteredZones() { return index2Instance.Keys; } private void Clear() { index2Instance.Clear(); instances2Index.Clear(); } public virtual void Init() { } public abstract (eDimensionIndex dim, LG_LayerType layer, eLocalZoneIndex zone) GetGlobalZoneIndex(T instance); public InstanceManager() { LevelAPI.OnBuildStart += Clear; LevelAPI.OnLevelCleanup += Clear; } } } namespace ExtraObjectiveSetup.BaseClasses.CustomTerminalDefinition { public class CustomCommand { public string Command { get; set; } = string.Empty; public LocalizedText CommandDesc { get; set; } public List PostCommandOutputs { get; set; } = new List(); public List CommandEvents { get; set; } = new List(); public TERM_CommandRule SpecialCommandRule { get; set; } public CustomTerminalCommand ToVanillaDataType() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown return new CustomTerminalCommand { Command = Command, CommandDesc = CommandDesc, CommandEvents = ListExtensions.ToIl2Cpp(CommandEvents), PostCommandOutputs = ListExtensions.ToIl2Cpp(PostCommandOutputs), SpecialCommandRule = SpecialCommandRule }; } } public class TerminalPasswordData { public bool PasswordProtected { get; set; } public string Password { get; set; } = string.Empty; public string PasswordHintText { get; set; } = "Password Required."; public bool GeneratePassword { get; set; } = true; public int PasswordPartCount { get; set; } = 1; public bool ShowPasswordLength { get; set; } public bool ShowPasswordPartPositions { get; set; } public List> TerminalZoneSelectionDatas { get; set; } = new List> { new List { new CustomTerminalZoneSelectionData() } }; public TerminalPasswordData() { PasswordPartCount = Math.Max(1, PasswordPartCount); } } public class TerminalDefinition { public List LocalLogFiles { get; set; } = new List(); public List UniqueCommands { get; set; } = new List { new CustomCommand() }; public TerminalPasswordData PasswordData { get; set; } = new TerminalPasswordData(); } public class CustomTerminalZoneSelectionData : GlobalZoneIndex { public eSeedType SeedType { get; set; } = (eSeedType)1; public int TerminalIndex { get; set; } public int StaticSeed { get; set; } public CustomTerminalZoneSelectionData() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) TerminalIndex = Math.Max(0, TerminalIndex); } } }