Decompiled source of DigitalWorld v1.2.4

plugins/Digital World/extra/Endlessinferno.plugins.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using GameData;
using Gear;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Player;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("weapon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("weapon")]
[assembly: AssemblyTitle("weapon")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Interference_Weapon
{
	[HarmonyPatch(typeof(BulletWeapon))]
	internal static class Inject_BulletWeapon
	{
		[HarmonyPostfix]
		[HarmonyPatch("UpdateAmmoStatus")]
		private static void Post_UpdateAmmoStatus(BulletWeapon __instance)
		{
			DoReload(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnWield")]
		private static void Post_Wield(BulletWeapon __instance)
		{
			DoReload(__instance);
		}

		private static void DoReload(BulletWeapon weapon)
		{
			if (weapon.m_clip == 0 && (((GameDataBlockBase<ItemDataBlock>)(object)((Item)weapon).ItemDataBlock).persistentID == 5001 || ((GameDataBlockBase<ItemDataBlock>)(object)((Item)weapon).ItemDataBlock).persistentID == 5005))
			{
				((Item)weapon).Owner.Inventory.DoReload();
			}
			else if (weapon.m_clip == 0 && (((GameDataBlockBase<ItemDataBlock>)(object)((Item)weapon).ItemDataBlock).persistentID == 5002 || ((GameDataBlockBase<ItemDataBlock>)(object)((Item)weapon).ItemDataBlock).persistentID == 5003) && ((PlayerInventoryBase)((Weapon)weapon).m_inventory).CanReloadCurrent())
			{
				((ItemEquippable)weapon).TryTriggerReloadAnimationSequence();
				if (((Item)weapon).Owner.Locomotion.IsRunning)
				{
					((Item)weapon).Owner.Locomotion.ChangeState((PLOC_State)0, false);
				}
			}
		}
	}
	[BepInPlugin("Yoake.Endlessinferno-Weapon", "Plugin for Endlessinferno Weaponpack", "1.1.0.0")]
	[BepInProcess("GTFO.exe")]
	public class EntryPoint : BasePlugin
	{
		public override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Interference.Weapon.Harmony").PatchAll();
		}
	}
}

plugins/Digital World/extra/Flowaria.MeltdownReactor.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
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.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using MTFO.Managers;
using MeltdownReactor.Json;
using MeltdownReactor.Json.PartialData;
using MeltdownReactor.ReactorData;
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("Flowaria.MeltdownReactor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Flowaria.MeltdownReactor")]
[assembly: AssemblyTitle("Flowaria.MeltdownReactor")]
[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 MeltdownReactor
{
	[BepInPlugin("Flowaria.MeltdownReactor", "MeltdownReactor", "2.1.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EntryPoint : BasePlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LiveEditEventHandler <0>__Listener_FileChanged1;
		}

		public const string PLUGIN_NAME = "MeltdownReactor";

		public const string AUTHOR = "Flowaria";

		public const string GUID = "Flowaria.MeltdownReactor";

		public const string VERSION = "2.1.4";

		public static string REACTOR_OVERRIDE_DATA_PATH = Path.Combine(MTFOUtil.CustomPath, "MeltdownReactor");

		public static readonly Dictionary<uint, ReactorOverrideData> ReactorOverrideDatas = new Dictionary<uint, ReactorOverrideData>();

		private Harmony m_Harmony;

		private LiveEditListener listener;

		public override void Load()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			MeltdownReactorLogger.Debug("This plugin is dev-ed based on Flowaria.MeltdownReactor, which is only used in rundowns Flowaria.Modulation and Flowaria.Paradigm");
			MeltdownReactorLogger.Debug("All credits belong to Flowaria.");
			if (!Directory.Exists(REACTOR_OVERRIDE_DATA_PATH))
			{
				Directory.CreateDirectory(REACTOR_OVERRIDE_DATA_PATH);
				StreamWriter streamWriter = File.CreateText(Path.Combine(REACTOR_OVERRIDE_DATA_PATH, "Template.json"));
				streamWriter.WriteLine(JSON.Serialize(new ReactorOverrideData()));
				streamWriter.Flush();
				streamWriter.Close();
				return;
			}
			ClassInjector.RegisterTypeInIl2Cpp<MeltdownReactor>();
			m_Harmony = new Harmony("Flowaria.MeltdownReactor");
			m_Harmony.PatchAll();
			foreach (string item in Directory.EnumerateFiles(REACTOR_OVERRIDE_DATA_PATH, "*.json", SearchOption.AllDirectories))
			{
				JSON.Load<ReactorOverrideData>(item, out var config);
				if (ReactorOverrideDatas.ContainsKey(config.ObjectiveDataID))
				{
					MeltdownReactorLogger.Error($"Duplicate ObjectiveDataID {config.ObjectiveDataID}");
				}
				else
				{
					ReactorOverrideDatas.Add(config.ObjectiveDataID, config);
				}
			}
			listener = LiveEdit.CreateListener(REACTOR_OVERRIDE_DATA_PATH, "*.json", true);
			LiveEditListener obj = listener;
			object obj2 = <>O.<0>__Listener_FileChanged1;
			if (obj2 == null)
			{
				LiveEditEventHandler val = Listener_FileChanged1;
				<>O.<0>__Listener_FileChanged1 = val;
				obj2 = (object)val;
			}
			obj.FileChanged += (LiveEditEventHandler)obj2;
		}

		private static void Listener_FileChanged1(LiveEditEventArgs e)
		{
			MeltdownReactorLogger.Warning("LiveEdit File Changed: " + e.FullPath + ".");
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				ReactorOverrideData reactorOverrideData = JSON.Deserialize<ReactorOverrideData>(content);
				if (!ReactorOverrideDatas.ContainsKey(reactorOverrideData.ObjectiveDataID))
				{
					MeltdownReactorLogger.Error("Changing ObjectiveDataID is not allowed, will not update.");
				}
				else
				{
					ReactorOverrideDatas[reactorOverrideData.ObjectiveDataID] = reactorOverrideData;
					MeltdownReactorLogger.Warning($"Updated override data with ObjectiveDataID {reactorOverrideData.ObjectiveDataID}");
				}
			});
		}
	}
	public class MeltdownReactor : MonoBehaviour
	{
		private const string MAINTERMINAL_NAME = "Main Terminal";

		private const float HIDE_TIMER_THRESHOLD = 43200f;

		private static Color LowTemperature;

		private static Color HighTemperature;

		private static uint VerifyTextID;

		private static uint MainTerminalTextID;

		private static uint CooldownCommandDescTextID;

		private static uint InfiniteWaveVerifyTextID;

		internal static uint NotReadyForVerificationOutputTextID;

		internal static uint IncorrectTerminalOutputTextID;

		internal static uint CorrectTerminalOutputTextID;

		private LG_Light[] _lights;

		private float _updateTimer;

		private Dictionary<int, LG_ComputerTerminal> verifyZoneOverrideTerminals = new Dictionary<int, LG_ComputerTerminal>();

		internal ReactorOverrideData overrideData;

		private Dictionary<int, string> meltdownWaveTerminalKeys;

		private HashSet<int> infiniteWaveIndices;

		private WardenObjectiveDataBlock objectiveDataBlock;

		private Dictionary<TERM_Command, List<WardenObjectiveEventData>> commandEventMap = new Dictionary<TERM_Command, List<WardenObjectiveEventData>>();

		private Dictionary<TERM_Command, List<TerminalOutput>> commandPostOutputMap = new Dictionary<TERM_Command, List<TerminalOutput>>();

		internal LG_WardenObjective_Reactor ChainedReactor { get; set; }

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


		public bool IsCorrectTerminal(LG_ComputerTerminal terminal)
		{
			int num = ChainedReactor.m_currentWaveCount - 1;
			if (num >= 0)
			{
				MeltdownReactorLogger.Error($"Index: {num}");
				MeltdownReactorLogger.Error("Comp Terminal Key1: " + terminal.ItemKey);
				MeltdownReactorLogger.Error("Comp Terminal Key2: " + (meltdownWaveTerminalKeys.ContainsKey(num) ? meltdownWaveTerminalKeys[num] : "empty"));
				if (meltdownWaveTerminalKeys.ContainsKey(num) && meltdownWaveTerminalKeys[num].Equals(terminal.ItemKey, StringComparison.InvariantCultureIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public void Init()
		{
			if (overrideData == null)
			{
				MeltdownReactorLogger.Error("ReactorOverrideData is null!");
				return;
			}
			meltdownWaveTerminalKeys = new Dictionary<int, string>();
			overrideData.MeltdownWaveIndices.ForEach(delegate(int index)
			{
				meltdownWaveTerminalKeys.TryAdd(index, string.Empty);
			});
			infiniteWaveIndices = overrideData.InfiniteWaveIndices.ToHashSet();
			LevelAPI.OnEnterLevel += OnDrop;
			if (VerifyTextID == 0)
			{
				VerifyTextID = 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");
			}
		}

		private void OnDrop()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			LG_WardenObjective_Reactor chainedReactor = ChainedReactor;
			LG_ComputerTerminal terminal = ChainedReactor.m_terminal;
			objectiveDataBlock = GameDataBlockBase<WardenObjectiveDataBlock>.GetBlock(overrideData.ObjectiveDataID);
			if (objectiveDataBlock == null)
			{
				MeltdownReactorLogger.Error($"Failed to get the Reactor Startup objective for layer {chainedReactor.SpawnNode.LayerType}");
				return;
			}
			if ((int)objectiveDataBlock.Type != 1)
			{
				MeltdownReactorLogger.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);
			}
			SetupVerifyZoneOverride();
			SetupMeltdownAndInfiniteWave();
			if (overrideData.ReactorTerminal != null && overrideData.ReactorTerminal.TerminalPassword.PasswordProtected)
			{
				BuildReactorTerminalPassword();
			}
		}

		private void SetupVerifyZoneOverride()
		{
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val3 = default(LG_Zone);
			foreach (VerifyZoneOverride verifyZoneOverride in overrideData.VerifyZoneOverrides)
			{
				if (verifyZoneOverrideTerminals.ContainsKey(verifyZoneOverride.WaveIndex))
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: Duplicate Wave Index {verifyZoneOverride.WaveIndex}");
					continue;
				}
				if (infiniteWaveIndices.Contains(verifyZoneOverride.WaveIndex))
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: Wave Index {verifyZoneOverride.WaveIndex} is specified as Infinite Wave but VerifyZoneOverride is specified! Will not process");
					continue;
				}
				if (verifyZoneOverride.WaveIndex < 0 || verifyZoneOverride.WaveIndex >= objectiveDataBlock.ReactorWaves.Count)
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: Invalid Wave Index {verifyZoneOverride.WaveIndex}. Valid value for this reactor is: [0, {objectiveDataBlock.ReactorWaves.Count - 1}]");
					continue;
				}
				ReactorWaveData val = objectiveDataBlock.ReactorWaves[verifyZoneOverride.WaveIndex];
				if (!val.VerifyInOtherZone)
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: `VerifyInOtherZone` is false for wave {verifyZoneOverride.WaveIndex}. You need to set it to true to generate the log, and thereby enabling moving the log.");
					continue;
				}
				LG_ComputerTerminal val2 = Utils.FindTerminalWithTerminalSerial(val.VerificationTerminalSerial, ChainedReactor.SpawnNode.m_dimension.DimensionIndex, ChainedReactor.SpawnNode.LayerType, val.ZoneForVerification);
				if ((Object)(object)val2 == (Object)null)
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: Cannot find wave log terminal. Wave index: {verifyZoneOverride.WaveIndex}");
					continue;
				}
				TargetZone targetZone = verifyZoneOverride.TargetZone;
				if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(targetZone.DimensionIndex, targetZone.LayerType, targetZone.LocalIndex, ref val3) || (Object)(object)val3 == (Object)null)
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: Cannot find target zone {targetZone.LocalIndex}, {targetZone.LayerType}, {targetZone.DimensionIndex}.");
					continue;
				}
				if (val3.TerminalsSpawnedInZone == null || val3.TerminalsSpawnedInZone.Count < 0)
				{
					MeltdownReactorLogger.Error($"VerifyZoneOverrides: No spawned terminal found in target zone {targetZone.LocalIndex}, {targetZone.LayerType}, {targetZone.DimensionIndex}..");
					continue;
				}
				int num = Builder.SessionSeedRandom.Seed;
				if (num < 0)
				{
					num = ((num != int.MinValue) ? (-num) : int.MaxValue);
				}
				int num2 = num % val3.TerminalsSpawnedInZone.Count;
				LG_ComputerTerminal val4 = val3.TerminalsSpawnedInZone[num2];
				string text = val.VerificationTerminalFileName.ToUpperInvariant();
				TerminalLogFileData localLog = val2.GetLocalLog(text);
				if (localLog == null)
				{
					MeltdownReactorLogger.Error("VerifyZoneOverrides: Cannot find reactor verify log on terminal.");
					continue;
				}
				val2.RemoveLocalLog(text);
				val4.AddLocalLog(localLog, true);
				val.VerificationTerminalSerial = val4.ItemKey;
				val2.ResetInitialOutput();
				val4.ResetInitialOutput();
				MeltdownReactorLogger.Debug($"VerifyZoneOverrides: moved wave {verifyZoneOverride.WaveIndex} verify log from {val2.ItemKey} to {val4.ItemKey}");
				verifyZoneOverrideTerminals.Add(verifyZoneOverride.WaveIndex, val4);
			}
		}

		private void SetupMeltdownAndInfiniteWave()
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0138: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			LG_WardenObjective_Reactor chainedReactor = ChainedReactor;
			LG_ComputerTerminal terminal = ChainedReactor.m_terminal;
			eDimensionIndex dimensionIndex = chainedReactor.SpawnNode.m_dimension.DimensionIndex;
			LG_LayerType layerType = chainedReactor.SpawnNode.LayerType;
			LG_Zone val3 = default(LG_Zone);
			for (int i = 0; i < objectiveDataBlock.ReactorWaves.Count; i++)
			{
				if (!meltdownWaveTerminalKeys.ContainsKey(i) && !infiniteWaveIndices.Contains(i))
				{
					continue;
				}
				ReactorWaveData val = objectiveDataBlock.ReactorWaves[i];
				if (!val.HasVerificationTerminal)
				{
					_ = terminal.m_command;
					if (meltdownWaveTerminalKeys.ContainsKey(i))
					{
						meltdownWaveTerminalKeys[i] = terminal.ItemKey;
						AddVerifyCommand(terminal);
						MeltdownReactorLogger.Debug($"MeltdownWave: Setup as Meltdown Wave for wave index {i}");
					}
					else
					{
						MeltdownReactorLogger.Debug($"InfiniteWave: Setup as Infinite Wavefor wave index {i}");
					}
					continue;
				}
				LG_ComputerTerminal val2 = null;
				if (verifyZoneOverrideTerminals.ContainsKey(i))
				{
					val2 = verifyZoneOverrideTerminals[i];
				}
				else
				{
					if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, val.ZoneForVerification, ref val3))
					{
						MeltdownReactorLogger.Error($"Cannot find LG_Zone {dimensionIndex}, {layerType}, {val.ZoneForVerification}");
						continue;
					}
					for (int j = 0; j < val3.TerminalsSpawnedInZone.Count; j++)
					{
						LG_ComputerTerminal val4 = val3.TerminalsSpawnedInZone[j];
						if (val4.ItemKey.Equals(val.VerificationTerminalSerial, StringComparison.InvariantCultureIgnoreCase))
						{
							val2 = val4;
							break;
						}
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					MeltdownReactorLogger.Error($"MeltdownWave: cannot find verify terminal for wave index {i}");
					continue;
				}
				val2.ConnectedReactor = chainedReactor;
				val2.RemoveLocalLog(val.VerificationTerminalFileName.ToUpperInvariant());
				if (meltdownWaveTerminalKeys.ContainsKey(i))
				{
					meltdownWaveTerminalKeys[i] = val2.ItemKey;
					AddVerifyCommand(val2);
					MeltdownReactorLogger.Debug($"MeltdownWave: Setup as Meltdown Wave for wave index {i}");
				}
				else
				{
					MeltdownReactorLogger.Debug($"InfiniteWave: Setup as Infinite Wavefor wave index {i}");
				}
				val2.ResetInitialOutput();
			}
			if (meltdownWaveTerminalKeys.Count == objectiveDataBlock.ReactorWaves.Count)
			{
				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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			LG_ComputerTerminalCommandInterpreter command = terminal.m_command;
			if (command.HasRegisteredCommand((TERM_Command)42))
			{
				MeltdownReactorLogger.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 = ((CooldownCommandDescTextID == 0) ? "Confirm Reactor Startup Cooling Protocol" : Text.Get(CooldownCommandDescTextID)),
				Id = 0u
			}, (TERM_CommandRule)0);
			terminal.TrySyncSetCommandRule((TERM_Command)42, (TERM_CommandRule)0);
		}

		private 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 -= OnDrop;
			ChainedReactor = null;
			infiniteWaveIndices?.Clear();
			meltdownWaveTerminalKeys?.Clear();
			verifyZoneOverrideTerminals?.Clear();
			commandEventMap?.Clear();
			commandPostOutputMap?.Clear();
			infiniteWaveIndices = null;
			meltdownWaveTerminalKeys = null;
			overrideData = null;
			objectiveDataBlock = null;
			verifyZoneOverrideTerminals = null;
			commandEventMap = null;
			commandPostOutputMap = 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			int num = ChainedReactor.m_currentWaveCount - 1;
			if (num < 0)
			{
				return;
			}
			bool flag = ChainedReactor.m_currentWaveData.Verify < 43200f;
			if ((int)status != 4)
			{
				return;
			}
			if (meltdownWaveTerminalKeys.ContainsKey(num))
			{
				string text = ((MainTerminalTextID == 0) ? "Main Terminal" : Text.Get(MainTerminalTextID));
				if (ChainedReactor.m_currentWaveData.HasVerificationTerminal)
				{
					text = ChainedReactor.m_currentWaveData.VerificationTerminalSerial;
				}
				ChainedReactor.SetGUIMessage(true, FormatText(VerifyTextID, ChainedReactor.m_currentWaveCount, ChainedReactor.m_waveCountMax, "<color=orange>" + text + "</color>"), (ePUIMessageStyle)3, flag, "<size=125%>" + Text.Get(1104u), "</size>");
			}
			else if (infiniteWaveIndices.Contains(num))
			{
				ChainedReactor.SetGUIMessage(true, string.Format(Text.Get(InfiniteWaveVerifyTextID), ChainedReactor.m_currentWaveCount, ChainedReactor.m_waveCountMax), (ePUIMessageStyle)3, flag, "<size=125%>" + Text.Get(1104u), "</size>");
			}
			else 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, flag, "<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, flag, "<size=125%>" + Text.Get(1104u), "</size>");
			}
		}

		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);
				}
			}
		}

		private void BuildReactorTerminalPassword()
		{
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//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)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Expected O, but got Unknown
			LG_ComputerTerminal terminal = ChainedReactor.m_terminal;
			TerminalPassword terminalPassword = overrideData.ReactorTerminal.TerminalPassword;
			if (!terminalPassword.GeneratePassword)
			{
				terminal.LockWithPassword(terminalPassword.Password, new string[1] { "" });
				return;
			}
			if (terminalPassword.TerminalZoneSelectionDatas.Count <= 0)
			{
				MeltdownReactorLogger.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 = terminalPassword.PasswordHintText;
			string text = "<b>[Forgot your password?]</b> Backup security key(s) located in logs on ";
			int num = terminalPassword.PasswordPartCount;
			if (codeWord.Length % num != 0)
			{
				MeltdownReactorLogger.Error($"Build() password.Length ({codeWord.Length}) not divisible by passwordParts ({terminalPassword.PasswordPartCount}). Defaulting to 1.");
				num = 1;
			}
			string[] array = ((num > 1) ? Il2CppArrayBase<string>.op_Implicit((Il2CppArrayBase<string>)(object)StringUtils.SplitIntoChunksArray(codeWord, codeWord.Length / num)) : new string[1] { codeWord });
			string text2 = "";
			if (terminalPassword.ShowPasswordPartPositions)
			{
				for (int i = 0; i < array[0].Length; i++)
				{
					text2 += "-";
				}
			}
			HashSet<LG_ComputerTerminal> hashSet = new HashSet<LG_ComputerTerminal>();
			for (int j = 0; j < num; j++)
			{
				int index = j % terminalPassword.TerminalZoneSelectionDatas.Count;
				LG_ComputerTerminal val = Utils.SelectTerminalFromSelectionData(terminalPassword.TerminalZoneSelectionDatas[index][Builder.SessionSeedRandom.Range(0, terminalPassword.TerminalZoneSelectionDatas[index].Count, "NO_TAG")]);
				if ((Object)(object)val != (Object)null)
				{
					string text3 = "";
					string text4;
					if (terminalPassword.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 text5 = (terminalPassword.ShowPasswordPartPositions ? ("0" + (j + 1)) : ("0" + Builder.SessionSeedRandom.Range(0, 9, "NO_TAG")));
					TerminalLogFileData val2 = new TerminalLogFileData();
					val2.FileName = "key" + text5 + "_" + terminal.m_serialNumber + (val.HasPasswordPart ? "_1" : "") + ".LOG";
					val2.FileContent = new LocalizedText
					{
						UntranslatedText = string.Format(Text.Get((num == 1) ? 1431221909u : 2260297836u), text4),
						Id = 0u
					};
					TerminalLogFileData val3 = val2;
					val.AddLocalLog(val3, true);
					if (!hashSet.Contains(val))
					{
						if (j > 0)
						{
							text += ", ";
						}
						text = text + val.PublicName + " in " + val.SpawnNode.m_zone.AliasName;
					}
					hashSet.Add(val);
					val.HasPasswordPart = true;
				}
				else
				{
					MeltdownReactorLogger.Error($"Build() CRITICAL ERROR, could not get a LG_ComputerTerminal for password part ({j + 1}/{num}) for {terminal.PublicName} backup log.");
				}
			}
			string text6 = text + ".";
			if (terminalPassword.ShowPasswordLength)
			{
				terminal.LockWithPassword(codeWord, new string[3]
				{
					passwordHintText,
					text6,
					"Char[" + codeWord.Length + "]"
				});
			}
			else
			{
				terminal.LockWithPassword(codeWord, new string[2] { passwordHintText, text6 });
			}
			foreach (LG_ComputerTerminal item in hashSet)
			{
				item.ResetInitialOutput();
			}
		}

		private void BuildReactorTerminalCustomCommands()
		{
			//IL_0044: 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_0064: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_00ef: 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)
			LG_ComputerTerminal terminal = ChainedReactor.m_terminal;
			List<ReactorCustomTerminalCommand> uniqueCommands = overrideData.ReactorTerminal.UniqueCommands;
			TERM_Command val = default(TERM_Command);
			for (int i = 0; i < uniqueCommands.Count; i++)
			{
				ReactorCustomTerminalCommand reactorCustomTerminalCommand = uniqueCommands[i];
				if (terminal.m_command.TryGetUniqueCommandSlot(ref val))
				{
					terminal.m_command.AddCommand(val, reactorCustomTerminalCommand.Command, reactorCustomTerminalCommand.CommandDesc, reactorCustomTerminalCommand.SpecialCommandRule);
					commandEventMap.Add(val, reactorCustomTerminalCommand.CommandEvents);
					commandPostOutputMap.Add(val, reactorCustomTerminalCommand.PostCommandOutputs);
					for (int j = 0; j < reactorCustomTerminalCommand.CommandEvents.Count; j++)
					{
						WardenObjectiveEventData val2 = reactorCustomTerminalCommand.CommandEvents[j];
						if (val2.ChainPuzzle != 0)
						{
							ChainedPuzzleDataBlock block = GameDataBlockBase<ChainedPuzzleDataBlock>.GetBlock(val2.ChainPuzzle);
							if (block != null)
							{
								ChainedPuzzleInstance val3 = ChainedPuzzleManager.CreatePuzzleInstance(block, terminal.ConnectedReactor.SpawnNode.m_area, terminal.ConnectedReactor.m_chainedPuzzleAlign.position, terminal.ConnectedReactor.m_chainedPuzzleAlign, val2.UseStaticBioscanPoints);
								terminal.SetChainPuzzleForCommand(val, j, val3);
							}
						}
					}
				}
				else
				{
					MeltdownReactorLogger.Error($"LG_ComputerTerminal: Could not get any more unique command slots for this terminal!! Have you added too many unique commands to this terminal? (Yours: {uniqueCommands.Count}, Max: 5)");
				}
			}
			ChainedPuzzleInstance val6 = default(ChainedPuzzleInstance);
			for (int k = 38; k <= 42; k++)
			{
				TERM_Command val4 = (TERM_Command)(byte)k;
				if (!commandEventMap.TryGetValue(val4, out var value) || value == null)
				{
					continue;
				}
				ChainedPuzzleInstance val5 = null;
				for (int l = 0; l < value.Count; l++)
				{
					WardenObjectiveEventData eventData = value[l];
					if (eventData == null)
					{
						continue;
					}
					if (ChainedReactor.m_terminal.TryGetChainPuzzleForCommand(val4, l, ref val6) && (Object)(object)val6 != (Object)null)
					{
						ChainedPuzzleInstance obj = val6;
						obj.OnPuzzleSolved += Action.op_Implicit((Action)delegate
						{
							WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(eventData, (eWardenObjectiveEventTrigger)0, true, 0f);
						});
						val5 = val6;
					}
					else if ((Object)(object)val5 != (Object)null)
					{
						ChainedPuzzleInstance obj2 = val5;
						obj2.OnPuzzleSolved += Action.op_Implicit((Action)delegate
						{
							WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(eventData, (eWardenObjectiveEventTrigger)0, true, 0f);
						});
					}
				}
			}
			MeltdownReactorLogger.Warning("CustomCommand built!");
		}

		private static string FormatText(uint id, params object[] objs)
		{
			return string.Format(Text.Get(id), objs);
		}

		static MeltdownReactor()
		{
			//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;
			VerifyTextID = 0u;
			MainTerminalTextID = 0u;
			CooldownCommandDescTextID = 0u;
			InfiniteWaveVerifyTextID = 0u;
			NotReadyForVerificationOutputTextID = 0u;
			IncorrectTerminalOutputTextID = 0u;
			CorrectTerminalOutputTextID = 0u;
		}
	}
	internal static class MeltdownReactorLogger
	{
		private static readonly ManualLogSource _logger = Logger.CreateLogSource("MeltdownReactor");

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(object data)
		{
			_logger.LogMessage((object)Format(data));
		}

		public static void Verbose(object data)
		{
		}

		public static void Debug(object data)
		{
			_logger.LogDebug((object)Format(data));
		}

		public static void Error(object data)
		{
			_logger.LogError((object)Format(data));
		}

		public static void Warning(object data)
		{
			_logger.LogWarning((object)Format(data));
		}
	}
	internal static class Utils
	{
		public static LG_ComputerTerminal FindTerminalWithTerminalSerial(string itemKey, eDimensionIndex dim, LG_LayerType layer, 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_0009: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = null;
			if (Builder.CurrentFloor.TryGetZoneByLocalIndex(dim, layer, localIndex, ref val) && (Object)(object)val != (Object)null)
			{
				Enumerator<LG_ComputerTerminal> enumerator = val.TerminalsSpawnedInZone.GetEnumerator();
				while (enumerator.MoveNext())
				{
					LG_ComputerTerminal current = enumerator.Current;
					if (current.ItemKey.Equals(itemKey, StringComparison.InvariantCultureIgnoreCase))
					{
						return current;
					}
				}
			}
			return null;
		}

		public static TerminalLogFileData GetLocalLog(this LG_ComputerTerminal terminal, string logName)
		{
			Dictionary<string, TerminalLogFileData> 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 LG_ComputerTerminal SelectTerminalFromSelectionData(PasswordTerminalZoneSelectionData selectionData)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0137: Expected I4, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			TargetZone targetZone = selectionData.TargetZone;
			LG_Zone val = default(LG_Zone);
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(targetZone.DimensionIndex, targetZone.LayerType, targetZone.LocalIndex, ref val) || (Object)(object)val == (Object)null)
			{
				MeltdownReactorLogger.Error("SelectTerminalFromSelectionData() Could NOT find zone with " + targetZone);
				return null;
			}
			if (val.TerminalsSpawnedInZone.Count <= 0)
			{
				MeltdownReactorLogger.Error("SelectTerminalFromSelectionData() Could not find any terminals in zone with " + targetZone?.ToString() + ". At least one terminal required!!");
				return null;
			}
			List<LG_ComputerTerminal> list = new List<LG_ComputerTerminal>();
			if ((int)selectionData.SeedType != 0)
			{
				Enumerator<LG_ComputerTerminal> enumerator = val.TerminalsSpawnedInZone.GetEnumerator();
				while (enumerator.MoveNext())
				{
					LG_ComputerTerminal current = enumerator.Current;
					if (!current.HasPasswordPart)
					{
						list.Add(current);
					}
				}
				if (list.Count <= 0)
				{
					eLocalZoneIndex localIndex = targetZone.LocalIndex;
					MeltdownReactorLogger.Error("SelectTerminalFromSelectionData() Could not find any terminals without a password part in zone with " + ((object)(eLocalZoneIndex)(ref localIndex)).ToString() + ". Putting the password on random (session) already used terminal.");
					return val.TerminalsSpawnedInZone[Builder.SessionSeedRandom.Range(0, val.TerminalsSpawnedInZone.Count, "NO_TAG")];
				}
			}
			eSeedType seedType = selectionData.SeedType;
			switch ((int)seedType)
			{
			case 0:
				return val.TerminalsSpawnedInZone[Mathf.Clamp(0, val.TerminalsSpawnedInZone.Count - 1, selectionData.TerminalIndex)];
			case 1:
				return list[Builder.SessionSeedRandom.Range(0, list.Count, "NO_TAG")];
			case 2:
				return list[Builder.BuildSeedRandom.Range(0, list.Count, "NO_TAG")];
			case 3:
				Random.InitState(selectionData.StaticSeed);
				return list[Random.Range(0, list.Count)];
			default:
				MeltdownReactorLogger.Error("SelectTerminalFromSelectionData() did not have a valid SeedType!!");
				return null;
			}
		}
	}
}
namespace MeltdownReactor.ReactorData
{
	public class PasswordTerminalZoneSelectionData
	{
		public TargetZone TargetZone { get; set; } = new TargetZone();


		public eSeedType SeedType { get; set; }

		public int TerminalIndex { get; set; }

		public int StaticSeed { get; set; }

		public PasswordTerminalZoneSelectionData()
		{
			SeedType = (eSeedType)1;
		}

		public override string ToString()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			string[] obj = new string[7]
			{
				TargetZone?.ToString(),
				" ",
				null,
				null,
				null,
				null,
				null
			};
			eSeedType seedType = SeedType;
			obj[2] = ((object)(eSeedType)(ref seedType)).ToString();
			obj[3] = " ";
			obj[4] = TerminalIndex.ToString();
			obj[5] = " ";
			obj[6] = StaticSeed.ToString();
			return string.Concat(obj);
		}
	}
	public class ReactorCustomTerminalCommand
	{
		public string Command { get; set; }

		public LocalizedText CommandDesc { get; set; }

		public List<TerminalOutput> PostCommandOutputs { get; set; }

		public List<WardenObjectiveEventData> CommandEvents { get; set; }

		public TERM_CommandRule SpecialCommandRule { get; set; }

		public ReactorCustomTerminalCommand()
		{
			PostCommandOutputs = new List<TerminalOutput>();
			CommandEvents = new List<WardenObjectiveEventData>();
		}
	}
	public class ReactorOverrideData
	{
		public uint ObjectiveDataID { get; set; }

		public bool StartupOnDrop { get; set; }

		public List<int> MeltdownWaveIndices { get; set; } = new List<int>();


		public List<int> InfiniteWaveIndices { get; set; } = new List<int>();


		public ReactorTerminalSetting ReactorTerminal { get; set; } = new ReactorTerminalSetting();


		public List<VerifyZoneOverride> VerifyZoneOverrides { get; set; } = new List<VerifyZoneOverride>
		{
			new VerifyZoneOverride()
		};

	}
	public class ReactorTerminalSetting
	{
		public List<ReactorCustomTerminalCommand> UniqueCommands { get; set; } = new List<ReactorCustomTerminalCommand>();


		public TerminalPassword TerminalPassword { get; set; } = new TerminalPassword();

	}
	public class TargetZone
	{
		public eDimensionIndex DimensionIndex { get; set; }

		public LG_LayerType LayerType { get; set; }

		public eLocalZoneIndex LocalIndex { get; set; }

		public override string ToString()
		{
			//IL_000c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			return $"{LocalIndex}, {LayerType}, {DimensionIndex}";
		}
	}
	public class TerminalPassword
	{
		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<List<PasswordTerminalZoneSelectionData>> TerminalZoneSelectionDatas { get; set; } = new List<List<PasswordTerminalZoneSelectionData>>
		{
			new List<PasswordTerminalZoneSelectionData>()
		};

	}
	public class VerifyZoneOverride
	{
		public int WaveIndex { get; set; } = -1;


		public TargetZone TargetZone { get; set; } = new TargetZone();

	}
}
namespace MeltdownReactor.Patches
{
	[HarmonyPatch]
	internal static class Patch_LG_ComputerTerminal
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_ComputerTerminal), "OnStateChange")]
		private static bool Pre_OnStateChange(LG_ComputerTerminal __instance, bool isRecall)
		{
			if (__instance.SpawnNode != null || !isRecall)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")]
	internal static class Patch_Meltdown_Reactor_Terminal
	{
		private static bool Prefix(LG_ComputerTerminalCommandInterpreter __instance, TERM_Command cmd)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0022: 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 || (int)cmd != 42)
			{
				return true;
			}
			if (__instance.m_terminal.CommandIsHidden(cmd))
			{
				return true;
			}
			_ = __instance.m_terminal.ItemKey;
			MeltdownReactor component = ((Component)connectedReactor).gameObject.GetComponent<MeltdownReactor>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (!connectedReactor.ReadyForVerification)
			{
				__instance.AddOutput("", true);
				__instance.AddOutput((TerminalLineType)3, Text.Get(MeltdownReactor.NotReadyForVerificationOutputTextID), 4f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance.AddOutput("", true);
				return false;
			}
			if (component.IsCorrectTerminal(__instance.m_terminal))
			{
				MeltdownReactorLogger.Info("Reactor Verify Correct!");
				if (SNet.IsMaster)
				{
					if (connectedReactor.m_currentWaveCount == connectedReactor.m_waveCountMax)
					{
						connectedReactor.AttemptInteract((eReactorInteraction)5, 0f);
					}
					else
					{
						connectedReactor.AttemptInteract((eReactorInteraction)3, 0f);
					}
				}
				__instance.AddOutput(Text.Get(MeltdownReactor.CorrectTerminalOutputTextID), true);
			}
			else
			{
				MeltdownReactorLogger.Info("Reactor Verify Incorrect!");
				__instance.AddOutput("", true);
				__instance.AddOutput((TerminalLineType)3, Text.Get(MeltdownReactor.IncorrectTerminalOutputTextID), 4f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance.AddOutput("", true);
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class Patch_Meltdown_Reactor
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Post_BuildDone(LG_WardenObjective_Reactor __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			WardenObjectiveDataBlock val = default(WardenObjectiveDataBlock);
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val))
			{
				MeltdownReactorLogger.Error("Failed to get WardenObjectiveData for this reactor");
			}
			else if (EntryPoint.ReactorOverrideDatas.ContainsKey(((GameDataBlockBase<WardenObjectiveDataBlock>)(object)val).persistentID))
			{
				ReactorOverrideData overrideData = EntryPoint.ReactorOverrideDatas[((GameDataBlockBase<WardenObjectiveDataBlock>)(object)val).persistentID];
				if ((int)val.Type != 1)
				{
					MeltdownReactorLogger.Error($"ObjectiveDataID {((GameDataBlockBase<WardenObjectiveDataBlock>)(object)val).persistentID} is not reactor startup, which is unsupported.");
					return;
				}
				MeltdownReactor meltdownReactor = ((Component)__instance).gameObject.AddComponent<MeltdownReactor>();
				meltdownReactor.ChainedReactor = __instance;
				meltdownReactor.UsingLightEffect = false;
				meltdownReactor.overrideData = overrideData;
				meltdownReactor.Init();
				MeltdownReactorLogger.Warning($"Override Reactor Data for ObjectiveID {((GameDataBlockBase<WardenObjectiveDataBlock>)(object)val).persistentID}");
			}
		}
	}
}
namespace MeltdownReactor.Json
{
	internal static class JSON
	{
		private static readonly JsonSerializerOptions s_SerializerOptions;

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, s_SerializerOptions);
		}

		public static string Serialize<T>(T obj)
		{
			return JsonSerializer.Serialize(obj, s_SerializerOptions);
		}

		static JSON()
		{
			s_SerializerOptions = new JsonSerializerOptions
			{
				AllowTrailingCommas = true,
				ReadCommentHandling = JsonCommentHandling.Skip,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true
			};
			s_SerializerOptions.Converters.Add(new JsonStringEnumConverter());
			if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized)
			{
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
				MeltdownReactorLogger.Info("PartialData Support Found!");
			}
			else
			{
				s_SerializerOptions.Converters.Add(new LocalizedTextConverter());
			}
		}

		public static void Load<T>(string file, out T config) where T : new()
		{
			if (file.Length < ".json".Length)
			{
				config = default(T);
				return;
			}
			if (file.Substring(file.Length - ".json".Length) != ".json")
			{
				file += ".json";
			}
			file = File.ReadAllText(Path.Combine(ConfigManager.CustomPath, "MeltdownReactor", file));
			config = Deserialize<T>(file);
		}
	}
	internal class LocalizedTextConverter : JsonConverter<LocalizedText>
	{
		public override bool HandleNull => false;

		public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			//IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			switch (reader.TokenType)
			{
			case JsonTokenType.String:
			{
				string @string = reader.GetString();
				return new LocalizedText
				{
					Id = 0u,
					UntranslatedText = @string
				};
			}
			case JsonTokenType.Number:
				return new LocalizedText
				{
					Id = reader.GetUInt32(),
					UntranslatedText = null
				};
			default:
				throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!");
			}
		}

		public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options)
		{
			JsonSerializer.Serialize<LocalizedText>(writer, value, options);
		}
	}
}
namespace MeltdownReactor.Json.PartialData
{
	public static class MTFOPartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		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;
			if (!((BaseChainloader<BasePlugin>)(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 == "LocalizedTextConverter");
				if ((object)type2 == null)
				{
					throw new Exception("Unable to Find LocalizedTextConverter Class");
				}
				Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class");
				PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo? property3 = obj2.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(type2);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				MeltdownReactorLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{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<BasePlugin>)(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)
			{
				MeltdownReactorLogger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}");
			}
		}
	}
}

plugins/Digital World/extra/MeleeFix.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Player;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MeleeFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MeleeFix")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0419bef8-8fd3-47f2-96e2-897346c1410e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MeleeFix
{
	[BepInPlugin("com.Sexypanda.MeleeFix", "MeleeFix", "1.0.0")]
	public class EntryPoint : BasePlugin
	{
		public override void Load()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.Sexypanda.MeleeFix").PatchAll();
		}
	}
}
namespace MeleeFix.Patches
{
	[HarmonyPatch]
	internal static class MeleeFix_Patch
	{
		[HarmonyPatch(typeof(FirstPersonItemHolder), "MeleeAttackShortcut")]
		[HarmonyPrefix]
		public static void MeleeAttackShortcut__Prefix(FirstPersonItemHolder __instance)
		{
			__instance.m_inventoryLocal.SetWieldDelayOverride(0f);
			__instance.m_owner.Sync.WantsToWieldSlot((InventorySlot)10, false);
		}
	}
}

plugins/Digital World/extra/net6/LEGACY.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
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.Serialization;
using AIGraph;
using AK;
using Agents;
using AssetShards;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using BoosterImplants;
using CellMenu;
using ChainedPuzzles;
using EOSExt.Reactor.Managers;
using Enemies;
using ExtraObjectiveSetup;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.Expedition.Gears;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using ExtraObjectiveSetup.Instances;
using ExtraObjectiveSetup.Utils;
using FirstPersonItem;
using FloLib.Infos;
using FloLib.Networks.Replications;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LEGACY.ExtraEvents;
using LEGACY.LegacyOverride;
using LEGACY.LegacyOverride.DummyVisual;
using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation;
using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation.AnimationConfig;
using LEGACY.LegacyOverride.DummyVisual.VisualSequenceType;
using LEGACY.LegacyOverride.ElevatorCargo;
using LEGACY.LegacyOverride.EnemyTagger;
using LEGACY.LegacyOverride.EventScan;
using LEGACY.LegacyOverride.ExpeditionIntelNotification;
using LEGACY.LegacyOverride.ExpeditionSuccessPage;
using LEGACY.LegacyOverride.FogBeacon;
using LEGACY.LegacyOverride.ForceFail;
using LEGACY.LegacyOverride.Music;
using LEGACY.LegacyOverride.ResourceStations;
using LEGACY.LegacyOverride.ThermalSightAdjustment;
using LEGACY.Utils;
using LEGACY.VanillaFix;
using LevelGeneration;
using Localization;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using ScanPosOverride.JSON;
using ScanPosOverride.Managers;
using StateMachines;
using TMPro;
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("LEGACY")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LEGACY")]
[assembly: AssemblyTitle("LEGACY")]
[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;
		}
	}
}
[HarmonyPatch(typeof(PUI_Watermark), "UpdateWatermark")]
internal static class Patch_WatermarkUpdateWatermark
{
	private static void Postfix(PUI_Watermark __instance)
	{
		string value = "4.6.1+gitf831086-dirty-main".Remove("x.x.x".Length);
		((TMP_Text)__instance.m_watermarkText).SetText($"<color=red>MODDED</color> <color=orange>{value}</color>\n<color=#00ae9d>LEGACY</color> <color=orange>{"4.2.4"} STANDALONE</color>", true);
	}
}
namespace LEGACY
{
	internal static class Assets
	{
		public static GameObject CircleSensor { get; private set; }

		public static GameObject MovableSensor { get; private set; }

		public static GameObject OBSVisual { get; private set; }

		public static GameObject ObjectiveMarker { get; private set; }

		public static GameObject EventScan { get; private set; }

		internal static GameObject DummyScan { get; private set; }

		internal static GameObject DummySensor { get; private set; }

		internal static GameObject AmmoStation { get; private set; }

		internal static GameObject MediStation { get; private set; }

		internal static GameObject ToolStation { get; private set; }

		public static void Init()
		{
			CircleSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/CircleSensor.prefab");
			MovableSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/MovableSensor.prefab");
			OBSVisual = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/OBSVisual.prefab");
			ObjectiveMarker = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/ObjectiveMarker.prefab");
			EventScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/EventObjects/EventScan.prefab");
			DummyScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummyScan.prefab");
			DummySensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummySensor.prefab");
			AmmoStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/AmmoStation.prefab");
			MediStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/MediStation.prefab");
			ToolStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/ToolStation.prefab");
		}
	}
	[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.*/)]
	[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.*/)]
	[BepInIncompatibility("GTFO.AWO")]
	[BepInPlugin("Inas.LEGACY", "LEGACY", "4.2.4")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string RUNDOWN_NAME = "LEGACY";

		public const string VERSION = "4.2.4";

		public const bool TESTING = false;

		public const string TEST_STRING = "TESTING";

		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("LEGACY");
			m_Harmony.PatchAll();
			LegacyOverrideManagers.Init();
			LegacyExtraEvents.Init();
			LEGACY.VanillaFix.Debugger.Current.Init();
			AssetAPI.OnAssetBundlesLoaded += Assets.Init;
			EventAPI.OnManagersSetup += delegate
			{
				AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)MainMenuGuiLayer.Current.PageRundownNew.SetupCustomTutorialButton);
			};
		}
	}
}
namespace LEGACY.Reactor
{
	[HarmonyPatch]
	internal class Patch_ReactorShutdown
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static void Post_OnStateChange(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0060: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected I4, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || oldState.status == newState.status)
			{
				return;
			}
			WardenObjectiveDataBlock val = null;
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
			{
				LegacyLogger.Error("Patch_ReactorShutdown: ");
				LegacyLogger.Error("Failed to get warden objective");
			}
			else if ((int)val.Type == 2 && !val.OnActivateOnSolveItem)
			{
				eWardenObjectiveEventTrigger val2 = (eWardenObjectiveEventTrigger)0;
				eReactorStatus status = newState.status;
				switch (status - 7)
				{
				default:
					return;
				case 0:
					val2 = (eWardenObjectiveEventTrigger)1;
					break;
				case 1:
					val2 = (eWardenObjectiveEventTrigger)2;
					break;
				case 2:
					val2 = (eWardenObjectiveEventTrigger)3;
					break;
				}
				_ = __instance.SpawnNode.LayerType;
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(val.EventsOnActivate, val2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Pre_OnBuildDone_ChainedPuzzleMidObjectiveFix(LG_WardenObjective_Reactor __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			WardenObjectiveDataBlock val = null;
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
			{
				LegacyLogger.Error("Patch_ReactorShutdown: Failed to get warden objective");
			}
			else if (val.ChainedPuzzleMidObjective != 0)
			{
				__instance.m_chainedPuzzleAlignMidObjective = __instance.m_chainedPuzzleAlign;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "Update")]
		private static bool Pre_Update(LG_WardenObjective_Reactor __instance)
		{
			//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_000c: Invalid comparison between Unknown and I4
			if ((int)__instance.m_currentState.status != 7)
			{
				return true;
			}
			if (!__instance.m_currentWaveData.HasVerificationTerminal)
			{
				return true;
			}
			__instance.SetGUIMessage(true, Text.Format(3000u, (Object[])(object)new Object[1] { Object.op_Implicit("<color=orange>" + __instance.m_currentWaveData.VerificationTerminalSerial + "</color>") }), (ePUIMessageStyle)3, false, "", "");
			return false;
		}
	}
	[HarmonyPatch]
	internal class Patch_ReactorStartup_ExtraEventsExecution
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static void Post_ExecuteOnNoneEventsOnDefenseStart(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//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 == 3)
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)0, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Post_OnBuildDone(LG_WardenObjective_Reactor __instance)
		{
			//IL_0011: 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_004c: Invalid comparison between Unknown and I4
			WardenObjectiveDataBlock db = default(WardenObjectiveDataBlock);
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref db) || db == null)
			{
				LegacyLogger.Error("Patch_ReactorStartup_ExtraEventsExecution: ");
				LegacyLogger.Error("Failed to get warden objective");
			}
			else if ((int)db.Type == 1 && !db.OnActivateOnSolveItem)
			{
				ChainedPuzzleInstance chainedPuzzleToStartSequence = __instance.m_chainedPuzzleToStartSequence;
				chainedPuzzleToStartSequence.OnPuzzleSolved += Action.op_Implicit((Action)delegate
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(db.EventsOnActivate, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
				});
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_ReactorStartup_OverwriteGUIBehaviour
	{
		private static HashSet<uint> ForceDisableLevels;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static bool Pre_HideReactorMessageForInfiniteWave(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//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_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_0017: Invalid comparison between Unknown and I4
			//IL_0019: 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_0020: Invalid comparison between Unknown and I4
			//IL_0037: 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_0022: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0078: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected I4, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: 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)
			if (oldState.status == newState.status)
			{
				return true;
			}
			if ((int)newState.status != 2 && (int)newState.status != 3 && (int)newState.status != 4)
			{
				return true;
			}
			if (ForceDisable())
			{
				if (oldState.stateCount != newState.stateCount)
				{
					__instance.OnStateCountUpdate(newState.stateCount);
				}
				if (oldState.stateProgress != newState.stateProgress)
				{
					__instance.OnStateProgressUpdate(newState.stateProgress);
				}
				__instance.ReadyForVerification = false;
				eReactorStatus status = newState.status;
				switch (status - 2)
				{
				case 0:
				{
					WardenObjectiveDataBlock val = null;
					if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
					{
						LegacyLogger.Error("Patch_ReactorStartup_OverwriteGUIBehaviour: ");
						LegacyLogger.Error("Failed to get warden objective datablock");
						break;
					}
					__instance.m_lightCollection.SetMode(val.LightsOnDuringIntro);
					__instance.m_lightCollection.ResetUpdateValues(true);
					__instance.lcReset = true;
					__instance.m_lightsBlinking = false;
					__instance.m_spawnEnemies = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.m_alarmCountdownPlayed = false;
					__instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Warmup : __instance.m_currentWaveData.WarmupFail);
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)1, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
					if (__instance.m_currentWaveCount == 1)
					{
						Debug.LogError(Object.op_Implicit("Reactor IDLE START"));
						__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_LOOP, true);
						__instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f);
					}
					else
					{
						Debug.LogError(Object.op_Implicit("Reactor REACTOR_POWER_DOWN"));
						__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_2_TO_1_TRANSITION, true);
						__instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f);
					}
					break;
				}
				case 1:
					__instance.m_lightCollection.ResetUpdateValues(true);
					__instance.lcReset = true;
					__instance.m_spawnEnemies = true;
					__instance.m_currentEnemyWaveIndex = 0;
					__instance.m_alarmCountdownPlayed = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.m_currentDuration = __instance.m_currentWaveData.Wave;
					__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_TO_3_TRANSITION, true);
					break;
				case 2:
					__instance.m_lightCollection.ResetUpdateValues(false);
					__instance.lcReset = true;
					__instance.m_spawnEnemies = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.ReadyForVerification = true;
					Debug.Log(Object.op_Implicit("Wait for verify! newState.verifyFailed? " + newState.verifyFailed));
					__instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Verify : __instance.m_currentWaveData.VerifyFail);
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
					break;
				}
				__instance.m_currentState = newState;
				return false;
			}
			return true;
		}

		private static bool ForceDisable()
		{
			return ForceDisableLevels.Contains(RundownManager.ActiveExpedition.LevelLayoutData);
		}

		static Patch_ReactorStartup_OverwriteGUIBehaviour()
		{
			ForceDisableLevels = new HashSet<uint>();
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L3E2_L1");
			if (block != null)
			{
				ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID);
			}
			block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L1E1_L1");
			if (block != null)
			{
				ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID);
			}
		}
	}
}
namespace LEGACY.HardcodedBehaviours
{
	[HarmonyPatch]
	internal class Patch_PickupItem_Hardcoded
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_Distribute_PickupItemsPerZone), "Build")]
		private static void Pre_LG_Distribute_PickupItemsPerZone(LG_Distribute_PickupItemsPerZone __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_002f: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("LAYOUT_O4_1_L1");
			if (block == null || RundownManager.ActiveExpedition.LevelLayoutData != ((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID)
			{
				return;
			}
			eLocalZoneIndex localIndex = __instance.m_zone.LocalIndex;
			if ((int)localIndex != 1)
			{
				if ((int)localIndex == 5)
				{
					__instance.m_zonePlacementWeights.Start = 0f;
					__instance.m_zonePlacementWeights.Middle = 0f;
					__instance.m_zonePlacementWeights.End = 100000f;
				}
			}
			else if ((int)__instance.m_pickupType == 1)
			{
				__instance.m_zonePlacementWeights.Start = 100000f;
				__instance.m_zonePlacementWeights.Middle = 0f;
				__instance.m_zonePlacementWeights.End = 0f;
			}
		}
	}
}
namespace LEGACY.VanillaFix
{
	[HarmonyPatch]
	internal class Patch_FixScoutFreeze
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ES_ScoutScream), "CommonUpdate")]
		private static bool Prefix_Debug(ES_ScoutScream __instance)
		{
			if (((AgentAI)((ES_Base)__instance).m_ai).Target == null)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class Patch_LG_SecurityDoor_Fix_EventsOnUnlockDoor_Powergenerator
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		private static void Pre_OnSyncDoorStatusChange(LG_SecurityDoor __instance, pDoorState state, 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0013: 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_001e: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			eDoorStatus status = state.status;
			if ((status - 4 <= 1 || (int)status == 9) && (int)__instance.m_lastState.status == 6 && !isRecall)
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.LinkedToZoneData.EventsOnUnlockDoor, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_LockSecurityDoor_FixCustomText
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "Setup", new Type[] { typeof(LG_SecurityDoor) })]
		private static void Post_LG_SecurityDoor_Locks_Setup(LG_SecurityDoor door, LG_SecurityDoor_Locks __instance)
		{
			LocalizedText customText = door.LinkedToZoneData.ProgressionPuzzleToEnter.CustomText;
			__instance.m_lockedWithNoKeyInteractionText = customText;
		}
	}
	[HarmonyPatch]
	internal class Debugger
	{
		public static Debugger Current { get; private set; } = new Debugger();


		public bool DEBUGGING { get; private set; }

		private Debugger()
		{
		}

		internal void Init()
		{
			_ = DEBUGGING;
		}
	}
}
namespace LEGACY.Utils
{
	public delegate float EasingFunction(float t, float b, float c, float d);
	public delegate bool BoolCheck();
	internal static class CoroutineEase
	{
		private static IEnumerator DoEaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//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)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localScale = Vector3.Lerp(startScale, targetScale, num);
				yield return null;
			}
			trans.localScale = targetScale;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		private static IEnumerator DoEaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//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)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localPosition = Vector3.Lerp(sourcePos, targetPos, num);
				yield return null;
			}
			trans.localPosition = targetPos;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		private static IEnumerator DoEaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//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)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localEulerAngles = Vector3.Lerp(sourceEuler, targetEuler, num);
				yield return null;
			}
			trans.localEulerAngles = targetEuler;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		internal static Coroutine EaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: 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)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalScale(trans, startScale, targetScale, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}

		internal static Coroutine EaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: 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)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalPos(trans, sourcePos, targetPos, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}

		internal static Coroutine EaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: 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)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalRot(trans, sourceEuler, targetEuler, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}
	}
	public static class Helper
	{
		private static void ResetChild(iChainedPuzzleCore ICore)
		{
			CP_Bioscan_Core val = ((Il2CppObjectBase)ICore).TryCast<CP_Bioscan_Core>();
			if ((Object)(object)val != (Object)null)
			{
				((Il2CppObjectBase)val.m_spline).Cast<CP_Holopath_Spline>();
				((Il2CppObjectBase)val.PlayerScanner).Cast<CP_PlayerScanner>().ResetScanProgression(0f);
				val.Deactivate();
				return;
			}
			CP_Cluster_Core val2 = ((Il2CppObjectBase)ICore).TryCast<CP_Cluster_Core>();
			if ((Object)(object)val2 == (Object)null)
			{
				LegacyLogger.Error("ResetChild: found iChainedPuzzleCore that is neither CP_Bioscan_Core nor CP_Cluster_Core...");
				return;
			}
			((Il2CppObjectBase)val2.m_spline).Cast<CP_Holopath_Spline>();
			foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)val2.m_childCores)
			{
				ResetChild(item);
			}
			val2.Deactivate();
		}

		public static void ResetChainedPuzzle(ChainedPuzzleInstance chainedPuzzleInstance)
		{
			//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 (chainedPuzzleInstance.Data.DisableSurvivalWaveOnComplete)
			{
				chainedPuzzleInstance.m_sound = new CellSoundPlayer(chainedPuzzleInstance.m_parent.position);
			}
			foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleInstance.m_chainedPuzzleCores)
			{
				ResetChild(item);
			}
			if (SNet.IsMaster)
			{
				pChainedPuzzleState state = chainedPuzzleInstance.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;
				chainedPuzzleInstance.m_stateReplicator.InteractWithState(val2, new pChainedPuzzleInteraction
				{
					type = (eChainedPuzzleInteraction)2
				});
			}
		}

		public static List<T> ToManagedList<T>(this List<T> il2cppList)
		{
			List<T> list = new List<T>();
			Enumerator<T> enumerator = il2cppList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				list.Add(current);
			}
			return list;
		}

		public static bool TryGetComponent<T>(this GameObject obj, out T comp)
		{
			comp = obj.GetComponent<T>();
			return comp != null;
		}

		public static bool IsPlayerInLevel(PlayerAgent player)
		{
			//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: Invalid comparison between Unknown and I4
			return (int)player.Owner.Load<pGameState>().gameState == 10;
		}

		public static ChainedPuzzleInstance GetChainedPuzzleForCommandOnTerminal(LG_ComputerTerminal terminal, string command)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected I4, but got Unknown
			//IL_00bc: 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_0133: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Invalid comparison between Unknown and I4
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Invalid comparison between Unknown and I4
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Invalid comparison between Unknown and I4
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Invalid comparison between Unknown and I4
			//IL_01d2: 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_01b5: Invalid comparison between Unknown and I4
			uint num = 0u;
			if (terminal.SpawnNode.m_dimension.IsMainDimension)
			{
				LG_LayerType layerType = terminal.SpawnNode.LayerType;
				switch ((int)layerType)
				{
				case 0:
					num = RundownManager.ActiveExpedition.LevelLayoutData;
					break;
				case 1:
					num = RundownManager.ActiveExpedition.SecondaryLayout;
					break;
				case 2:
					num = RundownManager.ActiveExpedition.ThirdLayout;
					break;
				default:
					LegacyLogger.Error("Unimplemented layer type.");
					return null;
				}
			}
			else
			{
				num = terminal.SpawnNode.m_dimension.DimensionData.LevelLayoutData;
			}
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(num);
			List<CustomTerminalCommand> val = null;
			List<LG_ComputerTerminal> terminalsSpawnedInZone = terminal.SpawnNode.m_zone.TerminalsSpawnedInZone;
			int num2 = terminalsSpawnedInZone.IndexOf(terminal);
			ExpeditionZoneData val2 = null;
			Enumerator<ExpeditionZoneData> enumerator = block.Zones.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ExpeditionZoneData current = enumerator.Current;
				if (current.LocalIndex == terminal.SpawnNode.m_zone.LocalIndex)
				{
					val2 = current;
					break;
				}
			}
			if (val2 == null)
			{
				LegacyLogger.Error("Cannot find target zone data.");
				return null;
			}
			if (val2.TerminalPlacements.Count != terminalsSpawnedInZone.Count)
			{
				LegacyLogger.Error("The numbers of terminal placement and spawn, skipped for the zone terminal.");
				return null;
			}
			val = val2.TerminalPlacements[num2].UniqueCommands;
			if (val.Count == 0)
			{
				return null;
			}
			List<WardenObjectiveEventData> val3 = null;
			TERM_Command val4 = (TERM_Command)0;
			Enumerator<CustomTerminalCommand> enumerator2 = val.GetEnumerator();
			string text = default(string);
			string text2 = default(string);
			while (enumerator2.MoveNext())
			{
				CustomTerminalCommand current2 = enumerator2.Current;
				if (current2.Command == command)
				{
					val3 = current2.CommandEvents;
					if (!terminal.m_command.TryGetCommand(current2.Command, ref val4, ref text, ref text2))
					{
						LegacyLogger.Error("Cannot get TERM_COMMAND for command {0} on the specified terminal.");
					}
					break;
				}
			}
			if (val3 == null || (int)val4 == 0)
			{
				return null;
			}
			if ((int)val4 != 38 && (int)val4 != 39 && (int)val4 != 40 && (int)val4 != 41 && (int)val4 != 42)
			{
				return null;
			}
			ChainedPuzzleInstance val5 = null;
			for (int i = 0; i < val3.Count && (val3[i].ChainPuzzle == 0 || !terminal.TryGetChainPuzzleForCommand(val4, i, ref val5) || !((Object)(object)val5 != (Object)null)); i++)
			{
			}
			return val5;
		}

		public static bool TryGetZoneEntranceSecDoor(LG_Zone zone, out LG_SecurityDoor door)
		{
			if ((Object)(object)zone == (Object)null)
			{
				door = null;
				return false;
			}
			if ((Object)(object)zone.m_sourceGate == (Object)null)
			{
				door = null;
				return false;
			}
			if (zone.m_sourceGate.SpawnedDoor == null)
			{
				door = null;
				return false;
			}
			door = ((Il2CppObjectBase)zone.m_sourceGate.SpawnedDoor).TryCast<LG_SecurityDoor>();
			return (Object)(object)door != (Object)null;
		}

		internal static bool isSecDoorToZoneOpened(LG_Zone zone14)
		{
			//IL_001d: 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)
			//IL_0029: Invalid comparison between Unknown and I4
			LG_SecurityDoor door = null;
			if (!TryGetZoneEntranceSecDoor(zone14, out door) || (Object)(object)door == (Object)null)
			{
				return false;
			}
			return (int)door.m_sync.GetCurrentSyncState().status == 10;
		}

		public static List<T> cast<T>(List<T> list)
		{
			List<T> list2 = new List<T>();
			Enumerator<T> enumerator = list.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				list2.Add(current);
			}
			return list2;
		}

		private static eDimensionIndex GetCurrentDimensionIndex()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerManager.PlayerAgentsInLevel.Count <= 0)
			{
				throw new Exception("? You don't have any player agent in level? How could that happen?");
			}
			return ((Agent)PlayerManager.PlayerAgentsInLevel[0]).DimensionIndex;
		}

		public static void GetMinLayerAndLocalIndex(out LG_LayerType MinLayer, out eLocalZoneIndex MinLocalIndex)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between I4 and Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between I4 and Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected I4, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected I4, but got Unknown
			MinLayer = (LG_LayerType)2;
			MinLocalIndex = (eLocalZoneIndex)20;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsPlayerInLevel(current))
				{
					if ((int)MinLayer > (int)current.m_courseNode.LayerType)
					{
						MinLayer = (LG_LayerType)(int)current.m_courseNode.LayerType;
						MinLocalIndex = (eLocalZoneIndex)20;
					}
					if ((int)MinLocalIndex >= (int)current.m_courseNode.m_zone.LocalIndex)
					{
						MinLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex;
					}
				}
			}
		}

		public static void GetMaxLayerAndLocalIndex(out LG_LayerType MaxLayer, out eLocalZoneIndex MaxLocalIndex)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between I4 and Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between I4 and Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected I4, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected I4, but got Unknown
			MaxLayer = (LG_LayerType)0;
			MaxLocalIndex = (eLocalZoneIndex)0;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsPlayerInLevel(current))
				{
					if ((int)MaxLayer < (int)current.m_courseNode.LayerType)
					{
						MaxLayer = (LG_LayerType)(int)current.m_courseNode.LayerType;
						MaxLocalIndex = (eLocalZoneIndex)0;
					}
					if ((int)MaxLocalIndex < (int)current.m_courseNode.m_zone.LocalIndex)
					{
						MaxLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex;
					}
				}
			}
		}

		public static int GetMinAreaIndex(LG_Zone zone)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001e: 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_0051: 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)
			if ((Object)(object)zone == (Object)null)
			{
				return -1;
			}
			LG_LayerType type = zone.m_layer.m_type;
			eLocalZoneIndex localIndex = zone.LocalIndex;
			GetCurrentDimensionIndex();
			int num = zone.m_areas.Count;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (current.m_courseNode.LayerType != type || current.m_courseNode.m_zone.LocalIndex != localIndex)
				{
					continue;
				}
				int i = 0;
				for (List<LG_Area> areas = zone.m_areas; i < areas.Count; i++)
				{
					if (((Object)((Component)areas[i]).gameObject).GetInstanceID() == ((Object)((Component)current.m_courseNode.m_area).gameObject).GetInstanceID())
					{
						if (num > i)
						{
							num = i;
						}
						break;
					}
				}
			}
			return num;
		}

		public static LG_ComputerTerminal FindTerminal(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, int terminalIndex)
		{
			//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_0009: 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_0048: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = null;
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, localIndex, ref val) || (Object)(object)val == (Object)null)
			{
				LegacyLogger.Error($"FindTerminal: Didn't find LG_Zone {dimensionIndex}, {layerType}, {localIndex}");
				return null;
			}
			if (val.TerminalsSpawnedInZone == null || terminalIndex >= val.TerminalsSpawnedInZone.Count)
			{
				LegacyLogger.Error($"FindTerminal: Invalid terminal index {terminalIndex} - {((val.TerminalsSpawnedInZone != null) ? val.TerminalsSpawnedInZone.Count : 0)} terminals are spawned in {dimensionIndex}, {layerType}, {localIndex}");
				return null;
			}
			if (terminalIndex >= 0)
			{
				return val.TerminalsSpawnedInZone[terminalIndex];
			}
			return null;
		}

		public static AIG_NodeCluster GetNodeFromDimensionPosition(eDimensionIndex dimensionIndex, Vector3 position)
		{
			//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_0012: 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)
			AIG_GeomorphNodeVolume val = default(AIG_GeomorphNodeVolume);
			AIG_VoxelNodePillar val2 = default(AIG_VoxelNodePillar);
			AIG_INode val3 = default(AIG_INode);
			AIG_NodeCluster result = default(AIG_NodeCluster);
			if (!AIG_GeomorphNodeVolume.TryGetGeomorphVolume(0, dimensionIndex, position, ref val) || !((AIG_NodeVolume)val).m_voxelNodeVolume.TryGetPillar(position, ref val2) || !val2.TryGetVoxelNode(position.y, ref val3) || !AIG_NodeCluster.TryGetNodeCluster(val3.ClusterID, ref result))
			{
				LegacyLogger.Error("TryWarpTo : Position is not valid, try again inside an area.");
				return null;
			}
			return result;
		}
	}
	internal static class Json
	{
		private static readonly JsonSerializerOptions _setting;

		static Json()
		{
			_setting = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				IncludeFields = false,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true,
				IgnoreReadOnlyProperties = true
			};
			_setting.Converters.Add(new JsonStringEnumConverter());
			_setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
			_setting.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
		}

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, _setting);
		}

		public static object Deserialize(Type type, string json)
		{
			return JsonSerializer.Deserialize(json, type, _setting);
		}

		public static string Serialize<T>(T value)
		{
			return JsonSerializer.Serialize(value, _setting);
		}

		public static void Load<T>(string filePath, out T config) where T : new()
		{
			config = Deserialize<T>(File.ReadAllText(filePath));
		}
	}
	internal static class LegacyLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("LEGACYCore");

		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);
			}
		}
	}
	public class SpawnHibernateEnemiesEvent
	{
		public eWardenObjectiveEventTrigger Trigger { get; set; }

		public int Type { get; set; } = 170;


		public eDimensionIndex DimensionIndex { get; set; }

		public LG_LayerType Layer { get; set; }

		public eLocalZoneIndex LocalIndex { get; set; }

		public string WorldEventObjectFilter { get; set; } = "RANDOM";


		public uint EnemyID { get; set; }

		public int Count { get; set; } = 1;


		public float Delay { get; set; }

		public float Duration { get; set; } = 2f;

	}
	public class WeightedAreaSelector
	{
		private static readonly Dictionary<LG_Zone, WeightedAreaSelector> dict;

		private WeightedRandomBag<LG_Area> weightedRandomBag;

		public static WeightedAreaSelector Get(LG_Zone zone)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected I4, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (!dict.ContainsKey(zone))
			{
				WeightedAreaSelector weightedAreaSelector = new WeightedAreaSelector();
				Enumerator<LG_Area> enumerator = zone.m_areas.GetEnumerator();
				while (enumerator.MoveNext())
				{
					LG_Area current = enumerator.Current;
					float num = 0f;
					LG_AreaSize size = current.m_size;
					switch (size - 1)
					{
					case 4:
						num = 7f;
						break;
					case 0:
						num = 20f;
						break;
					case 1:
						num = 30f;
						break;
					case 2:
						num = 35f;
						break;
					case 3:
						num = 45f;
						break;
					default:
						LegacyLogger.Error($"Unhandled LG_AreaSize: {current.m_size}. Won't build.");
						return null;
					}
					weightedAreaSelector.AddEntry(current, num);
				}
				dict.Add(zone, weightedAreaSelector);
			}
			return dict[zone];
		}

		public static WeightedAreaSelector Get(eDimensionIndex eDimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex)
		{
			//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)
			LG_Zone val = default(LG_Zone);
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(eDimensionIndex, layerType, localIndex, ref val) || !Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return Get(val);
		}

		private WeightedAreaSelector()
		{
			weightedRandomBag = new WeightedRandomBag<LG_Area>();
		}

		private void AddEntry(LG_Area area, float weight)
		{
			weightedRandomBag.AddEntry(area, weight);
		}

		public LG_Area GetRandom()
		{
			return weightedRandomBag.GetRandom();
		}

		private static void OnBuildDone()
		{
		}

		private static void Clear()
		{
			dict.Clear();
		}

		static WeightedAreaSelector()
		{
			dict = new Dictionary<LG_Zone, WeightedAreaSelector>();
			LevelAPI.OnLevelCleanup += dict.Clear;
		}
	}
	public class WeightedRandomBag<T>
	{
		private struct Entry
		{
			public double accumulatedWeight;

			public T item;
		}

		private List<Entry> entries = new List<Entry>();

		private double accumulatedWeight;

		private Random rand = new Random();

		public void AddEntry(T item, double weight)
		{
			if (weight <= 0.0)
			{
				LegacyLogger.Error("AddEntry: no non-positive weight pls.");
				return;
			}
			accumulatedWeight += weight;
			entries.Add(new Entry
			{
				item = item,
				accumulatedWeight = accumulatedWeight
			});
		}

		public T GetRandom()
		{
			double num = rand.NextDouble() * accumulatedWeight;
			foreach (Entry entry in entries)
			{
				if (entry.accumulatedWeight >= num)
				{
					return entry.item;
				}
			}
			return default(T);
		}
	}
}
namespace LEGACY.LegacyOverride
{
	internal class NavMarkerManager
	{
		private Dictionary<string, GameObject> markerVisuals = new Dictionary<string, GameObject>();

		private Dictionary<string, NavMarker> navMarkers = new Dictionary<string, NavMarker>();

		private List<GameObject> arbitraryNavMarkers = new List<GameObject>();

		public static NavMarkerManager Current { get; private set; } = new NavMarkerManager();


		private GameObject InstantiateMarkerVisual()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(Assets.ObjectiveMarker);
			float num = 0.16216217f;
			Transform transform = obj.transform;
			transform.localPosition += Vector3.up * num;
			return obj;
		}

		public void EnableMarkerAt(string markerName, GameObject target, float scale)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(true);
			}
			else
			{
				NavMarker val = GuiManager.NavMarkerLayer.PrepareGenericMarker(target);
				if ((Object)(object)val != (Object)null)
				{
					val.SetColor(new Color(0.855f, 0.482f, 0.976f));
					val.SetStyle((eNavMarkerStyle)14);
					val.SetVisible(true);
					navMarkers[markerName] = val;
				}
				else
				{
					LegacyLogger.Error("EnableMarkerAt: got null nav marker");
				}
			}
			GameObject val2 = null;
			if (markerVisuals.ContainsKey(markerName))
			{
				val2 = markerVisuals[markerName];
			}
			else
			{
				val2 = InstantiateMarkerVisual();
				val2.transform.localScale = new Vector3(scale, scale, scale);
				val2.transform.SetPositionAndRotation(target.transform.position, Quaternion.identity);
				markerVisuals[markerName] = val2;
			}
			CoroutineManager.BlinkIn(val2, 0f);
			LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled");
		}

		public void EnableArbitraryMarkerAt(string markerName, Vector3 Position)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(true);
			}
			else
			{
				GameObject val = new GameObject(markerName);
				val.transform.SetPositionAndRotation(Position, Quaternion.identity);
				arbitraryNavMarkers.Add(val);
				NavMarker val2 = GuiManager.NavMarkerLayer.PrepareGenericMarker(val);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetColor(new Color(0.855f, 0.482f, 0.976f));
					val2.SetStyle((eNavMarkerStyle)14);
					val2.SetVisible(true);
					navMarkers[markerName] = val2;
				}
				else
				{
					LegacyLogger.Error("EnableMarkerAt: got null nav marker");
				}
			}
			LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled");
		}

		internal (GameObject markerVisual, NavMarker navMakrer) GetMarkerVisuals(string markerName)
		{
			if (!markerVisuals.TryGetValue(markerName, out var value) || !navMarkers.TryGetValue(markerName, out var value2))
			{
				return (null, null);
			}
			return (value, value2);
		}

		public void DisableMakrer(string markerName)
		{
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(false);
			}
			if (markerVisuals.ContainsKey(markerName))
			{
				GameObject val = markerVisuals[markerName];
				if (val.active)
				{
					CoroutineManager.BlinkOut(val, 0f);
				}
				LegacyLogger.Debug("DisableMakrer: marker " + markerName + " disabled");
			}
		}

		public void Clear()
		{
			foreach (GameObject value in markerVisuals.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			arbitraryNavMarkers.ForEach((Action<GameObject>)Object.Destroy);
			markerVisuals.Clear();
			navMarkers.Clear();
			arbitraryNavMarkers.Clear();
		}

		private NavMarkerManager()
		{
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
		}
	}
	internal static class LegacyOverrideManagers
	{
		internal static readonly string LEGACY_CONFIG_PATH = Path.Combine(MTFOPathAPI.CustomPath, "LegacyOverride");

		internal static void Init()
		{
			ElevatorCargoOverrideManager.Current.Init();
			BigPickupFogBeaconSettingManager.Current.Init();
			EnemyTaggerSettingManager.Current.Init();
			ForceFailManager.Current.Init();
			((GenericExpeditionDefinitionManager<ExpeditionIntel>)ExpeditionIntelNotifier.Current).Init();
			((GenericExpeditionDefinitionManager<EventScanDefinition>)EventScanManager.Current).Init();
			((GenericExpeditionDefinitionManager<VisualGroupDefinition>)VisualManager.Current).Init();
			((GenericExpeditionDefinitionManager<MusicOverride>)MusicStateOverrider.Current).Init();
			((ZoneDefinitionManager<LevelSpawnedFogBeaconDefinition>)LevelSpawnedFogBeaconManager.Current).Init();
			((GenericExpeditionDefinitionManager<SuccessPageCustomization>)SuccessPageCustomizationManager.Current).Init();
			((GenericExpeditionDefinitionManager<ResourceStationDefinition>)ResourceStationManager.Current).Init();
			AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)delegate
			{
				((GenericDefinitionManager<TSADefinition>)TSAManager.Current).Init();
			});
		}
	}
}
namespace LEGACY.LegacyOverride.ThermalSightAdjustment
{
	public class TSADefinition
	{
		public float OffAimPixelZoom { get; set; } = 1f;


		public TSShader Shader { get; set; } = new TSShader();

	}
	internal class TSAManager : GenericDefinitionManager<TSADefinition>
	{
		private class PuzzleVisualWrapper
		{
			internal GameObject GO { get; set; }

			internal Renderer Renderer { get; set; }

			internal float Intensity { get; set; }

			internal float BehindWallIntensity { get; set; }

			internal void SetIntensity(float t)
			{
				if (GO.active)
				{
					if (Intensity > 0f)
					{
						Renderer.material.SetFloat("_Intensity", Intensity * t);
					}
					if (BehindWallIntensity > 0f)
					{
						Renderer.material.SetFloat("_BehindWallIntensity", BehindWallIntensity * t);
					}
				}
			}

			internal PuzzleVisualWrapper()
			{
			}
		}

		private const bool OUTPUT_THERMAL_SHADER_SETTINGS_ON_WIELD = false;

		private List<PuzzleVisualWrapper> PuzzleVisuals { get; } = new List<PuzzleVisualWrapper>();


		public static TSAManager Current { get; }

		protected override string DEFINITION_NAME => "ThermalSight";

		private Dictionary<uint, Renderer[]> InLevelGearThermals { get; } = new Dictionary<uint, Renderer[]>();


		private HashSet<uint> ModifiedInLevelGearThermals { get; } = new HashSet<uint>();


		private HashSet<uint> ThermalOfflineGears { get; } = new HashSet<uint>();


		public uint CurrentGearPID { get; private set; }

		internal void RegisterPuzzleVisual(CP_Bioscan_Core core)
		{
			Il2CppArrayBase<Renderer> componentsInChildren = ((Component)core).gameObject.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren == null)
			{
				return;
			}
			foreach (Renderer item2 in ((IEnumerable<Renderer>)componentsInChildren).Where((Renderer comp) => ((Object)((Component)comp).gameObject).name.Equals("Zone")).ToList())
			{
				GameObject gameObject = ((Component)item2).gameObject;
				float @float = item2.material.GetFloat("_Intensity");
				float float2 = item2.material.GetFloat("_BehindWallIntensity");
				PuzzleVisualWrapper item = new PuzzleVisualWrapper
				{
					GO = gameObject,
					Renderer = item2,
					Intensity = @float,
					BehindWallIntensity = float2
				};
				PuzzleVisuals.Add(item);
			}
		}

		private void AddOBSVisualRenderers()
		{
			foreach (GameObject oBSVisual in EnemyTaggerSettingManager.Current.OBSVisuals)
			{
				Renderer componentInChildren = oBSVisual.GetComponentInChildren<Renderer>();
				float @float = componentInChildren.material.GetFloat("_Intensity");
				float behindWallIntensity = -1f;
				PuzzleVisuals.Add(new PuzzleVisualWrapper
				{
					GO = oBSVisual,
					Renderer = componentInChildren,
					Intensity = @float,
					BehindWallIntensity = behindWallIntensity
				});
			}
		}

		internal void SetPuzzleVisualsIntensity(float t)
		{
			PuzzleVisuals.ForEach(delegate(PuzzleVisualWrapper v)
			{
				v.SetIntensity(t);
			});
		}

		private void CleanupPuzzleVisuals()
		{
			PuzzleVisuals.Clear();
		}

		protected override void FileChanged(LiveEditEventArgs e)
		{
			base.FileChanged(e);
			InitThermalOfflineGears();
			CleanupInLevelGearThermals(keepCurrentGear: true);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public override void Init()
		{
			InitThermalOfflineGears();
		}

		private void InitThermalOfflineGears()
		{
			ThermalOfflineGears.Clear();
			foreach (PlayerOfflineGearDataBlock allBlock in GameDataBlockBase<PlayerOfflineGearDataBlock>.GetAllBlocks())
			{
				if (((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).name.ToLowerInvariant().EndsWith("_t"))
				{
					ThermalOfflineGears.Add(((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).persistentID);
				}
			}
			LegacyLogger.Debug($"Found OfflineGear with thermal sight, count: {ThermalOfflineGears.Count}");
		}

		private bool TryGetInLevelGearThermalRenderersFromItem(ItemEquippable item, uint gearPID, out Renderer[] renderers)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			renderers = null;
			if (item.GearIDRange == null)
			{
				return false;
			}
			if (gearPID == 0)
			{
				gearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			}
			if (gearPID == 0 || !IsGearWithThermal(gearPID))
			{
				return false;
			}
			bool flag = false;
			if (!InLevelGearThermals.ContainsKey(gearPID))
			{
				flag = true;
			}
			else
			{
				try
				{
					_ = ((Component)InLevelGearThermals[gearPID][0]).gameObject.transform.position;
					flag = false;
				}
				catch
				{
					ModifiedInLevelGearThermals.Remove(gearPID);
					flag = true;
				}
			}
			if (flag)
			{
				renderers = (from x in ((IEnumerable<Renderer>)((Component)item).GetComponentsInChildren<Renderer>(true))?.Where((Renderer x) => (Object)(object)x.sharedMaterial != (Object)null && (Object)(object)x.sharedMaterial.shader != (Object)null)
					where ((Object)x.sharedMaterial.shader).name.ToLower().Contains("Thermal".ToLower())
					select x).ToArray() ?? null;
				if (renderers != null)
				{
					if (renderers.Length != 1)
					{
						LegacyLogger.Warning(((Item)item).PublicName + " contains more than 1 thermal renderers!");
					}
					InLevelGearThermals[gearPID] = renderers;
					return true;
				}
				LegacyLogger.Debug(((Item)item).PublicName + ": thermal renderer not found");
				return false;
			}
			renderers = InLevelGearThermals[gearPID];
			return true;
		}

		internal bool TrySetThermalSightRenderer(uint gearPID = 0u)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0110: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (gearPID == 0)
			{
				gearPID = CurrentGearPID;
			}
			if (!IsGearWithThermal(gearPID))
			{
				return false;
			}
			if (ModifiedInLevelGearThermals.Contains(gearPID))
			{
				return true;
			}
			if (base.definitions.TryGetValue(gearPID, out var value) && InLevelGearThermals.TryGetValue(gearPID, out var value2))
			{
				TSShader shader = value.Definition.Shader;
				Renderer[] array = value2;
				foreach (Renderer val in array)
				{
					PropertyInfo[] properties = shader.GetType().GetProperties();
					foreach (PropertyInfo propertyInfo in properties)
					{
						Type type = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType;
						string text = "_" + propertyInfo.Name;
						if (type == typeof(float))
						{
							val.material.SetFloat(text, (float)propertyInfo.GetValue(shader));
						}
						else if (type == typeof(EOSColor))
						{
							EOSColor val2 = (EOSColor)propertyInfo.GetValue(shader);
							val.material.SetVector(text, Color.op_Implicit(val2.ToUnityColor()));
						}
						else if (type == typeof(bool))
						{
							bool flag = (bool)propertyInfo.GetValue(shader);
							val.material.SetFloat(text, flag ? 1f : 0f);
						}
						else if (type == typeof(Vec4))
						{
							Vec4 val3 = (Vec4)propertyInfo.GetValue(shader);
							val.material.SetVector(text, val3.ToVector4());
						}
					}
				}
				ModifiedInLevelGearThermals.Add(gearPID);
				return true;
			}
			return false;
		}

		internal void OnPlayerItemWielded(FirstPersonItemHolder fpsItemHolder, ItemEquippable item)
		{
			if (item.GearIDRange == null)
			{
				CurrentGearPID = 0u;
				return;
			}
			CurrentGearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			TryGetInLevelGearThermalRenderersFromItem(item, CurrentGearPID, out var _);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public bool IsGearWithThermal(uint gearPID)
		{
			return ThermalOfflineGears.Contains(gearPID);
		}

		private void CleanupInLevelGearThermals(bool keepCurrentGear = false)
		{
			if (!keepCurrentGear || !InLevelGearThermals.ContainsKey(CurrentGearPID))
			{
				InLevelGearThermals.Clear();
			}
			else
			{
				Renderer[] value = InLevelGearThermals[CurrentGearPID];
				InLevelGearThermals.Clear();
				InLevelGearThermals[CurrentGearPID] = value;
			}
			ModifiedInLevelGearThermals.Clear();
		}

		internal void SetCurrentThermalSightSettings(float t)
		{
			if (InLevelGearThermals.TryGetValue(CurrentGearPID, out var value) && base.definitions.TryGetValue(CurrentGearPID, out var value2))
			{
				Renderer[] array = value;
				foreach (Renderer obj in array)
				{
					float zoom = value2.Definition.Shader.Zoom;
					float offAimPixelZoom = value2.Definition.OffAimPixelZoom;
					float num = Mathf.Lerp(zoom, offAimPixelZoom, t);
					obj.material.SetFloat("_Zoom", num);
				}
			}
		}

		private void Clear()
		{
			CurrentGearPID = 0u;
			CleanupInLevelGearThermals();
			CleanupPuzzleVisuals();
		}

		private TSAManager()
		{
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
			LevelAPI.OnEnterLevel += AddOBSVisualRenderers;
		}

		static TSAManager()
		{
			Current = new TSAManager();
		}
	}
	public class TSShader
	{
		[JsonPropertyName("DistanceFalloff")]
		[Range(0.0, 1.0)]
		public float HeatFalloff { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float FogFalloff { get; set; } = 0.1f;


		[JsonPropertyName("PixelZoom")]
		[Range(0.0, 1.0)]
		public float Zoom { get; set; } = 0.8f;


		[JsonPropertyName("AspectRatioAdjust")]
		[Range(0.0, 2.0)]
		public float RatioAdjust { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionCenter { get; set; } = 0.5f;


		public float DistortionScale { get; set; } = 1f;


		public float DistortionSpeed { get; set; } = 1f;


		public float DistortionSignalSpeed { get; set; } = 0.025f;


		[Range(0.0, 1.0)]
		public float DistortionMin { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float DistortionMax { get; set; } = 0.4f;


		[JsonPropertyName("AmbientTemperature")]
		[Range(0.0, 1.0)]
		public float AmbientTemp { get; set; } = 0.15f;


		[JsonPropertyName("BackgroundTemperature")]
		[Range(0.0, 1.0)]
		public float BackgroundTemp { get; set; } = 0.05f;


		[Range(0.0, 10.0)]
		public float AlbedoColorFactor { get; set; } = 0.5f;


		[Range(0.0, 10.0)]
		public float AmbientColorFactor { get; set; } = 5f;


		public float OcclusionHeat { get; set; } = 0.5f;


		public float BodyOcclusionHeat { get; set; } = 2.5f;


		[Range(0.0, 1.0)]
		public float ScreenIntensity { get; set; } = 0.2f;


		[Range(0.0, 1.0)]
		public float OffAngleFade { get; set; } = 0.95f;


		[Range(0.0, 1.0)]
		public float Noise { get; set; } = 0.1f;


		[JsonPropertyName("MinShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMinShadowEnemies { get; set; } = 0.2f;


		[JsonPropertyName("MaxShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMaxShadowEnemies { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionSignalSpeedShadowEnemies { get; set; } = 1f;


		public float ShadowEnemyFresnel { get; set; } = 10f;


		[Range(0.0, 1.0)]
		public float ShadowEnemyHeat { get; set; } = 0.1f;


		public EOSColor ReticuleColorA { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorB { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorC { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		[Range(0.0, 20.0)]
		public float SightDirt { get; set; }

		public bool LitGlass { get; set; }

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


		public Vec4 AxisX { get; set; } = new Vec4();


		public Vec4 AxisY { get; set; } = new Vec4();


		public Vec4 AxisZ { get; set; } = new Vec4();


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


		[JsonPropertyName("Distance1")]
		[Range(0.0, 100.0)]
		public float ProjDist1 { get; set; } = 100f;


		[JsonPropertyName("Distance2")]
		[Range(0.0, 100.0)]
		public float ProjDist2 { get; set; } = 66f;


		[JsonPropertyName("Distance3")]
		[Range(0.0, 100.0)]
		public float ProjDist3 { get; set; } = 33f;


		[JsonPropertyName("Size1")]
		[Range(0.0, 3.0)]
		public float ProjSize1 { get; set; } = 1f;


		[JsonPropertyName("Size2")]
		[Range(0.0, 3.0)]
		public float ProjSize2 { get; set; } = 1f;


		[JsonPropertyName("Size3")]
		[Range(0.0, 3.0)]
		public float ProjSize3 { get; set; } = 1f;


		[JsonPropertyName("Zeroing")]
		[Range(-1.0, 1.0)]
		public float ZeroOffset { get; set; }
	}
}
namespace LEGACY.LegacyOverride.ResourceStations
{
	public sealed class ToolStation : ResourceStation
	{
		public override string ItemKey => $"Tool_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.ToolStation");
			Interact.InteractionMessage = ((block == null) ? "TOOL STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			PlayerAmmoStorage ammoStorage = PlayerBackpackManager.GetBackpack(player.Owner).AmmoStorage;
			float num = Math.Max(0f, Math.Min(def.SupplyUplimit.Tool - ammoStorage.ClassAmmo.RelInPack, def.SupplyEfficiency.Tool));
			player.GiveAmmoRel(player, 0f, 0f, num);
			player.Sound.Post(EVENTS.AMMOPACK_APPLY, true);
		}

		public static ToolStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != StationType.TOOL)
			{
				LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.ToolStation);
			return new ToolStation(def, gO);
		}

		private ToolStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static ToolStation()
		{
		}
	}
	public sealed class MediStation : ResourceStation
	{
		public const float VANILLA_MAX_HEALTH = 25f;

		public override string ItemKey => $"Health_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.MediStation");
			Interact.InteractionMessage = ((block == null) ? "HEALTH STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			float health = ((Dam_SyncedDamageBase)player.Damage).Health;
			float num = def.SupplyUplimit.Medi * 25f;
			if (!(health >= num))
			{
				player.GiveHealth(player, Math.Min(def.SupplyEfficiency.Medi, (num - health) / 25f));
				player.Sound.Post(EVENTS.MEDPACK_APPLY, true);
			}
		}

		public static MediStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != 0)
			{
				LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.MediStation);
			return new MediStation(def, gO);
		}

		private MediStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static MediStation()
		{
		}
	}
	public abstract class ResourceStation
	{
		public virtual GameObject GameObject { get; protected set; }

		public virtual GameObject InteractGO
		{
			get
			{
				GameObject gameObject = GameObject;
				return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(3)).gameObject : null) ?? null;
			}
		}

		public virtual GameObject StationMarkerGO
		{
			get
			{
				GameObject gameObject = GameObject;
				return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(2)).gameObject : null) ?? null;
			}
		}

		public virtual Interact_Timed Interact { get; protected set; }

		public virtual ResourceStationDefinition def { get; protected set; }

		public StateReplicator<RSStateStruct> StateReplicator { get; protected set; }

		public LG_GenericTerminalItem TerminalItem { get; protected set; }

		public AIG_CourseNode SpawnNode
		{
			get
			{
				return TerminalItem.SpawnNode;
			}
			set
			{
				TerminalItem.SpawnNode = value;
			}
		}

		protected int SerialNumber { get; private set; }

		public virtual string ItemKey => $"Resource_Station_{SerialNumber}";

		public virtual void Destroy()
		{
			Object.Destroy((Object)(object)GameObject);
			Interact = null;
			def = null;
		}

		protected virtual void OnTriggerInteractionAction(PlayerAgent player)
		{
		}

		protected virtual void OnInteractionSelected(PlayerAgent agent, bool selected)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (selected)
			{
				string text = Text.Format(827u, (Object[])(object)new Object[1] { Object.op_Implicit(InputMapper.GetBindingName(((Interact_Base)Interact).InputAction)) });
				TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.OnAdditionalInteractionText.ResourceStation");
				string text2 = ((block == null) ? "TO REPLENISH" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
				GuiManager.InteractionLayer.SetInteractPrompt(Interact.InteractionMessage, text + text2, (ePUIMessageStyle)0);
			}
		}

		protected virtual void SetupInteraction()
		{
			Interact.InteractDuration = def.InteractDuration;
			Interact_Timed interact = Interact;
			interact.OnInteractionSelected += Action<PlayerAgent, bool>.op_Implicit((Action<PlayerAgent, bool>)OnInteractionSelected);
			Interact_Timed interact2 = Interact;
			interact2.OnInteractionTriggered += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)OnTriggerInteractionAction);
		}

		protected virtual void SetupTerminalItem()
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = default(LG_Zone);
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex, ref val) || (Object)(object)val == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: Cannot find spawn node!");
				return;
			}
			if (def.AreaIndex < 0 || def.AreaIndex >= val.m_areas.Count)
			{
				LegacyLogger.Error("ResourceStation: Cannot find spawn node - Area index is invalid!");
				return;
			}
			TerminalItem.Setup(ItemKey, val.m_areas[def.AreaIndex].m_courseNode);
			if (SpawnNode != null)
			{
				TerminalItem.FloorItemLocation = SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
			}
			TerminalItem.FloorItemStatus = (eFloorInventoryObjectStatus)0;
		}

		protected virtual void OnStateChanged(RSStateStruct oldState, RSStateStruct newState, bool isRecall)
		{
		}

		protected virtual void SetupReplicator()
		{
		}

		protected ResourceStation(ResourceStationDefinition def, GameObject GO)
		{
			//IL_0025: 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)
			this.def = def;
			GameObject = GO;
			GameObject.transform.SetPositionAndRotation(def.Position.ToVector3(), def.Rotation.ToQuaternion());
			Interact = InteractGO.GetComponent<Interact_Timed>();
			SerialNumber = SerialGenerator.GetUniqueSerialNo();
			if ((Object)(object)Interact == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: Interact Comp not found!");
			}
			else
			{
				SetupInteraction();
			}
			TerminalItem = GO.GetComponent<LG_GenericTerminalItem>();
			if ((Object)(object)TerminalItem == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: TerminalItem not found!");
			}
			else
			{
				SetupTerminalItem();
			}
			SetupReplicator();
		}

		static ResourceStation()
		{
		}
	}
	public sealed class AmmoStation : ResourceStation
	{
		public override string ItemKey => $"Ammunition_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.AmmoStation");
			Interact.InteractionMessage = ((block == null) ? "AMMUNITION STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			PlayerAmmoStorage ammoStorage = PlayerBackpackManager.GetBackpack(player.Owner).AmmoStorage;
			float num = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoStandard - 1f * (float)ammoStorage.StandardAmmo.BulletClipSize / (float)ammoStorage.StandardAmmo.BulletsMaxCap - ammoStorage.StandardAmmo.RelInPack, def.SupplyEfficiency.AmmoStandard));
			float num2 = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoSpecial - 1f * (float)ammoStorage.SpecialAmmo.BulletClipSize / (float)ammoStorage.SpecialAmmo.BulletsMaxCap - ammoStorage.SpecialAmmo.RelInPack, def.SupplyEfficiency.AmmoSpecial));
			player.GiveAmmoRel(player, num, num2, 0f);
			player.Sound.Post(EVENTS.AMMOPACK_APPLY, true);
		}

		public static AmmoStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != StationType.AMMO)
			{
				LegacyLogger.Error($"Trying to instantiate AmmoStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.AmmoStation);
			return new AmmoStation(def, gO);
		}

		private AmmoStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static AmmoStation()
		{
		}
	}
	public enum StationType
	{
		MEDI,
		AMMO,
		TOOL
	}
	public class SupplyUplimit
	{
		public float Medi { get; set; } = 0.6f;


		public float AmmoStandard { get; set; } = 1f;


		public float AmmoSpecial { get; set; } = 1f;


		public float Tool { get; set; }
	}
	public class SupplyEfficiency
	{
		public float Medi { get; set; } = 0.2f;


		public float AmmoStandard { get; set; } = 0.15f;


		public float AmmoSpecial { get; set; } = 0.15f;


		public float Tool { get; set; }
	}
	public class ResourceStationDefinition : GlobalZoneIndex
	{
		public int AreaIndex { get; set; }

		public string WorldEventObjectFilter { get; set; } = string.Empty;


		public StationType StationType { get; set; } = StationType.AMMO;


		public Vec3 Position { get; set; } = new Vec3();


		public Vec3 Rotation { get; set; } = new Vec3();


		public float InteractDuration { get; set; } = 2.5f;


		public SupplyEfficiency SupplyEfficiency { get; set; } = new SupplyEfficiency();


		public SupplyUplimit SupplyUplimit { get; set; } = new SupplyUplimit();


		public int AllowedUseTimePerCooldown { get; set; } = 3;


		public float CooldownTime { get; set; } = 5f;

	}
	public class ResourceStationManager : GenericExpeditionDefinitionManager<ResourceStationDefinition>
	{
		public static ResourceStationManager Current { get; private set; }

		protected override string DEFINITION_NAME => "ResourceStation";

		private Dictionary<string, ResourceStation> Stations { get; } = new Dictionary<string, ResourceStation>();


		private void Build(ResourceStationDefinition def)
		{
			if (Stations.ContainsKey(def.WorldEventObjectFilter))
			{
				LegacyLogger.Error("ResourceStationManager: WorldEventObjectFilter '" + def.WorldEventObjectFilter + "' is already used");
				return;
			}
			ResourceStation resourceStation = null;
			switch (def.StationType)
			{
			case StationType.MEDI:
				resourceStation = MediStation.Instantiate(def);
				break;
			case StationType.AMMO:
				resourceStation = AmmoStation.Instantiate(def);
				break;
			case StationType.TOOL:
				resourceStation = ToolStation.Instantiate(def);
				break;
			default:
				LegacyLogger.Error($"ResourceStation {def.StationType} is unimplemented");
				return;
			}
			if (resourceStation != null)
			{
				Stations[def.WorldEventObjectFilter] = resourceStation;
				LegacyLogger.Debug("ResourceStation '" + def.WorldEventObjectFilter + "' instantiated");
			}
		}

		private void BuildStations()
		{
			if (base.definitions.TryGetValue(base.CurrentMainLevelLayout, out var value))
			{
				value.Definitions.ForEach(Build);
			}
		}

		private void Clear()
		{
			foreach (ResourceStation value in Stations.Values)
			{
				value.Destroy();
			}
			Stations.Clear();
		}

		private ResourceStationManager()
		{
			LevelAPI.OnBuildStart += delegate
			{
				Clear();
			};
			LevelAPI.OnLevelCleanup += Clear;
			LevelAPI.OnBuildDone += BuildStations;
		}

		static ResourceStationManager()
		{
			Current = new ResourceStationManager();
		}
	}
	public struct RSStateStruct
	{
		public int RemainingUseTime;

		public float CurrentCooldownTime;

		public bool Enabled;

		public RSStateStruct()
		{
			RemainingUseTime = 0;
			CurrentCooldownTime = 0f;
			Enabled = false;
		}
	}
	public class RSTimer : MonoBehaviour
	{
		private float endTime;

		private bool hasOnGoingTimer;

		private Action OnTimerEnd;

		public float RemainingTime
		{
			get
			{
				if (!hasOnGoingTimer)
				{
					return 0f;
				}
				return Math.Max(endTime - Clock.Time, 0f);
			}
		}

		private static List<GameObject> TimerGOs { get; }

		private void Update()
		{
			//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 && hasOnGoingTimer && !(Clock.Time < endTime))
			{
				endTime = 0f;
				hasOnGoingTimer = false;
				Action onTimerEnd = OnTimerEnd;
				OnTimerEnd = null;
				onTimerEnd?.Invoke();
			}
		}

		public void StartTimer(float time, Action onEnd = null)
		{
			if (time <= 0f)
			{
				LegacyLogger.Error("StartTimer: time is not positive!");
				return;
			}
			if (hasOnGoingTimer)
			{
				LegacyLogger.Error("StartTimer: this timer is yet ended!");
				return;
			}
			endTime = Clock.Time + time;
			OnTimerEnd = onEnd;
			hasOnGoingTimer = true;
		}

		private void OnDestroy()
		{
			endTime = 0f;
			hasOnGoingTimer = false;
			OnTimerEnd = null;
		}

		public static RSTimer Instantiate()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			RSTimer result = val.AddComponent<RSTimer>();
			TimerGOs.Add(val);
			return result;
		}

		public static void DestroyAll()
		{
			TimerGOs.ForEach((Action<GameObject>)Object.Destroy);
			TimerGOs.Clear();
		}

		private RSTimer()
		{
		}

		static RSTimer()
		{
			TimerGOs = new List<GameObject>();
			ClassInjector.RegisterTypeInIl2Cpp<RSTimer>();
			LevelAPI.OnBuildStart += DestroyAll;
			LevelAPI.OnLevelCleanup += DestroyAll;
		}
	}
}
namespace LEGACY.LegacyOverride.EnemyTargeting
{
	internal class EnemyTargetingPrioritizer : MonoBehaviour
	{
		public const float UPDATE_INTERVAL = 3f;

		private float nextUpdateTime = float.NaN;

		internal EnemyAgent enemy;

		private Dam_EnemyDamageBase damage
		{
			get
			{
				EnemyAgent obj = enemy;
				if (obj == null)
				{
					return null;
				}
				return obj.Damage;
			}
		}

		private AgentTarget target
		{
			get
			{
				EnemyAgent obj = enemy;
				if (obj == null)
				{
					return null;
				}
				return ((AgentAI)obj.AI).Target;
			}
		}

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameStateManager.CurrentStateName != 10 || !SNet.IsMaster)
			{
				return;
			}
			if (float.IsNaN(nextUpdateTime))
			{
				nextUpdateTime = Clock.Time + 3f;
			}
			else if (!(Clock.Time < nextUpdateTime) && !((Object)(object)enemy == (Object)null))
			{
				nextUpdateTime = Clock.Time + 3f;
				if ((int)((AgentAI)enemy.AI).Mode == 1 && target != null && !(((Il2CppObjectBase)target.m_agent.CourseNode).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode).Pointer) && PlayerManager.PlayerAgentsInLevel.Count > 1 && ((Agent)PlayerManager.PlayerAgentsInLevel[0]).CourseNode.m_dimension.DimensionIndex == ((Agent)enemy).CourseNode.m_dimension.DimensionIndex)
				{
					TryPrioritizeCloserTarget();
				}
			}
		}

		internal void TryPrioritizeCloserTarget()
		{
			_ = target;
			Agent val = null;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (((Agent)current).Alive && ((Il2CppObjectBase)((Agent)current).CourseNode).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode).Pointer)
				{
					val = (Agent)(object)current;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
				while (enumerator.MoveNext())
				{
					PlayerAgent current2 = enumerator.Current;
					if (((Agent)current2).Alive && ((Il2CppObjectBase)((Agent)current2).CourseNode.m_zone).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode.m_zone).Pointer)
					{
						val = (Agent)(object)current2;
						break;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				((AgentAI)enemy.AI).SetTarget(val);
			}
		}

		private void OnDestroy()
		{
			enemy = null;
		}

		static EnemyTargetingPrioritizer()
		{
			ClassInjector.RegisterTypeInIl2Cpp<EnemyTargetingPrioritizer>();
		}
	}
}
namespace LEGACY.LegacyOverride.ElevatorCargo
{
	internal class ElevatorCargoOverrideManager
	{
		public static readonly ElevatorCargoOverrideManager Current;

		private Dictionary<uint, LevelElevatorCargo> elevatorCargos = new Dictionary<uint, LevelElevatorCargo>();

		private LiveEditListener liveEditListener;

		private static readonly string CONFIG_PATH;

		private void AddOverride(LevelElevatorCargo _override)
		{
			if (_override != null)
			{
				if (elevatorCargos.ContainsKey(_override.MainLevelLayout))
				{
					LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout);
					elevatorCargos[_override.MainLevelLayout] = _override;
				}
				else
				{
					elevatorCargos.Add(_override.MainLevelLayout, _override);
				}
			}
		}

		public void Init()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if (!Directory.Exists(CONFIG_PATH))
			{
				Directory.CreateDirectory(CONFIG_PATH);
				StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json"));
				streamWriter.WriteLine(Json.Serialize(new LevelElevatorCargo()));
				streamWriter.Flush();
				streamWriter.Close();
				return;
			}
			foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories))
			{
				Json.Load<LevelElevatorCargo>(item, out var config);
				AddOverride(config);
			}
			liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true);
			liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged);
		}

		private void FileChanged(LiveEditEventArgs e)
		{
			LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath);
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				LevelElevatorCargo @override = Json.Deserialize<LevelElevatorCargo>(content);
				AddOverride(@override);
			});
		}

		internal LevelElevatorCargo GetLevelElevatorCargoItems(uint MainLevelLayout)
		{
			if (!elevatorCargos.ContainsKey(MainLevelLayout))
			{
				return null;
			}
			return elevatorCargos[MainLevelLayout];
		}

		private ElevatorCargoOverrideManager()
		{
		}

		static ElevatorCargoOverrideManager()
		{
			CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "ElevatorCargoOverride");
			Current = new ElevatorCargoOverrideManager();
		}
	}
	public enum ItemType
	{
		Consumable,
		BigPickup
	}
	public class ElevatorCargoItem
	{
		public uint ItemID { get; set; }

		public ItemType ItemType { get; set; }
	}
	public class LevelElevatorCargo
	{
		public uint MainLevelLayout { get; set; }

		public bool ForceDisable { get; set; }

		public List<ElevatorCargoItem> ElevatorCargoItems { get; set; } = new List<ElevatorCargoItem>();

	}
}
namespace LEGACY.LegacyOverride.Patches
{
	[HarmonyPatch]
	internal static class DynamicVisualAdjustment
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(FirstPersonItemHolder), "SetWieldedItem")]
		private static void Post_SetWieldedItem(FirstPersonItemHolder __instance, ItemEquippable item)
		{
			TSAManager.Current.OnPlayerItemWielded(__instance, item);
			TSAManager.Current.SetPuzzleVisualsIntensity(1f);
			TSAManager.Current.SetCurrentThermalSightSettings(1f);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FPIS_Aim), "Update")]
		private static void Post_Aim_Update(FPIS_Aim __instance)
		{
			if (!((Object)(object)((FPItemState)__instance).Holder.WieldedItem == (Object)null))
			{
				float num = 1f - FirstPersonItemHolder.m_transitionDelta;
				if (!TSAManager.Current.IsGearWithThermal(TSAManager.Current.CurrentGearPID))
				{
					num = Math.Max(0.05f, num);
				}
				else
				{
					TSAManager.Current.SetCurrentThermalSightSettings(num);
				}
				TSAManager.Current.SetPuzzleVisualsIntensity(num);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CP_Bioscan_Core), "Setup")]
		private static void Post_CaptureBioscanVisual(CP_Bioscan_Core __instance)
		{
			TSAManager.Current.RegisterPuzzleVisual(__instance);
		}
	}
	[HarmonyPatch]
	internal static class ExpeditionSuccessPage
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageExpeditionSuccess), "OnEnable")]
		private static void Post_CM_PageExpeditionSuccess_OnEnable(CM_PageExpeditionSuccess __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				SuccessPageCustomization currentCustomization = SuccessPageCustomizationManager.Current.CurrentCustomization;
				if (currentCustomization != null)
				{
					((TMP_Text)__instance.m_header).SetText(LocalizedText.op_Implicit(currentCustomization.PageHeader), true);
					__instance.m_overrideSuccessMusic = currentCustomization.OverrideSuccessMusic;
					LegacyLogger.Warning("Post_CM_PageExpeditionSuccess_OnEnable: " + ((Object)currentCustomization.PageHeader).ToString());
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class LevelSpawnFogBeacon_BugFix
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HeavyFogRepellerGlobalState), "AttemptInteract")]
		private static void Post_HeavyFogRepellerGlobalState_AttemptInteract(HeavyFogRepellerGlobalState __instance)
		{
			LevelSpawnedFogBeaconSettings lSFBDef = LevelSpawnedFogBeaconManager.Current.GetLSFBDef(__instance);
			if (lSFBDef != null)
			{
				__instance.m_repellerSphere.Range = lSFBDef.Range;
			}
		}
	}
	[HarmonyPatch]
	internal class PrioritizeEnemyTargeting
	{
		private static bool s_patch = true;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyCourseNavigation), "UpdateTracking")]
		private static void UpdateTracking(EnemyCourseNavigation __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			if (!s_patch)
			{
				return;
			}
			int count = PlayerManager.PlayerAgentsInLevel.Count;
			if (!SNet.IsMaster || count <= 1)
			{
				return;
			}
			EnemyAgent owner = __instance.m_owner;
			if ((int)((StateMachine<ES_Base>)(object)owner.Locomotion).m_currentState.m_stateEnum == 14 || ((Il2CppObjectBase)__instance.m_targetRef.m_agent.CourseNode).Pointer == ((Il2CppObjectBase)((Agent)owner).CourseNode).Pointer)
			{
				return;
			}
			PlayerAgent val = null;
			int num = Random.RandomRangeInt(0, count);
			for (int i = 0; i < count; i++)
			{
				PlayerAgent val2 = PlayerManager.PlayerAgentsInLevel[num];
				if (((Agent)val2).Alive && ((Il2CppObjectBase)((Agent)val2).CourseNode).Pointer == ((Il2CppObjectBase)((Agent)owner).CourseNode).Pointer)
				{
					val = val2;
					break;
				}
				num = (num + 1) % count;
			}
			if ((Object)(object)val != (Object)null)
			{
				s_patch = false;
				((AgentAI)owner.AI).SetTarget((Agent)(object)val);
				s_patch = true;
			}
		}
	}
	[HarmonyPatch]
	internal class RundownSelectionCustomization
	{
		private static uint r1TitleID;

		private static uint r2TitleID;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageRundown_New), "Setup")]
		private static void Post_CM_PageRundown_New(CM_PageRundown_New __instance)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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)
			GameSetupDataBlock block = GameDataBlockBase<GameSetupDataBlock>.GetBlock(1u);
			if (block.RundownIdsToLoad.Count > 1 && block.RundownIdsToLoad.Count == 2)
			{
				((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[0] = new Vector3(-320f, 75f, 0f);
				((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[1] = new Vector3(320f, 0f, 0f);
				Vector3 zero = Vector3.zero;
				for (int i = block.RundownIdsToLoad.Count; i < ((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions).Count; i++)
				{
					zero = ((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[i];
					((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[i] = new Vector3(zero.x, -10000f, zero.z);
				}
				zero = __instance.m_textRundownHeaderTop.transform.position;
				__instance.m_textRundownHeaderTop.transform.position = new Vector3(zero.x, -350f, zero.z);
			}
		}

		private static void SetSelectionScale(CM_PageRundown_New p)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_013b: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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)
			GameSetupDataBlock block = GameDataBlockBase<GameSetupDataBlock>.GetBlock(1u);
			if (block.RundownIdsToLoad.Count > 1 && block.RundownIdsToLoad.Count == 2)
			{
				CM_RundownSelection obj = p.m_rundownSelections[0];
				CM_RundownSelection val = p.m_rundownSelections[1];
				((Component)obj).transform.localScale = new Vector3(2f, 2f, 2f) * 1.625f;
				((Component)val).transform.localScale = new Vector3(1.25f, 1.25f, 1.25f) * 1.5f;
				Transform transform = obj.m_rundownText.transform;
				Quaternion localRotation = (val.m_rundownText.transform.localRotation = Quaternion.AngleAxis(45f, Vector3.right));
				transform.localRotation = localRotation;
				obj.m_rundownText.transform.localPosition = Vector3.up * 60f + Vector3.right * 20f;
				val.m_rundownText.transform.localPosition = Vector3.up * 85f + Vector3.left * 25f;
				Transform transform2 = ((Component)obj).transform;
				localRotation = (((Component)val).transform.localRotation = Quaternion.AngleAxis(-45f, Vector3.right));
				transform2.localRotation = localRotation;
				((TMP_Text)obj.m_rundownText).text = ((r1TitleID != 0) ? Text.Get(r1TitleID) : "<size=50%><color=#00ae9d>[ LEGACY ]</color></size>");
				((TMP_Text)val.m_rundownText).text = ((r2TitleID != 0) ? Text.Get(r2TitleID) : "<size=80%><color=#009ad6>[ L-OMNI ]</color></size>");
				DestroyAltText(obj);
				DestroyAltText(val);
			}
			static void DestroyAltText(CM_RundownSelection s)
			{
				if ((Object)(object)s.m_altText != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)s.m_altText).gameObject);
					s.m_altText = null;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageRundown_New), "UpdateRundownSelectionButton")]
		private static void Post_UpdateRundownSelectionButton(CM_PageRundown_New __instance)
		{
			InitTitle();
			SetSelectionScale(__instance);
		}

		private static void InitTitle()
		{
			if (r1TitleID == 0)
			{
				TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("LEGACY_Title");
				if (block != null)
				{
					r1TitleID = ((GameDataBlockBase<TextDataBlock>)(object)block).persistentID;
				}
				block = GameDataBlockBase<TextDataBlock>.GetBlock("LEGACY-Omni_Title");
				if (block != nul

plugins/Digital World/extra/Oxygen/Oxygen.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using AK;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using GameEvent;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using MTFO.Managers;
using Microsoft.CodeAnalysis;
using Oxygen.Components;
using Oxygen.Config;
using Oxygen.Utils;
using Oxygen.Utils.PartialData;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Oxygen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Oxygen")]
[assembly: AssemblyTitle("Oxygen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Oxygen
{
	[BepInPlugin("Inas.Oxygen", "Oxygen", "1.3.2")]
	[BepInProcess("GTFO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__OnBuildDone;

			public static Action <1>__OnLevelCleanup;

			public static Action <2>__Setup;

			public static Action <3>__OnLevelCleanup;

			public static Action <4>__OnBuildStart;

			public static Action <5>__OnLevelCleanup;

			public static LiveEditEventHandler <6>__Listener_FileChanged1;
		}

		public const string MODNAME = "Oxygen";

		public const string AUTHOR = "Inas";

		public const string GUID = "Inas.Oxygen";

		public const string VERSION = "1.3.2";

		public static readonly string OXYGEN_CONFIG_PATH = Path.Combine(ConfigManager.CustomPath, "Oxygen");

		public static Dictionary<uint, OxygenBlock> lookup = new Dictionary<uint, OxygenBlock>();

		private static LiveEditListener listener = null;

		public override void Load()
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			if (!Directory.Exists(OXYGEN_CONFIG_PATH))
			{
				Directory.CreateDirectory(OXYGEN_CONFIG_PATH);
				StreamWriter streamWriter = File.CreateText(Path.Combine(OXYGEN_CONFIG_PATH, "Template.json"));
				streamWriter.WriteLine(ConfigManager.Serialize(new OxygenConfig()));
				streamWriter.Flush();
				streamWriter.Close();
			}
			ClassInjector.RegisterTypeInIl2Cpp<AirManager>();
			LevelAPI.OnBuildDone += AirManager.OnBuildDone;
			LevelAPI.OnLevelCleanup += AirManager.OnLevelCleanup;
			ClassInjector.RegisterTypeInIl2Cpp<AirBar>();
			LevelAPI.OnBuildStart += AirBar.Setup;
			LevelAPI.OnLevelCleanup += AirBar.OnLevelCleanup;
			ClassInjector.RegisterTypeInIl2Cpp<AirPlane>();
			LevelAPI.OnBuildStart += AirPlane.OnBuildStart;
			LevelAPI.OnLevelCleanup += AirPlane.OnLevelCleanup;
			new Harmony("Inas.Oxygen").PatchAll();
			foreach (string item in Directory.EnumerateFiles(OXYGEN_CONFIG_PATH, "*.json", SearchOption.AllDirectories))
			{
				ConfigManager.Load<OxygenConfig>(item, out var config);
				foreach (OxygenBlock block in config.Blocks)
				{
					foreach (uint fogSetting in block.FogSettings)
					{
						if (!lookup.ContainsKey(fogSetting))
						{
							lookup.Add(fogSetting, block);
						}
					}
				}
			}
			listener = LiveEdit.CreateListener(OXYGEN_CONFIG_PATH, "*.json", true);
			LiveEditListener obj = listener;
			object obj2 = <>O.<6>__Listener_FileChanged1;
			if (obj2 == null)
			{
				LiveEditEventHandler val = Listener_FileChanged1;
				<>O.<6>__Listener_FileChanged1 = val;
				obj2 = (object)val;
			}
			obj.FileChanged += (LiveEditEventHandler)obj2;
		}

		private static void Listener_FileChanged1(LiveEditEventArgs e)
		{
			Log.Warning("LiveEdit File Changed: " + e.FullPath + ".");
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				foreach (OxygenBlock block in ConfigManager.Deserialize<OxygenConfig>(content).Blocks)
				{
					foreach (uint fogSetting in block.FogSettings)
					{
						if (lookup.ContainsKey(fogSetting))
						{
							lookup.Remove(fogSetting);
						}
						lookup.Add(fogSetting, block);
						Log.Warning($"Replaced OxygenConfig for FogSetting: {fogSetting}.");
					}
				}
				if (GameStateManager.IsInExpedition)
				{
					AirManager.Current.UpdateAirConfig(AirManager.Current.FogSetting(), LiveEditForceUpdate: true);
				}
			});
		}
	}
}
namespace Oxygen.Utils
{
	internal static class Extension
	{
		public static T Instantiate<T>(this GameObject gameObject, string name) where T : Component
		{
			GameObject obj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false);
			((Object)obj).name = name;
			return obj.GetComponent<T>();
		}
	}
	internal class LocalizedTextConverter : JsonConverter<LocalizedText>
	{
		public override bool HandleNull => false;

		public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			//IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			switch (reader.TokenType)
			{
			case JsonTokenType.String:
			{
				string @string = reader.GetString();
				return new LocalizedText
				{
					Id = 0u,
					UntranslatedText = @string
				};
			}
			case JsonTokenType.Number:
				return new LocalizedText
				{
					Id = reader.GetUInt32(),
					UntranslatedText = null
				};
			default:
				throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!");
			}
		}

		public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options)
		{
			JsonSerializer.Serialize<LocalizedText>(writer, value, options);
		}
	}
	internal static class Log
	{
		private static ManualLogSource source;

		static Log()
		{
			source = Logger.CreateLogSource("Oxygen");
		}

		public static void Debug(object msg)
		{
			source.LogDebug(msg);
		}

		public static void Error(object msg)
		{
			source.LogError(msg);
		}

		public static void Fatal(object msg)
		{
			source.LogFatal(msg);
		}

		public static void Info(object msg)
		{
			source.LogInfo(msg);
		}

		public static void Message(object msg)
		{
			source.LogMessage(msg);
		}

		public static void Warning(object msg)
		{
			source.LogWarning(msg);
		}
	}
}
namespace Oxygen.Utils.PartialData
{
	public static class MTFOPartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		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;
			if (!((BaseChainloader<BasePlugin>)(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 == "LocalizedTextConverter");
				if ((object)type2 == null)
				{
					throw new Exception("Unable to Find LocalizedTextConverter Class");
				}
				Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class");
				PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo? property3 = obj2.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(type2);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				Log.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{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<BasePlugin>)(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)
			{
				Log.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}");
			}
		}
	}
}
namespace Oxygen.Patches
{
	[HarmonyPatch]
	internal class Patches_Dam_PlayerDamageLocal
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveNoAirDamage")]
		public static bool Pre_ReceiveNoAirDamage(Dam_PlayerDamageLocal __instance, pMiniDamageData data)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
			((Dam_PlayerDamageBase)__instance).m_nextRegen = Clock.Time + ((Dam_PlayerDamageBase)__instance).Owner.PlayerData.healthRegenStartDelayAfterDamage;
			if (((Agent)((Dam_PlayerDamageBase)__instance).Owner).IsLocallyOwned)
			{
				DramaManager.CurrentState.OnLocalDamage(num);
				GameEventManager.PostEvent((eGameEvent)13, ((Dam_PlayerDamageBase)__instance).Owner, num, "", (Dictionary<string, string>)null);
			}
			else
			{
				DramaManager.CurrentState.OnTeammatesDamage(num);
			}
			if (((Dam_PlayerDamageBase)__instance).IgnoreAllDamage)
			{
				return false;
			}
			if (SNet.IsMaster && !((Dam_SyncedDamageBase)__instance).RegisterDamage(num))
			{
				((Dam_SyncedDamageBase)__instance).SendSetHealth(((Dam_SyncedDamageBase)__instance).Health);
			}
			__instance.Hitreact(((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax), Vector3.zero, true, false, false);
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveBulletDamage")]
		public static void Post_ReceiveBulletDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveMeleeDamage")]
		public static void Post_ReceiveMeleeDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveFireDamage")]
		public static void Post_ReceiveFireDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveShooterProjectileDamage")]
		public static void Post_ReceiveShooterProjectileDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveTentacleAttackDamage")]
		public static void Post_ReceiveTentacleAttackDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceivePushDamage")]
		public static void Post_ReceivePushDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetDead")]
		public static void Post_ReceiveSetDead()
		{
			AirManager.Current.ResetHealthToRegen();
		}
	}
	[HarmonyPatch(typeof(EnvironmentStateManager), "UpdateFog")]
	internal class EnvironmentStateManager_UpdateFog
	{
		public static void Prefix(EnvironmentStateManager __instance)
		{
			//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_002a: 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 ((Object)(object)AirManager.Current == (Object)null)
			{
				return;
			}
			FogState val = ((Il2CppArrayBase<FogState>)(object)__instance.m_stateReplicator.State.FogStates)[__instance.m_latestKnownLocalDimensionCreationIndex];
			if (val.FogDataID != 0)
			{
				AirManager.Current.UpdateAirConfig(val.FogDataID);
				if (!AirManager.Current.HasAirConfig())
				{
					AirManager.Current.StopInfectionLoop();
				}
			}
		}
	}
	[HarmonyPatch(typeof(FogRepeller_Sphere), "StartRepelling")]
	internal class FogRepeller_Sphere_StartRepelling
	{
		public static void Postfix(ref FogRepeller_Sphere __instance)
		{
			if (__instance.m_infectionShield != null)
			{
				EffectVolumeManager.UnregisterVolume((EffectVolume)(object)__instance.m_infectionShield);
				((EffectVolume)__instance.m_infectionShield).contents = (eEffectVolumeContents)0;
				EffectVolumeManager.RegisterVolume((EffectVolume)(object)__instance.m_infectionShield);
			}
		}
	}
	[HarmonyPatch(typeof(LocalPlayerAgentSettings), "UpdateBlendTowardsTargetFogSetting")]
	internal class LocalPlayerAgentSettings_UpdateBlendTowardsTargetFogSetting
	{
		public static void Postfix(LocalPlayerAgentSettings __instance, float amount)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!AirManager.Current.HasAirConfig())
			{
				AirPlane.Current.Unregister();
			}
			else
			{
				if (__instance.m_targetFogSettings == null || !SNet.LocalPlayer.HasPlayerAgent)
				{
					return;
				}
				PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
				if ((Object)(object)localPlayerAgent.FPSCamera == (Object)null)
				{
					return;
				}
				AirPlane current = AirPlane.Current;
				if (!((Object)(object)current == (Object)null) && RundownManager.ExpeditionIsStarted)
				{
					float num = 0f;
					Dimension val = default(Dimension);
					if (Dimension.GetDimension(((Agent)localPlayerAgent).DimensionIndex, ref val))
					{
						num = val.GroundY;
					}
					PreLitVolume prelitVolume = localPlayerAgent.FPSCamera.PrelitVolume;
					((EffectVolume)current.airPlane).invert = (double)prelitVolume.m_densityHeightMaxBoost > (double)prelitVolume.m_fogDensity;
					((EffectVolume)current.airPlane).contents = (eEffectVolumeContents)1;
					((EffectVolume)current.airPlane).modification = (eEffectVolumeModification)0;
					((EffectVolume)current.airPlane).modificationScale = AirManager.Current.AirLoss();
					current.airPlane.lowestAltitude = prelitVolume.m_densityHeightAltitude + num;
					current.airPlane.highestAltitude = prelitVolume.m_densityHeightAltitude + prelitVolume.m_densityHeightRange + num;
					AirPlane.Current.Register();
				}
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_PlayerAgent
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerAgent), "ReceiveModification")]
		public static void ReceiveModification(PlayerAgent __instance, ref EV_ModificationData data)
		{
			if (AirManager.Current.HasAirConfig())
			{
				if ((double)data.health != 0.0)
				{
					AirManager.Current.RemoveAir(data.health);
				}
				else
				{
					AirManager.Current.AddAir();
				}
				data.health = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		[HarmonyPatch(typeof(PlayerAgent), "Setup")]
		internal static void Post_Setup(PlayerAgent __instance)
		{
			if (((Agent)__instance).IsLocallyOwned)
			{
				AirManager.Setup(__instance);
			}
		}
	}
}
namespace Oxygen.Config
{
	public class ConfigManager
	{
		private static readonly JsonSerializerOptions s_SerializerOptions;

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, s_SerializerOptions);
		}

		public static string Serialize<T>(T value)
		{
			return JsonSerializer.Serialize(value, s_SerializerOptions);
		}

		static ConfigManager()
		{
			s_SerializerOptions = new JsonSerializerOptions
			{
				AllowTrailingCommas = true,
				ReadCommentHandling = JsonCommentHandling.Skip,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true
			};
			s_SerializerOptions.Converters.Add(new JsonStringEnumConverter());
			if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized)
			{
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
				Log.Message("PartialData Support Found!");
			}
			else
			{
				s_SerializerOptions.Converters.Add(new LocalizedTextConverter());
			}
		}

		public static void Load<T>(string file, out T config) where T : new()
		{
			if (file.Length < ".json".Length)
			{
				config = default(T);
				return;
			}
			if (file.Substring(file.Length - ".json".Length) != ".json")
			{
				file += ".json";
			}
			file = File.ReadAllText(Path.Combine(ConfigManager.CustomPath, "Oxygen", file));
			config = Deserialize<T>(file);
		}
	}
	public class AirText
	{
		public float x { get; set; }

		public float y { get; set; }

		public LocalizedText Text { get; set; }
	}
	public class OxygenConfig
	{
		public List<OxygenBlock> Blocks { get; set; } = new List<OxygenBlock>
		{
			new OxygenBlock()
		};

	}
	public class OxygenBlock
	{
		public float AirLoss { get; set; }

		public float AirGain { get; set; } = 1f;


		public float DamageTime { get; set; } = 1f;


		public float DamageAmount { get; set; }

		public bool ShatterGlass { get; set; }

		public float ShatterAmount { get; set; }

		public float DamageThreshold { get; set; } = 0.1f;


		public bool AlwaysDisplayAirBar { get; set; }

		public float HealthRegenProportion { get; set; } = 1f;


		public float TimeToStartHealthRegen { get; set; } = 3f;


		public float TimeToCompleteHealthRegen { get; set; } = 5f;


		public AirText AirText { get; set; }

		public List<uint> FogSettings { get; set; } = new List<uint> { 0u };

	}
}
namespace Oxygen.Components
{
	public class AirBar : MonoBehaviour
	{
		public static AirBar Current;

		private TextMeshPro m_airText;

		private TextMeshPro m_airTextLocalization;

		private float m_airTextX;

		private float m_airTextY;

		private float m_airTextZ;

		private RectTransform m_air1;

		private RectTransform m_air2;

		private SpriteRenderer m_airBar1;

		private SpriteRenderer m_airBar2;

		private float m_airWidth = 100f;

		private float m_barHeightMin = 3f;

		private float m_barHeightMax = 9f;

		private Color m_airLow = new Color(0f, 0.5f, 0.5f);

		private Color m_airHigh = new Color(0f, 0.3f, 0.8f);

		public AirBar(IntPtr value)
			: base(value)
		{
		}//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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)


		public static void Setup()
		{
			if ((Object)(object)Current == (Object)null)
			{
				Current = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus).gameObject.AddComponent<AirBar>();
				Current.Init();
			}
		}

		private void Init()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_airText == (Object)null)
			{
				m_airText = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_healthText).gameObject.Instantiate<TextMeshPro>("AirText");
				TextMeshPro airText = m_airText;
				((TMP_Text)airText).fontSize = ((TMP_Text)airText).fontSize / 1.25f;
				m_airText.transform.Translate(0f, -30f, 0f);
			}
			if ((Object)(object)m_airTextLocalization == (Object)null)
			{
				m_airTextLocalization = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_pulseText).gameObject.Instantiate<TextMeshPro>("AirText Localization");
				((Behaviour)m_airTextLocalization).enabled = true;
				m_airTextLocalization.transform.Translate(300f - m_airWidth, -45f, 0f);
				m_airTextX = m_airTextLocalization.transform.position.x;
				m_airTextY = m_airTextLocalization.transform.position.y;
				m_airTextZ = m_airTextLocalization.transform.position.z;
			}
			if ((Object)(object)m_air1 == (Object)null)
			{
				m_air1 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health1).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Right");
				((Component)m_air1).transform.Translate(0f, -30f, 0f);
				SpriteRenderer component = ((Component)((Transform)m_air1).GetChild(0)).GetComponent<SpriteRenderer>();
				component.size = new Vector2(m_airWidth, component.size.y);
				m_airBar1 = ((Component)((Transform)m_air1).GetChild(1)).GetComponent<SpriteRenderer>();
				((Renderer)((Component)((Transform)m_air1).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false;
			}
			if ((Object)(object)m_air2 == (Object)null)
			{
				m_air2 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health2).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Left");
				((Component)m_air2).transform.Translate(0f, 30f, 0f);
				SpriteRenderer component2 = ((Component)((Transform)m_air2).GetChild(0)).GetComponent<SpriteRenderer>();
				component2.size = new Vector2(m_airWidth, component2.size.y);
				m_airBar2 = ((Component)((Transform)m_air2).GetChild(1)).GetComponent<SpriteRenderer>();
				((Renderer)((Component)((Transform)m_air2).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false;
			}
			UpdateAirBar(1f);
			SetVisible(vis: false);
		}

		public void UpdateAirBar(float air)
		{
			SetAirPercentageText(air);
			SetAirBar(m_airBar1, air);
			SetAirBar(m_airBar2, air);
		}

		private void SetAirBar(SpriteRenderer bar, float val)
		{
			//IL_001b: 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_002d: 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)
			bar.size = new Vector2(val * m_airWidth, Mathf.Lerp(m_barHeightMin, m_barHeightMax, val));
			bar.color = Color.Lerp(m_airLow, m_airHigh, val);
		}

		private void SetAirPercentageText(float val)
		{
			//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)
			//IL_0012: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			Color color = Color.Lerp(m_airLow, m_airHigh, val);
			((TMP_Text)m_airText).text = "O<size=75%>2</size>";
			((Graphic)m_airText).color = color;
			((TMP_Text)m_airText).ForceMeshUpdate(true, false);
			((Graphic)m_airTextLocalization).color = color;
			((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false);
		}

		public void UpdateAirText(OxygenBlock config)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (config != null)
			{
				string text = LocalizedText.op_Implicit(config.AirText.Text);
				float x = config.AirText.x;
				float y = config.AirText.y;
				((TMP_Text)m_airTextLocalization).text = text;
				((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false);
				CoroutineManager.BlinkIn(((Component)m_airTextLocalization).gameObject, 0f);
				m_airTextLocalization.transform.SetPositionAndRotation(new Vector3(m_airTextX + x, m_airTextY + y, m_airTextZ), m_airTextLocalization.transform.rotation);
			}
		}

		public void SetVisible(bool vis)
		{
			((Component)m_airText).gameObject.SetActive(vis);
			((Component)m_airTextLocalization).gameObject.SetActive(vis);
			((Component)m_air1).gameObject.SetActive(vis);
			((Component)m_air2).gameObject.SetActive(vis);
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.SetVisible(vis: false);
			}
		}
	}
	public class AirManager : MonoBehaviour
	{
		public static AirManager Current;

		public PlayerAgent m_playerAgent;

		private HUDGlassShatter m_hudGlass;

		private Dam_PlayerDamageBase Damage;

		public OxygenBlock config;

		private uint fogSetting;

		private FogSettingsDataBlock fogSettingDB;

		private float airAmount = 1f;

		private float damageTick;

		private float glassShatterAmount;

		private bool m_isInInfectionLoop;

		private bool isRegeningHealth;

		private float healthToRegen;

		private float healthRegenTick;

		private float tickUntilHealthRegenHealthStart;

		private readonly float regenHealthTickInterval = 0.25f;

		private float healthRegenAmountPerInterval;

		internal bool PlayerShouldCough;

		private readonly float CoughPerLoss = 0.1f;

		private float CoughLoss;

		public AirManager(IntPtr value)
			: base(value)
		{
		}

		public static void Setup(PlayerAgent playerAgent)
		{
			Current = ((Component)playerAgent).gameObject.AddComponent<AirManager>();
		}

		public static void OnBuildDone()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.m_playerAgent = PlayerManager.GetLocalPlayerAgent();
				Current.m_hudGlass = ((Component)Current.m_playerAgent.FPSCamera).GetComponent<HUDGlassShatter>();
				Current.Damage = ((Component)Current.m_playerAgent).gameObject.GetComponent<Dam_PlayerDamageBase>();
				Current.UpdateAirConfig(RundownManager.ActiveExpedition.Expedition.FogSettings);
				AirBar.Current.UpdateAirText(Current.config);
			}
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				if (Current.m_isInInfectionLoop)
				{
					Current.StopInfectionLoop();
				}
				Current.config = null;
				Current.fogSetting = 0u;
				Current.fogSettingDB = null;
				Current.airAmount = 0f;
				Current.damageTick = 0f;
				Current.glassShatterAmount = 0f;
				Current.healthToRegen = 0f;
				Current.m_playerAgent = null;
				Current.m_hudGlass = null;
				Current.Damage = null;
			}
		}

		private void Update()
		{
			if (!RundownManager.ExpeditionIsStarted)
			{
				return;
			}
			if (!HasAirConfig())
			{
				AirBar.Current.SetVisible(vis: false);
				return;
			}
			if (airAmount == 1f)
			{
				if (config.AlwaysDisplayAirBar)
				{
					AirBar.Current.SetVisible(vis: true);
				}
				else
				{
					AirBar.Current.SetVisible(vis: false);
				}
			}
			else
			{
				AirBar.Current.SetVisible(vis: true);
			}
			if (airAmount <= config.DamageThreshold)
			{
				damageTick += Time.deltaTime;
				if (damageTick > config.DamageTime && ((Agent)m_playerAgent).Alive)
				{
					AirDamage();
				}
				isRegeningHealth = false;
			}
			else if (healthToRegen > 0f)
			{
				tickUntilHealthRegenHealthStart += Time.deltaTime;
				if (tickUntilHealthRegenHealthStart > config.TimeToStartHealthRegen)
				{
					if (healthRegenAmountPerInterval == 0f)
					{
						healthRegenAmountPerInterval = healthToRegen * (regenHealthTickInterval / config.TimeToCompleteHealthRegen);
					}
					RegenHealth();
					if (!isRegeningHealth)
					{
						Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen + config.TimeToCompleteHealthRegen;
						isRegeningHealth = true;
					}
				}
			}
			else
			{
				isRegeningHealth = false;
			}
		}

		public void AddAir()
		{
			if (HasAirConfig())
			{
				float airGain = config.AirGain;
				airAmount = Mathf.Clamp01(airAmount + airGain);
				AirBar.Current.UpdateAirBar(airAmount);
				if (fogSettingDB.Infection <= 0f && m_isInInfectionLoop)
				{
					StopInfectionLoop();
				}
			}
		}

		public void RemoveAir(float amount)
		{
			if (HasAirConfig())
			{
				amount = config.AirLoss;
				airAmount = Mathf.Clamp01(airAmount - amount);
				AirBar.Current.UpdateAirBar(airAmount);
				if (fogSettingDB.Infection <= 0f && amount > 0f)
				{
					StartInfectionLoop();
				}
			}
		}

		public void AirDamage()
		{
			float health = ((Dam_SyncedDamageBase)Damage).Health;
			float damageAmount = config.DamageAmount;
			Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen;
			if (!(health <= 1f))
			{
				((Dam_SyncedDamageBase)Damage).NoAirDamage(damageAmount);
				if (config.ShatterGlass)
				{
					glassShatterAmount += config.ShatterAmount;
					m_hudGlass.SetGlassShatterProgression(glassShatterAmount);
				}
				damageTick = 0f;
				tickUntilHealthRegenHealthStart = 0f;
				healthRegenAmountPerInterval = 0f;
				healthToRegen += damageAmount * config.HealthRegenProportion;
				CoughLoss += damageAmount;
				if (CoughLoss > CoughPerLoss)
				{
					PlayerShouldCough = true;
					CoughLoss = 0f;
				}
			}
		}

		public void RegenHealth()
		{
			if (healthToRegen <= 0f)
			{
				return;
			}
			tickUntilHealthRegenHealthStart = config.TimeToStartHealthRegen;
			healthRegenTick += Time.deltaTime;
			if (healthRegenTick > regenHealthTickInterval)
			{
				float num = healthRegenAmountPerInterval;
				if (num >= healthToRegen)
				{
					num = healthToRegen;
					healthToRegen = 0f;
					tickUntilHealthRegenHealthStart = 0f;
					healthRegenAmountPerInterval = 0f;
					isRegeningHealth = false;
				}
				else
				{
					healthToRegen -= num;
				}
				((Dam_SyncedDamageBase)Damage).AddHealth(num, (Agent)(object)m_playerAgent);
				healthRegenTick = 0f;
			}
		}

		public void UpdateAirConfig(uint fogsetting, bool LiveEditForceUpdate = false)
		{
			if (fogsetting != 0 && (fogsetting != fogSetting || LiveEditForceUpdate))
			{
				if (Plugin.lookup.ContainsKey(fogsetting))
				{
					config = Plugin.lookup[fogsetting];
				}
				else if (Plugin.lookup.ContainsKey(0u))
				{
					config = Plugin.lookup[0u];
				}
				else
				{
					config = null;
					airAmount = 1f;
				}
				fogSetting = fogsetting;
				fogSettingDB = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(fogsetting);
				if (GameStateManager.IsInExpedition)
				{
					AirBar.Current.UpdateAirText(config);
				}
			}
		}

		public void ResetHealthToRegen()
		{
			healthRegenTick = 0f;
			healthToRegen = 0f;
			tickUntilHealthRegenHealthStart = 0f;
		}

		public float AirLoss()
		{
			if (config != null)
			{
				return config.AirLoss;
			}
			return 0f;
		}

		public bool AlwaysDisplayAirBar()
		{
			if (config != null)
			{
				return config.AlwaysDisplayAirBar;
			}
			return false;
		}

		public uint FogSetting()
		{
			return fogSetting;
		}

		public float HealthToRegen()
		{
			return healthToRegen;
		}

		public string AirText()
		{
			return LocalizedText.op_Implicit((config == null) ? null : config.AirText.Text);
		}

		public float AirTextX()
		{
			if (config != null)
			{
				return config.AirText.x;
			}
			return 0f;
		}

		public float AirTextY()
		{
			if (config != null)
			{
				return config.AirText.y;
			}
			return 0f;
		}

		public bool HasAirConfig()
		{
			return config != null;
		}

		public void StartInfectionLoop()
		{
			if (!m_isInInfectionLoop)
			{
				m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_START, true);
				m_isInInfectionLoop = true;
			}
		}

		public void StopInfectionLoop()
		{
			if (m_isInInfectionLoop)
			{
				if ((Object)(object)m_playerAgent != (Object)null && m_playerAgent.Sound != null)
				{
					m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_STOP, true);
				}
				m_isInInfectionLoop = false;
			}
		}
	}
	public class AirPlane : MonoBehaviour
	{
		public static AirPlane Current;

		public EV_Plane airPlane;

		private bool isAirPlaneRegistered;

		public AirPlane(IntPtr value)
			: base(value)
		{
		}

		public static void OnBuildStart()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if ((Object)(object)Current == (Object)null)
			{
				Current = ((Component)LocalPlayerAgentSettings.Current).gameObject.AddComponent<AirPlane>();
			}
			Current.airPlane = new EV_Plane();
			uint num = RundownManager.ActiveExpedition.Expedition.FogSettings;
			if (num == 0)
			{
				num = 21u;
			}
			OxygenBlock oxygenBlock = (Plugin.lookup.ContainsKey(num) ? Plugin.lookup[num] : ((!Plugin.lookup.ContainsKey(0u)) ? null : Plugin.lookup[0u]));
			FogSettingsDataBlock block = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(num);
			((EffectVolume)Current.airPlane).invert = block.DensityHeightMaxBoost > block.FogDensity;
			((EffectVolume)Current.airPlane).contents = (eEffectVolumeContents)1;
			((EffectVolume)Current.airPlane).modification = (eEffectVolumeModification)0;
			Current.airPlane.lowestAltitude = block.DensityHeightAltitude;
			Current.airPlane.highestAltitude = block.DensityHeightAltitude + block.DensityHeightRange;
			if (oxygenBlock != null)
			{
				((EffectVolume)Current.airPlane).modificationScale = oxygenBlock.AirLoss;
				Current.Register();
			}
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.Unregister();
				Current.isAirPlaneRegistered = false;
				Current.airPlane = null;
			}
		}

		public void Register()
		{
			if (airPlane != null && !isAirPlaneRegistered)
			{
				EffectVolumeManager.RegisterVolume((EffectVolume)(object)airPlane);
				isAirPlaneRegistered = true;
			}
		}

		public void Unregister()
		{
			if (airPlane != null && isAirPlaneRegistered)
			{
				EffectVolumeManager.UnregisterVolume((EffectVolume)(object)airPlane);
				isAirPlaneRegistered = false;
			}
		}
	}
}