Decompiled source of AllyMonsterMod v0.1.0

AllyMonsterMod.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[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("TheLux")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AllyMonsterMod")]
[assembly: AssemblyTitle("AllyMonsterMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 AllyMonsterMod
{
	public sealed class AllyBeamerMarker : MonoBehaviour
	{
		private float searchTimer;

		private float attackCooldown;

		private float damageTimer;

		private bool wasAttacking;

		private const float SearchInterval = 1f;

		private const float SearchRadius = 30f;

		private const float AttackRange = 9f;

		private const float DamageInterval = 0.35f;

		private const float AttackCooldown = 3f;

		private const int LaserDamage = 8;

		private static readonly MethodInfo? UpdateStateMethod = AccessTools.Method(typeof(EnemyBeamer), "UpdateState", new Type[1] { typeof(State) }, (Type[])null);

		internal Enemy? OwnEnemy { get; private set; }

		internal EnemyBeamer? Beamer { get; private set; }

		internal Enemy? TargetEnemy { get; private set; }

		private void Awake()
		{
			OwnEnemy = ((Component)this).GetComponent<Enemy>();
			Beamer = ((Component)this).GetComponent<EnemyBeamer>();
		}

		private void Update()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)OwnEnemy == (Object)null) && !((Object)(object)Beamer == (Object)null))
			{
				searchTimer -= Time.deltaTime;
				attackCooldown -= Time.deltaTime;
				damageTimer -= Time.deltaTime;
				if (searchTimer <= 0f)
				{
					searchTimer = 1f;
					UpdateTarget();
				}
				bool flag = IsAttackSequence();
				if (wasAttacking && !flag)
				{
					attackCooldown = 3f;
				}
				wasAttacking = flag;
			}
		}

		private void LateUpdate()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Invalid comparison between Unknown and I4
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)OwnEnemy == (Object)null || (Object)(object)Beamer == (Object)null || (Object)(object)TargetEnemy == (Object)null)
			{
				return;
			}
			if ((Object)(object)TargetEnemy.Health == (Object)null || TargetEnemy.Health.dead)
			{
				TargetEnemy = null;
				RequestState((State)1);
				return;
			}
			Vector3 targetPosition = GetTargetPosition(TargetEnemy);
			float num = Vector3.Distance(((Component)this).transform.position, targetPosition);
			if (IsAttackSequence())
			{
				OwnEnemy.NavMeshAgent.ResetPath();
				if ((int)Beamer.currentState == 5)
				{
					ApplyLaserDamage(targetPosition);
				}
			}
			else if (num > 9f)
			{
				OwnEnemy.NavMeshAgent.SetDestination(targetPosition);
			}
			else
			{
				OwnEnemy.NavMeshAgent.ResetPath();
				if (attackCooldown <= 0f)
				{
					RequestState((State)4);
				}
			}
		}

		internal Vector3 GetCurrentTargetPosition()
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			if ((Object)(object)TargetEnemy == (Object)null)
			{
				return ((Component)this).transform.position;
			}
			return GetTargetPosition(TargetEnemy);
		}

		private bool IsAttackSequence()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			if ((Object)(object)Beamer == (Object)null)
			{
				return false;
			}
			return (int)Beamer.currentState == 4 || (int)Beamer.currentState == 5 || (int)Beamer.currentState == 6;
		}

		private void RequestState(State state)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Beamer == (Object)null))
			{
				UpdateStateMethod?.Invoke(Beamer, new object[1] { state });
			}
		}

		private void ApplyLaserDamage(Vector3 targetPosition)
		{
			//IL_0044: 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_004a: 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_004c: 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_0076: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Beamer == (Object)null || (Object)(object)TargetEnemy == (Object)null || damageTimer > 0f)
			{
				return;
			}
			Vector3 position = Beamer.laserStartTransform.position;
			Vector3 val = targetPosition - position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 0.01f || magnitude > 9f)
			{
				return;
			}
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(position, ((Vector3)(ref val)).normalized, ref val2, magnitude, LayerMask.GetMask(new string[1] { "Default" })))
			{
				Enemy componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Enemy>();
				if ((Object)(object)componentInParent != (Object)(object)TargetEnemy)
				{
					return;
				}
			}
			TargetEnemy.Health.Hurt(8, ((Vector3)(ref val)).normalized);
			damageTimer = 0.35f;
		}

		private void UpdateTarget()
		{
			Enemy val = FindNearestEnemy();
			if (!((Object)(object)val == (Object)(object)TargetEnemy))
			{
				TargetEnemy = val;
				if ((Object)(object)TargetEnemy != (Object)null)
				{
					AllyMonsterMod.Logger.LogInfo((object)("Clown aliado eligió objetivo: " + ((Object)((Component)TargetEnemy).gameObject).name));
				}
			}
		}

		private Enemy? FindNearestEnemy()
		{
			//IL_0087: 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)
			Enemy[] array = Object.FindObjectsOfType<Enemy>();
			Enemy result = null;
			float num = 30f;
			Enemy[] array2 = array;
			foreach (Enemy val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)OwnEnemy) && !((Object)(object)((Component)val).GetComponent<AllyBeamerMarker>() != (Object)null) && !((Object)(object)val.Health == (Object)null) && !val.Health.dead)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private Vector3 GetTargetPosition(Enemy enemy)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			if ((Object)(object)enemy.CenterTransform != (Object)null)
			{
				return enemy.CenterTransform.position;
			}
			return ((Component)enemy).transform.position;
		}
	}
	public sealed class AllyBeamerSpawnerController : MonoBehaviour
	{
		private ItemToggle? itemToggle;

		private bool previousToggleState;

		private bool consumed;

		private void Awake()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			if ((Object)(object)itemToggle == (Object)null)
			{
				AllyMonsterMod.Logger.LogError((object)"AllyBeamerSpawner no tiene ItemToggle.");
			}
		}

		private void Update()
		{
			if (!consumed && !((Object)(object)itemToggle == (Object)null))
			{
				bool toggleState = itemToggle.toggleState;
				if (toggleState && !previousToggleState)
				{
					TryActivate();
				}
				previousToggleState = toggleState;
			}
		}

		private void TryActivate()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				AllyMonsterMod.Logger.LogWarning((object)"Solo el host puede activar el invocador por ahora.");
				return;
			}
			EnemySetup val = FindBeamerSetup();
			if ((Object)(object)val == (Object)null)
			{
				AllyMonsterMod.Logger.LogError((object)"No se encontró el EnemySetup del Clown/Beamer.");
				return;
			}
			consumed = true;
			((MonoBehaviour)this).StartCoroutine(SpawnAlliedBeamer(val));
		}

		private EnemySetup? FindBeamerSetup()
		{
			EnemySetup[] array = Resources.FindObjectsOfTypeAll<EnemySetup>();
			EnemySetup[] array2 = array;
			foreach (EnemySetup val in array2)
			{
				if ((Object)(object)val == (Object)null || val.spawnObjects == null)
				{
					continue;
				}
				foreach (PrefabRef spawnObject in val.spawnObjects)
				{
					if (spawnObject == null)
					{
						continue;
					}
					GameObject prefab = ((PrefabRef<GameObject>)(object)spawnObject).Prefab;
					if (!((Object)(object)prefab == (Object)null))
					{
						EnemyBeamer componentInChildren = prefab.GetComponentInChildren<EnemyBeamer>(true);
						if ((Object)(object)componentInChildren != (Object)null)
						{
							AllyMonsterMod.Logger.LogInfo((object)("EnemySetup del Clown encontrado: " + ((Object)val).name));
							return val;
						}
					}
				}
			}
			return null;
		}

		private IEnumerator SpawnAlliedBeamer(EnemySetup beamerSetup)
		{
			HashSet<int> existingBeamers = new HashSet<int>();
			EnemyBeamer[] array = Object.FindObjectsOfType<EnemyBeamer>();
			foreach (EnemyBeamer existing in array)
			{
				existingBeamers.Add(((Object)existing).GetInstanceID());
			}
			Vector3 spawnPosition = ((Component)this).transform.position + ((Component)this).transform.forward * 1.5f + Vector3.up * 0.2f;
			AllyMonsterMod.Logger.LogInfo((object)$"Invocando Clown aliado en {spawnPosition}.");
			Enemies.SpawnEnemy(beamerSetup, spawnPosition, Quaternion.identity, false);
			float timeout = 5f;
			while (timeout > 0f)
			{
				yield return null;
				timeout -= Time.deltaTime;
				EnemyBeamer spawnedBeamer = FindNewBeamer(existingBeamers, spawnPosition);
				if ((Object)(object)spawnedBeamer == (Object)null)
				{
					continue;
				}
				if ((Object)(object)((Component)spawnedBeamer).GetComponent<AllyBeamerMarker>() == (Object)null)
				{
					((Component)spawnedBeamer).gameObject.AddComponent<AllyBeamerMarker>();
				}
				AllyMonsterMod.Logger.LogInfo((object)"Clown invocado y marcado como aliado.");
				ConsumeOrb();
				yield break;
			}
			consumed = false;
			AllyMonsterMod.Logger.LogError((object)"El Clown fue solicitado, pero no se encontró su instancia.");
		}

		private EnemyBeamer? FindNewBeamer(HashSet<int> existingBeamers, Vector3 spawnPosition)
		{
			//IL_0044: 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)
			EnemyBeamer result = null;
			float num = 8f;
			EnemyBeamer[] array = Object.FindObjectsOfType<EnemyBeamer>();
			foreach (EnemyBeamer val in array)
			{
				if (!((Object)(object)val == (Object)null) && !existingBeamers.Contains(((Object)val).GetInstanceID()))
				{
					float num2 = Vector3.Distance(((Component)val).transform.position, spawnPosition);
					if (num2 < num)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private void ConsumeOrb()
		{
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			if (GameManager.Multiplayer() && (Object)(object)component != (Object)null && PhotonNetwork.IsMasterClient)
			{
				PhotonNetwork.Destroy(((Component)component).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	[BepInPlugin("TheLux.AllyMonsterMod", "AllyMonsterMod", "1.0")]
	public class AllyMonsterMod : BaseUnityPlugin
	{
		internal static AllyMonsterMod Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

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

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)"AllyMonsterMod has Bien cargado ctm!");
		}

		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()
		{
		}
	}
	[HarmonyPatch]
	internal static class BeamerAllyAttackPatches
	{
		private static readonly FieldInfo StateImpulseField = AccessTools.Field(typeof(EnemyBeamer), "stateImpulse");

		private static readonly FieldInfo SeekDestinationField = AccessTools.Field(typeof(EnemyBeamer), "seekDestination");

		private static readonly FieldInfo AimHorizontalTargetField = AccessTools.Field(typeof(EnemyBeamer), "aimHorizontalTarget");

		private static readonly FieldInfo AimHorizontalLerpField = AccessTools.Field(typeof(EnemyBeamer), "aimHorizontalLerp");

		private static readonly FieldInfo AimHorizontalResultField = AccessTools.Field(typeof(EnemyBeamer), "aimHorizontalResult");

		private static readonly FieldInfo AimVerticalTargetField = AccessTools.Field(typeof(EnemyBeamer), "aimVerticalTarget");

		private static readonly MethodInfo UpdateStateMethod = AccessTools.Method(typeof(EnemyBeamer), "UpdateState", new Type[1] { typeof(State) }, (Type[])null);

		[HarmonyPatch(typeof(EnemyBeamer), "StateAttackStart")]
		[HarmonyPrefix]
		private static bool StateAttackStartPrefix(EnemyBeamer __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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_01a2: 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)
			AllyBeamerMarker component = ((Component)__instance).GetComponent<AllyBeamerMarker>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.TargetEnemy == (Object)null)
			{
				return true;
			}
			Vector3 currentTargetPosition = component.GetCurrentTargetPosition();
			if ((bool)StateImpulseField.GetValue(__instance))
			{
				AimHorizontalResultField.SetValue(__instance, 0f);
				StateImpulseField.SetValue(__instance, false);
				__instance.stateTimer = 1.5f;
				__instance.enemy.NavMeshAgent.Warp(((Component)__instance.enemy.Rigidbody).transform.position, false);
				__instance.enemy.NavMeshAgent.ResetPath();
				SeekDestinationField.SetValue(__instance, currentTargetPosition);
				AimHorizontalLerpField.SetValue(__instance, 0f);
			}
			float num = (float)AimHorizontalLerpField.GetValue(__instance);
			float num2 = Mathf.Lerp(0f, 0f - __instance.aimHorizontalSpread, __instance.aimHorizontalCurve.Evaluate(num));
			AimHorizontalResultField.SetValue(__instance, num2);
			AimHorizontalLerpField.SetValue(__instance, num + 1.5f * Time.deltaTime);
			Vector3 val = currentTargetPosition - ((Component)__instance.enemy.Rigidbody).transform.position;
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				Quaternion val2 = Quaternion.LookRotation(val);
				val2 = Quaternion.Euler(0f, ((Quaternion)(ref val2)).eulerAngles.y, 0f);
				AimHorizontalTargetField.SetValue(__instance, val2);
			}
			__instance.stateTimer -= Time.deltaTime;
			if (__instance.stateTimer <= 0f)
			{
				UpdateStateMethod.Invoke(__instance, new object[1] { (object)(State)5 });
			}
			return false;
		}

		[HarmonyPatch(typeof(EnemyBeamer), "VerticalAimLogic")]
		[HarmonyPrefix]
		private static bool VerticalAimLogicPrefix(EnemyBeamer __instance)
		{
			//IL_0037: 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)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_0073: 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_007a: 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)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			AllyBeamerMarker component = ((Component)__instance).GetComponent<AllyBeamerMarker>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.TargetEnemy == (Object)null)
			{
				return true;
			}
			Quaternion val = (Quaternion)AimVerticalTargetField.GetValue(__instance);
			if ((int)__instance.currentState != 4 && (int)__instance.currentState != 5 && (int)__instance.currentState != 6)
			{
				val = Quaternion.identity;
			}
			else
			{
				Vector3 currentTargetPosition = component.GetCurrentTargetPosition();
				Vector3 val2 = currentTargetPosition - __instance.laserRayTransform.position;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
				{
					Quaternion val3 = Quaternion.LookRotation(val2);
					val = ((!(val == Quaternion.identity)) ? Quaternion.Lerp(val, val3, 2f * Time.deltaTime) : val3);
				}
				Quaternion rotation = __instance.laserRayTransform.rotation;
				__instance.laserRayTransform.rotation = val;
				val = __instance.laserRayTransform.localRotation;
				val = Quaternion.Euler(__instance.laserRayTransform.eulerAngles.x, 0f, 0f);
				__instance.laserRayTransform.rotation = rotation;
			}
			AimVerticalTargetField.SetValue(__instance, val);
			__instance.aimVerticalTransform.localRotation = Quaternion.Lerp(__instance.aimVerticalTransform.localRotation, val, 20f * Time.deltaTime);
			__instance.laserRayTransform.localRotation = val;
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyBeamer), "Awake")]
	internal static class BeamerSpawnPatch
	{
		private static void Postfix(EnemyBeamer __instance)
		{
			AllyMonsterMod.Logger.LogInfo((object)("Clown normal detectado: " + ((Object)((Component)__instance).gameObject).name));
		}
	}
	[HarmonyPatch(typeof(EnemyBeamer), "OnVision")]
	internal static class BeamerVisionPatch
	{
		private static bool Prefix(EnemyBeamer __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<AllyBeamerMarker>() != (Object)null)
			{
				return false;
			}
			return true;
		}
	}
}