Decompiled source of Brice v1.0.5

BepInEx/plugins/com.studiocanigou.Brice.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 ExampleEnemy.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using com.studiocanigou.Brice.NetcodePatcher;

[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("com.studiocanigou.Brice")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8d1b8ff2e359c25f3d9a283b5e2b390a9eeb3d3a")]
[assembly: AssemblyProduct("ExampleEnemy")]
[assembly: AssemblyTitle("com.studiocanigou.Brice")]
[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 Brice
{
	public class BriceAI : EnemyAI
	{
		public float minDistance;

		public float maxDistance;

		[Space(5f)]
		public float jumpSpeed = 5f;

		public float jumpTime = 0.25f;

		public float startingInterval = 2f;

		public float endingInterval = 0.2f;

		public int snareBeatAmount;

		[Space(3f)]
		public float currentInterval;

		private float beatTimer;

		[Space(5f)]
		public BriceAI master;

		private bool isMaster;

		[Space(5f)]
		public bool isJumping;

		private float jumpTimer;

		private bool jumpingLastFrame;

		private int beatsSinceSeeingPlayer;

		private bool hasLOS;

		public SimpleEvent SendDanceBeat;

		private int currentHour;

		private bool jumpCycle;

		public AISearchRoutine searchRoutine;

		private float timeSinceSnip;

		private float snareIntervalTimer;

		public AudioSource musicAudio;

		public AudioSource musicAudio2;

		public AudioClip snareDrum;

		public AudioClip[] paradeClips;

		public AudioClip snipScissors;

		private int previousParadeClip;

		public List<BriceAI> allBrices;

		private int snareNum;

		public float snareOffset;

		public MeshRenderer[] scissorBlades;

		public SkinnedMeshRenderer skin;

		public Material scissorGuyMat;

		private Material thisMaterial;

		private RaycastHit hit;

		private bool listeningToMasterBrice;

		private bool choseMasterBrice;

		[Space(3f)]
		public AudioClip[] customVoicelines;

		public Material[] BriceMaterials;

		public SkinnedMeshRenderer[] BriceSkinnedMeshRenderers;

		private void Awake()
		{
		}

		[ClientRpc]
		public void SyncMasterBriceClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			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(510174886u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 510174886u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || ((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			master = this;
			isMaster = true;
			TimeOfDay.Instance.onHourChanged.AddListener(new UnityAction(HourChanged));
			SendDanceBeat = new SimpleEvent();
			allBrices = Object.FindObjectsByType<BriceAI>((FindObjectsSortMode)0).ToList();
			for (int i = 0; i < allBrices.Count; i++)
			{
				if (!((Object)(object)allBrices[i] == (Object)(object)this))
				{
					allBrices[i].master = this;
					allBrices[i].ListenToMasterBrice();
					Object.Destroy((Object)(object)((Component)allBrices[i].musicAudio2).gameObject);
				}
			}
		}

		public void ListenToMasterBrice()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (!listeningToMasterBrice)
			{
				listeningToMasterBrice = true;
				((UnityEvent)master.SendDanceBeat).AddListener(new UnityAction(DanceBeat));
				if ((Object)(object)musicAudio2 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)musicAudio2).gameObject);
				}
				if (!master.allBrices.Contains(this))
				{
					master.allBrices.Add(this);
				}
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			HourChanged();
		}

		private void LateUpdate()
		{
			if (!choseMasterBrice)
			{
				choseMasterBrice = true;
				ChooseMasterBrice();
			}
		}

		private void ChooseMasterBrice()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (((NetworkBehaviour)this).IsServer && !listeningToMasterBrice)
			{
				BriceAI[] array = Object.FindObjectsByType<BriceAI>((FindObjectsSortMode)0);
				int num = 1000;
				int num2 = -50;
				for (int i = 0; i < array.Length; i++)
				{
					if (((EnemyAI)array[i]).thisEnemyIndex < num)
					{
						num = ((EnemyAI)array[i]).thisEnemyIndex;
						num2 = i;
					}
				}
				master = array[num2];
				if ((Object)(object)master == (Object)(object)this)
				{
					isMaster = true;
					TimeOfDay.Instance.onHourChanged.AddListener(new UnityAction(HourChanged));
					SendDanceBeat = new SimpleEvent();
					allBrices = array.ToList();
					for (int j = 0; j < allBrices.Count; j++)
					{
						if (!((Object)(object)allBrices[j] == (Object)(object)this))
						{
							allBrices[j].master = this;
							allBrices[j].ListenToMasterBrice();
						}
					}
					SyncMasterBriceClientRpc();
				}
				if (!isMaster && (Object)(object)musicAudio2 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)musicAudio2).gameObject);
				}
			}
			else if ((Object)(object)musicAudio2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)musicAudio2).gameObject);
			}
		}

		public override void OnDestroy()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			((EnemyAI)this).OnDestroy();
			if (isMaster)
			{
				TimeOfDay.Instance.onHourChanged.RemoveListener(new UnityAction(HourChanged));
			}
			else if ((Object)(object)master != (Object)null)
			{
				master.allBrices.Remove(this);
				if (master.SendDanceBeat != null)
				{
					((UnityEvent)master.SendDanceBeat).RemoveListener(new UnityAction(DanceBeat));
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			PlayerControllerB targetPlayer = base.targetPlayer;
			if (((EnemyAI)this).TargetClosestPlayer(5f, true, 120f))
			{
				hasLOS = true;
				beatsSinceSeeingPlayer = 0;
				if (searchRoutine.inProgress)
				{
					((EnemyAI)this).StopSearch(searchRoutine, true);
				}
			}
			else if (beatsSinceSeeingPlayer > 6)
			{
				if (hasLOS)
				{
					hasLOS = false;
				}
				if (!searchRoutine.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, searchRoutine);
				}
			}
			else if ((Object)(object)targetPlayer != (Object)null)
			{
				base.targetPlayer = targetPlayer;
			}
		}

		private void PlayMusic()
		{
			if (snareIntervalTimer <= 0f)
			{
				snareIntervalTimer = 100f;
				musicAudio.PlayOneShot(snareDrum);
				WalkieTalkie.TransmitOneShotAudio(musicAudio, snareDrum, 1f);
				if (isMaster)
				{
					musicAudio2.PlayOneShot(snareDrum);
				}
			}
			else
			{
				snareIntervalTimer -= Time.deltaTime;
			}
		}

		private void SetMusicVolume()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 1000f;
			for (int i = 0; i < allBrices.Count; i++)
			{
				if (!((Object)(object)allBrices[i] == (Object)null) && !((EnemyAI)allBrices[i]).isEnemyDead)
				{
					num = Vector3.Distance(((Component)StartOfRound.Instance.audioListener).transform.position, ((Component)allBrices[i]).transform.position);
					if (num < num2)
					{
						num2 = num;
					}
				}
			}
			if (num2 < 40f)
			{
				float num3 = ((!(num2 < 20f)) ? Mathf.Lerp(1f, 0.25f, num2 / 50f) : Mathf.Lerp(0.4f, 0f, num2 / 10f));
				musicAudio2.volume = Mathf.Lerp(musicAudio2.volume, num3, 2.5f * Time.deltaTime);
			}
			else
			{
				musicAudio2.volume = Mathf.Lerp(musicAudio2.volume, 0f, 4f * Time.deltaTime);
			}
		}

		private void SetVisibility()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)StartOfRound.Instance.audioListener).transform.position, ((Component)this).transform.position + Vector3.up * 0.7f);
			Material[] briceMaterials = BriceMaterials;
			foreach (Material val in briceMaterials)
			{
				val.SetFloat("_AlphaCutoff", (num - minDistance) / (maxDistance - minDistance));
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!localPlayerController.isPlayerDead && (Object)(object)localPlayerController != (Object)null && num < 15f && num > maxDistance + 2f)
			{
				localPlayerController.IncreaseFearLevelOverTime(0.37f, 0.25f);
			}
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			SetVisibility();
			if (isMaster)
			{
				SetDanceClock();
				SetMusicVolume();
			}
			if (StartOfRound.Instance.allPlayersDead || (Object)(object)master == (Object)null)
			{
				return;
			}
			if (isMaster)
			{
				PlayMusic();
			}
			timeSinceSnip += Time.deltaTime;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (base.isEnemyDead || base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			else if (isJumping)
			{
				if (timeSinceSnip < 0.7f)
				{
					timeSinceSnip += Time.deltaTime;
					base.agent.speed = 0f;
				}
				jumpTimer -= Time.deltaTime;
				if (jumpTimer <= 0f)
				{
					isJumping = false;
					base.agent.speed = 0f;
				}
				else
				{
					base.agent.speed = jumpSpeed;
				}
			}
			if (isMaster)
			{
				if (beatTimer <= 0f)
				{
					beatTimer = currentInterval;
					DoBeatOnOwnerClient();
				}
				else
				{
					beatTimer -= Time.deltaTime;
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!(timeSinceSnip < 1f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					val.KillPlayer(Vector3.up * 14f, true, (CauseOfDeath)17, 7, default(Vector3));
					KillPlayerServerRpc(val.playerUsername);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void KillPlayerServerRpc(string playerUsername)
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2076375905u, val, (RpcDelivery)0);
				bool flag = playerUsername != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(playerUsername, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2076375905u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				KillPlayerClientRpc(playerUsername);
			}
		}

		[ClientRpc]
		public void KillPlayerClientRpc(string playerUsername)
		{
			//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(3856669396u, val, (RpcDelivery)0);
				bool flag = playerUsername != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(playerUsername, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3856669396u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				base.agent.speed = 0f;
				beatTimer += 2f;
			}
			snareIntervalTimer = Mathf.Min(snareIntervalTimer + 2f, 4f);
			timeSinceSnip = 0f;
			base.creatureAnimator.SetTrigger("snip");
			AudioClip val3 = snipScissors;
			AudioClip[] array = customVoicelines;
			foreach (AudioClip val4 in array)
			{
				if (((Object)val4).name == playerUsername)
				{
					val3 = val4;
				}
			}
			if ((Object)(object)val3 != (Object)null)
			{
				base.creatureSFX.PlayOneShot(val3);
			}
		}

		private void DoBeatOnOwnerClient()
		{
			DanceBeat();
			((UnityEvent)SendDanceBeat).Invoke();
			DoBeatServerRpc();
		}

		[ServerRpc]
		public void DoBeatServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2413757497u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2413757497u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DoBeatClientRpc();
			}
		}

		[ClientRpc]
		public void DoBeatClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			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(1123458835u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1123458835u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
			{
				if (isMaster)
				{
					DanceBeat();
				}
				if (SendDanceBeat != null)
				{
					((UnityEvent)SendDanceBeat).Invoke();
				}
			}
		}

		private void HourChanged()
		{
			currentInterval = Mathf.Clamp(Mathf.Lerp(startingInterval, endingInterval, (float)TimeOfDay.Instance.hour / (float)TimeOfDay.Instance.numberOfHours), endingInterval, startingInterval);
		}

		private void DanceBeat()
		{
			//IL_009c: 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_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)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0157: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			if (base.stunNormalizedTimer > 0f)
			{
				return;
			}
			isJumping = true;
			jumpTimer = jumpTime;
			jumpCycle = !jumpCycle;
			base.creatureAnimator.SetBool("walkCycle", jumpCycle);
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			beatsSinceSeeingPlayer++;
			if (hasLOS && (Object)(object)base.targetPlayer != (Object)null)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position;
				if (Physics.Raycast(((Component)base.targetPlayer).transform.position + Vector3.up * 0.5f, Vector3.down, ref hit, 7f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					val = ((RaycastHit)(ref hit)).point;
				}
				Vector3 onUnitSphere = Random.onUnitSphere;
				onUnitSphere.y = 0f;
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(val, onUnitSphere);
				float num = Vector3.Distance(((Component)this).transform.position, val);
				val = ((!Physics.Raycast(val2, ref hit, num, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) ? ((Ray)(ref val2)).GetPoint(num) : ((RaycastHit)(ref hit)).point);
				((EnemyAI)this).SetDestinationToPosition(val, false);
			}
		}

		public override void AnimationEventA()
		{
			//IL_00e8: 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)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).AnimationEventA();
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).SyncPositionToClients();
			}
			if (!(timeSinceSnip < 0.4f))
			{
				int num = Random.Range(0, paradeClips.Length);
				if (num == previousParadeClip)
				{
					num = (num + 1) % paradeClips.Length;
				}
				previousParadeClip = num;
				float pitch = Random.Range(0.95f, 1.05f);
				musicAudio.pitch = pitch;
				musicAudio.PlayOneShot(paradeClips[num]);
				WalkieTalkie.TransmitOneShotAudio(musicAudio, paradeClips[num], 1f);
				snareIntervalTimer = currentInterval - snareOffset;
				snareNum = 0;
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (!localPlayerController.isPlayerDead && localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.7f, 70f, (int)maxDistance - 1, -1f))
				{
					localPlayerController.JumpToFearLevel(0.85f, true);
				}
				if (isMaster)
				{
					musicAudio2.pitch = pitch;
					musicAudio2.PlayOneShot(paradeClips[num]);
				}
			}
		}

		private void SetDanceClock()
		{
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BriceAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(510174886u, new RpcReceiveHandler(__rpc_handler_510174886));
			NetworkManager.__rpc_func_table.Add(2076375905u, new RpcReceiveHandler(__rpc_handler_2076375905));
			NetworkManager.__rpc_func_table.Add(3856669396u, new RpcReceiveHandler(__rpc_handler_3856669396));
			NetworkManager.__rpc_func_table.Add(2413757497u, new RpcReceiveHandler(__rpc_handler_2413757497));
			NetworkManager.__rpc_func_table.Add(1123458835u, new RpcReceiveHandler(__rpc_handler_1123458835));
		}

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

		private static void __rpc_handler_2076375905(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 playerUsername = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref playerUsername, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BriceAI)(object)target).KillPlayerServerRpc(playerUsername);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_2413757497(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BriceAI)(object)target).DoBeatServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "BriceAI";
		}
	}
	[BepInPlugin("com.studiocanigou.Brice", "ExampleEnemy", "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 = "Brice";
			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>("Brice");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("BriceTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("BriceTK");
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>
			{
				{
					(LevelTypes)4,
					40
				},
				{
					(LevelTypes)16,
					100
				},
				{
					(LevelTypes)64,
					100
				},
				{
					(LevelTypes)128,
					100
				},
				{
					(LevelTypes)(-1),
					60
				}
			};
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, dictionary, dictionary2, val2, val3);
			Logger.LogInfo((object)"Plugin com.studiocanigou.Brice 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 = "com.studiocanigou.Brice";

		public const string PLUGIN_NAME = "ExampleEnemy";

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

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 500, "The spawn chance weight for ExampleEnemy, 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 com.studiocanigou.Brice.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}