Decompiled source of Echohold v1.0.0

EchoholdAPI.dll

Decompiled 2 months 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 UnityEngine;
using UnityEngine.Events;

[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("Rosay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EchoholdAPI")]
[assembly: AssemblyTitle("EchoholdAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[DisallowMultipleComponent]
public class AirVentTrap : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <AutoOffCountdown>d__12 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public AirVentTrap <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(<>4__this.autoOffSeconds);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()) && <>4__this.isEnabledNow)
				{
					<>4__this.BroadcastSetActive(enable: false);
				}
				<>4__this.autoOffRoutine = null;
				return false;
			}
		}

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

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

	[Header("Assign the empty that holds your effects")]
	[SerializeField]
	private GameObject effectsRoot;

	[Header("Start state / timing")]
	[SerializeField]
	private bool startsEnabled = false;

	[SerializeField]
	private float autoOffSeconds = 5f;

	[Header("Networking")]
	[SerializeField]
	private bool allowClientRequestToMaster = true;

	private bool isEnabledNow;

	private PhotonView pv;

	private Coroutine autoOffRoutine;

	private void Awake()
	{
		pv = ((Component)this).GetComponent<PhotonView>();
		if ((Object)(object)pv == (Object)null)
		{
			pv = ((Component)this).GetComponentInParent<PhotonView>();
		}
		Apply(startsEnabled);
	}

	private void OnDisable()
	{
		StopAutoOff();
	}

	private void Apply(bool enable)
	{
		isEnabledNow = enable;
		if ((Object)(object)effectsRoot != (Object)null)
		{
			effectsRoot.SetActive(enable);
		}
		if (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient())
		{
			if (enable)
			{
				RestartAutoOff();
			}
			else
			{
				StopAutoOff();
			}
		}
	}

	private void RestartAutoOff()
	{
		StopAutoOff();
		if (autoOffSeconds > 0f)
		{
			autoOffRoutine = ((MonoBehaviour)this).StartCoroutine(AutoOffCountdown());
		}
	}

	private void StopAutoOff()
	{
		if (autoOffRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(autoOffRoutine);
			autoOffRoutine = null;
		}
	}

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

	public void ToggleOnGrab()
	{
		bool flag = !isEnabledNow;
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClient())
			{
				BroadcastSetActive(flag);
			}
			else if (allowClientRequestToMaster && (Object)(object)pv != (Object)null)
			{
				pv.RPC("RequestToggleRPC", (RpcTarget)2, Array.Empty<object>());
			}
		}
		else
		{
			SetActiveRPC(flag);
		}
	}

	[PunRPC]
	private void RequestToggleRPC()
	{
		if (SemiFunc.IsMasterClient())
		{
			BroadcastSetActive(!isEnabledNow);
		}
	}

	private void BroadcastSetActive(bool enable)
	{
		if ((Object)(object)pv != (Object)null && SemiFunc.IsMultiplayer())
		{
			pv.RPC("SetActiveRPC", (RpcTarget)0, new object[1] { enable });
		}
		else
		{
			SetActiveRPC(enable);
		}
	}

	[PunRPC]
	public void SetActiveRPC(bool enable)
	{
		Apply(enable);
	}

	public void EnableTrap()
	{
		ToggleTo(state: true);
	}

	public void DisableTrap()
	{
		ToggleTo(state: false);
	}

	private void ToggleTo(bool state)
	{
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClient())
			{
				BroadcastSetActive(state);
			}
			else if (allowClientRequestToMaster && (Object)(object)pv != (Object)null)
			{
				pv.RPC("RequestToggleRPC", (RpcTarget)2, Array.Empty<object>());
			}
		}
		else
		{
			SetActiveRPC(state);
		}
	}
}
public class ButtonSlideDoor : MonoBehaviourPun
{
	[CompilerGenerated]
	private sealed class <SlideDoorCoroutine>d__29 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 targetPosition;

		public ButtonSlideDoor <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.moving = true;
				if ((Object)(object)<>4__this.doorAudioSource != (Object)null && (Object)(object)<>4__this.doorMoveClip != (Object)null)
				{
					<>4__this.doorAudioSource.PlayOneShot(<>4__this.doorMoveClip);
				}
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (Vector3.Distance(<>4__this.door.position, targetPosition) > 0.01f)
			{
				<>4__this.door.position = Vector3.MoveTowards(<>4__this.door.position, targetPosition, <>4__this.moveSpeed * Time.deltaTime);
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<>4__this.door.position = targetPosition;
			<>4__this.moving = false;
			return false;
		}

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

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

	[Header("Door Settings")]
	public Transform door;

	public float moveDistance = 3f;

	public float moveSpeed = 2f;

	[Header("Audio Settings")]
	public AudioSource buttonAudioSource;

	public AudioClip buttonPressClip;

	public AudioSource doorAudioSource;

	public AudioClip doorMoveClip;

	[Header("Enemy Trigger Settings")]
	public bool useEnemyTrigger = false;

	public Collider triggerZone;

	private int enemiesInZone = 0;

	private Vector3 originalDoorPosition;

	private Vector3 openDoorPosition;

	private bool moving = false;

	private PhotonView photonView;

	private void Start()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0041: 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)
		photonView = ((Component)this).GetComponentInParent<PhotonView>();
		if ((Object)(object)door != (Object)null)
		{
			originalDoorPosition = door.position;
			openDoorPosition = originalDoorPosition + Vector3.up * moveDistance;
		}
	}

	public void SlideDoorToggle()
	{
		if (moving || (Object)(object)door == (Object)null)
		{
			return;
		}
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("RPC_PlayButtonSound", (RpcTarget)0, Array.Empty<object>());
		}
		else
		{
			PlayButtonSound();
		}
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				photonView.RPC("RPC_ToggleDoor", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				photonView.RPC("RPC_RequestToggleDoor", (RpcTarget)2, Array.Empty<object>());
			}
		}
		else
		{
			ToggleDoor();
		}
	}

	[PunRPC]
	private void RPC_PlayButtonSound()
	{
		PlayButtonSound();
	}

	private void PlayButtonSound()
	{
		if ((Object)(object)buttonAudioSource != (Object)null && (Object)(object)buttonPressClip != (Object)null)
		{
			buttonAudioSource.PlayOneShot(buttonPressClip);
		}
	}

	[PunRPC]
	private void RPC_ToggleDoor()
	{
		ToggleDoor();
	}

	[PunRPC]
	private void RPC_RequestToggleDoor()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			photonView.RPC("RPC_ToggleDoor", (RpcTarget)0, Array.Empty<object>());
		}
	}

	private void ToggleDoor()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		if (!moving && !((Object)(object)door == (Object)null))
		{
			if (Vector3.Distance(door.position, openDoorPosition) < 0.01f)
			{
				((MonoBehaviour)this).StartCoroutine(SlideDoorCoroutine(originalDoorPosition));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(SlideDoorCoroutine(openDoorPosition));
			}
		}
	}

	public void OnTriggerEnter(Collider other)
	{
		if (!useEnemyTrigger || (Object)(object)triggerZone == (Object)null || (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClientOrSingleplayer()) || (Object)(object)other == (Object)(object)triggerZone)
		{
			return;
		}
		EnemyRigidbody componentInParent = ((Component)other).GetComponentInParent<EnemyRigidbody>();
		Debug.Log((object)$"[DoorTrigger] OnTriggerEnter: '{((Object)((Component)other).gameObject).name}' - EnemyRigidbody found: {(Object)(object)componentInParent != (Object)null}");
		if ((Object)(object)componentInParent != (Object)null)
		{
			enemiesInZone++;
			Debug.Log((object)$"[DoorTrigger] Enemy entered. enemiesInZone now: {enemiesInZone}");
			if (enemiesInZone == 1)
			{
				Debug.Log((object)"[DoorTrigger] First enemy in zone, opening door.");
				OpenDoorFromTrigger();
			}
		}
	}

	public void OnTriggerExit(Collider other)
	{
		if (!useEnemyTrigger || (Object)(object)triggerZone == (Object)null || (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClientOrSingleplayer()) || (Object)(object)other == (Object)(object)triggerZone)
		{
			return;
		}
		EnemyRigidbody componentInParent = ((Component)other).GetComponentInParent<EnemyRigidbody>();
		Debug.Log((object)$"[DoorTrigger] OnTriggerExit: '{((Object)((Component)other).gameObject).name}' - EnemyRigidbody found: {(Object)(object)componentInParent != (Object)null}");
		if ((Object)(object)componentInParent != (Object)null)
		{
			enemiesInZone = Mathf.Max(0, enemiesInZone - 1);
			Debug.Log((object)$"[DoorTrigger] Enemy left. enemiesInZone now: {enemiesInZone}");
			if (enemiesInZone == 0)
			{
				Debug.Log((object)"[DoorTrigger] Last enemy left zone, closing door.");
				CloseDoorFromTrigger();
			}
		}
	}

	public void OpenDoorFromTrigger()
	{
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("RPC_ForceOpenDoor", (RpcTarget)0, Array.Empty<object>());
		}
		else
		{
			ForceOpenDoor();
		}
	}

	public void CloseDoorFromTrigger()
	{
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("RPC_ForceCloseDoor", (RpcTarget)0, Array.Empty<object>());
		}
		else
		{
			ForceCloseDoor();
		}
	}

	[PunRPC]
	private void RPC_ForceOpenDoor()
	{
		ForceOpenDoor();
	}

	[PunRPC]
	private void RPC_ForceCloseDoor()
	{
		ForceCloseDoor();
	}

	public void ForceOpenDoor()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		if (!moving && !((Object)(object)door == (Object)null) && !(Vector3.Distance(door.position, openDoorPosition) < 0.01f))
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)this).StartCoroutine(SlideDoorCoroutine(openDoorPosition));
		}
	}

	public void ForceCloseDoor()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		if (!moving && !((Object)(object)door == (Object)null) && !(Vector3.Distance(door.position, originalDoorPosition) < 0.01f))
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)this).StartCoroutine(SlideDoorCoroutine(originalDoorPosition));
		}
	}

	[IteratorStateMachine(typeof(<SlideDoorCoroutine>d__29))]
	private IEnumerator SlideDoorCoroutine(Vector3 targetPosition)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SlideDoorCoroutine>d__29(0)
		{
			<>4__this = this,
			targetPosition = targetPosition
		};
	}
}
[DisallowMultipleComponent]
[RequireComponent(typeof(PhotonView))]
public class ChanceManager : MonoBehaviourPun
{
	[Range(0f, 1f)]
	[SerializeField]
	private float chanceToAppear = 0.5f;

	[SerializeField]
	private GameObject nonChanceObject;

	[SerializeField]
	private GameObject ChanceObject;

	private void OnEnable()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			bool flag = Random.value < chanceToAppear;
			if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("RPC_SetChanceState", (RpcTarget)3, new object[1] { flag });
			}
			else
			{
				SetChanceState(flag);
			}
		}
	}

	[PunRPC]
	private void RPC_SetChanceState(bool isChance)
	{
		SetChanceState(isChance);
	}

	private void SetChanceState(bool isChance)
	{
		if (Object.op_Implicit((Object)(object)ChanceObject))
		{
			ChanceObject.SetActive(isChance);
		}
		if (Object.op_Implicit((Object)(object)nonChanceObject))
		{
			nonChanceObject.SetActive(!isChance);
		}
	}
}
public class EnemyTriggerRelay : MonoBehaviour
{
	public ButtonSlideDoor linkedDoor;

	private void OnTriggerEnter(Collider other)
	{
		linkedDoor?.OnTriggerEnter(other);
	}

	private void OnTriggerExit(Collider other)
	{
		linkedDoor?.OnTriggerExit(other);
	}
}
public class ProjectileAutoDestruct : MonoBehaviour
{
	private HurtCollider hurtCollider;

	private bool hasImpacted = false;

	private void Awake()
	{
		hurtCollider = ((Component)this).GetComponent<HurtCollider>();
		if ((Object)(object)hurtCollider == (Object)null)
		{
			hurtCollider = ((Component)this).GetComponentInChildren<HurtCollider>();
		}
		if ((Object)(object)hurtCollider == (Object)null)
		{
			Debug.LogError((object)"[ProjectileAutoDestruct] No HurtCollider found on this GameObject or its children!", (Object)(object)this);
			((Behaviour)this).enabled = false;
		}
	}

	private void OnEnable()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		if ((Object)(object)hurtCollider != (Object)null)
		{
			hurtCollider.onImpactAny.AddListener(new UnityAction(OnAnyImpact));
		}
		((MonoBehaviour)this).Invoke("SelfDestruct", 1f);
	}

	private void OnDisable()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		if ((Object)(object)hurtCollider != (Object)null)
		{
			hurtCollider.onImpactAny.RemoveListener(new UnityAction(OnAnyImpact));
		}
		((MonoBehaviour)this).CancelInvoke("SelfDestruct");
	}

	private void OnAnyImpact()
	{
		DestroyProjectile();
	}

	private void SelfDestruct()
	{
		DestroyProjectile();
	}

	private void DestroyProjectile()
	{
		if (!hasImpacted)
		{
			hasImpacted = true;
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null && component.ViewID != 0 && (component.IsMine || PhotonNetwork.IsMasterClient))
			{
				PhotonNetwork.Destroy(((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
public class AirlockDoor : MonoBehaviourPun
{
	[CompilerGenerated]
	private sealed class <DoorRoutine>d__24 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public AirlockDoor <>4__this;

		private GameObject[] <>s__1;

		private int <>s__2;

		private GameObject <go>5__3;

		private GameObject[] <>s__4;

		private int <>s__5;

		private GameObject <go>5__6;

		private GameObject[] <>s__7;

		private int <>s__8;

		private GameObject <go>5__9;

		private GameObject[] <>s__10;

		private int <>s__11;

		private GameObject <go>5__12;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = null;
			<go>5__3 = null;
			<>s__4 = null;
			<go>5__6 = null;
			<>s__7 = null;
			<go>5__9 = null;
			<>s__10 = null;
			<go>5__12 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.isOperating = true;
				<>s__1 = <>4__this.alarmObjects;
				for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
				{
					<go>5__3 = <>s__1[<>s__2];
					if ((Object)(object)<go>5__3 != (Object)null)
					{
						<go>5__3.SetActive(true);
					}
					<go>5__3 = null;
				}
				<>s__1 = null;
				if ((Object)(object)<>4__this.alarmAudioSource != (Object)null && (Object)(object)<>4__this.alarmClip != (Object)null)
				{
					<>4__this.alarmAudioSource.PlayOneShot(<>4__this.alarmClip);
				}
				<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.SlideDoorCoroutine(<>4__this.openDoorPosition));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(<>4__this.alarmTime);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>s__4 = <>4__this.alarmObjects;
				for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
				{
					<go>5__6 = <>s__4[<>s__5];
					if ((Object)(object)<go>5__6 != (Object)null)
					{
						<go>5__6.SetActive(false);
					}
					<go>5__6 = null;
				}
				<>s__4 = null;
				<>s__7 = <>4__this.activateOnOpen;
				for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++)
				{
					<go>5__9 = <>s__7[<>s__8];
					if ((Object)(object)<go>5__9 != (Object)null)
					{
						<go>5__9.SetActive(true);
					}
					<go>5__9 = null;
				}
				<>s__7 = null;
				<>2__current = (object)new WaitForSeconds(<>4__this.openTime);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>s__10 = <>4__this.activateOnOpen;
				for (<>s__11 = 0; <>s__11 < <>s__10.Length; <>s__11++)
				{
					<go>5__12 = <>s__10[<>s__11];
					if ((Object)(object)<go>5__12 != (Object)null)
					{
						<go>5__12.SetActive(false);
					}
					<go>5__12 = null;
				}
				<>s__10 = null;
				<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.SlideDoorCoroutine(<>4__this.originalDoorPosition));
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				<>4__this.isOperating = false;
				return false;
			}
		}

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

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

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

		private object <>2__current;

		public Vector3 targetPosition;

		public AirlockDoor <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00cd: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)<>4__this.doorAudioSource != (Object)null && (Object)(object)<>4__this.doorMoveClip != (Object)null)
				{
					<>4__this.doorAudioSource.PlayOneShot(<>4__this.doorMoveClip);
				}
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (Vector3.Distance(<>4__this.door.position, targetPosition) > 0.01f)
			{
				<>4__this.door.position = Vector3.MoveTowards(<>4__this.door.position, targetPosition, <>4__this.moveSpeed * Time.deltaTime);
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<>4__this.door.position = targetPosition;
			return false;
		}

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

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

	[Header("Door Settings")]
	public Transform door;

	public float moveDistance = 3f;

	public float moveSpeed = 2f;

	public float openTime = 3f;

	public float alarmTime = 2f;

	[Header("Audio Settings")]
	public AudioSource buttonAudioSource;

	public AudioClip buttonPressClip;

	public AudioSource doorAudioSource;

	public AudioClip doorMoveClip;

	[Header("Alarm Settings (optional)")]
	public GameObject[] alarmObjects;

	public AudioSource alarmAudioSource;

	public AudioClip alarmClip;

	[Header("Objects To Activate During Open (e.g. Wind, Pushers)")]
	public GameObject[] activateOnOpen;

	private Vector3 originalDoorPosition;

	private Vector3 openDoorPosition;

	private bool isOperating = false;

	private PhotonView photonView;

	private void Start()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0041: 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)
		photonView = ((Component)this).GetComponentInParent<PhotonView>();
		if ((Object)(object)door != (Object)null)
		{
			originalDoorPosition = door.position;
			openDoorPosition = originalDoorPosition + Vector3.up * moveDistance;
		}
	}

	public void ActivateDoor()
	{
		if (isOperating || (Object)(object)door == (Object)null)
		{
			return;
		}
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("RPC_PlayButtonSound", (RpcTarget)0, Array.Empty<object>());
		}
		else
		{
			PlayButtonSound();
		}
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				photonView.RPC("RPC_ActivateTimedDoor", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				photonView.RPC("RPC_RequestActivateTimedDoor", (RpcTarget)2, Array.Empty<object>());
			}
		}
		else
		{
			StartTimedDoor();
		}
	}

	[PunRPC]
	private void RPC_PlayButtonSound()
	{
		PlayButtonSound();
	}

	private void PlayButtonSound()
	{
		if ((Object)(object)buttonAudioSource != (Object)null && (Object)(object)buttonPressClip != (Object)null)
		{
			buttonAudioSource.PlayOneShot(buttonPressClip);
		}
	}

	[PunRPC]
	private void RPC_ActivateTimedDoor()
	{
		StartTimedDoor();
	}

	[PunRPC]
	private void RPC_RequestActivateTimedDoor()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			photonView.RPC("RPC_ActivateTimedDoor", (RpcTarget)0, Array.Empty<object>());
		}
	}

	private void StartTimedDoor()
	{
		if (!isOperating && !((Object)(object)door == (Object)null))
		{
			((MonoBehaviour)this).StartCoroutine(DoorRoutine());
		}
	}

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

	[IteratorStateMachine(typeof(<SlideDoorCoroutine>d__25))]
	private IEnumerator SlideDoorCoroutine(Vector3 targetPosition)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SlideDoorCoroutine>d__25(0)
		{
			<>4__this = this,
			targetPosition = targetPosition
		};
	}
}
public class TurretRotator : MonoBehaviourPunCallbacks
{
	[Header("Rotation Settings")]
	public float idleRotationSpeed = 30f;

	public float firingRotationSpeed = 70f;

	[Header("Detection Settings")]
	public float detectionRange = 10f;

	[Range(1f, 180f)]
	public float fieldOfView = 60f;

	[Header("Vision Mask (like EnemyVision's VisionMask)")]
	public LayerMask visionMask;

	[Header("Turret Eye (optional, uses transform if null)")]
	public Transform turretEye;

	[Header("Target Search Intervals (seconds)")]
	[Tooltip("How often to check for targets while idle (not firing).")]
	public float idleSearchInterval = 0.25f;

	[Tooltip("How often to check for targets while firing/locked on.")]
	public float firingSearchInterval = 0.21f;

	[Header("Spotting and Visuals")]
	public float spotToShootDelay = 1f;

	public GameObject spottedIcon;

	[Header("Audio")]
	public AudioSource audioSource;

	public AudioClip spottedSound;

	public AudioClip shootingSound;

	[Range(0f, 1f)]
	public float easterEggChance = 0.1f;

	public AudioClip[] easterEggSpottedSounds;

	public float[] easterEggDelays;

	[Header("Debug")]
	public bool enableDebug = false;

	private Transform target;

	private TurretShooter shooter;

	private float searchTimer = 0f;

	private bool isFiring = false;

	private bool isSpotted = false;

	private float spotTimer = 0f;

	private int lastEasterEggIndex = -1;

	private static readonly List<PlayerAvatar> cachedPlayers = new List<PlayerAvatar>(16);

	private Quaternion syncedRotation;

	private bool syncedIsSpotted;

	private bool syncedIsFiring;

	private int syncedTargetViewID = -1;

	private float lastSyncTime = 0f;

	private PhotonView photonView;

	private bool CanSendRPCs => PhotonNetwork.IsConnectedAndReady && PhotonNetwork.InRoom;

	private void Awake()
	{
		//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)
		shooter = ((Component)this).GetComponent<TurretShooter>();
		photonView = ((Component)this).GetComponent<PhotonView>();
		if ((Object)(object)spottedIcon != (Object)null)
		{
			spottedIcon.SetActive(false);
		}
		syncedRotation = ((Component)this).transform.rotation;
		syncedIsSpotted = false;
		syncedIsFiring = false;
		syncedTargetViewID = -1;
	}

	private void Update()
	{
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			float num = (isFiring ? firingSearchInterval : idleSearchInterval);
			searchTimer -= Time.deltaTime;
			if (searchTimer <= 0f)
			{
				searchTimer = num;
				Transform val = FindTargetInFOV();
				if (!isSpotted && (Object)(object)val != (Object)null)
				{
					OnPlayerSpotted();
					SyncStateWithClients();
				}
				else if (isSpotted && (Object)(object)val == (Object)null)
				{
					OnPlayerLost();
					SyncStateWithClients();
				}
				target = val;
			}
			if (isSpotted && (Object)(object)target != (Object)null)
			{
				LookAtTarget(firingRotationSpeed);
				if (spotTimer > 0f)
				{
					spotTimer -= Time.deltaTime;
				}
				else
				{
					if (!isFiring)
					{
						isFiring = true;
						SyncStateWithClients();
					}
					if ((Object)(object)shooter != (Object)null)
					{
						shooter.FireAtTarget(target, PlayShootingSound);
					}
				}
			}
			else
			{
				if (isFiring)
				{
					isFiring = false;
					SyncStateWithClients();
				}
				Rotate(idleRotationSpeed);
			}
			if (Time.time - lastSyncTime > 0.05f && CanSendRPCs)
			{
				lastSyncTime = Time.time;
				photonView.RPC("RPC_UpdateRotation", (RpcTarget)1, new object[1] { ((Component)this).transform.rotation });
			}
		}
		else
		{
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, syncedRotation, Time.deltaTime * 18f);
			if ((Object)(object)spottedIcon != (Object)null)
			{
				spottedIcon.SetActive(syncedIsSpotted);
			}
		}
	}

	private void SyncStateWithClients()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		int num = (Object.op_Implicit((Object)(object)target) ? ((Object)target).GetInstanceID() : (-1));
		if (CanSendRPCs)
		{
			photonView.RPC("RPC_UpdateTurretState", (RpcTarget)1, new object[4]
			{
				((Component)this).transform.rotation,
				isSpotted,
				isFiring,
				num
			});
		}
	}

	[PunRPC]
	private void RPC_UpdateTurretState(Quaternion rot, bool spotted, bool firing, int targetID)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		syncedRotation = rot;
		syncedIsSpotted = spotted;
		syncedIsFiring = firing;
		syncedTargetViewID = targetID;
	}

	[PunRPC]
	private void RPC_UpdateRotation(Quaternion rot)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		syncedRotation = rot;
	}

	private void OnPlayerSpotted()
	{
		isSpotted = true;
		lastEasterEggIndex = -1;
		if (easterEggSpottedSounds != null && easterEggSpottedSounds.Length != 0 && easterEggDelays != null && easterEggDelays.Length == easterEggSpottedSounds.Length && Random.value < easterEggChance)
		{
			lastEasterEggIndex = Random.Range(0, easterEggSpottedSounds.Length);
			AudioClip val = easterEggSpottedSounds[lastEasterEggIndex];
			float num = (spotTimer = easterEggDelays[lastEasterEggIndex]);
			if (enableDebug)
			{
				Debug.Log((object)$"[Turret] Easter egg spotted! Playing: {((val != null) ? ((Object)val).name : null)}, delay: {num}");
			}
			if ((Object)(object)audioSource != (Object)null && (Object)(object)val != (Object)null)
			{
				audioSource.PlayOneShot(val);
			}
		}
		else
		{
			spotTimer = spotToShootDelay;
			if (enableDebug)
			{
				Debug.Log((object)("[Turret] Player spotted! Playing normal sound. Delay before firing: " + spotToShootDelay));
			}
			if ((Object)(object)audioSource != (Object)null && (Object)(object)spottedSound != (Object)null)
			{
				audioSource.PlayOneShot(spottedSound);
			}
		}
		if ((Object)(object)spottedIcon != (Object)null)
		{
			spottedIcon.SetActive(true);
		}
	}

	private void OnPlayerLost()
	{
		isSpotted = false;
		isFiring = false;
		spotTimer = 0f;
		lastEasterEggIndex = -1;
		if (enableDebug)
		{
			Debug.Log((object)"[Turret] Lost sight of player.");
		}
		if ((Object)(object)spottedIcon != (Object)null)
		{
			spottedIcon.SetActive(false);
		}
	}

	private void PlayShootingSound()
	{
		if ((Object)(object)audioSource != (Object)null && (Object)(object)shootingSound != (Object)null)
		{
			audioSource.PlayOneShot(shootingSound);
		}
	}

	private void Rotate(float speed)
	{
		((Component)this).transform.Rotate(0f, speed * Time.deltaTime, 0f);
	}

	private void LookAtTarget(float speed)
	{
		//IL_0007: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: 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)
		Vector3 val = target.position - (Object.op_Implicit((Object)(object)turretEye) ? turretEye.position : ((Component)this).transform.position);
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		normalized.y = 0f;
		if (normalized != Vector3.zero)
		{
			Quaternion val2 = Quaternion.LookRotation(normalized);
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * speed / 10f);
		}
	}

	private Transform FindTargetInFOV()
	{
		//IL_0083: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: 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_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: 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)
		cachedPlayers.Clear();
		cachedPlayers.AddRange(SemiFunc.PlayerGetAll());
		if (enableDebug)
		{
			Debug.Log((object)$"[Turret] Checking {cachedPlayers.Count} players in scene.");
		}
		Transform bestTarget = null;
		float bestDot = -1f;
		Vector3 eye = (Object.op_Implicit((Object)(object)turretEye) ? turretEye.position : ((Component)this).transform.position);
		Vector3 forward = ((Component)this).transform.forward;
		foreach (PlayerAvatar cachedPlayer in cachedPlayers)
		{
			if ((Object)(object)cachedPlayer == (Object)null || cachedPlayer.isDisabled)
			{
				continue;
			}
			Transform val = ((Component)cachedPlayer).transform;
			FieldInfo field = ((object)cachedPlayer).GetType().GetField("VisionTarget");
			if (field != null)
			{
				object value = field.GetValue(cachedPlayer);
				Transform val2 = (Transform)((value is Transform) ? value : null);
				if (val2 != null && (Object)(object)val2 != (Object)null)
				{
					val = val2;
				}
			}
			Vector3 val3 = val.position;
			if ((Object)(object)val == (Object)(object)((Component)cachedPlayer).transform)
			{
				val3 += Vector3.up * 1f;
			}
			CheckCandidate(((Component)cachedPlayer).transform, val3, "Player");
		}
		if (Object.op_Implicit((Object)(object)bestTarget) && enableDebug)
		{
			Debug.Log((object)("[Turret] Closest visible target selected: " + ((Object)bestTarget).name));
		}
		else if (!Object.op_Implicit((Object)(object)bestTarget) && enableDebug)
		{
			Debug.Log((object)"[Turret] No valid player found in FOV.");
		}
		return bestTarget;
		void CheckCandidate(Transform candidateRoot, Vector3 candidateVisionTargetPosition, string candidateType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val4 = candidateVisionTargetPosition - eye;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			if (magnitude > detectionRange)
			{
				if (enableDebug)
				{
					Debug.Log((object)$"[Turret] {candidateType} {((Object)candidateRoot).name} is too far: {magnitude:F2} > {detectionRange}");
				}
			}
			else
			{
				Vector3 val5 = val4 / magnitude;
				float num = Vector3.Dot(forward, val5);
				float num2 = Mathf.Cos(MathF.PI / 180f * fieldOfView / 2f);
				if (enableDebug)
				{
					Debug.Log((object)$"[Turret] {candidateType} {((Object)candidateRoot).name} dot {num:F3}, required {num2:F3}");
				}
				if (num < num2)
				{
					if (enableDebug)
					{
						Debug.Log((object)("[Turret] " + candidateType + " " + ((Object)candidateRoot).name + " is outside FOV."));
					}
				}
				else
				{
					RaycastHit[] array = Physics.RaycastAll(eye, val5, magnitude, LayerMask.op_Implicit(visionMask), (QueryTriggerInteraction)1);
					Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
					Transform val6 = null;
					Transform val7 = null;
					RaycastHit[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						RaycastHit val8 = array2[i];
						if (enableDebug)
						{
							Debug.Log((object)$"[Turret] Raycast hit: {((Object)((RaycastHit)(ref val8)).transform).name} (tag: {((Component)((RaycastHit)(ref val8)).transform).tag}) dist: {((RaycastHit)(ref val8)).distance:F2}");
						}
						if (Object.op_Implicit((Object)(object)((Component)candidateRoot).GetComponent<PlayerAvatar>()) && ((Component)((RaycastHit)(ref val8)).transform).CompareTag("Player"))
						{
							val6 = ((RaycastHit)(ref val8)).transform;
						}
						if ((Object)(object)val7 == (Object)null && (Object)(object)((RaycastHit)(ref val8)).transform != (Object)(object)((Component)this).transform && !((RaycastHit)(ref val8)).transform.IsChildOf(((Component)this).transform) && (!Object.op_Implicit((Object)(object)((Component)candidateRoot).GetComponent<PlayerAvatar>()) || !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val8)).transform).GetComponentInParent<EnemyRigidbody>())))
						{
							val7 = ((RaycastHit)(ref val8)).transform;
						}
					}
					if (Object.op_Implicit((Object)(object)((Component)candidateRoot).GetComponent<PlayerAvatar>()) && (Object)(object)val6 != (Object)null && (Object)(object)val6 == (Object)(object)val7)
					{
						if (enableDebug)
						{
							Debug.Log((object)("[Turret] " + candidateType + " " + ((Object)candidateRoot).name + " is visible! Ray hit: " + ((Object)val6).name));
						}
						if (num > bestDot)
						{
							bestDot = num;
							bestTarget = candidateRoot;
						}
					}
				}
			}
		}
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0001: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00ca: 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)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		Gizmos.color = Color.yellow;
		Gizmos.DrawWireSphere(((Component)this).transform.position, detectionRange);
		Vector3 val = Quaternion.Euler(0f, (0f - fieldOfView) / 2f, 0f) * ((Component)this).transform.forward;
		Vector3 val2 = Quaternion.Euler(0f, fieldOfView / 2f, 0f) * ((Component)this).transform.forward;
		Gizmos.color = Color.cyan;
		Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + val * detectionRange);
		Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + val2 * detectionRange);
		if (Application.isPlaying && (Object)(object)target != (Object)null)
		{
			Gizmos.color = Color.red;
			Gizmos.DrawLine(((Component)this).transform.position, target.position);
		}
	}

	public void DisableTurretRotation()
	{
		((Behaviour)this).enabled = false;
		Debug.Log((object)"[TurretRotator] Rotation disabled");
	}
}
public class TurretShooter : MonoBehaviourPunCallbacks
{
	[Header("Projectile Firing")]
	public GameObject projectilePrefab;

	public Transform projectileSpawnPoint;

	public float projectileForce = 20f;

	public float fireRate = 1f;

	[Header("VFX")]
	public GameObject muzzleFlashRoot;

	private float fireCooldown = 0f;

	private bool CanSendRPCs => PhotonNetwork.IsConnectedAndReady && PhotonNetwork.InRoom;

	private void Update()
	{
		if (fireCooldown > 0f)
		{
			fireCooldown -= Time.deltaTime;
		}
	}

	public void FireAtTarget(Transform target, Action onFireSound = null)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target == (Object)null || fireCooldown > 0f)
		{
			return;
		}
		if ((Object)(object)projectilePrefab == (Object)null || (Object)(object)projectileSpawnPoint == (Object)null)
		{
			Debug.LogWarning((object)"[TurretShooter] Missing projectilePrefab or spawn point!");
			return;
		}
		Vector3 val = target.position - projectileSpawnPoint.position;
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		Quaternion val2 = Quaternion.LookRotation(normalized);
		Vector3 position = projectileSpawnPoint.position;
		float num = projectileForce;
		if (CanSendRPCs)
		{
			((MonoBehaviourPun)this).photonView.RPC("RPC_SpawnProjectile", (RpcTarget)0, new object[3] { position, val2, num });
		}
		else
		{
			SpawnProjectile(position, val2, num);
		}
		PlayMuzzleFlash();
		onFireSound?.Invoke();
		fireCooldown = fireRate;
	}

	[PunRPC]
	private void RPC_SpawnProjectile(Vector3 spawnPos, Quaternion spawnRot, float force)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		SpawnProjectile(spawnPos, spawnRot, force);
	}

	private void SpawnProjectile(Vector3 spawnPos, Quaternion spawnRot, float force)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)projectilePrefab == (Object)null)
		{
			Debug.LogWarning((object)"[TurretShooter] Projectile prefab not assigned!");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(projectilePrefab, spawnPos, spawnRot);
		val.SetActive(true);
		Rigidbody component = val.GetComponent<Rigidbody>();
		if ((Object)(object)component != (Object)null)
		{
			component.velocity = val.transform.forward * force;
		}
		Object.Destroy((Object)(object)val, 5f);
	}

	private void PlayMuzzleFlash()
	{
		if (!((Object)(object)muzzleFlashRoot == (Object)null))
		{
			ParticleSystem[] componentsInChildren = muzzleFlashRoot.GetComponentsInChildren<ParticleSystem>(true);
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				val.Stop(true, (ParticleSystemStopBehavior)0);
				val.Play(true);
			}
		}
	}

	public void DisableTurret()
	{
		((Behaviour)this).enabled = false;
		Debug.Log((object)"[TurretShooter] Disabled");
	}
}
[RequireComponent(typeof(BoxCollider))]
public class ZeroGravityZone : MonoBehaviour
{
	public float antiGravityDuration = 0.1f;

	[Header("Toggling")]
	[SerializeField]
	private bool isZoneActive = false;

	[SerializeField]
	private GameObject zeroGravityEffects;

	private readonly HashSet<PlayerAvatar> playersInZone = new HashSet<PlayerAvatar>();

	private BoxCollider zoneCollider;

	private PhotonView photonView;

	private void Awake()
	{
		zoneCollider = ((Component)this).GetComponent<BoxCollider>();
		((Collider)zoneCollider).isTrigger = true;
		photonView = ((Component)this).GetComponent<PhotonView>();
		if ((Object)(object)photonView == (Object)null)
		{
			photonView = ((Component)this).GetComponentInParent<PhotonView>();
		}
		ApplyEnabledState(isZoneActive);
	}

	private void ApplyEnabledState(bool enable)
	{
		isZoneActive = enable;
		if ((Object)(object)zoneCollider != (Object)null)
		{
			((Collider)zoneCollider).enabled = enable;
		}
		if ((Object)(object)zeroGravityEffects != (Object)null)
		{
			zeroGravityEffects.SetActive(enable);
		}
		if (!enable)
		{
			playersInZone.Clear();
		}
	}

	public void ToggleZoneOnGrab()
	{
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClient())
			{
				bool flag = !isZoneActive;
				if ((Object)(object)photonView != (Object)null)
				{
					photonView.RPC("SetZoneActiveRPC", (RpcTarget)0, new object[1] { flag });
				}
				else
				{
					SetZoneActiveRPC(flag);
				}
			}
		}
		else
		{
			SetZoneActiveRPC(!isZoneActive);
		}
	}

	[PunRPC]
	public void SetZoneActiveRPC(bool enable)
	{
		ApplyEnabledState(enable);
	}

	private void Update()
	{
		if (!isZoneActive)
		{
			return;
		}
		foreach (PlayerAvatar item in playersInZone)
		{
			if ((Object)(object)item != (Object)null && item.isLocal)
			{
				PlayerController.instance.AntiGravity(antiGravityDuration);
			}
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (isZoneActive)
		{
			PlayerAvatar componentInParent = ((Component)other).GetComponentInParent<PlayerAvatar>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				playersInZone.Add(componentInParent);
			}
		}
	}

	private void OnTriggerExit(Collider other)
	{
		if (isZoneActive)
		{
			PlayerAvatar componentInParent = ((Component)other).GetComponentInParent<PlayerAvatar>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				playersInZone.Remove(componentInParent);
			}
		}
	}

	private void OnTriggerStay(Collider other)
	{
		if (isZoneActive && SemiFunc.IsMasterClientOrSingleplayer())
		{
			PhysGrabObject componentInParent = ((Component)other).GetComponentInParent<PhysGrabObject>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				componentInParent.OverrideDrag(0.5f, 0.1f);
				componentInParent.OverrideAngularDrag(0.5f, 0.1f);
				componentInParent.OverrideZeroGravity(0.1f);
			}
		}
	}
}
namespace EchoholdAPI
{
	[BepInPlugin("Rosay.EchoholdAPI", "EchoholdAPI", "1.0")]
	public class EchoholdAPI : BaseUnityPlugin
	{
		internal static EchoholdAPI 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)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

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

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

		private void Update()
		{
		}
	}
}

PlasmaGunAPI.dll

Decompiled 2 months 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 TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[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("Rosay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlasmaGunAPI")]
[assembly: AssemblyTitle("PlasmaGunAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class ItemPlasmaGun : MonoBehaviour
{
	public enum State
	{
		Idle,
		OutOfEnergy,
		Buildup,
		Shooting,
		Reloading
	}

	[Header("Plasma Gun Settings")]
	public bool hasOneShot = true;

	public float shootTime = 1f;

	public bool hasBuildUp;

	public float buildUpTime = 1f;

	public int numberOfBullets = 1;

	[Header("Gun Physics")]
	[Range(0f, 65f)]
	public float gunRandomSpread;

	public float gunRange = 50f;

	public float distanceKeep = 0.8f;

	public float gunRecoilForce = 1f;

	public float cameraShakeMultiplier = 1f;

	public float torqueMultiplier = 1f;

	public float grabStrengthMultiplier = 1f;

	public float shootCooldown = 1f;

	[Header("Plasma Energy")]
	[Range(0f, 100f)]
	public float misfirePercentageChange = 50f;

	[Header("Gun Components")]
	public Transform gunMuzzle;

	public GameObject bulletPrefab;

	public GameObject muzzleFlashPrefab;

	public Transform gunTrigger;

	public float grabVerticalOffset = -0.2f;

	public float aimVerticalOffset = -5f;

	public float investigateRadius = 20f;

	[Header("Particle Effects")]
	public ParticleSystem muzzleFlashParticles;

	public ParticleSystem chargingParticles;

	public ParticleSystem energyTrailParticles;

	[Header("Audio")]
	public Sound soundShoot;

	public Sound soundShootGlobal;

	public Sound soundNoEnergyClick;

	public Sound soundHit;

	public Sound soundCharging;

	public Sound soundEnergyDepleted;

	[Header("Unity Events")]
	public UnityEvent onStateIdleStart;

	public UnityEvent onStateIdleUpdate;

	public UnityEvent onStateIdleFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateOutOfEnergyStart;

	public UnityEvent onStateOutOfEnergyUpdate;

	public UnityEvent onStateOutOfEnergyFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateBuildupStart;

	public UnityEvent onStateBuildupUpdate;

	public UnityEvent onStateBuildupFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateShootingStart;

	public UnityEvent onStateShootingUpdate;

	public UnityEvent onStateShootingFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateReloadingStart;

	public UnityEvent onStateReloadingUpdate;

	public UnityEvent onStateReloadingFixedUpdate;

	private PhysGrabObject physGrabObject;

	private ItemToggle itemToggle;

	private PlasmaEnergySystem plasmaEnergySystem;

	private PhotonView photonView;

	private PhysGrabObjectImpactDetector impactDetector;

	private ItemEquippable itemEquippable;

	private RoomVolumeCheck roomVolumeCheck;

	private bool prevToggleState;

	private AnimationCurve triggerAnimationCurve;

	private float triggerAnimationEval;

	private bool triggerAnimationActive;

	private float investigateCooldown;

	internal float stateTimer;

	internal float stateTimeMax;

	internal State stateCurrent;

	private State statePrev;

	private bool stateStart;

	private bool hasIdleUpdate = true;

	private bool hasIdleFixedUpdate = true;

	private bool hasOutOfEnergyUpdate = true;

	private bool hasOutOfEnergyFixedUpdate = true;

	private bool hasBuildupUpdate = true;

	private bool hasBuildupFixedUpdate = true;

	private bool hasShootingUpdate = true;

	private bool hasShootingFixedUpdate = true;

	private bool hasReloadingUpdate = true;

	private bool hasReloadingFixedUpdate = true;

	internal HurtCollider hurtCollider;

	private void Start()
	{
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		roomVolumeCheck = ((Component)this).GetComponent<RoomVolumeCheck>();
		itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
		physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		itemToggle = ((Component)this).GetComponent<ItemToggle>();
		plasmaEnergySystem = ((Component)this).GetComponent<PlasmaEnergySystem>();
		photonView = ((Component)this).GetComponent<PhotonView>();
		impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
		if ((Object)(object)plasmaEnergySystem == (Object)null)
		{
			Debug.LogError((object)"ItemPlasmaGun: PlasmaEnergySystem component is required!");
			((Behaviour)this).enabled = false;
		}
		else
		{
			plasmaEnergySystem.OnEnergyDepleted.AddListener(new UnityAction(OnEnergyDepleted));
			triggerAnimationCurve = AssetManager.instance.animationCurveClickInOut;
			OptimizeEventCalls();
		}
	}

	private void OptimizeEventCalls()
	{
		hasIdleUpdate = onStateIdleUpdate != null;
		hasIdleFixedUpdate = onStateIdleFixedUpdate != null;
		hasOutOfEnergyUpdate = onStateOutOfEnergyUpdate != null;
		hasOutOfEnergyFixedUpdate = onStateOutOfEnergyFixedUpdate != null;
		hasBuildupUpdate = onStateBuildupUpdate != null;
		hasBuildupFixedUpdate = onStateBuildupFixedUpdate != null;
		hasShootingUpdate = onStateShootingUpdate != null;
		hasShootingFixedUpdate = onStateShootingFixedUpdate != null;
		hasReloadingUpdate = onStateReloadingUpdate != null;
		hasReloadingFixedUpdate = onStateReloadingFixedUpdate != null;
	}

	private void FixedUpdate()
	{
		StateMachine(_fixedUpdate: true);
	}

	private void Update()
	{
		StateMachine(_fixedUpdate: false);
		HandleGrabbing();
		HandleTriggerAnimation();
		UpdateMaster();
	}

	private void HandleGrabbing()
	{
		if (physGrabObject.grabbed && physGrabObject.grabbedLocal)
		{
			PhysGrabber.instance.OverrideGrabDistance(distanceKeep);
		}
	}

	private void HandleTriggerAnimation()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if (triggerAnimationActive)
		{
			float num = 45f;
			triggerAnimationEval += Time.deltaTime * 4f;
			gunTrigger.localRotation = Quaternion.Euler(num * triggerAnimationCurve.Evaluate(triggerAnimationEval), 0f, 0f);
			if (triggerAnimationEval >= 1f)
			{
				gunTrigger.localRotation = Quaternion.Euler(0f, 0f, 0f);
				triggerAnimationActive = false;
				triggerAnimationEval = 1f;
			}
		}
	}

	private void UpdateMaster()
	{
		//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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer() || physGrabObject.playerGrabbing.Count <= 0)
		{
			return;
		}
		Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f);
		Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
		Quaternion identity = Quaternion.identity;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		bool flag4 = true;
		foreach (PhysGrabber item in physGrabObject.playerGrabbing)
		{
			if (flag4)
			{
				if (item.playerAvatar.isCrouching)
				{
					flag2 = true;
				}
				if (item.playerAvatar.isCrawling)
				{
					flag3 = true;
				}
				flag4 = false;
			}
			if (item.isRotating)
			{
				flag = true;
			}
		}
		if (!flag)
		{
			physGrabObject.TurnXYZ(val, val2, identity);
		}
		float num = grabVerticalOffset;
		if (flag2)
		{
			num += 0.5f;
		}
		if (flag3)
		{
			num -= 0.5f;
		}
		physGrabObject.OverrideGrabVerticalPosition(num);
		if (!flag && physGrabObject.grabbed)
		{
			physGrabObject.OverrideTorqueStrength(12f, 0.1f);
			physGrabObject.OverrideAngularDrag(20f, 0.1f);
		}
		if (flag)
		{
			physGrabObject.OverrideTorqueStrength(2f, 0.1f);
			physGrabObject.OverrideAngularDrag(20f, 0.1f);
		}
	}

	public void Misfire()
	{
		if (!roomVolumeCheck.inTruck && !physGrabObject.grabbed && !physGrabObject.hasNeverBeenGrabbed && SemiFunc.IsMasterClientOrSingleplayer() && (float)Random.Range(0, 100) < misfirePercentageChange)
		{
			Shoot();
		}
	}

	public void Shoot()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if (!plasmaEnergySystem.HasEnoughEnergy || !plasmaEnergySystem.TryConsumeEnergy())
		{
			return;
		}
		if (hasOneShot)
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("ShootRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				ShootRPC();
			}
			StateSet(State.Reloading);
		}
		else if (hasBuildUp)
		{
			StateSet(State.Buildup);
		}
		else
		{
			StateSet(State.Shooting);
		}
	}

	private void MuzzleFlash()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)muzzleFlashPrefab != (Object)null)
		{
			GameObject val = Object.Instantiate<GameObject>(muzzleFlashPrefab, gunMuzzle.position, gunMuzzle.rotation, gunMuzzle);
			PlasmaMuzzleFlash component = val.GetComponent<PlasmaMuzzleFlash>();
			if ((Object)(object)component != (Object)null)
			{
				component.ActivateAllEffects();
			}
			else
			{
				ItemGunMuzzleFlash component2 = val.GetComponent<ItemGunMuzzleFlash>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.ActivateAllEffects();
				}
			}
		}
		if ((Object)(object)muzzleFlashParticles != (Object)null)
		{
			muzzleFlashParticles.Play();
		}
	}

	private void StartTriggerAnimation()
	{
		triggerAnimationActive = true;
		triggerAnimationEval = 0f;
	}

	private void OnEnergyDepleted()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (soundEnergyDepleted != null)
		{
			soundEnergyDepleted.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}
	}

	[PunRPC]
	public void ShootRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: 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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: 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_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: 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)
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		float num = 3f * cameraShakeMultiplier;
		float num2 = 16f * cameraShakeMultiplier;
		SemiFunc.CameraShakeImpactDistance(gunMuzzle.position, 5f * cameraShakeMultiplier, 0.1f, num, num2);
		SemiFunc.CameraShakeDistance(gunMuzzle.position, 0.1f * cameraShakeMultiplier, 0.1f * cameraShakeMultiplier, num, num2);
		soundShoot.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
		soundShootGlobal.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
		MuzzleFlash();
		StartTriggerAnimation();
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if (investigateRadius > 0f)
		{
			EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
		}
		physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * gunRecoilForce, gunMuzzle.position, (ForceMode)1);
		RaycastHit val4 = default(RaycastHit);
		for (int i = 0; i < numberOfBullets; i++)
		{
			Vector3 endPosition = gunMuzzle.position;
			bool hit = false;
			bool flag = false;
			Vector3 val = gunMuzzle.forward;
			if (gunRandomSpread > 0f)
			{
				float num3 = Random.Range(0f, gunRandomSpread / 2f);
				float num4 = Random.Range(0f, 360f);
				Vector3 val2 = Vector3.Cross(val, Random.onUnitSphere);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Quaternion val3 = Quaternion.AngleAxis(num3, normalized);
				val2 = Quaternion.AngleAxis(num4, val) * val3 * val;
				val = ((Vector3)(ref val2)).normalized;
			}
			if (Physics.Raycast(gunMuzzle.position, val, ref val4, gunRange, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "Enemy" })))
			{
				endPosition = ((RaycastHit)(ref val4)).point;
				hit = true;
			}
			else
			{
				flag = true;
			}
			if (flag)
			{
				endPosition = gunMuzzle.position + gunMuzzle.forward * gunRange;
				hit = true;
			}
			ShootBullet(endPosition, hit);
		}
	}

	private void ShootBullet(Vector3 _endPosition, bool _hit)
	{
		//IL_0044: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("ShootBulletRPC", (RpcTarget)0, new object[2] { _endPosition, _hit });
			}
			else
			{
				ShootBulletRPC(_endPosition, _hit);
			}
		}
	}

	[PunRPC]
	public void ShootBulletRPC(Vector3 _endPosition, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: 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_008b: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		if (physGrabObject.playerGrabbing.Count > 1)
		{
			foreach (PhysGrabber item in physGrabObject.playerGrabbing)
			{
				item.OverrideGrabRelease();
			}
		}
		if ((Object)(object)bulletPrefab != (Object)null)
		{
			PlasmaProjectile component = Object.Instantiate<GameObject>(bulletPrefab, gunMuzzle.position, gunMuzzle.rotation).GetComponent<PlasmaProjectile>();
			component.SetProjectileData(gunMuzzle.position, _endPosition, _hit);
			hurtCollider = ((Component)component).GetComponentInChildren<HurtCollider>();
			component.ActivateAll();
		}
		soundHit.Play(_endPosition, 1f, 1f, 1f, 1f);
		if ((Object)(object)energyTrailParticles != (Object)null)
		{
			energyTrailParticles.Play();
		}
	}

	private void StateSet(State _state)
	{
		//IL_004f: 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)
		if (_state == stateCurrent)
		{
			return;
		}
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClient())
			{
				photonView.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (int)_state });
			}
		}
		else
		{
			StateSetRPC((int)_state);
		}
	}

	private void ShootLogic()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer() && itemToggle.toggleState != prevToggleState)
		{
			if (!plasmaEnergySystem.HasEnoughEnergy)
			{
				soundNoEnergyClick.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				StartTriggerAnimation();
				SemiFunc.CameraShakeImpact(1f, 0.1f);
				physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * 1f, gunMuzzle.position, (ForceMode)1);
			}
			else
			{
				Shoot();
			}
			prevToggleState = itemToggle.toggleState;
		}
	}

	[PunRPC]
	private void StateSetRPC(int state, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			stateStart = true;
			statePrev = stateCurrent;
			stateCurrent = (State)state;
		}
	}

	private void StateMachine(bool _fixedUpdate)
	{
		switch (stateCurrent)
		{
		case State.Idle:
			StateIdle(_fixedUpdate);
			break;
		case State.OutOfEnergy:
			StateOutOfEnergy(_fixedUpdate);
			break;
		case State.Buildup:
			StateBuildup(_fixedUpdate);
			break;
		case State.Shooting:
			StateShooting(_fixedUpdate);
			break;
		case State.Reloading:
			StateReloading(_fixedUpdate);
			break;
		}
	}

	private void StateIdle(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			UnityEvent obj = onStateIdleStart;
			if (obj != null)
			{
				obj.Invoke();
			}
			stateStart = false;
			prevToggleState = itemToggle.toggleState;
		}
		if (!_fixedUpdate)
		{
			ShootLogic();
			if (hasIdleUpdate)
			{
				onStateIdleUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasIdleFixedUpdate)
		{
			onStateIdleFixedUpdate.Invoke();
		}
	}

	private void StateOutOfEnergy(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			UnityEvent obj = onStateOutOfEnergyStart;
			if (obj != null)
			{
				obj.Invoke();
			}
			stateStart = false;
			prevToggleState = itemToggle.toggleState;
		}
		if (!_fixedUpdate)
		{
			if (plasmaEnergySystem.HasEnoughEnergy)
			{
				StateSet(State.Idle);
				return;
			}
			ShootLogic();
			if (hasOutOfEnergyUpdate)
			{
				onStateOutOfEnergyUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasOutOfEnergyFixedUpdate)
		{
			onStateOutOfEnergyFixedUpdate.Invoke();
		}
	}

	private void StateBuildup(bool _fixedUpdate)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart && !_fixedUpdate)
		{
			UnityEvent obj = onStateBuildupStart;
			if (obj != null)
			{
				obj.Invoke();
			}
			stateTimer = 0f;
			stateTimeMax = buildUpTime;
			stateStart = false;
			if ((Object)(object)chargingParticles != (Object)null)
			{
				chargingParticles.Play();
			}
			if (soundCharging != null)
			{
				soundCharging.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}
		if (!_fixedUpdate)
		{
			if (hasBuildupUpdate)
			{
				onStateBuildupUpdate.Invoke();
			}
			stateTimer += Time.deltaTime;
			if (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped)
			{
				StateSet(State.Idle);
			}
			if (stateTimer >= stateTimeMax && plasmaEnergySystem.HasEnoughEnergy)
			{
				StateSet(State.Shooting);
			}
		}
		if (_fixedUpdate && hasBuildupFixedUpdate)
		{
			onStateBuildupFixedUpdate.Invoke();
		}
	}

	private void StateShooting(bool _fixedUpdate)
	{
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart && !_fixedUpdate)
		{
			stateStart = false;
			UnityEvent obj = onStateShootingStart;
			if (obj != null)
			{
				obj.Invoke();
			}
			if (!hasOneShot)
			{
				stateTimeMax = shootTime;
				stateTimer = 0f;
				investigateCooldown = 0f;
			}
			else
			{
				stateTimer = 0.001f;
			}
		}
		if (!_fixedUpdate)
		{
			if (investigateRadius > 0f)
			{
				if (investigateCooldown <= 0f)
				{
					EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
					investigateCooldown = 0.5f;
				}
				else
				{
					investigateCooldown -= Time.deltaTime;
				}
			}
			stateTimer += Time.deltaTime;
			if (stateTimer >= stateTimeMax || (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped))
			{
				StateSet(State.Reloading);
			}
			if (hasShootingUpdate)
			{
				onStateShootingUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasShootingFixedUpdate)
		{
			onStateShootingFixedUpdate.Invoke();
		}
	}

	private void StateReloading(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			stateStart = false;
			UnityEvent obj = onStateReloadingStart;
			if (obj != null)
			{
				obj.Invoke();
			}
			stateTimeMax = shootCooldown;
			stateTimer = 0f;
		}
		if (!_fixedUpdate)
		{
			stateTimer += Time.deltaTime;
			if (stateTimer >= stateTimeMax)
			{
				if (plasmaEnergySystem.HasEnoughEnergy)
				{
					StateSet(State.Idle);
				}
				else
				{
					StateSet(State.OutOfEnergy);
				}
			}
			if (hasReloadingUpdate)
			{
				onStateReloadingUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasReloadingFixedUpdate)
		{
			onStateReloadingFixedUpdate.Invoke();
		}
	}

	public float GetCurrentEnergyPercentage()
	{
		return plasmaEnergySystem.CurrentEnergyPercentage;
	}

	public bool HasEnoughEnergy()
	{
		return plasmaEnergySystem.HasEnoughEnergy;
	}

	public bool IsRegenerating()
	{
		return plasmaEnergySystem.IsRegenerating;
	}
}
[Serializable]
public class PlasmaEnergySystem : MonoBehaviour
{
	[Header("Plasma Energy Settings")]
	[Range(0f, 100f)]
	public float maxEnergy = 100f;

	[Range(0.1f, 50f)]
	public float energyDrainPerShot = 10f;

	[Range(0.1f, 20f)]
	public float energyRegenRate = 5f;

	[Range(0f, 5f)]
	public float regenDelay = 1f;

	[Header("Critical Energy System")]
	[Range(0f, 25f)]
	public float criticalEnergyThreshold = 10f;

	[Range(0f, 10f)]
	public float criticalRegenDelay = 3f;

	public Sound criticalEnergySound;

	[Header("Current State")]
	[SerializeField]
	private float currentEnergy = 100f;

	[SerializeField]
	private bool isRegenerating = false;

	[SerializeField]
	private bool isInCriticalState = false;

	private float lastShotTime = 0f;

	private PhotonView photonView;

	private bool hasPlayedCriticalSound = false;

	[Header("Events")]
	public UnityEvent<float> OnEnergyChanged;

	public UnityEvent OnEnergyDepleted;

	public UnityEvent OnRegenerationStarted;

	public UnityEvent OnRegenerationStopped;

	public UnityEvent<bool> OnRegenerationStateChanged;

	public float CurrentEnergy => currentEnergy;

	public float CurrentEnergyPercentage => currentEnergy / maxEnergy * 100f;

	public bool HasEnoughEnergy => currentEnergy >= energyDrainPerShot && !isInCriticalState;

	public bool IsRegenerating => isRegenerating;

	public bool IsFullyCharged => currentEnergy >= maxEnergy;

	public bool IsInCriticalState => isInCriticalState;

	private void Awake()
	{
		photonView = ((Component)this).GetComponent<PhotonView>();
		currentEnergy = maxEnergy;
	}

	private void Start()
	{
		OnEnergyChanged?.Invoke(CurrentEnergyPercentage);
	}

	private void Update()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			HandleEnergyRegeneration();
		}
	}

	private void HandleEnergyRegeneration()
	{
		HandleCriticalEnergyState();
		float num = (isInCriticalState ? (regenDelay + criticalRegenDelay) : regenDelay);
		bool flag = currentEnergy < maxEnergy && Time.time >= lastShotTime + num;
		if (flag && !isRegenerating)
		{
			StartRegeneration();
		}
		else if (!flag && isRegenerating)
		{
			StopRegeneration();
		}
		if (!isRegenerating)
		{
			return;
		}
		float num2 = currentEnergy;
		currentEnergy = Mathf.Min(currentEnergy + energyRegenRate * Time.deltaTime, maxEnergy);
		if (currentEnergy != num2)
		{
			SyncEnergyLevel(currentEnergy);
		}
		if (currentEnergy >= maxEnergy)
		{
			StopRegeneration();
			if (isInCriticalState)
			{
				ExitCriticalState();
			}
		}
	}

	private void HandleCriticalEnergyState()
	{
		float currentEnergyPercentage = CurrentEnergyPercentage;
		if (!isInCriticalState && currentEnergyPercentage <= criticalEnergyThreshold)
		{
			EnterCriticalState();
		}
		else if (isInCriticalState && currentEnergyPercentage >= 100f)
		{
			ExitCriticalState();
		}
	}

	private void EnterCriticalState()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		isInCriticalState = true;
		if (!hasPlayedCriticalSound && criticalEnergySound != null)
		{
			criticalEnergySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			hasPlayedCriticalSound = true;
		}
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetCriticalStateRPC", (RpcTarget)0, new object[1] { true });
		}
	}

	private void ExitCriticalState()
	{
		isInCriticalState = false;
		hasPlayedCriticalSound = false;
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetCriticalStateRPC", (RpcTarget)0, new object[1] { false });
		}
	}

	public bool TryConsumeEnergy()
	{
		if (!HasEnoughEnergy)
		{
			UnityEvent onEnergyDepleted = OnEnergyDepleted;
			if (onEnergyDepleted != null)
			{
				onEnergyDepleted.Invoke();
			}
			return false;
		}
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			ConsumeEnergy(energyDrainPerShot);
		}
		return true;
	}

	public bool TryConsumeEnergy(float amount)
	{
		if (currentEnergy < amount)
		{
			UnityEvent onEnergyDepleted = OnEnergyDepleted;
			if (onEnergyDepleted != null)
			{
				onEnergyDepleted.Invoke();
			}
			return false;
		}
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			ConsumeEnergy(amount);
		}
		return true;
	}

	private void ConsumeEnergy(float amount)
	{
		currentEnergy = Mathf.Max(currentEnergy - amount, 0f);
		lastShotTime = Time.time;
		if (isRegenerating)
		{
			StopRegeneration();
		}
		SyncEnergyLevel(currentEnergy);
	}

	private void StartRegeneration()
	{
		isRegenerating = true;
		UnityEvent onRegenerationStarted = OnRegenerationStarted;
		if (onRegenerationStarted != null)
		{
			onRegenerationStarted.Invoke();
		}
		OnRegenerationStateChanged?.Invoke(true);
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetRegenerationStateRPC", (RpcTarget)0, new object[1] { true });
		}
	}

	private void StopRegeneration()
	{
		isRegenerating = false;
		UnityEvent onRegenerationStopped = OnRegenerationStopped;
		if (onRegenerationStopped != null)
		{
			onRegenerationStopped.Invoke();
		}
		OnRegenerationStateChanged?.Invoke(false);
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetRegenerationStateRPC", (RpcTarget)0, new object[1] { false });
		}
	}

	private void SyncEnergyLevel(float energy)
	{
		OnEnergyChanged?.Invoke(energy / maxEnergy * 100f);
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetEnergyLevelRPC", (RpcTarget)0, new object[1] { energy });
		}
	}

	[PunRPC]
	private void SetEnergyLevelRPC(float energy)
	{
		currentEnergy = energy;
		OnEnergyChanged?.Invoke(energy / maxEnergy * 100f);
	}

	[PunRPC]
	private void SetRegenerationStateRPC(bool regenerating)
	{
		isRegenerating = regenerating;
		OnRegenerationStateChanged?.Invoke(regenerating);
		if (regenerating)
		{
			UnityEvent onRegenerationStarted = OnRegenerationStarted;
			if (onRegenerationStarted != null)
			{
				onRegenerationStarted.Invoke();
			}
		}
		else
		{
			UnityEvent onRegenerationStopped = OnRegenerationStopped;
			if (onRegenerationStopped != null)
			{
				onRegenerationStopped.Invoke();
			}
		}
	}

	[PunRPC]
	private void SetCriticalStateRPC(bool critical)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		isInCriticalState = critical;
		if (critical && !hasPlayedCriticalSound && criticalEnergySound != null)
		{
			criticalEnergySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			hasPlayedCriticalSound = true;
		}
		else if (!critical)
		{
			hasPlayedCriticalSound = false;
		}
	}

	public void SetMaxEnergy(float newMaxEnergy)
	{
		maxEnergy = newMaxEnergy;
		currentEnergy = Mathf.Min(currentEnergy, maxEnergy);
		OnEnergyChanged?.Invoke(CurrentEnergyPercentage);
	}

	public void SetEnergyDrainPerShot(float newDrain)
	{
		energyDrainPerShot = newDrain;
	}

	public void SetRegenRate(float newRate)
	{
		energyRegenRate = newRate;
	}

	public void SetRegenDelay(float newDelay)
	{
		regenDelay = newDelay;
	}

	public void RestoreEnergy(float amount)
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			currentEnergy = Mathf.Min(currentEnergy + amount, maxEnergy);
			SyncEnergyLevel(currentEnergy);
		}
	}

	public void SetEnergyLevel(float energy)
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			currentEnergy = Mathf.Clamp(energy, 0f, maxEnergy);
			SyncEnergyLevel(currentEnergy);
		}
	}

	[ContextMenu("Drain 25% Energy")]
	private void DebugDrainEnergy()
	{
		TryConsumeEnergy(maxEnergy * 0.25f);
	}

	[ContextMenu("Restore Full Energy")]
	private void DebugRestoreEnergy()
	{
		SetEnergyLevel(maxEnergy);
	}
}
public class PlasmaMuzzleFlash : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <MuzzleFlashDestroy>d__8 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public PlasmaMuzzleFlash <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(<>4__this.initialDelay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			if (<>4__this.AreParticlesPlaying() || <>4__this.AreLightsActive())
			{
				<>2__current = null;
				<>1__state = 2;
				return true;
			}
			Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
			return false;
		}

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

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

	[Header("Particle Systems")]
	[Tooltip("Assign as many particle systems as you want for the muzzle flash")]
	public ParticleSystem[] muzzleParticles;

	[Header("Lights")]
	[Tooltip("Assign as many lights as you want for the muzzle flash")]
	public Light[] muzzleLights;

	[Header("Settings")]
	[Tooltip("How long to wait before starting the destruction check")]
	public float initialDelay = 0.1f;

	[Tooltip("Speed at which lights fade out")]
	public float lightFadeSpeed = 10f;

	[Tooltip("Minimum light intensity before disabling")]
	public float minLightIntensity = 0.01f;

	private List<float> originalLightIntensities = new List<float>();

	private bool effectsActivated = false;

	public void ActivateAllEffects()
	{
		((Component)this).gameObject.SetActive(true);
		effectsActivated = true;
		originalLightIntensities.Clear();
		if (muzzleParticles != null)
		{
			ParticleSystem[] array = muzzleParticles;
			foreach (ParticleSystem val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(true);
					val.Play();
				}
			}
		}
		if (muzzleLights != null)
		{
			Light[] array2 = muzzleLights;
			foreach (Light val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					originalLightIntensities.Add(val2.intensity);
					((Behaviour)val2).enabled = true;
				}
			}
		}
		((MonoBehaviour)this).StartCoroutine(MuzzleFlashDestroy());
	}

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

	private bool AreParticlesPlaying()
	{
		if (muzzleParticles == null)
		{
			return false;
		}
		ParticleSystem[] array = muzzleParticles;
		foreach (ParticleSystem val in array)
		{
			if ((Object)(object)val != (Object)null && val.isPlaying)
			{
				return true;
			}
		}
		return false;
	}

	private bool AreLightsActive()
	{
		if (muzzleLights == null)
		{
			return false;
		}
		Light[] array = muzzleLights;
		foreach (Light val in array)
		{
			if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
			{
				return true;
			}
		}
		return false;
	}

	private void Update()
	{
		if (!effectsActivated || muzzleLights == null)
		{
			return;
		}
		for (int i = 0; i < muzzleLights.Length; i++)
		{
			Light val = muzzleLights[i];
			if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
			{
				val.intensity = Mathf.Lerp(val.intensity, 0f, Time.deltaTime * lightFadeSpeed);
				if (val.intensity < minLightIntensity)
				{
					((Behaviour)val).enabled = false;
				}
			}
		}
	}

	public void StopAllEffects()
	{
		if (muzzleParticles != null)
		{
			ParticleSystem[] array = muzzleParticles;
			foreach (ParticleSystem val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.Stop();
				}
			}
		}
		if (muzzleLights == null)
		{
			return;
		}
		Light[] array2 = muzzleLights;
		foreach (Light val2 in array2)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				((Behaviour)val2).enabled = false;
			}
		}
	}

	public void ResetLightIntensities()
	{
		if (muzzleLights == null || originalLightIntensities.Count != muzzleLights.Length)
		{
			return;
		}
		for (int i = 0; i < muzzleLights.Length; i++)
		{
			if ((Object)(object)muzzleLights[i] != (Object)null && i < originalLightIntensities.Count)
			{
				muzzleLights[i].intensity = originalLightIntensities[i];
			}
		}
	}

	[ContextMenu("Test Muzzle Flash")]
	private void TestMuzzleFlash()
	{
		ActivateAllEffects();
	}

	private void OnDestroy()
	{
		originalLightIntensities.Clear();
	}
}
public class PlasmaProjectile : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <ProjectileDestroy>d__54 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public PlasmaProjectile <>4__this;

		private float <timer>5__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<timer>5__1 = 0f;
				goto IL_0066;
			case 1:
				<>1__state = -1;
				goto IL_0066;
			case 2:
				{
					<>1__state = -1;
					<>4__this.StopProjectileParticles();
					if (<>4__this.useTrailRenderer && (Object)(object)<>4__this.plasmaTrailRenderer != (Object)null)
					{
						((Renderer)<>4__this.plasmaTrailRenderer).enabled = false;
					}
					Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
					return false;
				}
				IL_0066:
				if (<timer>5__1 < <>4__this.maxLifetime && <>4__this.isMoving)
				{
					<timer>5__1 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (<>4__this.isMoving)
				{
					<>4__this.isMoving = false;
					<>4__this.StopProjectileParticles();
				}
				<>2__current = (object)new WaitForSeconds(<>4__this.projectileLingerTime);
				<>1__state = 2;
				return true;
			}
		}

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

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

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

		private object <>2__current;

		public PlasmaProjectile <>4__this;

		private float <moveDistance>5__1;

		private Vector3 <newPosition>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.currentDistance = 0f;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<>4__this.isMoving && <>4__this.currentDistance < <>4__this.totalDistance)
			{
				<moveDistance>5__1 = <>4__this.projectileSpeed * Time.deltaTime;
				<>4__this.currentDistance += <moveDistance>5__1;
				<newPosition>5__2 = <>4__this.startPosition + <>4__this.direction * <>4__this.currentDistance;
				((Component)<>4__this).transform.position = <newPosition>5__2;
				if (!(<>4__this.currentDistance >= <>4__this.totalDistance))
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				((Component)<>4__this).transform.position = <>4__this.hitPosition;
				<>4__this.hasReachedTarget = true;
				<>4__this.isMoving = false;
				<>4__this.TriggerImpact();
			}
			return false;
		}

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

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

	[Header("Projectile Settings")]
	public float projectileSpeed = 30f;

	public float maxLifetime = 3f;

	[Header("Plasma Particle Effects")]
	private Transform hitEffectTransform;

	private ParticleSystem particleImpactSparks;

	private ParticleSystem particleImpactSmoke;

	private ParticleSystem particleImpactEnergy;

	private ParticleSystem particleImpactGlow;

	private Light hitLight;

	private Light projectileLight;

	[Header("Projectile Particles")]
	public ParticleSystem plasmaCore;

	public ParticleSystem plasmaTrail;

	public ParticleSystem plasmaGlow;

	public ParticleSystem plasmaEnergy;

	[Header("Trail Renderer Option")]
	public bool useTrailRenderer = false;

	public TrailRenderer plasmaTrailRenderer;

	[Header("Scaling Options")]
	public bool enableScaling = true;

	[Space(5f)]
	public bool useInitialScale = true;

	public Vector3 initialScaleMultiplier = new Vector3(0.5f, 0.5f, 0.5f);

	[Space(5f)]
	public bool scaleOverDistance = true;

	public AnimationCurve scaleOverDistanceCurve = AnimationCurve.Linear(0f, 1f, 1f, 0.5f);

	[Space(5f)]
	public bool scaleOverTime = false;

	public AnimationCurve scaleOverTimeCurve = AnimationCurve.Linear(0f, 1f, 1f, 0.8f);

	[Space(5f)]
	public bool scaleOnImpact = true;

	public AnimationCurve impactScaleCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
	{
		new Keyframe(0f, 1f),
		new Keyframe(0.3f, 0f)
	});

	public float impactScaleDuration = 0.3f;

	[Space(5f)]
	public Vector3 minScale = new Vector3(0.1f, 0.1f, 0.1f);

	public Vector3 maxScale = new Vector3(2f, 2f, 2f);

	[Header("Damage Settings")]
	public bool hasHurtCollider = true;

	public HurtCollider hurtCollider;

	public float hurtColliderTimer = 0.25f;

	[Header("Impact Effects")]
	public GameObject hitEffectPrefab;

	public float hitEffectDestroyTime = 3f;

	public GameObject hitGameObject;

	public float hitGameObjectDestroyTime = 2f;

	public bool hasExtraParticles;

	public GameObject extraParticles;

	[Header("Projectile Cleanup")]
	public float projectileLingerTime = 0.1f;

	internal bool projectileHit;

	internal Vector3 hitPosition;

	internal Vector3 startPosition;

	internal Vector3 direction;

	private float currentDistance;

	private float totalDistance;

	private bool isMoving = true;

	private bool hasReachedTarget = false;

	private Vector3 originalScale;

	private float projectileLifetime = 0f;

	private bool isImpactScaling = false;

	private float impactScaleTimer = 0f;

	public void ActivateAll()
	{
		//IL_0015: 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_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_014f: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).gameObject.SetActive(true);
		originalScale = ((Component)this).transform.localScale;
		hitEffectTransform = ((Component)this).transform.Find("Hit Effect");
		if ((Object)(object)hitEffectTransform != (Object)null)
		{
			Transform obj = hitEffectTransform.Find("Particle Impact Sparks");
			particleImpactSparks = ((obj != null) ? ((Component)obj).GetComponent<ParticleSystem>() : null);
			Transform obj2 = hitEffectTransform.Find("Particle Impact Smoke");
			particleImpactSmoke = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null);
			Transform obj3 = hitEffectTransform.Find("Particle Impact Energy");
			particleImpactEnergy = ((obj3 != null) ? ((Component)obj3).GetComponent<ParticleSystem>() : null);
			Transform obj4 = hitEffectTransform.Find("Particle Impact Glow");
			particleImpactGlow = ((obj4 != null) ? ((Component)obj4).GetComponent<ParticleSystem>() : null);
			Transform obj5 = hitEffectTransform.Find("Hit Light");
			hitLight = ((obj5 != null) ? ((Component)obj5).GetComponent<Light>() : null);
		}
		projectileLight = ((Component)this).GetComponentInChildren<Light>();
		if (useTrailRenderer && (Object)(object)plasmaTrailRenderer == (Object)null)
		{
			plasmaTrailRenderer = ((Component)this).GetComponentInChildren<TrailRenderer>();
		}
		startPosition = ((Component)this).transform.position;
		Vector3 val = hitPosition - startPosition;
		direction = ((Vector3)(ref val)).normalized;
		totalDistance = Vector3.Distance(startPosition, hitPosition);
		if (direction != Vector3.zero)
		{
			((Component)this).transform.rotation = Quaternion.LookRotation(direction);
		}
		if (enableScaling && useInitialScale)
		{
			originalScale = Vector3.Scale(originalScale, initialScaleMultiplier);
			((Component)this).transform.localScale = originalScale;
		}
		StartProjectileParticles();
		if (useTrailRenderer && (Object)(object)plasmaTrailRenderer != (Object)null)
		{
			((Renderer)plasmaTrailRenderer).enabled = true;
		}
		if ((Object)(object)projectileLight != (Object)null)
		{
			((Behaviour)projectileLight).enabled = true;
		}
		((MonoBehaviour)this).StartCoroutine(ProjectileMovement());
		((MonoBehaviour)this).StartCoroutine(ProjectileDestroy());
	}

	private void StartProjectileParticles()
	{
		if ((Object)(object)plasmaCore != (Object)null)
		{
			((Component)plasmaCore).gameObject.SetActive(true);
			plasmaCore.Play();
		}
		if ((Object)(object)plasmaTrail != (Object)null)
		{
			((Component)plasmaTrail).gameObject.SetActive(true);
			plasmaTrail.Play();
		}
		if ((Object)(object)plasmaGlow != (Object)null)
		{
			((Component)plasmaGlow).gameObject.SetActive(true);
			plasmaGlow.Play();
		}
		if ((Object)(object)plasmaEnergy != (Object)null)
		{
			((Component)plasmaEnergy).gameObject.SetActive(true);
			plasmaEnergy.Play();
		}
	}

	private void StopProjectileParticles()
	{
		if ((Object)(object)plasmaCore != (Object)null)
		{
			plasmaCore.Stop();
		}
		if ((Object)(object)plasmaTrail != (Object)null)
		{
			plasmaTrail.Stop();
		}
		if ((Object)(object)plasmaGlow != (Object)null)
		{
			plasmaGlow.Stop();
		}
		if ((Object)(object)plasmaEnergy != (Object)null)
		{
			plasmaEnergy.Stop();
		}
		if ((Object)(object)projectileLight != (Object)null)
		{
			((Behaviour)projectileLight).enabled = false;
		}
	}

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

	private void TriggerImpact()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		StopProjectileParticles();
		if (enableScaling && scaleOnImpact)
		{
			isImpactScaling = true;
			impactScaleTimer = 0f;
		}
		if (!projectileHit)
		{
			return;
		}
		if ((Object)(object)hitEffectPrefab != (Object)null)
		{
			GameObject val = Object.Instantiate<GameObject>(hitEffectPrefab, hitPosition, Quaternion.LookRotation(-direction));
			val.SetActive(true);
			ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val2 in array)
			{
				((Component)val2).gameObject.SetActive(true);
				val2.Play();
			}
			Light[] componentsInChildren2 = val.GetComponentsInChildren<Light>();
			Light[] array2 = componentsInChildren2;
			foreach (Light val3 in array2)
			{
				((Behaviour)val3).enabled = true;
			}
			Object.Destroy((Object)(object)val, hitEffectDestroyTime);
		}
		if ((Object)(object)hitEffectTransform != (Object)null)
		{
			((Component)hitEffectTransform).gameObject.SetActive(true);
			hitEffectTransform.position = hitPosition;
			hitEffectTransform.rotation = Quaternion.LookRotation(-direction);
			if ((Object)(object)particleImpactSparks != (Object)null)
			{
				((Component)particleImpactSparks).gameObject.SetActive(true);
				particleImpactSparks.Play();
			}
			if ((Object)(object)particleImpactSmoke != (Object)null)
			{
				((Component)particleImpactSmoke).gameObject.SetActive(true);
				particleImpactSmoke.Play();
			}
			if ((Object)(object)particleImpactEnergy != (Object)null)
			{
				((Component)particleImpactEnergy).gameObject.SetActive(true);
				particleImpactEnergy.Play();
			}
			if ((Object)(object)particleImpactGlow != (Object)null)
			{
				((Component)particleImpactGlow).gameObject.SetActive(true);
				particleImpactGlow.Play();
			}
			if ((Object)(object)hitLight != (Object)null)
			{
				((Behaviour)hitLight).enabled = true;
			}
		}
		GameObject val4 = null;
		if (hasHurtCollider && (Object)(object)hurtCollider != (Object)null)
		{
			val4 = ((Component)hurtCollider).gameObject;
		}
		else if ((Object)(object)hitGameObject != (Object)null)
		{
			val4 = hitGameObject;
		}
		if ((Object)(object)val4 != (Object)null)
		{
			val4.SetActive(true);
			val4.transform.position = hitPosition;
			val4.transform.rotation = Quaternion.LookRotation(-direction);
		}
		if (hasExtraParticles && (Object)(object)extraParticles != (Object)null)
		{
			extraParticles.SetActive(true);
			extraParticles.transform.position = hitPosition;
			extraParticles.transform.rotation = Quaternion.LookRotation(-direction);
		}
	}

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

	private bool AreParticlesPlaying()
	{
		bool result = false;
		if ((Object)(object)plasmaCore != (Object)null && plasmaCore.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)plasmaTrail != (Object)null && plasmaTrail.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)plasmaGlow != (Object)null && plasmaGlow.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)plasmaEnergy != (Object)null && plasmaEnergy.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)particleImpactSparks != (Object)null && particleImpactSparks.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)particleImpactSmoke != (Object)null && particleImpactSmoke.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)particleImpactEnergy != (Object)null && particleImpactEnergy.isPlaying)
		{
			result = true;
		}
		if ((Object)(object)particleImpactGlow != (Object)null && particleImpactGlow.isPlaying)
		{
			result = true;
		}
		return result;
	}

	private bool IsLightActive()
	{
		bool result = false;
		if ((Object)(object)projectileLight != (Object)null && ((Behaviour)projectileLight).enabled)
		{
			result = true;
		}
		if ((Object)(object)hitLight != (Object)null && ((Behaviour)hitLight).enabled)
		{
			result = true;
		}
		return result;
	}

	private bool IsHurtColliderActive()
	{
		return hasHurtCollider && (Object)(object)hurtCollider != (Object)null && ((Component)hurtCollider).gameObject.activeSelf;
	}

	private bool IsHitGameObjectActive()
	{
		return !hasHurtCollider && (Object)(object)hitGameObject != (Object)null && hitGameObject.activeSelf;
	}

	private void UpdateEffects()
	{
		if (projectileHit && hasHurtCollider && (Object)(object)hurtCollider != (Object)null)
		{
			if (hurtColliderTimer > 0f)
			{
				hurtColliderTimer -= Time.deltaTime;
				if (!((Component)hurtCollider).gameObject.activeSelf)
				{
				}
			}
			else
			{
				((Component)hurtCollider).gameObject.SetActive(false);
			}
		}
		if (projectileHit && !hasHurtCollider && (Object)(object)hitGameObject != (Object)null)
		{
			hitGameObjectDestroyTime -= Time.deltaTime;
			if (hitGameObjectDestroyTime <= 0f)
			{
				hitGameObject.SetActive(false);
			}
		}
		if ((Object)(object)hitLight != (Object)null && ((Behaviour)hitLight).enabled)
		{
			hitLight.intensity = Mathf.Lerp(hitLight.intensity, 0f, Time.deltaTime * 10f);
			if (hitLight.intensity < 0.01f)
			{
				((Behaviour)hitLight).enabled = false;
			}
		}
		if ((Object)(object)projectileLight != (Object)null && ((Behaviour)projectileLight).enabled && !isMoving)
		{
			projectileLight.intensity = Mathf.Lerp(projectileLight.intensity, 0f, Time.deltaTime * 15f);
			if (projectileLight.intensity < 0.01f)
			{
				((Behaviour)projectileLight).enabled = false;
			}
		}
	}

	private void Update()
	{
		projectileLifetime += Time.deltaTime;
		if (enableScaling)
		{
			UpdateScaling();
		}
		if (hasReachedTarget || !isMoving)
		{
			UpdateEffects();
		}
	}

	private void UpdateScaling()
	{
		//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_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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = originalScale;
		if (isImpactScaling)
		{
			impactScaleTimer += Time.deltaTime;
			float num = Mathf.Clamp01(impactScaleTimer / impactScaleDuration);
			float num2 = impactScaleCurve.Evaluate(num);
			val = Vector3.Scale(originalScale, Vector3.one * num2);
			if (num >= 1f)
			{
				isImpactScaling = false;
			}
		}
		else
		{
			if (scaleOverDistance && totalDistance > 0f)
			{
				float num3 = Mathf.Clamp01(currentDistance / totalDistance);
				float num4 = scaleOverDistanceCurve.Evaluate(num3);
				val = Vector3.Scale(val, Vector3.one * num4);
			}
			if (scaleOverTime)
			{
				float num5 = Mathf.Clamp01(projectileLifetime / maxLifetime);
				float num6 = scaleOverTimeCurve.Evaluate(num5);
				val = Vector3.Scale(val, Vector3.one * num6);
			}
		}
		val.x = Mathf.Clamp(val.x, minScale.x, maxScale.x);
		val.y = Mathf.Clamp(val.y, minScale.y, maxScale.y);
		val.z = Mathf.Clamp(val.z, minScale.z, maxScale.z);
		((Component)this).transform.localScale = val;
	}

	public void SetProjectileData(Vector3 startPos, Vector3 endPos, bool hit)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: 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_000a: 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)
		startPosition = startPos;
		hitPosition = endPos;
		projectileHit = hit;
		((Component)this).transform.position = startPos;
	}
}
public class PlasmaVisualLogic : MonoBehaviour
{
	[Header("Plasma System Reference")]
	[Tooltip("Assign the specific PlasmaEnergySystem this UI should display")]
	public PlasmaEnergySystem plasmaEnergySystem;

	[Header("UI Components")]
	public TextMeshProUGUI energyText;

	public TextMeshPro energyText3D;

	public Image energyBar;

	public GameObject energyContainer;

	[Header("Visual Settings")]
	public bool usePercentage = true;

	public bool showDecimalPlaces = true;

	public int decimalPlaces = 1;

	public bool showEnergyBar = true;

	[Header("Colors")]
	public Color normalColor = Color.white;

	public Color regeneratingColor = Color.green;

	public Color lowEnergyColor = Color.red;

	public Color depletedColor = Color.red;

	[Header("Animation Settings")]
	public bool animateText = true;

	public float textAnimationSpeed = 2f;

	public bool pulseWhenRegenerating = true;

	public float pulseSpeed = 3f;

	public float pulseIntensity = 0.3f;

	[Header("Low Energy Warning")]
	[Range(0f, 50f)]
	public float lowEnergyThreshold = 25f;

	public bool blinkWhenLow = true;

	public float blinkSpeed = 2f;

	[Header("Critical Energy Warning")]
	public Color criticalColor = Color.red;

	public bool flashWhenCritical = true;

	public float criticalFlashSpeed = 5f;

	public float criticalFlashIntensity = 0.8f;

	public bool showCriticalWarning = true;

	public string criticalWarningText = "CRITICAL";

	public float criticalWarningDuration = 2f;

	public bool scalePulseWhenCritical = true;

	public float criticalScalePulse = 1.3f;

	[Header("World Space Settings")]
	public bool faceCamera = true;

	public bool scaleWithDistance = true;

	public float baseScale = 1f;

	public float maxScale = 3f;

	public float scaleDistance = 10f;

	private PlasmaEnergySystem energySystem;

	private Camera mainCamera;

	private float currentDisplayedEnergy;

	private float targetEnergy;

	private bool isRegenerating;

	private float animationTimer;

	private Color baseColor;

	private Vector3 originalScale;

	private bool isBlinking;

	private float blinkTimer;

	private bool isPulsing;

	private float pulseTimer;

	private bool isInCriticalState;

	private bool isCriticalFlashing;

	private float criticalFlashTimer;

	private bool isCriticalScaling;

	private float criticalScaleTimer;

	private string originalEnergyText;

	private float criticalWarningTimer;

	private bool showingCriticalWarning;

	private void Awake()
	{
		//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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		mainCamera = Camera.main;
		energySystem = plasmaEnergySystem;
		if ((Object)(object)energySystem == (Object)null)
		{
			Debug.LogError((object)"PlasmaVisualLogic: No PlasmaEnergySystem assigned! Please assign one in the inspector.");
			return;
		}
		originalScale = ((Component)this).transform.localScale;
		baseColor = GetCurrentTextColor();
		energySystem.OnEnergyChanged.AddListener((UnityAction<float>)OnEnergyChanged);
		energySystem.OnRegenerationStateChanged.AddListener((UnityAction<bool>)OnRegenerationStateChanged);
		energySystem.OnEnergyDepleted.AddListener(new UnityAction(OnEnergyDepleted));
	}

	private void Start()
	{
		currentDisplayedEnergy = energySystem.CurrentEnergyPercentage;
		targetEnergy = currentDisplayedEnergy;
		UpdateEnergyDisplay();
		if ((Object)(object)energyContainer != (Object)null)
		{
			energyContainer.SetActive(true);
		}
	}

	private void Update()
	{
		HandleWorldSpaceSettings();
		HandleTextAnimation();
		HandleVisualEffects();
	}

	private void HandleWorldSpaceSettings()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		if (faceCamera && !((Object)(object)mainCamera == (Object)null))
		{
			((Component)this).transform.LookAt(((Component)mainCamera).transform);
			((Component)this).transform.Rotate(0f, 180f, 0f);
			if (scaleWithDistance)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)mainCamera).transform.position);
				float num2 = Mathf.Lerp(baseScale, maxScale, num / scaleDistance);
				num2 = Mathf.Clamp(num2, baseScale, maxScale);
				((Component)this).transform.localScale = originalScale * num2;
			}
		}
	}

	private void HandleTextAnimation()
	{
		if (animateText)
		{
			if (Mathf.Abs(currentDisplayedEnergy - targetEnergy) > 0.1f)
			{
				currentDisplayedEnergy = Mathf.Lerp(currentDisplayedEnergy, targetEnergy, textAnimationSpeed * Time.deltaTime);
				UpdateEnergyDisplay();
			}
			else if (currentDisplayedEnergy != targetEnergy)
			{
				currentDisplayedEnergy = targetEnergy;
				UpdateEnergyDisplay();
			}
		}
	}

	private void HandleVisualEffects()
	{
		//IL_0050: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		HandleCriticalEnergyState();
		if (isInCriticalState && showingCriticalWarning)
		{
			criticalWarningTimer += Time.deltaTime;
			if (criticalWarningTimer >= criticalWarningDuration)
			{
				showingCriticalWarning = false;
			}
		}
		Color textColor = normalColor;
		if (isInCriticalState)
		{
			textColor = criticalColor;
			if (flashWhenCritical)
			{
				HandleCriticalFlashEffect();
			}
			if (scalePulseWhenCritical)
			{
				HandleCriticalScaleEffect();
			}
		}
		else if (isRegenerating)
		{
			textColor = regeneratingColor;
			if (pulseWhenRegenerating)
			{
				HandlePulseEffect();
			}
		}
		else if (currentDisplayedEnergy <= 0f)
		{
			textColor = depletedColor;
		}
		else if (currentDisplayedEnergy <= lowEnergyThreshold)
		{
			textColor = lowEnergyColor;
			if (blinkWhenLow)
			{
				HandleBlinkEffect();
			}
		}
		if (!isPulsing && !isBlinking && !isCriticalFlashing)
		{
			SetTextColor(textColor);
		}
	}

	private void HandlePulseEffect()
	{
		//IL_0042: 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_0059: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		if (isPulsing)
		{
			pulseTimer += Time.deltaTime * pulseSpeed;
			float num = (Mathf.Sin(pulseTimer) + 1f) * 0.5f;
			Color textColor = Color.Lerp(regeneratingColor, regeneratingColor * (1f + pulseIntensity), num);
			SetTextColor(textColor);
		}
	}

	private void HandleBlinkEffect()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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)
		if (isBlinking)
		{
			blinkTimer += Time.deltaTime * blinkSpeed;
			Color textColor = ((Mathf.Sin(blinkTimer) > 0f) ? lowEnergyColor : Color.clear);
			SetTextColor(textColor);
		}
	}

	private void HandleCriticalEnergyState()
	{
		if ((Object)(object)energySystem == (Object)null)
		{
			return;
		}
		bool flag = energySystem.IsInCriticalState;
		if (flag != isInCriticalState)
		{
			isInCriticalState = flag;
			if (isInCriticalState)
			{
				EnterCriticalState();
			}
			else
			{
				ExitCriticalState();
			}
		}
	}

	private void EnterCriticalState()
	{
		isCriticalFlashing = flashWhenCritical;
		isCriticalScaling = scalePulseWhenCritical;
		criticalFlashTimer = 0f;
		criticalScaleTimer = 0f;
		criticalWarningTimer = 0f;
		showingCriticalWarning = showCriticalWarning;
		if (showCriticalWarning)
		{
			originalEnergyText = FormatEnergyText(currentDisplayedEnergy);
		}
	}

	private void ExitCriticalState()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		isCriticalFlashing = false;
		isCriticalScaling = false;
		if (scalePulseWhenCritical)
		{
			((Component)this).transform.localScale = originalScale;
		}
	}

	private void HandleCriticalFlashEffect()
	{
		//IL_0042: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if (isCriticalFlashing)
		{
			criticalFlashTimer += Time.deltaTime * criticalFlashSpeed;
			float num = (Mathf.Sin(criticalFlashTimer) + 1f) * 0.5f;
			Color val = criticalColor * (1f + criticalFlashIntensity);
			Color textColor = Color.Lerp(criticalColor, val, num);
			SetTextColor(textColor);
		}
	}

	private void HandleCriticalScaleEffect()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		if (isCriticalScaling)
		{
			criticalScaleTimer += Time.deltaTime * criticalFlashSpeed;
			float num = (Mathf.Sin(criticalScaleTimer) + 1f) * 0.5f;
			float num2 = Mathf.Lerp(1f, criticalScalePulse, num);
			((Component)this).transform.localScale = originalScale * num2;
		}
	}

	private void OnEnergyChanged(float energyPercentage)
	{
		targetEnergy = energyPercentage;
		if (!animateText)
		{
			currentDisplayedEnergy = targetEnergy;
			UpdateEnergyDisplay();
		}
	}

	private void OnRegenerationStateChanged(bool regenerating)
	{
		isRegenerating = regenerating;
		isPulsing = regenerating && pulseWhenRegenerating;
		if (isPulsing)
		{
			pulseTimer = 0f;
		}
	}

	private void OnEnergyDepleted()
	{
		if (!((Object)(object)energyContainer != (Object)null))
		{
		}
	}

	private void UpdateEnergyDisplay()
	{
		string text = ((!isInCriticalState || !showingCriticalWarning) ? FormatEnergyText(currentDisplayedEnergy) : criticalWarningText);
		if ((Object)(object)energyText != (Object)null)
		{
			((TMP_Text)energyText).text = text;
		}
		if ((Object)(object)energyText3D != (Object)null)
		{
			((TMP_Text)energyText3D).text = text;
		}
		if ((Object)(object)energyBar != (Object)null && showEnergyBar)
		{
			energyBar.fillAmount = currentDisplayedEnergy / 100f;
		}
		bool flag = currentDisplayedEnergy <= lowEnergyThreshold && currentDisplayedEnergy > 0f && !isRegenerating && !isInCriticalState && blinkWhenLow;
		if (flag != isBlinking)
		{
			isBlinking = flag;
			blinkTimer = 0f;
		}
	}

	private string FormatEnergyText(float energy)
	{
		if (usePercentage)
		{
			if (showDecimalPlaces)
			{
				return energy.ToString($"F{decimalPlaces}") + "%";
			}
			return Mathf.RoundToInt(energy) + "%";
		}
		float num = energy / 100f * energySystem.maxEnergy;
		if (showDecimalPlaces)
		{
			return num.ToString($"F{decimalPlaces}");
		}
		return Mathf.RoundToInt(num).ToString();
	}

	private Color GetCurrentTextColor()
	{
		//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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0047: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)energyText != (Object)null)
		{
			return ((Graphic)energyText).color;
		}
		if ((Object)(object)energyText3D != (Object)null)
		{
			return ((Graphic)energyText3D).color;
		}
		return Color.white;
	}

	private void SetTextColor(Color color)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)energyText != (Object)null)
		{
			((Graphic)energyText).color = color;
		}
		if ((Object)(object)energyText3D != (Object)null)
		{
			((Graphic)energyText3D).color = color;
		}
		if ((Object)(object)energyBar != (Object)null)
		{
			((Graphic)energyBar).color = color;
		}
	}

	public void Show()
	{
		if ((Object)(object)energyContainer != (Object)null)
		{
			energyContainer.SetActive(true);
		}
	}

	public void Hide()
	{
		if ((Object)(object)energyContainer != (Object)null)
		{
			energyContainer.SetActive(false);
		}
	}

	public void SetVisibility(bool visible)
	{
		if (visible)
		{
			Show();
		}
		else
		{
			Hide();
		}
	}

	public void OverrideShowTime(float time)
	{
		Show();
		if (time > 0f)
		{
			((MonoBehaviour)this).Invoke("Hide", time);
		}
	}

	private void OnDestroy()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		if ((Object)(object)energySystem != (Object)null)
		{
			energySystem.OnEnergyChanged.RemoveListener((UnityAction<float>)OnEnergyChanged);
			energySystem.OnRegenerationStateChanged.RemoveListener((UnityAction<bool>)OnRegenerationStateChanged);
			energySystem.OnEnergyDepleted.RemoveListener(new UnityAction(OnEnergyDepleted));
		}
	}

	[ContextMenu("Test Low Energy")]
	private void TestLowEnergy()
	{
		OnEnergyChanged(15f);
	}

	[ContextMenu("Test Critical Energy")]
	private void TestCriticalEnergy()
	{
		isInCriticalState = true;
		EnterCriticalState();
		OnEnergyChanged(5f);
	}

	[ContextMenu("Test Regeneration")]
	private void TestRegeneration()
	{
		OnRegenerationStateChanged(regenerating: true);
	}

	[ContextMenu("Test Normal")]
	private void TestNormal()
	{
		OnEnergyChanged(75f);
		OnRegenerationStateChanged(regenerating: false);
		isInCriticalState = false;
		ExitCriticalState();
	}
}
namespace PlasmaGunAPI
{
	[BepInPlugin("Rosay.PlasmaGunAPI", "PlasmaGunAPI", "1.0")]
	public class PlasmaGunAPI : BaseUnityPlugin
	{
		internal static PlasmaGunAPI 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)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

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

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

		private void Update()
		{
		}
	}
}