Decompiled source of ShibaBatInu v0.0.6

ReavsStuff.ShibaEnemy.dll

Decompiled a month ago
#define DEBUG
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 HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using ReavsStuff.ShibaEnemy.NetcodePatcher;
using ShibaEnemy.Configuration;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.VFX;

[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: AssemblyCompany("ReavsStuff.ShibaEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.6.0")]
[assembly: AssemblyInformationalVersion("0.0.6")]
[assembly: AssemblyProduct("ShibaEnemy")]
[assembly: AssemblyTitle("ReavsStuff.ShibaEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.6.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;
		}
	}
}
namespace ShibaEnemy
{
	[BepInPlugin("ReavsStuff.ShibaEnemy", "ShibaEnemy", "0.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		private readonly Harmony _harmony = new Harmony("ShibaEnemy");

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			string path = "ShibaBatInu";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("ShibaEnemy");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("ShibaEnemyTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("ShibaEnemyTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			InitializeNetworkBehaviours();
			Logger.LogInfo((object)"Plugin ReavsStuff.ShibaEnemy 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);
					}
				}
			}
		}
	}
	public class ShibaEnemyAI : EnemyAI
	{
		public enum State
		{
			RoamSearch,
			Chasing,
			Attacking,
			AttackingSpecial,
			PostSpecial,
			Death
		}

		private AISearchRoutine searchForPlayers;

		private float attackFuncTimer;

		private Vector3 lastPositionOfSeenPlayer;

		private bool lostPlayerInChase;

		private float lostPlayerInChaseTimer;

		private float timeSinceHittingLocalPlayer;

		private bool attackAudioClipTrue;

		[Header("Audio Stuff")]
		public AudioClip AudioClipRoaming;

		public AudioClip AudioClipChasing;

		public AudioClip AudioClipAttacking;

		public AudioClip AudioClipSpecialAttacking;

		public AudioClip AudioClipSlideSFX;

		private bool fadeOutSpecialSFX = false;

		private bool disableFootstepSFX = false;

		public float currentPitchTime = 0f;

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public Transform specialAttackArea = null;

		private int observedState = -1;

		public bool canAttack = false;

		public bool attackingDone = true;

		public bool attackTriggerBool = false;

		private bool attackingPlayer;

		private float shibaVolume;

		private float shibaRoamSpeed;

		private float shibaChaseSpeed;

		private int shibaDamage;

		private int shibaHealth;

		private float currentClipLength;

		private float maxClipLength;

		private int specialAttackChanceValue;

		private bool setSpecialAttackChance;

		private bool SpecialAttackEngaged = false;

		public int specialAttackChance = 5;

		private bool specialPostDone = false;

		private int specialAttackCurrentHits;

		private int specialAttackMaxHits = 8;

		public VisualEffect visualEffect;

		private static VFXExposedProperty specialVFXBeginTrigger;

		private static VFXExposedProperty specialVFXEndTrigger;

		private static readonly string specialVFXBeginTriggerName = "StartSpecial";

		private static readonly string specialVFXEndTriggerName = "StopSpecial";

		private List<ulong> hitPlayers = new List<ulong>();

		public bool allowCollisionDamage = false;

		private bool slideAfterAttack = false;

		private bool sliderAfterDis = false;

		private Ray ray;

		private RaycastHit rayHit;

		private RoundManager roundManager;

		public static ShibaEnemyAI? AiInstance { get; private set; }

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

		public override void Start()
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			((EnemyAI)this).Start();
			AiInstance = this;
			LogIfDebugBuild("Shiba Spawned");
			DoAnimationClientRpc("RoamSearch");
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			shibaVolume = PluginConfig.ShibaVolumeAdjustment.Value;
			shibaRoamSpeed = PluginConfig.ShibaRoamSpeed.Value;
			shibaChaseSpeed = PluginConfig.ShibaChaseSpeed.Value;
			shibaDamage = PluginConfig.ShibaDamage.Value;
			shibaHealth = PluginConfig.ShibaHealth.Value;
			specialAttackChance = PluginConfig.ShibaSpecialAttackChance.Value;
			base.enemyHP = shibaHealth;
			timeSinceHittingLocalPlayer = 0f;
			roundManager = Object.FindObjectOfType<RoundManager>();
			base.agent.angularSpeed = 200f;
			base.agent.stoppingDistance = 0.1f;
			base.openDoorSpeedMultiplier = 50f;
			specialVFXBeginTrigger.name = specialVFXBeginTriggerName;
			specialVFXEndTrigger.name = specialVFXEndTriggerName;
			searchForPlayers = new AISearchRoutine();
			if (base.creatureVoice.isPlaying)
			{
				maxClipLength = base.creatureVoice.clip.length;
			}
		}

		public void StartAnimVFX()
		{
			visualEffect.SendEvent(specialVFXBeginTrigger.name);
		}

		public void EndAnimVFX()
		{
			visualEffect.SendEvent(specialVFXBeginTrigger.name);
		}

		private void ObserveState()
		{
			if (observedState != base.currentBehaviourStateIndex)
			{
				attackFuncTimer = 0f;
				disableFootstepSFX = false;
				base.creatureVoice.Stop();
				hitPlayers.Clear();
				base.creatureVoice.volume = shibaVolume;
				base.creatureSFX.volume = shibaVolume;
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					setSpecialAttackChance = false;
					base.addPlayerVelocityToDestination = 0f;
					base.creatureVoice.clip = AudioClipRoaming;
					base.creatureVoice.loop = true;
					base.creatureVoice.Play();
					base.creatureSFX.Stop();
					base.agent.speed = shibaRoamSpeed;
					DoAnimationClientRpc("RoamSearch");
					break;
				case 1:
					base.addPlayerVelocityToDestination = 1f;
					base.creatureVoice.clip = AudioClipChasing;
					base.creatureVoice.loop = true;
					base.creatureVoice.Play();
					attackingPlayer = false;
					attackingDone = false;
					base.agent.speed = shibaChaseSpeed;
					slideAfterAttack = false;
					sliderAfterDis = false;
					DoAnimationClientRpc("Chasing");
					break;
				case 2:
					disableFootstepSFX = true;
					fadeOutSpecialSFX = false;
					attackAudioClipTrue = true;
					base.addPlayerVelocityToDestination = 1f;
					setSpecialAttackChance = false;
					allowCollisionDamage = true;
					attackingDone = false;
					specialPostDone = false;
					base.creatureSFX.Stop();
					base.creatureSFX.volume = 0.25f;
					base.creatureSFX.clip = AudioClipSlideSFX;
					base.creatureSFX.pitch = Random.Range(1.5f, 1.6f);
					base.agent.speed = 8f;
					DoAnimationClientRpc("Attacking");
					break;
				case 3:
					disableFootstepSFX = true;
					attackAudioClipTrue = true;
					fadeOutSpecialSFX = false;
					base.addPlayerVelocityToDestination = 1f;
					base.creatureVoice.loop = false;
					base.creatureSFX.Stop();
					base.creatureSFX.clip = AudioClipSpecialAttacking;
					allowCollisionDamage = true;
					attackingDone = false;
					specialPostDone = false;
					base.agent.speed = 12f;
					DoAnimationClientRpc("AttackingSpecial");
					break;
				case 4:
					disableFootstepSFX = true;
					fadeOutSpecialSFX = true;
					base.addPlayerVelocityToDestination = 0f;
					setSpecialAttackChance = false;
					allowCollisionDamage = false;
					attackingDone = true;
					base.agent.speed = 0f;
					DoAnimationClientRpc("PostSpecial");
					break;
				}
				observedState = base.currentBehaviourStateIndex;
			}
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead && base.currentBehaviourStateIndex == 0)
			{
			}
		}

		private bool FoundTargetablePlayer()
		{
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(120f, 40, 10, 5f);
			if ((Object)(object)val != (Object)null)
			{
				base.targetPlayer = StartOfRound.Instance.allPlayerScripts[val.actualClientId];
				return true;
			}
			return false;
		}

		private bool FindNewTargetablePlayer()
		{
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(60f, 40, 10, 5f);
			if ((Object)(object)val != (Object)null)
			{
				base.targetPlayer = StartOfRound.Instance.allPlayerScripts[val.actualClientId];
				return true;
			}
			return false;
		}

		private bool FoundCloserTargetablePlayer(float differenceDistance)
		{
			//IL_0051: 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_0073: 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)
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(120f, 40, 10, 5f);
			if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)base.targetPlayer && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) - differenceDistance > Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position))
			{
				base.targetPlayer = StartOfRound.Instance.allPlayerScripts[val.actualClientId];
				return true;
			}
			return false;
		}

		private bool NoPlayerVisible()
		{
			PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(true, false, false);
			if ((Object)(object)closestPlayer == (Object)null)
			{
				return true;
			}
			return false;
		}

		public override void Update()
		{
			//IL_0050: 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_009e: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if ((!slideAfterAttack || !sliderAfterDis) && (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) < 5f && (base.currentBehaviourStateIndex == 1 || base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 3))
			{
				LookAtTarget(((Component)base.targetPlayer).transform.position);
			}
			HandleBehaviourStates();
			ObserveState();
			currentClipLength += Time.deltaTime;
			ClipPitch();
			if (timeSinceHittingLocalPlayer > 0f)
			{
				attackAudioClipTrue = true;
				timeSinceHittingLocalPlayer -= Time.deltaTime;
			}
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.25f, 50f, 25, 5f))
			{
				if (base.currentBehaviourStateIndex == 1 || base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 3)
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(1f, 1f);
				}
				else if ((Object)(object)base.targetPlayer != (Object)null)
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(0.8f, 0.25f);
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(0.8f, 0f);
				}
			}
		}

		private void HandleBehaviourStates()
		{
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				DoRoamState();
				break;
			case 1:
				DoChaseState();
				break;
			case 2:
				DoAttackState();
				break;
			case 3:
				DoAttackSpecialState();
				break;
			case 4:
				DoPostSpecialState();
				break;
			}
		}

		private void DoRoamState()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!searchForPlayers.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
			}
			if (FoundTargetablePlayer())
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}

		private void DoChaseState()
		{
			//IL_003a: 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_00bd: 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_0122: 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_026d: 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 (!attackingPlayer && (Object)(object)base.targetPlayer != (Object)null && !SpecialAttackEngaged)
			{
				if (!setSpecialAttackChance & (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 6f))
				{
					setSpecialAttackChance = true;
					specialAttackChanceValue = Random.Range(1, 100);
					if (specialAttackChanceValue <= specialAttackChance)
					{
						SpecialAttackEngaged = true;
						attackingPlayer = true;
						base.agent.speed = 10f;
						((EnemyAI)this).SwitchToBehaviourClientRpc(3);
					}
				}
				else if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 3f)
				{
					attackingPlayer = true;
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
			}
			if (lostPlayerInChase)
			{
				setSpecialAttackChance = false;
				if (!searchForPlayers.inProgress)
				{
					((EnemyAI)this).SetDestinationToPosition(lastPositionOfSeenPlayer, false);
					((EnemyAI)this).StartSearch(lastPositionOfSeenPlayer, searchForPlayers);
				}
				if (FindNewTargetablePlayer())
				{
					lostPlayerInChase = false;
					lostPlayerInChaseTimer = 0f;
					return;
				}
				lostPlayerInChaseTimer += base.AIIntervalTime;
				if (lostPlayerInChaseTimer >= 10f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				return;
			}
			if (searchForPlayers.inProgress && !lostPlayerInChase)
			{
				((EnemyAI)this).StopSearch(searchForPlayers, true);
			}
			if (FoundCloserTargetablePlayer(2.5f) && (Object)(object)base.targetPlayer != (Object)null)
			{
				lostPlayerInChaseTimer = 0f;
				return;
			}
			if (NoPlayerVisible())
			{
				lostPlayerInChaseTimer += Time.deltaTime;
				if (lostPlayerInChaseTimer > 2.5f)
				{
					lostPlayerInChase = true;
				}
			}
			if ((Object)(object)base.targetPlayer != (Object)null && !lostPlayerInChase)
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				lastPositionOfSeenPlayer = ((Component)base.targetPlayer).transform.position;
			}
		}

		private void DoAttackState()
		{
			//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_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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (attackingDone)
			{
				base.creatureSFX.volume = 0f;
				slideAfterAttack = false;
				sliderAfterDis = false;
				base.creatureSFX.Stop();
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			else if (!attackingDone)
			{
				if (slideAfterAttack)
				{
					ray = new Ray(((Component)this).transform.position + Vector3.up, ((Component)this).transform.forward);
					Vector3 val = ((!Physics.Raycast(ray, ref rayHit, 10f, StartOfRound.Instance.collidersAndRoomMask)) ? ((Ray)(ref ray)).GetPoint(10f) : ((RaycastHit)(ref rayHit)).point);
					val = roundManager.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
					((EnemyAI)this).SetDestinationToPosition(val, false);
					base.agent.speed = 6f;
					slideAfterAttack = false;
					sliderAfterDis = true;
					base.creatureSFX.Play();
				}
				else if (!sliderAfterDis)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				}
			}
			if (attackTriggerBool)
			{
				AttackProc();
				attackTriggerBool = false;
				allowCollisionDamage = false;
				base.agent.speed = 0f;
				slideAfterAttack = true;
			}
		}

		private void DoAttackSpecialState()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (attackFuncTimer >= 8f || specialAttackCurrentHits >= specialAttackMaxHits)
			{
				attackingDone = true;
				attackFuncTimer = 0f;
				SpecialAttackEngaged = false;
				attackingPlayer = false;
				specialAttackCurrentHits = 0;
				((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			}
			if (attackTriggerBool)
			{
				hitPlayers.Clear();
				allowCollisionDamage = true;
				AttackProcSpecial();
				allowCollisionDamage = false;
				attackTriggerBool = false;
			}
			if (!FoundCloserTargetablePlayer(1f))
			{
				if (!attackingDone)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				}
				attackFuncTimer += Time.deltaTime;
			}
		}

		private void DoPostSpecialState()
		{
			if (attackFuncTimer >= 3f)
			{
				attackFuncTimer = 0f;
				specialPostDone = true;
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			attackFuncTimer += Time.deltaTime;
		}

		public void AttackProcSpecial()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			int num = 8;
			Collider[] array = Physics.OverlapBox(specialAttackArea.position, specialAttackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				PlayerControllerB val2 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val, false, false);
				if ((Object)(object)val2 != (Object)null && !hitPlayers.Contains(val2.actualClientId))
				{
					val2.DamagePlayer(shibaDamage, false, true, (CauseOfDeath)1, 0, false, default(Vector3));
					if (attackAudioClipTrue)
					{
						base.creatureVoice.PlayOneShot(AudioClipAttacking, shibaVolume);
						attackAudioClipTrue = false;
					}
					base.agent.speed = base.agent.speed - 1f;
					specialAttackCurrentHits++;
					timeSinceHittingLocalPlayer += 0.2f;
					hitPlayers.Add(val2.actualClientId);
				}
			}
		}

		public void AttackProc()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				PlayerControllerB val2 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val, false, false);
				if ((Object)(object)val2 != (Object)null && !hitPlayers.Contains(val2.actualClientId))
				{
					val2.DamagePlayer(shibaDamage, false, true, (CauseOfDeath)1, 0, false, default(Vector3));
					if (attackAudioClipTrue)
					{
						base.creatureVoice.PlayOneShot(AudioClipAttacking, shibaVolume);
						attackAudioClipTrue = false;
					}
					hitPlayers.Add(val2.actualClientId);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0060: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!allowCollisionDamage)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null && !SpecialAttackEngaged && !hitPlayers.Contains(val.actualClientId))
			{
				val.DamagePlayer(shibaDamage, false, true, (CauseOfDeath)1, 0, false, default(Vector3));
				if (attackAudioClipTrue)
				{
					base.creatureVoice.PlayOneShot(AudioClipAttacking, shibaVolume);
					attackAudioClipTrue = false;
				}
				hitPlayers.Add(val.actualClientId);
			}
			else if ((Object)(object)val != (Object)null && SpecialAttackEngaged && !hitPlayers.Contains(val.actualClientId))
			{
				val.DamagePlayer(shibaDamage, false, true, (CauseOfDeath)1, 0, false, default(Vector3));
				if (attackAudioClipTrue)
				{
					base.creatureVoice.PlayOneShot(AudioClipAttacking, shibaVolume);
					attackAudioClipTrue = false;
				}
				specialAttackCurrentHits++;
				timeSinceHittingLocalPlayer += 0.2f;
				hitPlayers.Add(val.actualClientId);
			}
		}

		public void LookAtTarget(Vector3 target)
		{
			//IL_0001: 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_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.LookRotation(target - ((Component)this).transform.position);
			((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val, 300f * Time.deltaTime);
		}

		public void ClipPitch()
		{
			if (currentClipLength >= maxClipLength && base.creatureVoice.isPlaying)
			{
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					base.creatureVoice.pitch = Random.Range(0.85f, 1.15f);
					break;
				case 1:
					base.creatureVoice.pitch = Random.Range(0.8f, 1.3f);
					break;
				case 2:
					base.creatureVoice.pitch = Random.Range(0.9f, 1.1f);
					break;
				case 3:
					base.creatureVoice.pitch = Random.Range(0.85f, 1.2f);
					break;
				case 4:
					base.creatureVoice.pitch = Random.Range(0.95f, 1.4f);
					break;
				}
				maxClipLength = base.creatureVoice.clip.length;
				currentClipLength = 0f;
			}
			if (fadeOutSpecialSFX)
			{
				base.creatureSFX.volume = Mathf.Lerp(base.creatureSFX.volume, 0f, 2f);
			}
		}

		public override void FinishedCurrentSearchRoutine()
		{
			((EnemyAI)this).FinishedCurrentSearchRoutine();
		}

		public void AttackTriggerFunction()
		{
			attackTriggerBool = true;
		}

		public void AttackDoneAnimation()
		{
			attackingDone = true;
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (!base.isEnemyDead && !SpecialAttackEngaged)
			{
				((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
				base.enemyHP -= force;
				if (base.enemyHP <= 0 && !base.isEnemyDead && ((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			base.agent.speed = 0f;
			((EnemyAI)this).SwitchToBehaviourClientRpc(5);
			if (((NetworkBehaviour)this).IsServer)
			{
				base.creatureAnimator.SetTrigger("KillEnemy");
			}
		}

		public void Footsteps()
		{
			if (!disableFootstepSFX)
			{
				base.creatureSFX.pitch = Random.Range(0.85f, 1.15f);
				base.creatureSFX.PlayOneShot(base.enemyType.audioClips[0]);
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animName)
		{
			//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(926349753u, val, (RpcDelivery)0);
				bool flag = animName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 926349753u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animName);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ShibaEnemyAI()
		{
			//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(926349753u, new RpcReceiveHandler(__rpc_handler_926349753));
		}

		private static void __rpc_handler_926349753(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 animName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ShibaEnemyAI)(object)target).DoAnimationClientRpc(animName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ShibaEnemyAI";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ReavsStuff.ShibaEnemy";

		public const string PLUGIN_NAME = "ShibaEnemy";

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

		public static ConfigEntry<float> ShibaVolumeAdjustment;

		public static ConfigEntry<float> ShibaRoamSpeed;

		public static ConfigEntry<float> ShibaChaseSpeed;

		public static ConfigEntry<int> ShibaDamage;

		public static ConfigEntry<int> ShibaHealth;

		public static ConfigEntry<int> ShibaSpecialAttackChance;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for Shiba, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			CreateIntCfgEntry(SpawnWeight);
			ShibaVolumeAdjustment = cfg.Bind<float>("General", "Volume", 1f, "Adjust volume.\n1.0 = 100%, 0.0 = 0%");
			CreateFloatCfgEntry(ShibaVolumeAdjustment, 0f, 1.25f);
			ShibaDamage = cfg.Bind<int>("General", "Damage", 10, "How much damage the doggy does.\nMin: 5    Max: 15");
			CreateIntCfgEntry(ShibaDamage, 5, 15);
			ShibaHealth = cfg.Bind<int>("General", "Health", 4, "How much health the doggy has.\nMin: 2    Max: 6");
			CreateIntCfgEntry(ShibaHealth, 2, 6);
			ShibaSpecialAttackChance = cfg.Bind<int>("General", "Specialattack Chance", 5, "The chance for a special attack.\nMin: 2    Max: 15");
			CreateIntCfgEntry(ShibaSpecialAttackChance, 2, 15);
			ShibaRoamSpeed = cfg.Bind<float>("Speed Variables", "Roamspeed", 4f, "How fast the roam speed is.\nMin: 4     Max: 8");
			CreateFloatCfgEntry(ShibaRoamSpeed, 4f, 8f);
			ShibaChaseSpeed = cfg.Bind<float>("Speed Variables", "Chasespeed", 8f, "How fast the chase speed is.\nMin: 8     Max: 16");
			CreateFloatCfgEntry(ShibaChaseSpeed, 8f, 16f);
			ClearUnusedEntries(cfg);
		}

		private void CreateFloatCfgEntry(ConfigEntry<float> cfgEntry, float min = 0f, float max = 100f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)(object)val).Min = min;
			((BaseRangeOptions<float>)(object)val).Max = max;
			((BaseOptions)val).RequiresRestart = false;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(cfgEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateIntCfgEntry(ConfigEntry<int> cfgEntry, int min = 0, int max = 100)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)(object)val).Min = min;
			((BaseRangeOptions<int>)(object)val).Max = max;
			((BaseOptions)val).RequiresRestart = false;
			IntSliderConfigItem val2 = new IntSliderConfigItem(cfgEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateStringCfgEntry(ConfigEntry<string> cfgEntry, bool requireRestart = false)
		{
			//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_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			TextInputFieldConfigItem val = new TextInputFieldConfigItem(cfgEntry, new TextInputFieldOptions
			{
				RequiresRestart = requireRestart
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
		}

		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 ReavsStuff.ShibaEnemy.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}