Decompiled source of EOSExt Reactor v1.0.4

plugins/Inas07.EOSExt.Reactor.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json.Serialization;
using AIGraph;
using AK;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using EOSExt.Reactor.Component;
using EOSExt.Reactor.Definition;
using EOSExt.Reactor.Managers;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.BaseClasses.CustomTerminalDefinition;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using ExtraObjectiveSetup.Instances;
using ExtraObjectiveSetup.Utils;
using GTFO.API;
using GTFO.API.Extensions;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using SNetwork;
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.EOSExt.Reactor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Inas07.EOSExt.Reactor")]
[assembly: AssemblyTitle("Inas07.EOSExt.Reactor")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EOSExt.Reactor
{
	[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.EOSExt.Reactor", "EOSExt.Reactor", "1.0.4")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string PLUGIN_NAME = "EOSExt.Reactor";

		public const string VERSION = "1.0.4";

		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("EOSExt.Reactor");
			m_Harmony.PatchAll();
			SetupManagers();
			SetupExtraWardenEventDefinitions();
			ClassInjector.RegisterTypeInIl2Cpp<OverrideReactorComp>();
			EOSLogger.Log("ExtraObjectiveSetup.Reactor loaded.");
		}

		private void SetupManagers()
		{
			((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).Init();
			((InstanceDefinitionManager<ReactorStartupOverride>)ReactorStartupOverrideManager.Current).Init();
		}

		private void SetupExtraWardenEventDefinitions()
		{
			EOSWardenEventManager.Current.AddEventDefinition(WardenEvents.EventType.ReactorStartup.ToString(), 150u, (Action<WardenObjectiveEventData>)WardenEvents.ReactorStartup);
			EOSWardenEventManager.Current.AddEventDefinition(WardenEvents.EventType.CompleteCurrentVerify.ToString(), 151u, (Action<WardenObjectiveEventData>)WardenEvents.CompleteCurrentVerify);
		}
	}
}
namespace EOSExt.Reactor.Patches
{
	[HarmonyPatch]
	internal class CommandInterpreter_ReactorVerify
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReactorVerify")]
		private static bool Pre_LG_ComputerTerminalCommandInterpreter_ReactorVerify(LG_ComputerTerminalCommandInterpreter __instance, string param1)
		{
			LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
			if ((Object)(object)connectedReactor == (Object)null)
			{
				EOSLogger.Error("ReactorVerify: connected reactor is null - bug detected");
				return true;
			}
			if (connectedReactor.m_isWardenObjective)
			{
				return true;
			}
			if (connectedReactor.ReadyForVerification && param1 == connectedReactor.CurrentStateOverrideCode)
			{
				__instance.m_terminal.ChangeState((TERM_State)7);
			}
			else
			{
				__instance.AddOutput("", true);
				__instance.AddOutput((TerminalLineType)3, Text.Get(2195342028u), 4f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance.AddOutput("", true);
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal class OnTerminalStartupSequenceVerify
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnTerminalStartupSequenceVerify")]
		private static void Post_ExecuteEventsOnEndOnClientSide(LG_WardenObjective_Reactor __instance)
		{
			if (!SNet.IsMaster)
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)3, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}
	}
	[HarmonyPatch]
	internal class Reactor_OnBuildDone
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Post_LG_WardenObjective_Reactor_OnBuildDone(LG_WardenObjective_Reactor __instance)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0058: 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_0081: Invalid comparison between Unknown and I4
			uint num = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).Register(__instance);
			if (__instance.m_isWardenObjective)
			{
				ReactorStartupOverride definition = ((InstanceDefinitionManager<ReactorStartupOverride>)ReactorStartupOverrideManager.Current).GetDefinition(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, num);
				if (definition == null)
				{
					return;
				}
				WardenObjectiveDataBlock val = default(WardenObjectiveDataBlock);
				if (!WardenObjectiveManager.TryGetWardenObjectiveDataForLayer(__instance.SpawnNode.LayerType, __instance.WardenObjectiveChainIndex, ref val) || val == null)
				{
					EOSLogger.Error("Failed to get WardenObjectiveData for this reactor");
					return;
				}
				if ((int)val.Type != 1)
				{
					EOSLogger.Error($"Reactor Instance {(((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(__instance), num)} is not setup as vanilla ReactorStartup, cannot override");
					return;
				}
				definition.ObjectiveDB = val;
				ReactorStartupOverrideManager.Current.Build(__instance, definition);
			}
			else
			{
				ReactorShutdownDefinition definition2 = ((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).GetDefinition(__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex, num);
				if (definition2 != null)
				{
					ReactorShutdownObjectiveManager.Current.Build(__instance, definition2);
					EOSLogger.Debug($"Reactor Shutdown Instance {(((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(__instance), num)}: custom setup complete");
				}
			}
			if ((Object)(object)__instance.m_terminal != (Object)null)
			{
				TerminalInstanceManager.Current.RegisterReactorTerminal(__instance);
			}
		}
	}
	[HarmonyPatch]
	internal class Reactor_OnStateChange
	{
		private static void Startup_OnStateChange(LG_WardenObjective_Reactor reactor, pReactorState oldState, pReactorState newState, bool isDropinState)
		{
		}

		private static void Shutdown_OnStateChange(LG_WardenObjective_Reactor reactor, pReactorState oldState, pReactorState newState, bool isDropinState, ReactorShutdownDefinition def)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			eReactorStatus status = newState.status;
			switch (status - 6)
			{
			case 0:
				GuiManager.PlayerLayer.m_wardenIntel.ShowSubObjectiveMessage("", Text.Get(1080u), false, 200f, 8f, (Action)null);
				reactor.m_progressUpdateEnabled = true;
				reactor.m_currentDuration = 15f;
				reactor.m_lightCollection.SetMode(false);
				reactor.m_sound.Stop();
				def.EventsOnActive.ForEach(delegate(WardenObjectiveEventData e)
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f);
				});
				break;
			case 1:
				GuiManager.PlayerLayer.m_wardenIntel.ShowSubObjectiveMessage("", Text.Get(1081u), false, 200f, 8f, (Action)null);
				reactor.m_progressUpdateEnabled = false;
				reactor.ReadyForVerification = true;
				break;
			case 2:
				reactor.m_progressUpdateEnabled = false;
				if ((Object)(object)def.ChainedPuzzleOnVerificationInstance != (Object)null)
				{
					GuiManager.PlayerLayer.m_wardenIntel.ShowSubObjectiveMessage("", Text.Get(1082u), false, 200f, 8f, (Action)null);
					def.ChainedPuzzleOnVerificationInstance.AttemptInteract((eChainedPuzzleInteraction)0);
				}
				def.EventsOnShutdownPuzzleStarts.ForEach(delegate(WardenObjectiveEventData e)
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f);
				});
				break;
			case 3:
				reactor.m_progressUpdateEnabled = false;
				reactor.m_objectiveCompleteTimer = Clock.Time + 5f;
				def.EventsOnComplete.ForEach(delegate(WardenObjectiveEventData e)
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f);
				});
				break;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static bool Pre_LG_WardenObjective_Reactor_OnStateChange(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState, bool isDropinState)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_isWardenObjective)
			{
				return true;
			}
			if (oldState.stateCount != newState.stateCount)
			{
				__instance.OnStateCountUpdate(newState.stateCount);
			}
			if (oldState.stateProgress != newState.stateProgress)
			{
				__instance.OnStateProgressUpdate(newState.stateProgress);
			}
			if (oldState.status == newState.status)
			{
				return false;
			}
			__instance.ReadyForVerification = false;
			uint zoneInstanceIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetZoneInstanceIndex(__instance);
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(__instance);
			if (ReactorInstanceManager.Current.IsStartupReactor(__instance))
			{
				return true;
			}
			if (ReactorInstanceManager.Current.IsShutdownReactor(__instance))
			{
				ReactorShutdownDefinition definition = ((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).GetDefinition(globalZoneIndex, zoneInstanceIndex);
				if (definition == null)
				{
					EOSLogger.Error("Reactor_OnStateChange: found built custom reactor but its definition is missing, what happened?");
					return false;
				}
				Shutdown_OnStateChange(__instance, oldState, newState, isDropinState, definition);
				__instance.m_currentState = newState;
				return false;
			}
			EOSLogger.Error("Reactor_OnStateChange: found built custom reactor but it's neither startup nor shutdown reactor, what happened?");
			return false;
		}
	}
	[HarmonyPatch]
	internal class Reactor_OnStateCountUpdate
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateCountUpdate")]
		private static bool Pre_LG_WardenObjective_Reactor_OnStateCountUpdate(LG_WardenObjective_Reactor __instance, int count)
		{
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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)
			//IL_0136: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			if (__instance.m_isWardenObjective)
			{
				return true;
			}
			uint zoneInstanceIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetZoneInstanceIndex(__instance);
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(__instance);
			if (ReactorInstanceManager.Current.IsStartupReactor(__instance))
			{
				return true;
			}
			if (ReactorInstanceManager.Current.IsShutdownReactor(__instance))
			{
				ReactorShutdownDefinition definition = ((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).GetDefinition(globalZoneIndex, zoneInstanceIndex);
				if (definition == null)
				{
					EOSLogger.Error("Reactor_OnStateCountUpdate: found built custom reactor but its definition is missing, what happened?");
					return true;
				}
				__instance.m_currentWaveCount = count;
				if (definition.PutVerificationCodeOnTerminal)
				{
					LG_ComputerTerminal instance = ((InstanceManager<LG_ComputerTerminal>)(object)TerminalInstanceManager.Current).GetInstance(((GlobalZoneIndex)definition.VerificationCodeTerminal).GlobalZoneIndexTuple(), definition.VerificationCodeTerminal.InstanceIndex);
					__instance.m_currentWaveData = new ReactorWaveData
					{
						HasVerificationTerminal = (definition.PutVerificationCodeOnTerminal && (Object)(object)instance != (Object)null),
						VerificationTerminalSerial = (((Object)(object)instance != (Object)null) ? instance.ItemKey : string.Empty),
						Warmup = 1f,
						WarmupFail = 1f,
						Wave = 1f,
						Verify = 1f,
						VerifyFail = 1f
					};
				}
				else
				{
					__instance.m_currentWaveData = new ReactorWaveData
					{
						HasVerificationTerminal = false,
						VerificationTerminalSerial = string.Empty,
						Warmup = 1f,
						WarmupFail = 1f,
						Wave = 1f,
						Verify = 1f,
						VerifyFail = 1f
					};
				}
				if (__instance.m_overrideCodes != null && !string.IsNullOrEmpty(((Il2CppArrayBase<string>)(object)__instance.m_overrideCodes)[0]))
				{
					__instance.CurrentStateOverrideCode = ((Il2CppArrayBase<string>)(object)__instance.m_overrideCodes)[0];
				}
				else
				{
					EOSLogger.Error("Reactor_OnStateCountUpdate: code is not built?");
				}
				return false;
			}
			EOSLogger.Error("Reactor_OnStateCountUpdate: found built custom reactor but it's neither a startup nor shutdown reactor, what happen?");
			return true;
		}
	}
	[HarmonyPatch]
	internal class Reactor_Update
	{
		private static bool _checked;

		private static TextDataBlock shutdownVerification_GUIText;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "Update")]
		private static bool Pre_LG_WardenObjective_Reactor_Update(LG_WardenObjective_Reactor __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (__instance.m_isWardenObjective || (int)__instance.m_currentState.status != 7)
			{
				return true;
			}
			if (!_checked)
			{
				shutdownVerification_GUIText = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.ExtraObjectiveSetup_ReactorShutdown.SecurityVerificationRequired");
				_checked = true;
			}
			string empty = string.Empty;
			empty = ((!__instance.m_currentWaveData.HasVerificationTerminal) ? string.Format(Text.Get(1107u), "<color=orange>" + __instance.CurrentStateOverrideCode + "</color>") : string.Format((shutdownVerification_GUIText != null) ? Text.Get(((GameDataBlockBase<TextDataBlock>)(object)shutdownVerification_GUIText).persistentID) : "SECURITY VERIFICATION REQUIRED. USE COMMAND <color=orange>REACTOR_VERIFY</color> AND FIND CODE ON <color=orange>{0}</color>.", __instance.m_currentWaveData.VerificationTerminalSerial));
			__instance.SetGUIMessage(true, empty, (ePUIMessageStyle)3, false, "", "");
			return false;
		}
	}
	[HarmonyPatch]
	internal class Reactor_CommandInterpreter
	{
		private static bool Handle_ReactorShutdown(LG_ComputerTerminalCommandInterpreter __instance)
		{
			LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
			uint zoneInstanceIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetZoneInstanceIndex(connectedReactor);
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(connectedReactor);
			ReactorShutdownDefinition definition = ((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).GetDefinition(globalZoneIndex, zoneInstanceIndex);
			if (definition == null)
			{
				EOSLogger.Error("ReactorVerify: found built custom reactor shutdown but its definition is missing, what happened?");
				return true;
			}
			__instance.AddOutput((TerminalLineType)3, Text.Get(3436726297u), 4f, (TerminalSoundType)0, (TerminalSoundType)0);
			if ((Object)(object)definition.ChainedPuzzleToActiveInstance != (Object)null)
			{
				__instance.AddOutput(Text.Get(2277987284u), true);
				if (SNet.IsMaster)
				{
					definition.ChainedPuzzleToActiveInstance.AttemptInteract((eChainedPuzzleInteraction)0);
				}
			}
			else
			{
				connectedReactor.AttemptInteract((eReactorInteraction)6, 0f);
			}
			return false;
		}

		private static bool Handle_ReactorStartup_SpecialCommand(LG_ComputerTerminalCommandInterpreter __instance, TERM_Command cmd)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
			if (__instance.m_terminal.CommandIsHidden(cmd))
			{
				return true;
			}
			_ = __instance.m_terminal.ItemKey;
			OverrideReactorComp component = ((Component)connectedReactor).gameObject.GetComponent<OverrideReactorComp>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (!connectedReactor.ReadyForVerification)
			{
				__instance.AddOutput("", true);
				__instance.AddOutput((TerminalLineType)3, ReactorStartupOverrideManager.NotReadyForVerificationOutputText, 4f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance.AddOutput("", true);
				return false;
			}
			if (component.IsCorrectTerminal(__instance.m_terminal))
			{
				EOSLogger.Log("Reactor Verify Correct!");
				if (SNet.IsMaster)
				{
					if (connectedReactor.m_currentWaveCount == connectedReactor.m_waveCountMax)
					{
						connectedReactor.AttemptInteract((eReactorInteraction)5, 0f);
					}
					else
					{
						connectedReactor.AttemptInteract((eReactorInteraction)3, 0f);
					}
				}
				else
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(connectedReactor.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)3, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
				}
				__instance.AddOutput(ReactorStartupOverrideManager.CorrectTerminalOutputText, true);
			}
			else
			{
				EOSLogger.Log("Reactor Verify Incorrect!");
				__instance.AddOutput("", true);
				__instance.AddOutput((TerminalLineType)3, ReactorStartupOverrideManager.IncorrectTerminalOutputText, 4f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance.AddOutput("", true);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")]
		private static bool Pre_ReceiveCommand(LG_ComputerTerminalCommandInterpreter __instance, TERM_Command cmd, string inputLine, string param1, string param2)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
			if ((Object)(object)connectedReactor == (Object)null)
			{
				return true;
			}
			if ((int)cmd == 23 && !connectedReactor.m_isWardenObjective)
			{
				return Handle_ReactorShutdown(__instance);
			}
			if ((int)cmd == 42)
			{
				return Handle_ReactorStartup_SpecialCommand(__instance, cmd);
			}
			return true;
		}
	}
}
namespace EOSExt.Reactor.Patches.Shutdown
{
	[HarmonyPatch]
	internal class Reactor_OnReactorShutdownVerifyChaosDone
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "OnReactorShutdownVerifyChaosDone")]
		private static bool Pre_LG_ComputerTerminalCommandInterpreter_OnReactorShutdownVerifyChaosDone(LG_ComputerTerminalCommandInterpreter __instance)
		{
			LG_WardenObjective_Reactor connectedReactor = __instance.m_terminal.ConnectedReactor;
			if ((Object)(object)connectedReactor == (Object)null || connectedReactor.m_isWardenObjective)
			{
				return true;
			}
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) globalZoneIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetGlobalZoneIndex(connectedReactor);
			uint zoneInstanceIndex = ((InstanceManager<LG_WardenObjective_Reactor>)ReactorInstanceManager.Current).GetZoneInstanceIndex(connectedReactor);
			ReactorShutdownDefinition definition = ((InstanceDefinitionManager<ReactorShutdownDefinition>)ReactorShutdownObjectiveManager.Current).GetDefinition(globalZoneIndex, zoneInstanceIndex);
			if (definition == null)
			{
				EOSLogger.Error("OnReactorShutdownVerifyChaosDone: found built custom reactor shutdown but its definition is missing, what happened?");
				return false;
			}
			connectedReactor.AttemptInteract((eReactorInteraction)(((Object)(object)definition.ChainedPuzzleOnVerificationInstance != (Object)null) ? 8 : 9), 0f);
			return false;
		}
	}
}
namespace EOSExt.Reactor.Managers
{
	public sealed class ReactorInstanceManager : InstanceManager<LG_WardenObjective_Reactor>
	{
		private HashSet<IntPtr> startupReactor = new HashSet<IntPtr>();

		private HashSet<IntPtr> shutdownReactor = new HashSet<IntPtr>();

		public static ReactorInstanceManager Current { get; private set; }

		public override (eDimensionIndex, LG_LayerType, eLocalZoneIndex) GetGlobalZoneIndex(LG_WardenObjective_Reactor 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 void MarkAsStartupReactor(LG_WardenObjective_Reactor reactor)
		{
			if (shutdownReactor.Contains(((Il2CppObjectBase)reactor).Pointer))
			{
				throw new ArgumentException("Invalid: cannot mark a reactor both as startup and shutdown reactor");
			}
			startupReactor.Add(((Il2CppObjectBase)reactor).Pointer);
		}

		public void MarkAsShutdownReactor(LG_WardenObjective_Reactor reactor)
		{
			if (startupReactor.Contains(((Il2CppObjectBase)reactor).Pointer))
			{
				throw new ArgumentException("Invalid: cannot mark a reactor both as startup and shutdown reactor");
			}
			shutdownReactor.Add(((Il2CppObjectBase)reactor).Pointer);
		}

		public bool IsStartupReactor(LG_WardenObjective_Reactor reactor)
		{
			return startupReactor.Contains(((Il2CppObjectBase)reactor).Pointer);
		}

		public bool IsShutdownReactor(LG_WardenObjective_Reactor reactor)
		{
			return shutdownReactor.Contains(((Il2CppObjectBase)reactor).Pointer);
		}

		private void Clear()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			foreach (IntPtr item in startupReactor)
			{
				LG_WardenObjective_Reactor val = new LG_WardenObjective_Reactor(item);
				if ((int)val != 0)
				{
					CellSoundPlayer sound = val.m_sound;
					if (sound != null)
					{
						sound.Recycle();
					}
				}
			}
			foreach (IntPtr item2 in shutdownReactor)
			{
				LG_WardenObjective_Reactor val2 = new LG_WardenObjective_Reactor(item2);
				if ((int)val2 != 0)
				{
					CellSoundPlayer sound2 = val2.m_sound;
					if (sound2 != null)
					{
						sound2.Recycle();
					}
				}
			}
			startupReactor.Clear();
			shutdownReactor.Clear();
		}

		public void SetupReactorTerminal(LG_WardenObjective_Reactor reactor, TerminalDefinition reactorTerminalData)
		{
			reactor.SpawnNode.m_zone.TerminalsSpawnedInZone.Add(reactor.m_terminal);
			if (reactorTerminalData != null)
			{
				reactorTerminalData.LocalLogFiles?.ForEach(delegate(TerminalLogFileData log)
				{
					reactor.m_terminal.AddLocalLog(log, true);
				});
				reactorTerminalData.UniqueCommands?.ForEach(delegate(CustomCommand cmd)
				{
					EOSTerminalUtils.AddUniqueCommand(reactor.m_terminal, cmd);
				});
				EOSTerminalUtils.BuildPassword(reactor.m_terminal, reactorTerminalData.PasswordData);
			}
		}

		public static LG_WardenObjective_Reactor FindVanillaReactor(LG_LayerType layer, int count)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if (count < 0)
			{
				EOSLogger.Error($"FindVanillaReactor: Count should be non-negative, but got {count}!");
				return null;
			}
			LG_WardenObjective_Reactor val = null;
			int num = count;
			Enumerator<LayerChainIndex, iWardenObjectiveItem> enumerator = WardenObjectiveManager.Current.m_wardenObjectiveItem.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<LayerChainIndex, iWardenObjectiveItem> current = enumerator.Current;
				if (current.Key.Layer != layer)
				{
					continue;
				}
				iWardenObjectiveItem value = current.Value;
				val = ((value != null) ? ((Il2CppObjectBase)value).TryCast<LG_WardenObjective_Reactor>() : null);
				if (!((Object)(object)val == (Object)null))
				{
					if (num <= 0)
					{
						break;
					}
					val = null;
					num--;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				EOSLogger.Error($"FindVanillaReactor: reactor not found with index(Count) {num} in {layer}!");
			}
			return val;
		}

		private ReactorInstanceManager()
		{
			LevelAPI.OnLevelCleanup += Clear;
		}

		static ReactorInstanceManager()
		{
			Current = new ReactorInstanceManager();
		}
	}
	internal class ReactorStartupOverrideManager : InstanceDefinitionManager<ReactorStartupOverride>
	{
		private List<ReactorStartupOverride> builtOverride = new List<ReactorStartupOverride>();

		public static uint SpecialCmdVerifyTextID { get; private set; }

		public static uint MainTerminalTextID { get; private set; }

		public static uint CooldownCommandDescTextID { get; private set; }

		public static uint InfiniteWaveVerifyTextID { get; private set; }

		public static uint NotReadyForVerificationOutputTextID { get; private set; }

		public static uint IncorrectTerminalOutputTextID { get; private set; }

		public static uint CorrectTerminalOutputTextID { get; private set; }

		public static string CoolDownCommandDesc
		{
			get
			{
				if (CooldownCommandDescTextID == 0)
				{
					return "Confirm Reactor Startup Cooling Protocol";
				}
				return Text.Get(CooldownCommandDescTextID);
			}
		}

		public static string MainTerminalText
		{
			get
			{
				if (MainTerminalTextID == 0)
				{
					return "Main Terminal";
				}
				return Text.Get(MainTerminalTextID);
			}
		}

		public static string SpecialCmdVerifyText
		{
			get
			{
				if (SpecialCmdVerifyTextID == 0)
				{
					return "REACTOR COOLING REQUIRED ({0}/{1})\nMANUAL OVERRIDE REQUIRED. USE COMMAND <color=orange>REACTOR_COOLDOWN</color> AT {2}";
				}
				return Text.Get(SpecialCmdVerifyTextID);
			}
		}

		public static string InfiniteWaveVerifyText
		{
			get
			{
				if (InfiniteWaveVerifyTextID == 0)
				{
					return "VERIFICATION ({0}/{1}).";
				}
				return Text.Get(InfiniteWaveVerifyTextID);
			}
		}

		public static string NotReadyForVerificationOutputText
		{
			get
			{
				if (NotReadyForVerificationOutputTextID == 0)
				{
					return "<color=red>Reactor intensive test in progress, cannot initate cooldown</color>";
				}
				return Text.Get(NotReadyForVerificationOutputTextID);
			}
		}

		public static string CorrectTerminalOutputText
		{
			get
			{
				if (CorrectTerminalOutputTextID == 0)
				{
					return "<color=red>Reactor stage cooldown completed</color>";
				}
				return Text.Get(CorrectTerminalOutputTextID);
			}
		}

		public static string IncorrectTerminalOutputText
		{
			get
			{
				if (IncorrectTerminalOutputTextID == 0)
				{
					return "<color=red>Incorrect terminal, cannot initate cooldown</color>";
				}
				return Text.Get(IncorrectTerminalOutputTextID);
			}
		}

		public static ReactorStartupOverrideManager Current { get; private set; }

		protected override string DEFINITION_NAME => "ReactorStartup";

		public static void FetchOverrideTextDB()
		{
			SpecialCmdVerifyTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownVerification");
			MainTerminalTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownMainTerminalName");
			CooldownCommandDescTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownCoolDown.CommandDesc");
			InfiniteWaveVerifyTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.Verification.InfiniteWave");
			NotReadyForVerificationOutputTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownCoolDown.Not_ReadyForVerification_Output");
			IncorrectTerminalOutputTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownCoolDown.IncorrectTerminal_Output");
			CorrectTerminalOutputTextID = GameDataBlockBase<TextDataBlock>.GetBlockID("InGame.WardenObjective_Reactor.MeltdownCoolDown.CorrectTerminal_Output");
		}

		protected override void AddDefinitions(InstanceDefinitionsForLevel<ReactorStartupOverride> definitions)
		{
			definitions.Definitions.ForEach(delegate(ReactorStartupOverride def)
			{
				def.Overrides.Sort((WaveOverride o1, WaveOverride o2) => (o1.WaveIndex >= o2.WaveIndex) ? ((o1.WaveIndex > o2.WaveIndex) ? 1 : 0) : (-1));
			});
			base.AddDefinitions(definitions);
		}

		internal void Build(LG_WardenObjective_Reactor reactor, ReactorStartupOverride def)
		{
			if (!reactor.m_isWardenObjective)
			{
				EOSLogger.Error($"ReactorStartup: Reactor Override for reactor {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}, Instance_{((BaseInstanceDefinition)def).InstanceIndex} is not setup by vanilla, won't override");
				return;
			}
			OverrideReactorComp overrideReactorComp = ((Component)reactor).gameObject.AddComponent<OverrideReactorComp>();
			overrideReactorComp.ChainedReactor = reactor;
			overrideReactorComp.overrideData = def;
			overrideReactorComp.UsingLightEffect = false;
			overrideReactorComp.Init();
			ReactorInstanceManager.Current.MarkAsStartupReactor(reactor);
			ReactorInstanceManager.Current.SetupReactorTerminal(reactor, def.ReactorTerminal);
			def.ChainedPuzzleToActiveInstance = reactor.m_chainedPuzzleToStartSequence;
			if ((Object)(object)def.ChainedPuzzleToActiveInstance != (Object)null)
			{
				ChainedPuzzleInstance chainedPuzzleToActiveInstance = def.ChainedPuzzleToActiveInstance;
				chainedPuzzleToActiveInstance.OnPuzzleSolved += Action.op_Implicit((Action)delegate
				{
					def.EventsOnActive.ForEach(delegate(WardenObjectiveEventData e)
					{
						WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(e, (eWardenObjectiveEventTrigger)0, true, 0f);
					});
				});
			}
			builtOverride.Add(def);
			EOSLogger.Debug($"ReactorStartup: {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}, Instance_{((BaseInstanceDefinition)def).InstanceIndex}, override completed");
		}

		private void OnLevelCleanup()
		{
			builtOverride.ForEach(delegate(ReactorStartupOverride def)
			{
				def.ChainedPuzzleToActiveInstance = null;
			});
			builtOverride.Clear();
		}

		private ReactorStartupOverrideManager()
		{
			LevelAPI.OnLevelCleanup += OnLevelCleanup;
			LevelAPI.OnBuildStart += OnLevelCleanup;
		}

		static ReactorStartupOverrideManager()
		{
			SpecialCmdVerifyTextID = 0u;
			MainTerminalTextID = 0u;
			CooldownCommandDescTextID = 0u;
			InfiniteWaveVerifyTextID = 0u;
			NotReadyForVerificationOutputTextID = 0u;
			IncorrectTerminalOutputTextID = 0u;
			CorrectTerminalOutputTextID = 0u;
			Current = new ReactorStartupOverrideManager();
			EventAPI.OnExpeditionStarted += FetchOverrideTextDB;
		}
	}
	internal class ReactorShutdownObjectiveManager : InstanceDefinitionManager<ReactorShutdownDefinition>
	{
		private List<ReactorShutdownDefinition> builtShutdownPuzzles = new List<ReactorShutdownDefinition>();

		public static ReactorShutdownObjectiveManager Current { get; private set; }

		protected override string DEFINITION_NAME => "ReactorShutdown";

		private void GenericObjectiveSetup(LG_WardenObjective_Reactor reactor, TerminalDefinition reactorTerminalData)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			reactor.m_serialNumber = SerialGenerator.GetUniqueSerialNo();
			reactor.m_itemKey = "REACTOR_" + reactor.m_serialNumber;
			reactor.m_terminalItem = GOUtil.GetInterfaceFromComp<iTerminalItem>(reactor.m_terminalItemComp);
			reactor.m_terminalItem.Setup(reactor.m_itemKey, (AIG_CourseNode)null);
			reactor.m_terminalItem.FloorItemStatus = EnumUtil.GetRandomValue<eFloorInventoryObjectStatus>();
			reactor.m_overrideCodes = Il2CppStringArray.op_Implicit(new string[1] { SerialGenerator.GetCodeWord() });
			reactor.m_terminalItem.OnWantDetailedInfo = Func<List<string>, List<string>>.op_Implicit((Func<List<string>, List<string>>)delegate(List<string> defaultDetails)
			{
				List<string> list = new List<string> { "----------------------------------------------------------------", "MAIN POWER REACTOR" };
				Enumerator<string> enumerator = defaultDetails.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					list.Add(current);
				}
				list.Add("----------------------------------------------------------------");
				return ListExtensions.ToIl2Cpp<string>(list);
			});
			reactor.m_terminal = GOUtil.SpawnChildAndGetComp<LG_ComputerTerminal>(reactor.m_terminalPrefab, reactor.m_terminalAlign);
			reactor.m_terminal.Setup((TerminalStartStateData)null, (TerminalPlacementData)null);
			reactor.m_terminal.ConnectedReactor = reactor;
			ReactorInstanceManager.Current.SetupReactorTerminal(reactor, reactorTerminalData);
		}

		private void OnLateBuildJob(LG_WardenObjective_Reactor reactor, BaseReactorDefinition reactorDefinition)
		{
			//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_0035: 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_0044: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			reactor.m_stateReplicator = SNet_StateReplicator<pReactorState, pReactorInteraction>.Create(new iSNet_StateReplicatorProvider<pReactorState, pReactorInteraction>(((Il2CppObjectBase)reactor).Pointer), (eSNetReplicatorLifeTime)1, default(pReactorState), (SNet_ChannelType)2);
			GenericObjectiveSetup(reactor, reactorDefinition.ReactorTerminal);
			reactor.m_sound = new CellSoundPlayer(reactor.m_terminalAlign.position);
			reactor.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_LOOP, true);
			reactor.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 100f);
			reactor.m_terminal.m_command.SetupReactorCommands(false, true);
		}

		internal void Build(LG_WardenObjective_Reactor reactor, ReactorShutdownDefinition def)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_015f: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_019d: Expected O, but got Unknown
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			if (reactor.m_isWardenObjective)
			{
				EOSLogger.Error($"ReactorShutdown: Reactor definition for reactor {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}, Instance_{((BaseInstanceDefinition)def).InstanceIndex} is already setup by vanilla, won't build.");
				return;
			}
			OnLateBuildJob(reactor, def);
			reactor.m_lightCollection = LG_LightCollection.Create(reactor.m_reactorArea.m_courseNode, reactor.m_terminalAlign.position, (LG_LightCollectionSorting)1, float.MaxValue);
			reactor.m_lightCollection.SetMode(true);
			if (def.PutVerificationCodeOnTerminal)
			{
				LG_ComputerTerminal instance = ((InstanceManager<LG_ComputerTerminal>)(object)TerminalInstanceManager.Current).GetInstance(((GlobalZoneIndex)def.VerificationCodeTerminal).GlobalZoneIndexTuple(), def.VerificationCodeTerminal.InstanceIndex);
				if ((Object)(object)instance == (Object)null)
				{
					EOSLogger.Error($"ReactorShutdown: PutVerificationCodeOnTerminal is specified but could NOT find terminal {def.VerificationCodeTerminal}, will show verification code upon shutdown initiation");
				}
				else
				{
					string fileName = "reactor_ver" + SerialGenerator.GetCodeWordPrefix() + ".log";
					TerminalLogFileData val = new TerminalLogFileData
					{
						FileName = fileName,
						FileContent = new LocalizedText
						{
							UntranslatedText = string.Format(Text.Get(182408469u), ((Il2CppArrayBase<string>)(object)reactor.m_overrideCodes)[0].ToUpperInvariant()),
							Id = 0u
						}
					};
					instance.AddLocalLog(val, true);
					instance.m_command.ClearOutputQueueAndScreenBuffer();
					instance.m_command.AddInitialTerminalOutput();
				}
			}
			if (reactor.SpawnNode != null && reactor.m_terminalItem != null)
			{
				reactor.m_terminalItem.SpawnNode = reactor.SpawnNode;
				reactor.m_terminalItem.FloorItemLocation = reactor.SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
			}
			if (def.ChainedPuzzleToActive != 0)
			{
				ChainedPuzzleDataBlock block = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(def.ChainedPuzzleToActive);
				if (block == null)
				{
					EOSLogger.Error("ReactorShutdown: ChainedPuzzleToActive is specified but could not find its ChainedPuzzleDatablock definition!");
				}
				else
				{
					_ = ((Component)reactor).transform.position;
					def.ChainedPuzzleToActiveInstance = ChainedPuzzleManager.CreatePuzzleInstance(block, reactor.SpawnNode.m_area, reactor.m_chainedPuzzleAlign.position, ((Component)reactor).transform);
					ChainedPuzzleInstance chainedPuzzleToActiveInstance = def.ChainedPuzzleToActiveInstance;
					chainedPuzzleToActiveInstance.OnPuzzleSolved += Action.op_Implicit((Action)delegate
					{
						if (SNet.IsMaster)
						{
							reactor.AttemptInteract((eReactorInteraction)6, 0f);
						}
					});
				}
			}
			else
			{
				EOSLogger.Debug("ReactorShutdown: Reactor has no ChainedPuzzleToActive, will start shutdown sequence on shutdown command initiation.");
			}
			if (def.ChainedPuzzleOnVerification != 0)
			{
				ChainedPuzzleDataBlock block2 = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(def.ChainedPuzzleOnVerification);
				if (block2 == null)
				{
					EOSLogger.Error("ReactorShutdown: ChainedPuzzleOnVerification is specified but could not find its ChainedPuzzleDatablock definition! Will complete shutdown on verification");
				}
				_ = ((Component)reactor).transform.position;
				def.ChainedPuzzleOnVerificationInstance = ChainedPuzzleManager.CreatePuzzleInstance(block2, reactor.SpawnNode.m_area, reactor.m_chainedPuzzleAlign.position, ((Component)reactor).transform);
				ChainedPuzzleInstance chainedPuzzleOnVerificationInstance = def.ChainedPuzzleOnVerificationInstance;
				chainedPuzzleOnVerificationInstance.OnPuzzleSolved += Action.op_Implicit((Action)delegate
				{
					if (SNet.IsMaster)
					{
						reactor.AttemptInteract((eReactorInteraction)9, 0f);
					}
				});
			}
			else
			{
				EOSLogger.Debug("ReactorShutdown: ChainedPuzzleOnVerification unspecified, will complete shutdown on verification.");
			}
			LG_ComputerTerminal terminal = reactor.m_terminal;
			iLG_SpawnedInNodeHandler val2 = ((terminal != null) ? ((Component)terminal).GetComponent<iLG_SpawnedInNodeHandler>() : null);
			if (val2 != null)
			{
				val2.SpawnNode = reactor.SpawnNode;
			}
			reactor.SetLightsEnabled(reactor.m_lightsWhenOff, false);
			reactor.SetLightsEnabled(reactor.m_lightsWhenOn, true);
			builtShutdownPuzzles.Add(def);
			ReactorInstanceManager.Current.MarkAsShutdownReactor(reactor);
			EOSLogger.Debug($"ReactorShutdown: {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}, Instance_{((BaseInstanceDefinition)def).InstanceIndex}, custom setup completed");
		}

		private void OnLevelCleanup()
		{
			builtShutdownPuzzles.ForEach(delegate(ReactorShutdownDefinition def)
			{
				ChainedPuzzleInstance chainedPuzzleOnVerificationInstance = (def.ChainedPuzzleToActiveInstance = null);
				def.ChainedPuzzleOnVerificationInstance = chainedPuzzleOnVerificationInstance;
			});
			builtShutdownPuzzles.Clear();
		}

		private ReactorShutdownObjectiveManager()
		{
			LevelAPI.OnLevelCleanup += OnLevelCleanup;
			LevelAPI.OnBuildStart += OnLevelCleanup;
		}

		static ReactorShutdownObjectiveManager()
		{
			Current = new ReactorShutdownObjectiveManager();
		}
	}
}
namespace EOSExt.Reactor.Definition
{
	public enum EOSReactorVerificationType
	{
		NORMAL,
		BY_SPECIAL_COMMAND,
		BY_WARDEN_EVENT
	}
	public class WaveOverride
	{
		public int WaveIndex { get; set; } = -1;


		public EOSReactorVerificationType VerificationType { get; set; }

		public bool HideVerificationTimer { get; set; }

		public bool ChangeVerifyZone { get; set; }

		public BaseInstanceDefinition VerifyZone { get; set; } = new BaseInstanceDefinition();


		[JsonIgnore]
		public LG_ComputerTerminal VerifyTerminal { get; set; }
	}
	public class ReactorStartupOverride : BaseReactorDefinition
	{
		public bool StartupOnDrop { get; set; }

		[JsonIgnore]
		public WardenObjectiveDataBlock ObjectiveDB { get; set; }

		public List<WaveOverride> Overrides { get; set; } = new List<WaveOverride>
		{
			new WaveOverride()
		};

	}
	internal class WardenEvents
	{
		public enum EventType
		{
			ReactorStartup = 150,
			CompleteCurrentVerify
		}

		internal static void ReactorStartup(WardenObjectiveEventData e)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster)
			{
				return;
			}
			LG_WardenObjective_Reactor val = ReactorInstanceManager.FindVanillaReactor(e.Layer, e.Count);
			WardenObjectiveDataBlock val2 = default(WardenObjectiveDataBlock);
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(e.Layer, ref val2) || val2 == null)
			{
				EOSLogger.Error("CompleteCurrentReactorWave: Cannot get WardenObjectiveDataBlock");
				return;
			}
			if ((int)val2.Type != 1)
			{
				EOSLogger.Error($"CompleteCurrentReactorWave: {e.Layer} is not ReactorStartup. CompleteCurrentReactorWave is invalid.");
				return;
			}
			if ((Object)(object)val == (Object)null)
			{
				EOSLogger.Error($"ReactorStartup: Cannot find reactor in {e.Layer}.");
				return;
			}
			if ((int)val.m_currentState.status == 0)
			{
				if (SNet.IsMaster)
				{
					val.AttemptInteract((eReactorInteraction)0, 0f);
				}
				val.m_terminal.TrySyncSetCommandHidden((TERM_Command)21);
			}
			EOSLogger.Debug($"ReactorStartup: Current reactor wave for {e.Layer} completed");
		}

		internal static void CompleteCurrentVerify(WardenObjectiveEventData e)
		{
			//IL_0006: 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)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0068: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			WardenObjectiveDataBlock val = default(WardenObjectiveDataBlock);
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(e.Layer, ref val) || val == null)
			{
				EOSLogger.Error("CompleteCurrentReactorWave: Cannot get WardenObjectiveDataBlock");
				return;
			}
			if ((int)val.Type != 1)
			{
				EOSLogger.Error($"CompleteCurrentReactorWave: {e.Layer} is not ReactorStartup. CompleteCurrentReactorWave is invalid.");
				return;
			}
			LG_WardenObjective_Reactor val2 = ReactorInstanceManager.FindVanillaReactor(e.Layer, e.Count);
			if ((Object)(object)val2 == (Object)null)
			{
				EOSLogger.Error($"CompleteCurrentReactorWave: Cannot find reactor in {e.Layer}.");
				return;
			}
			if (SNet.IsMaster)
			{
				if (val2.m_currentWaveCount == val2.m_waveCountMax)
				{
					val2.AttemptInteract((eReactorInteraction)5, 0f);
				}
				else
				{
					val2.AttemptInteract((eReactorInteraction)3, 0f);
				}
			}
			else
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(val2.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)3, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
			EOSLogger.Debug($"CompleteCurrentReactorWave: Current reactor verify for {e.Layer} completed");
		}
	}
	public class BaseReactorDefinition : BaseInstanceDefinition
	{
		[JsonPropertyOrder(-9)]
		public TerminalDefinition ReactorTerminal { get; set; } = new TerminalDefinition();


		[JsonPropertyOrder(-9)]
		public List<WardenObjectiveEventData> EventsOnActive { get; set; } = new List<WardenObjectiveEventData>();


		[JsonIgnore]
		public ChainedPuzzleInstance ChainedPuzzleToActiveInstance { get; set; }
	}
	public class ReactorShutdownDefinition : BaseReactorDefinition
	{
		[JsonPropertyOrder(-9)]
		public uint ChainedPuzzleToActive { get; set; }

		public bool PutVerificationCodeOnTerminal { get; set; }

		public BaseInstanceDefinition VerificationCodeTerminal { get; set; } = new BaseInstanceDefinition();


		public uint ChainedPuzzleOnVerification { get; set; }

		[JsonIgnore]
		public ChainedPuzzleInstance ChainedPuzzleOnVerificationInstance { get; set; }

		public List<WardenObjectiveEventData> EventsOnShutdownPuzzleStarts { get; set; } = new List<WardenObjectiveEventData>();


		public List<WardenObjectiveEventData> EventsOnComplete { get; set; } = new List<WardenObjectiveEventData>();

	}
}
namespace EOSExt.Reactor.Component
{
	public class OverrideReactorComp : MonoBehaviour
	{
		private static Color LowTemperature;

		private static Color HighTemperature;

		private LG_Light[] _lights;

		private float _updateTimer;

		private List<WaveOverride> WaveData = new List<WaveOverride>();

		public LG_WardenObjective_Reactor ChainedReactor { get; internal set; }

		public ReactorStartupOverride overrideData { get; internal set; }

		public bool UsingLightEffect { get; set; } = true;


		public WardenObjectiveDataBlock ObjectiveData => overrideData?.ObjectiveDB;

		public void Init()
		{
			if ((Object)(object)ChainedReactor == (Object)null || overrideData == null)
			{
				EOSLogger.Error("ReactorOverride not properly initialized!");
				return;
			}
			int i;
			for (i = 0; i < ObjectiveData.ReactorWaves.Count; i++)
			{
				int num = overrideData.Overrides.FindIndex((WaveOverride o) => o.WaveIndex == i);
				if (num != -1)
				{
					WaveData.Add(new WaveOverride
					{
						WaveIndex = i,
						VerificationType = overrideData.Overrides[num].VerificationType,
						HideVerificationTimer = overrideData.Overrides[num].HideVerificationTimer,
						ChangeVerifyZone = overrideData.Overrides[num].ChangeVerifyZone,
						VerifyZone = overrideData.Overrides[num].VerifyZone
					});
				}
				else
				{
					WaveData.Add(new WaveOverride
					{
						WaveIndex = i
					});
				}
			}
			LevelAPI.OnEnterLevel += OnEnterLevel;
		}

		private void OnEnterLevel()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			LG_WardenObjective_Reactor chainedReactor = ChainedReactor;
			LG_ComputerTerminal terminal = ChainedReactor.m_terminal;
			if ((int)ObjectiveData.Type != 1)
			{
				EOSLogger.Error("Only Reactor Startup is supported");
				((Behaviour)this).enabled = false;
				return;
			}
			if (UsingLightEffect)
			{
				_lights = ((IEnumerable<LG_Light>)chainedReactor.SpawnNode.m_lightsInNode).Where((LG_Light x) => (int)x.m_category == 3).ToArray();
				chainedReactor.m_lightCollection.RemoveLights(Il2CppReferenceArray<LG_Light>.op_Implicit(_lights));
			}
			if (overrideData.StartupOnDrop && SNet.IsMaster)
			{
				chainedReactor.AttemptInteract((eReactorInteraction)0, 0f);
				terminal.TrySyncSetCommandHidden((TERM_Command)21);
			}
			SetupVerifyZoneOverrides();
			SetupWaves();
		}

		private void SetupVerifyZoneOverrides()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Expected O, but got Unknown
			//IL_041f: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: 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)
			LG_Zone val = default(LG_Zone);
			foreach (WaveOverride waveDatum in WaveData)
			{
				if (!waveDatum.ChangeVerifyZone)
				{
					continue;
				}
				if (waveDatum.VerificationType == EOSReactorVerificationType.BY_WARDEN_EVENT)
				{
					EOSLogger.Error($"VerifyZoneOverrides: Wave_{waveDatum.WaveIndex} - Verification Type is {2}, which doesn't work with VerifyZoneOverride");
					continue;
				}
				BaseInstanceDefinition verifyZone = waveDatum.VerifyZone;
				if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(((GlobalZoneIndex)verifyZone).DimensionIndex, ((GlobalZoneIndex)verifyZone).LayerType, ((GlobalZoneIndex)verifyZone).LocalIndex, ref val) || (Object)(object)val == (Object)null)
				{
					EOSLogger.Error($"VerifyZoneOverrides: Wave_{waveDatum.WaveIndex} - Cannot find target zone {((GlobalZoneIndex)verifyZone).GlobalZoneIndexTuple()}.");
					continue;
				}
				if (val.TerminalsSpawnedInZone == null || val.TerminalsSpawnedInZone.Count <= 0)
				{
					EOSLogger.Error($"VerifyZoneOverrides: No spawned terminal found in target zone {((GlobalZoneIndex)verifyZone).GlobalZoneIndexTuple()}.");
					continue;
				}
				LG_ComputerTerminal val2 = null;
				if (verifyZone.InstanceIndex >= 0)
				{
					val2 = ((InstanceManager<LG_ComputerTerminal>)(object)TerminalInstanceManager.Current).GetInstance(((GlobalZoneIndex)verifyZone).GlobalZoneIndexTuple(), verifyZone.InstanceIndex);
				}
				else
				{
					List<LG_ComputerTerminal> instancesInZone = ((InstanceManager<LG_ComputerTerminal>)(object)TerminalInstanceManager.Current).GetInstancesInZone(((GlobalZoneIndex)verifyZone).GlobalZoneIndexTuple());
					int index = Builder.SessionSeedRandom.Range(0, instancesInZone.Count, "NO_TAG");
					val2 = instancesInZone[index];
				}
				if ((Object)(object)val2 == (Object)null)
				{
					EOSLogger.Error($"VerifyZoneOverride: cannot find target terminal with Terminal Instance Index: {waveDatum}");
				}
				waveDatum.VerifyTerminal = val2;
				ReactorWaveData waveData = ObjectiveData.ReactorWaves[waveDatum.WaveIndex];
				TerminalLogFileData val3 = null;
				if (waveData.VerifyInOtherZone)
				{
					List<LG_ComputerTerminal> list = EOSTerminalUtils.FindTerminal(ChainedReactor.SpawnNode.m_dimension.DimensionIndex, ChainedReactor.SpawnNode.LayerType, waveData.ZoneForVerification, (Predicate<LG_ComputerTerminal>)((LG_ComputerTerminal x) => x.ItemKey == waveData.VerificationTerminalSerial));
					if (list == null || list.Count < 1)
					{
						EOSLogger.Error($"Wave_{waveDatum.WaveIndex}: cannot find vanilla verification terminal in {(ChainedReactor.SpawnNode.m_dimension.DimensionIndex, ChainedReactor.SpawnNode.LayerType, waveData.ZoneForVerification)}, unable to override");
						continue;
					}
					LG_ComputerTerminal val4 = list[0];
					if ((Object)(object)val4 == (Object)null)
					{
						EOSLogger.Error($"VerifyZoneOverrides: Wave_{waveDatum.WaveIndex} - Cannot find log terminal");
						continue;
					}
					string text = waveData.VerificationTerminalFileName.ToUpperInvariant();
					val3 = EOSTerminalUtils.GetLocalLog(val4, text);
					if (val3 == null)
					{
						EOSLogger.Error("VerifyZoneOverrides: Cannot find vanilla-generated reactor verify log on terminal...");
						continue;
					}
					val4.RemoveLocalLog(text);
					EOSTerminalUtils.ResetInitialOutput(val4);
				}
				else
				{
					waveData.VerificationTerminalFileName = "reactor_ver" + SerialGenerator.GetCodeWordPrefix() + ".log";
					val3 = new TerminalLogFileData
					{
						FileName = waveData.VerificationTerminalFileName,
						FileContent = new LocalizedText
						{
							UntranslatedText = string.Format(Text.Get(182408469u), ((Il2CppArrayBase<string>)(object)ChainedReactor.m_overrideCodes)[waveDatum.WaveIndex].ToUpper()),
							Id = 0u
						}
					};
					EOSLogger.Debug($"VerifyZoneOverrides: Wave_{waveDatum.WaveIndex} - Log generated.");
				}
				waveData.HasVerificationTerminal = true;
				waveData.VerificationTerminalSerial = val2.ItemKey;
				val2.AddLocalLog(val3, true);
				EOSTerminalUtils.ResetInitialOutput(val2);
				EOSLogger.Debug($"VerifyZoneOverrides: Wave_{waveDatum.WaveIndex} verification overriden");
			}
		}

		private void SetupWaves()
		{
			//IL_0012: 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_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)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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)
			LG_WardenObjective_Reactor chainedReactor = ChainedReactor;
			eDimensionIndex dimensionIndex = chainedReactor.SpawnNode.m_dimension.DimensionIndex;
			LG_LayerType layerType = chainedReactor.SpawnNode.LayerType;
			int num = 0;
			for (int i = 0; i < WaveData.Count; i++)
			{
				ReactorWaveData reactorWave = ObjectiveData.ReactorWaves[i];
				WaveOverride waveOverride = WaveData[i];
				switch (waveOverride.VerificationType)
				{
				case EOSReactorVerificationType.BY_SPECIAL_COMMAND:
					if (!reactorWave.HasVerificationTerminal)
					{
						waveOverride.VerifyTerminal = ChainedReactor.m_terminal;
						AddVerifyCommand(ChainedReactor.m_terminal);
					}
					else
					{
						LG_ComputerTerminal val = waveOverride.VerifyTerminal;
						if ((Object)(object)val == (Object)null)
						{
							val = EOSTerminalUtils.FindTerminal(dimensionIndex, layerType, reactorWave.ZoneForVerification, (Predicate<LG_ComputerTerminal>)((LG_ComputerTerminal terminal) => terminal.ItemKey.Equals(reactorWave.VerificationTerminalSerial, StringComparison.InvariantCultureIgnoreCase)))?[0];
							if ((Object)(object)val == (Object)null)
							{
								EOSLogger.Error($"SetupWaves: cannot find verify terminal for Wave_{i}, skipped");
								break;
							}
							waveOverride.VerifyTerminal = val;
						}
						val.ConnectedReactor = chainedReactor;
						val.RemoveLocalLog(reactorWave.VerificationTerminalFileName.ToUpperInvariant());
						AddVerifyCommand(val);
						EOSTerminalUtils.ResetInitialOutput(val);
					}
					num++;
					EOSLogger.Debug($"WaveOverride: Setup as Wave Verification {1} for Wave_{i}");
					break;
				default:
					EOSLogger.Error($"Unimplemented Verification Type {waveOverride.VerificationType}");
					break;
				case EOSReactorVerificationType.NORMAL:
				case EOSReactorVerificationType.BY_WARDEN_EVENT:
					break;
				}
			}
			if (num == ObjectiveData.ReactorWaves.Count)
			{
				ChainedReactor.m_terminal.TrySyncSetCommandHidden((TERM_Command)22);
			}
		}

		private void AddVerifyCommand(LG_ComputerTerminal terminal)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			LG_ComputerTerminalCommandInterpreter command = terminal.m_command;
			if (command.HasRegisteredCommand((TERM_Command)42))
			{
				EOSLogger.Debug("TERM_Command.UniqueCommand5 already registered. If this terminal is specified as objective terminal for 2 waves and the number of commands in 'UniqueCommands' on this terminal isn't more than 4, simply ignore this message.");
				return;
			}
			command.AddCommand((TERM_Command)42, "REACTOR_COOLDOWN", new LocalizedText
			{
				UntranslatedText = ReactorStartupOverrideManager.CoolDownCommandDesc,
				Id = 0u
			}, (TERM_CommandRule)0);
			terminal.TrySyncSetCommandRule((TERM_Command)42, (TERM_CommandRule)0);
		}

		public bool IsCorrectTerminal(LG_ComputerTerminal terminal)
		{
			int num = ChainedReactor.m_currentWaveCount - 1;
			if (num >= 0)
			{
				EOSLogger.Debug($"Index: {num}");
				EOSLogger.Debug("Comp Terminal Key1: " + terminal.ItemKey);
				EOSLogger.Debug("Comp Terminal Key2: " + (((Object)(object)WaveData[num].VerifyTerminal != (Object)null) ? WaveData[num].VerifyTerminal.ItemKey : "empty"));
				if (WaveData[num].VerifyTerminal.ItemKey != null && WaveData[num].VerifyTerminal.ItemKey.Equals(terminal.ItemKey, StringComparison.InvariantCultureIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public void SetIdle()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ChainedReactor == (Object)null))
			{
				pReactorState val = default(pReactorState);
				val.status = (eReactorStatus)0;
				val.stateCount = 0;
				val.stateProgress = 0f;
				val.verifyFailed = false;
				pReactorState state = val;
				ChainedReactor.m_stateReplicator.State = state;
			}
		}

		private void OnDestroy()
		{
			LevelAPI.OnEnterLevel -= OnEnterLevel;
			ChainedReactor = null;
			overrideData = null;
		}

		private void LateUpdate()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameStateManager.CurrentStateName == 10)
			{
				eReactorStatus status = ChainedReactor.m_currentState.status;
				if (UsingLightEffect)
				{
					UpdateLight(status, ChainedReactor.m_currentWaveProgress);
				}
				UpdateGUIText(status);
			}
		}

		private void UpdateGUIText(eReactorStatus status)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			int num = ChainedReactor.m_currentWaveCount - 1;
			if (num < 0)
			{
				return;
			}
			WaveOverride waveOverride = WaveData[num];
			if ((int)status != 4)
			{
				return;
			}
			switch (waveOverride.VerificationType)
			{
			case EOSReactorVerificationType.NORMAL:
				if (ChainedReactor.m_currentWaveData.HasVerificationTerminal)
				{
					ChainedReactor.SetGUIMessage(true, Text.Format(1103u, (Object[])(object)new Object[3]
					{
						Object.op_Implicit(ChainedReactor.m_currentWaveCount),
						Object.op_Implicit(ChainedReactor.m_waveCountMax),
						Object.op_Implicit("<color=orange>" + ChainedReactor.m_currentWaveData.VerificationTerminalSerial + "</color>")
					}), (ePUIMessageStyle)3, !waveOverride.HideVerificationTimer, "<size=125%>" + Text.Get(1104u), "</size>");
				}
				else
				{
					ChainedReactor.SetGUIMessage(true, Text.Format(1105u, (Object[])(object)new Object[3]
					{
						Object.op_Implicit(ChainedReactor.m_currentWaveCount),
						Object.op_Implicit(ChainedReactor.m_waveCountMax),
						Object.op_Implicit("<color=orange>" + ChainedReactor.CurrentStateOverrideCode + "</color>")
					}), (ePUIMessageStyle)3, !waveOverride.HideVerificationTimer, "<size=125%>" + Text.Get(1104u), "</size>");
				}
				break;
			case EOSReactorVerificationType.BY_SPECIAL_COMMAND:
			{
				string text = (ChainedReactor.m_currentWaveData.HasVerificationTerminal ? ChainedReactor.m_currentWaveData.VerificationTerminalSerial : ReactorStartupOverrideManager.MainTerminalText);
				ChainedReactor.SetGUIMessage(true, string.Format(ReactorStartupOverrideManager.SpecialCmdVerifyText, ChainedReactor.m_currentWaveCount, ChainedReactor.m_waveCountMax, "<color=orange>" + text + "</color>"), (ePUIMessageStyle)3, !waveOverride.HideVerificationTimer, "<size=125%>" + Text.Get(1104u), "</size>");
				break;
			}
			case EOSReactorVerificationType.BY_WARDEN_EVENT:
				ChainedReactor.SetGUIMessage(true, string.Format(ReactorStartupOverrideManager.InfiniteWaveVerifyText, ChainedReactor.m_currentWaveCount, ChainedReactor.m_waveCountMax), (ePUIMessageStyle)3, !waveOverride.HideVerificationTimer, "<size=125%>" + Text.Get(1104u), "</size>");
				break;
			}
		}

		private void UpdateLight(eReactorStatus status, float progress)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected I4, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!(_updateTimer > Clock.Time))
			{
				_updateTimer = Clock.Time + 0.15f;
				switch (status - 1)
				{
				case 0:
					SetLightColor(Color.black);
					break;
				case 1:
					SetLightColor(Color.Lerp(LowTemperature, HighTemperature, progress));
					break;
				case 2:
					SetLightColor(Color.Lerp(HighTemperature, LowTemperature, progress));
					break;
				case 3:
					SetLightColor(LowTemperature);
					break;
				case 4:
					SetLightColor(LowTemperature);
					break;
				}
			}
		}

		private void SetLightColor(Color color)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (UsingLightEffect && _lights != null)
			{
				for (int i = 0; i < _lights.Length; i++)
				{
					_lights[i].ChangeColor(color);
				}
			}
		}

		static OverrideReactorComp()
		{
			//IL_0005: 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_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			LowTemperature = ColorExt.Hex("#23E4F2") * 2.5f;
			HighTemperature = ColorExt.Hex("#F63838") * 12f;
		}
	}
}