Decompiled source of LightEater v1.1.1

LightEater.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LegaFusionCore.Managers;
using LegaFusionCore.Managers.NetworkManagers;
using LegaFusionCore.Registries;
using LegaFusionCore.Utilities;
using LethalLib.Modules;
using LethalStatus.Managers;
using LethalStatus.StatusEffects;
using LightEater.Behaviours;
using LightEater.Behaviours.LightSystem.Factories;
using LightEater.Behaviours.LightSystem.Handlers.DeluminatorHandlers;
using LightEater.Behaviours.LightSystem.Handlers.LightEaterHandlers;
using LightEater.Behaviours.LightSystem.Interfaces;
using LightEater.Managers;
using LightEater.NetcodePatcher;
using LightEater.Patches;
using LightEater.Values;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LightEater")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LightEater")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4f6e7a3d-9f39-4466-b505-b6ce2e3133d4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 LightEater
{
	public class Constants
	{
		public const string GLOBAL = "_Global_";

		public const string ENEMIES_INTERACTIONS = "Enemies Interactions";

		public const string SHIP_INTERACTIONS = "Ship Interactions";

		public const string LIGHT_EATER = "Light Eater";

		public const string OLD_BIRD_NAME = "RadMech";

		public const string DELUMINATOR = "Deluminator";

		public const string IMPOSSIBLE_ACTION = "Impossible Action";

		public const string INFORMATION = "Information";

		public const string MESSAGE_INFO_WAIT_SHIP = "Cannot be used until the ship has landed";

		public const string MESSAGE_INFO_NO_LIGHT = "No targeted light source or unavailable charge";

		public const string MESSAGE_INFO_ABSORPTION_CANCELED = "Light source absorption cancelled out";

		public const string MESSAGE_INFO_MAX_CHARGES = "You have already reached the maximum number of charges for this item";

		public const string MESSAGE_DEFAULT_ITEM_CHARGER = "(Requires battery-powered item)";

		public const string SHIP_LIGHTS = "ShipElectricLights";
	}
	[BepInPlugin("Lega.LightEater", "Light Eater", "1.1.1")]
	public class LightEater : BaseUnityPlugin
	{
		internal const string modGUID = "Lega.LightEater";

		internal const string modName = "Light Eater";

		internal const string modVersion = "1.1.1";

		private readonly Harmony harmony = new Harmony("Lega.LightEater");

		private static readonly AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lighteater"));

		internal static ManualLogSource mls;

		public static ConfigFile configFile;

		public static GameObject deluminatorObj;

		public void Awake()
		{
			mls = Logger.CreateLogSource("LightEater");
			configFile = ((BaseUnityPlugin)this).Config;
			ConfigManager.Load();
			ConfigManager.GetEnemiesValues();
			NetcodePatcher();
			LoadEnemies();
			LoadItems();
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public static void LoadEnemies()
		{
			EnemyType val = bundle.LoadAsset<EnemyType>("Assets/LightEater/LightEaterEnemy.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			var (dictionary, dictionary2) = ConfigManager.GetEnemiesSpawns();
			Enemies.RegisterEnemy(val, dictionary, dictionary2, bundle.LoadAsset<TerminalNode>("Assets/LightEater/LightEaterTN.asset"), bundle.LoadAsset<TerminalKeyword>("Assets/LightEater/LightEaterTK.asset"));
		}

		public void LoadItems()
		{
			if (ConfigManager.isDeluminator.Value)
			{
				deluminatorObj = LFCObjectsManager.RegisterObject(typeof(Deluminator), bundle.LoadAsset<Item>("Assets/Deluminator/DeluminatorItem.asset")).spawnPrefab;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LightEater";

		public const string PLUGIN_NAME = "LightEater";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LightEater.Values
{
	public class EnemyValue
	{
		public string EnemyName { get; internal set; }

		public int AbsorbDistance { get; internal set; }

		public int AbsorbCharge { get; internal set; }

		public bool Destroy { get; internal set; }

		public EnemyValue(string enemyName, int absorbDistance, int absorbCharge, bool destroy)
		{
			EnemyName = enemyName;
			AbsorbDistance = absorbDistance;
			AbsorbCharge = absorbCharge;
			Destroy = destroy;
			base..ctor();
		}
	}
}
namespace LightEater.Patches
{
	internal class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPostfix]
		private static void ShipLeave()
		{
			Deluminator[] array = Object.FindObjectsOfType<Deluminator>();
			foreach (Deluminator deluminator in array)
			{
				deluminator.energyNetwork.StopHandleLightCoroutine(showMsg: false);
			}
			LightEaterAI[] array2 = Object.FindObjectsOfType<LightEaterAI>();
			foreach (LightEaterAI lightEaterAI in array2)
			{
				lightEaterAI.energyNetwork.StopHandleLightCoroutine(showMsg: false);
			}
		}
	}
}
namespace LightEater.Managers
{
	public class ConfigManager
	{
		public static List<EnemyValue> enemiesValues = new List<EnemyValue>();

		public static ConfigEntry<string> spawnWeights;

		public static ConfigEntry<bool> isDeluminator;

		public static ConfigEntry<int> damage;

		public static ConfigEntry<string> absorbedEnemies;

		public static ConfigEntry<int> shipMinHour;

		public static ConfigEntry<bool> disableShipLights;

		public static ConfigEntry<bool> disableShipScreen;

		public static ConfigEntry<bool> disableShipDoors;

		public static ConfigEntry<bool> disableShipLever;

		public static ConfigEntry<bool> disableTerminal;

		public static ConfigEntry<bool> disableItemCharger;

		public static ConfigEntry<bool> disableShipTV;

		public static ConfigEntry<bool> disableShipTeleporters;

		public static ConfigEntry<bool> disableSmartCupboard;

		public static void Load()
		{
			spawnWeights = LightEater.configFile.Bind<string>("_Global_", "Spawn weights", "Vanilla:20,Modded:20", "Light Eater spawn weights");
			isDeluminator = LightEater.configFile.Bind<bool>("_Global_", "Enable Deluminator", true, "Is Deluminator item enabled?");
			damage = LightEater.configFile.Bind<int>("_Global_", "Damage", 30, "Light Eater damage");
			absorbedEnemies = LightEater.configFile.Bind<string>("Enemies Interactions", "Enemies list", "RadMech:20:100:True,Boomba:5:20:False,Cleaning Drone:5:20:False,Mobile Turret:5:20:True,Shockwave Drone:5:20:True", "List of enemies that can be absorbed.\nThe format is 'EnemyName:AbsorbDistance:AbsorbCharge'.");
			shipMinHour = LightEater.configFile.Bind<int>("Ship Interactions", "Min hour", 9, "Hour at which the Light Eater can absorb the ship (between 1 and 18)");
			disableShipLights = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable lights", true, "Disable ship lights");
			disableShipScreen = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable screen", true, "Disable ship screen");
			disableShipDoors = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable doors", true, "Disable ship doors");
			disableShipLever = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable lever", false, "Disable ship lever");
			disableTerminal = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable terminal", true, "Disable terminal");
			disableItemCharger = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable item charger", true, "Disable item charger");
			disableShipTV = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable TV", true, "Disable TV");
			disableShipTeleporters = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable teleporters", true, "Disable ship teleporters");
			disableSmartCupboard = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable smart cupboard", true, "Disable smart cupboard (from SelfSortingStorage)");
		}

		public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) GetEnemiesSpawns()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in spawnWeights.Value.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
					}
					else
					{
						dictionary2[text] = result;
					}
				}
			}
			return (dictionary, dictionary2);
		}

		public static void GetEnemiesValues()
		{
			string[] array = absorbedEnemies.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(':');
				if (array3.Length == 4)
				{
					enemiesValues.Add(new EnemyValue(array3[0], int.Parse(array3[1]), int.Parse(array3[2]), bool.Parse(array3[3])));
				}
			}
		}
	}
	public class LightEnergyManager
	{
		public static object DetermineLightSource(GameObject lightSource)
		{
			ShipLights componentInChildren = lightSource.GetComponentInChildren<ShipLights>();
			if (componentInChildren == null)
			{
				GrabbableObject result = default(GrabbableObject);
				if (!lightSource.TryGetComponent<GrabbableObject>(ref result))
				{
					Turret componentInChildren2 = lightSource.GetComponentInChildren<Turret>();
					if (componentInChildren2 == null)
					{
						Landmine componentInChildren3 = lightSource.GetComponentInChildren<Landmine>();
						if (componentInChildren3 == null)
						{
							EnemyAI componentInChildren4 = lightSource.GetComponentInChildren<EnemyAI>();
							if (componentInChildren4 == null)
							{
								return RoundManager.Instance.allPoweredLightsAnimators?.FirstOrDefault((Func<Animator, bool>)((Animator l) => (Object)(object)((l != null) ? ((Component)l).gameObject : null) == (Object)(object)lightSource));
							}
							return componentInChildren4;
						}
						return componentInChildren3;
					}
					return componentInChildren2;
				}
				return result;
			}
			return componentInChildren;
		}

		public static bool CanBeAbsorbed(GrabbableObject grabbableObject, Vector3 position, float distance)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)grabbableObject != (Object)null && grabbableObject.itemProperties.requiresBattery)
			{
				Battery insertedBattery = grabbableObject.insertedBattery;
				if (insertedBattery != null && insertedBattery.charge > 0f)
				{
					return IsObjectClose(grabbableObject, position, distance);
				}
			}
			return false;
		}

		public static bool IsObjectClose(GrabbableObject grabbableObject, Vector3 position, float distance)
		{
			//IL_000d: 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_0046: 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)
			if (Vector3.Distance(position, ((Component)grabbableObject).transform.position) <= distance)
			{
				return true;
			}
			foreach (BeltBagItem allA in LFCSpawnRegistry.GetAllAs<BeltBagItem>())
			{
				if (!((Object)(object)allA == (Object)null) && !(Vector3.Distance(position, ((Component)allA).transform.position) > distance) && (Object)(object)((IEnumerable<GrabbableObject>)allA.objectsInBag).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject o) => (Object)(object)o == (Object)(object)grabbableObject)) != (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		public static void StunExplosion(Vector3 position, bool applyStatus, PlayerControllerB playerHeldBy = null, EnemyAI enemyWhoExplode = null)
		{
			//IL_00b9: 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_0089: 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_016c: 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)
			PlayerControllerB val = GameNetworkManager.Instance.localPlayerController;
			if (val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null)
			{
				val = GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript;
			}
			if ((Object)(object)val != (Object)(object)playerHeldBy && val.HasLineOfSightToPosition(position, 60f, 12, 4f, -1))
			{
				if (applyStatus)
				{
					LSNetworkManager.Instance.ApplyStatusEveryoneRpc(((Object)(object)playerHeldBy != (Object)null) ? ((int)playerHeldBy.playerClientId) : (-1), (int)val.playerClientId, 3, 10, 10, NetworkObjectReference.op_Implicit(((Object)(object)enemyWhoExplode != (Object)null) ? ((NetworkBehaviour)enemyWhoExplode).NetworkObject : null));
				}
				HUDManager.Instance.flashFilter = 1f;
				SoundManager.Instance.earsRingingTimer = 1f;
			}
			Collider[] array = (Collider[])(object)new Collider[64];
			int num = Physics.OverlapSphereNonAlloc(position, 12f, array, 524288, (QueryTriggerInteraction)2);
			EnemyAICollisionDetect val3 = default(EnemyAICollisionDetect);
			for (int i = 0; i < num; i++)
			{
				Collider val2 = array[i];
				if (!((Object)(object)val2 != (Object)null) || !LFCUtilities.TryGetComponentInParent<EnemyAICollisionDetect>(((Component)val2).gameObject, ref val3))
				{
					continue;
				}
				EnemyAI mainScript = val3.mainScript;
				if ((Object)(object)mainScript != (Object)null && (Object)(object)mainScript != (Object)(object)enemyWhoExplode && !mainScript.isEnemyDead && (Object)(object)((NetworkBehaviour)mainScript).NetworkObject != (Object)null && mainScript.CheckLineOfSightForPosition(position, 120f, 15, 4f, (Transform)null))
				{
					if (applyStatus)
					{
						LSNetworkManager.Instance.ApplyStatusEveryoneRpc(((Object)(object)playerHeldBy != (Object)null) ? ((int)playerHeldBy.playerClientId) : (-1), NetworkObjectReference.op_Implicit(((NetworkBehaviour)mainScript).NetworkObject), 3, 10, 100, NetworkObjectReference.op_Implicit(((Object)(object)enemyWhoExplode != (Object)null) ? ((NetworkBehaviour)enemyWhoExplode).NetworkObject : null));
					}
					mainScript.SetEnemyStunned(true, 1f, playerHeldBy);
				}
			}
		}
	}
	public class LightEnergyNetworkManager : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <HandleLightCoroutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LightEnergyNetworkManager <>4__this;

			private ILightSource <lightHandler>5__2;

			private bool <completed>5__3;

			private float <duration>5__4;

			private float <remainingDuration>5__5;

			private float <timePassed>5__6;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Expected O, but got Unknown
				int num = <>1__state;
				LightEnergyNetworkManager lightEnergyNetworkManager = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<timePassed>5__6 += 0.5f;
					if (!<lightHandler>5__2.HandleLightConsumption(<duration>5__4, <remainingDuration>5__5, <timePassed>5__6))
					{
						<completed>5__3 = false;
						goto IL_010f;
					}
				}
				else
				{
					<>1__state = -1;
					object obj = LightEnergyManager.DetermineLightSource(lightEnergyNetworkManager.closestLightSource);
					<lightHandler>5__2 = LightSourceFactory.GetLightHandler(obj, lightEnergyNetworkManager);
					if (<lightHandler>5__2 == null)
					{
						lightEnergyNetworkManager.StopHandleLightCoroutine(showMsg: false);
						return false;
					}
					<completed>5__3 = true;
					<duration>5__4 = ((obj is EnemyAI) ? 10f : 5f);
					<remainingDuration>5__5 = <duration>5__4;
					<timePassed>5__6 = 0f;
					lightEnergyNetworkManager.PlayActionSound?.Invoke();
					<lightHandler>5__2.HandleLightInitialization(ref <remainingDuration>5__5);
				}
				if (<timePassed>5__6 < <remainingDuration>5__5)
				{
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				}
				goto IL_010f;
				IL_010f:
				<lightHandler>5__2.HandleInterruptAction();
				if (<completed>5__3)
				{
					<lightHandler>5__2.HandleLightDepletion();
				}
				lightEnergyNetworkManager.ResetAction?.Invoke();
				lightEnergyNetworkManager.StopHandleLightCoroutine(showMsg: false);
				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 int currentCharge;

		public GameObject closestLightSource;

		public Coroutine handleLightCoroutine;

		public Action PlayActionSound;

		public Action StopActionSound;

		public Action ResetAction;

		public void HandleLight(GameObject lightSource)
		{
			//IL_0026: 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)
			if (handleLightCoroutine == null)
			{
				NetworkObject val = default(NetworkObject);
				if (LFCUtilities.TryGetComponentInParent<NetworkObject>(lightSource, ref val))
				{
					HandleLightEveryoneRpc(NetworkObjectReference.op_Implicit(val));
				}
				else
				{
					HandleLightEveryoneRpc(lightSource.transform.position);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void HandleLightEveryoneRpc(NetworkObjectReference obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: 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_0088: 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_00a0: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1400556278u, val2, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendRpc(ref val3, 1400556278u, val2, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val4 = default(NetworkObject);
				if (((NetworkObjectReference)(ref obj)).TryGet(ref val4, (NetworkManager)null))
				{
					closestLightSource = ((Component)val4).gameObject;
					handleLightCoroutine = ((MonoBehaviour)this).StartCoroutine(HandleLightCoroutine());
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void HandleLightEveryoneRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1142273148u, val2, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val3)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendRpc(ref val3, 1142273148u, val2, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					closestLightSource = GetPoweredLightByPosition(position);
					handleLightCoroutine = ((MonoBehaviour)this).StartCoroutine(HandleLightCoroutine());
				}
			}
		}

		public GameObject GetPoweredLightByPosition(Vector3 position)
		{
			//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)
			List<Animator> allPoweredLightsAnimators = RoundManager.Instance.allPoweredLightsAnimators;
			if (allPoweredLightsAnimators == null)
			{
				return null;
			}
			return ((Component)allPoweredLightsAnimators.OrderBy((Animator p) => (!((Object)(object)p != (Object)null)) ? float.MaxValue : Vector3.Distance(position, ((Component)p).transform.position)).FirstOrDefault()).gameObject;
		}

		[IteratorStateMachine(typeof(<HandleLightCoroutine>d__10))]
		public IEnumerator HandleLightCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HandleLightCoroutine>d__10(0)
			{
				<>4__this = this
			};
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void StopHandleLightEveryoneRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(349786453u, val2, val, (SendTo)6, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val3, 349786453u, val2, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					StopHandleLightCoroutine();
				}
			}
		}

		public void StopHandleLightCoroutine(bool showMsg = true)
		{
			if (handleLightCoroutine != null)
			{
				StopActionSound?.Invoke();
				if ((Object)(object)closestLightSource != (Object)null)
				{
					LightSourceFactory.GetLightHandler(LightEnergyManager.DetermineLightSource(closestLightSource), this)?.HandleInterruptAction();
					closestLightSource = null;
				}
				if (showMsg && LFCUtilities.ShouldBeLocalPlayer(((GrabbableObject)(((Component)this).GetComponentInParent<Deluminator>()?)).playerHeldBy))
				{
					HUDManager.Instance.DisplayTip("Information", "Light source absorption cancelled out", false, false, "LC_Tip1");
				}
				((MonoBehaviour)this).StopCoroutine(handleLightCoroutine);
				handleLightCoroutine = null;
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1400556278u, new RpcReceiveHandler(__rpc_handler_1400556278), "HandleLightEveryoneRpc");
			((NetworkBehaviour)this).__registerRpc(1142273148u, new RpcReceiveHandler(__rpc_handler_1142273148), "HandleLightEveryoneRpc");
			((NetworkBehaviour)this).__registerRpc(349786453u, new RpcReceiveHandler(__rpc_handler_349786453), "StopHandleLightEveryoneRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1400556278(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEnergyNetworkManager)(object)target).HandleLightEveryoneRpc(obj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1142273148(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEnergyNetworkManager)(object)target).HandleLightEveryoneRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_349786453(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEnergyNetworkManager)(object)target).StopHandleLightEveryoneRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "LightEnergyNetworkManager";
		}
	}
}
namespace LightEater.Behaviours
{
	public class Deluminator : PhysicsProp
	{
		public LightEnergyNetworkManager energyNetwork;

		public AudioSource ActionAudio;

		public AudioClip ActionSound;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			energyNetwork.PlayActionSound = delegate
			{
				ActionAudio.PlayOneShot(ActionSound);
				ActionAudio.pitch = 1f;
			};
			energyNetwork.StopActionSound = ActionAudio.Stop;
			energyNetwork.ResetAction = delegate
			{
				if (LFCUtilities.ShouldBeLocalPlayer(((GrabbableObject)this).playerHeldBy))
				{
					((GrabbableObject)this).SetControlTipsForItem();
				}
			};
		}

		public override void EquipItem()
		{
			((PhysicsProp)this).EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.activatingItem = false;
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			energyNetwork.StopHandleLightEveryoneRpc();
		}

		public override void DiscardItem()
		{
			energyNetwork.StopHandleLightEveryoneRpc();
			((GrabbableObject)this).DiscardItem();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				StartAbsorption();
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			//IL_004c: 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)
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!right && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && energyNetwork.currentCharge >= 100)
			{
				energyNetwork.currentCharge = Mathf.Max(0, energyNetwork.currentCharge - 100);
				LightEnergyManager.StunExplosion(((Component)this).transform.position, applyStatus: true, ((GrabbableObject)this).playerHeldBy);
				StunExplosionEveryoneRpc(((Component)this).transform.position);
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void StunExplosionEveryoneRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(883547727u, val2, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val3)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendRpc(ref val3, 883547727u, val2, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (LFCUtilities.ShouldNotBeLocalPlayer(((GrabbableObject)this).playerHeldBy))
				{
					LightEnergyManager.StunExplosion(position, applyStatus: true, ((GrabbableObject)this).playerHeldBy);
					energyNetwork.currentCharge = Mathf.Max(0, energyNetwork.currentCharge - 100);
				}
			}
		}

		public void StartAbsorption()
		{
			if (!StartOfRound.Instance.shipHasLanded)
			{
				HUDManager.Instance.DisplayTip("Impossible Action", "Cannot be used until the ship has landed", false, false, "LC_Tip1");
				return;
			}
			if (energyNetwork.handleLightCoroutine != null)
			{
				energyNetwork.StopHandleLightEveryoneRpc();
				return;
			}
			if (energyNetwork.currentCharge >= 200)
			{
				HUDManager.Instance.DisplayTip("Impossible Action", "You have already reached the maximum number of charges for this item", false, false, "LC_Tip1");
				return;
			}
			energyNetwork.closestLightSource = GetClosestLightSourceInView();
			if ((Object)(object)energyNetwork.closestLightSource == (Object)null)
			{
				HUDManager.Instance.DisplayTip("Impossible Action", "No targeted light source or unavailable charge", false, false, "LC_Tip1");
			}
			else
			{
				energyNetwork.HandleLight(energyNetwork.closestLightSource);
			}
		}

		public GameObject GetClosestLightSourceInView()
		{
			//IL_0010: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.SphereCastAll(new Ray(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward), 2f, 5f);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit hit = array[i];
				List<EnemyAI> allAs = LFCSpawnRegistry.GetAllAs<EnemyAI>();
				object obj;
				if (allAs == null)
				{
					obj = null;
				}
				else
				{
					EnemyAI? obj2 = ((IEnumerable<EnemyAI>)allAs).FirstOrDefault((Func<EnemyAI, bool>)((EnemyAI e) => !e.isEnemyDead && ConfigManager.enemiesValues.Select((EnemyValue v) => v.EnemyName).Contains(e.enemyType.enemyName) && (Object)(object)e == (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<EnemyAI>()));
					obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
				}
				if (obj == null)
				{
					List<GrabbableObject> allAs2 = LFCSpawnRegistry.GetAllAs<GrabbableObject>();
					if (allAs2 == null)
					{
						obj = null;
					}
					else
					{
						GrabbableObject? obj3 = ((IEnumerable<GrabbableObject>)allAs2).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject g) => CanBeAbsorbed(g) && (Object)(object)g == (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<GrabbableObject>()));
						obj = ((obj3 != null) ? ((Component)obj3).gameObject : null);
					}
					if (obj == null)
					{
						HashSet<Component> setExact = LFCSpawnRegistry.GetSetExact<Turret>();
						if (setExact == null)
						{
							obj = null;
						}
						else
						{
							IEnumerable<Turret> enumerable = setExact.Cast<Turret>();
							if (enumerable == null)
							{
								obj = null;
							}
							else
							{
								Turret? obj4 = enumerable.FirstOrDefault((Func<Turret, bool>)((Turret t) => (Object)(object)t != (Object)null && t.turretActive && (Object)(object)t == (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<Turret>()));
								obj = ((obj4 != null) ? ((Component)obj4).gameObject : null);
							}
						}
						if (obj == null)
						{
							HashSet<Component> setExact2 = LFCSpawnRegistry.GetSetExact<Landmine>();
							if (setExact2 == null)
							{
								obj = null;
							}
							else
							{
								IEnumerable<Landmine> enumerable2 = setExact2.Cast<Landmine>();
								if (enumerable2 == null)
								{
									obj = null;
								}
								else
								{
									Landmine? obj5 = enumerable2.FirstOrDefault((Func<Landmine, bool>)((Landmine l) => (Object)(object)l != (Object)null && l.mineActivated && (Object)(object)l == (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<Landmine>()));
									obj = ((obj5 != null) ? ((Component)obj5).gameObject : null);
								}
							}
							if (obj == null)
							{
								List<Animator> allPoweredLightsAnimators = RoundManager.Instance.allPoweredLightsAnimators;
								if (allPoweredLightsAnimators == null)
								{
									obj = null;
								}
								else
								{
									Animator? obj6 = ((IEnumerable<Animator>)allPoweredLightsAnimators).FirstOrDefault((Func<Animator, bool>)((Animator p) => (Object)(object)p != (Object)null && !LFCPoweredLightsRegistry.IsLocked(p) && (Object)(object)p == (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<Animator>()));
									obj = ((obj6 != null) ? ((Component)obj6).gameObject : null);
								}
							}
						}
					}
				}
				GameObject val = (GameObject)obj;
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		public bool CanBeAbsorbed(GrabbableObject grabbableObject)
		{
			if ((Object)(object)grabbableObject != (Object)null && grabbableObject.itemProperties.requiresBattery && grabbableObject.insertedBattery != null)
			{
				return grabbableObject.insertedBattery.charge > 0f;
			}
			return false;
		}

		public override void SetControlTipsForItem()
		{
			((GrabbableObject)this).itemProperties.toolTips[2] = $"[Charges : {energyNetwork.currentCharge}]";
			HUDManager.Instance.ChangeControlTipMultiple(((GrabbableObject)this).itemProperties.toolTips, true, ((GrabbableObject)this).itemProperties);
		}

		protected override void __initializeVariables()
		{
			((PhysicsProp)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(883547727u, new RpcReceiveHandler(__rpc_handler_883547727), "StunExplosionEveryoneRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

		private static void __rpc_handler_883547727(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Deluminator)(object)target).StunExplosionEveryoneRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "Deluminator";
		}
	}
	public class LightEaterAI : EnemyAI
	{
		public enum State
		{
			WANDERING,
			HUNTING,
			ABSORBING,
			CHASING
		}

		public enum Sound
		{
			ABSORPTION,
			SWING,
			CHARGE,
			EXPLOSION
		}

		[CompilerGenerated]
		private sealed class <StunExplosionCoroutine>d__22 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LightEaterAI <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				LightEaterAI lightEaterAI = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					lightEaterAI.DoAnimationEveryoneRpc("startExplode");
					lightEaterAI.PlayAudioEveryoneRpc(2);
					<>2__current = LFCEnemyManager.WaitForFullAnimation((EnemyAI)(object)lightEaterAI, "explode", 10f, 0);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					lightEaterAI.PlayAudioEveryoneRpc(3);
					lightEaterAI.DoAnimationEveryoneRpc("startMove");
					lightEaterAI.StunExplosionEveryoneRpc(((EnemyAI)lightEaterAI).eye.position, applyStatus: true);
					lightEaterAI.stunCoroutine = null;
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <SwingCoroutine>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LightEaterAI <>4__this;

			public int playerId;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				LightEaterAI lightEaterAI = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					lightEaterAI.DoAnimationEveryoneRpc("startSwing");
					lightEaterAI.PlayAudioEveryoneRpc(1);
					<>2__current = LFCEnemyManager.WaitForFullAnimation((EnemyAI)(object)lightEaterAI, "swing", 10f, 0);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					LFCNetworkManager.Instance.DamagePlayerEveryoneRpc(playerId, ConfigManager.damage.Value, true, true, 8);
					lightEaterAI.DoAnimationEveryoneRpc("startMove");
					if (StartOfRound.Instance.allPlayerObjects[playerId].GetComponent<PlayerControllerB>().isPlayerDead)
					{
						((EnemyAI)lightEaterAI).StartSearch(((Component)lightEaterAI).transform.position, (AISearchRoutine)null);
						((EnemyAI)lightEaterAI).SwitchToBehaviourClientRpc(0);
					}
					lightEaterAI.swingCoroutine = null;
					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 LightEnergyNetworkManager energyNetwork;

		public Transform TurnCompass;

		public AudioClip[] MoveSounds = Array.Empty<AudioClip>();

		public AudioClip[] LightEaterSounds = Array.Empty<AudioClip>();

		public int absorbDistance = 5;

		public float moveTimer;

		public Coroutine stunCoroutine;

		public Coroutine swingCoroutine;

		public override void Start()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			energyNetwork.PlayActionSound = delegate
			{
				base.creatureSFX.PlayOneShot(LightEaterSounds[0]);
				base.creatureSFX.pitch = 1f;
			};
			energyNetwork.StopActionSound = base.creatureSFX.Stop;
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_004e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			((EnemyAI)this).Update();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				PlayMoveSound();
				if ((Object)(object)base.targetPlayer != (Object)null && base.currentBehaviourStateIndex == 3)
				{
					TurnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
					((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, TurnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
				}
			}
		}

		public void PlayMoveSound()
		{
			if (base.currentBehaviourStateIndex != 2)
			{
				moveTimer -= Time.deltaTime;
				if (MoveSounds.Length != 0 && moveTimer <= 0f)
				{
					base.creatureSFX.PlayOneShot(MoveSounds[Random.Range(0, MoveSounds.Length)]);
					moveTimer = 3f;
				}
			}
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					DoWandering();
					break;
				case 1:
					DoHunting();
					break;
				case 2:
					DoAbsorbing();
					break;
				case 3:
					DoChasing();
					break;
				}
			}
		}

		public void DoWandering()
		{
			base.agent.speed = 2f;
			if (LFCEnemyManager.FoundClosestPlayerInRange((EnemyAI)(object)this, 25, 10, 60f, false))
			{
				energyNetwork.closestLightSource = null;
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
			else if (FoundLightSource())
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}

		public bool FoundLightSource()
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			if (CrossingLight())
			{
				return true;
			}
			if (CanAbsorbShip())
			{
				absorbDistance = 20;
				energyNetwork.closestLightSource = ((Component)StartOfRound.Instance.shipRoomLights).gameObject;
				return (Object)(object)energyNetwork.closestLightSource != (Object)null;
			}
			IEnumerable<EnemyAI> source = LFCSpawnRegistry.GetAllAs<EnemyAI>()?.Where((EnemyAI e) => !e.isEnemyDead && ConfigManager.enemiesValues.Select((EnemyValue v) => v.EnemyName).Contains(e.enemyType.enemyName));
			if (source.Any())
			{
				EnemyAI closestEnemy = source.OrderBy((EnemyAI r) => Vector3.Distance(((Component)this).transform.position, ((Component)r).transform.position)).FirstOrDefault();
				absorbDistance = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(closestEnemy.enemyType.enemyName))?.AbsorbDistance ?? 5;
				energyNetwork.closestLightSource = ((Component)closestEnemy).gameObject;
				return (Object)(object)energyNetwork.closestLightSource != (Object)null;
			}
			absorbDistance = 5;
			if (!base.isOutside)
			{
				base.path1 = new NavMeshPath();
				LightEnergyNetworkManager lightEnergyNetworkManager = energyNetwork;
				List<Animator> allPoweredLightsAnimators = RoundManager.Instance.allPoweredLightsAnimators;
				object closestLightSource;
				if (allPoweredLightsAnimators == null)
				{
					closestLightSource = null;
				}
				else
				{
					Animator? obj = (from p in allPoweredLightsAnimators
						where (Object)(object)p != (Object)null && !LFCPoweredLightsRegistry.IsLocked(p) && base.agent.CalculatePath(((EnemyAI)this).ChooseClosestNodeToPosition(((Component)p).transform.position, false, 0).position, base.path1)
						orderby Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position)
						select p).FirstOrDefault();
					closestLightSource = ((obj != null) ? ((Component)obj).gameObject : null);
				}
				lightEnergyNetworkManager.closestLightSource = (GameObject)closestLightSource;
			}
			else
			{
				LightEnergyNetworkManager lightEnergyNetworkManager2 = energyNetwork;
				List<Animator> allPoweredLightsAnimators2 = RoundManager.Instance.allPoweredLightsAnimators;
				object closestLightSource2;
				if (allPoweredLightsAnimators2 == null)
				{
					closestLightSource2 = null;
				}
				else
				{
					Animator? obj2 = (from p in allPoweredLightsAnimators2
						where (Object)(object)p != (Object)null && !LFCPoweredLightsRegistry.IsLocked(p)
						orderby (!Object.op_Implicit((Object)(object)p)) ? float.MaxValue : Vector3.Distance(LFCEnemyManager.GetEntranceExitPosition(LFCEnemyManager.GetClosestEntrance((EnemyAI)(object)this)), ((Component)p).transform.position)
						select p).FirstOrDefault();
					closestLightSource2 = ((obj2 != null) ? ((Component)obj2).gameObject : null);
				}
				lightEnergyNetworkManager2.closestLightSource = (GameObject)closestLightSource2;
			}
			return (Object)(object)energyNetwork.closestLightSource != (Object)null;
		}

		public bool CanAbsorbShip()
		{
			if (TimeOfDay.Instance.hour >= ConfigManager.shipMinHour.Value)
			{
				if ((!ConfigManager.disableShipLights.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)0)) && (!ConfigManager.disableShipScreen.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)1)) && (!ConfigManager.disableShipDoors.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)2)) && (!ConfigManager.disableShipLever.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)3)) && (!ConfigManager.disableTerminal.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)4)) && (!ConfigManager.disableItemCharger.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)5)) && (!ConfigManager.disableShipTV.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)6)) && (!ConfigManager.disableShipTeleporters.Value || LFCShipFeatureRegistry.IsLocked((ShipFeatureType)7)))
				{
					if (ConfigManager.disableSmartCupboard.Value)
					{
						return !LFCShipFeatureRegistry.IsLocked((ShipFeatureType)8);
					}
					return false;
				}
				return true;
			}
			return false;
		}

		public void DoHunting()
		{
			base.agent.speed = 4f;
			if (LFCEnemyManager.FoundClosestPlayerInRange((EnemyAI)(object)this, 25, 10, 60f, false))
			{
				energyNetwork.closestLightSource = null;
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
			else if (CloseToLightSource())
			{
				DoAnimationEveryoneRpc("startAbsorb");
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
		}

		public bool CloseToLightSource()
		{
			//IL_0067: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			CrossingLight();
			object obj = LightEnergyManager.DetermineLightSource(energyNetwork.closestLightSource);
			if (!(obj is ShipLights) || base.isOutside)
			{
				EnemyAI val = (EnemyAI)((obj is EnemyAI) ? obj : null);
				if ((val == null || val.isOutside == base.isOutside) && (!(obj is Animator) || !base.isOutside))
				{
					ILightSource lightHandler = LightSourceFactory.GetLightHandler(obj, this);
					if (lightHandler == null)
					{
						return false;
					}
					((EnemyAI)this).SetDestinationToPosition(lightHandler.GetClosestNodePosition(), false);
					if (!(Vector3.Distance(((Component)base.eye).transform.position, lightHandler.GetClosestLightPosition()) < (float)absorbDistance))
					{
						return Vector3.Distance(((Component)this).transform.position, lightHandler.GetClosestNodePosition()) < 1f;
					}
					return true;
				}
			}
			LFCEnemyManager.GoTowardsEntrance((EnemyAI)(object)this);
			return false;
		}

		public void DoAbsorbing()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			if ((Object)(object)energyNetwork.closestLightSource == (Object)null || !StartOfRound.Instance.shipHasLanded)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				DoAnimationEveryoneRpc("startMove");
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			else
			{
				energyNetwork.HandleLight(energyNetwork.closestLightSource);
			}
		}

		public void DoChasing()
		{
			//IL_0069: 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)
			if (stunCoroutine != null || swingCoroutine != null)
			{
				return;
			}
			base.agent.speed = 5f;
			if (LFCEnemyManager.TargetOutsideChasedPlayer((EnemyAI)(object)this))
			{
				return;
			}
			float num = default(float);
			if (!LFCEnemyManager.TargetClosestPlayerInAnyCase((EnemyAI)(object)this, ref num, false) || (num > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				return;
			}
			if (!LSStatusEffectRegistry.HasStatus(((Component)base.targetPlayer).gameObject, (StatusEffectType)3))
			{
				if (StunExplosion())
				{
					return;
				}
				if (CrossingLight())
				{
					DoAnimationEveryoneRpc("startAbsorb");
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					return;
				}
			}
			((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
		}

		public bool StunExplosion()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (energyNetwork.currentCharge >= 100 && base.targetPlayer.HasLineOfSightToPosition(base.eye.position, 60f, 12, 2f, -1))
			{
				base.agent.speed = 0f;
				energyNetwork.currentCharge -= 100;
				stunCoroutine = ((MonoBehaviour)this).StartCoroutine(StunExplosionCoroutine());
				return true;
			}
			return false;
		}

		[IteratorStateMachine(typeof(<StunExplosionCoroutine>d__22))]
		public IEnumerator StunExplosionCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StunExplosionCoroutine>d__22(0)
			{
				<>4__this = this
			};
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void StunExplosionEveryoneRpc(Vector3 position, bool applyStatus)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2747428478u, val2, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val3)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref applyStatus, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendRpc(ref val3, 2747428478u, val2, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					LightEnergyManager.StunExplosion(position, applyStatus, null, (EnemyAI)(object)this);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!base.isEnemyDead && base.currentBehaviourStateIndex == 3 && stunCoroutine == null && swingCoroutine == null)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (LFCUtilities.ShouldBeLocalPlayer(val))
				{
					SwingServerRpc((int)val.playerClientId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwingServerRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1448657909u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1448657909u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (swingCoroutine == null)
				{
					swingCoroutine = ((MonoBehaviour)this).StartCoroutine(SwingCoroutine(playerId));
				}
			}
		}

		[IteratorStateMachine(typeof(<SwingCoroutine>d__26))]
		public IEnumerator SwingCoroutine(int playerId)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SwingCoroutine>d__26(0)
			{
				<>4__this = this,
				playerId = playerId
			};
		}

		public bool CrossingLight()
		{
			List<Animator> allPoweredLightsAnimators = RoundManager.Instance.allPoweredLightsAnimators;
			object obj;
			if (allPoweredLightsAnimators == null)
			{
				obj = null;
			}
			else
			{
				Animator? obj2 = ((IEnumerable<Animator>)allPoweredLightsAnimators).FirstOrDefault((Func<Animator, bool>)((Animator p) => (Object)(object)p != (Object)null && !LFCPoweredLightsRegistry.IsLocked(p) && Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position) <= 10f));
				obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			}
			if (obj == null)
			{
				List<GrabbableObject> allAs = LFCSpawnRegistry.GetAllAs<GrabbableObject>();
				if (allAs == null)
				{
					obj = null;
				}
				else
				{
					GrabbableObject? obj3 = ((IEnumerable<GrabbableObject>)allAs).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject g) => LightEnergyManager.CanBeAbsorbed(g, ((Component)this).transform.position, 10f)));
					obj = ((obj3 != null) ? ((Component)obj3).gameObject : null);
				}
				if (obj == null)
				{
					HashSet<Component> setExact = LFCSpawnRegistry.GetSetExact<Turret>();
					if (setExact == null)
					{
						obj = null;
					}
					else
					{
						IEnumerable<Turret> enumerable = setExact.Cast<Turret>();
						if (enumerable == null)
						{
							obj = null;
						}
						else
						{
							Turret? obj4 = enumerable.FirstOrDefault((Func<Turret, bool>)((Turret t) => (Object)(object)t != (Object)null && t.turretActive && Vector3.Distance(((Component)this).transform.position, ((Component)t).transform.position) <= 10f));
							obj = ((obj4 != null) ? ((Component)obj4).gameObject : null);
						}
					}
					if (obj == null)
					{
						HashSet<Component> setExact2 = LFCSpawnRegistry.GetSetExact<Landmine>();
						if (setExact2 == null)
						{
							obj = null;
						}
						else
						{
							IEnumerable<Landmine> enumerable2 = setExact2.Cast<Landmine>();
							if (enumerable2 == null)
							{
								obj = null;
							}
							else
							{
								Landmine? obj5 = enumerable2.FirstOrDefault((Func<Landmine, bool>)((Landmine l) => (Object)(object)l != (Object)null && l.mineActivated && Vector3.Distance(((Component)this).transform.position, ((Component)l).transform.position) <= 10f));
								obj = ((obj5 != null) ? ((Component)obj5).gameObject : null);
							}
						}
					}
				}
			}
			GameObject val = (GameObject)obj;
			if ((Object)(object)val != (Object)null)
			{
				absorbDistance = 5;
				energyNetwork.closestLightSource = val;
			}
			return (Object)(object)energyNetwork.closestLightSource != (Object)null;
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return;
			}
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (energyNetwork.currentCharge > 0)
				{
					StunExplosionEveryoneRpc(base.eye.position, energyNetwork.currentCharge >= 100);
				}
				if (base.enemyHP <= 0)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
				energyNetwork.currentCharge = 0;
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			//IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).KillEnemy(false);
			if (LFCUtilities.IsServer && ConfigManager.isDeluminator.Value)
			{
				LFCObjectsManager.SpawnObjectForServer(LightEater.deluminatorObj, ((Component)this).transform.position + Vector3.up * 0.5f);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void PlayAudioEveryoneRpc(int enemySound)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(453609561u, val2, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val3, enemySound);
				((NetworkBehaviour)this).__endSendRpc(ref val3, 453609561u, val2, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (LightEaterSounds.Length != 0)
				{
					base.creatureSFX.PlayOneShot(LightEaterSounds[enemySound]);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void DoAnimationEveryoneRpc(string animationState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(40964250u, val2, val, (SendTo)6, (RpcDelivery)0);
				bool flag = animationState != null;
				((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val3)).WriteValueSafe(animationState, false);
				}
				((NetworkBehaviour)this).__endSendRpc(ref val3, 40964250u, val2, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetTrigger(animationState);
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2747428478u, new RpcReceiveHandler(__rpc_handler_2747428478), "StunExplosionEveryoneRpc");
			((NetworkBehaviour)this).__registerRpc(1448657909u, new RpcReceiveHandler(__rpc_handler_1448657909), "SwingServerRpc");
			((NetworkBehaviour)this).__registerRpc(453609561u, new RpcReceiveHandler(__rpc_handler_453609561), "PlayAudioEveryoneRpc");
			((NetworkBehaviour)this).__registerRpc(40964250u, new RpcReceiveHandler(__rpc_handler_40964250), "DoAnimationEveryoneRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_2747428478(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				bool applyStatus = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref applyStatus, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEaterAI)(object)target).StunExplosionEveryoneRpc(position, applyStatus);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1448657909(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEaterAI)(object)target).SwingServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_453609561(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int enemySound = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref enemySound);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEaterAI)(object)target).PlayAudioEveryoneRpc(enemySound);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_40964250(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationState = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationState, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEaterAI)(object)target).DoAnimationEveryoneRpc(animationState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "LightEaterAI";
		}
	}
}
namespace LightEater.Behaviours.LightSystem.Interfaces
{
	public interface ILightSource
	{
		void HandleLightInitialization(ref float remainingDuration);

		bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed);

		void HandleLightDepletion();

		void HandleInterruptAction();

		Vector3 GetClosestNodePosition();

		Vector3 GetClosestLightPosition();
	}
}
namespace LightEater.Behaviours.LightSystem.Handlers
{
	public class AnimatorHandler : ILightSource
	{
		protected readonly Animator animator;

		protected AnimatorHandler(Animator animator)
		{
			this.animator = animator;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			Animator obj = animator;
			if (obj != null)
			{
				obj.SetTrigger("Flicker");
			}
			return true;
		}

		public virtual void HandleLightDepletion()
		{
			LFCPoweredLightsRegistry.AddLock(animator, "Light Eater");
		}

		public virtual void HandleInterruptAction()
		{
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)animator).transform.position;
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)animator).transform.position;
		}
	}
	public class EnemyHandler : ILightSource
	{
		protected readonly EnemyAI enemy;

		protected EnemyHandler(EnemyAI enemy)
		{
			this.enemy = enemy;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			EnemyAI obj = enemy;
			RadMechAI val = (RadMechAI)(object)((obj is RadMechAI) ? obj : null);
			if (val != null)
			{
				val.FlickerFace();
				if (val.inFlyingMode)
				{
					return false;
				}
			}
			return !enemy.isEnemyDead;
		}

		public virtual void HandleLightDepletion()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (LFCUtilities.IsServer && !enemy.isEnemyDead)
			{
				string enemyName = enemy.enemyType.enemyName;
				if (enemyName == "RadMech")
				{
					GameObject val = Object.Instantiate<GameObject>(enemy.enemyType.nestSpawnPrefab, ((Component)enemy).transform.position, ((Component)enemy).transform.rotation);
					val.GetComponentInChildren<NetworkObject>().Spawn(true);
				}
				EnemyValue enemyValue = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(enemy.enemyType.enemyName));
				enemy.KillEnemyOnOwnerClient(enemyValue?.Destroy ?? true);
			}
		}

		public virtual void HandleInterruptAction()
		{
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)enemy).transform.position;
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)enemy).transform.position;
		}
	}
	public class GrabbableObjectHandler : ILightSource
	{
		protected readonly GrabbableObject grabbableObject;

		protected GrabbableObjectHandler(GrabbableObject grabbableObject)
		{
			this.grabbableObject = grabbableObject;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
			remainingDuration *= grabbableObject.insertedBattery.charge;
			GrabbableObject obj = grabbableObject;
			FlashlightItem val = (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null);
			if (val != null)
			{
				LFCObjectStateRegistry.AddFlickeringFlashlight(val, "Light Eater");
			}
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			grabbableObject.insertedBattery.charge = Mathf.Max(0f, 1f - (timePassed + (absorbDuration - remainingDuration)) / absorbDuration);
			return true;
		}

		public virtual void HandleLightDepletion()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			grabbableObject.insertedBattery = new Battery(true, 0f);
			grabbableObject.ChargeBatteries();
			grabbableObject.isBeingUsed = false;
		}

		public virtual void HandleInterruptAction()
		{
			GrabbableObject obj = grabbableObject;
			FlashlightItem val = (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null);
			if (val != null)
			{
				LFCObjectStateRegistry.RemoveFlickeringFlashlight(val, "Light Eater");
				val.SwitchFlashlight(false);
			}
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetObjectPosition();
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetObjectPosition();
		}

		protected Vector3 GetObjectPosition()
		{
			//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_0073: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)grabbableObject).transform.position;
			foreach (BeltBagItem allA in LFCSpawnRegistry.GetAllAs<BeltBagItem>())
			{
				if ((Object)(object)allA != (Object)null && (Object)(object)((IEnumerable<GrabbableObject>)allA.objectsInBag).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject o) => (Object)(object)o == (Object)(object)grabbableObject)) != (Object)null)
				{
					position = ((Component)allA).transform.position;
				}
			}
			return position;
		}
	}
	public class LandmineHandler : ILightSource
	{
		protected readonly Landmine landmine;

		protected LandmineHandler(Landmine landmine)
		{
			this.landmine = landmine;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			return true;
		}

		public virtual void HandleLightDepletion()
		{
			landmine.ToggleMineEnabledLocalClient(false);
		}

		public virtual void HandleInterruptAction()
		{
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)landmine).transform.position;
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)landmine).transform.position;
		}
	}
	public class ShipLightsHandler : ILightSource
	{
		protected Animator shipAnimator;

		protected Animator shipDoorsAnimator;

		protected AudioSource shipDoorsAudio;

		protected Vector3 shipPosition;

		protected ShipLightsHandler()
		{
			//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)
			shipAnimator = ((Component)StartOfRound.Instance.shipAnimatorObject).gameObject.GetComponent<Animator>();
			shipDoorsAnimator = StartOfRound.Instance.shipDoorsAnimator;
			shipDoorsAudio = StartOfRound.Instance.shipDoorAudioSource;
			shipPosition = StartOfRound.Instance.shipLandingPosition.position;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
			StartOfRound.Instance.PowerSurgeShip();
			shipAnimator.SetBool("AlarmRinging", true);
			shipDoorsAudio.PlayOneShot(StartOfRound.Instance.alarmSFX);
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			shipDoorsAnimator.SetBool("Closed", !shipDoorsAnimator.GetBool("Closed"));
			return true;
		}

		public virtual void HandleLightDepletion()
		{
			if (ConfigManager.disableShipLights.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)0, "Light Eater");
			}
			if (ConfigManager.disableShipScreen.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)1, "Light Eater");
			}
			if (ConfigManager.disableShipDoors.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)2, "Light Eater");
			}
			if (ConfigManager.disableShipLever.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)3, "Light Eater");
			}
			if (ConfigManager.disableTerminal.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)4, "Light Eater");
			}
			if (ConfigManager.disableItemCharger.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)5, "Light Eater");
			}
			if (ConfigManager.disableShipTV.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)6, "Light Eater");
			}
			if (ConfigManager.disableShipTeleporters.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)7, "Light Eater");
			}
			if (ConfigManager.disableSmartCupboard.Value)
			{
				LFCShipFeatureRegistry.AddLock((ShipFeatureType)8, "Light Eater");
			}
			HandleInterruptAction();
		}

		public virtual void HandleInterruptAction()
		{
			shipAnimator.SetBool("Closed", false);
			shipDoorsAudio.Stop();
			shipAnimator.SetBool("AlarmRinging", false);
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return shipPosition;
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return shipPosition;
		}
	}
	public class TurretHandler : ILightSource
	{
		protected readonly Turret turret;

		protected TurretHandler(Turret turret)
		{
			this.turret = turret;
		}

		public virtual void HandleLightInitialization(ref float remainingDuration)
		{
		}

		public virtual bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			turret.SwitchTurretMode(3);
			return true;
		}

		public virtual void HandleLightDepletion()
		{
			turret.ToggleTurretEnabledLocalClient(false);
			turret.mainAudio.Stop();
			turret.farAudio.Stop();
			turret.berserkAudio.Stop();
			if (turret.fadeBulletAudioCoroutine != null)
			{
				((MonoBehaviour)turret).StopCoroutine(turret.fadeBulletAudioCoroutine);
			}
			turret.fadeBulletAudioCoroutine = ((MonoBehaviour)turret).StartCoroutine(turret.FadeBulletAudio());
			turret.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
			turret.turretAnimator.SetInteger("TurretMode", 0);
		}

		public virtual void HandleInterruptAction()
		{
		}

		public virtual Vector3 GetClosestNodePosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)turret).transform.position;
		}

		public virtual Vector3 GetClosestLightPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)turret).transform.position;
		}
	}
}
namespace LightEater.Behaviours.LightSystem.Handlers.LightEaterHandlers
{
	public class AnimatorHandler : global::LightEater.Behaviours.LightSystem.Handlers.AnimatorHandler
	{
		private readonly LightEaterAI lightEater;

		public AnimatorHandler(LightEaterAI lightEater, Animator animator)
		{
			this.lightEater = lightEater;
			base..ctor(animator);
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			lightEater.energyNetwork.currentCharge += 20;
		}

		public override Vector3 GetClosestNodePosition()
		{
			//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)
			return ((EnemyAI)lightEater).ChooseClosestNodeToPosition(lightEater.energyNetwork.closestLightSource.transform.position, false, 0).position;
		}

		public override Vector3 GetClosestLightPosition()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return lightEater.energyNetwork.closestLightSource.transform.position;
		}
	}
	public class EnemyHandler : global::LightEater.Behaviours.LightSystem.Handlers.EnemyHandler
	{
		private readonly LightEaterAI lightEater;

		public EnemyHandler(LightEaterAI lightEater, EnemyAI enemy)
		{
			this.lightEater = lightEater;
			base..ctor(enemy);
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			EnemyValue enemyValue = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(enemy.enemyType.enemyName));
			lightEater.energyNetwork.currentCharge += enemyValue?.AbsorbCharge ?? 20;
		}
	}
	public class GrabbableObjectHandler : global::LightEater.Behaviours.LightSystem.Handlers.GrabbableObjectHandler
	{
		private readonly LightEaterAI lightEater;

		public GrabbableObjectHandler(LightEaterAI lightEater, GrabbableObject grabbableObject)
		{
			this.lightEater = lightEater;
			base..ctor(grabbableObject);
		}

		public override bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (base.HandleLightConsumption(absorbDuration, remainingDuration, timePassed))
			{
				if (grabbableObject.insertedBattery.charge > 0f)
				{
					return LightEnergyManager.CanBeAbsorbed(grabbableObject, ((Component)lightEater).transform.position, 15f);
				}
				return true;
			}
			return false;
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			lightEater.energyNetwork.currentCharge += 20;
		}

		public override Vector3 GetClosestNodePosition()
		{
			//IL_0007: 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)
			return ((EnemyAI)lightEater).ChooseClosestNodeToPosition(GetObjectPosition(), false, 0).position;
		}
	}
	public class LandmineHandler : global::LightEater.Behaviours.LightSystem.Handlers.LandmineHandler
	{
		private readonly LightEaterAI lightEater;

		public LandmineHandler(LightEaterAI lightEater, Landmine landmine)
		{
			this.lightEater = lightEater;
			base..ctor(landmine);
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			lightEater.energyNetwork.currentCharge += 20;
		}

		public override Vector3 GetClosestNodePosition()
		{
			//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)
			return ((EnemyAI)lightEater).ChooseClosestNodeToPosition(lightEater.energyNetwork.closestLightSource.transform.position, false, 0).position;
		}
	}
	public class ShipLightsHandler : global::LightEater.Behaviours.LightSystem.Handlers.ShipLightsHandler
	{
		private readonly LightEaterAI lightEater;

		public ShipLightsHandler(LightEaterAI lightEater)
		{
			this.lightEater = lightEater;
			base..ctor();
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			lightEater.energyNetwork.currentCharge += 200;
		}
	}
	public class TurretHandler : global::LightEater.Behaviours.LightSystem.Handlers.TurretHandler
	{
		private readonly LightEaterAI lightEater;

		public TurretHandler(LightEaterAI lightEater, Turret turret)
		{
			this.lightEater = lightEater;
			base..ctor(turret);
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			lightEater.energyNetwork.currentCharge += 20;
		}

		public override Vector3 GetClosestNodePosition()
		{
			//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)
			return ((EnemyAI)lightEater).ChooseClosestNodeToPosition(lightEater.energyNetwork.closestLightSource.transform.position, false, 0).position;
		}
	}
}
namespace LightEater.Behaviours.LightSystem.Handlers.DeluminatorHandlers
{
	public class AnimatorHandler : global::LightEater.Behaviours.LightSystem.Handlers.AnimatorHandler
	{
		private readonly Deluminator deluminator;

		public AnimatorHandler(Deluminator deluminator, Animator animator)
		{
			this.deluminator = deluminator;
			base..ctor(animator);
		}

		public override bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			//IL_0026: 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)
			if (base.HandleLightConsumption(absorbDuration, remainingDuration, timePassed))
			{
				PlayerControllerB playerHeldBy = ((GrabbableObject)deluminator).playerHeldBy;
				if ((Object)(object)playerHeldBy != (Object)null)
				{
					return Vector3.Distance(((Component)playerHeldBy).transform.position, ((Component)animator).transform.position) <= 7.5f;
				}
				return false;
			}
			return false;
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			deluminator.energyNetwork.currentCharge = Mathf.Min(200, deluminator.energyNetwork.currentCharge + 20);
		}
	}
	public class EnemyHandler : global::LightEater.Behaviours.LightSystem.Handlers.EnemyHandler
	{
		private readonly Deluminator deluminator;

		public EnemyHandler(Deluminator deluminator, EnemyAI enemy)
		{
			this.deluminator = deluminator;
			base..ctor(enemy);
		}

		public override bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			//IL_0059: 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)
			if (base.HandleLightConsumption(absorbDuration, remainingDuration, timePassed))
			{
				if (LFCUtilities.IsServer && (Object)(object)enemy.targetPlayer == (Object)null && (Object)(object)((GrabbableObject)deluminator).playerHeldBy != (Object)null)
				{
					enemy.SetMovingTowardsTargetPlayer(((GrabbableObject)deluminator).playerHeldBy);
				}
				return Vector3.Distance(((Component)deluminator).transform.position, ((Component)enemy).transform.position) <= 7.5f;
			}
			return false;
		}

		public override void HandleLightDepletion()
		{
			base.HandleLightDepletion();
			EnemyValue enemyValue = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(enemy.enemyType.enemyName));
			deluminator.energyNetwork.currentCharge = Mathf.Min(200, (deluminator.energyNetwork.currentCharge + enemyValue?.AbsorbCharge).GetValueOrDefault(20));
		}
	}
	public class GrabbableObjectHandler : global::LightEater.Behaviours.LightSystem.Handlers.GrabbableObjectHandler
	{
		private readonly Deluminator deluminator;

		public GrabbableObjectHandler(Deluminator deluminator, GrabbableObject grabbableObject)
		{
			this.deluminator = deluminator;
			base..ctor(grabbableObject);
		}

		public override bool HandleLightConsumption(float absorbDuration, float remainingDuration, float timePassed)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (base.HandleLightConsumption(absorbDuration, remainingDuration, timePassed))
			{
				if (grabbableObject.insertedBattery.charge > 0f)
				{
					return LightEnergyManager.CanBeAbsorbed(grabbableObject, ((Component)deluminator).transform.position, 7.5f);
				}
				return true;
			}
			return false;
		}

		public override void HandleLightDepletion()
		{
			base.HandleLight