Decompiled source of Moon Enemy v0.2.0

Moon_Enemy.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Moon_Enemy;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using Unity.AI.Navigation;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("yzch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Moon_Enemy")]
[assembly: AssemblyTitle("Moon_Enemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
public class EnemyMoon : MonoBehaviour
{
	public enum State
	{
		Spawn,
		Despawn,
		Routing,
		Prepare,
		FlyDown,
		Run,
		RushPlayerIn,
		RushPlayerOut,
		FlyUp
	}

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

		private object <>2__current;

		public Light l;

		public EnemyMoon <>4__this;

		private int <flickTimes>5__1;

		private int <i>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<flickTimes>5__1 = Random.Range(2, 4);
				<i>5__2 = 0;
				break;
			case 1:
				<>1__state = -1;
				((Behaviour)l).enabled = true;
				<>2__current = (object)new WaitForSeconds(Random.Range(0.4f, 0.65f));
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<i>5__2++;
				break;
			}
			if (<i>5__2 < <flickTimes>5__1)
			{
				((Behaviour)l).enabled = false;
				<>2__current = (object)new WaitForSeconds(Random.Range(0.2f, 0.5f));
				<>1__state = 1;
				return true;
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public Light l;

		public bool secondTime;

		public EnemyMoon <>4__this;

		private float <defValue>5__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<defValue>5__1 = l.intensity;
				<>2__current = (object)new WaitForSeconds(Random.Range(0f, 2f));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				goto IL_0142;
			case 2:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 5;
				return true;
			case 5:
				<>1__state = -1;
				goto IL_0142;
			case 6:
				<>1__state = -1;
				break;
			case 7:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 8;
				return true;
			case 8:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 9;
				return true;
			case 9:
				<>1__state = -1;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 10;
				return true;
			case 10:
				{
					<>1__state = -1;
					break;
				}
				IL_0142:
				if (Object.op_Implicit((Object)(object)l) && l.intensity > 0f)
				{
					Light obj = l;
					obj.intensity -= 110f * Time.deltaTime;
					<>2__current = (object)new WaitForNextFrameUnit();
					<>1__state = 2;
					return true;
				}
				if (Object.op_Implicit((Object)(object)l))
				{
					l.intensity = 0f;
				}
				if (Object.op_Implicit((Object)(object)l) && Random.value >= 0.7f)
				{
					<>4__this.audioLampFlicke.Play(((Component)l).transform.position, 1f, 1f, 1f, 1f);
				}
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 6;
				return true;
			}
			if (Object.op_Implicit((Object)(object)l) && l.intensity < <defValue>5__1)
			{
				Light obj2 = l;
				obj2.intensity += 110f * Time.deltaTime;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 7;
				return true;
			}
			if (Object.op_Implicit((Object)(object)l))
			{
				l.intensity = <defValue>5__1;
			}
			if (!secondTime)
			{
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.FlickerLight(l, secondTime: true));
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public EnemyMoon <>4__this;

		private int <lightId>5__1;

		private PlayerAvatar <localPlayer>5__2;

		private FlashlightController[] <flashLightControllers>5__3;

		private int <i>5__4;

		private PropLight <pl>5__5;

		private int <i>5__6;

		private FlashlightController[] <>s__7;

		private int <>s__8;

		private FlashlightController <f>5__9;

		private Light <l>5__10;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<localPlayer>5__2 = null;
			<flashLightControllers>5__3 = null;
			<pl>5__5 = null;
			<>s__7 = null;
			<f>5__9 = null;
			<l>5__10 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<lightId>5__1 = 0;
				<i>5__4 = 0;
				while (<i>5__4 < <>4__this.allLights.Length)
				{
					if (Object.op_Implicit((Object)(object)<>4__this.allLights[<i>5__4]))
					{
						<pl>5__5 = ((Component)<>4__this.allLights[<i>5__4]).gameObject.GetComponent<PropLight>();
						if (Object.op_Implicit((Object)(object)<pl>5__5))
						{
							<>4__this.allLightsDefValue[<i>5__4] = <pl>5__5.originalIntensity;
						}
						else
						{
							<>4__this.allLightsDefValue[<i>5__4] = <>4__this.allLights[<i>5__4].intensity;
						}
						<pl>5__5 = null;
					}
					<i>5__4++;
				}
				<localPlayer>5__2 = PlayerAvatar.instance;
				SemiFunc.CameraShake(2f, 0.4f);
				<i>5__6 = 0;
				while (<i>5__6 < <>4__this.allLights.Length)
				{
					if (Object.op_Implicit((Object)(object)<>4__this.allLights[<i>5__6]) && Vector3.Distance(((Component)<localPlayer>5__2).transform.position, ((Component)<>4__this.allLights[<i>5__6]).transform.position) <= 20f)
					{
						((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.FlickerLight(<>4__this.allLights[<i>5__6], secondTime: false));
					}
					<i>5__6++;
				}
				<flashLightControllers>5__3 = Object.FindObjectsOfType<FlashlightController>();
				<>s__7 = <flashLightControllers>5__3;
				for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++)
				{
					<f>5__9 = <>s__7[<>s__8];
					<l>5__10 = ((Component)((Component)<f>5__9).transform).GetComponentInChildren<Light>(true);
					if (Object.op_Implicit((Object)(object)<l>5__10))
					{
						((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.FlickerFlashlight(<l>5__10));
					}
					<l>5__10 = null;
					<f>5__9 = null;
				}
				<>s__7 = null;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			if (!<>4__this.IsClient() && <>4__this.stateTimer > 0f)
			{
				<>4__this.stateTimer -= Time.deltaTime;
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 2;
				return true;
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public float delay;

		public EnemyMoon <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.SetLights(onOff: true));
				return false;
			}
		}

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

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

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

		private object <>2__current;

		public EnemyMoon <>4__this;

		private LevelGenerator <lvlg>5__1;

		private NavMeshSurface <navMesh>5__2;

		private int <checkpointsCount>5__3;

		private float <totalDistance>5__4;

		private int <i>5__5;

		private Module <m>5__6;

		private Vector3 <point>5__7;

		private NavMeshHit <hit>5__8;

		private int <i>5__9;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<lvlg>5__1 = null;
			<navMesh>5__2 = null;
			<m>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<lvlg>5__1 = LevelGenerator.Instance;
				<navMesh>5__2 = NavMeshSurface.activeSurfaces[0];
				<checkpointsCount>5__3 = Random.Range(<>4__this.checkpoints_min, <>4__this.checkpoints_max + 1);
				<>4__this.checkpoints = (Vector3[])(object)new Vector3[<checkpointsCount>5__3];
				<i>5__5 = 0;
				goto IL_0173;
			case 1:
				<>1__state = -1;
				<m>5__6 = null;
				<i>5__5++;
				goto IL_0173;
			case 2:
				{
					<>1__state = -1;
					<i>5__9++;
					break;
				}
				IL_0173:
				if (<i>5__5 < <>4__this.checkpoints.Length)
				{
					<m>5__6 = <>4__this.modules[Random.Range(0, <>4__this.modules.Length)];
					<point>5__7 = ((Component)((Component)<m>5__6).transform.GetChild(Random.Range(2, ((Component)<m>5__6).transform.childCount))).transform.position;
					if (NavMesh.SamplePosition(<point>5__7, ref <hit>5__8, 99999f, -1))
					{
						<>4__this.checkpoints[<i>5__5] = ((NavMeshHit)(ref <hit>5__8)).position;
					}
					else
					{
						<i>5__5--;
					}
					<>2__current = (object)new WaitForNextFrameUnit();
					<>1__state = 1;
					return true;
				}
				<totalDistance>5__4 = 0f;
				<i>5__9 = 0;
				break;
			}
			if (<i>5__9 < <>4__this.checkpoints.Length - 1)
			{
				<totalDistance>5__4 += Vector3.Distance(<>4__this.checkpoints[<i>5__9], <>4__this.checkpoints[<i>5__9 + 1]);
				<>2__current = (object)new WaitForNextFrameUnit();
				<>1__state = 2;
				return true;
			}
			if (<totalDistance>5__4 < <>4__this.routeLength_min)
			{
				<>4__this.checkpoints = null;
			}
			<>4__this.routingFinished = true;
			return false;
		}

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

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

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

		private object <>2__current;

		public bool onOff;

		public EnemyMoon <>4__this;

		private int <lightId>5__1;

		private bool <finished>5__2;

		private int <i>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<lightId>5__1 = 0;
				<finished>5__2 = false;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (!RoundDirector.instance.allExtractionPointsCompleted)
			{
				<i>5__3 = 0;
				while (<i>5__3 < <>4__this.flickerLightsPerFrame)
				{
					if (Object.op_Implicit((Object)(object)<>4__this.allLights[<lightId>5__1]))
					{
						((Behaviour)<>4__this.allLights[<lightId>5__1]).enabled = onOff;
						<>4__this.allLights[<lightId>5__1].intensity = <>4__this.allLightsDefValue[<lightId>5__1];
					}
					<lightId>5__1++;
					if (<lightId>5__1 >= <>4__this.allLights.Length)
					{
						<finished>5__2 = true;
						break;
					}
					<i>5__3++;
				}
				if (!<finished>5__2)
				{
					<>2__current = (object)new WaitForNextFrameUnit();
					<>1__state = 1;
					return true;
				}
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public EnemyMoon <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<>4__this.currentState == State.Run || <>4__this.currentState == State.FlyDown || <>4__this.currentState == State.RushPlayerIn || <>4__this.currentState == State.RushPlayerOut || <>4__this.currentState == State.FlyUp)
			{
				SemiFunc.CameraShakeImpactDistance(<>4__this.CamShakeCenter.transform.position, <>4__this.cameraShakeStrength, 0.3f, 0f, 12f);
				<>2__current = (object)new WaitForSeconds(0.2f);
				<>1__state = 1;
				return true;
			}
			return false;
		}

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

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

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

		private object <>2__current;

		public EnemyMoon <>4__this;

		private int <i>5__1;

		private PlayerAvatar <p>5__2;

		private Vector3 <playerCenter>5__3;

		private Vector3 <direction>5__4;

		private float <distance>5__5;

		private RaycastHit <hitInfo>5__6;

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

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

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

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

		private bool MoveNext()
		{
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				goto IL_02d2;
			case 1:
				<>1__state = -1;
				goto IL_02d2;
			case 2:
				<>1__state = -1;
				goto IL_02d2;
			case 3:
				<>1__state = -1;
				<p>5__2 = null;
				<i>5__1--;
				goto IL_029c;
			case 4:
				{
					<>1__state = -1;
					goto IL_02d2;
				}
				IL_02d2:
				if (<>4__this.currentState == State.Run || <>4__this.currentState == State.FlyDown || <>4__this.currentState == State.RushPlayerIn || <>4__this.currentState == State.RushPlayerOut || <>4__this.currentState == State.FlyUp)
				{
					if (Object.op_Implicit((Object)(object)<>4__this.playerTarget) || <>4__this.currentState != State.Run)
					{
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					}
					if (<>4__this.IsClient())
					{
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 2;
						return true;
					}
					<i>5__1 = <>4__this.playersToHunt.Count - 1;
					goto IL_029c;
				}
				return false;
				IL_02b1:
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 4;
				return true;
				IL_029c:
				if (<i>5__1 >= 0)
				{
					<p>5__2 = <>4__this.playersToHunt[<i>5__1];
					if (<p>5__2.playerHealth.health > 0)
					{
						<playerCenter>5__3 = <>4__this.GetPlayerCenter(<p>5__2);
						<direction>5__4 = <playerCenter>5__3 - <>4__this.MeshGO.transform.position;
						<distance>5__5 = Vector3.Distance(<playerCenter>5__3, <>4__this.MeshGO.transform.position);
						if (<distance>5__5 <= <>4__this.visionRange && !Physics.Raycast(<>4__this.MeshGO.transform.position, <direction>5__4, ref <hitInfo>5__6, <distance>5__5, LayerMask.op_Implicit(<>4__this.visionLayerMask)))
						{
							Debug.Log((object)"See player!");
							if (GameManager.Multiplayer())
							{
								<>4__this.photonView.RPC("SetPlayerTargetRPC", (RpcTarget)0, new object[1] { <p>5__2.playerName });
							}
							else
							{
								<>4__this.SetPlayerTargetRPC(<p>5__2.playerName);
							}
							<>4__this.playersToHunt.RemoveAt(<i>5__1);
							<>4__this.UpdateState(State.RushPlayerIn);
							goto IL_02b1;
						}
					}
					<>2__current = (object)new WaitForNextFrameUnit();
					<>1__state = 3;
					return true;
				}
				goto IL_02b1;
			}
		}

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

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

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

		private object <>2__current;

		public EnemyMoon <>4__this;

		private int <lightId>5__1;

		private int <i>5__2;

		private Light <l>5__3;

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

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

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

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

		private bool MoveNext()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<lightId>5__1 = 0;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<>4__this.currentState == State.Run || <>4__this.currentState == State.FlyDown || <>4__this.currentState == State.RushPlayerIn || <>4__this.currentState == State.RushPlayerOut || <>4__this.currentState == State.FlyUp)
			{
				<i>5__2 = 0;
				while (<i>5__2 < <>4__this.flickerLightsPerFrame)
				{
					<l>5__3 = <>4__this.allLights[<lightId>5__1];
					if (Object.op_Implicit((Object)(object)<l>5__3) && ((Behaviour)<l>5__3).enabled && Vector3.Distance(((Component)<l>5__3).transform.position, <>4__this.MeshGO.transform.position) <= 15f)
					{
						((Behaviour)<l>5__3).enabled = false;
						<>4__this.audioLampBreak.Play(((Component)<l>5__3).transform.position, 1f, 1f, 1f, 1f);
					}
					<lightId>5__1++;
					if (<lightId>5__1 >= <>4__this.allLights.Length)
					{
						<lightId>5__1 = 0;
					}
					<l>5__3 = null;
					<i>5__2++;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 1;
				return true;
			}
			return false;
		}

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

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

	private PhotonView photonView;

	public GameObject MeshGO;

	public GameObject CamShakeCenter;

	public GameObject FollowTarget;

	public ParticleSystem Particle_Smoke;

	public EnemyNavMeshAgent enemyNavAgent;

	public EnemyRigidbody enemyRigidbody;

	private State currentState;

	private bool stateImpulse = true;

	private float stateTimer;

	private bool routingFinished = false;

	[Header("State timers")]
	public float stateDespawnTimer_min;

	public float stateDespawnTimer_max;

	public float statePrepareTimer;

	[Header("Routing")]
	public int checkpoints_min;

	public int checkpoints_max;

	public float routeLength_min;

	[Header("Prepare")]
	public int flickerLightsPerFrame;

	public float cameraShakeStrength;

	[Header("Hunt / Run")]
	public float visionRange;

	public int baseDamage;

	public float huntSpeed;

	public float rushToPlayerSpeed;

	public float lightsRestore_min;

	public float lightsRestore_max;

	private int curCheckpoint;

	private Vector3[] checkpoints;

	private Module[] modules;

	private float[] allLightsDefValue;

	private Light[] allLights;

	private PlayerAvatar playerTarget;

	public Sound audioLampFlicke;

	public Sound audioLampBreak;

	public HurtCollider hurtCollider;

	public LayerMask visionLayerMask;

	private List<PlayerAvatar> playersToHunt = new List<PlayerAvatar>();

	private static readonly Vector3 MeshGOOffset = new Vector3(0f, 1.5f, 0f);

	private bool ConfigLoaded = false;

	private void Awake()
	{
		photonView = ((Component)this).GetComponent<PhotonView>();
		global::Moon_Enemy.Moon_Enemy.Logger.LogInfo((object)"Config is loading... Awake()");
		stateDespawnTimer_min = global::Moon_Enemy.Moon_Enemy.stateDespawnTimer_min.Value;
		stateDespawnTimer_max = global::Moon_Enemy.Moon_Enemy.stateDespawnTimer_max.Value;
		statePrepareTimer = global::Moon_Enemy.Moon_Enemy.statePrepareTimer.Value;
		checkpoints_min = global::Moon_Enemy.Moon_Enemy.checkPoints_min.Value;
		checkpoints_max = global::Moon_Enemy.Moon_Enemy.checkPoints_max.Value;
		routeLength_min = global::Moon_Enemy.Moon_Enemy.routeLength_min.Value;
		flickerLightsPerFrame = global::Moon_Enemy.Moon_Enemy.flickerLightsPerFrame.Value;
		cameraShakeStrength = global::Moon_Enemy.Moon_Enemy.cameraShakeStrength.Value;
		visionRange = global::Moon_Enemy.Moon_Enemy.visionRange.Value;
		if (GameManager.Multiplayer())
		{
			if (!IsClient())
			{
				photonView.RPC("ApplyConfigRPC", (RpcTarget)0, new object[5]
				{
					global::Moon_Enemy.Moon_Enemy.baseDamage.Value,
					global::Moon_Enemy.Moon_Enemy.huntSpeed.Value,
					global::Moon_Enemy.Moon_Enemy.rushPlayerSpeed.Value,
					global::Moon_Enemy.Moon_Enemy.lightsRestore_min.Value,
					global::Moon_Enemy.Moon_Enemy.lightsRestore_max.Value
				});
			}
		}
		else
		{
			ApplyConfigRPC(global::Moon_Enemy.Moon_Enemy.baseDamage.Value, global::Moon_Enemy.Moon_Enemy.huntSpeed.Value, global::Moon_Enemy.Moon_Enemy.rushPlayerSpeed.Value, global::Moon_Enemy.Moon_Enemy.lightsRestore_min.Value, global::Moon_Enemy.Moon_Enemy.lightsRestore_max.Value);
		}
	}

	[PunRPC]
	public void ApplyConfigRPC(int baseDamage, float huntSpeed, float rushToPlayerSpeed, float lightsRestore_min, float lightsRestore_max)
	{
		this.baseDamage = baseDamage;
		this.huntSpeed = huntSpeed;
		this.rushToPlayerSpeed = rushToPlayerSpeed;
		this.lightsRestore_min = lightsRestore_min;
		this.lightsRestore_max = lightsRestore_max;
		global::Moon_Enemy.Moon_Enemy.Logger.LogInfo((object)"Config fetched! [PunRPC] ApplyConfigRPC(..)");
		ConfigLoaded = true;
	}

	private void Start()
	{
		currentState = State.Spawn;
	}

	private void Update()
	{
		if (LevelGenerator.Instance.Generated)
		{
			switch (currentState)
			{
			case State.Spawn:
				StateSpawn();
				break;
			case State.Despawn:
				StateDespawn();
				break;
			case State.Routing:
				StateRouting();
				break;
			case State.Prepare:
				StatePrepare();
				break;
			case State.FlyDown:
				StateFlyDownUp(up: false);
				break;
			case State.Run:
				StateRun();
				break;
			case State.RushPlayerIn:
				StateRushPlayerIn();
				break;
			case State.RushPlayerOut:
				StateRushPlayerOut();
				break;
			case State.FlyUp:
				StateFlyDownUp(up: true);
				break;
			}
		}
	}

	private void UpdateState(State _state)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if (currentState != _state)
		{
			if (GameManager.Multiplayer())
			{
				photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { _state });
			}
			else
			{
				UpdateStateRPC(_state);
			}
		}
	}

	[PunRPC]
	private void UpdateStateRPC(State _state, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		currentState = _state;
		stateImpulse = true;
		stateTimer = 0f;
	}

	private void StateSpawn()
	{
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		MeshGO.SetActive(false);
		modules = Object.FindObjectsOfType<Module>();
		allLights = ((Component)((Component)modules[0]).transform.parent).GetComponentsInChildren<Light>(true);
		allLightsDefValue = new float[allLights.Length];
		hurtCollider.playerDamage = baseDamage;
		enemyNavAgent.DefaultSpeed = huntSpeed;
		enemyNavAgent.Agent.speed = huntSpeed;
		if (IsClient())
		{
			return;
		}
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 1f;
			enemyNavAgent.Warp(((Component)enemyNavAgent).transform.position, false);
			enemyNavAgent.ResetPath();
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			if (MeshGO.activeSelf)
			{
				MeshGO.SetActive(false);
				stateTimer = 1f;
			}
			else
			{
				UpdateState(State.Despawn);
			}
		}
	}

	private void StateDespawn()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = Random.Range(stateDespawnTimer_min, stateDespawnTimer_max);
			((Component)Particle_Smoke).transform.SetParent(((Component)this).transform, true);
			Particle_Smoke.Stop();
			MeshGO.SetActive(false);
			playerTarget = null;
		}
		if (MeshGO.activeSelf)
		{
			MeshGO.SetActive(false);
		}
		if (IsClient())
		{
			return;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			if (RoundDirector.instance.allExtractionPointsCompleted)
			{
				stateTimer = 30f;
			}
			else
			{
				UpdateState(State.Routing);
			}
		}
	}

	private void StateRouting()
	{
		if (IsClient())
		{
			return;
		}
		if (stateImpulse)
		{
			stateImpulse = false;
			routingFinished = false;
			((MonoBehaviour)this).StartCoroutine(RouteNewPath());
		}
		if (routingFinished)
		{
			if (checkpoints == null)
			{
				stateImpulse = true;
			}
			else
			{
				UpdateState(State.Prepare);
			}
		}
	}

	private void StatePrepare()
	{
		//IL_0052: 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)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = statePrepareTimer;
			((MonoBehaviour)this).StartCoroutine(FlickerLights());
			playerTarget = null;
			if (IsClient())
			{
				return;
			}
			enemyNavAgent.Warp(checkpoints[0], false);
			FollowTarget.transform.localPosition = new Vector3(0f, 40f, 0f);
			enemyRigidbody.Teleport();
			curCheckpoint = 0;
			playersToHunt = new List<PlayerAvatar>(GameDirector.instance.PlayerList);
		}
		if (!IsClient() && stateTimer <= 0f)
		{
			UpdateState(State.FlyDown);
		}
	}

	private void StateRun()
	{
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 5f;
			enemyRigidbody.positionSpeedChase = huntSpeed;
			if (!Object.op_Implicit((Object)(object)playerTarget))
			{
				((MonoBehaviour)this).StartCoroutine(StateRunning_HuntPayer());
			}
			else
			{
				playerTarget = null;
			}
			if (IsClient())
			{
				return;
			}
			((Behaviour)enemyNavAgent.Agent).enabled = true;
			enemyNavAgent.SetDestination(checkpoints[curCheckpoint]);
		}
		if (IsClient())
		{
			return;
		}
		Vector3 val = checkpoints[curCheckpoint];
		float num = Vector3.Distance(((Component)enemyNavAgent).gameObject.transform.position, val);
		if (num < 0.2f)
		{
			if (curCheckpoint + 1 >= checkpoints.Length)
			{
				float num2 = Random.Range(lightsRestore_min, lightsRestore_max);
				if (GameManager.Multiplayer())
				{
					photonView.RPC("RestoreLightsRPC", (RpcTarget)0, new object[1] { num2 });
				}
				else
				{
					RestoreLightsRPC(num2);
				}
				UpdateState(State.FlyUp);
			}
			else
			{
				curCheckpoint++;
				enemyNavAgent.SetDestination(checkpoints[curCheckpoint]);
			}
		}
		UpdateMovement();
	}

	private void StateFlyDownUp(bool up)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		if (up)
		{
			if (!IsClient())
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f, 40f, 0f);
				Vector3 val2 = val - FollowTarget.transform.localPosition;
				Transform transform = FollowTarget.transform;
				transform.localPosition += val2 * Time.deltaTime * 1.5f;
				if (MeshGO.transform.localPosition.y >= 39.5f)
				{
					FollowTarget.transform.localPosition = val;
					UpdateState(State.Despawn);
				}
			}
			return;
		}
		if (stateImpulse)
		{
			stateImpulse = false;
			enemyRigidbody.positionSpeedChase = 12f;
			MeshGO.SetActive(true);
			if (!Particle_Smoke.isPlaying)
			{
				((Component)Particle_Smoke).transform.SetParent(MeshGO.transform, false);
				((Component)Particle_Smoke).transform.localPosition = Vector3.zero;
				((Component)Particle_Smoke).transform.localEulerAngles = Vector3.zero;
				Particle_Smoke.Play();
			}
			((MonoBehaviour)this).StartCoroutine(StateRunning_CameraShake());
			((MonoBehaviour)this).StartCoroutine(StateRunning_TakeLightsOff());
		}
		if (!IsClient())
		{
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(0f, 1.5f, 0f);
			Vector3 val4 = val3 - FollowTarget.transform.localPosition;
			Transform transform2 = FollowTarget.transform;
			transform2.localPosition += val4 * Time.deltaTime * 1.5f;
			if (MeshGO.transform.localPosition.y <= 1.55f)
			{
				FollowTarget.transform.localPosition = val3;
				UpdateState(State.Run);
			}
		}
	}

	private void StateRushPlayerIn()
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			if ((Object)(object)playerTarget == (Object)(object)PlayerAvatar.instance)
			{
				CameraGlitch.Instance.PlayLong();
			}
			enemyRigidbody.positionSpeedChase = rushToPlayerSpeed;
			if (IsClient())
			{
				return;
			}
			((Behaviour)enemyNavAgent.Agent).enabled = false;
		}
		if ((Object)(object)playerTarget == (Object)(object)PlayerAvatar.instance)
		{
			CameraAim.Instance.AimTargetSoftSet(MeshGO.transform.position, 0.1f, 25f, 25f, ((Component)this).gameObject, 100);
			PostProcessing.Instance.VignetteOverride(Color.black, 0.5f, 1f, 1f, 0.5f, 0.1f, ((Component)this).gameObject);
		}
		if (!IsClient())
		{
			if ((Object)(object)playerTarget == (Object)null)
			{
				UpdateState(State.RushPlayerOut);
				return;
			}
			if (playerTarget.playerHealth.health <= 0)
			{
				UpdateState(State.RushPlayerOut);
				return;
			}
			Vector3 val = GetPlayerCenter(playerTarget) - MeshGO.transform.position;
			Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, MeshGO.transform.up);
			Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles;
			FollowTarget.transform.position = GetPlayerCenter(playerTarget);
			FollowTarget.transform.localEulerAngles = new Vector3(eulerAngles.x, eulerAngles.y + 90f, eulerAngles.z);
		}
	}

	private void StateRushPlayerOut()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_0092: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
		}
		if (!IsClient())
		{
			if (Vector3.Distance(MeshGO.transform.position, ((Component)enemyNavAgent).transform.position + MeshGOOffset) < 0.15f)
			{
				UpdateState(State.Run);
				return;
			}
			Vector3 val = ((Component)enemyNavAgent).transform.position + MeshGOOffset - MeshGO.transform.position;
			Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, MeshGO.transform.up);
			Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles;
			FollowTarget.transform.localPosition = MeshGOOffset;
			FollowTarget.transform.localEulerAngles = new Vector3(eulerAngles.x, eulerAngles.y + 90f, eulerAngles.z);
		}
	}

	private void UpdateMovement()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		if (((Behaviour)enemyNavAgent).isActiveAndEnabled)
		{
			Quaternion val = Quaternion.LookRotation(enemyNavAgent.AgentVelocity, MeshGO.transform.up);
			Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles;
			FollowTarget.transform.localEulerAngles = new Vector3(0f, eulerAngles.y + 90f, 0f);
		}
	}

	public void OnPlayerImpact()
	{
		if (!IsClient() && currentState == State.RushPlayerIn && Object.op_Implicit((Object)(object)playerTarget))
		{
			UpdateState(State.RushPlayerOut);
		}
	}

	private Vector3 GetPlayerCenter(PlayerAvatar p)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)p).transform.position;
		position.y += 1.4f;
		if (p.isCrouching)
		{
			position.y -= 0.7f;
		}
		if (p.isCrawling)
		{
			position.y -= 0.45f;
		}
		return position;
	}

	private void WarpMeshGO(Vector3 pos)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		FollowTarget.transform.position = new Vector3(pos.x + MeshGOOffset.x, MeshGO.transform.position.y + (pos.y - MeshGO.transform.position.y) * Time.deltaTime * 1.5f + MeshGOOffset.y, pos.z + MeshGOOffset.z);
	}

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

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

	[IteratorStateMachine(typeof(<FlickerFlashlight>d__59))]
	private IEnumerator FlickerFlashlight(Light l)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FlickerFlashlight>d__59(0)
		{
			<>4__this = this,
			l = l
		};
	}

	[IteratorStateMachine(typeof(<FlickerLight>d__60))]
	private IEnumerator FlickerLight(Light l, bool secondTime)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FlickerLight>d__60(0)
		{
			<>4__this = this,
			l = l,
			secondTime = secondTime
		};
	}

	[IteratorStateMachine(typeof(<SetLights>d__61))]
	private IEnumerator SetLights(bool onOff)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SetLights>d__61(0)
		{
			<>4__this = this,
			onOff = onOff
		};
	}

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

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

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

	[IteratorStateMachine(typeof(<RestoreLights>d__65))]
	private IEnumerator RestoreLights(float delay)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RestoreLights>d__65(0)
		{
			<>4__this = this,
			delay = delay
		};
	}

	[PunRPC]
	public void SetPlayerTargetRPC(string playerName)
	{
		foreach (PlayerAvatar item in playersToHunt)
		{
			if (item.playerName.Equals(playerName))
			{
				playerTarget = item;
				break;
			}
		}
	}

	[PunRPC]
	public void RestoreLightsRPC(float delay)
	{
		((MonoBehaviour)this).StartCoroutine(RestoreLights(delay));
	}

	private bool IsClient()
	{
		return GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient;
	}
}
namespace Moon_Enemy
{
	[BepInPlugin("yzch.Moon_Enemy", "Moon Enemy", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Moon_Enemy : BaseUnityPlugin
	{
		internal static string modFolder;

		public static ConfigEntry<float> spawnChance;

		public static ConfigEntry<int> spawnLevel;

		public static ConfigEntry<bool> spawnInMuseum;

		public static ConfigEntry<float> stateDespawnTimer_min;

		public static ConfigEntry<float> stateDespawnTimer_max;

		public static ConfigEntry<float> statePrepareTimer;

		public static ConfigEntry<int> checkPoints_min;

		public static ConfigEntry<int> checkPoints_max;

		public static ConfigEntry<float> routeLength_min;

		public static ConfigEntry<int> flickerLightsPerFrame;

		public static ConfigEntry<float> cameraShakeStrength;

		public static ConfigEntry<float> visionRange;

		public static ConfigEntry<int> baseDamage;

		public static ConfigEntry<float> huntSpeed;

		public static ConfigEntry<float> rushPlayerSpeed;

		public static ConfigEntry<float> lightsRestore_min;

		public static ConfigEntry<float> lightsRestore_max;

		internal static Moon_Enemy Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal static EnemySetup? moonEnemySetup { get; set; }

		private void Awake()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Expected O, but got Unknown
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Expected O, but got Unknown
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Expected O, but got Unknown
			Instance = this;
			modFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(modFolder, "moon_enemy");
			Logger.LogInfo((object)("Moon_Enemy Path: " + text));
			if (!File.Exists(text))
			{
				Logger.LogError((object)"Bundle file doesn't exist!");
				return;
			}
			spawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Spawn chance", 20f, new ConfigDescription("Chance to remove one random enemy and spawn Moon instead.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			spawnLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Spawn level", 3, new ConfigDescription("At what level can Moon start spawning", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			spawnInMuseum = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Spawn in museum", false, new ConfigDescription("Can spawn in Museum level", (AcceptableValueBase)null, Array.Empty<object>()));
			stateDespawnTimer_min = ((BaseUnityPlugin)this).Config.Bind<float>("State timers", "Despawn MIN", 260f, new ConfigDescription("How long to wait before start hunting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 900f), Array.Empty<object>()));
			stateDespawnTimer_max = ((BaseUnityPlugin)this).Config.Bind<float>("State timers", "Despawn MAX", 600f, new ConfigDescription("How long to wait before start hunting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(11f, 900f), Array.Empty<object>()));
			statePrepareTimer = ((BaseUnityPlugin)this).Config.Bind<float>("State timers", "Prepare", 10f, new ConfigDescription("After lights starts flicking, how long to wait before hunt start.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 15f), Array.Empty<object>()));
			checkPoints_min = ((BaseUnityPlugin)this).Config.Bind<int>("Routing", "Checkpoints MIN", 4, new ConfigDescription("How many points on map will Moon run through", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 15), Array.Empty<object>()));
			checkPoints_max = ((BaseUnityPlugin)this).Config.Bind<int>("Routing", "Checkpoints MAX", 8, new ConfigDescription("How many points on map will Moon run through", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 15), Array.Empty<object>()));
			routeLength_min = ((BaseUnityPlugin)this).Config.Bind<float>("Routing", "Route length MIN", 25f, new ConfigDescription("Minimal path length. Very high number + low checkpoints = game freeze/crash.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f), Array.Empty<object>()));
			flickerLightsPerFrame = ((BaseUnityPlugin)this).Config.Bind<int>("Prepare", "Lights per frame", 16, new ConfigDescription("(Client-side) How many lights gets processed per frame. Leave, if there aren't performance issues.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>()));
			cameraShakeStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Prepare", "Camera shake strength", 12f, new ConfigDescription("(Client-side) How much camera shakes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			visionRange = ((BaseUnityPlugin)this).Config.Bind<float>("Hunt", "Vision range", 15f, new ConfigDescription("How far enemy sees all around itself", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 40f), Array.Empty<object>()));
			baseDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Hunt", "Base damage", 5000, new ConfigDescription("Damage on touch with player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5000), Array.Empty<object>()));
			huntSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Hunt", "Hunt speed", 9f, new ConfigDescription("How fast Moon moves, when roaming around", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			rushPlayerSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Hunt", "Rush player speed", 8f, new ConfigDescription("How fast Moon rushes to player, once it sees one", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			lightsRestore_min = ((BaseUnityPlugin)this).Config.Bind<float>("Hunt", "Lights restore MIN", 30f, new ConfigDescription("How long to wait, before restoring broken lights after hunt ends.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), Array.Empty<object>()));
			lightsRestore_max = ((BaseUnityPlugin)this).Config.Bind<float>("Hunt", "Lights restore MAX", 60f, new ConfigDescription("How long to wait, before restoring broken lights after hunt ends.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 120f), Array.Empty<object>()));
			BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				EnemyContent val = assetBundle.LoadAsset<EnemyContent>("MoonEnemyContent");
				Enemies.RegisterEnemy(val);
				moonEnemySetup = val.Setup;
			}, false);
			Logger.LogWarning((object)"Mod temporarily disabled due to networking bug. It will automatically reactivates once update with fix gets released.");
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}
namespace Turrets
{
	[HarmonyPatch(typeof(LevelGenerator))]
	internal static class LevelGeneratorPatch
	{
		[HarmonyPatch(typeof(LevelGenerator), "Generate")]
		private class LevelGeneratorCoroutinePatch
		{
			[CompilerGenerated]
			private sealed class <WrapCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public IEnumerator original;

				private LevelGenerator <generator>5__1;

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

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

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

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

				private bool MoveNext()
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						break;
					case 1:
						<>1__state = -1;
						break;
					}
					if (original.MoveNext())
					{
						<>2__current = original.Current;
						<>1__state = 1;
						return true;
					}
					if (LevelGenerator.Instance.Level.HasEnemies && !RunManager.instance.levelIsShop)
					{
						<generator>5__1 = LevelGenerator.Instance;
						SpawnDebugEnemy(<generator>5__1);
						<generator>5__1 = null;
					}
					return false;
				}

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

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

			private static IEnumerator Postfix(IEnumerator result)
			{
				return WrapCoroutine(result);
			}

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

		[Harmony]
		private static void SpawnDebugEnemy(LevelGenerator generator)
		{
			if (!GameManager.Multiplayer())
			{
			}
		}
	}
}