Decompiled source of OiiaCat v1.3.0

Luxciano32.OiiaCat.dll

Decompiled 2 months 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.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+5423e585c5e70ffadcb418a21b853eaf3f6d357b")]
[assembly: AssemblyProduct("OiiaCat")]
[assembly: AssemblyTitle("Luxciano32.OiiaCat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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;

		public List<AudioClip> audioClipsFart = 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> lowValueItems = new List<string> { "Flashlight", "Key", "Lockpicker", "box", "Shovel", "Extension ladder", "Walkie-talkie", "TZP-Inhalant" };

		private List<string> midValueItems = new List<string> { "Boombox", "Pro-flashlight", "Stun grenade", "Zap gun", "Belt bag", "Spray paint", "Weed killer" };

		private List<string> highValueItems = new List<string> { "Jetpack", "Shotgun", "Kitchen knife", "Binoculars" };

		private List<string> lowValuescraps = new List<string>
		{
			"Rubber Ducky", "Brush", "Metal sheet", "Gift", "Dust pan", "Cookie mold pan", "Plastic cup", "Yield sign", "Pill bottle", "Flask",
			"Steering wheel", "Toy cube", "Mug", "Plastic fish", "Jar of pickles", "Garbage lid", "Bottles"
		};

		private List<string> midValuescraps = new List<string>
		{
			"Candy", "Apparatus", "Remote", "Big bolt", "Stop sign", "Toothpaste", "Red soda", "Homemade flashbang", "Easter egg", "Tragedy",
			"Comedy", "Tea kettle", "Chemical jug", "Zed Dog", "Control pad", "Large axle", "Magic 7 ball", "Hive", "V-type engine", "Whoopie cushion",
			"Soccer ball", "Magnifying glass", "Airhorn", "Clown horn", "Toy robot"
		};

		private List<string> highValuescraps = new List<string>
		{
			"Laser pointer", "Old phone", "Clock", "Bell", "Perfume bottle", "Ring", "Toy train", "Teeth", "Fancy lamp", "Painting",
			"Toilet paper", "Hairdryer", "Cash register", "Gold bar"
		};

		private List<string> lowDangerEnemies = new List<string> { "HoarderBug", "Centipede", "Blob", "CaveDweller" };

		private List<string> midDangerEnemies = new List<string> { "SandSpider", "Puffer", "SpringMan", "MaskedPlayerEnemy", "Butler" };

		private List<string> highDangerEnemies = new List<string> { "Flowerman", "Crawler", "DressGirl", "Nutcracker", "ClaySurgeon", "Jester" };

		[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)
				{
					((MonoBehaviour)this).StopCoroutine(StopAnimationWhenAudioEnds());
					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()
		{
			while (base.creatureVoice.isPlaying)
			{
				yield return null;
			}
			base.creatureAnimator.SetTrigger("backToIdle");
			yield return (object)new WaitForSeconds((float)waitBeforeNextSong);
			PlaySong();
		}

		private IEnumerator StopAnimationItem()
		{
			yield return (object)new WaitForSeconds(base.creatureVoice.clip.length);
			Random randomNumber = new Random();
			int randomIndex = randomNumber.Next(100);
			if (randomIndex <= 30)
			{
				TriggerExplosionFromAnimation();
			}
			else if (randomIndex > 30 && randomIndex <= 55)
			{
				SpawnScrap();
			}
			else if (randomIndex > 55 && randomIndex <= 75)
			{
				SpawnItems();
			}
			else if (randomIndex > 75 && randomIndex <= 90)
			{
				SpawnEnemy();
			}
			else
			{
				SpawnFartSound();
			}
			base.creatureAnimator.SetTrigger("animationExit");
		}

		public void SpawnItems()
		{
			//IL_00d8: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LogIfDebugBuild("Spawning items");
				List<string> list = new List<string>();
				Random random = new Random();
				int num = random.Next(100);
				list = ((num <= 50) ? lowValueItems : ((num <= 50 || num > 80) ? highValueItems : midValueItems));
				Random random2 = new Random();
				int index = random2.Next(list.Count);
				string randomItemName = list[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_00d8: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LogIfDebugBuild("Spawning scrap");
				List<string> list = new List<string>();
				Random random = new Random();
				int num = random.Next(100);
				list = ((num <= 50) ? lowValuescraps : ((num <= 50 || num > 80) ? highValuescraps : midValuescraps));
				Random random2 = new Random();
				int index = random2.Next(list.Count);
				string randomScrapName = list[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 random3 = new Random();
					int scrapValue = random3.Next(minValue, maxValue);
					component.SetScrapValue(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, 50, 0f, 4.3f, 15, (CauseOfDeath)3);
				Destroy();
			}
			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_0326: 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_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: 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)
				{
					LogIfDebugBuild("Damaging player: " + ((Object)((Component)array[i]).gameObject).name);
					val3 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val3 != (Object)null)
					{
						float num3 = Mathf.Clamp01((maxDamageRange - minDamageRange) / (num2 - 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);
				}
			}
		}

		public void SpawnEnemy()
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild("Spawning enemy");
			List<string> list = new List<string>();
			Random random = new Random();
			int num = random.Next(100);
			list = ((num <= 80) ? lowDangerEnemies : ((num <= 80 || num > 92) ? highDangerEnemies : midDangerEnemies));
			Random random2 = new Random();
			int index = random2.Next(list.Count);
			string randomEnemyName = list[index];
			while (!RoundManager.Instance.currentLevel.Enemies.Exists((SpawnableEnemyWithRarity e) => ((Object)e.enemyType).name == randomEnemyName))
			{
				index = random2.Next(list.Count);
				randomEnemyName = list[index];
			}
			try
			{
				EnemyType enemyType = RoundManager.Instance.currentLevel.Enemies.Find((SpawnableEnemyWithRarity e) => ((Object)e.enemyType).name == randomEnemyName).enemyType;
				RoundManager.Instance.SpawnEnemyGameObject(new Vector3(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z), 0f, -1, enemyType);
			}
			catch (Exception ex)
			{
				LogIfDebugBuild("Error: " + ex.Message);
				SpawnScrap();
			}
		}

		public void SpawnFartSound()
		{
			Random random = new Random();
			int index = random.Next(audioClipsFart.Count);
			AudioClip val = audioClipsFart[index];
			base.creatureVoice.PlayOneShot(val, 2.5f);
			int num = random.Next(100);
			if (num <= 40)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			else if (num > 40 && num <= 60)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
		}

		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.3.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, 70, (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.3.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
	{
	}
}