Decompiled source of More Drones v0.2.1

BepInEx/plugins/Robin-MoreDrones/RepoMoreDrones.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepoMoreDrones")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1")]
[assembly: AssemblyProduct("RepoMoreDrones")]
[assembly: AssemblyTitle("RepoMoreDrones")]
[assembly: AssemblyVersion("0.2.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 RepoMoreDrones
{
	public static class DiscoEnemySafety
	{
		internal static readonly Type[] SoftControllers = new Type[8]
		{
			typeof(EnemyDuck),
			typeof(EnemyOogly),
			typeof(EnemyElsa),
			typeof(EnemyBirthdayBoy),
			typeof(EnemyThinMan),
			typeof(EnemyAnimal),
			typeof(EnemyValuableThrower),
			typeof(EnemyCeilingEye)
		};

		private static readonly FieldRef<Enemy, bool> RealStunned = AccessTools.FieldRefAccess<Enemy, bool>("Stunned");

		internal static bool NeedsSoftPause(GameObject target)
		{
			Type[] softControllers = SoftControllers;
			foreach (Type type in softControllers)
			{
				if (Object.op_Implicit((Object)(object)target.GetComponent(type)))
				{
					return true;
				}
			}
			return false;
		}

		public static bool ShouldPause(Enemy enemy)
		{
			DiscoDaze discoDaze = default(DiscoDaze);
			if (!Object.op_Implicit((Object)(object)enemy) || !((Component)enemy).TryGetComponent<DiscoDaze>(ref discoDaze) || !discoDaze.UsesSoftPause || !discoDaze.BlocksAttacks)
			{
				return false;
			}
			if (RealStunned.Invoke(enemy))
			{
				return false;
			}
			EnemyStateStunned component = ((Component)enemy).GetComponent<EnemyStateStunned>();
			if (Object.op_Implicit((Object)(object)component))
			{
				return component.stunTimer <= 0f;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class DiscoPauseSpecialControllers
	{
		[HarmonyTargetMethods]
		private static IEnumerable<MethodBase> Targets()
		{
			Type[] softControllers = DiscoEnemySafety.SoftControllers;
			foreach (Type type in softControllers)
			{
				string[] array = new string[2] { "Update", "FixedUpdate" };
				foreach (string text in array)
				{
					MethodInfo methodInfo = AccessTools.DeclaredMethod(type, text, (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						yield return methodInfo;
					}
				}
			}
		}

		[HarmonyPrefix]
		private static bool Prefix(Component __instance)
		{
			return !DiscoEnemySafety.ShouldPause(__instance.GetComponent<Enemy>());
		}
	}
	[HarmonyPatch(typeof(EnemyVision), "VisionTrigger")]
	internal static class DiscoPauseVision
	{
		[HarmonyPrefix]
		private static bool Prefix(EnemyVision __instance)
		{
			DiscoDaze discoDaze = default(DiscoDaze);
			if (((Component)__instance).TryGetComponent<DiscoDaze>(ref discoDaze))
			{
				return !discoDaze.BlocksAttacks;
			}
			return true;
		}
	}
	public static class DroneGeometry
	{
		public static bool RaySphere(Vector3 origin, Vector3 direction, Vector3 centre, float radius, out float distance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			distance = 0f;
			if (radius <= 0f || ((Vector3)(ref direction)).sqrMagnitude < 0.99f)
			{
				return false;
			}
			Vector3 val = origin - centre;
			float num = Vector3.Dot(val, direction);
			float num2 = ((Vector3)(ref val)).sqrMagnitude - radius * radius;
			float num3 = num * num - num2;
			if (num3 < 0f)
			{
				return false;
			}
			if (0f - num + Mathf.Sqrt(num3) < 0f)
			{
				return false;
			}
			distance = Mathf.Max(0f, 0f - num - Mathf.Sqrt(num3));
			return true;
		}

		public static Vector3 ScatterDirection(double time, int ray, int seed)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			double num = time / 1.7 + (double)ray * 0.137;
			int num2 = (int)Math.Floor(num);
			float num3 = (float)(num - Math.Floor(num));
			num3 = num3 * num3 * (3f - 2f * num3);
			float num4 = Hash(num2, ray, seed);
			float num5 = Hash(num2 + 1, ray, seed);
			float num6 = Mathf.LerpAngle(num4 * 360f, num5 * 360f, num3) + (float)ray * 137.508f;
			float num7 = Mathf.Lerp(Hash(num2, ray + 13, seed), Hash(num2 + 1, ray + 13, seed), num3);
			return Quaternion.Euler(Mathf.Lerp(-48f, 58f, num7), num6, 0f) * Vector3.forward;
		}

		private static float Hash(int step, int ray, int seed)
		{
			int num = (step * 747796405) ^ ((ray + 1) * -1403630843) ^ (seed * 277803737);
			int num2 = (num ^ (num >>> 16)) * -2048144777;
			int num3 = (num2 ^ (num2 >>> 13)) * -1028477379;
			return (float)(uint)(num3 ^ (num3 >>> 16)) / 4.2949673E+09f;
		}
	}
	public sealed class DroneLooks : MonoBehaviour
	{
		private sealed class Panel
		{
			internal Transform Transform;

			internal Vector3 Position;

			internal Vector3 Direction;
		}

		private MoreDrone drone;

		private Transform ornament;

		private Light glow;

		private AudioSource music;

		private Material accent;

		private Transform housing;

		private MeshRenderer housingRenderer;

		private Vector3 centreLocal;

		private float unfold;

		private readonly List<Panel> panels = new List<Panel>();

		private static AudioClip? beat;

		private readonly List<Material> owned = new List<Material>();

		public Vector3 Center
		{
			get
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)housing))
				{
					return ((Component)this).transform.position;
				}
				return housing.TransformPoint(centreLocal);
			}
		}

		public float MirrorRadius
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)drone) || !drone.IsDisco)
				{
					return 0f;
				}
				return 0.175f * Mathf.SmoothStep(0f, 1f, unfold);
			}
		}

		public float Unfold => unfold;

		public void Setup(MoreDrone owner)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Expected O, but got Unknown
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			drone = owner;
			housing = ((Component)this).transform.Find("Drone");
			housingRenderer = ((Component)housing).GetComponent<MeshRenderer>();
			MeshRenderer val = housingRenderer;
			Bounds bounds = ((Component)housing).GetComponent<MeshFilter>().sharedMesh.bounds;
			centreLocal = ((Bounds)(ref bounds)).center;
			accent = new Material(((Renderer)val).sharedMaterial);
			owned.Add(accent);
			if (accent.HasProperty("_MainTex"))
			{
				accent.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
			}
			if (accent.HasProperty("_EmissionMap"))
			{
				accent.SetTexture("_EmissionMap", (Texture)(object)Texture2D.whiteTexture);
			}
			accent.EnableKeyword("_EMISSION");
			accent.SetColor("_Color", new Color(0.18f, 0.18f, 0.2f));
			accent.SetColor("_EmissionColor", owner.IsDisco ? new Color(0.5f, 0.04f, 0.8f) : new Color(1f, 0.02f, 0f));
			GameObject val2 = new GameObject(owner.IsDisco ? "Integrated folding mirror core" : "Laser origin");
			val2.transform.SetParent(housing, false);
			val2.transform.localPosition = centreLocal;
			ornament = val2.transform;
			if (owner.IsDisco)
			{
				foreach (Transform item in housing)
				{
					Transform val3 = item;
					if (!((Object)val3).name.StartsWith("Drone Triangle") && !((Object)val3).name.StartsWith("Drone Pyramid"))
					{
						continue;
					}
					Renderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Renderer>();
					if (componentsInChildren.Length != 0)
					{
						Vector3 val4 = Vector3.zero;
						Renderer[] array = componentsInChildren;
						foreach (Renderer val5 in array)
						{
							Vector3 val6 = val4;
							Transform obj = housing;
							bounds = val5.bounds;
							val4 = val6 + obj.InverseTransformPoint(((Bounds)(ref bounds)).center);
						}
						val4 /= (float)componentsInChildren.Length;
						Vector3 val7 = val4 - centreLocal;
						Vector3 direction = ((Vector3)(ref val7)).normalized;
						if (((Vector3)(ref direction)).sqrMagnitude < 0.1f)
						{
							direction = Vector3.up;
						}
						panels.Add(new Panel
						{
							Transform = val3,
							Position = val3.localPosition,
							Direction = direction
						});
					}
				}
				Material val8 = new Material(accent);
				owned.Add(val8);
				val8.SetColor("_Color", new Color(0.5f, 0.55f, 0.65f));
				val8.SetColor("_EmissionColor", Color.black);
				if (val8.HasProperty("_Metallic"))
				{
					val8.SetFloat("_Metallic", 0.8f);
				}
				if (val8.HasProperty("_Glossiness"))
				{
					val8.SetFloat("_Glossiness", 0.75f);
				}
				Part((PrimitiveType)0, ornament, Vector3.zero, Vector3.one * 0.34f, val8);
				for (int j = -2; j <= 2; j++)
				{
					for (int k = 0; k < 14; k++)
					{
						float num = (float)k * MathF.PI * 2f / 14f;
						float num2 = (float)j * 0.43f;
						Vector3 val9 = new Vector3(Mathf.Cos(num) * Mathf.Cos(num2), Mathf.Sin(num2), Mathf.Sin(num) * Mathf.Cos(num2)) * 0.171f;
						Part((PrimitiveType)3, ornament, val9, new Vector3(0.061f, 0.06f, 0.009f), (Material)(((k + j * 3) % 7 == 0) ? ((object)accent) : ((object)val8))).localRotation = Quaternion.LookRotation(val9);
					}
				}
				music = ((Component)this).gameObject.AddComponent<AudioSource>();
				music.playOnAwake = false;
				music.loop = true;
				music.spatialBlend = 1f;
				music.rolloffMode = (AudioRolloffMode)1;
				music.minDistance = 1f;
				music.maxDistance = 14f;
				music.dopplerLevel = 0f;
				music.priority = 180;
				AudioSource component = ((Component)this).GetComponent<AudioSource>();
				if (Object.op_Implicit((Object)(object)component))
				{
					music.outputAudioMixerGroup = component.outputAudioMixerGroup;
				}
				if (!Object.op_Implicit((Object)(object)beat))
				{
					beat = BuildBeat();
				}
				music.clip = beat;
			}
			GameObject val10 = new GameObject("Drone glow");
			val10.transform.SetParent(ornament, false);
			glow = val10.AddComponent<Light>();
			glow.type = (LightType)2;
			glow.range = (owner.IsDisco ? 5f : 1.3f);
			glow.shadows = (LightShadows)0;
			glow.intensity = 0f;
			if (owner.IsDisco)
			{
				ornament.localScale = Vector3.zero;
				((Component)ornament).gameObject.SetActive(false);
			}
		}

		private static Transform Part(PrimitiveType type, Transform parent, Vector3 position, Vector3 scale, Material material)
		{
			//IL_0000: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(type);
			obj.GetComponent<Collider>().enabled = false;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = position;
			obj.transform.localScale = scale;
			obj.GetComponent<Renderer>().sharedMaterial = material;
			return obj.transform;
		}

		private void LateUpdate()
		{
			//IL_005c: 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_0061: 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_00a7: 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_012b: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)drone))
			{
				return;
			}
			bool active = drone.Active;
			Color val = (Color)(drone.IsDisco ? Color.HSVToRGB(Mathf.Repeat(Time.time * 0.1f, 1f), 0.8f, 1f) : new Color(1f, 0.1f, 0.02f));
			glow.color = val;
			glow.intensity = ((!active) ? 0f : (drone.IsDisco ? 1.3f : 0.25f));
			accent.SetColor("_EmissionColor", val * (active ? 1.7f : 0.3f));
			if (!drone.IsDisco)
			{
				return;
			}
			unfold = Mathf.MoveTowards(unfold, (float)(active ? 1 : 0), Time.deltaTime / 0.65f);
			float num = Mathf.SmoothStep(0f, 1f, unfold);
			((Component)ornament).gameObject.SetActive(unfold > 0.001f);
			Vector3 lossyScale = housing.lossyScale;
			ornament.localScale = new Vector3(num / lossyScale.x, num / lossyScale.y, num / lossyScale.z);
			ornament.localPosition = centreLocal;
			if (active)
			{
				ornament.Rotate(Vector3.up, 70f * Time.deltaTime, (Space)1);
			}
			foreach (Panel panel in panels)
			{
				panel.Transform.localPosition = panel.Position + panel.Direction * (0.055f * num);
			}
			((Renderer)housingRenderer).enabled = unfold < 0.85f;
			music.volume = DronePlugin.MusicVolume.Value;
			if (active && !music.isPlaying)
			{
				music.Play();
			}
			if (!active && music.isPlaying)
			{
				music.Stop();
			}
		}

		private void OnDisable()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)music))
			{
				music.Stop();
			}
			if (Object.op_Implicit((Object)(object)glow))
			{
				glow.intensity = 0f;
			}
			unfold = 0f;
			if (!Object.op_Implicit((Object)(object)drone) || !drone.IsDisco)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)ornament))
			{
				ornament.localScale = Vector3.zero;
				((Component)ornament).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)housingRenderer))
			{
				((Renderer)housingRenderer).enabled = true;
			}
			foreach (Panel panel in panels)
			{
				if (Object.op_Implicit((Object)(object)panel.Transform))
				{
					panel.Transform.localPosition = panel.Position;
				}
			}
		}

		private void OnDestroy()
		{
			foreach (Material item in owned)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}

		internal static Texture2D Icon(bool disco)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				name = (disco ? "Disco glyph" : "Laser glyph"),
				filterMode = (FilterMode)0
			};
			Color[] array = (Color[])(object)new Color[1024];
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = (float)j - 15.5f;
					float num2 = (float)i - 15.5f;
					bool flag = (disco ? (num * num + num2 * num2 < 160f && j % 5 < 3 && i % 5 < 3) : (Math.Abs(num2) < 2f || (j < 11 && Math.Abs(num2) < 7f) || (j > 23 && Math.Abs(Math.Abs(num2) - (float)(j - 23)) < 1.8f)));
					array[i * 32 + j] = (flag ? Color.white : Color.clear);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static AudioClip BuildBeat()
		{
			float[] array = new float[176400];
			Random random = new Random(817);
			double[] array2 = new double[8] { 65.406, 65.406, 77.782, 87.307, 65.406, 98.0, 87.307, 77.782 };
			for (int i = 0; i < array.Length; i++)
			{
				double num = (double)i / 22050.0;
				double num2 = num % 0.5;
				double num3 = num % 0.25;
				double num4 = Math.Sin(Math.PI * 2.0 * (48.0 * num2 + 4.0 * (1.0 - Math.Exp((0.0 - num2) * 30.0)))) * Math.Exp((0.0 - num2) * 19.0);
				double num5 = (random.NextDouble() * 2.0 - 1.0) * Math.Exp((0.0 - num3) * 95.0) * 0.09;
				double num6 = (((int)(num / 0.5) % 2 == 1) ? ((random.NextDouble() * 2.0 - 1.0) * Math.Exp((0.0 - num2) * 25.0) * 0.18) : 0.0);
				double num7 = array2[(int)(num / 0.5) % array2.Length];
				double num8 = (Math.Sin(num * num7 * 2.0 * Math.PI) + 0.25 * Math.Sin(num * num7 * 4.0 * Math.PI)) * Math.Exp((0.0 - num2) * 7.0) * 0.18;
				double num9 = Math.Min(1.0, Math.Min(num * 100.0, (8.0 - num) * 100.0));
				array[i] = (float)((num4 * 0.35 + num5 + num6 + num8) * num9);
			}
			AudioClip obj = AudioClip.Create("More Drones original disco loop", array.Length, 1, 22050, false);
			obj.SetData(array, 0);
			return obj;
		}
	}
	[BepInPlugin("robin.moredrones", "More Drones", "0.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class DronePlugin : BaseUnityPlugin
	{
		public const string Id = "robin.moredrones";

		public const string Version = "0.2.1";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> MusicVolume;

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			MusicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "DiscoMusicVolume", 0.35f, new ConfigDescription("Local volume of the disco beat; 0 mutes music without disabling the drone.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			new Harmony("robin.moredrones").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"More Drones loaded; waiting for native item registration.");
		}
	}
	[HarmonyPatch(typeof(StatsManager), "RunStartStats")]
	internal static class RegisterDrones
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix()
		{
			DroneCatalog.Initialize();
		}
	}
	[HarmonyPatch(typeof(StatsManager), "Start")]
	internal static class RegisterDronesOnClient
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			DroneCatalog.Initialize();
		}
	}
	public static class DroneCatalog
	{
		internal static MuseumLaserLogic LevelLaser;

		private static GameObject vault;

		private static bool attempted;

		public static Item LaserItem { get; private set; }

		public static Item DiscoItem { get; private set; }

		public static bool Ready { get; private set; }

		public static void Initialize()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			if (attempted)
			{
				return;
			}
			attempted = true;
			try
			{
				GameObject obj = Resources.Load<GameObject>("Items/Item Drone Feather");
				GameObject val = Resources.Load<GameObject>("Level/Museum/Modules/Module - Museum - DE - 1 - Small Gallery");
				if (Object.op_Implicit((Object)(object)val))
				{
					LevelLaser = val.GetComponentInChildren<MuseumLaserLogic>(true);
				}
				if (!Object.op_Implicit((Object)(object)obj) || !Object.op_Implicit((Object)(object)LevelLaser) || !Object.op_Implicit((Object)(object)LevelLaser.beamMeshRenderer) || !Object.op_Implicit((Object)(object)LevelLaser.beamInnerMeshRenderer))
				{
					throw new InvalidOperationException("Native Feather Drone or Museum level laser assets were not found.");
				}
				vault = new GameObject("More Drones templates");
				vault.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)vault);
				LaserItem = Make(obj, disco: false);
				DiscoItem = Make(obj, disco: true);
				Ready = true;
				DronePlugin.Log.LogInfo((object)"Registered Laser Drone and Disco Drone as independent shop items.");
			}
			catch (Exception ex)
			{
				DronePlugin.Log.LogError((object)("Drone registration failed: " + ex));
			}
		}

		private static Item Make(GameObject source, bool disco)
		{
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(source, vault.transform);
			((Object)val).name = "Item More Drones " + (disco ? "Disco" : "Laser");
			Object.DestroyImmediate((Object)(object)val.GetComponent<ItemDroneFeather>());
			MonoBehaviour[] components = val.GetComponents<MonoBehaviour>();
			foreach (MonoBehaviour val2 in components)
			{
				if (val2 is ITargetingCondition)
				{
					Object.DestroyImmediate((Object)(object)val2);
				}
			}
			ItemAttributes component = val.GetComponent<ItemAttributes>();
			Item val3 = Object.Instantiate<Item>(component.item);
			((Object)val3).name = ((Object)val).name;
			val3.itemName = (disco ? "Disco Drone" : "Laser Drone");
			val3.itemNameLocalized = null;
			val3.description = (disco ? "Drop an active disco drone to distract nearby enemies. A laser drone turns it into a deadly light show." : "Emits a continuous forward laser while active. Aim the beam at a deployed Disco Drone to scatter it. Avoid the beam!");
			val3.disabled = false;
			val3.minPlayerCount = 1;
			val3.maxAmount = 3;
			val3.maxAmountInShop = 1;
			val3.maxPurchase = false;
			val3.value = Object.Instantiate<Value>(val3.value);
			val3.value.valueMin = (disco ? 6000 : 8000);
			val3.value.valueMax = (disco ? 9000 : 12000);
			val3.colorPreset = Object.Instantiate<ColorPresets>(val3.colorPreset);
			Color val4 = (disco ? new Color(0.85f, 0.12f, 1f) : new Color(1f, 0.15f, 0.06f));
			val3.colorPreset.colorMain = val4;
			val3.colorPreset.colorLight = Color.Lerp(val4, Color.white, 0.4f);
			val3.colorPreset.colorDark = val4 * 0.5f;
			component.item = val3;
			Texture2D val5 = DroneLooks.Icon(disco);
			component.icon = Sprite.Create(val5, new Rect(0f, 0f, (float)((Texture)val5).width, (float)((Texture)val5).height), new Vector2(0.5f, 0.5f), 32f);
			ItemDrone component2 = val.GetComponent<ItemDrone>();
			component2.droneIcon = (Texture)(object)val5;
			component2.targetPlayers = (component2.targetValuables = false);
			component2.targetEnemies = (component2.targetNonValuables = false);
			val.GetComponent<ItemBattery>().autoDrain = false;
			val.AddComponent<MoreDrone>().IsDisco = disco;
			val.AddComponent<DroneTargetFilter>();
			if (Items.RegisterItem(component) == null)
			{
				throw new InvalidOperationException("Cannot register " + ((Object)val).name);
			}
			val.SetActive(true);
			return val3;
		}
	}
	public sealed class DroneTargetFilter : MonoBehaviour, ITargetingCondition
	{
		public bool CustomTargetingCondition(GameObject target)
		{
			return false;
		}
	}
	public static class DroneRules
	{
		public const float DiscoRange = 8f;

		public const float LaserRange = 18f;

		public const float ReflectionRange = 12f;

		public const int SplitCount = 6;

		public const float DazeSeconds = 3.5f;

		public const float CalmSeconds = 1.5f;

		public const float RecoverySeconds = 5f;

		public const float ChargeMultiplier = 3f;

		public const float IdleDrain = 1f / 3f;

		public const float DiscoDrain = 5f / 6f;

		public const float LaserDrain = 1.1f;

		public const float ComboDrain = 1.6666666f;

		public static float Drain(bool disco, bool firing, bool combo)
		{
			if (!disco)
			{
				if (!combo)
				{
					if (!firing)
					{
						return 1f / 3f;
					}
					return 1.1f;
				}
				return 1.6666666f;
			}
			return 5f / 6f;
		}

		public static float BatteryAfter(float battery, float drain, float delta)
		{
			return Math.Max(0f, Math.Min(100f, battery - Math.Max(0f, drain) * Math.Max(0f, delta)));
		}
	}
	public sealed class DazeWindow
	{
		public float Until { get; private set; } = float.NegativeInfinity;

		public float CalmUntil { get; private set; } = float.NegativeInfinity;

		public float ReadyAt { get; private set; } = float.NegativeInfinity;

		public bool Active(float now)
		{
			return now < Until;
		}

		public bool Protected(float now)
		{
			return now < CalmUntil;
		}

		public bool TryBegin(float now)
		{
			if (now < ReadyAt)
			{
				return false;
			}
			Until = now + 3.5f;
			CalmUntil = Until + 1.5f;
			ReadyAt = CalmUntil + 5f;
			return true;
		}

		public void Stop(float now)
		{
			Until = Math.Min(Until, now);
			CalmUntil = Math.Min(CalmUntil, Until + 1.5f);
		}

		public void Reset()
		{
			float num = (ReadyAt = float.NegativeInfinity);
			float until = (CalmUntil = num);
			Until = until;
		}
	}
	public sealed class LevelLaserBeam : MonoBehaviour
	{
		private MeshRenderer outer;

		private MeshRenderer core;

		private Material outerMaterial;

		private Material coreMaterial;

		private Mesh mesh;

		private HurtCollider hurt;

		private Transform damage;

		private Light impact;

		private AudioSource hum;

		private AudioSource hitAudio;

		private Sound startSound = new Sound();

		private Sound endSound = new Sound();

		private float diameter;

		private float lastRefresh = -100f;

		private static readonly FieldRef<HurtCollider, PlayerAvatar> CausingHurt = AccessTools.FieldRefAccess<HurtCollider, PlayerAvatar>("playerCausingHurtOverride");

		public bool Visible
		{
			get
			{
				if (Object.op_Implicit((Object)(object)outer))
				{
					return ((Renderer)outer).enabled;
				}
				return false;
			}
		}

		public Vector3 From { get; private set; }

		public Vector3 To { get; private set; }

		public void Setup(MoreDrone owner, bool reflected)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00df: 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_019a: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			MuseumLaserLogic levelLaser = DroneCatalog.LevelLaser;
			diameter = (reflected ? 0.04f : 0.055f);
			mesh = ((Component)levelLaser.beamMeshRenderer).GetComponent<MeshFilter>().sharedMesh;
			outerMaterial = new Material(((Renderer)levelLaser.beamMeshRenderer).sharedMaterial);
			coreMaterial = new Material(((Renderer)levelLaser.beamInnerMeshRenderer).sharedMaterial);
			outer = MakeMesh("Museum laser outer", mesh, outerMaterial);
			core = MakeMesh("Museum laser core", ((Component)levelLaser.beamInnerMeshRenderer).GetComponent<MeshFilter>().sharedMesh, coreMaterial);
			GameObject val = new GameObject("Laser damage");
			val.SetActive(false);
			val.transform.SetParent(((Component)this).transform, false);
			damage = val.transform;
			BoxCollider obj = val.AddComponent<BoxCollider>();
			((Collider)obj).isTrigger = true;
			obj.size = Vector3.one;
			obj.center = Vector3.zero;
			hurt = val.AddComponent<HurtCollider>();
			hurt.playerKill = (hurt.enemyKill = (hurt.enemyStun = (hurt.physLogic = false)));
			hurt.playerLogic = (hurt.enemyLogic = true);
			hurt.playerDamage = (reflected ? 3 : 5);
			hurt.enemyDamage = (reflected ? 6 : 8);
			hurt.playerDamageCooldown = (hurt.enemyDamageCooldown = 0.4f);
			hurt.enemyImpact = (BreakImpact)0;
			hurt.enemyFreezeTime = 0f;
			hurt.playerRayCast = (hurt.enemyRayCast = true);
			hurt.ignoreObjects.Add(((Component)owner).GetComponent<PhysGrabObject>());
			hurt.onImpactAny = new UnityEvent();
			hurt.onImpactEnemy = new UnityEvent();
			hurt.onImpactPlayer = new UnityEvent();
			hurt.onImpactPhysObject = new UnityEvent();
			GameObject val2 = new GameObject("Laser contact glow");
			val2.transform.SetParent(((Component)this).transform, false);
			impact = val2.AddComponent<Light>();
			impact.type = (LightType)2;
			impact.range = 0.8f;
			impact.color = levelLaser.beamLight1.color;
			impact.intensity = (reflected ? 0.4f : 0.8f);
			impact.shadows = (LightShadows)0;
			hum = Audio("Museum laser hum", levelLaser.soundLoop, reflected ? 0.08f : 0.3f);
			hitAudio = Audio("Museum laser contact", levelLaser.soundHitLoop, reflected ? 0.04f : 0.15f);
			Sound.CopySound(levelLaser.soundPowerUp, startSound);
			startSound.Source = null;
			Sound.CopySound(levelLaser.soundShutdown, endSound);
			endSound.Source = null;
			Sound obj2 = startSound;
			obj2.Volume *= (reflected ? 0f : 0.15f);
			Sound obj3 = endSound;
			obj3.Volume *= (reflected ? 0f : 0.15f);
			StopBeam(sound: false);
		}

		private MeshRenderer MakeMesh(string label, Mesh geometry, Material material)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(label);
			val.transform.SetParent(((Component)this).transform, false);
			val.AddComponent<MeshFilter>().sharedMesh = geometry;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = material;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			return obj;
		}

		private AudioSource Audio(string label, Sound sound, float multiplier)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(label);
			val.transform.SetParent(((Component)this).transform, false);
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.playOnAwake = false;
			val2.loop = true;
			val2.spatialBlend = 1f;
			val2.dopplerLevel = 0f;
			val2.minDistance = 1f;
			val2.maxDistance = 15f;
			val2.rolloffMode = (AudioRolloffMode)1;
			val2.volume = sound.Volume * multiplier;
			val2.pitch = sound.Pitch;
			if (sound.Sounds != null && sound.Sounds.Length != 0)
			{
				val2.clip = sound.Sounds[0];
			}
			if (Object.op_Implicit((Object)(object)sound.Source))
			{
				val2.outputAudioMixerGroup = sound.Source.outputAudioMixerGroup;
			}
			return val2;
		}

		public void Present(Vector3 from, Vector3 to, bool isHit, PlayerAvatar owner)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: 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)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				StopBeam();
				return;
			}
			bool num = !Visible;
			From = from;
			To = to;
			lastRefresh = Time.time;
			((Component)this).transform.SetPositionAndRotation(from, Quaternion.LookRotation(val));
			float magnitude = ((Vector3)(ref val)).magnitude;
			float num2 = 1f + 0.08f * Mathf.Sin(Time.time * 45f);
			Shape(outer, mesh, magnitude, diameter * num2);
			Shape(core, ((Component)core).GetComponent<MeshFilter>().sharedMesh, magnitude, diameter * 0.22f);
			outerMaterial.SetTextureOffset("_MainTex", new Vector2(Time.time * 0.5f, Time.time * 5f));
			coreMaterial.SetTextureOffset("_MainTex", new Vector2(Time.time, Time.time * 10f));
			MeshRenderer obj = outer;
			bool enabled = (((Renderer)core).enabled = true);
			((Renderer)obj).enabled = enabled;
			damage.localPosition = new Vector3(0f, 0f, magnitude * 0.5f);
			damage.localRotation = Quaternion.identity;
			damage.localScale = new Vector3(diameter * 1.4f, diameter * 1.4f, magnitude);
			CausingHurt.Invoke(hurt) = owner;
			((Component)damage).gameObject.SetActive(true);
			((Component)impact).transform.position = to - ((Vector3)(ref val)).normalized * 0.04f;
			((Behaviour)impact).enabled = isHit;
			AudioListenerFollow instance = AudioListenerFollow.instance;
			float num3 = (Object.op_Implicit((Object)(object)instance) ? Mathf.Clamp01(Vector3.Dot(((Component)instance).transform.position - from, val) / ((Vector3)(ref val)).sqrMagnitude) : 0.5f);
			((Component)hum).transform.position = Vector3.Lerp(from, to, num3);
			((Component)hitAudio).transform.position = to;
			if (Object.op_Implicit((Object)(object)hum.clip) && !hum.isPlaying)
			{
				hum.Play();
			}
			if (isHit && Object.op_Implicit((Object)(object)hitAudio.clip) && !hitAudio.isPlaying)
			{
				hitAudio.Play();
			}
			if (!isHit && hitAudio.isPlaying)
			{
				hitAudio.Stop();
			}
			if (num && startSound.Volume > 0f)
			{
				AudioClip[] sounds = startSound.Sounds;
				if (sounds != null && sounds.Length != 0)
				{
					startSound.Play(from, 1f, 1f, 1f, 1f);
				}
			}
		}

		private static void Shape(MeshRenderer renderer, Mesh geometry, float length, float width)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0049: 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)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			Bounds bounds = geometry.bounds;
			Vector3 size = ((Bounds)(ref bounds)).size;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(width / size.x, length / size.y, width / size.z);
			Quaternion val2 = Quaternion.Euler(90f, 0f, 0f);
			((Component)renderer).transform.localScale = val;
			((Component)renderer).transform.localRotation = val2;
			Transform transform = ((Component)renderer).transform;
			Vector3 val3 = Vector3.forward * (length * 0.5f);
			bounds = geometry.bounds;
			transform.localPosition = val3 - val2 * Vector3.Scale(((Bounds)(ref bounds)).center, val);
		}

		public void StopBeam(bool sound = true)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)outer) && Visible && sound && endSound.Volume > 0f)
			{
				AudioClip[] sounds = endSound.Sounds;
				if (sounds != null && sounds.Length != 0 && Object.op_Implicit((Object)(object)AudioManager.instance))
				{
					endSound.Play(From, 1f, 1f, 1f, 1f);
				}
			}
			if (Object.op_Implicit((Object)(object)outer))
			{
				((Renderer)outer).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)core))
			{
				((Renderer)core).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)damage))
			{
				((Component)damage).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)impact))
			{
				((Behaviour)impact).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)hum))
			{
				hum.Stop();
			}
			if (Object.op_Implicit((Object)(object)hitAudio))
			{
				hitAudio.Stop();
			}
		}

		private void Update()
		{
			if (Visible && Time.time - lastRefresh > 0.3f)
			{
				StopBeam();
			}
		}

		private void OnDisable()
		{
			StopBeam(sound: false);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)outerMaterial))
			{
				Object.Destroy((Object)(object)outerMaterial);
			}
			if (Object.op_Implicit((Object)(object)coreMaterial))
			{
				Object.Destroy((Object)(object)coreMaterial);
			}
		}
	}
	public sealed class MoreDrone : MonoBehaviour
	{
		public bool IsDisco;

		public static readonly List<MoreDrone> Instances = new List<MoreDrone>();

		private static readonly FieldRef<ItemDrone, PlayerAvatar> NativeOwner = AccessTools.FieldRefAccess<ItemDrone, PlayerAvatar>("droneOwner");

		private static readonly FieldRef<ItemEquippable, bool> Equipped = AccessTools.FieldRefAccess<ItemEquippable, bool>("isEquipped");

		private static readonly FieldRef<EnemyParent, bool> Spawned = AccessTools.FieldRefAccess<EnemyParent, bool>("Spawned");

		private ItemDrone native;

		private ItemBattery battery;

		private ItemToggle toggle;

		private ItemEquippable equippable;

		private PhysGrabObject phys;

		private PhotonView view;

		private DroneLooks looks;

		private readonly List<LevelLaserBeam> beams = new List<LevelLaserBeam>();

		private Vector3[] starts = (Vector3[])(object)new Vector3[7];

		private Vector3[] ends = (Vector3[])(object)new Vector3[7];

		private bool[] hits = new bool[7];

		private float nextScan;

		private float nextNetwork;

		private float lastFrameAt = -10f;

		private bool initialized;

		private bool wasActive;

		public bool Active
		{
			get
			{
				if (initialized && toggle.toggleState && battery.batteryLife > 0f && !Equipped.Invoke(equippable))
				{
					return ((Component)this).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		public int BeamCount { get; private set; }

		public bool Combining { get; private set; }

		public Vector3 Origin
		{
			get
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)looks))
				{
					return ((Component)this).transform.position;
				}
				return looks.Center;
			}
		}

		public Vector3 BeamDirection => ((Component)this).transform.forward;

		public float MirrorRadius
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)looks))
				{
					return 0f;
				}
				return looks.MirrorRadius;
			}
		}

		private void OnEnable()
		{
			if (!Instances.Contains(this))
			{
				Instances.Add(this);
			}
		}

		private void OnDisable()
		{
			Instances.Remove(this);
			BeamCount = 0;
			Combining = false;
			foreach (LevelLaserBeam beam in beams)
			{
				if (Object.op_Implicit((Object)(object)beam))
				{
					((Component)beam).gameObject.SetActive(false);
				}
			}
			DiscoDaze.CancelSource(this);
		}

		private void Start()
		{
			//IL_008e: 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)
			native = ((Component)this).GetComponent<ItemDrone>();
			battery = ((Component)this).GetComponent<ItemBattery>();
			toggle = ((Component)this).GetComponent<ItemToggle>();
			equippable = ((Component)this).GetComponent<ItemEquippable>();
			phys = ((Component)this).GetComponent<PhysGrabObject>();
			view = ((Component)this).GetComponent<PhotonView>();
			battery.autoDrain = false;
			looks = ((Component)this).gameObject.AddComponent<DroneLooks>();
			looks.Setup(this);
			if (!IsDisco)
			{
				for (int i = 0; i <= 6; i++)
				{
					GameObject val = new GameObject("More Drones level beam " + i);
					val.transform.SetParent(((Component)this).transform, false);
					LevelLaserBeam levelLaserBeam = val.AddComponent<LevelLaserBeam>();
					levelLaserBeam.Setup(this, i != 0);
					beams.Add(levelLaserBeam);
				}
			}
			initialized = true;
		}

		private void FixedUpdate()
		{
			if (Active && SemiFunc.IsMasterClientOrSingleplayer())
			{
				phys.OverrideZeroGravity(0.1f);
				phys.OverrideDrag(2f, 0.1f);
				phys.OverrideAngularDrag(8f, 0.1f);
				battery.batteryLife = DroneRules.BatteryAfter(battery.batteryLife, DroneRules.Drain(IsDisco, BeamCount > 0, Combining), Time.fixedDeltaTime);
				if (battery.batteryLife <= 0f)
				{
					toggle.ToggleItem(false, -1);
					native.DeactivateDrone();
				}
			}
		}

		private void Update()
		{
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Invalid comparison between Unknown and I4
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Invalid comparison between Unknown and I4
			//IL_0148: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer() && toggle.toggleState && battery.batteryLife <= 0f)
			{
				toggle.ToggleItem(false, -1);
				native.DeactivateDrone();
			}
			bool active = Active;
			if (active && !wasActive)
			{
				foreach (LevelLaserBeam beam in beams)
				{
					if (Object.op_Implicit((Object)(object)beam))
					{
						((Component)beam).gameObject.SetActive(true);
					}
				}
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (active && IsDisco && Time.time >= nextScan)
				{
					nextScan = Time.time + 0.2f;
					Enemy[] array = Object.FindObjectsOfType<Enemy>();
					foreach (Enemy val in array)
					{
						EnemyParent componentInParent = ((Component)val).GetComponentInParent<EnemyParent>();
						if (Object.op_Implicit((Object)(object)componentInParent) && Spawned.Invoke(componentInParent) && componentInParent.EnableObject.activeInHierarchy && (int)val.CurrentState != 11 && (int)val.CurrentState != 1 && Object.op_Implicit((Object)(object)val.CenterTransform) && !(Vector3.Distance(Origin, val.CenterTransform.position) > 8f) && ClearLine(Origin, val.CenterTransform.position, this, ((Component)componentInParent).transform) && (((Component)val).GetComponent<DiscoDaze>() ?? ((Component)val).gameObject.AddComponent<DiscoDaze>()).Begin(this))
						{
							SendDaze(val, active: true);
						}
					}
				}
				if (active && !IsDisco)
				{
					AimLaser();
				}
				else
				{
					BeamCount = 0;
					Combining = false;
				}
				if ((active || wasActive) && !IsDisco && Time.time >= nextNetwork)
				{
					nextNetwork = Time.time + 0.1f;
					if (SemiFunc.IsMultiplayer())
					{
						view.RPC("MoreDronesBeamRPC", (RpcTarget)1, new object[4] { starts, ends, hits, BeamCount });
					}
				}
			}
			if (!active)
			{
				BeamCount = 0;
				Combining = false;
				if (wasActive)
				{
					DiscoDaze.CancelSource(this);
					foreach (LevelLaserBeam beam2 in beams)
					{
						((Component)beam2).gameObject.SetActive(false);
					}
				}
			}
			else if (!IsDisco)
			{
				if (!SemiFunc.IsMasterClientOrSingleplayer() && Time.time - lastFrameAt > 0.5f)
				{
					BeamCount = 0;
				}
				for (int j = 0; j < BeamCount; j++)
				{
					beams[j].Present(starts[j], ends[j], hits[j], NativeOwner.Invoke(native));
				}
				for (int k = BeamCount; k < beams.Count; k++)
				{
					beams[k].StopBeam();
				}
			}
			wasActive = active;
		}

		private void AimLaser()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: 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_0134: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			Vector3 beamDirection = BeamDirection;
			starts[0] = Origin;
			CastBeam(Origin, beamDirection, 18f, this, null, out ends[0], out hits[0]);
			BeamCount = 1;
			Combining = false;
			MoreDrone moreDrone = null;
			float num = Vector3.Distance(Origin, ends[0]);
			foreach (MoreDrone instance in Instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && instance.IsDisco && instance.Active && !(instance.MirrorRadius < 0.04f) && DroneGeometry.RaySphere(Origin, beamDirection, instance.Origin, instance.MirrorRadius, out var distance) && !(distance > num) && ClearLine(Origin, Origin + beamDirection * distance, this, ((Component)instance).transform))
				{
					moreDrone = instance;
					num = distance;
				}
			}
			if (Object.op_Implicit((Object)(object)moreDrone))
			{
				Combining = true;
				ends[0] = Origin + beamDirection * num;
				hits[0] = true;
				double time = (SemiFunc.IsMultiplayer() ? PhotonNetwork.Time : Time.timeAsDouble);
				for (int i = 0; i < 6; i++)
				{
					Vector3 val = DroneGeometry.ScatterDirection(time, i, ((Component)moreDrone).GetComponent<PhotonView>().ViewID);
					CastBeam(moreDrone.Origin, val, 12f, moreDrone, null, out ends[i + 1], out hits[i + 1]);
					float num2 = Mathf.Min(moreDrone.MirrorRadius, Vector3.Distance(moreDrone.Origin, ends[i + 1]));
					starts[i + 1] = moreDrone.Origin + val * num2;
				}
				BeamCount = starts.Length;
			}
		}

		public static void CastBeam(Vector3 origin, Vector3 direction, float range, MoreDrone source, MoreDrone? ignore, out Vector3 end, out bool hit)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			range = Mathf.Clamp(range, 0.02f, 18f);
			end = origin + direction * range;
			hit = false;
			float num = range;
			RaycastHit[] array = Physics.RaycastAll(origin, direction, range, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				MoreDrone componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<MoreDrone>();
				if (!((Object)(object)componentInParent == (Object)(object)source) && (!Object.op_Implicit((Object)(object)ignore) || !((Object)(object)componentInParent == (Object)(object)ignore)) && !(((RaycastHit)(ref val)).distance >= num))
				{
					num = ((RaycastHit)(ref val)).distance;
					end = ((RaycastHit)(ref val)).point;
					hit = true;
				}
			}
		}

		public static bool ClearLine(Vector3 origin, Vector3 destination, MoreDrone source, Transform target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			Vector3 val = destination - origin;
			RaycastHit[] array = Physics.RaycastAll(origin, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				if (!((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<MoreDrone>() == (Object)(object)source) && !((Object)(object)((RaycastHit)(ref val2)).transform == (Object)(object)target) && !((RaycastHit)(ref val2)).transform.IsChildOf(target))
				{
					return false;
				}
			}
			return true;
		}

		internal void SendDaze(Enemy enemy, bool active)
		{
			if (SemiFunc.IsMultiplayer() && ((MonoBehaviourPun)enemy).photonView.ViewID > 0)
			{
				view.RPC("MoreDronesDazeRPC", (RpcTarget)1, new object[2]
				{
					((MonoBehaviourPun)enemy).photonView.ViewID,
					active
				});
			}
		}

		[PunRPC]
		public void MoreDronesBeamRPC(Vector3[] from, Vector3[] to, bool[] hit, int count, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info) && !IsDisco && from != null && to != null && hit != null && count >= 0 && count <= 7 && from.Length == to.Length && to.Length == hit.Length && from.Length <= 7 && count <= from.Length)
			{
				starts = from;
				ends = to;
				hits = hit;
				BeamCount = count;
				Combining = count > 1;
				lastFrameAt = Time.time;
			}
		}

		[PunRPC]
		public void MoreDronesDazeRPC(int enemyId, bool active, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(info) || !IsDisco)
			{
				return;
			}
			PhotonView val = PhotonView.Find(enemyId);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Enemy component = ((Component)val).GetComponent<Enemy>();
			if (Object.op_Implicit((Object)(object)component))
			{
				DiscoDaze discoDaze = ((Component)component).GetComponent<DiscoDaze>() ?? ((Component)component).gameObject.AddComponent<DiscoDaze>();
				if (active)
				{
					discoDaze.Begin(this);
				}
				else
				{
					discoDaze.EndFrom(this);
				}
			}
		}
	}
	public sealed class DiscoDaze : MonoBehaviour
	{
		private static readonly List<DiscoDaze> All = new List<DiscoDaze>();

		public readonly DazeWindow Window = new DazeWindow();

		private Enemy enemy;

		private MoreDrone source;

		private EnemyVision vision;

		private EnemyNavMeshAgent nav;

		private EnemyParent parent;

		private bool ended = true;

		private static readonly FieldRef<Enemy, float> ChaseDisable = AccessTools.FieldRefAccess<Enemy, float>("DisableChaseTimer");

		private static readonly FieldRef<EnemyVision, float> VisionDisable = AccessTools.FieldRefAccess<EnemyVision, float>("DisableTimer");

		private static readonly FieldRef<EnemyNavMeshAgent, float> NavDisable = AccessTools.FieldRefAccess<EnemyNavMeshAgent, float>("DisableTimer");

		public bool UsesSoftPause { get; private set; }

		private bool Live
		{
			get
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Invalid comparison between Unknown and I4
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Invalid comparison between Unknown and I4
				if (((Behaviour)this).isActiveAndEnabled && Object.op_Implicit((Object)(object)enemy) && (int)enemy.CurrentState != 1 && (int)enemy.CurrentState != 11 && Object.op_Implicit((Object)(object)parent))
				{
					return parent.EnableObject.activeInHierarchy;
				}
				return false;
			}
		}

		public bool Dancing
		{
			get
			{
				if (Live && !ended && Window.Active(Time.time) && Object.op_Implicit((Object)(object)source))
				{
					return source.Active;
				}
				return false;
			}
		}

		public bool BlocksAttacks
		{
			get
			{
				if (Live)
				{
					return Window.Protected(Time.time);
				}
				return false;
			}
		}

		public bool SuppliesStun
		{
			get
			{
				if (!UsesSoftPause)
				{
					return BlocksAttacks;
				}
				return false;
			}
		}

		private void Awake()
		{
			enemy = ((Component)this).GetComponent<Enemy>();
			vision = ((Component)this).GetComponent<EnemyVision>();
			nav = ((Component)this).GetComponent<EnemyNavMeshAgent>();
			parent = ((Component)this).GetComponentInParent<EnemyParent>();
			UsesSoftPause = DiscoEnemySafety.NeedsSoftPause(((Component)this).gameObject);
			All.Add(this);
		}

		private void OnDisable()
		{
			ended = true;
			Window.Reset();
		}

		private void OnDestroy()
		{
			All.Remove(this);
		}

		public bool Begin(MoreDrone drone)
		{
			if (!Live || !Object.op_Implicit((Object)(object)drone) || !drone.Active || !Window.TryBegin(Time.time))
			{
				return false;
			}
			source = drone;
			ended = false;
			Hold();
			return true;
		}

		public void End()
		{
			if (!ended)
			{
				ended = true;
				Window.Stop(Time.time);
				if (Object.op_Implicit((Object)(object)source) && Object.op_Implicit((Object)(object)GameManager.instance) && SemiFunc.IsMasterClientOrSingleplayer())
				{
					source.SendDaze(enemy, active: false);
				}
			}
		}

		public void EndFrom(MoreDrone drone)
		{
			if ((Object)(object)source == (Object)(object)drone)
			{
				End();
			}
		}

		public static void CancelSource(MoreDrone drone)
		{
			foreach (DiscoDaze item in All)
			{
				if (Object.op_Implicit((Object)(object)item) && (Object)(object)item.source == (Object)(object)drone)
				{
					item.End();
				}
			}
		}

		private void Update()
		{
			//IL_0037: 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_005e: 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)
			if (!Live)
			{
				End();
				Window.Reset();
				return;
			}
			if (!ended && (!Dancing || (SemiFunc.IsMasterClientOrSingleplayer() && (Vector3.Distance(source.Origin, enemy.CenterTransform.position) > 8f || !MoreDrone.ClearLine(source.Origin, enemy.CenterTransform.position, source, ((Component)parent).transform)))))
			{
				End();
			}
			if (BlocksAttacks)
			{
				Hold();
			}
		}

		private void Hold()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				ChaseDisable.Invoke(enemy) = Mathf.Max(ChaseDisable.Invoke(enemy), 0.2f);
				if (Object.op_Implicit((Object)(object)vision))
				{
					VisionDisable.Invoke(vision) = Mathf.Max(VisionDisable.Invoke(vision), 0.2f);
				}
				if (Object.op_Implicit((Object)(object)nav))
				{
					nav.Disable(Mathf.Max(NavDisable.Invoke(nav), 0.15f));
				}
				enemy.FreezeTimer = Mathf.Max(enemy.FreezeTimer, 0.15f);
			}
		}
	}
	[HarmonyPatch(typeof(Enemy), "IsStunned")]
	internal static class DiscoPacify
	{
		[HarmonyPostfix]
		private static void Postfix(Enemy __instance, ref bool __result)
		{
			DiscoDaze discoDaze = default(DiscoDaze);
			if (!__result && ((Component)__instance).TryGetComponent<DiscoDaze>(ref discoDaze) && discoDaze.SuppliesStun)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(HurtCollider), "CanHit")]
	internal static class DiscoCancelContactAttack
	{
		[HarmonyPrefix]
		private static bool Prefix(HurtCollider __instance, ref bool __result)
		{
			Enemy val = __instance.enemyHost;
			if (!Object.op_Implicit((Object)(object)val))
			{
				EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>();
				val = ((componentInParent != null) ? ((Component)componentInParent).GetComponentInChildren<Enemy>() : null);
			}
			DiscoDaze discoDaze = default(DiscoDaze);
			if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<DiscoDaze>(ref discoDaze) && discoDaze.BlocksAttacks)
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
}