Decompiled source of Arboretum V1 Testing v0.0.6

ArboretumV1.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
using AIGraph;
using Agents;
using ArboretumV1.CustomEnemyBehavior;
using ArboretumV1.CustomLevelBehavior;
using ArboretumV1.Patches;
using ArboretumV1.StolenEEC;
using ArboretumV1.Utils;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CConsole.Commands;
using CConsole.Interop;
using CellMenu;
using Enemies;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using LevelGeneration;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ArboretumV1")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5b3d09f7c2d6230c752b3b5335789b6e9132e984")]
[assembly: AssemblyProduct("ArboretumV1")]
[assembly: AssemblyTitle("ArboretumV1")]
[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 ArboretumV1
{
	[BepInPlugin("com.RLC.ArboretumV1", "RLC.ArboretumV1", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal Harmony _harmony;

		public static Object s_CustomIntelImage1;

		public static GameObject s_customFogSphere;

		public static bool hasCConsole;

		public override void Load()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading Arboretum V-1");
			}
			log.LogInfo(val);
			_harmony = new Harmony("RLC.ArboretumV1");
			FuckOffMTFO();
			GUI_Patches.Setup();
			CustomGearPatches.Setup();
			MiscPatches.Setup();
			CustomEnemyPatches.Setup();
			AssetAPI.OnAssetBundlesLoaded += RegisterTypes;
			AssetAPI.OnAssetBundlesLoaded += AssetAPI_OnAssetBundlesLoaded;
			UniversalLevelPatches.Setup();
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Arboretum V-1 Setup");
			}
			log2.LogInfo(val);
			static async Task FuckOffMTFO()
			{
				await Task.Delay(5000);
				Harmony.CreateAndPatchAll(typeof(Patch_CustomWatermark), (string)null);
			}
		}

		private static void RegisterTypes()
		{
			ClassInjector.RegisterTypeInIl2Cpp<CustomEnemyAbilityBase>();
			ClassInjector.RegisterTypeInIl2Cpp<CustomAbility_Phaser_Small>();
			ClassInjector.RegisterTypeInIl2Cpp<CustomAbility_Phaser_Big>();
			ClassInjector.RegisterTypeInIl2Cpp<CustomBlackoutHandler>();
			ClassInjector.RegisterTypeInIl2Cpp<A2Elevator>();
			ClassInjector.RegisterTypeInIl2Cpp<PUI_A3_DoorKnowledge>();
			ClassInjector.RegisterTypeInIl2Cpp<D1_Resurgence.D1_ReactorBehaviour>();
			CustomLevelBehavior_Manager.Setup();
			string key = "Inas.ExtraObjectiveSetup";
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey(key))
			{
				ArboretumEvents.Setup();
			}
			string key2 = "CConsole";
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey(key2))
			{
				hasCConsole = true;
			}
			ArboJsonHandler.Setup();
		}

		private static void AssetAPI_OnAssetBundlesLoaded()
		{
			s_CustomIntelImage1 = AssetAPI.GetLoadedAsset("Assets/Bundles/Arboretum/CustomIntel/CustomIntelImageObject1.prefab");
			s_customFogSphere = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/Bundles/Arboretum/A-2/CustomFogSphere.prefab")).TryCast<GameObject>();
		}
	}
}
namespace ArboretumV1.Utils
{
	public class ArboJsonHandler
	{
		private static string ArboCustomPath;

		private static readonly JsonSerializerOptions _setting = new JsonSerializerOptions
		{
			ReadCommentHandling = JsonCommentHandling.Skip,
			IncludeFields = true,
			PropertyNameCaseInsensitive = true,
			WriteIndented = true,
			IgnoreReadOnlyProperties = true,
			Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
		};

		public static void Setup()
		{
			ArboCustomPath = Path.Combine(MTFOPathAPI.CustomPath, "Arboretum");
			if (!Directory.Exists(ArboCustomPath))
			{
				Directory.CreateDirectory(ArboCustomPath);
			}
			MTFOHotReloadAPI.OnHotReload += OnHotreload;
		}

		public static void LoadJson(bool isHotreload = false)
		{
		}

		public static T DeserializeAndCreateIfNotReal<T>(string jsonPath, T data)
		{
			if (!File.Exists(jsonPath))
			{
				string contents = JsonSerializer.Serialize(data, _setting);
				File.WriteAllText(jsonPath, contents);
			}
			return JsonSerializer.Deserialize<T>(File.ReadAllText(jsonPath), _setting);
		}

		public static void OnHotreload()
		{
			Log.Info("Reloading json");
			LoadJson(isHotreload: true);
		}
	}
	internal class ArboretumEvents
	{
		public static void Setup()
		{
			EOSWardenEventManager.Current.AddEventDefinition("A1_Blackout", 2001u, (Action<WardenObjectiveEventData>)A1_Restart.BlackoutEvent);
		}
	}
	internal class CustomNetworkEvents
	{
		public static void RegisterEvents()
		{
		}
	}
	public class FuckingInterfaces
	{
		public interface iMineDeployerInstance_Detonation
		{
			event Action OnDetonationDone;

			void Setup(iMineDeployerInstanceCore core);

			void TriggerDetonate(float detectionRange);
		}
	}
	internal static class Log
	{
		private static readonly ManualLogSource _logger;

		static Log()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			_logger = new ManualLogSource("RLC.Arboretum");
			Logger.Sources.Add((ILogSource)(object)_logger);
		}

		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)
		{
			_logger.LogDebug((object)Format(data));
		}

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

		public static void Error(object data)
		{
			_logger.LogError((object)Format(data));
		}
	}
	[HarmonyPatch(typeof(PUI_Watermark), "UpdateWatermark")]
	public class Patch_CustomWatermark
	{
		public static void Postfix(PUI_Watermark __instance)
		{
			((TMP_Text)__instance.m_watermarkText).SetText("Arboretum V-1<color=orange> 0.5.0</color>", true);
		}
	}
}
namespace ArboretumV1.StolenEEC
{
	public static class EnemyAgentExtension
	{
		public static void AddOnDeadOnce(this EnemyAgent agent, Action onDead)
		{
			Action onDead2 = onDead;
			bool called = false;
			agent.OnDeadCallback += Action.op_Implicit((Action)delegate
			{
				if (!called)
				{
					onDead2?.Invoke();
					called = true;
				}
			});
		}

		public static T RegisterOrGetProperty<T>(this EnemyAgent agent) where T : class, new()
		{
			return EnemyProperty<T>.RegisterOrGet(agent);
		}

		public static bool TryGetProperty<T>(this EnemyAgent agent, out T property) where T : class, new()
		{
			return EnemyProperty<T>.TryGet(agent, out property);
		}

		public static bool TryGetSpawnData(this EnemyAgent agent, out pEnemySpawnData spawnData)
		{
			return EnemySpawnDataManager.TryGet(((Agent)agent).GlobalID, out spawnData);
		}

		public static bool TryGetEnemyGroup(this EnemyAgent agent, out EnemyGroup group)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!agent.TryGetSpawnData(out var spawnData))
			{
				group = null;
				return false;
			}
			if (spawnData.groupReplicatorKey == 0)
			{
				group = null;
				return false;
			}
			IReplicator val = default(IReplicator);
			if (!SNet_Replication.TryGetReplicator(spawnData.groupReplicatorKey, ref val))
			{
				group = null;
				return false;
			}
			if (val.ReplicatorSupplier == null)
			{
				group = null;
				return false;
			}
			group = ((Il2CppObjectBase)val.ReplicatorSupplier).TryCast<EnemyGroup>();
			return (Object)(object)group != (Object)null;
		}

		public static AIG_CourseNode GetSpawnedNode(this EnemyAgent agent)
		{
			//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)
			pEnemySpawnData spawnData = ((SNet_DynamicReplicator<pEnemySpawnData>)(object)((Il2CppObjectBase)agent.Sync.Replicator).Cast<EnemyReplicator>()).GetSpawnData();
			AIG_CourseNode result = default(AIG_CourseNode);
			if (!((pCourseNode)(ref spawnData.courseNode)).TryGet(ref result))
			{
				return null;
			}
			return result;
		}
	}
	public delegate void EnemyTakeDamageHandler(EnemyAgent enemyAgent, Agent inflictor, float damage);
	public delegate void EnemyHealthUpdateHandler(EnemyAgent enemyAgent, float maxHealth, float health);
	public static class EnemyDamageEvents
	{
		public static event EnemyTakeDamageHandler Damage;

		[Obsolete("Disabled Due to Patching Error", true)]
		public static event EnemyTakeDamageHandler MeleeDamage;

		[Obsolete("Disabled Due to Patching Error", true)]
		public static event EnemyTakeDamageHandler BulletDamage;

		[Obsolete("Disabled Due to Patching Error", true)]
		public static event EnemyTakeDamageHandler ExplosionDamage;

		public static event EnemyHealthUpdateHandler HealthUpdated;

		internal static void OnDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			EnemyDamageEvents.Damage?.Invoke(enemyAgent, inflictor, damage);
		}

		internal static void OnMeleeDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			EnemyDamageEvents.MeleeDamage?.Invoke(enemyAgent, inflictor, damage);
		}

		internal static void OnBulletDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			EnemyDamageEvents.BulletDamage?.Invoke(enemyAgent, inflictor, damage);
		}

		internal static void OnExplosionDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			EnemyDamageEvents.ExplosionDamage?.Invoke(enemyAgent, inflictor, damage);
		}

		internal static void OnHealthUpdated(EnemyAgent enemyAgent, float maxHealth, float health)
		{
			EnemyDamageEvents.HealthUpdated?.Invoke(enemyAgent, maxHealth, health);
		}
	}
	public delegate void EnemyAgentHandlerWithSpawnData(EnemyAgent agent, pEnemySpawnData spawnData);
	public delegate void EnemyAgentHandler(EnemyAgent agent);
	public static class EnemyEvents
	{
		public static event EnemyAgentHandlerWithSpawnData Spawn;

		public static event EnemyAgentHandler Spawned;

		public static event EnemyAgentHandler Despawn;

		public static event EnemyAgentHandler Despawned;

		internal static void OnSpawn(EnemyAgent agent, pEnemySpawnData spawnData)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			EnemyEvents.Spawn?.Invoke(agent, spawnData);
		}

		internal static void OnSpawned(EnemyAgent agent)
		{
			EnemyEvents.Spawned?.Invoke(agent);
		}

		internal static void OnDespawn(EnemyAgent agent)
		{
			EnemyEvents.Despawn?.Invoke(agent);
		}

		internal static void OnDespawned(EnemyAgent agent)
		{
			EnemyEvents.Despawned?.Invoke(agent);
		}
	}
	public static class EnemyProperty<T> where T : class, new()
	{
		private static readonly Dictionary<ushort, T> _properties;

		public static IEnumerable<T> Properties => _properties.Values;

		static EnemyProperty()
		{
			_properties = new Dictionary<ushort, T>();
			EnemyEvents.Despawn += EnemyDespawn;
			UniversalLevelPatches.OnLevelCleanup += OnLevelCleanup;
		}

		private static void EnemyDespawn(EnemyAgent agent)
		{
			_properties.Remove(((Agent)agent).GlobalID);
		}

		private static void OnLevelCleanup()
		{
			_properties.Clear();
		}

		public static T RegisterOrGet(EnemyAgent agent)
		{
			T val = RegisterEnemy(agent);
			if (val != null)
			{
				return val;
			}
			return Get(agent);
		}

		public static T RegisterEnemy(EnemyAgent agent)
		{
			ushort globalID = ((Agent)agent).GlobalID;
			if (_properties.ContainsKey(globalID))
			{
				return null;
			}
			T val = new T();
			_properties.Add(globalID, val);
			return val;
		}

		public static T Get(EnemyAgent agent)
		{
			return Get(((Agent)agent).GlobalID);
		}

		public static T Get(ushort id)
		{
			if (_properties.ContainsKey(id))
			{
				return _properties[id];
			}
			return null;
		}

		public static bool TryGet(EnemyAgent agent, out T property)
		{
			return TryGet(((Agent)agent).GlobalID, out property);
		}

		public static bool TryGet(ushort id, out T property)
		{
			return _properties.TryGetValue(id, out property);
		}
	}
	public static class EnemySpawnDataManager
	{
		private static readonly Dictionary<ushort, pEnemySpawnData> _lookup;

		static EnemySpawnDataManager()
		{
			_lookup = new Dictionary<ushort, pEnemySpawnData>(500);
			EnemyEvents.Spawn += Spawn;
			EnemyEvents.Despawn += Despawn;
			UniversalLevelPatches.OnLevelCleanup += OnLevelCleanup;
		}

		private static void Spawn(EnemyAgent agent, pEnemySpawnData spawnData)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			_lookup[spawnData.replicationData.ReplicatorKey] = spawnData;
		}

		private static void Despawn(EnemyAgent agent)
		{
			_lookup.Remove(((Agent)agent).GlobalID);
		}

		private static void OnLevelCleanup()
		{
			_lookup.Clear();
		}

		public static bool TryGet(ushort id, out pEnemySpawnData data)
		{
			return _lookup.TryGetValue(id, out data);
		}
	}
	public struct LazyTimer
	{
		private float _lastTickTime;

		private float _durationInv;

		public float PassedTime { get; private set; }

		public float Duration { get; private set; }

		public bool Done => Progress >= 1f;

		public float Progress => Mathf.Clamp01(ProgressUnclamped);

		public float ProgressUnclamped
		{
			get
			{
				if (Duration != 0f)
				{
					return PassedTime * _durationInv;
				}
				return 1f;
			}
		}

		public LazyTimer(float duration)
		{
			PassedTime = 0f;
			Duration = duration;
			_durationInv = 1f / duration;
			_lastTickTime = GetTime();
		}

		public void Reset(float newDuration = -1f)
		{
			PassedTime = 0f;
			if (newDuration >= 0f)
			{
				Duration = newDuration;
				_durationInv = 1f / newDuration;
			}
			_lastTickTime = GetTime();
		}

		public void Tick()
		{
			float time = GetTime();
			float num = time - _lastTickTime;
			_lastTickTime = time;
			PassedTime += num;
		}

		public bool TickAndCheckDone()
		{
			Tick();
			return Done;
		}

		private static float GetTime()
		{
			//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)
			{
				return Clock.ExpeditionProgressionTime;
			}
			return Clock.Time;
		}
	}
	public struct Timer
	{
		private float _durationInv;

		public float PassedTime { get; private set; }

		public float Duration { get; private set; }

		public bool Done => Progress >= 1f;

		public float Progress => Mathf.Clamp01(ProgressUnclamped);

		public float ProgressUnclamped
		{
			get
			{
				if (Duration != 0f)
				{
					return PassedTime * _durationInv;
				}
				return 1f;
			}
		}

		public Timer(float duration)
		{
			PassedTime = 0f;
			Duration = duration;
			_durationInv = 1f / duration;
		}

		public void Reset(float newDuration = -1f)
		{
			PassedTime = 0f;
			if (newDuration >= 0f)
			{
				Duration = newDuration;
				_durationInv = 1f / newDuration;
			}
		}

		public void Tick()
		{
			PassedTime += Time.deltaTime;
		}

		public void Tick(float deltaTime)
		{
			PassedTime += deltaTime;
		}

		public bool TickAndCheckDone()
		{
			Tick();
			return Done;
		}

		public bool TickAndCheckDone(float deltaTime)
		{
			Tick(deltaTime);
			return Done;
		}
	}
	public struct DoubleTimer
	{
		private double _durationInv;

		public double PassedTime { get; private set; }

		public double Duration { get; private set; }

		public bool Done => Progress >= 1.0;

		public double Progress => Math.Clamp(0.0, 1.0, ProgressUnclamped);

		public double ProgressUnclamped
		{
			get
			{
				if (Duration != 0.0)
				{
					return PassedTime * _durationInv;
				}
				return 1.0;
			}
		}

		public DoubleTimer(double duration)
		{
			PassedTime = 0.0;
			Duration = duration;
			_durationInv = 1.0 / duration;
		}

		public void Reset(double newDuration = -1.0)
		{
			PassedTime = 0.0;
			if (newDuration >= 0.0)
			{
				Duration = newDuration;
				_durationInv = 1.0 / newDuration;
			}
		}

		public void Tick()
		{
			PassedTime += Time.deltaTime;
		}

		public bool TickAndCheckDone()
		{
			Tick();
			return Done;
		}
	}
}
namespace ArboretumV1.Patches
{
	public class CustomEnemyPatches
	{
		[HarmonyPatch(typeof(EnemyAgent), "Setup")]
		private class Patch_EnemyAgent_Setup
		{
			public static void Postfix(EnemyAgent __instance)
			{
				if (0 == 0)
				{
					((Component)__instance).gameObject.AddComponent<CustomEnemyAbilityBase>().Setup();
				}
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageBase), "ProcessReceivedDamage")]
		private class Patch_Dam_EnemyDamageBase_ProcessReceivedDamage
		{
			public static void Postfix(float damage, Agent damageSource, Dam_EnemyDamageBase __instance)
			{
				EnemyDamageEvents.OnDamage(__instance.Owner, damageSource, damage);
			}
		}

		public static void Setup()
		{
			Harmony.CreateAndPatchAll(typeof(Patch_EnemyAgent_Setup), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_Dam_EnemyDamageBase_ProcessReceivedDamage), (string)null);
			Log.Info("Custom Enemy Patches Setup");
		}
	}
	internal class CustomGearPatches
	{
		[HarmonyPatch(typeof(MineDeployerFirstPerson), "OnWield")]
		private class Patch_MineDeployerFirstPerson_OnWield
		{
			public static void Postfix(MineDeployerFirstPerson __instance)
			{
				if (((Object)((Component)__instance).gameObject).name == "GearItem_Krieger C6")
				{
					__instance.m_mineIdToSpawn = 126u;
				}
				if (((Object)((Component)__instance).gameObject).name == "GearItem_Krieger G12")
				{
					__instance.m_mineIdToSpawn = 3027u;
				}
			}
		}

		[HarmonyPatch(typeof(PLOC_Run), "FixedUpdate")]
		private class Patch_PLOC_Run_FixedUpdate
		{
			public static void Prefix(PLOC_Run __instance)
			{
				ArchetypeDataBlock archetypeData = ((PLOC_Base)__instance).m_owner.Inventory.WieldedItem.ArchetypeData;
				float walkMoveSpeed = 3.5f;
				float runMoveSpeed = 6f;
				if (archetypeData != null)
				{
					if (((GameDataBlockBase<ArchetypeDataBlock>)(object)archetypeData).persistentID == 1006)
					{
						runMoveSpeed = 4.75f;
						walkMoveSpeed = 3f;
					}
					else
					{
						runMoveSpeed = 6f;
						walkMoveSpeed = 3.5f;
					}
				}
				((PLOC_Base)__instance).m_owner.PlayerData.walkMoveSpeed = walkMoveSpeed;
				((PLOC_Base)__instance).m_owner.PlayerData.runMoveSpeed = runMoveSpeed;
			}
		}

		[HarmonyPatch(typeof(PLOC_Stand), "FixedUpdate")]
		private class Patch_PLOC_Stand_FixedUpdate
		{
			public static void Prefix(PLOC_Stand __instance)
			{
				ArchetypeDataBlock archetypeData = ((PLOC_Base)__instance).m_owner.Inventory.WieldedItem.ArchetypeData;
				float walkMoveSpeed = 3.5f;
				float runMoveSpeed = 6f;
				if (archetypeData != null)
				{
					if (((GameDataBlockBase<ArchetypeDataBlock>)(object)archetypeData).persistentID == 1006)
					{
						runMoveSpeed = 4.75f;
						walkMoveSpeed = 3f;
					}
					else
					{
						runMoveSpeed = 6f;
						walkMoveSpeed = 3.5f;
					}
				}
				((PLOC_Base)__instance).m_owner.PlayerData.walkMoveSpeed = walkMoveSpeed;
				((PLOC_Base)__instance).m_owner.PlayerData.runMoveSpeed = runMoveSpeed;
			}
		}

		public static void Setup()
		{
			Harmony.CreateAndPatchAll(typeof(Patch_MineDeployerFirstPerson_OnWield), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_PLOC_Run_FixedUpdate), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_PLOC_Stand_FixedUpdate), (string)null);
			Log.Info("Custom Gear Patches Setup");
		}
	}
	internal class GUI_Patches
	{
		[HarmonyPatch(typeof(CM_PageRundown_New), "SetRundownFullyRevealed")]
		private class Patch_CM_PageRundown_New_SetRundownFullyRevealed
		{
			public static void Postfix(CM_PageRundown_New __instance)
			{
				__instance.m_tierMarker1.SetVisible(true, 0f);
				__instance.m_tierMarker2.SetVisible(true, 0f);
				__instance.m_tierMarker3.SetVisible(true, 0f);
				__instance.m_tierMarker4.SetVisible(true, 0f);
				((Component)((Component)__instance).transform.GetChild(2).GetChild(4).GetChild(15)).gameObject.SetActive(false);
				((Component)((Component)__instance).transform.GetChild(2).GetChild(4).GetChild(17)).gameObject.SetActive(false);
			}
		}

		[HarmonyPatch(typeof(CM_PageRundown_New), "Setup")]
		private class Patch_CM_PageRundown_New_Setup
		{
			[CompilerGenerated]
			private sealed class <CustomRundownElements>d__2 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public CM_PageRundown_New __instance;

				private GameObject <newTierMarker1>5__2;

				private GameObject <newTierMarker2>5__3;

				private GameObject <newTierMarker3>5__4;

				private GameObject <newTierMarker4>5__5;

				private GameObject <newTierMarker5>5__6;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <CustomRundownElements>d__2(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<newTierMarker1>5__2 = null;
					<newTierMarker2>5__3 = null;
					<newTierMarker3>5__4 = null;
					<newTierMarker4>5__5 = null;
					<newTierMarker5>5__6 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ea: Expected O, but got Unknown
					//IL_010c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0116: Expected O, but got Unknown
					//IL_0138: Unknown result type (might be due to invalid IL or missing references)
					//IL_0142: Expected O, but got Unknown
					//IL_0164: Unknown result type (might be due to invalid IL or missing references)
					//IL_016e: Expected O, but got Unknown
					//IL_0190: Unknown result type (might be due to invalid IL or missing references)
					//IL_019a: Expected O, but got Unknown
					//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
					//IL_01c6: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						Transform child = ((Component)__instance).transform.GetChild(2).GetChild(4);
						<newTierMarker1>5__2 = Object.Instantiate<GameObject>(((Component)__instance.m_tierMarker1).gameObject, child);
						<newTierMarker2>5__3 = Object.Instantiate<GameObject>(((Component)__instance.m_tierMarker2).gameObject, child);
						<newTierMarker3>5__4 = Object.Instantiate<GameObject>(((Component)__instance.m_tierMarker3).gameObject, child);
						<newTierMarker4>5__5 = Object.Instantiate<GameObject>(((Component)__instance.m_tierMarker4).gameObject, child);
						<newTierMarker5>5__6 = Object.Instantiate<GameObject>(((Component)__instance.m_tierMarker5).gameObject, child);
						<>2__current = (object)new WaitForSeconds(3.44f);
						<>1__state = 1;
						return true;
					}
					case 1:
						<>1__state = -1;
						<newTierMarker1>5__2.SetActive(true);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -1;
						<newTierMarker2>5__3.SetActive(true);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -1;
						<newTierMarker3>5__4.SetActive(true);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -1;
						<newTierMarker4>5__5.SetActive(true);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -1;
						<newTierMarker5>5__6.SetActive(true);
						<>2__current = (object)new WaitForSeconds(7f);
						<>1__state = 6;
						return true;
					case 6:
						<>1__state = -1;
						<>2__current = null;
						<>1__state = 7;
						return true;
					case 7:
						<>1__state = -1;
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static Coroutine? _Coroutine;

			public static void Postfix(CM_PageRundown_New __instance)
			{
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				CM_PageRundown_New __instance2 = __instance;
				CM_Item buttonConnect = __instance2.m_buttonConnect;
				buttonConnect.OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)delegate
				{
					if (_Coroutine == null)
					{
						_Coroutine = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(CustomRundownElements(__instance2)), (Action)null);
					}
				});
				Transform child = ((Component)__instance2).transform.GetChild(2).GetChild(4);
				m_customRundownName = Object.Instantiate<GameObject>(((Component)__instance2.m_textRundownHeader).gameObject, child);
				m_customRundownName.SetActive(false);
				((TMP_Text)((Component)__instance2.m_buttonVanityItemDrops).GetComponent<TextMeshPro>()).text = "";
				((Component)((Component)__instance2.m_buttonVanityItemDrops).transform.GetChild(0)).gameObject.SetActive(false);
				((Component)__instance2.m_vanityItemDropsNext).transform.localPosition = new Vector3(9999f, 0f, 0f);
			}

			[IteratorStateMachine(typeof(<CustomRundownElements>d__2))]
			private static IEnumerator CustomRundownElements(CM_PageRundown_New __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <CustomRundownElements>d__2(0)
				{
					__instance = __instance
				};
			}
		}

		[HarmonyPatch(typeof(CM_PageRundown_New), "TryPlaceRundown")]
		private class Patch_CM_PageRundown_New_TryPlaceRundown
		{
			[CompilerGenerated]
			private sealed class <FixRundownName>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public CM_PageRundown_New __instance;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <FixRundownName>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0052: Unknown result type (might be due to invalid IL or missing references)
					//IL_005c: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						((TMP_Text)m_customRundownName.GetComponent<TextMeshPro>()).text = ((TMP_Text)__instance.m_textRundownHeader).text;
						m_customRundownName.SetActive(false);
						<>2__current = (object)new WaitForSeconds(5.6f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						m_customRundownName.SetActive(true);
						<>2__current = null;
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -1;
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			public static void Postfix(CM_PageRundown_New __instance)
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(FixRundownName(__instance)), (Action)null);
			}

			[IteratorStateMachine(typeof(<FixRundownName>d__1))]
			private static IEnumerator FixRundownName(CM_PageRundown_New __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <FixRundownName>d__1(0)
				{
					__instance = __instance
				};
			}
		}

		[HarmonyPatch(typeof(CM_RundownTierMarker), "Setup")]
		private class Patch_CM_RundownTierMarker_Setup
		{
			public static void Postfix(CM_RundownTierMarker __instance)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				((Component)((Component)__instance).transform.GetChild(0)).transform.localPosition = new Vector3(20f, 0f, 0f);
				((Component)((Component)__instance).transform.GetChild(0).GetChild(0)).transform.localPosition = new Vector3(0f, 0f, 0f);
				((Component)((Component)__instance).transform.GetChild(0).GetChild(0)).transform.localScale = new Vector3(0.9104f, 35.0818f, 0.9104f);
				((Component)((Component)__instance).transform.GetChild(0).GetChild(1)).transform.localPosition = new Vector3(850f, 0f, 0f);
			}
		}

		[HarmonyPatch(typeof(CM_BoosterImplantSlotHolder), "Setup")]
		private class Patch_CM_BoosterImplantSlotHolder_Setup
		{
			public static void Prefix(CM_BoosterImplantSlotHolder __instance)
			{
				//IL_001b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
				RectTransform component = ((Component)__instance).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchoredPosition = new Vector2(1f, 2000f);
					component.sizeDelta = new Vector2(1f, 2000f);
					((Transform)component).localScale = new Vector3(1f, 1f, 1f);
				}
			}
		}

		[HarmonyPatch(typeof(CM_GlobalPopup), "ShowMessage")]
		private class Patch_CM_GlobalPopup_ShowMessage
		{
			public static void Postfix(CM_GlobalPopup __instance)
			{
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)((Component)__instance).gameObject).name == "CM_GlobalPopup_RundownIntel(Clone)")
				{
					Transform transform = ((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(4)).gameObject.transform;
					Object.Instantiate(Plugin.s_CustomIntelImage1, transform);
					GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(4).GetChild(0)).gameObject;
					gameObject.transform.localScale = new Vector3(27f, 27f, 27f);
					((Renderer)gameObject.GetComponent<SpriteRenderer>()).sortingLayerID = 2124035475;
					((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(4)).gameObject.GetComponent<SpriteRenderer>().color = new Color(0f, 0f, 0f, 0f);
					((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(5)).gameObject.GetComponent<SpriteRenderer>().color = new Color(0f, 0f, 0f, 0f);
					((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(6)).gameObject.GetComponent<SpriteRenderer>().color = new Color(0f, 0f, 0f, 0f);
					((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(0).GetChild(1)).gameObject.SetActive(true);
					((TMP_Text)((Component)((Component)__instance).gameObject.transform.GetChild(0).GetChild(0).GetChild(1)).gameObject.GetComponent<TextMeshPro>()).SetText("RND_BRIEFING", true);
				}
			}
		}

		[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "SetArtifactHeat")]
		private class Patch_CM_ExpeditionIcon_New_SetArtifactHeat
		{
			public static void Postfix(CM_ExpeditionIcon_New __instance)
			{
				((TMP_Text)__instance.m_artifactHeatText).SetText("", true);
			}
		}

		private static GameObject m_customRundownName;

		public static void Setup()
		{
			Harmony.CreateAndPatchAll(typeof(Patch_CM_PageRundown_New_SetRundownFullyRevealed), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_PageRundown_New_Setup), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_PageRundown_New_TryPlaceRundown), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_RundownTierMarker_Setup), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_BoosterImplantSlotHolder_Setup), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_GlobalPopup_ShowMessage), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_CM_ExpeditionIcon_New_SetArtifactHeat), (string)null);
			Log.Info("GUI Patches Setup");
		}
	}
	internal class MiscPatches
	{
		[HarmonyPatch(typeof(PlayerAmmoStorage), "UpdateBulletsInPack")]
		private class Patch_PlayerAmmoStorage_UpdateBulletsInPack
		{
			private static float current;

			private static InventorySlotAmmo ammo;

			public static void Prefix(PlayerAmmoStorage __instance, ref AmmoType ammoType, ref int bulletCount)
			{
				ammo = ((Il2CppArrayBase<InventorySlotAmmo>)(object)__instance.m_ammoStorage)[(int)ammoType];
				current = ammo.AmmoInPack;
			}

			public static void Postfix(PlayerAmmoStorage __instance, ref AmmoType ammoType, ref int bulletCount)
			{
				ammo = ((Il2CppArrayBase<InventorySlotAmmo>)(object)__instance.m_ammoStorage)[(int)ammoType];
				float num = (float)bulletCount * ammo.CostOfBullet;
				float ammoInPack = current + num;
				ammo.AmmoInPack = ammoInPack;
				__instance.UpdateAllAmmoUI();
			}
		}

		public static void Setup()
		{
			Harmony.CreateAndPatchAll(typeof(Patch_PlayerAmmoStorage_UpdateBulletsInPack), (string)null);
			Log.Info("miscellaneous patches setup");
		}
	}
	internal class UniversalLevelPatches
	{
		private class Patch_LG_Factory_OnFactoryBuildStart
		{
			public static void LinkEvent()
			{
				UniversalLevelPatches.OnBuildStart?.Invoke();
			}
		}

		[HarmonyPatch(typeof(LG_Factory), "FactoryDone")]
		private class Patch_LG_Factory_FactoryDone
		{
			public static void Postfix()
			{
				UniversalLevelPatches.OnBuildDone?.Invoke();
			}
		}

		[HarmonyPatch(typeof(WardenObjectiveManager), "OnLocalPlayerStartExpedition")]
		private class Patch_WardenObjectiveManager_OnLocalPlayerStartExpedition
		{
			public static void Postfix()
			{
				UniversalLevelPatches.OnStartExpedition?.Invoke();
			}
		}

		[HarmonyPatch(typeof(WardenObjectiveManager), "OnLocalPlayerSolvedObjectiveItem")]
		private class Patch_WardenObjectiveManager_OnLocalPlayerSolvedObjectiveItem
		{
			public static void Postfix()
			{
				UniversalLevelPatches.OnSolvedObjectiveItem?.Invoke();
			}
		}

		[HarmonyPatch(typeof(WardenObjectiveManager), "ActivateWinCondition")]
		private class Patch_WardenObjectiveManager_ActivateWinCondition
		{
			public static void Postfix()
			{
				UniversalLevelPatches.OnObjectiveComplete?.Invoke();
			}
		}

		[HarmonyPatch(typeof(GS_AfterLevel), "CleanupAfterExpedition")]
		private class Patch_GS_AfterLevel_CleanupAfterExpedition
		{
			public static void Postfix()
			{
				UniversalLevelPatches.OnLevelCleanup?.Invoke();
			}
		}

		public static event Action OnBuildStart;

		public static event Action OnBuildDone;

		public static event Action OnStartExpedition;

		public static event Action OnSolvedObjectiveItem;

		public static event Action OnObjectiveComplete;

		public static event Action OnLevelCleanup;

		public static void Setup()
		{
			LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)Patch_LG_Factory_OnFactoryBuildStart.LinkEvent);
			Harmony.CreateAndPatchAll(typeof(Patch_LG_Factory_FactoryDone), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_WardenObjectiveManager_OnLocalPlayerStartExpedition), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_WardenObjectiveManager_OnLocalPlayerSolvedObjectiveItem), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_WardenObjectiveManager_ActivateWinCondition), (string)null);
			Harmony.CreateAndPatchAll(typeof(Patch_GS_AfterLevel_CleanupAfterExpedition), (string)null);
			Log.Info("Universal Level Patches Setup");
		}
	}
}
namespace ArboretumV1.CustomLevelBehavior
{
	public class A1_Restart
	{
		private static List<CustomBlackoutHandler> blackoutHandlers = new List<CustomBlackoutHandler>();

		public void Setup()
		{
			UniversalLevelPatches.OnBuildDone += OnBuildDone;
			UniversalLevelPatches.OnLevelCleanup += OnLevelCleanup;
			Log.Error("A-1 Restart Setup");
			if (Plugin.hasCConsole)
			{
				RegisterCommands();
			}
		}

		internal static void RegisterCommands()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			CustomCommandSetting val = default(CustomCommandSetting);
			val.Category = (CategoryType)13;
			val.Command = "SetBlackoutState";
			val.Description = "Sets the blackout state in the specified tile";
			val.HostOnly = true;
			val.MinArgumentCount = 0;
			val.Priority = 0;
			val.RequireInLevel = true;
			val.RequireLocalPlayer = true;
			val.RequireRayObject = false;
			val.Usage = "SetBlackoutState [TileIndex int] [Enabled bool] [SkipTerminals bool]";
			CustomCommands.Register(val, new OnCommandUsedDelegate(OnCommandUsed));
		}

		internal static void OnCommandUsed(in CustomCmdContext ctx, string[] args)
		{
			int index = 0;
			bool state = false;
			bool skipTerminals = false;
			try
			{
				index = int.Parse(args[0]);
				state = bool.Parse(args[1]);
				skipTerminals = bool.Parse(args[2]);
			}
			catch
			{
				Log.Error("Tried to parse an argument that wasn't an int or bool (or both)");
			}
			Log.Info("Setting new blackout state in zone: " + index + ", to: " + state);
			blackoutHandlers[index].SetState(state, skipTerminals);
		}

		private void OnBuildDone()
		{
			LG_Floor currentFloor = Builder.CurrentFloor;
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(0)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(1)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(2)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(3)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(4)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(5)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(6)).gameObject.AddComponent<CustomBlackoutHandler>());
			blackoutHandlers.Add(((Component)((Component)currentFloor).transform.GetChild(0).GetChild(7)).gameObject.AddComponent<CustomBlackoutHandler>());
		}

		public static void BlackoutEvent(WardenObjectiveEventData e)
		{
			switch (e.Count)
			{
			case 0:
				blackoutHandlers[0].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 1:
				blackoutHandlers[1].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 2:
				blackoutHandlers[2].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 3:
				blackoutHandlers[3].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 4:
				blackoutHandlers[4].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 5:
				blackoutHandlers[5].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 6:
				blackoutHandlers[6].SetState(!e.Enabled, e.ClearDimension);
				break;
			case 7:
				blackoutHandlers[7].SetState(!e.Enabled, e.ClearDimension);
				break;
			}
		}

		private void OnLevelCleanup()
		{
			blackoutHandlers.Clear();
			UniversalLevelPatches.OnBuildDone -= OnBuildDone;
			UniversalLevelPatches.OnLevelCleanup -= OnLevelCleanup;
		}
	}
	public class CustomBlackoutHandler : MonoBehaviour
	{
		public LG_DoorButton[] doorButtons = Array.Empty<LG_DoorButton>();

		public LG_ComputerTerminal[] terminals = Array.Empty<LG_ComputerTerminal>();

		public LG_Light[] lights = Array.Empty<LG_Light>();

		public void Start()
		{
			doorButtons = Il2CppArrayBase<LG_DoorButton>.op_Implicit(((Component)this).GetComponentsInChildren<LG_DoorButton>());
			terminals = Il2CppArrayBase<LG_ComputerTerminal>.op_Implicit(((Component)this).GetComponentsInChildren<LG_ComputerTerminal>());
			lights = Il2CppArrayBase<LG_Light>.op_Implicit(((Component)this).GetComponentsInChildren<LG_Light>());
		}

		public void SetState(bool state, bool skipTerminals = false)
		{
			LG_DoorButton[] array = doorButtons;
			foreach (LG_DoorButton obj in array)
			{
				obj.m_enabled = state;
				((Component)((Component)obj).transform.GetChild(1)).gameObject.SetActive(state);
			}
			LG_Light[] array2 = lights;
			for (int i = 0; i < array2.Length; i++)
			{
				((Component)array2[i]).gameObject.SetActive(state);
			}
			LG_ComputerTerminal[] array3 = terminals;
			foreach (LG_ComputerTerminal val in array3)
			{
				if (skipTerminals)
				{
					break;
				}
				if (!((Object)(object)val.ConnectedReactor != (Object)null))
				{
					val.ExitFPSView();
					((Component)((Component)val).transform.GetChild(0)).gameObject.SetActive(state);
					((Component)((Component)val).transform.GetChild(1).GetChild(0)).gameObject.SetActive(state);
					((Component)((Component)val).transform.GetChild(1).GetChild(1).GetChild(1)).gameObject.SetActive(state);
				}
			}
		}
	}
	public class A2_Balance
	{
		private A2Elevator ElevatorOne;

		private A2Elevator ElevatorTwo;

		public void Setup()
		{
			LevelAPI.OnBuildStart += OnBuildStart;
			LevelAPI.OnBuildDone += OnBuildDone;
			LevelAPI.OnLevelCleanup += OnLevelCleanup;
			Log.Error("A-2 Balance Setup");
		}

		private void OnBuildStart()
		{
		}

		private void OnBuildDone()
		{
			GenerateFogSphere();
			SpawnElevators();
		}

		private void SpawnElevators()
		{
			((Component)((Component)Builder.CurrentFloor).transform.GetChild(0).GetChild(1).GetChild(1)
				.GetChild(0)).gameObject.AddComponent<A2Elevator>();
		}

		public void GenerateFogSphere()
		{
			//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)
			Log.Info("GeneratingFogSphere");
			FogSphereHandler component = Object.Instantiate<GameObject>(Plugin.s_customFogSphere, new Vector3(0f, 0f, 0f), Quaternion.identity).GetComponent<FogSphereHandler>();
			component.m_totalLength = 1E+13f;
			if (component.Play())
			{
				Log.Info("Played Fog Sphere");
			}
			else
			{
				Log.Error("Could not play fog sphere :(");
			}
		}

		public void Update()
		{
		}

		private void OnLevelCleanup()
		{
			UniversalLevelPatches.OnBuildDone -= OnBuildDone;
			UniversalLevelPatches.OnLevelCleanup -= OnLevelCleanup;
		}
	}
	public class A2Elevator : MonoBehaviour
	{
		public int m_elevatorID;

		private GameObject elevatorActual;

		private OffMeshLink elevatorMeshLink;

		private float speed = 2f;

		private Transform TopFloor;

		private Transform MidFloor;

		private Transform BottomFloor;

		private int CurrentFloor;

		public void Setup()
		{
			elevatorActual = ((Component)((Component)this).transform.GetChild(0)).gameObject;
			elevatorMeshLink = ((Component)((Component)this).transform.GetChild(0).GetChild(2)).GetComponent<OffMeshLink>();
		}

		public void TraveltoFloor(int floor)
		{
			switch (floor)
			{
			case 0:
				if (CurrentFloor != 0)
				{
					if (CurrentFloor == 1)
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
					else
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
				}
				break;
			case 1:
				if (CurrentFloor != 1)
				{
					if (CurrentFloor == 2)
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
					else
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
				}
				break;
			case 2:
				if (CurrentFloor != 2)
				{
					if (CurrentFloor == 1)
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
					else
					{
						((MonoBehaviour)this).InvokeRepeating("MoveBitch", 5f, 0.1f);
					}
				}
				break;
			}
		}

		private void MoveBitch(Transform currentTransform, Transform targetTransform)
		{
			//IL_000c: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			elevatorActual.transform.localPosition = Vector3.MoveTowards(currentTransform.position, targetTransform.position, speed * Time.deltaTime);
			if (elevatorActual.transform.localPosition == targetTransform.position)
			{
				((MonoBehaviour)this).CancelInvoke("MoveBitch");
			}
		}
	}
	internal class A3_Betrayal
	{
		public GameObject m_customGUI;

		public void Setup()
		{
		}

		public void OnElevatorLand()
		{
		}

		private void CreateCustomGUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0051: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			m_customGUI = Object.Instantiate<GameObject>(new GameObject("PUI_A3_KnownDoors"), ((Component)GuiManager.PlayerLayer.WardenObjectives).transform.parent);
			m_customGUI.layer = 5;
			Transform transform = m_customGUI.transform;
			transform.localPosition = new Vector3(-880f, 200f, 0f);
			transform.localScale = new Vector3(5f, 5f, 5f);
			m_customGUI.AddComponent<PUI_A3_DoorKnowledge>();
			GameObject obj = Object.Instantiate<GameObject>(new GameObject("Header"), transform);
			obj.layer = 5;
			((TMP_Text)obj.AddComponent<TextMeshPro>()).text = "Intelligence";
		}
	}
	public class PUI_A3_DoorKnowledge : MonoBehaviour
	{
		public GameObject doorsHeader;
	}
	public class C2_Relay
	{
		private const string HarmonyID = "RLC.C2_Relay";

		public void Setup()
		{
			UniversalLevelPatches.OnStartExpedition += OnStartExpedition;
			UniversalLevelPatches.OnLevelCleanup += CleanupAfterExpedition;
			OnFactoryBuildStart();
			Log.Error("C2_Relay Setup with ID: RLC.C2_Relay");
		}

		public void OnFactoryBuildStart()
		{
		}

		public void OnStartExpedition()
		{
		}

		public void CleanupAfterExpedition()
		{
			Harmony.UnpatchID("RLC.C2_Relay");
			UniversalLevelPatches.OnStartExpedition -= OnStartExpedition;
			UniversalLevelPatches.OnLevelCleanup -= CleanupAfterExpedition;
			Log.Error("C2_Relay Cleaned up ID: RLC.C2_Relay");
		}
	}
	public class CustomFogTesting : MonoBehaviour
	{
		public static void Setup()
		{
			Log.Info("Setting up custom fog layer :)");
		}
	}
	internal class CustomLevelBehavior_Manager
	{
		public static A1_Restart A1;

		public static A2_Balance A2;

		public static A3_Betrayal A3;

		public static D1_Resurgence D1;

		public static C2_Relay C2;

		public static void Setup()
		{
			D1 = new D1_Resurgence();
			C2 = new C2_Relay();
			A1 = new A1_Restart();
			A2 = new A2_Balance();
			A3 = new A3_Betrayal();
			LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)SetupCustomLevel);
		}

		public static void SetupCustomLevel()
		{
			switch (RundownManager.ActiveExpedition.LevelLayoutData)
			{
			case 1001u:
				A1.Setup();
				break;
			case 1002u:
				A2.Setup();
				break;
			case 1003u:
				A3.Setup();
				break;
			case 1u:
				D1.Setup();
				break;
			case 16u:
				C2.Setup();
				break;
			case 9999u:
				A2.Setup();
				break;
			}
		}
	}
	public class D1_Resurgence_ReactorRestart : MonoBehaviour
	{
		private void Start()
		{
		}

		private void Update()
		{
		}
	}
	internal class D1_Resurgence
	{
		public class D1_ReactorBehaviour : MonoBehaviour
		{
			private bool isSetup;

			public int ReactorTempMain;

			public int ReactorTempDecimal;

			public float ReactorTempActual;

			public void Setup()
			{
				isSetup = true;
			}

			public void Update()
			{
				_ = isSetup;
			}
		}

		private const string HarmonyID = "RLC.D1_Resurgence";

		public void Setup()
		{
			Log.Error("D-1 Resurgence Setup");
		}

		private static float IntToFloat(int mainPart, int decimalPart)
		{
			if (decimalPart < 0 || decimalPart >= 100)
			{
				Log.Error("Decimal part must be between 0 and 99.");
			}
			return (float)mainPart + (float)decimalPart / 100f;
		}

		private static void FloatToInt(float value, out int mainPart, out int decimalPart)
		{
			mainPart = (int)value;
			decimalPart = (int)Math.Round((value - (float)mainPart) * 100f);
		}
	}
}
namespace ArboretumV1.CustomEnemyBehavior
{
	public class CustomAbility_Phaser_Big : MonoBehaviour
	{
		private CustomEnemyAbilityBase m_customAbilityBase;

		private Timer _phaseRegenTimer;

		private bool _isTimerDone;

		public SkinnedMeshRenderer _meshRenderer;

		public bool EnableCloaking = true;

		private static float m_currentPhaseLevel = 0.5f;

		private static float m_minPhaseLevel = 0.05f;

		private static float m_maxPhaseLevel = 0.8f;

		private void Start()
		{
			m_customAbilityBase = ((Component)this).GetComponent<CustomEnemyAbilityBase>();
			SkinnedMeshRenderer component = ((Component)((Component)this).gameObject.transform.GetChild(3).GetChild(3)).GetComponent<SkinnedMeshRenderer>();
			_meshRenderer = component;
			EnemyDamageEvents.Damage += OnTakeDamage;
			m_customAbilityBase.m_enemyDamageBase.Owner.AddOnDeadOnce(delegate
			{
				EnemyDamageEvents.Damage -= OnTakeDamage;
			});
		}

		private void FixedUpdate()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (EnableCloaking && ((Agent)m_customAbilityBase.m_enemyAgent).Alive)
			{
				if (!_isTimerDone && _phaseRegenTimer.TickAndCheckDone())
				{
					_isTimerDone = true;
				}
				else if (_isTimerDone)
				{
					IncreasePhaseLevel();
				}
				Color color = ((Renderer)_meshRenderer).material.color;
				color.a = m_currentPhaseLevel;
				((Renderer)_meshRenderer).material.color = color;
			}
		}

		private void OnTakeDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			if (((Agent)enemyAgent).GlobalID == ((Agent)m_customAbilityBase.m_enemyAgent).GlobalID)
			{
				_phaseRegenTimer.Reset(6f);
				_isTimerDone = false;
				DecreasePhaseLevel(damage);
			}
		}

		private void DecreasePhaseLevel(float damage)
		{
			if (damage >= 100f)
			{
				m_currentPhaseLevel = Mathf.Lerp(m_currentPhaseLevel, m_minPhaseLevel, 0.15f);
				return;
			}
			float num = damage * 0.01f;
			m_currentPhaseLevel = Mathf.Clamp(Mathf.Lerp(m_currentPhaseLevel, m_currentPhaseLevel + num, 0.15f), m_minPhaseLevel, m_maxPhaseLevel);
		}

		private void IncreasePhaseLevel()
		{
			m_currentPhaseLevel = Mathf.Clamp(m_currentPhaseLevel - 0.01f, m_minPhaseLevel, m_maxPhaseLevel);
		}
	}
	public class CustomAbility_Phaser_Small : MonoBehaviour
	{
		private CustomEnemyAbilityBase m_customAbilityBase;

		private Timer _phaseRegenTimer;

		private bool _isTimerDone;

		public SkinnedMeshRenderer _meshRenderer;

		public bool EnableCloaking = true;

		private static float m_currentPhaseLevel = 0.5f;

		private static float m_minPhaseLevel = 0.05f;

		private static float m_maxPhaseLevel = 0.8f;

		private void Start()
		{
			m_customAbilityBase = ((Component)this).GetComponent<CustomEnemyAbilityBase>();
			SkinnedMeshRenderer component = ((Component)((Component)this).gameObject.transform.GetChild(3).GetChild(3)).GetComponent<SkinnedMeshRenderer>();
			_meshRenderer = component;
			EnemyDamageEvents.Damage += OnTakeDamage;
			m_customAbilityBase.m_enemyDamageBase.Owner.AddOnDeadOnce(delegate
			{
				EnemyDamageEvents.Damage -= OnTakeDamage;
			});
		}

		private void FixedUpdate()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (EnableCloaking && ((Agent)m_customAbilityBase.m_enemyAgent).Alive)
			{
				if (!_isTimerDone && _phaseRegenTimer.TickAndCheckDone())
				{
					_isTimerDone = true;
				}
				else if (_isTimerDone)
				{
					IncreasePhaseLevel();
				}
				Color color = ((Renderer)_meshRenderer).material.color;
				color.a = m_currentPhaseLevel;
				((Renderer)_meshRenderer).material.color = color;
			}
		}

		private void OnTakeDamage(EnemyAgent enemyAgent, Agent inflictor, float damage)
		{
			if (((Agent)enemyAgent).GlobalID == ((Agent)m_customAbilityBase.m_enemyAgent).GlobalID)
			{
				_phaseRegenTimer.Reset(3f);
				_isTimerDone = false;
				DecreasePhaseLevel(damage);
			}
		}

		private void DecreasePhaseLevel(float damage)
		{
			if (damage >= 100f)
			{
				m_currentPhaseLevel = Mathf.Lerp(m_currentPhaseLevel, m_minPhaseLevel, 0.15f);
				return;
			}
			float num = damage * 0.05f;
			m_currentPhaseLevel = Mathf.Clamp(Mathf.Lerp(m_currentPhaseLevel, m_currentPhaseLevel + num, 0.15f), m_minPhaseLevel, m_maxPhaseLevel);
		}

		private void IncreasePhaseLevel()
		{
			m_currentPhaseLevel = Mathf.Clamp(m_currentPhaseLevel - 0.015f, m_minPhaseLevel, m_maxPhaseLevel);
		}
	}
	public class CustomEnemyAbilityBase : MonoBehaviour
	{
		public EnemyAgent m_enemyAgent;

		public Dam_EnemyDamageBase m_enemyDamageBase;

		public void Setup()
		{
			m_enemyAgent = ((Component)this).GetComponent<EnemyAgent>();
			m_enemyDamageBase = ((Component)this).GetComponent<Dam_EnemyDamageBase>();
			if (((GameDataBlockBase<EnemyDataBlock>)(object)m_enemyAgent.EnemyData).persistentID == 503)
			{
				((Component)this).gameObject.AddComponent<CustomAbility_Phaser_Small>();
			}
			if (((GameDataBlockBase<EnemyDataBlock>)(object)m_enemyAgent.EnemyData).persistentID == 504)
			{
				((Component)this).gameObject.AddComponent<CustomAbility_Phaser_Big>();
			}
		}
	}
}