Decompiled source of LightEater v1.0.3

LightEater.dll

Decompiled 2 days 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 LethalLib.Modules;
using LightEater.Behaviours;
using LightEater.Managers;
using LightEater.NetcodePatcher;
using LightEater.Patches;
using LightEater.Values;
using Microsoft.CodeAnalysis;
using TMPro;
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("DissonanceVoip")]
[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.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("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[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]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 STORM_INTERACTIONS = "Storm Interactions";

		public const string LIGHT_EATER = "Light Eater";

		public const string OLD_BIRD_NAME = "RadMech";

		public const string MESSAGE_SHIP_ENERGY = "Not enough energy left...";

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

		public const string MESSAGE_DEFAULT_SHIP_LEVER = "[Wait for ship to land]";

		public const string SHIP_LIGHTS = "ShipElectricLights";

		public const string TURRET = "TurretScript";

		public const string LANDMINE = "Landmine";
	}
	[BepInPlugin("Lega.LightEater", "Light Eater", "1.0.3")]
	public class LightEater : BaseUnityPlugin
	{
		private const string modGUID = "Lega.LightEater";

		private const string modName = "Light Eater";

		private const string modVersion = "1.0.3";

		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 bool isSellBodies = false;

		public static List<EnemyAI> enemies = new List<EnemyAI>();

		public static List<GrabbableObject> grabbableObjects = new List<GrabbableObject>();

		public static List<Turret> turrets = new List<Turret>();

		public static List<Landmine> landmines = new List<Landmine>();

		public void Awake()
		{
			mls = Logger.CreateLogSource("LightEater");
			configFile = ((BaseUnityPlugin)this).Config;
			ConfigManager.Load();
			ConfigManager.GetEnemiesValues();
			NetcodePatcher();
			LoadEnemies();
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(TurretPatch));
			harmony.PatchAll(typeof(LandminePatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(PatcherToolPatch));
			if (ConfigManager.interactWithStorm.Value)
			{
				harmony.PatchAll(typeof(StormyWeatherPatch));
			}
			if (ConfigManager.disableShipLights.Value)
			{
				harmony.PatchAll(typeof(ShipLightsPatch));
			}
			if (ConfigManager.disableShipDoor.Value)
			{
				harmony.PatchAll(typeof(HangarShipDoorPatch));
			}
			if (ConfigManager.disableItemCharger.Value)
			{
				harmony.PatchAll(typeof(ItemChargerPatch));
			}
			if (ConfigManager.disableShipScreen.Value)
			{
				harmony.PatchAll(typeof(ManualCameraRendererPatch));
			}
			if (ConfigManager.disableShipTeleporters.Value)
			{
				harmony.PatchAll(typeof(ShipTeleporterPatch));
			}
			PatchOtherMods();
		}

		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);
			Enemies.RegisterEnemy(val, ConfigManager.rarity.Value, (LevelTypes)(-1), (TerminalNode)null, (TerminalKeyword)null);
		}

		public static void PatchOtherMods()
		{
			isSellBodies = Type.GetType("SellBodies.MyPluginInfo, SellBodies") != null;
		}
	}
	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 EnemyAIPatch
	{
		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPostfix]
		private static void StartEnemy(ref EnemyAI __instance)
		{
			RoundManagerPatch.AddEnemy(__instance);
		}

		[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.CanBeShocked")]
		[HarmonyPrefix]
		private static bool CanBeShocked(ref EnemyAICollisionDetect __instance, ref bool __result)
		{
			if ((Object)(object)__instance.mainScript == (Object)null || !(__instance.mainScript is LightEaterAI))
			{
				return true;
			}
			__result = true;
			return false;
		}

		[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.ShockWithGun")]
		[HarmonyPostfix]
		private static void ShockWithGun(ref EnemyAICollisionDetect __instance)
		{
			if (!((Object)(object)__instance.mainScript == (Object)null) && __instance.mainScript is LightEaterAI lightEaterAI)
			{
				lightEaterAI.isShocked = true;
			}
		}
	}
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		private static void StartGrabbableObject(ref GrabbableObject __instance)
		{
			RoundManagerPatch.AddGrabbableObject(__instance);
		}
	}
	internal class HangarShipDoorPatch
	{
		[HarmonyPatch(typeof(HangarShipDoor), "Update")]
		[HarmonyPostfix]
		private static void UpdateShipDoor(HangarShipDoor __instance)
		{
			if (ShipLightsPatch.hasBeenAbsorbed)
			{
				__instance.doorPower = 0f;
				((TMP_Text)__instance.doorPowerDisplay).text = "0%";
			}
		}
	}
	internal class ItemChargerPatch
	{
		[HarmonyPatch(typeof(ItemCharger), "Update")]
		[HarmonyPostfix]
		private static void UpdateItemCharger(ref ItemCharger __instance)
		{
			if (ShipLightsPatch.hasBeenAbsorbed)
			{
				__instance.triggerScript.disabledHoverTip = "Not enough energy left...";
				__instance.triggerScript.interactable = false;
			}
		}
	}
	internal class LandminePatch
	{
		[HarmonyPatch(typeof(Landmine), "Start")]
		[HarmonyPostfix]
		private static void StartLandmine(ref Landmine __instance)
		{
			RoundManagerPatch.AddLandmine(__instance);
		}
	}
	internal class ManualCameraRendererPatch
	{
		[HarmonyPatch(typeof(ManualCameraRenderer), "SwitchScreenButton")]
		[HarmonyPrefix]
		private static bool SwitchScreenButton()
		{
			return !ShipLightsPatch.hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "SwitchScreenOn")]
		[HarmonyPrefix]
		private static bool SwitchScreenOn()
		{
			return !ShipLightsPatch.hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "SwitchScreenOnClientRpc")]
		[HarmonyPrefix]
		private static bool SwitchScreenOnClientRpc()
		{
			return !ShipLightsPatch.hasBeenAbsorbed;
		}
	}
	internal class PatcherToolPatch
	{
		[HarmonyPatch(typeof(PatcherTool), "StopShockingAnomalyOnClient")]
		[HarmonyPrefix]
		private static void StopShocking(ref PatcherTool __instance)
		{
			if (__instance.shockedTargetScript != null)
			{
				IShockableWithGun shockedTargetScript = __instance.shockedTargetScript;
				EnemyAICollisionDetect val = (EnemyAICollisionDetect)(object)((shockedTargetScript is EnemyAICollisionDetect) ? shockedTargetScript : null);
				if (val != null && !((Object)(object)val.mainScript == (Object)null) && val.mainScript is LightEaterAI lightEaterAI)
				{
					lightEaterAI.ShockEnemyServerRpc((int)(__instance.timeSpentShocking / 0.1f * 25f));
				}
			}
		}
	}
	internal class RoundManagerPatch
	{
		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPostfix]
		private static void StartGame()
		{
			StormyWeatherPatch.lightEaters.Clear();
			LightEater.enemies.Clear();
			EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
			foreach (EnemyAI enemy in array)
			{
				AddEnemy(enemy);
			}
			LightEater.grabbableObjects.Clear();
			GrabbableObject[] array2 = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject grabbableObject in array2)
			{
				AddGrabbableObject(grabbableObject);
			}
			LightEater.turrets.Clear();
			Turret[] array3 = Object.FindObjectsOfType<Turret>();
			foreach (Turret turret in array3)
			{
				AddTurret(turret);
			}
			LightEater.landmines.Clear();
			Landmine[] array4 = Object.FindObjectsOfType<Landmine>();
			foreach (Landmine landmine in array4)
			{
				AddLandmine(landmine);
			}
		}

		public static void AddEnemy(EnemyAI enemy)
		{
			if (!string.IsNullOrEmpty(enemy.enemyType?.enemyName) && ConfigManager.enemiesValues.Select((EnemyValue e) => e.EnemyName).Contains(enemy.enemyType.enemyName) && !LightEater.enemies.Contains(enemy))
			{
				LightEater.enemies.Add(enemy);
			}
		}

		public static void AddGrabbableObject(GrabbableObject grabbableObject)
		{
			if (grabbableObject.itemProperties.requiresBattery && !LightEater.grabbableObjects.Contains(grabbableObject))
			{
				LightEater.grabbableObjects.Add(grabbableObject);
			}
		}

		public static void AddTurret(Turret turret)
		{
			if (turret.turretActive && !LightEater.turrets.Contains(turret))
			{
				LightEater.turrets.Add(turret);
			}
		}

		public static void AddLandmine(Landmine landmine)
		{
			if (landmine.mineActivated && !LightEater.landmines.Contains(landmine))
			{
				LightEater.landmines.Add(landmine);
			}
		}
	}
	internal class ShipLightsPatch
	{
		public static bool hasBeenAbsorbed;

		[HarmonyPatch(typeof(ShipLights), "SetShipLightsBoolean")]
		[HarmonyPrefix]
		private static bool SetShipLightsBoolean()
		{
			return !hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ShipLights), "SetShipLightsClientRpc")]
		[HarmonyPrefix]
		private static bool SetShipLightsClientRpc()
		{
			return !hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ShipLights), "SetShipLightsOnLocalClientOnly")]
		[HarmonyPrefix]
		private static bool SetShipLightsOnLocalClientOnly()
		{
			return !hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ShipLights), "ToggleShipLights")]
		[HarmonyPrefix]
		private static bool ToggleShipLights()
		{
			return !hasBeenAbsorbed;
		}

		[HarmonyPatch(typeof(ShipLights), "ToggleShipLightsOnLocalClientOnly")]
		[HarmonyPrefix]
		private static bool ToggleShipLightsOnLocalClientOnly()
		{
			return !hasBeenAbsorbed;
		}
	}
	internal class ShipTeleporterPatch
	{
		[HarmonyPatch(typeof(ShipTeleporter), "Update")]
		[HarmonyPostfix]
		private static void UpdateShipTeleporter(ref ShipTeleporter __instance)
		{
			if (ShipLightsPatch.hasBeenAbsorbed)
			{
				__instance.buttonTrigger.disabledHoverTip = "Not enough energy left...";
				__instance.buttonTrigger.interactable = false;
			}
		}
	}
	internal class StartOfRoundPatch
	{
		public static HangarShipDoor shipDoor;

		public static StartMatchLever shipLever;

		public static ItemCharger itemCharger;

		public static Terminal terminal;

		public static ShipTeleporter shipTeleporter;

		public static ShipTeleporter inverseShipTeleporter;

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartRound()
		{
			if (ConfigManager.disableShipDoor.Value)
			{
				shipDoor = Object.FindObjectOfType<HangarShipDoor>();
			}
			if (ConfigManager.disableShipLever.Value)
			{
				shipLever = Object.FindObjectOfType<StartMatchLever>();
			}
			if (ConfigManager.disableItemCharger.Value)
			{
				itemCharger = Object.FindObjectOfType<ItemCharger>();
			}
			if (ConfigManager.disableTerminal.Value)
			{
				terminal = Object.FindObjectOfType<Terminal>();
			}
			if (ConfigManager.disableShipTeleporters.Value)
			{
				shipTeleporter = ((IEnumerable<ShipTeleporter>)Object.FindObjectsOfType<ShipTeleporter>()).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter t) => !t.isInverseTeleporter));
				inverseShipTeleporter = ((IEnumerable<ShipTeleporter>)Object.FindObjectsOfType<ShipTeleporter>()).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter t) => t.isInverseTeleporter));
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPostfix]
		private static void ShipLeave()
		{
			EndGame();
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipLeaveAutomatically")]
		[HarmonyPostfix]
		private static void ShipLeaveAutomatically()
		{
			EndGame();
		}

		public static void EndGame()
		{
			ShipLightsPatch.hasBeenAbsorbed = false;
			EnablesShipFunctionalities(enable: true);
		}

		public static void EnablesShipFunctionalities(bool enable)
		{
			EnablesShipDoor(enable);
			EnablesShipLever(enable);
			EnablesItemCharger(enable);
			EnablesTerminal(enable);
			EnablesShipTeleporter(enable);
			EnablesInverseShipTeleporter(enable);
		}

		public static void EnablesShipDoor(bool enable)
		{
			if (!ConfigManager.disableShipDoor.Value)
			{
				return;
			}
			if (shipDoor == null)
			{
				shipDoor = Object.FindObjectOfType<HangarShipDoor>();
			}
			if (!((Object)(object)shipDoor == (Object)null))
			{
				shipDoor.hydraulicsScreenDisplayed = enable;
				shipDoor.hydraulicsDisplay.SetActive(enable);
				shipDoor.SetDoorButtonsEnabled(enable);
				StartOfRound.Instance.shipDoorsAnimator.SetBool("Closed", enable);
				if (!enable)
				{
					shipDoor.SetDoorOpen();
				}
			}
		}

		public static void EnablesShipLever(bool enable)
		{
			if (!ConfigManager.disableShipLever.Value)
			{
				return;
			}
			if (shipLever == null)
			{
				shipLever = Object.FindObjectOfType<StartMatchLever>();
			}
			if (!((Object)(object)shipLever == (Object)null))
			{
				if (!enable)
				{
					shipLever.triggerScript.disabledHoverTip = "Not enough energy left...";
				}
				else
				{
					shipLever.triggerScript.disabledHoverTip = "[Wait for ship to land]";
				}
				shipLever.triggerScript.interactable = enable;
			}
		}

		public static void EnablesItemCharger(bool enable)
		{
			if (!ConfigManager.disableItemCharger.Value)
			{
				return;
			}
			if (itemCharger == null)
			{
				itemCharger = Object.FindObjectOfType<ItemCharger>();
			}
			if (!((Object)(object)itemCharger == (Object)null))
			{
				if (!enable)
				{
					itemCharger.triggerScript.disabledHoverTip = "Not enough energy left...";
				}
				else
				{
					itemCharger.triggerScript.disabledHoverTip = "(Requires battery-powered item)";
				}
				itemCharger.triggerScript.interactable = enable;
			}
		}

		public static void EnablesTerminal(bool enable)
		{
			if (!ConfigManager.disableTerminal.Value)
			{
				return;
			}
			if (terminal == null)
			{
				terminal = Object.FindObjectOfType<Terminal>();
			}
			if (!((Object)(object)terminal == (Object)null))
			{
				if (!enable)
				{
					terminal.terminalTrigger.disabledHoverTip = "Not enough energy left...";
				}
				terminal.terminalTrigger.interactable = enable;
			}
		}

		public static void EnablesShipTeleporter(bool enable)
		{
			if (!ConfigManager.disableShipTeleporters.Value)
			{
				return;
			}
			if (shipTeleporter == null)
			{
				shipTeleporter = ((IEnumerable<ShipTeleporter>)Object.FindObjectsOfType<ShipTeleporter>()).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter t) => !t.isInverseTeleporter));
			}
			if (!((Object)(object)shipTeleporter == (Object)null))
			{
				if (!enable)
				{
					shipTeleporter.buttonTrigger.disabledHoverTip = "Not enough energy left...";
				}
				shipTeleporter.buttonTrigger.interactable = enable;
			}
		}

		public static void EnablesInverseShipTeleporter(bool enable)
		{
			if (!ConfigManager.disableShipTeleporters.Value)
			{
				return;
			}
			if (inverseShipTeleporter == null)
			{
				inverseShipTeleporter = ((IEnumerable<ShipTeleporter>)Object.FindObjectsOfType<ShipTeleporter>()).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter t) => t.isInverseTeleporter));
			}
			if (!((Object)(object)inverseShipTeleporter == (Object)null))
			{
				if (!enable)
				{
					inverseShipTeleporter.buttonTrigger.disabledHoverTip = "Not enough energy left...";
				}
				inverseShipTeleporter.buttonTrigger.interactable = enable;
			}
		}
	}
	internal class StormyWeatherPatch
	{
		public static List<LightEaterAI> lightEaters = new List<LightEaterAI>();

		public static int randomStrikeTimer = 10;

		public static float strikeLightEaterTimer = 0f;

		public static GameObject setStaticToEnemy;

		public static LightEaterAI targetedLightEater;

		[HarmonyPatch(typeof(StormyWeather), "Update")]
		[HarmonyPostfix]
		private static void UpdateStormyWeather(ref StormyWeather __instance)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)setStaticToEnemy != (Object)null)
			{
				EnemyAI componentInChildren = setStaticToEnemy.GetComponentInChildren<EnemyAI>();
				if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.isOutside)
				{
					__instance.staticElectricityParticle.Stop();
				}
				((Component)__instance.staticElectricityParticle).transform.position = setStaticToEnemy.transform.position;
			}
			if (!((NetworkBehaviour)RoundManager.Instance).IsOwner || !lightEaters.Any())
			{
				return;
			}
			strikeLightEaterTimer += Time.deltaTime;
			if (strikeLightEaterTimer < (float)randomStrikeTimer)
			{
				return;
			}
			LightEaterAI lightEaterAI = null;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB player in allPlayerScripts)
			{
				if (player.isPlayerControlled && !player.isPlayerDead)
				{
					lightEaterAI = lightEaters.FirstOrDefault((LightEaterAI l) => ((EnemyAI)l).isOutside && Vector3.Distance(((Component)player).transform.position, ((Component)l).transform.position) < 20f);
					if ((Object)(object)lightEaterAI != (Object)null)
					{
						break;
					}
				}
			}
			if (!((Object)(object)lightEaterAI == (Object)null))
			{
				randomStrikeTimer = new Random().Next(ConfigManager.minStrikeDuration.Value, ConfigManager.maxStrikeDuration.Value);
				strikeLightEaterTimer = 0f;
				((MonoBehaviour)__instance).StartCoroutine(StrikeLightEaterCoroutine());
			}
		}

		public static IEnumerator StrikeLightEaterCoroutine()
		{
			LightEaterAI lightEater = lightEaters[new Random().Next(lightEaters.Count)];
			RoundManager.Instance.ShowStaticElectricityWarningServerRpc(NetworkObjectReference.op_Implicit(((EnemyAI)lightEater).thisNetworkObject), 1.5f);
			yield return (object)new WaitForSeconds(2f);
			if (((EnemyAI)lightEater).isOutside)
			{
				targetedLightEater = lightEater;
				RoundManager.Instance.LightningStrikeServerRpc(((Component)lightEater).transform.position);
			}
		}

		[HarmonyPatch(typeof(StormyWeather), "SetStaticElectricityWarning")]
		[HarmonyPrefix]
		private static bool SetStaticElectricityWarning(ref StormyWeather __instance, ref NetworkObject warningObject, ref float particleTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)warningObject).GetComponentInChildren<EnemyAI>() == (Object)null)
			{
				return true;
			}
			setStaticToEnemy = ((Component)warningObject).gameObject;
			ShapeModule shape = __instance.staticElectricityParticle.shape;
			((ShapeModule)(ref shape)).meshRenderer = setStaticToEnemy.GetComponentInChildren<MeshRenderer>();
			__instance.staticElectricityParticle.time = particleTime;
			__instance.staticElectricityParticle.Play();
			AudioSource component = ((Component)__instance.staticElectricityParticle).gameObject.GetComponent<AudioSource>();
			component.clip = __instance.staticElectricityAudio;
			component.Play();
			component.time = particleTime;
			return false;
		}

		[HarmonyPatch(typeof(StormyWeather), "LightningStrike")]
		[HarmonyPostfix]
		private static void LightningStrike()
		{
			if (!((Object)(object)targetedLightEater == (Object)null))
			{
				targetedLightEater.currentCharge += ConfigManager.stormCharge.Value;
			}
		}
	}
	internal class TurretPatch
	{
		[HarmonyPatch(typeof(Turret), "Start")]
		[HarmonyPostfix]
		private static void StartTurret(ref Turret __instance)
		{
			RoundManagerPatch.AddTurret(__instance);
		}
	}
}
namespace LightEater.Managers
{
	public class ConfigManager
	{
		public static List<EnemyValue> enemiesValues = new List<EnemyValue>();

		public static ConfigEntry<int> rarity;

		public static ConfigEntry<float> huntingSpeed;

		public static ConfigEntry<float> chasingSpeed;

		public static ConfigEntry<int> damage;

		public static ConfigEntry<int> lightCharge;

		public static ConfigEntry<int> itemCharge;

		public static ConfigEntry<int> turretCharge;

		public static ConfigEntry<int> landmineCharge;

		public static ConfigEntry<string> absorbedEnemies;

		public static ConfigEntry<int> shipMinHour;

		public static ConfigEntry<bool> disableShipLights;

		public static ConfigEntry<bool> disableShipDoor;

		public static ConfigEntry<bool> disableShipLever;

		public static ConfigEntry<bool> disableItemCharger;

		public static ConfigEntry<bool> disableTerminal;

		public static ConfigEntry<bool> disableShipScreen;

		public static ConfigEntry<bool> disableShipTeleporters;

		public static ConfigEntry<bool> interactWithStorm;

		public static ConfigEntry<int> minStrikeDuration;

		public static ConfigEntry<int> maxStrikeDuration;

		public static ConfigEntry<int> stormCharge;

		public static void Load()
		{
			rarity = LightEater.configFile.Bind<int>("_Global_", "Rarity", 20, "Light Eater rarity");
			huntingSpeed = LightEater.configFile.Bind<float>("_Global_", "Hunting speed", 3f, "Light Eater speed when it moves towards a light");
			chasingSpeed = LightEater.configFile.Bind<float>("_Global_", "Chasing speed", 4f, "Light Eater speed when it moves towards a player");
			damage = LightEater.configFile.Bind<int>("_Global_", "Damage", 20, "Light Eater damage");
			lightCharge = LightEater.configFile.Bind<int>("_Global_", "Light charge", 20, "Electric charge received upon absorption of a dungeon light");
			itemCharge = LightEater.configFile.Bind<int>("_Global_", "Item charge", 20, "Electric charge received upon absorption of an item");
			turretCharge = LightEater.configFile.Bind<int>("_Global_", "Turret charge", 20, "Electric charge received upon absorption of a turret");
			landmineCharge = LightEater.configFile.Bind<int>("_Global_", "Landmine charge", 10, "Electric charge received upon absorption of a landmine");
			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");
			disableShipDoor = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable door", true, "Disable ship door");
			disableShipLever = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable lever", false, "Disable ship lever");
			disableItemCharger = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable item charger", true, "Disable item charger");
			disableTerminal = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable terminal", true, "Disable terminal");
			disableShipScreen = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable screen", true, "Disable ship screen");
			disableShipTeleporters = LightEater.configFile.Bind<bool>("Ship Interactions", "Disable teleporters", true, "Disable ship teleporters");
			interactWithStorm = LightEater.configFile.Bind<bool>("Storm Interactions", "Enable", true, "Enable Storm Interactions");
			minStrikeDuration = LightEater.configFile.Bind<int>("Storm Interactions", "Min strike duration", 7, "Minimum time interval before a new strike");
			maxStrikeDuration = LightEater.configFile.Bind<int>("Storm Interactions", "Max strike duration", 15, "Maximum time interval before a new strike");
			stormCharge = LightEater.configFile.Bind<int>("Storm Interactions", "Storm charge", 100, "Electrical charge received by lightning");
		}

		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])));
				}
			}
		}
	}
}
namespace LightEater.Behaviours
{
	public class LightEaterAI : EnemyAI
	{
		public enum State
		{
			WANDERING,
			HUNTING,
			ABSORBING,
			CHASING
		}

		public int currentCharge;

		public bool isShocked;

		public Transform TurnCompass;

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

		public AudioClip AbsorptionSound;

		public AudioClip SwingSound;

		public AudioClip ChargeSound;

		public AudioClip StunSound;

		public AudioClip ExplosionSound;

		public float moveTimer;

		public List<EntranceTeleport> entrances;

		public int absorbDistance = 5;

		public GameObject closestLightSource;

		private float explodeTimer;

		public bool absorbPlayerObject;

		public Coroutine absorbCoroutine;

		public Coroutine stunCoroutine;

		public Coroutine attackCoroutine;

		public Coroutine killCoroutine;

		public override void Start()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.currentBehaviourStateIndex = 0;
			base.creatureAnimator.SetTrigger("startWalk");
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			entrances = Object.FindObjectsOfType<EntranceTeleport>().ToList();
			StormyWeatherPatch.lightEaters.Add(this);
		}

		public override void Update()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				explodeTimer += Time.deltaTime;
				PlayMoveSound();
				int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
				if ((Object)(object)base.targetPlayer != (Object)null && 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 (FoundClosestPlayerInRange(25, 10))
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				DoAnimationClientRpc("startRun");
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
			else if (currentCharge > 200 || FoundLightSource())
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				DoAnimationClientRpc("startRun");
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}

		private bool FoundClosestPlayerInRange(int range, int senseRange)
		{
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(60f, range, senseRange);
			if ((Object)(object)val == (Object)null || !((EnemyAI)this).PlayerIsTargetable(val, false, false))
			{
				return false;
			}
			return Object.op_Implicit((Object)(object)(base.targetPlayer = val));
		}

		public bool FoundLightSource()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			if (CrossingLight())
			{
				return true;
			}
			if (TimeOfDay.Instance.hour >= ConfigManager.shipMinHour.Value && !ShipLightsPatch.hasBeenAbsorbed)
			{
				absorbDistance = 20;
				closestLightSource = ((Component)StartOfRound.Instance.shipRoomLights).gameObject;
			}
			else if (LightEater.enemies.Any((EnemyAI r) => !r.isEnemyDead))
			{
				EnemyAI closestEnemy = (from r in LightEater.enemies
					where !r.isEnemyDead
					orderby Vector3.Distance(((Component)this).transform.position, ((Component)r).transform.position)
					select r).FirstOrDefault();
				absorbDistance = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(closestEnemy.enemyType.enemyName))?.AbsorbDistance ?? 5;
				closestLightSource = ((Component)closestEnemy).gameObject;
			}
			else
			{
				absorbDistance = 5;
				if (!base.isOutside)
				{
					base.path1 = new NavMeshPath();
					Animator? obj = (from l in RoundManager.Instance.allPoweredLightsAnimators
						where (Object)(object)l != (Object)null && base.agent.CalculatePath(((EnemyAI)this).ChooseClosestNodeToPosition(((Component)l).transform.position, false, 0).position, base.path1)
						orderby Vector3.Distance(((Component)this).transform.position, ((Component)l).transform.position)
						select l).FirstOrDefault();
					closestLightSource = ((obj != null) ? ((Component)obj).gameObject : null);
				}
				else
				{
					Animator? obj2 = RoundManager.Instance.allPoweredLightsAnimators.OrderBy((Animator l) => (!Object.op_Implicit((Object)(object)l)) ? float.MaxValue : Vector3.Distance(GetEntranceExitPosition(GetClosestEntrance()), ((Component)l).transform.position)).FirstOrDefault();
					closestLightSource = ((obj2 != null) ? ((Component)obj2).gameObject : null);
				}
			}
			return (Object)(object)closestLightSource != (Object)null;
		}

		public void DoHunting()
		{
			base.agent.speed = ConfigManager.huntingSpeed.Value;
			if (FoundClosestPlayerInRange(25, 10))
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
			else if (!HuntPlayers() && CloseToLightSource())
			{
				DoAnimationClientRpc("startAbsorb");
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
		}

		public bool HuntPlayers()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (currentCharge <= 200 && (Object)(object)closestLightSource != (Object)null)
			{
				return false;
			}
			PlayerControllerB val = (from p in StartOfRound.Instance.allPlayerScripts
				where p.isPlayerControlled && !p.isPlayerDead
				orderby Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position)
				select p).FirstOrDefault();
			((EnemyAI)this).SetDestinationToPosition(((Component)val).transform.position, false);
			return true;
		}

		public bool CloseToLightSource()
		{
			//IL_006a: 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)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			CrossingLight();
			object obj = DetermineLightSource();
			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))
				{
					Vector3 val2 = ((obj is ShipLights) ? StartOfRound.Instance.shipLandingPosition.position : ((!(obj is EnemyAI)) ? ((EnemyAI)this).ChooseClosestNodeToPosition(closestLightSource.transform.position, false, 0).position : closestLightSource.transform.position));
					Vector3 val3 = val2;
					((EnemyAI)this).SetDestinationToPosition(val3, false);
					if (!(Vector3.Distance(((Component)base.eye).transform.position, closestLightSource.transform.position) < (float)absorbDistance))
					{
						return Vector3.Distance(((Component)this).transform.position, val3) < 1f;
					}
					return true;
				}
			}
			GoTowardsEntrance();
			return false;
		}

		public void DoAbsorbing()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			if ((Object)(object)closestLightSource == (Object)null)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				DoAnimationClientRpc("startWalk");
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			else
			{
				AbsorbLight();
			}
		}

		public void AbsorbLight()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (absorbCoroutine == null)
			{
				NetworkObject component = closestLightSource.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					AbsorbLightClientRpc(NetworkObjectReference.op_Implicit(component));
				}
				else
				{
					AbsorbLightClientRpc(((Object)closestLightSource).name, closestLightSource.transform.position);
				}
			}
		}

		[ClientRpc]
		public void AbsorbLightClientRpc(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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3900372421u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3900372421u, val, (RpcDelivery)0);
			}
			NetworkObject val3 = default(NetworkObject);
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null))
			{
				closestLightSource = ((Component)val3).gameObject;
				if (absorbCoroutine == null)
				{
					absorbCoroutine = ((MonoBehaviour)this).StartCoroutine(AbsorbLightCoroutine());
				}
			}
		}

		[ClientRpc]
		public void AbsorbLightClientRpc(string objectName, 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0088: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1914148197u, val, (RpcDelivery)0);
				bool flag = objectName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(objectName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1914148197u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				Vector3 position2 = position;
				closestLightSource = (GameObject)(objectName switch
				{
					"ShipElectricLights" => ((Component)StartOfRound.Instance.shipRoomLights).gameObject, 
					"TurretScript" => ((Component)LightEater.turrets.OrderBy((Turret t) => (!((Object)(object)t != (Object)null)) ? float.MaxValue : Vector3.Distance(position2, ((Component)t).transform.position)).FirstOrDefault()).gameObject, 
					"Landmine" => ((Component)LightEater.landmines.OrderBy((Landmine l) => (!((Object)(object)l != (Object)null)) ? float.MaxValue : Vector3.Distance(position2, ((Component)l).transform.position)).FirstOrDefault()).gameObject, 
					_ => ((Component)RoundManager.Instance.allPoweredLightsAnimators.OrderBy((Animator l) => (!((Object)(object)l != (Object)null)) ? float.MaxValue : Vector3.Distance(position2, ((Component)l).transform.position)).FirstOrDefault()).gameObject, 
				});
				if (absorbCoroutine == null)
				{
					absorbCoroutine = ((MonoBehaviour)this).StartCoroutine(AbsorbLightCoroutine());
				}
			}
		}

		public IEnumerator AbsorbLightCoroutine()
		{
			object lightSource = DetermineLightSource();
			bool isAbsorbed = true;
			float absorbDuration = 5f;
			float timePassed = 0f;
			base.creatureSFX.PlayOneShot(AbsorptionSound);
			HandleLightInitialization(lightSource, ref absorbDuration);
			while (timePassed < absorbDuration)
			{
				yield return (object)new WaitForSeconds(0.5f);
				timePassed += 0.5f;
				if (!HandleLightConsumption(lightSource, absorbDuration, timePassed))
				{
					isAbsorbed = false;
					break;
				}
			}
			FlashlightItem val = (FlashlightItem)((lightSource is FlashlightItem) ? lightSource : null);
			if (val != null)
			{
				val.flashlightInterferenceLevel = 0;
			}
			if (isAbsorbed)
			{
				HandleLightDepletion(lightSource);
			}
			closestLightSource = null;
			absorbCoroutine = null;
		}

		public void HandleLightInitialization(object lightSource, ref float absorbDuration)
		{
			GrabbableObject val = (GrabbableObject)((lightSource is GrabbableObject) ? lightSource : null);
			if (val == null)
			{
				if (lightSource is ShipLights)
				{
					StartOfRound.Instance.PowerSurgeShip();
					((Component)StartOfRound.Instance.shipAnimatorObject).gameObject.GetComponent<Animator>().SetBool("AlarmRinging", true);
					StartOfRound.Instance.shipDoorAudioSource.PlayOneShot(StartOfRound.Instance.alarmSFX);
				}
				return;
			}
			absorbDuration *= val.insertedBattery.charge;
			FlashlightItem val2 = (FlashlightItem)((lightSource is FlashlightItem) ? lightSource : null);
			if (val2 != null)
			{
				val2.flashlightAudio.PlayOneShot(val2.flashlightFlicker);
				WalkieTalkie.TransmitOneShotAudio(val2.flashlightAudio, val2.flashlightFlicker, 0.8f);
				val2.flashlightInterferenceLevel = 1;
			}
		}

		public bool HandleLightConsumption(object lightSource, float absorbDuration, float timePassed)
		{
			if (!(lightSource is ShipLights))
			{
				EnemyAI val = (EnemyAI)((lightSource is EnemyAI) ? lightSource : null);
				if (val != null)
				{
					RadMechAI val2 = (RadMechAI)(object)((val is RadMechAI) ? val : null);
					if (val2 != null)
					{
						val2.FlickerFace();
						if (val2.inFlyingMode)
						{
							return false;
						}
					}
					return !val.isEnemyDead;
				}
				GrabbableObject val3 = (GrabbableObject)((lightSource is GrabbableObject) ? lightSource : null);
				if (val3 != null)
				{
					val3.insertedBattery.charge = Mathf.Max(0f, 1f - (timePassed + (5f - absorbDuration)) / 5f);
					if (val3.insertedBattery.charge > 0f)
					{
						return CanBeAbsorbed(val3, 15f);
					}
					return true;
				}
				Turret val4 = (Turret)((lightSource is Turret) ? lightSource : null);
				if (val4 == null)
				{
					Animator val5 = (Animator)((lightSource is Animator) ? lightSource : null);
					if (val5 != null && val5 != null)
					{
						val5.SetTrigger("Flicker");
					}
				}
				else
				{
					val4.SwitchTurretMode(3);
				}
			}
			else
			{
				StartOfRound.Instance.shipDoorsAnimator.SetBool("Closed", !StartOfRound.Instance.shipDoorsAnimator.GetBool("Closed"));
			}
			return true;
		}

		public void HandleLightDepletion(object lightSource)
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			if (!(lightSource is ShipLights))
			{
				EnemyAI val = (EnemyAI)((lightSource is EnemyAI) ? lightSource : null);
				if (val == null)
				{
					GrabbableObject val2 = (GrabbableObject)((lightSource is GrabbableObject) ? lightSource : null);
					if (val2 == null)
					{
						Turret val3 = (Turret)((lightSource is Turret) ? lightSource : null);
						if (val3 == null)
						{
							Landmine val4 = (Landmine)((lightSource is Landmine) ? lightSource : null);
							if (val4 == null)
							{
								if (!(lightSource is Animator))
								{
									return;
								}
								currentCharge += ConfigManager.lightCharge.Value;
								Animator val5 = (Animator)((lightSource is Animator) ? lightSource : null);
								if (val5 != null)
								{
									val5.SetBool("on", false);
									RoundManager.Instance.allPoweredLightsAnimators.RemoveAll((Animator l) => (Object)(object)((Component)l).gameObject == (Object)(object)closestLightSource);
								}
							}
							else
							{
								currentCharge += ConfigManager.landmineCharge.Value;
								val4.ToggleMineEnabledLocalClient(false);
								LightEater.landmines.Remove(val4);
							}
						}
						else
						{
							currentCharge += ConfigManager.turretCharge.Value;
							val3.ToggleTurretEnabledLocalClient(false);
							val3.mainAudio.Stop();
							val3.farAudio.Stop();
							val3.berserkAudio.Stop();
							if (val3.fadeBulletAudioCoroutine != null)
							{
								((MonoBehaviour)this).StopCoroutine(val3.fadeBulletAudioCoroutine);
							}
							val3.fadeBulletAudioCoroutine = ((MonoBehaviour)this).StartCoroutine(val3.FadeBulletAudio());
							val3.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
							val3.turretAnimator.SetInteger("TurretMode", 0);
							LightEater.turrets.Remove(val3);
						}
					}
					else
					{
						currentCharge += ConfigManager.itemCharge.Value;
						LightEater.grabbableObjects.Remove(val2);
					}
					return;
				}
				EnemyValue enemyValue = ConfigManager.enemiesValues.FirstOrDefault((EnemyValue e) => e.EnemyName.Equals(val.enemyType.enemyName));
				currentCharge += enemyValue?.AbsorbCharge ?? 20;
				if (!((NetworkBehaviour)this).IsOwner)
				{
					return;
				}
				LightEater.enemies.Remove(val);
				if (!val.isEnemyDead)
				{
					string enemyName = val.enemyType.enemyName;
					if (enemyName == "RadMech")
					{
						GameObject val6 = Object.Instantiate<GameObject>(val.enemyType.nestSpawnPrefab, ((Component)val).transform.position, ((Component)val).transform.rotation);
						val6.GetComponentInChildren<NetworkObject>().Spawn(true);
					}
					val.KillEnemyOnOwnerClient(enemyValue?.Destroy ?? true);
				}
			}
			else
			{
				currentCharge += 200;
				ShipLightsPatch.hasBeenAbsorbed = true;
				StartOfRoundPatch.EnablesShipFunctionalities(enable: false);
				((Component)StartOfRound.Instance.shipAnimatorObject).gameObject.GetComponent<Animator>().SetBool("AlarmRinging", false);
			}
		}

		public void DoChasing()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (stunCoroutine != null)
			{
				return;
			}
			base.agent.speed = (isShocked ? (ConfigManager.chasingSpeed.Value / 2f) : ConfigManager.chasingSpeed.Value);
			if (TargetOutsideChasedPlayer())
			{
				return;
			}
			if (explodeTimer < 10f)
			{
				((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			}
			else if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				DoAnimationClientRpc("startWalk");
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			else if (!StunExplosion())
			{
				if (AbsorbPlayerObject() || CrossingLight())
				{
					absorbPlayerObject = false;
					DoAnimationClientRpc("startAbsorb");
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
				else
				{
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
				}
			}
		}

		public bool TargetOutsideChasedPlayer()
		{
			if (base.targetPlayer.isInsideFactory == base.isOutside)
			{
				GoTowardsEntrance();
				return true;
			}
			return false;
		}

		public bool TargetClosestPlayerInAnyCase()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			return (Object)(object)base.targetPlayer != (Object)null;
		}

		public bool StunExplosion()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (currentCharge < 100 || explodeTimer < 10f)
			{
				return false;
			}
			if (!base.targetPlayer.HasLineOfSightToPosition(base.eye.position, 60f, 15, -1f))
			{
				return false;
			}
			base.agent.speed = 0f;
			if (currentCharge > 200)
			{
				StunEnemyClientRpc();
				return true;
			}
			currentCharge -= 100;
			explodeTimer = 0f;
			StunExplosionClientRpc();
			return true;
		}

		[ClientRpc]
		public void StunEnemyClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2458810888u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2458810888u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					stunCoroutine = ((MonoBehaviour)this).StartCoroutine(StunEnemyCoroutine());
				}
			}
		}

		public IEnumerator StunEnemyCoroutine()
		{
			base.creatureAnimator.SetTrigger("startStun");
			base.creatureSFX.PlayOneShot(StunSound);
			base.enemyType.canDie = true;
			yield return (object)new WaitForSeconds(5f);
			if (killCoroutine == null)
			{
				currentCharge = 200;
				base.creatureAnimator.SetTrigger("startRun");
				base.enemyType.canDie = false;
				stunCoroutine = null;
			}
		}

		[ClientRpc]
		public void StunExplosionClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2969224247u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2969224247u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(StunExplosionCoroutine());
				}
			}
		}

		public IEnumerator StunExplosionCoroutine()
		{
			base.creatureAnimator.SetTrigger("startExplode");
			base.creatureSFX.PlayOneShot(ChargeSound);
			yield return (object)new WaitForSeconds(0.75f);
			base.creatureSFX.PlayOneShot(ExplosionSound);
			StunGrenadeItem.StunExplosion(base.eye.position, true, 2f, 2f, 1f, false, (PlayerControllerB)null, (PlayerControllerB)null, 0f);
			base.creatureAnimator.SetTrigger("startRun");
		}

		public bool AbsorbPlayerObject()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 15f)
			{
				return false;
			}
			if (absorbPlayerObject)
			{
				return true;
			}
			AbsorbPlayerObjectClientRpc((int)base.targetPlayer.playerClientId);
			return absorbPlayerObject;
		}

		[ClientRpc]
		public void AbsorbPlayerObjectClientRpc(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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1373637753u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1373637753u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerId].GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return;
			}
			for (int i = 0; i < component.ItemSlots.Length; i++)
			{
				GrabbableObject val3 = component.ItemSlots[i];
				if (CanBeAbsorbed(val3, 15f))
				{
					absorbDistance = 5;
					closestLightSource = ((Component)val3).gameObject;
					break;
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (base.currentBehaviourStateIndex == 3 && stunCoroutine == null && attackCoroutine == null && killCoroutine == null)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					AttackServerRpc((int)val.playerClientId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AttackServerRpc(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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3866375404u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3866375404u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					AttackClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		public void AttackClientRpc(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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1596026719u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1596026719u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && attackCoroutine == null)
				{
					attackCoroutine = ((MonoBehaviour)this).StartCoroutine(AttackCoroutine(StartOfRound.Instance.allPlayerObjects[playerId].GetComponent<PlayerControllerB>()));
				}
			}
		}

		public IEnumerator AttackCoroutine(PlayerControllerB player)
		{
			base.creatureAnimator.SetTrigger("startAttack");
			base.creatureSFX.PlayOneShot(SwingSound);
			yield return (object)new WaitForSeconds(0.8f);
			player.DamagePlayer(ConfigManager.damage.Value, true, true, (CauseOfDeath)8, 0, false, default(Vector3));
			base.creatureAnimator.SetTrigger("startRun");
			attackCoroutine = null;
		}

		public bool CrossingLight()
		{
			Animator? obj = ((IEnumerable<Animator>)RoundManager.Instance.allPoweredLightsAnimators).FirstOrDefault((Func<Animator, bool>)((Animator l) => (Object)(object)l != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)l).transform.position) <= 10f));
			object obj2 = ((obj != null) ? ((Component)obj).gameObject : null);
			if (obj2 == null)
			{
				GrabbableObject? obj3 = ((IEnumerable<GrabbableObject>)LightEater.grabbableObjects).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject g) => CanBeAbsorbed(g, 10f)));
				obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
				if (obj2 == null)
				{
					Turret? obj4 = ((IEnumerable<Turret>)LightEater.turrets).FirstOrDefault((Func<Turret, bool>)((Turret t) => (Object)(object)t != (Object)null && t.turretActive && Vector3.Distance(((Component)this).transform.position, ((Component)t).transform.position) <= 10f));
					obj2 = ((obj4 != null) ? ((Component)obj4).gameObject : null);
					if (obj2 == null)
					{
						Landmine? obj5 = ((IEnumerable<Landmine>)LightEater.landmines).FirstOrDefault((Func<Landmine, bool>)((Landmine l) => (Object)(object)l != (Object)null && l.mineActivated && Vector3.Distance(((Component)this).transform.position, ((Component)l).transform.position) <= 10f));
						obj2 = ((obj5 != null) ? ((Component)obj5).gameObject : null);
					}
				}
			}
			GameObject val = (GameObject)obj2;
			if ((Object)(object)val != (Object)null)
			{
				absorbDistance = 5;
				closestLightSource = val;
			}
			return (Object)(object)closestLightSource != (Object)null;
		}

		public bool CanBeAbsorbed(GrabbableObject grabbableObject, float distance)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)grabbableObject == (Object)null)
			{
				return false;
			}
			if (!grabbableObject.itemProperties.requiresBattery)
			{
				return false;
			}
			if (grabbableObject.insertedBattery == null || grabbableObject.insertedBattery.charge <= 0f)
			{
				return false;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)grabbableObject).transform.position) > distance)
			{
				return false;
			}
			PatcherTool val = (PatcherTool)(object)((grabbableObject is PatcherTool) ? grabbableObject : null);
			if (val != null && val.isShocking)
			{
				return false;
			}
			return true;
		}

		public object DetermineLightSource()
		{
			ShipLights componentInParent = closestLightSource.GetComponentInParent<ShipLights>();
			if (componentInParent != null)
			{
				return componentInParent;
			}
			GrabbableObject result = default(GrabbableObject);
			if (closestLightSource.TryGetComponent<GrabbableObject>(ref result))
			{
				return result;
			}
			Turret componentInParent2 = closestLightSource.GetComponentInParent<Turret>();
			if (componentInParent2 != null)
			{
				return componentInParent2;
			}
			Landmine componentInParent3 = closestLightSource.GetComponentInParent<Landmine>();
			if (componentInParent3 != null)
			{
				return componentInParent3;
			}
			EnemyAI componentInParent4 = closestLightSource.GetComponentInParent<EnemyAI>();
			if (componentInParent4 != null)
			{
				return componentInParent4;
			}
			return ((IEnumerable<Animator>)RoundManager.Instance.allPoweredLightsAnimators).FirstOrDefault((Func<Animator, bool>)((Animator l) => (Object)(object)((l != null) ? ((Component)l).gameObject : null) == (Object)(object)closestLightSource));
		}

		public void GoTowardsEntrance()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			EntranceTeleport closestEntrance = GetClosestEntrance();
			if (Vector3.Distance(((Component)this).transform.position, closestEntrance.entrancePoint.position) < 1f)
			{
				Vector3 entranceExitPosition = GetEntranceExitPosition(closestEntrance);
				((MonoBehaviour)this).StartCoroutine(TeleportEnemyCoroutine(entranceExitPosition));
			}
			else
			{
				((EnemyAI)this).SetDestinationToPosition(closestEntrance.entrancePoint.position, false);
			}
		}

		public EntranceTeleport GetClosestEntrance()
		{
			return (from e in entrances
				where e.isEntranceToBuilding == base.isOutside
				orderby Vector3.Distance(((Component)this).transform.position, e.entrancePoint.position)
				select e).FirstOrDefault();
		}

		public Vector3 GetEntranceExitPosition(EntranceTeleport entranceTeleport)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.isEntranceToBuilding != entranceTeleport.isEntranceToBuilding && e.entranceId == entranceTeleport.entranceId)).entrancePoint.position;
		}

		public IEnumerator TeleportEnemyCoroutine(Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(1f);
			TeleportEnemyClientRpc(position, !base.isOutside);
		}

		[ClientRpc]
		public void TeleportEnemyClientRpc(Vector3 teleportPosition, bool isOutside)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3427173509u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref teleportPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isOutside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3427173509u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((EnemyAI)this).SetEnemyOutside(isOutside);
					base.serverPosition = teleportPosition;
					((Component)this).transform.position = teleportPosition;
					base.agent.Warp(teleportPosition);
					((EnemyAI)this).SyncPositionToClients();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ShockEnemyServerRpc(int charge)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2218259456u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, charge);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2218259456u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					currentCharge += charge;
					isShocked = false;
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (!base.isEnemyDead && base.enemyType.canDie)
			{
				((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
				base.enemyHP -= force;
				if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(!LightEater.isSellBodies);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			killCoroutine = ((MonoBehaviour)this).StartCoroutine(KillEnemyCoroutine(destroy));
		}

		public IEnumerator KillEnemyCoroutine(bool destroy)
		{
			base.creatureAnimator.SetTrigger("startExplode");
			base.creatureSFX.PlayOneShot(ChargeSound);
			yield return (object)new WaitForSeconds(4f);
			<>n__0(destroy);
			Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up, true, 6f, 6.3f, 50, 0f, (GameObject)null, false);
		}

		[ServerRpc(RequireOwnership = false)]
		public void DoAnimationServerRpc(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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ba: 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(1228153506u, val, (RpcDelivery)0);
				bool flag = animationState != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationState, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1228153506u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DoAnimationClientRpc(animationState);
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ba: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2154635945u, val, (RpcDelivery)0);
				bool flag = animationState != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationState, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2154635945u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationState);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LightEaterAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3900372421u, new RpcReceiveHandler(__rpc_handler_3900372421));
			NetworkManager.__rpc_func_table.Add(1914148197u, new RpcReceiveHandler(__rpc_handler_1914148197));
			NetworkManager.__rpc_func_table.Add(2458810888u, new RpcReceiveHandler(__rpc_handler_2458810888));
			NetworkManager.__rpc_func_table.Add(2969224247u, new RpcReceiveHandler(__rpc_handler_2969224247));
			NetworkManager.__rpc_func_table.Add(1373637753u, new RpcReceiveHandler(__rpc_handler_1373637753));
			NetworkManager.__rpc_func_table.Add(3866375404u, new RpcReceiveHandler(__rpc_handler_3866375404));
			NetworkManager.__rpc_func_table.Add(1596026719u, new RpcReceiveHandler(__rpc_handler_1596026719));
			NetworkManager.__rpc_func_table.Add(3427173509u, new RpcReceiveHandler(__rpc_handler_3427173509));
			NetworkManager.__rpc_func_table.Add(2218259456u, new RpcReceiveHandler(__rpc_handler_2218259456));
			NetworkManager.__rpc_func_table.Add(1228153506u, new RpcReceiveHandler(__rpc_handler_1228153506));
			NetworkManager.__rpc_func_table.Add(2154635945u, new RpcReceiveHandler(__rpc_handler_2154635945));
		}

		private static void __rpc_handler_3900372421(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)2;
				((LightEaterAI)(object)target).AbsorbLightClientRpc(obj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1914148197(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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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 objectName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref objectName, false);
				}
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LightEaterAI)(object)target).AbsorbLightClientRpc(objectName, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2458810888(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)2;
				((LightEaterAI)(object)target).StunEnemyClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2969224247(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)2;
				((LightEaterAI)(object)target).StunExplosionClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1373637753(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)2;
				((LightEaterAI)(object)target).AbsorbPlayerObjectClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3866375404(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).AttackServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1596026719(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)2;
				((LightEaterAI)(object)target).AttackClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3427173509(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 teleportPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref teleportPosition);
				bool isOutside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isOutside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LightEaterAI)(object)target).TeleportEnemyClientRpc(teleportPosition, isOutside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2218259456(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 charge = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref charge);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LightEaterAI)(object)target).ShockEnemyServerRpc(charge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1228153506(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).DoAnimationServerRpc(animationState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2154635945(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)2;
				((LightEaterAI)(object)target).DoAnimationClientRpc(animationState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "LightEaterAI";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace LightEater.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}