using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
[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("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Manny204553")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BaldiEnemy")]
[assembly: AssemblyTitle("BaldiEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BaldiEnemy
{
[BepInPlugin("Manny204553.BaldiEnemy", "BaldiEnemy", "1.0")]
public class BaldiEnemy : BaseUnityPlugin
{
internal static BaldiEnemy Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}
namespace BaldiEnemy.AI
{
public class EnemyBaldi : MonoBehaviour
{
public enum State
{
Spawn,
Idle,
Roam,
Investigate,
TargetPlayer,
SeekPlayer,
Attack,
StuckAttack,
Stun,
Leave,
Despawn
}
[Header("References")]
internal Enemy enemy;
private PhotonView photonView;
private NavMeshAgent agent;
internal PlayerAvatar targetPlayer;
public Transform eyeLocation;
internal bool isOnScreen;
internal bool attackImpulse;
internal bool deathImpulse;
[Header("Idle Break")]
public float idleBreakTimeMin = 45f;
public float idleBreakTimeMax = 90f;
private float idleBreakTimer;
internal bool idleBreakTrigger;
[Space]
public SpringQuaternion rotationSpring;
private Quaternion rotationTarget;
public State currentState;
private float stateTimer;
private bool stateImpulse;
private Vector3 targetPosition;
private Vector3 agentDestination;
private float overrideAgentLerp;
private float grabAggroTimer;
public bool db;
public float baseTime;
public float speed;
private float currentSpeed;
public Vector2 WaitDuration;
public Vector2 WaitMaxDuration;
public float MaxLevelProgression;
public ParticleSystem[] deathParticles;
private PhotonView _photonView;
public float timeToMove;
public float baldiAnger;
public float baldiTempAnger;
public float baldiWait;
public float baldiSpeedScale;
private float moveFrames;
public float angerRate;
public float angerRateRate;
public float angerFrequency;
public float timeToAnger;
[Header("Sounds")]
public Sound sfxSlap;
public Sound sfxChatter;
public Vector2 ChatterRange;
private float ChatterDuration;
public Sound sfxDeath;
public Sound sfxOuch;
public Sound sfxScreech;
public Sound sfxScreechGlobal;
public Animator baldiAnimator;
public float coolDown;
private Vector3 previous;
private void Awake()
{
enemy = ((Component)this).GetComponent<Enemy>();
photonView = ((Component)this).GetComponent<PhotonView>();
agent = ((Component)this).GetComponent<NavMeshAgent>();
_photonView = ((Component)this).GetComponent<PhotonView>();
if (!Object.op_Implicit((Object)(object)enemy))
{
Debug.LogError((object)("Missing Enemy component on " + ((Object)((Component)this).gameObject).name), (Object)(object)((Component)this).gameObject);
}
else if (!Object.op_Implicit((Object)(object)photonView))
{
Debug.LogError((object)("Missing PhotonView on " + ((Object)((Component)this).gameObject).name), (Object)(object)((Component)this).gameObject);
}
else if (!Object.op_Implicit((Object)(object)agent))
{
Debug.LogError((object)("Missing NavMeshAgent on " + ((Object)((Component)this).gameObject).name), (Object)(object)((Component)this).gameObject);
}
else
{
idleBreakTimer = Random.Range(idleBreakTimeMin, idleBreakTimeMax);
}
}
private void Start()
{
timeToMove = baseTime * Random.Range(0f, 1f);
GetAngry(0f);
ChatterDuration = Random.Range(ChatterRange.x, ChatterRange.y);
}
private void Update()
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Invalid comparison between Unknown and I4
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMasterClientOrSingleplayer() || (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
{
return;
}
int num = RoundDirector.instance.extractionPoints - 1;
int extractionPointsCompleted = RoundDirector.instance.extractionPointsCompleted;
float num2 = (float)num / Mathf.Max((float)extractionPointsCompleted, 1f);
if (num2 != baldiAnger)
{
GetAngry(num2);
}
if (enemy.IsStunned())
{
UpdateState(State.Stun);
}
else if ((int)enemy.CurrentState == 11)
{
UpdateState(State.Despawn);
}
switch (currentState)
{
case State.Stun:
StateStun();
break;
}
if (ChatterDuration <= 0f)
{
ChatterDuration = Random.Range(ChatterRange.x, ChatterRange.y);
Vector3 position = ((Component)this).transform.position;
if (GameManager.Multiplayer())
{
photonView.RPC("RPC_Chatter", (RpcTarget)0, new object[1] { position });
}
else
{
RPC_Chatter(position);
}
}
else
{
ChatterDuration -= Time.deltaTime;
}
if (idleBreakTimer >= 0f)
{
idleBreakTimer -= Time.deltaTime;
if (idleBreakTimer <= 0f && CanIdleBreak())
{
IdleBreak();
idleBreakTimer = Random.Range(idleBreakTimeMin, idleBreakTimeMax);
}
}
enemy.NavMeshAgent.OverrideAgent(currentSpeed, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
enemy.Rigidbody.OverrideFollowPosition(1f, enemy.Rigidbody.positionSpeedChase, -1f);
FindNearestPlayer();
if ((Object)(object)targetPlayer != (Object)null)
{
agent.SetDestination(((Component)targetPlayer).transform.position);
RotateTowardTarget();
}
if (timeToMove > 0f)
{
timeToMove -= Time.deltaTime;
}
else
{
Move();
}
if (coolDown > 0f)
{
coolDown -= Time.deltaTime;
}
if (baldiTempAnger > 0f)
{
baldiTempAnger -= 0.02f * Time.deltaTime;
}
else
{
baldiTempAnger = 0f;
}
}
private void FixedUpdate()
{
if (moveFrames > 0f)
{
moveFrames -= 1f;
currentSpeed = speed;
}
else
{
currentSpeed = 0f;
}
}
private void Move()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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)
Vector3 position = ((Component)this).transform.position;
moveFrames = 10f;
timeToMove = baldiWait - baldiTempAnger;
previous = position;
if (GameManager.Multiplayer())
{
photonView.RPC("RPC_PlaySlap", (RpcTarget)0, new object[1] { position });
}
else
{
RPC_PlaySlap(position);
}
}
public void GetAngry(float value)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Clamp01((float)RunManager.instance.levelsCompleted / MaxLevelProgression);
Vector2 val = Vector2.Lerp(WaitDuration, WaitMaxDuration, num);
baldiAnger = value;
baldiWait = Mathf.Lerp(val.x, val.y, baldiAnger);
}
private void FindNearestPlayer()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
float num = float.MaxValue;
PlayerAvatar val = null;
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
if ((Object)(object)player != (Object)null && !player.isDisabled)
{
float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position);
if (num2 < num)
{
num = num2;
val = player;
}
}
}
targetPlayer = val;
}
private void RotateTowardTarget()
{
//IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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)
if ((Object)(object)targetPlayer != (Object)null)
{
Vector3 val = ((Component)targetPlayer).transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
Quaternion val2 = Quaternion.LookRotation(new Vector3(normalized.x, 0f, normalized.z));
rotationTarget = val2;
((Component)this).transform.rotation = rotationTarget;
}
}
private bool CanIdleBreak()
{
return true;
}
private void IdleBreak()
{
if (GameManager.Multiplayer())
{
photonView.RPC("IdleBreakRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
IdleBreakRPC();
}
}
internal void UpdateState(State _state)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && currentState != _state)
{
currentState = _state;
stateImpulse = true;
stateTimer = 0f;
if (GameManager.Multiplayer())
{
photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
}
else
{
UpdateStateRPC(currentState);
}
}
}
public void OnSpawn()
{
}
public void OnHurt()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)this).transform.position;
if (GameManager.Multiplayer())
{
photonView.RPC("RPC_Hurt", (RpcTarget)0, new object[1] { position });
}
else
{
RPC_Hurt(position);
}
if (SemiFunc.IsMasterClientOrSingleplayer() && currentState == State.Leave)
{
UpdateState(State.Idle);
}
}
public void DeathParticlesImpulse()
{
ParticleSystem[] array = deathParticles;
for (int i = 0; i < array.Length; i++)
{
array[i].Play();
}
}
public void OnDeath()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0032: Unknown result type (might be due to invalid IL or missing references)
deathImpulse = true;
Vector3 position = ((Component)this).transform.position;
if (GameManager.Multiplayer())
{
photonView.RPC("RPC_Death", (RpcTarget)0, new object[1] { position });
}
else
{
RPC_Death(position);
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
enemy.EnemyParent.SpawnedTimerSet(0f);
enemy.EnemyParent.Despawn();
}
}
public void OnVision()
{
}
public void OnInvestigate()
{
}
public void OnGrabbed()
{
if (SemiFunc.IsMasterClientOrSingleplayer() && !(grabAggroTimer > 0f) && currentState == State.Leave)
{
grabAggroTimer = 60f;
targetPlayer = enemy.Vision.onVisionTriggeredPlayer;
UpdateState(State.TargetPlayer);
if (GameManager.Multiplayer())
{
photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { targetPlayer.photonView.ViewID });
}
else
{
TargetPlayerRPC(targetPlayer.photonView.ViewID);
}
}
}
private void StateStun()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (stateImpulse)
{
enemy.NavMeshAgent.ResetPath();
enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position);
stateImpulse = false;
}
if (!enemy.IsStunned())
{
UpdateState(State.Idle);
}
}
[PunRPC]
private void RPC_Screech(Vector3 pos)
{
//IL_0007: 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_005c: 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)
sfxScreech.Play(pos, 1f, 1f, 1f, 1f);
sfxScreechGlobal.Play(pos, 1f, 1f, 1f, 1f);
GameDirector.instance.CameraShake.ShakeDistance(5f, 3f, 8f, pos, 0.5f);
GameDirector.instance.CameraImpact.ShakeDistance(5f, 3f, 8f, pos, 0.1f);
}
[PunRPC]
private void RPC_Chatter(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
sfxChatter.Play(pos, 1f, 1f, 1f, 1f);
}
[PunRPC]
private void RPC_Hurt(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
sfxOuch.Play(pos, 1f, 1f, 1f, 1f);
}
[PunRPC]
private void RPC_Death(Vector3 pos)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
DeathParticlesImpulse();
sfxDeath.Play(pos, 1f, 1f, 1f, 1f);
}
public void PlayScreech()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)this).transform.position;
if (GameManager.Multiplayer())
{
photonView.RPC("RPC_Screech", (RpcTarget)0, new object[1] { position });
}
else
{
RPC_Screech(position);
}
}
[PunRPC]
private void RPC_PlaySlap(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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)
sfxSlap.Play(pos, 1f, 1f, 1f, 1f);
baldiAnimator.SetTrigger("slap");
GameDirector.instance.CameraShake.ShakeDistance(1f, 10f, 58f, pos, 0.25f);
GameDirector.instance.CameraImpact.ShakeDistance(1f, 10f, 50f, pos, 0.1f);
}
[PunRPC]
private void UpdateStateRPC(State _state)
{
currentState = _state;
stateImpulse = true;
}
[PunRPC]
private void TargetPlayerRPC(int _)
{
}
[PunRPC]
private void UpdateOnScreenRPC(bool _)
{
}
[PunRPC]
private void AttackImpulseRPC()
{
}
[PunRPC]
private void LookUnderAttackImpulseRPC()
{
}
[PunRPC]
private void IdleBreakRPC()
{
}
}
}