Decompiled source of BaldiPlus v1.0.0

plugins/tmf.baldiplus.dll

Decompiled 8 hours ago
using System;
using System.Collections;
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 BaldiPlus.UI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
using UnityEngine.Video;
using tmf.baldiplus.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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("tmf.baldiplus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BaldiPlus")]
[assembly: AssemblyTitle("tmf.baldiplus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 BaldiPlus
{
	internal class BaldiConfig
	{
		public readonly ConfigEntry<int> baldiSpawnWeight;

		public readonly ConfigEntry<float> startingAnger;

		public readonly ConfigEntry<float> angerPerMinute;

		public readonly ConfigEntry<float> countingInterval;

		public readonly ConfigEntry<float> completedNotebookBonus;

		public readonly ConfigEntry<float> failedNotebookPenalty;

		public readonly ConfigEntry<float> angerReductionOnKill;

		public readonly ConfigEntry<bool> disableRegenNotebook;

		public readonly ConfigEntry<bool> restoreStaminaNotebook;

		public readonly ConfigEntry<int> notebookCreditBonus;

		public readonly ConfigEntry<float> jumpscareVolume;

		public readonly ConfigEntry<float> yctpSensitivity;

		public BaldiConfig(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			baldiSpawnWeight = cfg.Bind<int>("General", "Baldi Spawn Weight", 15, "Global spawn weight for the Baldi enemy.");
			jumpscareVolume = cfg.Bind<float>("General - Client", "Jumpscare Volume", 1f, "Volume of the jumpscare sound when killed by Baldi.");
			yctpSensitivity = cfg.Bind<float>("General - Client", "YCTP Cursor Sensitivity", 1f, "Sensitivity of the cursor when completing math problems on the YouCanThinkPad™");
			startingAnger = cfg.Bind<float>("Mechanics - Baldi", "Starting Anger", 1f, "The anger level that Baldi starts at upon beginning Hide & Seek.");
			angerPerMinute = cfg.Bind<float>("Mechanics - Baldi", "Anger per Minute", 1.2f, "The speed at which Baldi's anger increases over time (additive), measured per minute.");
			countingInterval = cfg.Bind<float>("Mechanics - Baldi", "Counting Interval", 2f, "The time it takes for Baldi to count down per number.(multiply by 10 for the total countdown sequence length excluding \"ready or not\")");
			completedNotebookBonus = cfg.Bind<float>("Mechanics - Notebook", "Completed Notebook Bonus", 1f, "The amount that Baldi's anger is decreased when successfully completing a notebook.");
			failedNotebookPenalty = cfg.Bind<float>("Mechanics - Notebook", "Failed Notebook Penalty", 1.2f, "The amount that Baldi's anger is increased when failing a notebook.");
			angerReductionOnKill = cfg.Bind<float>("Mechanics - Notebook", "Anger Reduction on Kill", 1.5f, "The amount that Baldi's anger is decreased upon killing a player.");
			disableRegenNotebook = cfg.Bind<bool>("Mechanics - Notebook", "Disable Stamina Regen during Notebook", true, "Disable stamina regeneration while having a notebook opened.");
			restoreStaminaNotebook = cfg.Bind<bool>("Mechanics - Notebook", "Restore Stamina upon Notebook Completion", true, "Fully restore a player's stamina meter when successfully completing a notebook.");
			notebookCreditBonus = cfg.Bind<int>("Mechanics - Notebook", "Notebook Credit Bonus", 25, "The amount of bonus credits awarded when successfully completing a notebook.\n(Doesn't contribute to the quota)\n(Set to 0 to disable the credit bonus)");
			cfg.SaveOnConfigSet = true;
		}
	}
	public class BaldiEnemyAI : EnemyAI
	{
		public enum State
		{
			Inviting,
			Counting,
			Roaming,
			Chasing,
			Attacking,
			Praising
		}

		[Header("Audio")]
		public AudioSource audSrc_sfx;

		public AudioSource audSrc_voice;

		private float[] voiceSamples = new float[256000];

		public AnimationCurve mouthSensitivity;

		public float sampleHangTime = 0.1f;

		private int lastSample = 0;

		public AudioClip aud_slap;

		public AudioClip[] aud_praise = (AudioClip[])(object)new AudioClip[6];

		public AudioClip[] aud_count = (AudioClip[])(object)new AudioClip[10];

		public AudioClip aud_finishCounting;

		public AudioClip aud_startCounting;

		public AudioClip[] aud_hear = (AudioClip[])(object)new AudioClip[2];

		public AudioClip[] aud_stalk = (AudioClip[])(object)new AudioClip[5];

		public AudioClip[] aud_buzz = (AudioClip[])(object)new AudioClip[0];

		[Header("Mechanics")]
		private float anger = 1f;

		private float slapInterval = 1f;

		public AnimationCurve speedCurve;

		private float slapCooldown = 2f;

		private float totalMoveTime = 0.1f;

		private float currentMoveTime = 0f;

		public float moveSpeed = 100f;

		public float angerPerSecond = 0.02f;

		public float praiseLength = 5f;

		public float viewAngle = 135f;

		public int viewRange = 200;

		public AnimationCurve noisePriorityFalloff;

		public float notebookSpawnInterval = 30f;

		public float intervalSlowdownFactor = 0.75f;

		private float notebookTimer;

		public float invitingSpeed = 2f;

		public float inviteSpeedPerSecond = 0.015f;

		private float currentInvitingSpeed;

		[Header("Misc")]
		public Transform bone_head;

		public Transform bone_leftEye;

		public Transform bone_rightEye;

		public SkinnedMeshRenderer meshObject;

		public GameObject notebookPrefab;

		[SerializeField]
		private Vector3 notebookSpawnOffset = new Vector3(0f, 0.5f, 0f);

		[SerializeField]
		private Animator killCamAnimator;

		[SerializeField]
		private Camera killCam;

		[SerializeField]
		private Light killCamLight;

		private bool debug_frozen = false;

		private List<NotebookPickup> activeNotebooks = new List<NotebookPickup>();

		private State currentState;

		private IEnumerator activePraiseRoutine;

		private Vector3 targetPosition;

		private State praiseExitState = State.Attacking;

		private float attackStateBuffer = 0.1f;

		private float currentAttackStateBuffer = 0f;

		private float currentNoisePriority = 0f;

		private bool taggedPlayer = false;

		private bool seenStalking = false;

		public float stalkingQuoteCooldown = 10f;

		public float stalkingQuoteChance = 0.5f;

		private float currentStalkingQuoteCooldown = 0f;

		[HideInInspector]
		public float speakHearDebounce = 0f;

		[HideInInspector]
		public bool isKilling = false;

		public float killCooldown = 1.5f;

		private float currentKillCooldown = 0f;

		public static bool inKillAnimClient;

		private float slapReplicateDebounce = 0f;

		private float angerReductionOnKill = 1.5f;

		private float countdownInterval = 2f;

		private bool debug_mode = false;

		public bool IsAngry => currentState == State.Roaming || currentState == State.Chasing || currentState == State.Attacking;

		public void StartTalking(AudioClip voiceClip)
		{
			if (audSrc_voice.isPlaying)
			{
				audSrc_voice.Stop();
			}
			lastSample = 0;
			int num = Mathf.CeilToInt(voiceClip.length * (float)voiceClip.frequency * (float)voiceClip.channels);
			voiceSamples = new float[num];
			voiceClip.GetData(voiceSamples, 0);
			audSrc_voice.clip = voiceClip;
			audSrc_voice.Play();
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			if (debug_mode)
			{
				HUDManager.Instance.AddTextToChatOnServer("Baldi Debug mode is enabled. Remember to disable for release!", 0);
			}
			notebookTimer = notebookSpawnInterval;
			currentInvitingSpeed = invitingSpeed;
			if (((NetworkBehaviour)this).IsOwner)
			{
				SetStateRpc(State.Inviting);
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				ApplyConfigSettingsRpc(BaldiPlus.PluginConfig.startingAnger.Value, BaldiPlus.PluginConfig.angerPerMinute.Value / 60f, BaldiPlus.PluginConfig.angerReductionOnKill.Value, BaldiPlus.PluginConfig.countingInterval.Value);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ApplyConfigSettingsRpc(float startingAnger, float angerPerSecond, float angerLossOnKill, float countInterval)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1974329057u, val3, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref startingAnger, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref angerPerSecond, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref angerLossOnKill, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref countInterval, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendRpc(ref val2, 1974329057u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					this.angerPerSecond = angerPerSecond;
					anger = startingAnger;
					angerReductionOnKill = angerLossOnKill;
					countdownInterval = countInterval;
				}
			}
		}

		public void PlayPraise()
		{
			currentMoveTime = 0f;
			slapCooldown = slapInterval;
			base.agent.speed = 0f;
			int clipIndex = Random.RandomRangeInt(0, aud_praise.Length);
			PlayPraiseSequenceClientRpc(clipIndex);
			if (currentState == State.Praising)
			{
				((MonoBehaviour)this).StopCoroutine(activePraiseRoutine);
			}
			activePraiseRoutine = PraiseWait();
			((MonoBehaviour)this).StartCoroutine(activePraiseRoutine);
			SetStateRpc(State.Praising);
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void GiveOwnershipToServerRpc()
		{
			//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_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(722856282u, val3, val, (SendTo)2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 722856282u, val3, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (!((NetworkBehaviour)this).IsOwnedByServer)
				{
				}
			}
		}

		private void SetTarget(PlayerControllerB? newTargetPlayer)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				base.targetPlayer = newTargetPlayer;
				if ((Object)(object)newTargetPlayer != (Object)null)
				{
					((EnemyAI)this).ChangeEnemyOwnerServerRpc(newTargetPlayer.actualClientId);
				}
				else
				{
					GiveOwnershipToServerRpc();
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void HearNoiseRpc(Vector3 origin, BaldiHearing.NoiseType noise, NetworkBehaviourReference playerRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(529243842u, val3, val, (SendTo)0, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref origin);
				((FastBufferWriter)(ref val2)).WriteValueSafe<BaldiHearing.NoiseType>(ref noise, default(ForEnums));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 529243842u, val3, val, (SendTo)0, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (currentState == State.Attacking || currentState == State.Counting || currentState == State.Inviting)
			{
				return;
			}
			PlayerControllerB val4 = default(PlayerControllerB);
			((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref val4, (NetworkManager)null);
			NoiseData noiseData = BaldiHearing.noiseData[noise];
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(origin, RoundManager.Instance.navHit, 1.75f, base.agentMask);
			if (base.path1 == null)
			{
				base.path1 = new NavMeshPath();
			}
			if (!NavMesh.CalculatePath(((Component)this).transform.position, navMeshPosition, base.agent.areaMask, base.path1))
			{
				BaldiPlus.Logger.LogDebug((object)"Baldi ignoring audible sound as there is no valid path");
				return;
			}
			Vector3 val5 = origin - ((Component)this).transform.position;
			float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
			float num = noiseData.priority * noisePriorityFalloff.Evaluate(sqrMagnitude / (float)Math.Pow(noiseData.range, 2.0) / 1.6f);
			if ((Object)(object)base.targetPlayer != (Object)null && ((Object)(object)val4 == (Object)null || (Object)(object)val4 != (Object)(object)base.targetPlayer))
			{
				num /= 1.6f;
			}
			if (num < currentNoisePriority)
			{
				BaldiPlus.Logger.LogDebug((object)$"Baldi ignoring audible sound {num} < {currentNoisePriority}");
				return;
			}
			currentNoisePriority = noiseData.priority * noisePriorityFalloff.Evaluate(sqrMagnitude / (float)Math.Pow(noiseData.range, 2.0));
			SetTarget(val4);
			targetPosition = navMeshPosition;
			if (Random.Range(0f, 1f) <= noiseData.quoteChance)
			{
				BaldiPlus.Logger.LogDebug((object)"Baldi playing hearing quote");
				StartTalkingClientRpc(4, Random.Range(0, aud_hear.Length));
			}
			if (currentState == State.Praising)
			{
				praiseExitState = State.Chasing;
			}
			else if (currentState == State.Roaming)
			{
				SetStateRpc(State.Chasing);
			}
		}

		private IEnumerator PraiseWait()
		{
			yield return (object)new WaitForSeconds(praiseLength);
			SetStateRpc(praiseExitState);
			ExitPraiseClientRpc();
		}

		public void RemoveNotebook(NotebookPickup notebook)
		{
			if (activeNotebooks.Contains(notebook))
			{
				activeNotebooks.Remove(notebook);
			}
		}

		public void ModifyAnger(float change)
		{
			anger = Math.Max(anger + change, 0.75f);
		}

		public void SpawnNotebook()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(notebookPrefab, RoundManager.Instance.mapPropsContainer.transform);
			NotebookPickup component = val.GetComponent<NotebookPickup>();
			activeNotebooks.Add(component);
			component.parentBaldi = this;
			val.transform.rotation = ((Component)this).transform.rotation;
			val.transform.position = ((Component)this).transform.position + notebookSpawnOffset;
			val.GetComponent<NetworkObject>().Spawn(false);
		}

		private Vector3 GetClosestPointOnNavMesh(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			NavMesh.SamplePosition(pos, ref val, 1.5f, -1);
			return ((NavMeshHit)(ref val)).position;
		}

		private void AttackToChasing()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_0034: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 velocity = base.targetPlayer.thisController.velocity;
			Vector3 val = ((Vector3)(ref velocity)).normalized * 0.25f;
			Vector3 val2 = ((Component)base.targetPlayer).transform.position + val;
			targetPosition = val2;
			SetStateRpc(State.Chasing);
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void StartCountingRpc()
		{
			//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_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1962367088u, val3, val, (SendTo)6, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 1962367088u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				taggedPlayer = true;
				base.agent.speed = 0f;
				StartTalking(aud_startCounting);
				if (((NetworkBehaviour)this).IsOwner)
				{
					((MonoBehaviour)this).StartCoroutine(CountingWaitStuff());
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void CountAnimSyncThingyRpc(int mode)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3044370750u, val3, val, (SendTo)7, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, mode);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3044370750u, val3, val, (SendTo)7, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				switch (mode)
				{
				case 0:
					base.creatureAnimator.SetBool("Counting", true);
					break;
				case 1:
					base.creatureAnimator.SetBool("Happy", false);
					base.creatureAnimator.SetBool("Counting", false);
					break;
				}
			}
		}

		private IEnumerator CountingWaitStuff()
		{
			yield return (object)new WaitForSeconds(aud_startCounting.length + 0.6f);
			CountAnimSyncThingyRpc(0);
			SetStateRpc(State.Counting);
			for (int i = 9; i > -1; i--)
			{
				StartTalkingClientRpc(1, i);
				yield return (object)new WaitForSeconds(countdownInterval);
			}
			StartTalkingClientRpc(2);
			yield return (object)new WaitForSeconds(aud_finishCounting.length + 1f);
			CountAnimSyncThingyRpc(1);
			SetStateRpc(State.Roaming);
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			if (currentState != State.Counting && currentState != State.Praising)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (currentState == State.Inviting && !taggedPlayer)
				{
					StartCountingRpc();
				}
				else if (IsAngry && !isKilling && StartOfRound.Instance.allowLocalPlayerDeath && ((NetworkBehaviour)val).IsOwner)
				{
					SetIsKillingRpc(Random.Range(0, aud_buzz.Length));
					inKillAnimClient = true;
					((MonoBehaviour)this).StartCoroutine(PlayerKillSequence());
				}
			}
		}

		private IEnumerator PlayerKillSequence()
		{
			PlayerControllerB player = GameNetworkManager.Instance.localPlayerController;
			player.StopHoldInteractionOnTrigger();
			killCamAnimator.SetTrigger("KillCam");
			StartOfRound.Instance.SwitchCamera(killCam);
			((Behaviour)killCam).enabled = true;
			((Behaviour)killCamLight).enabled = true;
			base.creatureAnimator.speed = 999f;
			Vector3 dir = player.thisPlayerBody.position - ((Component)this).transform.position;
			dir.y = 0f;
			player.thisPlayerBody.rotation = Quaternion.LookRotation(dir);
			((Renderer)player.thisPlayerModelArms).enabled = false;
			yield return (object)new WaitForSeconds(1f);
			base.creatureAnimator.speed = 1f;
			((Behaviour)killCam).enabled = false;
			((Behaviour)killCamLight).enabled = false;
			inKillAnimClient = false;
			Vector3 launchDir = Vector3.Normalize(player.thisPlayerBody.position - ((Component)this).transform.position);
			launchDir.y = 0f;
			player.KillPlayer(launchDir * -50f, true, (CauseOfDeath)0, 0, default(Vector3), false);
		}

		private bool VisibleByAnyPlayer()
		{
			//IL_003a: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_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_0157: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true))
				{
					bool flag = val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.6f, 68f, 60, -1f, -1);
					bool flag2 = val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.3f + ((Component)this).transform.right * -0.7f, 68f, 60, -1f, -1);
					bool flag3 = val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.3f + ((Component)this).transform.right * 0.7f, 68f, 60, -1f, -1);
					bool flag4 = val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 2f, 68f, 60, -1f, -1);
					Vector3 val2 = ((Component)val.gameplayCamera).transform.position - base.eye.position;
					bool flag5 = ((Vector3)(ref val2)).sqrMagnitude > 0.09f;
					if ((flag || flag2) && flag5)
					{
						result = true;
					}
				}
			}
			return result;
		}

		public override void DoAIInterval()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: 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)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner && !isKilling)
			{
				if (currentState == State.Attacking && (Object)(object)base.targetPlayer == (Object)null)
				{
					SetStateRpc(State.Roaming);
				}
				if (currentState == State.Praising)
				{
					PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(360f, viewRange, base.eye, 0.3f, -1);
					if (currentState == State.Attacking && (allPlayersInLineOfSight == null || !allPlayersInLineOfSight.Contains(base.targetPlayer) || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)))
					{
						if ((Object)(object)base.targetPlayer == (Object)null)
						{
							praiseExitState = State.Roaming;
						}
						else
						{
							targetPosition = ((Component)base.targetPlayer).transform.position;
							praiseExitState = State.Chasing;
						}
					}
					else
					{
						praiseExitState = State.Attacking;
					}
				}
				if (IsAngry)
				{
					float num = viewAngle;
					if (currentState == State.Roaming)
					{
						num /= 1.3f;
					}
					PlayerControllerB[] allPlayersInLineOfSight2 = ((EnemyAI)this).GetAllPlayersInLineOfSight(num, viewRange, base.eye, 0.3f, -1);
					PlayerControllerB val = null;
					bool flag = false;
					if (currentState == State.Attacking)
					{
						if (allPlayersInLineOfSight2 == null)
						{
							AttackToChasing();
						}
						else if (!allPlayersInLineOfSight2.Contains(base.targetPlayer) || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
						{
							if (allPlayersInLineOfSight2.Length > 1)
							{
								flag = true;
								val = base.targetPlayer;
							}
							else
							{
								AttackToChasing();
							}
						}
					}
					else if (allPlayersInLineOfSight2 != null)
					{
						flag = true;
						SetStateRpc(State.Attacking);
					}
					if (flag && allPlayersInLineOfSight2 != null)
					{
						float num2 = 99999f;
						PlayerControllerB[] array = allPlayersInLineOfSight2;
						foreach (PlayerControllerB val2 in array)
						{
							if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 == (Object)(object)val))
							{
								Vector3 val3 = ((Component)val2.gameplayCamera).transform.position - base.eye.position;
								float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
								if (sqrMagnitude < num2)
								{
									num2 = sqrMagnitude;
									SetTarget(val2);
								}
							}
						}
					}
				}
				else if (currentState == State.Inviting)
				{
					SetTarget(((EnemyAI)this).GetClosestPlayer(false, false, false));
				}
				if (IsAngry && currentState != State.Attacking && (!((EnemyAI)this).GetPathDistance(targetPosition, ((Component)this).transform.position) || base.pathDistance < 0.05f))
				{
					if (currentState != State.Roaming)
					{
						SetStateRpc(State.Roaming);
					}
					SetTarget(null);
					GameObject[] array2 = ((!base.isOutside) ? RoundManager.Instance.insideAINodes : RoundManager.Instance.outsideAIDryNodes);
					targetPosition = array2[Random.Range(0, array2.Length)].transform.position;
				}
				ulong clientID = 99uL;
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					clientID = base.targetPlayer.actualClientId;
				}
				ReplicateTargetRpc(targetPosition, clientID);
			}
			((EnemyAI)this).DoAIInterval();
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void UpdateVoiceHearCooldownRpc()
		{
			//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_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1102268400u, val3, val, (SendTo)6, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 1102268400u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					speakHearDebounce = 0.5f;
				}
			}
		}

		public override void Update()
		{
			//IL_0152: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (((NetworkBehaviour)this).IsOwner && debug_mode && ((ButtonControl)Keyboard.current.pKey).wasPressedThisFrame)
			{
				debug_frozen = !debug_frozen;
				BaldiPlus.Logger.LogInfo((object)$"DEBUG - Set Baldi's frozen state to {debug_frozen}.");
			}
			if (speakHearDebounce > 0f)
			{
				speakHearDebounce -= Time.deltaTime;
			}
			if (currentStalkingQuoteCooldown > 0f)
			{
				currentStalkingQuoteCooldown -= Time.deltaTime;
			}
			if (currentKillCooldown > 0f)
			{
				currentKillCooldown -= Time.deltaTime;
				if (currentKillCooldown <= 0f)
				{
					isKilling = false;
				}
			}
			if (((NetworkBehaviour)this).IsOwner && slapReplicateDebounce > 0f)
			{
				slapReplicateDebounce -= Time.deltaTime;
			}
			if (currentState == State.Attacking && (Object)(object)base.targetPlayer != (Object)null)
			{
				targetPosition = ((Component)base.targetPlayer).transform.position;
			}
			else if (currentState == State.Inviting)
			{
				if (!taggedPlayer)
				{
					currentInvitingSpeed += inviteSpeedPerSecond * Time.deltaTime;
					if (VisibleByAnyPlayer())
					{
						if (!seenStalking)
						{
							seenStalking = true;
							if (Random.Range(0f, 1f) <= stalkingQuoteChance && currentStalkingQuoteCooldown <= 0f)
							{
								currentStalkingQuoteCooldown = stalkingQuoteCooldown;
								StartTalkingClientRpc(5, Random.Range(0, aud_stalk.Length));
							}
						}
						base.agent.speed = 0f;
					}
					else
					{
						seenStalking = false;
						base.agent.speed = currentInvitingSpeed;
					}
				}
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					targetPosition = ((Component)this).transform.position;
				}
				else
				{
					targetPosition = ((Component)base.targetPlayer).transform.position;
				}
			}
			((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
			if (audSrc_voice.isPlaying)
			{
				AudioClip clip = audSrc_voice.clip;
				int num = Mathf.CeilToInt((float)(audSrc_voice.timeSamples * clip.channels));
				int num2 = Mathf.CeilToInt(sampleHangTime * (float)clip.frequency * (float)clip.channels);
				float num3 = 0f;
				for (int i = lastSample - num2; i < num; i++)
				{
					if (i >= 0)
					{
						float num4 = Mathf.Abs(voiceSamples[i]);
						if (num4 > num3)
						{
							num3 = num4;
						}
					}
				}
				lastSample = num;
				meshObject.SetBlendShapeWeight(0, mouthSensitivity.Evaluate(num3) * 100f);
			}
			else
			{
				meshObject.SetBlendShapeWeight(0, 0f);
			}
			Vector3 val = Vector3.zero;
			bool flag = true;
			float num5 = 4f;
			if (inKillAnimClient)
			{
				num5 = 100f;
				val = ((Component)killCam).transform.position;
			}
			else if (IsAngry)
			{
				if (currentState == State.Attacking && (Object)(object)base.targetPlayer != (Object)null)
				{
					val = base.targetPlayer.playerEye.position;
				}
				else
				{
					val = targetPosition + Vector3.up * 1.2f;
					flag = ((EnemyAI)this).CheckLineOfSightForPosition(val, viewAngle, viewRange, 0.5f, base.eye);
				}
			}
			else if (currentState == State.Inviting || currentState == State.Praising)
			{
				PlayerControllerB val2 = ((currentState != State.Inviting || !((Object)(object)base.targetPlayer != (Object)null)) ? ((EnemyAI)this).CheckLineOfSightForClosestPlayer(viewAngle, viewRange, 1, 0f) : base.targetPlayer);
				if ((Object)(object)val2 != (Object)null)
				{
					val = val2.playerEye.position;
				}
				else
				{
					flag = false;
				}
			}
			else
			{
				flag = false;
			}
			Quaternion val4;
			Quaternion val6;
			if (flag)
			{
				Vector3 val3 = val - bone_head.position;
				val3.y = 0f;
				val4 = Quaternion.LookRotation(val3);
				Vector3 val5 = (bone_leftEye.position + bone_rightEye.position) / 2f;
				val6 = Quaternion.LookRotation(val - val5);
				val6 *= Quaternion.Euler(0f, -90f, -90f);
			}
			else
			{
				val4 = ((Component)this).transform.rotation;
				val6 = ((Component)this).transform.rotation * Quaternion.Euler(0f, -90f, -90f);
			}
			bone_head.rotation = Quaternion.Slerp(bone_head.rotation, val4, (num5 + base.agent.speed) * Time.deltaTime);
			bone_leftEye.rotation = val6;
			bone_rightEye.rotation = val6;
			if (!IsAngry)
			{
				return;
			}
			if (currentMoveTime > 0f)
			{
				if (((NetworkBehaviour)this).IsOwner && slapReplicateDebounce <= 0f)
				{
					slapReplicateDebounce += 0.05f;
					((EnemyAI)this).UpdateEnemyPositionRpc(((Component)this).transform.position);
				}
				currentMoveTime -= Time.deltaTime;
				if (currentMoveTime <= 0f)
				{
					base.agent.speed = 0f;
				}
			}
			if (((NetworkBehaviour)this).IsOwner && !isKilling)
			{
				anger += angerPerSecond * Time.deltaTime;
				if (!debug_frozen)
				{
					slapCooldown -= Time.deltaTime;
				}
				if (slapCooldown <= 0f)
				{
					BroadcastSlapRpc();
					slapInterval = speedCurve.Evaluate(anger);
					slapCooldown += slapInterval;
				}
				notebookTimer -= Time.deltaTime * (float)Math.Pow(intervalSlowdownFactor, activeNotebooks.Count);
				if (notebookTimer <= 0f)
				{
					notebookTimer += notebookSpawnInterval;
					SpawnNotebook();
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void SetIsKillingRpc(int buzzAudIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2978236524u, val3, val, (SendTo)6, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, buzzAudIndex);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2978236524u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				isKilling = true;
				currentKillCooldown = killCooldown;
				audSrc_sfx.PlayOneShot(aud_buzz[buzzAudIndex], BaldiPlus.PluginConfig.jumpscareVolume.Value * 0.75f);
				if (((NetworkBehaviour)this).IsOwner)
				{
					ModifyAnger(0f - angerReductionOnKill);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void SetStateRpc(State newState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1566548862u, val3, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<State>(ref newState, default(ForEnums));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 1566548862u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				BaldiPlus.Logger.LogDebug((object)("Baldi changed state to " + newState));
				if (((NetworkBehaviour)this).IsOwner && (newState == State.Attacking || newState == State.Roaming))
				{
					currentNoisePriority = 0f;
				}
				currentState = newState;
			}
		}

		[ClientRpc]
		public void PlayPraiseSequenceClientRpc(int clipIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2460707671u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, clipIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2460707671u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.creatureAnimator.SetBool("Happy", true);
					StartTalking(aud_praise[clipIndex]);
				}
			}
		}

		[ClientRpc]
		public void StartTalkingClientRpc(int clipType, int clipIndex = 0)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1699192549u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clipType);
				BytePacker.WriteValueBitPacked(val, clipIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1699192549u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				AudioClip val3 = null;
				switch (clipType)
				{
				case 0:
					val3 = aud_praise[clipIndex];
					break;
				case 1:
					val3 = aud_count[clipIndex];
					break;
				case 2:
					val3 = aud_finishCounting;
					break;
				case 3:
					val3 = aud_startCounting;
					break;
				case 4:
					val3 = aud_hear[clipIndex];
					break;
				case 5:
					val3 = aud_stalk[clipIndex];
					break;
				}
				if ((Object)(object)val3 != (Object)null)
				{
					StartTalking(val3);
				}
			}
		}

		[ClientRpc]
		public void ExitPraiseClientRpc()
		{
			//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_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(579584160u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 579584160u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.creatureAnimator.SetBool("Happy", false);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void ReplicateTargetRpc(Vector3 dest, ulong clientID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3187919427u, val3, val, (SendTo)1, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref dest);
				BytePacker.WriteValueBitPacked(val2, clientID);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3187919427u, val3, val, (SendTo)1, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (clientID == 99)
				{
					SetTarget(null);
				}
				else
				{
					SetTarget(BaldiPlus.GetPlayerByClientID(clientID));
				}
				targetPosition = dest;
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void BroadcastSlapRpc()
		{
			//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_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1357582101u, val3, val, (SendTo)6, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 1357582101u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					audSrc_sfx.PlayOneShot(aud_slap);
					base.creatureAnimator.SetTrigger("Slap");
					currentMoveTime = totalMoveTime;
					base.agent.speed = moveSpeed;
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1974329057u, new RpcReceiveHandler(__rpc_handler_1974329057), "ApplyConfigSettingsRpc");
			((NetworkBehaviour)this).__registerRpc(722856282u, new RpcReceiveHandler(__rpc_handler_722856282), "GiveOwnershipToServerRpc");
			((NetworkBehaviour)this).__registerRpc(529243842u, new RpcReceiveHandler(__rpc_handler_529243842), "HearNoiseRpc");
			((NetworkBehaviour)this).__registerRpc(1962367088u, new RpcReceiveHandler(__rpc_handler_1962367088), "StartCountingRpc");
			((NetworkBehaviour)this).__registerRpc(3044370750u, new RpcReceiveHandler(__rpc_handler_3044370750), "CountAnimSyncThingyRpc");
			((NetworkBehaviour)this).__registerRpc(1102268400u, new RpcReceiveHandler(__rpc_handler_1102268400), "UpdateVoiceHearCooldownRpc");
			((NetworkBehaviour)this).__registerRpc(2978236524u, new RpcReceiveHandler(__rpc_handler_2978236524), "SetIsKillingRpc");
			((NetworkBehaviour)this).__registerRpc(1566548862u, new RpcReceiveHandler(__rpc_handler_1566548862), "SetStateRpc");
			((NetworkBehaviour)this).__registerRpc(2460707671u, new RpcReceiveHandler(__rpc_handler_2460707671), "PlayPraiseSequenceClientRpc");
			((NetworkBehaviour)this).__registerRpc(1699192549u, new RpcReceiveHandler(__rpc_handler_1699192549), "StartTalkingClientRpc");
			((NetworkBehaviour)this).__registerRpc(579584160u, new RpcReceiveHandler(__rpc_handler_579584160), "ExitPraiseClientRpc");
			((NetworkBehaviour)this).__registerRpc(3187919427u, new RpcReceiveHandler(__rpc_handler_3187919427), "ReplicateTargetRpc");
			((NetworkBehaviour)this).__registerRpc(1357582101u, new RpcReceiveHandler(__rpc_handler_1357582101), "BroadcastSlapRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_1974329057(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_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)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float startingAnger = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref startingAnger, default(ForPrimitives));
				float num = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num, default(ForPrimitives));
				float angerLossOnKill = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref angerLossOnKill, default(ForPrimitives));
				float countInterval = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref countInterval, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).ApplyConfigSettingsRpc(startingAnger, num, angerLossOnKill, countInterval);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_529243842(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 origin = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref origin);
				BaldiHearing.NoiseType noise = default(BaldiHearing.NoiseType);
				((FastBufferReader)(ref reader)).ReadValueSafe<BaldiHearing.NoiseType>(ref noise, default(ForEnums));
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).HearNoiseRpc(origin, noise, playerRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3044370750(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int mode = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref mode);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).CountAnimSyncThingyRpc(mode);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_2978236524(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int isKillingRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref isKillingRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).SetIsKillingRpc(isKillingRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1566548862(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_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				State stateRpc = default(State);
				((FastBufferReader)(ref reader)).ReadValueSafe<State>(ref stateRpc, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).SetStateRpc(stateRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2460707671(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).PlayPraiseSequenceClientRpc(clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1699192549(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clipType = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipType);
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).StartTalkingClientRpc(clipType, clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3187919427(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 dest = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref dest);
				ulong clientID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BaldiEnemyAI)(object)target).ReplicateTargetRpc(dest, clientID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BaldiEnemyAI";
		}
	}
	public class NoiseData
	{
		public float priority;

		public float range;

		public float quoteChance;

		public string noiseType;

		public NoiseData(float priority, string noiseType = "Unknown", float range = 9999f, float quoteChance = 0.02f)
		{
			this.priority = priority;
			this.range = range;
			this.quoteChance = quoteChance;
			this.noiseType = noiseType;
		}
	}
	public class BaldiHearing : NetworkBehaviour
	{
		public enum NoiseType
		{
			Door,
			ItemDrop,
			PlayerSpeak,
			NoisemakerProp,
			BadMath
		}

		public static Dictionary<NoiseType, NoiseData> noiseData = new Dictionary<NoiseType, NoiseData>
		{
			{
				NoiseType.Door,
				new NoiseData(1f, "Door Open/Close", 150f)
			},
			{
				NoiseType.ItemDrop,
				new NoiseData(1.2f, "Item Dropped", 35f, 0.15f)
			},
			{
				NoiseType.PlayerSpeak,
				new NoiseData(3f, "Player Speak", 50f, 0.06f)
			},
			{
				NoiseType.NoisemakerProp,
				new NoiseData(3f, "Noisemaker Prop", 60f, 0.2f)
			},
			{
				NoiseType.BadMath,
				new NoiseData(50f, "Bad Math", 500f, -1f)
			}
		};

		public static void ActivateNoise(Vector3 origin, NoiseType noise, PlayerControllerB? player)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			NoiseData noiseData = BaldiHearing.noiseData[noise];
			BaldiEnemyAI[] array = Object.FindObjectsOfType<BaldiEnemyAI>();
			foreach (BaldiEnemyAI baldiEnemyAI in array)
			{
				if (!(noiseData.range > 5000f))
				{
					Vector3 val = ((Component)baldiEnemyAI).transform.position - origin;
					if (!((double)((Vector3)(ref val)).sqrMagnitude < Math.Pow(noiseData.range, 2.0)))
					{
						continue;
					}
				}
				if (noise == NoiseType.PlayerSpeak)
				{
					if (baldiEnemyAI.speakHearDebounce > 0f)
					{
						continue;
					}
					baldiEnemyAI.UpdateVoiceHearCooldownRpc();
				}
				BaldiPlus.Logger.LogDebug((object)("Baldi heard noise of type: " + noiseData.noiseType));
				baldiEnemyAI.HearNoiseRpc(origin, noise, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player));
			}
		}

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

		protected override void __initializeRpcs()
		{
			((NetworkBehaviour)this).__initializeRpcs();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BaldiHearing";
		}
	}
	public static class BaldiPlusKeys
	{
		public static readonly NamespacedKey<DawnEnemyInfo> BaldiEnemy = NamespacedKey<DawnEnemyInfo>.From("tmf_baldiplus", "baldi");
	}
	[BepInPlugin("tmf.baldiplus", "BaldiPlus", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BaldiPlus : BaseUnityPlugin
	{
		public static GameObject creditsCounterPrefab;

		public static BaldiPlus Instance { get; private set; } = null;

		internal static ManualLogSource Logger { get; private set; } = null;

		internal static Harmony? Harmony { get; set; }

		public static AssetBundle Assets { get; private set; } = null;

		public static string BaseAssetPath { get; private set; } = "Assets/Projects/BaldiPlus/";

		public static string AssemblyLocation { get; private set; } = null;

		internal static BaldiConfig PluginConfig { get; private set; } = null;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			BaldiInput.Instance = new BaldiInput();
			AssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Assets = AssetBundle.LoadFromFile(Path.Combine(AssemblyLocation, "tmf_baldiplus_assets"));
			PluginConfig = new BaldiConfig(((BaseUnityPlugin)this).Config);
			EnemyType val = Assets.LoadAsset<EnemyType>(BaseAssetPath + "BaldiPlus.asset");
			DawnEnemyInfo val2 = DawnLib.DefineEnemy(BaldiPlusKeys.BaldiEnemy, val, (Action<EnemyInfoBuilder>)delegate(EnemyInfoBuilder builder)
			{
				builder.DefineInside((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder locBuilder)
				{
					locBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(PluginConfig.baldiSpawnWeight.Value);
					});
				}).CreateBestiaryNode(ExtraData.baldiBestiary).CreateNameKeyword("Baldi");
			});
			DawnLib.RegisterNetworkPrefab(Assets.LoadAsset<GameObject>(BaseAssetPath + "NotebookPickup/NotebookPickup.prefab"));
			DawnLib.RegisterNetworkPrefab(Assets.LoadAsset<GameObject>(BaseAssetPath + "BaldiEnemyAssets/BaldiPlusEnemy.prefab"));
			TerminalNode bestiaryNode = val2.BestiaryNode;
			if ((Object)(object)bestiaryNode != (Object)null)
			{
				bestiaryNode.displayVideo = Assets.LoadAsset<VideoClip>(BaseAssetPath + "BaldiEnemyAssets/BestiaryBaldi.mp4");
				bestiaryNode.loadImageSlowly = true;
				bestiaryNode.playClip = Assets.LoadAsset<AudioClip>(BaseAssetPath + "BaldiEnemyAssets/Audio/BAL_Terminal.wav");
			}
			GameObject val3 = Assets.LoadAsset<GameObject>(BaseAssetPath + "UIAssets/CompanyCreditsPopup.prefab");
			creditsCounterPrefab = val3;
			Patch();
			Logger.LogInfo((object)"tmf.baldiplus v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("tmf.baldiplus");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		public static PlayerControllerB? GetPlayerByClientID(ulong clientID)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return null;
			}
			int num = -1;
			if (StartOfRound.Instance.ClientPlayerList.ContainsKey(clientID))
			{
				num = StartOfRound.Instance.ClientPlayerList[clientID];
				return StartOfRound.Instance.allPlayerScripts[num];
			}
			return null;
		}
	}
	internal class ExtraData
	{
		public static string baldiBestiary = "Sigurd's Danger Level: 99%\n\nScientific Name: Professor Baldimore\n\n\"Great teacher due to his incredible hearing abilities! He can not only tell where any sound came from, but who made it too!\"\n\nThis is the exact text we found in that other guy's office, and we struggle to understand what it truly means. He doesn't feel like anything we've seen before, as if he's from another realm of sorts. It's uncanny.\nAll we know is that he loves math, and has an odd obsession with giving us problems to solve. [MISSING] tried to reject his questions. None of us have seen him since. We did hear something resembling-\n[CONNECTION TERMINATED]\n\nOh, hi! Let's play hide and seek! We'll surely have LOTS of fun together!";
	}
	public class BaldiInput : LcInputActions
	{
		public static BaldiInput Instance;

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction keybind_nb_exit { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction keybind_nb_enter { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction keybind_nb_clear { get; set; }
	}
	internal static class InputUtilsCompat
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils");

		public static InputAction input_nb_exit => BaldiInput.Instance.keybind_nb_exit;

		public static InputAction input_nb_enter => BaldiInput.Instance.keybind_nb_enter;

		public static InputAction input_nb_clear => BaldiInput.Instance.keybind_nb_clear;
	}
	public class NotebookPickup : NetworkBehaviour
	{
		public enum Operators
		{
			Addition,
			Subtraction,
			Multiplication
		}

		public enum State
		{
			Idle,
			Opened,
			Completed
		}

		public struct QuestionObject : INetworkSerializable
		{
			public int num1;

			public int num2;

			public Operators equationOperator;

			public QuestionObject(int num1, int num2, Operators equationOperator)
			{
				this.num1 = num1;
				this.num2 = num2;
				this.equationOperator = equationOperator;
			}

			public string SerializeQuestion()
			{
				return $"{num1}{num2}{(int)equationOperator}";
			}

			public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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)
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num1, default(ForPrimitives));
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num2, default(ForPrimitives));
				((BufferSerializer<Operators>*)(&serializer))->SerializeValue<Operators>(ref equationOperator, default(ForEnums));
			}

			public override string ToString()
			{
				string arg = ((equationOperator == Operators.Addition) ? "+" : "-");
				return $"{num1} {arg} {num2}";
			}
		}

		public Animator animator;

		public BaldiEnemyAI parentBaldi;

		public float angerDecrease = 0.6f;

		[SerializeField]
		private InteractTrigger interact;

		[SerializeField]
		private List<Material> coverMats = new List<Material>();

		[SerializeField]
		private SkinnedMeshRenderer meshRenderer;

		private ulong activeClientID;

		private PlayerControllerB activePlayer;

		public QuestionObject[] questions = new QuestionObject[3];

		public State currentState = State.Idle;

		public int completedQuestions = 0;

		public bool inMinigame = false;

		private NotebookMinigame minigameRef;

		[SerializeField]
		private GameObject minigamePrefab;

		[SerializeField]
		private AudioSource audioSource;

		[SerializeField]
		private AudioClip aud_correct;

		[SerializeField]
		private AudioClip aud_incorrect;

		[SerializeField]
		private AudioClip aud_open;

		[SerializeField]
		private AudioClip aud_collect;

		[SerializeField]
		private AudioClip aud_wow;

		private float completeNotebookBonus = 1f;

		private float failNotebookPenalty = 1.2f;

		[HideInInspector]
		public bool restoreStamina = true;

		[HideInInspector]
		public bool disableStaminaRegen = true;

		[HideInInspector]
		public int bonusCredits = 25;

		private Terminal terminal;

		private void SetQuestions()
		{
			string[] array = new string[3];
			for (int i = 0; i < 3; i++)
			{
				int num = Random.Range(0, 10);
				int num2 = Random.Range(0, 10);
				Operators equationOperator = (Operators)Random.Range(0, 2);
				QuestionObject questionObject = new QuestionObject(num, num2, equationOperator);
				questions[i] = questionObject;
				array[i] = questionObject.SerializeQuestion();
			}
			SetQuestionsClientRpc(questions);
		}

		private void Start()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				terminal = Object.FindObjectOfType<Terminal>();
				int coverMatClientRpc = Random.Range(0, coverMats.Count);
				SetCoverMatClientRpc(coverMatClientRpc);
				SetQuestions();
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				ApplyConfigSettingsRpc(BaldiPlus.PluginConfig.completedNotebookBonus.Value, BaldiPlus.PluginConfig.failedNotebookPenalty.Value, BaldiPlus.PluginConfig.restoreStaminaNotebook.Value, BaldiPlus.PluginConfig.disableRegenNotebook.Value, BaldiPlus.PluginConfig.notebookCreditBonus.Value);
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ApplyConfigSettingsRpc(float completeBonus, float failPenalty, bool stamina, bool regen, int credits)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2243353694u, val3, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref completeBonus, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref failPenalty, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref stamina, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref regen, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, credits);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 2243353694u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					completeNotebookBonus = completeBonus;
					failNotebookPenalty = failPenalty;
					restoreStamina = stamina;
					disableStaminaRegen = regen;
					bonusCredits = credits;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ShowBonusCreditsRpc()
		{
			//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_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2351492376u, val3, val, (SendTo)6, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val2, 2351492376u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					CreditCounter.Instance.PlayCreditsAnim(bonusCredits);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayAudioServerRpc(int clipIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result