Decompiled source of OiiaCat v1.1.0

Luxciano32.OiiaCat.dll

Decompiled 11 hours ago
#define DEBUG
using System;
using System.Collections;
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 Luxciano32.OiiaCat.NetcodePatcher;
using Microsoft.CodeAnalysis;
using OiiaCat.Configuration;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Luxciano32.OiiaCat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2f455a1e9eb7a6d1aab788655264d82d6c999959")]
[assembly: AssemblyProduct("OiiaCat")]
[assembly: AssemblyTitle("Luxciano32.OiiaCat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 OiiaCat
{
	internal class OiiaCatAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			StickingInFrontOfPlayer
		}

		private enum SingingAnimations
		{
			singing2spin,
			singing2spinfast,
			singin3spin,
			singin3spinfast,
			singing4spin,
			singing4spinfast
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 StalkPos;

		private Random enemyRandom = null;

		private bool isDeadAnimationDone;

		public List<AudioClip> audioClips = null;

		private int lastPlayedAudioClipIndex = -1;

		private int waitBeforeNextSong = 3;

		private float[] hitTimes = new float[3];

		private int hitIndex = 0;

		private float minTimeBetweenHits = 1f;

		private float maxTimeBetweenHits = 3f;

		public AudioClip audioClipDead = null;

		private List<string> items = new List<string>
		{
			"Binoculars", "Boombox", "box", "Flashlight", "Jetpack", "Key", "Lockpicker", "Mapper", "Pro-flashlight", "Shovel",
			"Stun grenade", "Extension ladder", "TZP-Inhalant", "Walkie-talkie", "Zap gun"
		};

		private List<string> scraps = new List<string>
		{
			"Apparatus", "Magic 7 ball", "Airhorn", "Bell", "Big bolt", "Bottles", "Brush", "Candy", "Cash register", "Chemical jug",
			"Clown horn", "Large axle", "Teeth", "Dust pan", "Egg beater", "V-type engine", "Golden cup", "Fancy lamp", "Painting", "Plastic fish",
			"Laser pointer", "Gold bar", "Hairdryer", "Magnifying glass", "Metal sheet", "Cookie mold pan", "Mug", "Perfume bottle", "Old phone", "Jar of pickles",
			"Pill bottle", "Remote", "Ring", "Toy robot", "Rubber Ducky", "Red soda", "Steering wheel", "Stop sign", "Tea kettle", "Toothpaste",
			"Toy cube", "Hive", "Yield sign", "Shotgun", "Spray paint"
		};

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

		public override void Start()
		{
			//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)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Oiia Cat Spawned");
			timeSinceHittingLocalPlayer = 0f;
			PlaySong();
			timeSinceNewRandPos = 0f;
			positionRandomness = new Vector3(0f, 0f, 0f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			base.currentBehaviourStateIndex = 0;
		}

		public override void Update()
		{
			//IL_00b3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					LogIfDebugBuild("Stopping enemy voice with janky code.");
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if ((Object)(object)base.targetPlayer != (Object)null && currentBehaviourStateIndex == 1)
			{
				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 (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 3f;
				if (FoundClosestPlayerInRange(25f, 3f))
				{
					LogIfDebugBuild("Start Target Player");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				base.agent.speed = 5f;
				StickingInFrontOfPlayer();
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: 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)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		private void StickingInFrontOfPlayer()
		{
			//IL_0069: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner && timeSinceNewRandPos > 0.7f)
			{
				timeSinceNewRandPos = 0f;
				positionRandomness = new Vector3((float)enemyRandom.Next(-2, 2), 0f, (float)enemyRandom.Next(-2, 2));
				StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-5f, 0f, -5f), ((Component)base.targetPlayer).transform.forward) + positionRandomness;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (isDeadAnimationDone)
			{
				return;
			}
			float time = Time.time;
			hitTimes[hitIndex] = time;
			if (hitIndex == 2)
			{
				float num = hitTimes[2] - hitTimes[1];
				if (num <= maxTimeBetweenHits)
				{
					LogIfDebugBuild("Tres golpes consecutivos recibidos, el tercero está dentro del tiempo permitido desde el segundo");
					base.creatureVoice.Stop();
					base.creatureVoice.clip = audioClipDead;
					base.creatureVoice.Play();
					isDeadAnimationDone = true;
					base.creatureAnimator.SetTrigger("singingForItem");
					((MonoBehaviour)this).StopCoroutine(StopAnimationItem());
					((MonoBehaviour)this).StartCoroutine(StopAnimationItem());
					return;
				}
			}
			LogIfDebugBuild($"El enemigo recibio el golpe N° {hitIndex + 1} de 3");
			hitIndex = (hitIndex + 1) % hitTimes.Length;
			PlaySong();
			if (!base.isEnemyDead)
			{
			}
		}

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

		public void NextSinginAnimation()
		{
			LogIfDebugBuild("Next singing animation");
			string trigger = GetRandomEnumValue((SingingAnimations[])Enum.GetValues(typeof(SingingAnimations))).ToString();
			base.creatureAnimator.SetTrigger(trigger);
		}

		public static T GetRandomEnumValue<T>(T[] EnumValues) where T : Enum
		{
			int num = Random.Range(0, EnumValues.Length);
			return EnumValues[num];
		}

		public void PlaySong()
		{
			((MonoBehaviour)this).StopCoroutine(StopAnimationWhenAudioEnds());
			AudioClip randomAudioClip = GetRandomAudioClip();
			if (!((Object)(object)randomAudioClip == (Object)null))
			{
				base.creatureVoice.clip = randomAudioClip;
				base.creatureVoice.Play();
				base.creatureAnimator.SetTrigger("animationIdle");
				((MonoBehaviour)this).StartCoroutine(StopAnimationWhenAudioEnds());
			}
		}

		private AudioClip? GetRandomAudioClip()
		{
			if (audioClips == null || audioClips.Count == 0)
			{
				LogIfDebugBuild("La lista de AudioClips está vacía o es nula.");
				return null;
			}
			int num;
			do
			{
				num = Random.Range(0, audioClips.Count);
			}
			while (num == lastPlayedAudioClipIndex && audioClips.Count > 1);
			lastPlayedAudioClipIndex = num;
			return audioClips[num];
		}

		private IEnumerator StopAnimationWhenAudioEnds()
		{
			yield return (object)new WaitForSeconds(base.creatureVoice.clip.length);
			base.creatureAnimator.SetTrigger("backToIdle");
			yield return (object)new WaitForSeconds((float)waitBeforeNextSong);
			if (!base.creatureVoice.isPlaying)
			{
				PlaySong();
			}
		}

		private IEnumerator StopAnimationItem()
		{
			yield return (object)new WaitForSeconds(base.creatureVoice.clip.length);
			Random random = new Random();
			int randomIndex = random.Next(10);
			if (randomIndex < 3)
			{
				TriggerExplosionFromAnimation();
			}
			else if (randomIndex < 7)
			{
				SpawnItems();
			}
			else
			{
				SpawnScrap();
			}
			base.creatureAnimator.SetTrigger("animationExit");
		}

		public void SpawnItems()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LogIfDebugBuild("Spawning items");
				Random random = new Random();
				int index = random.Next(items.Count);
				string randomItemName = items[index];
				Item val = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => item.itemName == randomItemName);
				try
				{
					LogIfDebugBuild("Instatiating item: " + val.itemName);
					GrabbableObject component = Object.Instantiate<GameObject>(val.spawnPrefab, new Vector3(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z), Quaternion.identity).GetComponent<GrabbableObject>();
					((NetworkBehaviour)component).NetworkObject.Spawn(false);
				}
				catch (Exception ex)
				{
					LogIfDebugBuild("Error al instanciar el item: " + ex.Message + "\n" + ex.StackTrace);
				}
			}
			catch (Exception ex2)
			{
				LogIfDebugBuild("Error al instanciar los items: " + ex2.Message + "\n" + ex2.StackTrace);
			}
		}

		public void SpawnScrap()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LogIfDebugBuild("Spawning scrap");
				Random random = new Random();
				int index = random.Next(scraps.Count);
				string randomScrapName = scraps[index];
				Item val = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => item.itemName == randomScrapName);
				try
				{
					LogIfDebugBuild("Instatiating scrap: " + val.itemName);
					GrabbableObject component = Object.Instantiate<GameObject>(val.spawnPrefab, new Vector3(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z), Quaternion.identity).GetComponent<GrabbableObject>();
					int minValue = val.minValue;
					int maxValue = val.maxValue;
					Random random2 = new Random();
					int scrapValue = random2.Next(minValue, maxValue);
					component.scrapValue = scrapValue;
					((NetworkBehaviour)component).NetworkObject.Spawn(false);
				}
				catch (Exception ex)
				{
					LogIfDebugBuild("Error al instanciar el item: " + ex.Message + "\n" + ex.StackTrace);
				}
			}
			catch (Exception ex2)
			{
				LogIfDebugBuild("Error al instanciar los items: " + ex2.Message + "\n" + ex2.StackTrace);
			}
		}

		public void TriggerExplosionFromAnimation()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CreateExplosion(((Component)this).transform.position, spawnExplosionEffect: true, 20, 0f, 1f, 6, (CauseOfDeath)3);
			}
			catch (Exception ex)
			{
				LogIfDebugBuild("Error al crear la explosión: " + ex.Message + "\n" + ex.StackTrace);
			}
		}

		public void CreateExplosion(Vector3? explosionPosition = null, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
		{
			//IL_0028: 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_002d: 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_00c8: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild("Spawning explosion}");
			Vector3 val = (Vector3)(((??)explosionPosition) ?? ((Component)this).transform.position);
			Transform val2 = null;
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
			{
				val2 = RoundManager.Instance.mapPropsContainer.transform;
			}
			if (spawnExplosionEffect)
			{
				Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, val, Quaternion.Euler(-90f, 0f, 0f), val2).SetActive(true);
			}
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, val);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			Collider[] array = Physics.OverlapSphere(val, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val3 = null;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(val, ((Component)array[i]).transform.position);
				if (num2 > 4f && Physics.Linecast(val, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
				{
					continue;
				}
				if (((Component)array[i]).gameObject.layer == 3)
				{
					val3 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val3 != (Object)null)
					{
						float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
						val3.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 21)
				{
					Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
					{
						LogIfDebugBuild("Setting off other mine");
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
					{
						componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false, -1);
					}
				}
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(val, 10f, num4);
			for (int j = 0; j < array.Length; j++)
			{
				Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, val, 10f);
				}
			}
		}

		private void CopyPropertiesToGameObject(Item source, GameObject target)
		{
			Type type = ((object)source).GetType();
			Component[] components = target.GetComponents<Component>();
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (!propertyInfo.CanRead)
				{
					continue;
				}
				object value = propertyInfo.GetValue(source);
				Component[] array = components;
				foreach (Component val in array)
				{
					PropertyInfo property = ((object)val).GetType().GetProperty(propertyInfo.Name);
					if (property != null && property.CanWrite)
					{
						property.SetValue(val, value);
					}
				}
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
			foreach (FieldInfo fieldInfo in fields)
			{
				object value2 = fieldInfo.GetValue(source);
				Component[] array2 = components;
				foreach (Component val2 in array2)
				{
					FieldInfo field = ((object)val2).GetType().GetField(fieldInfo.Name);
					if (field != null)
					{
						field.SetValue(val2, value2);
					}
				}
			}
		}

		public void Destroy()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

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

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

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

		protected internal override string __getTypeName()
		{
			return "OiiaCatAI";
		}
	}
	[BepInPlugin("Luxciano32.OiiaCat", "OiiaCat", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "oiiacatassets";
			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>("OiiaCat");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("OiiaCatTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("OiiaCatTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			Logger.LogInfo((object)"Plugin Luxciano32.OiiaCat 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 static class PluginInfo
	{
		public const string PLUGIN_GUID = "Luxciano32.OiiaCat";

		public const string PLUGIN_NAME = "OiiaCat";

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

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for OiiaCat, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			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 Luxciano32.OiiaCat.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}