Decompiled source of Wicked v1.1.3

plugins/Wicked/QwertyRodrigo.Wicked.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using QwertyRodrigo.Wicked.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using Wicked.Configuration;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("QwertyRodrigo.Wicked")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3+fb29796531a9dd5d2604682879d1e40005b37d7d")]
[assembly: AssemblyProduct("Wicked")]
[assembly: AssemblyTitle("QwertyRodrigo.Wicked")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 SkullrItem : GrabbableObject
{
	public ParticleSystem PoofParticle;

	public AudioSource presentAudio;

	public AudioClip useSkullrAudio;

	private PlayerControllerB previousPlayerHeldBy;

	private bool hasUsedSkullr;

	private bool loadedItemFromSave;

	private Light itemLight;

	public override void LoadItemSaveData(int saveData)
	{
		((GrabbableObject)this).LoadItemSaveData(saveData);
		loadedItemFromSave = true;
	}

	public override int GetItemDataToSave()
	{
		((GrabbableObject)this).GetItemDataToSave();
		return 0;
	}

	public override void Start()
	{
		((GrabbableObject)this).Start();
		itemLight = ((Component)this).GetComponentInChildren<Light>();
		if (!loadedItemFromSave)
		{
			_ = ((NetworkBehaviour)this).IsServer;
		}
	}

	public override void EquipItem()
	{
		((GrabbableObject)this).EquipItem();
		previousPlayerHeldBy = base.playerHeldBy;
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		if ((Object)(object)base.playerHeldBy != (Object)null && !hasUsedSkullr)
		{
			hasUsedSkullr = true;
			base.playerHeldBy.activatingItem = true;
			UseSkullrServerRpc();
		}
	}

	public override void PocketItem()
	{
		((GrabbableObject)this).PocketItem();
		if ((Object)(object)base.playerHeldBy != (Object)null)
		{
			base.playerHeldBy.activatingItem = false;
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void UseSkullrServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(628309643u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 628309643u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
		{
			return;
		}
		Vector3 randomAiNodePosition = GetRandomAiNodePosition();
		if (randomAiNodePosition != Vector3.zero)
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				((Component)base.playerHeldBy).transform.position = randomAiNodePosition;
				UseSkullrClientRpc(randomAiNodePosition);
			}
		}
		else
		{
			Debug.LogError((object)"Error: No AiNode found!");
			UseSkullrNoNodeClientRpc();
		}
	}

	private Vector3 GetRandomAiNodePosition()
	{
		//IL_000f: 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_00c4: 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_00ac: 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)
		//IL_0060: 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)
		GameObject[] array = GameObject.FindGameObjectsWithTag("AINode");
		if (array.Length == 0)
		{
			return Vector3.zero;
		}
		float num = 5f;
		List<Vector3> list = new List<Vector3>();
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			bool flag = true;
			GameObject[] array3 = array;
			foreach (GameObject val2 in array3)
			{
				if ((Object)(object)val != (Object)(object)val2 && Vector3.Distance(val.transform.position, val2.transform.position) < num)
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				list.Add(val.transform.position);
			}
		}
		if (list.Count == 0)
		{
			return Vector3.zero;
		}
		return list[Random.Range(0, list.Count)];
	}

	[ClientRpc]
	public void UseSkullrNoNodeClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(968120344u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 968120344u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			Debug.Log((object)"UseSkullrNoNodeClientRpc called");
			if ((Object)(object)PoofParticle != (Object)null)
			{
				PoofParticle.Play();
			}
			if ((Object)(object)presentAudio != (Object)null && (Object)(object)useSkullrAudio != (Object)null)
			{
				presentAudio.PlayOneShot(useSkullrAudio);
				WalkieTalkie.TransmitOneShotAudio(presentAudio, useSkullrAudio, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)presentAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
				DestroyObjectInHand(base.playerHeldBy);
			}
		}
	}

	[ClientRpc]
	public void UseSkullrClientRpc(Vector3 targetPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4246424339u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetPosition);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4246424339u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			Vector3 val3 = targetPosition;
			Debug.Log((object)("UseSkullrClientRpc called with targetPosition: " + ((object)(Vector3)(ref val3)).ToString()));
			if ((Object)(object)PoofParticle != (Object)null)
			{
				PoofParticle.Play();
			}
			if ((Object)(object)presentAudio != (Object)null && (Object)(object)useSkullrAudio != (Object)null)
			{
				presentAudio.PlayOneShot(useSkullrAudio);
				WalkieTalkie.TransmitOneShotAudio(presentAudio, useSkullrAudio, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)presentAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
				DestroyObjectInHand(base.playerHeldBy);
				((Component)base.playerHeldBy).transform.position = targetPosition;
			}
		}
	}

	private void DestroyObjectInHand(PlayerControllerB player)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		if (!((Object)(object)player != (Object)null))
		{
			return;
		}
		foreach (Transform item in ((Component)this).transform)
		{
			Transform val = item;
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_SkullrItem()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(628309643u, new RpcReceiveHandler(__rpc_handler_628309643));
		NetworkManager.__rpc_func_table.Add(968120344u, new RpcReceiveHandler(__rpc_handler_968120344));
		NetworkManager.__rpc_func_table.Add(4246424339u, new RpcReceiveHandler(__rpc_handler_4246424339));
	}

	private static void __rpc_handler_628309643(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((SkullrItem)(object)target).UseSkullrServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_968120344(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((SkullrItem)(object)target).UseSkullrNoNodeClientRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4246424339(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			Vector3 targetPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref targetPosition);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((SkullrItem)(object)target).UseSkullrClientRpc(targetPosition);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "SkullrItem";
	}
}
namespace Wicked
{
	[BepInPlugin("QwertyRodrigo.Wicked", "Wicked", "1.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? wickedassets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "wickedassets";
			wickedassets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)wickedassets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = wickedassets.LoadAsset<EnemyType>("Wicked");
			TerminalNode val2 = wickedassets.LoadAsset<TerminalNode>("WickedTN");
			TerminalKeyword val3 = wickedassets.LoadAsset<TerminalKeyword>("WickedTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, (TerminalKeyword)null);
			Item val4 = wickedassets.LoadAsset<Item>("skullbObj");
			Utilities.FixMixerGroups(val4.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Items.RegisterScrap(val4, BoundConfig.BlueSkullSpawnWeight.Value, (LevelTypes)(-1));
			Item val5 = wickedassets.LoadAsset<Item>("skullrObj");
			Utilities.FixMixerGroups(val5.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Items.RegisterScrap(val5, BoundConfig.RedSkullSpawnWeight.Value, (LevelTypes)(-1));
			Logger.LogInfo((object)$"Registering Wicked with spawn weight of {BoundConfig.SpawnWeight.Value}");
			Logger.LogInfo((object)$"Registering Red Skull with spawn weight of {BoundConfig.RedSkullSpawnWeight.Value}");
			Logger.LogInfo((object)$"Registering Blue Skull with spawn weight of {BoundConfig.BlueSkullSpawnWeight.Value}");
			Logger.LogInfo((object)"Plugin QwertyRodrigo.Wicked is loaded!!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	internal class WickedAI : EnemyAI
	{
		public Transform turnCompass;

		private float timeSinceHittingLocalPlayer;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		private NavMeshAgent agent;

		public AudioClip HitSFX;

		public AudioClip SpawnSFX;

		public AudioClip NearPlayerSFX;

		public AudioClip WeezerHitSFX;

		public AudioClip WeezerSpawnSFX;

		public AudioClip WeezerNearPlayerSFX;

		public AudioClip weezerhum;

		public AudioSource humsource;

		private bool hasPlayedNearPlayerSound;

		public Material wickedmaterial;

		public Material weezermaterial;

		public SkinnedMeshRenderer mesh;

		private Vector3 lastPosition;

		private float inactivityTimer;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			((Renderer)mesh).material = (Plugin.BoundConfig.Weezer.Value ? weezermaterial : wickedmaterial);
			if (Plugin.BoundConfig.Weezer.Value)
			{
				humsource.clip = weezerhum;
			}
			humsource.Play();
			HUDManager.Instance.DisplayTip(Plugin.BoundConfig.Weezer.Value ? "Something Weezer this way comes..." : "Something Wicked this way comes...", "", false, false, "LC_Tip1");
			base.creatureSFX.PlayOneShot(Plugin.BoundConfig.Weezer.Value ? WeezerSpawnSFX : SpawnSFX, 1f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			lastPosition = ((Component)this).transform.position;
			inactivityTimer = 0f;
		}

		public override void Update()
		{
			//IL_004a: 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_0070: 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_0084: 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)
			((EnemyAI)this).Update();
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.targetPlayer)
				{
					WickedSeePlayerEffect();
				}
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
				if (!hasPlayedNearPlayerSound && IsNearPlayer())
				{
					base.creatureSFX.PlayOneShot(Plugin.BoundConfig.Weezer.Value ? WeezerNearPlayerSFX : NearPlayerSFX, 1f);
					hasPlayedNearPlayerSound = true;
				}
			}
			else
			{
				hasPlayedNearPlayerSound = false;
			}
			if (base.stunNormalizedTimer > 0f)
			{
				agent.speed = 0f;
			}
			else
			{
				agent.speed = Plugin.BoundConfig.Speed.Value;
				FollowPlayer();
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			CheckInactivity();
		}

		private void CheckInactivity()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (Vector3.Distance(((Component)this).transform.position, lastPosition) < 0.01f)
			{
				inactivityTimer += Time.deltaTime;
				if (inactivityTimer >= 3f)
				{
					TeleportEnemy();
					inactivityTimer = 0f;
				}
			}
			else
			{
				inactivityTimer = 0f;
				lastPosition = ((Component)this).transform.position;
			}
		}

		private void FollowPlayer()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				FindClosestPlayer();
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
			}
		}

		private void FindClosestPlayer()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (num2 < num)
				{
					num = num2;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0043: 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)
			if (!(timeSinceHittingLocalPlayer < 1f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(Plugin.BoundConfig.Damage.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					base.creatureSFX.PlayOneShot(Plugin.BoundConfig.Weezer.Value ? WeezerHitSFX : HitSFX, 1f);
					TeleportEnemy();
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			base.creatureSFX.PlayOneShot(Plugin.BoundConfig.Weezer.Value ? WeezerHitSFX : HitSFX, 1f);
			TeleportEnemy();
		}

		private void TeleportEnemy()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			Vector3 randomAINodePosition = GetRandomAINodePosition();
			if (randomAINodePosition != Vector3.zero)
			{
				((Component)this).transform.position = randomAINodePosition;
				agent.Warp(randomAINodePosition);
				hasPlayedNearPlayerSound = false;
			}
		}

		private Vector3 GetRandomAINodePosition()
		{
			//IL_000f: 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_00c4: 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_00ac: 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)
			//IL_0060: 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)
			GameObject[] array = GameObject.FindGameObjectsWithTag("AINode");
			if (array.Length == 0)
			{
				return Vector3.zero;
			}
			float num = 5f;
			List<Vector3> list = new List<Vector3>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				bool flag = true;
				GameObject[] array3 = array;
				foreach (GameObject val2 in array3)
				{
					if ((Object)(object)val != (Object)(object)val2 && Vector3.Distance(val.transform.position, val2.transform.position) < num)
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					list.Add(val.transform.position);
				}
			}
			if (list.Count == 0)
			{
				return Vector3.zero;
			}
			return list[Random.Range(0, list.Count)];
		}

		private bool IsNearPlayer()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
			return num <= 10f;
		}

		[ClientRpc]
		private void DoAnimationClientRpc(string triggerName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2564535240u, val, (RpcDelivery)0);
				bool flag = triggerName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(triggerName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2564535240u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(triggerName);
			}
		}

		public void WickedSeePlayerEffect()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead && !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)
			{
				if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 15f)
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0f, true);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_WickedAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2564535240u, new RpcReceiveHandler(__rpc_handler_2564535240));
		}

		private static void __rpc_handler_2564535240(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string triggerName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WickedAI)(object)target).DoAnimationClientRpc(triggerName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "WickedAI";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "QwertyRodrigo.Wicked";

		public const string PLUGIN_NAME = "Wicked";

		public const string PLUGIN_VERSION = "1.1.3";
	}
}
namespace Wicked.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public ConfigEntry<int> Damage;

		public ConfigEntry<int> Speed;

		public ConfigEntry<int> RedSkullSpawnWeight;

		public ConfigEntry<int> BlueSkullSpawnWeight;

		public ConfigEntry<bool> Weezer;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 3, "The spawn chance weight for Something Wicked, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.\nA low rarity is recommended, he is a handful");
			Damage = cfg.Bind<int>("General", "Damage", 90, "The damage that Something Wicked does when he bites your ankles\nThe player has 100 health, 50 in the config is half of your health on hit");
			Speed = cfg.Bind<int>("General", "Speed", 8, "The speed at which Something Wicked will run\nLower and he will be a slow boi, any higher and pray to god");
			RedSkullSpawnWeight = cfg.Bind<int>("General", "Red Skull Spawn weight", 5, "The spawn chance weight for the Red Skull scrap item.\nGoes up from 0, lower is more rare, 100 and up is very common.\n");
			BlueSkullSpawnWeight = cfg.Bind<int>("General", "Blue Skull Spawn weight", 5, "The spawn chance weight for the Blue Skull scrap item.\nGoes up from 0, lower is more rare, 100 and up is very common.\n");
			Weezer = cfg.Bind<bool>("General", "Weezer?", false, "");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace QwertyRodrigo.Wicked.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}