using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FreddyEnemy.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
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("OrtonLongGaming")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f7c2e6493a33ad6be0ce8a105a9aebcd720b8ea4")]
[assembly: AssemblyProduct("FreddyEnemy")]
[assembly: AssemblyTitle("FreddyEnemy")]
[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 FreddyEnemy
{
[BepInPlugin("OrtonLongGaming.FreddyEnemy", "FreddyEnemy", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FreddyEnemy : BaseUnityPlugin
{
public static EnemySetup Freddy;
public static ConfigEntry<bool> useFlashingScreen;
internal static FreddyEnemy 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;
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} is loading assets..");
LoadAssets();
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
SetConfigs();
}
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 LoadAssets()
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "freddy.bundle");
AssetBundle val = AssetBundle.LoadFromFile(text);
Freddy = val.LoadAsset<EnemySetup>("assets/FNAF/enemies/FreddyFazbear/Enemy - Freddy Fazbear.asset");
Enemies.RegisterEnemy(Freddy);
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded assets!");
}
internal void SetConfigs()
{
useFlashingScreen = ((BaseUnityPlugin)this).Config.Bind<bool>("FreddyEnemy", "UseFlashingScreen", true, "Use the flashing hallucination when Freddy's look-at state changes?");
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}
namespace FreddyEnemy.Utils
{
public class CloakTest : MonoBehaviour
{
public Transform revealPlane;
public Transform meshParent;
private List<Renderer> renderers;
private List<Material> sharedMaterials = new List<Material>();
private List<Material> instancedMaterials = new List<Material>();
[SerializeField]
private bool isCloaked;
[SerializeField]
private float cloakAmount;
public void TriggerCloak(bool cloak)
{
isCloaked = cloak;
}
public void ForceCloak(bool cloak)
{
cloakAmount = (cloak ? 5f : (-5f));
}
private void Update()
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
if (isCloaked)
{
cloakAmount = Mathf.Lerp(cloakAmount, 1f, Time.deltaTime * 2f);
if (cloakAmount > 0.99f)
{
cloakAmount = 1f;
}
}
else
{
cloakAmount = Mathf.Lerp(cloakAmount, 0f, Time.deltaTime * 2f);
if (cloakAmount < 0.01f)
{
cloakAmount = 0f;
}
}
Vector3 localPosition = Vector3.Lerp(-Vector3.forward, Vector3.forward, Mathf.Clamp01(cloakAmount));
revealPlane.localPosition = localPosition;
}
private void Awake()
{
renderers = new List<Renderer>();
if (Object.op_Implicit((Object)(object)meshParent))
{
renderers.AddRange(((Component)meshParent).GetComponentsInChildren<Renderer>(true));
}
foreach (Renderer renderer in renderers)
{
Material val = null;
foreach (Material sharedMaterial in sharedMaterials)
{
if (((Object)renderer.sharedMaterial).name == ((Object)sharedMaterial).name)
{
val = sharedMaterial;
renderer.sharedMaterial = instancedMaterials[sharedMaterials.IndexOf(sharedMaterial)];
}
}
if (!Object.op_Implicit((Object)(object)val))
{
val = renderer.sharedMaterial;
sharedMaterials.Add(val);
instancedMaterials.Add(renderer.material);
}
}
}
private void LateUpdate()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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)
foreach (Material instancedMaterial in instancedMaterials)
{
instancedMaterial.SetVector("_PlanePosition", Vector4.op_Implicit(((Component)revealPlane).transform.position));
instancedMaterial.SetVector("_PlaneNormal", Vector4.op_Implicit(((Component)revealPlane).transform.forward));
}
}
}
public class WearAndTear : MonoBehaviour
{
public List<GameObject> wearObjects = new List<GameObject>();
public List<float> wearObjectsHealthBelow = new List<float>();
public Enemy controller;
public Transform meshParent;
private List<Renderer> renderers;
private List<Material> sharedMaterials = new List<Material>();
private List<Material> instancedMaterials = new List<Material>();
private void Awake()
{
renderers = new List<Renderer>();
if (Object.op_Implicit((Object)(object)meshParent))
{
renderers.AddRange(((Component)meshParent).GetComponentsInChildren<Renderer>(true));
}
foreach (Renderer renderer in renderers)
{
if (renderer is ParticleSystemRenderer)
{
continue;
}
Material val = null;
foreach (Material sharedMaterial in sharedMaterials)
{
if (((Object)renderer.sharedMaterial).name == ((Object)sharedMaterial).name)
{
val = sharedMaterial;
renderer.sharedMaterial = instancedMaterials[sharedMaterials.IndexOf(sharedMaterial)];
}
}
if (!Object.op_Implicit((Object)(object)val))
{
val = renderer.sharedMaterial;
sharedMaterials.Add(val);
instancedMaterials.Add(renderer.material);
}
}
}
public void OnHurt()
{
float num = (float)controller.Health.healthCurrent / (float)controller.Health.health;
foreach (Material instancedMaterial in instancedMaterials)
{
float num2 = Mathf.Lerp(-1f, 0.1f, 1f - num);
instancedMaterial.SetFloat("_WearBalance", num2);
}
foreach (GameObject wearObject in wearObjects)
{
wearObject.SetActive(num < wearObjectsHealthBelow[wearObjects.IndexOf(wearObject)]);
}
}
}
}
namespace FreddyEnemy.AI
{
public class EnemyFreddy : MonoBehaviour
{
public enum State
{
Spawn,
Idle,
Roam,
Stalk,
Haywire,
Attack,
Stun,
Leave,
Despawn,
Investigate
}
private enum HaywireType
{
LookAway,
LookAt,
LookAtThenAway
}
private Enemy _enemy;
private PhotonView _photonView;
private PlayerAvatar _target;
private bool _stateImpulse;
private bool _deathImpulse;
private Vector3 _agentDestination;
[HideInInspector]
public bool idleBreakerTrigger;
public EnemyFreddyAnim animator;
public PhysGrabObject grabbable;
[Header("State")]
[SerializeField]
private State _state;
[SerializeField]
private float _stateTimer;
private float _stateInitTimer;
private float _stateFallbackTimer;
private float _stateLength;
[Header("Rotation")]
public SpringQuaternion rotationSpring;
private Quaternion rotationTarget;
[Space]
public SpringQuaternion headLookAtSpring;
public Transform headLookAtTarget;
public Transform headLookAtSource;
private float headLookAtLerp = 1f;
[Header("Cloak and Haywire")]
[SerializeField]
private CloakTest _cloakTest;
[SerializeField]
private Transform _eyeMesh;
private Material _eyeMaterial;
[SerializeField]
[ColorUsage(true, true)]
private Color stareColor;
[SerializeField]
[ColorUsage(true, true)]
private Color lookAwayColor;
[SerializeField]
private GameObject mouthLight;
private Color originalEyeAlbedoColor;
private HaywireType _haywireType;
private bool _haywireStare;
private bool onScreen;
public bool attackImpulse;
public bool swapImpulse;
public bool _despawnImpulse;
private int currHaywireCount = 0;
[Header("Hurt Collider")]
public GameObject hurtCollider;
private float hurtColliderTimer;
[Header("Hallucination")]
public Canvas hallucinationCanvas;
public Animator hallucinationAnimator;
[Header("Player Collider")]
public Collider playerCollider;
public Enemy Enemy => _enemy;
public PlayerAvatar Target => _target;
private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;
private EnemyRigidbody _rigidbody => _enemy.Rigidbody;
public State CurrentState => _state;
private void Awake()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
_enemy = ((Component)this).GetComponent<Enemy>();
_photonView = ((Component)this).GetComponent<PhotonView>();
_eyeMaterial = ((Component)_eyeMesh).GetComponent<Renderer>().material;
originalEyeAlbedoColor = _eyeMaterial.GetColor("_AlbedoColor");
}
private void Update()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Invalid comparison between Unknown and I4
HurtColliderLogic();
if ((!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) && LevelGenerator.Instance.Generated)
{
if (_enemy.IsStunned())
{
UpdateState(State.Stun);
}
else if ((int)_enemy.CurrentState == 11 && _state == State.Idle)
{
UpdateState(State.Despawn);
}
switch (_state)
{
case State.Spawn:
HandleSpawn();
break;
case State.Idle:
HandleIdle();
break;
case State.Roam:
HandleRoam();
break;
case State.Stalk:
HandleStalk();
break;
case State.Haywire:
HandleHaywire();
break;
case State.Attack:
HandleAttack();
break;
case State.Stun:
HandleStun();
break;
case State.Leave:
HandleLeave();
break;
case State.Despawn:
HandleDespawn();
break;
case State.Investigate:
HandleInvestigate();
break;
}
RotationLogic();
if (GameManager.Multiplayer())
{
_photonView.RPC("WalkAnimationRPC", (RpcTarget)0, new object[1] { ((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude });
}
else
{
WalkAnimationRPC(((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude);
}
}
}
private void LateUpdate()
{
SpringLogic();
}
private void SpringLogic()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)_target))
{
return;
}
float num = Vector3.Distance(_enemy.CenterTransform.position, ((Component)_target).transform.position);
if ((_state == State.Attack || _state == State.Stalk || _state == State.Haywire) && num < 5f)
{
headLookAtLerp = 0f;
Vector3 val = _target.PlayerVisionTarget.VisionTransform.position - headLookAtTarget.position;
val = SemiFunc.ClampDirection(val, headLookAtTarget.forward, 70f);
headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, Quaternion.LookRotation(val), -1f);
return;
}
headLookAtLerp += Time.deltaTime;
headLookAtLerp = Mathf.Clamp01(headLookAtLerp);
if (!Mathf.Approximately(1f, headLookAtLerp))
{
Vector3 val2 = _target.PlayerVisionTarget.VisionTransform.position - headLookAtTarget.position;
val2 = SemiFunc.ClampDirection(val2, headLookAtTarget.forward, 70f);
headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, Quaternion.Lerp(Quaternion.LookRotation(val2), headLookAtTarget.rotation, headLookAtLerp), -1f);
}
}
private void UpdateState(State state)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && _state != state)
{
_state = state;
_stateImpulse = true;
_stateTimer = 0f;
if (GameManager.Multiplayer())
{
_photonView.RPC("RPC_UpdateState", (RpcTarget)0, new object[1] { state });
}
else
{
RPC_UpdateState(state);
}
}
}
private void RotationLogic()
{
//IL_0040: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0070: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)_target) && (_state == State.Haywire || _state == State.Stalk || _state == State.Attack))
{
rotationTarget = Quaternion.LookRotation(((Component)_target).transform.position - ((Component)this).transform.position);
((Quaternion)(ref rotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref rotationTarget)).eulerAngles.y, 0f);
}
else if (((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude > 0.1f)
{
rotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
((Quaternion)(ref rotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref rotationTarget)).eulerAngles.y, 0f);
}
((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(rotationSpring, rotationTarget, -1f);
}
private void HandleLeave()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: 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_0129: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_target == (Object)null)
{
UpdateState(State.Roam);
return;
}
if (_stateImpulse)
{
_stateTimer = 1.5f;
_stateFallbackTimer = 8f;
currHaywireCount = 0;
bool flag = false;
LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)_target).transform.position, 10f, 25f, false);
if (!Object.op_Implicit((Object)(object)val))
{
val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)_target).transform.position, 5f);
}
NavMeshHit val2 = default(NavMeshHit);
if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
{
_agentDestination = ((NavMeshHit)(ref val2)).position;
flag = true;
}
if (flag)
{
_navMeshAgent.SetDestination(_agentDestination);
_rigidbody.notMovingTimer = 0f;
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { true });
}
else
{
CloakedRPC(cloak: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { false });
}
else
{
TogglePlayerCollision(collide: false);
}
_stateImpulse = false;
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeEmissionRPC", (RpcTarget)0, new object[1] { 0 });
}
else
{
EyeEmissionRPC(0);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeAlbedoRPC", (RpcTarget)0, new object[1] { false });
}
else
{
EyeAlbedoRPC(black: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("HaywireRPC", (RpcTarget)0, new object[1] { false });
}
else
{
HaywireRPC(animate: false);
}
}
return;
}
if (_rigidbody.notMovingTimer > 2f)
{
_stateTimer -= Time.deltaTime;
}
else
{
_stateFallbackTimer -= Time.deltaTime;
}
if (_stateTimer <= 0f || _stateFallbackTimer <= 0f)
{
if (GameManager.Multiplayer())
{
_photonView.RPC("GrabEnabledRPC", (RpcTarget)0, new object[1] { true });
}
else
{
GrabEnabledRPC(grab: true);
}
UpdateState(State.Roam);
}
}
private void HandleStun()
{
//IL_003b: 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);
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { false });
}
else
{
TogglePlayerCollision(collide: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("GrabEnabledRPC", (RpcTarget)0, new object[1] { true });
}
else
{
GrabEnabledRPC(grab: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { false });
}
else
{
CloakedRPC(cloak: false);
}
_stateImpulse = false;
}
if (!_enemy.IsStunned())
{
UpdateState(State.Roam);
}
}
private void HandleAttack()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
attackImpulse = true;
_enemy.StuckCount = 0;
if (GameManager.Multiplayer())
{
_photonView.RPC("AttackImpulseRPC", (RpcTarget)1, Array.Empty<object>());
}
_target.playerHealth.HurtOther(50, ((Component)_target).transform.position, false, SemiFunc.EnemyGetIndex(_enemy));
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("ActivateHurtColliderRPC", (RpcTarget)0, new object[1] { ((Component)_target).transform.position });
}
else
{
ActivateHurtColliderRPC(((Component)_target).transform.position);
}
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("FreddyZoomRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
FreddyZoomRPC();
}
_enemy.NavMeshAgent.ResetPath();
_enemy.NavMeshAgent.Warp(((Component)_enemy.Rigidbody).transform.position);
_stateTimer = 2f;
_stateImpulse = false;
return;
}
_enemy.NavMeshAgent.Stop(0.2f);
_stateTimer -= Time.deltaTime;
if (_stateTimer <= 0f)
{
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("DisableMouthLightRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
DisableMouthLightRPC();
}
UpdateState(State.Leave);
}
}
private void HandleHaywire()
{
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
swapImpulse = false;
currHaywireCount++;
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { false });
}
else
{
CloakedRPC(cloak: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { true });
}
else
{
TogglePlayerCollision(collide: true);
}
_stateInitTimer = 1f;
_stateTimer = Random.Range(1.5f, 3f) + _stateInitTimer;
_stateLength = _stateTimer;
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
float value = Random.value;
_haywireType = (HaywireType)Random.Range(0, 3);
_haywireStare = _haywireType != HaywireType.LookAway;
if (GameManager.Multiplayer())
{
_photonView.RPC("HaywireRPC", (RpcTarget)0, new object[1] { true });
}
else
{
HaywireRPC(animate: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("HallucinationRPC", (RpcTarget)0, new object[1] { _haywireStare });
}
else
{
HallucinationRPC(_haywireStare);
}
}
if (_stateInitTimer > 0f)
{
_stateInitTimer -= Time.deltaTime;
if (GameManager.Multiplayer())
{
_photonView.RPC("AttackLookatRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
AttackLookatRPC();
}
}
if (_stateTimer > 0f)
{
_stateTimer -= Time.deltaTime;
if (_haywireType == HaywireType.LookAtThenAway && _stateTimer <= _stateLength / 2f && !swapImpulse)
{
_haywireStare = false;
swapImpulse = true;
if (GameManager.Multiplayer())
{
_photonView.RPC("HallucinationRPC", (RpcTarget)0, new object[1] { _haywireStare });
}
else
{
HallucinationRPC(_haywireStare);
}
}
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeEmissionRPC", (RpcTarget)0, new object[1] { (!_haywireStare) ? 1 : 2 });
}
else
{
EyeEmissionRPC((!_haywireStare) ? 1 : 2);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeAlbedoRPC", (RpcTarget)0, new object[1] { true });
}
else
{
EyeAlbedoRPC(black: true);
}
onScreen = _enemy.OnScreen.GetOnScreen(_target);
if (GameManager.Multiplayer())
{
_photonView.RPC("HaywireFXRPC", (RpcTarget)0, new object[1] { _haywireStare });
}
else
{
HaywireFXRPC(_haywireStare);
}
}
else if (onScreen)
{
if (_haywireStare)
{
if (currHaywireCount >= Random.Range(2, 4))
{
UpdateState(State.Leave);
}
else
{
UpdateState(State.Stalk);
}
}
else
{
UpdateState(State.Attack);
}
}
else if (_haywireStare)
{
UpdateState(State.Attack);
}
else if (currHaywireCount >= Random.Range(2, 4))
{
UpdateState(State.Leave);
}
else
{
UpdateState(State.Stalk);
}
}
private void HandleStalk()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
_stateInitTimer = 1f;
_stateTimer = Random.Range(2f, 4f) + _stateInitTimer;
_stateFallbackTimer = 5f;
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
_rigidbody.OverrideFollowPosition(_stateTimer, 10f, 30f);
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { true });
}
else
{
CloakedRPC(cloak: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { false });
}
else
{
TogglePlayerCollision(collide: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("GrabEnabledRPC", (RpcTarget)0, new object[1] { false });
}
else
{
GrabEnabledRPC(grab: false);
}
}
if (_stateInitTimer > 0f)
{
_stateInitTimer -= Time.deltaTime;
}
else if (Object.op_Implicit((Object)(object)_target))
{
_navMeshAgent.Warp(((Component)_target).transform.position + -((Component)_target).transform.forward * 2.5f);
}
_stateTimer -= Time.deltaTime;
_enemy.Vision.StandOverride(0.25f);
if (!(_stateTimer <= 0f))
{
return;
}
float num = Vector3.Distance(_enemy.CenterTransform.position, ((Component)_target).transform.position);
bool flag = false;
Vector3 val = ((Component)_target.PlayerVisionTarget.VisionTransform).transform.position - _enemy.Vision.VisionTransform.position;
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(_enemy.Vision.VisionTransform.position, val);
RaycastHit val3 = default(RaycastHit);
Physics.Raycast(val2, ref val3, 10f, LayerMask.op_Implicit(Enemy.VisionMask));
flag = (((Component)((RaycastHit)(ref val3)).transform).CompareTag("Player") ? true : false);
if (num > 5f || !flag)
{
_stateFallbackTimer -= Time.deltaTime;
if (_stateFallbackTimer <= 0f)
{
if (GameManager.Multiplayer())
{
_photonView.RPC("GrabEnabledRPC", (RpcTarget)0, new object[1] { true });
}
else
{
GrabEnabledRPC(grab: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("HaywireRPC", (RpcTarget)0, new object[1] { false });
}
else
{
HaywireRPC(animate: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeEmissionRPC", (RpcTarget)0, new object[1] { 0 });
}
else
{
EyeEmissionRPC(0);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("EyeAlbedoRPC", (RpcTarget)0, new object[1] { false });
}
else
{
EyeAlbedoRPC(black: false);
}
currHaywireCount = 0;
UpdateState(State.Roam);
}
}
else if (!Object.op_Implicit((Object)(object)_target) || _target.isDisabled)
{
UpdateState(State.Roam);
}
else
{
UpdateState(State.Haywire);
}
}
private void HandleRoam()
{
//IL_0198: 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_0063: 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_008c: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_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)
if (_stateImpulse)
{
_enemy.StuckCount = 0;
bool flag = false;
_stateTimer = Random.Range(10f, 12f);
LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
if (!Object.op_Implicit((Object)(object)val))
{
val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
}
NavMeshHit val2 = default(NavMeshHit);
if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
{
_agentDestination = ((NavMeshHit)(ref val2)).position;
flag = true;
}
if (!flag)
{
return;
}
_rigidbody.notMovingTimer = 0f;
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { false });
}
else
{
CloakedRPC(cloak: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { true });
}
else
{
TogglePlayerCollision(collide: true);
}
_stateImpulse = false;
}
else
{
_navMeshAgent.SetDestination(_agentDestination);
if (_rigidbody.notMovingTimer > 2f)
{
_stateTimer -= Time.deltaTime;
}
if (_stateTimer <= 0f)
{
UpdateState(State.Idle);
}
}
if (SemiFunc.EnemyForceLeave(_enemy))
{
UpdateState(State.Idle);
}
}
private void HandleIdle()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
_stateTimer = Random.Range(5f, 7f);
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { false });
}
else
{
CloakedRPC(cloak: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { true });
}
else
{
TogglePlayerCollision(collide: true);
}
}
if (!SemiFunc.EnemySpawnIdlePause())
{
if (_stateTimer > 0f)
{
_stateTimer -= Time.deltaTime;
}
else
{
UpdateState(State.Roam);
}
if (SemiFunc.EnemyForceLeave(_enemy))
{
UpdateState(State.Leave);
}
}
}
private void HandleSpawn()
{
if (_stateImpulse)
{
_enemy.StuckCount = 0;
if (GameManager.Multiplayer())
{
_photonView.RPC("ForceCloakedRPC", (RpcTarget)0, new object[1] { true });
}
else
{
ForceCloakedRPC(cloak: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { false });
}
else
{
CloakedRPC(cloak: false);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { true });
}
else
{
TogglePlayerCollision(collide: true);
}
_stateImpulse = false;
_stateTimer = 5f;
}
if (_stateTimer > 0f)
{
_stateTimer -= Time.deltaTime;
}
else
{
UpdateState(State.Idle);
}
}
public void HandleDespawn()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
_despawnImpulse = false;
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
if (GameManager.Multiplayer())
{
_photonView.RPC("CloakedRPC", (RpcTarget)0, new object[1] { true });
}
else
{
CloakedRPC(cloak: true);
}
if (GameManager.Multiplayer())
{
_photonView.RPC("TogglePlayerCollision", (RpcTarget)0, new object[1] { false });
}
else
{
TogglePlayerCollision(collide: false);
}
_stateTimer = 2f;
}
if (_stateTimer > 0f)
{
_stateTimer -= Time.deltaTime;
}
else if (!_despawnImpulse)
{
_despawnImpulse = true;
_enemy.EnemyParent.Despawn();
}
}
public void HandleInvestigate()
{
//IL_0046: 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)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateTimer = 5f;
_enemy.Rigidbody.notMovingTimer = 0f;
_stateImpulse = false;
}
else
{
_enemy.NavMeshAgent.SetDestination(_agentDestination);
if (_enemy.Rigidbody.notMovingTimer > 2f)
{
_stateTimer -= Time.deltaTime;
}
if (_stateTimer <= 0f)
{
UpdateState(State.Idle);
return;
}
if (Vector3.Distance(((Component)this).transform.position, _agentDestination) < 2f)
{
UpdateState(State.Idle);
}
}
if (SemiFunc.EnemyForceLeave(_enemy))
{
UpdateState(State.Leave);
}
}
public void OnInvestigate()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClientOrSingleplayer() && (_state == State.Idle || _state == State.Roam || _state == State.Investigate))
{
_agentDestination = _enemy.StateInvestigate.onInvestigateTriggeredPosition;
UpdateState(State.Investigate);
}
}
public void OnSpawn()
{
if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
{
UpdateState(State.Spawn);
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("RPC_AnimateSpawn", (RpcTarget)0, Array.Empty<object>());
}
else
{
RPC_AnimateSpawn();
}
}
}
public void OnHurt()
{
animator.SfxHurt();
if (SemiFunc.IsMasterClientOrSingleplayer() && _state == State.Leave)
{
UpdateState(State.Roam);
}
}
public void OnDeath()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
animator.SfxDeath();
GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 10f, ((Component)this).transform.position, 0.5f);
GameDirector.instance.CameraImpact.ShakeDistance(3f, 3f, 10f, ((Component)this).transform.position, 0.05f);
if (SemiFunc.IsMasterClientOrSingleplayer())
{
_enemy.EnemyParent.Despawn();
}
}
public void OnSeenPlayer()
{
if (SemiFunc.IsMasterClientOrSingleplayer() && (_state == State.Idle || _state == State.Roam || _state == State.Investigate))
{
_target = _enemy.Vision.onVisionTriggeredPlayer;
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("RPC_UpdateTarget", (RpcTarget)0, new object[1] { _target.photonView.ViewID });
}
else
{
RPC_UpdateTarget(_target.photonView.ViewID);
}
UpdateState(State.Stalk);
}
}
private void HurtColliderLogic()
{
if (hurtColliderTimer > 0f)
{
hurtColliderTimer -= Time.deltaTime;
if (hurtColliderTimer <= 0f)
{
hurtCollider.SetActive(false);
}
}
}
public void IdleBreakerSet()
{
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("IdleBreakerSetRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
IdleBreakerSetRPC();
}
}
[PunRPC]
private void RPC_UpdateTarget(int targetViewID)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
{
if (item.photonView.ViewID == targetViewID)
{
_target = item;
break;
}
}
}
[PunRPC]
private void RPC_UpdateState(State state)
{
_state = state;
_stateImpulse = true;
_stateTimer = 0f;
}
[PunRPC]
private void AttackImpulseRPC()
{
attackImpulse = true;
}
[PunRPC]
public void ActivateHurtColliderRPC(Vector3 _position)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references)
hurtCollider.transform.position = _position;
hurtCollider.transform.rotation = Quaternion.LookRotation(_enemy.Vision.VisionTransform.position - _position);
hurtCollider.SetActive(true);
hurtColliderTimer = 0.25f;
}
[PunRPC]
private void HaywireRPC(bool animate)
{
animator.SetHaywire(animate);
}
[PunRPC]
private void RPC_AnimateSpawn()
{
animator.OnSpawn();
}
[PunRPC]
private void IdleBreakerSetRPC()
{
idleBreakerTrigger = true;
}
[PunRPC]
private void CloakedRPC(bool cloak)
{
_cloakTest.TriggerCloak(cloak);
}
[PunRPC]
private void ForceCloakedRPC(bool cloak)
{
_cloakTest.ForceCloak(cloak);
}
[PunRPC]
private void GrabEnabledRPC(bool grab)
{
((Behaviour)grabbable).enabled = grab;
}
[PunRPC]
private void EyeEmissionRPC(int state)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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)
_eyeMaterial.SetColor("_EmissionColor", (state > 1) ? stareColor : ((state == 1) ? lookAwayColor : Color.black));
}
[PunRPC]
private void EyeAlbedoRPC(bool black)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
_eyeMaterial.SetColor("_AlbedoColor", black ? Color.black : originalEyeAlbedoColor);
}
[PunRPC]
private void FreddyZoomRPC()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (_target.isLocal)
{
CameraGlitch.Instance.PlayShort();
CameraAim.Instance.AimTargetSet(_enemy.Vision.VisionTransform.position, 0.75f, 3f, ((Component)this).gameObject, 90);
CameraZoom.Instance.OverrideZoomSet(30f, 0.75f, 1f, 3f, ((Component)this).gameObject, 50);
}
mouthLight.SetActive(true);
}
[PunRPC]
private void DisableMouthLightRPC()
{
mouthLight.SetActive(false);
}
[PunRPC]
private void HallucinationRPC(bool stare)
{
if (_target.isLocal)
{
hallucinationCanvas.worldCamera = SemiFunc.MainCamera();
hallucinationAnimator.SetBool("LookAt", stare);
hallucinationAnimator.SetTrigger("Go");
}
}
[PunRPC]
private void AttackLookatRPC()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (_target.isLocal)
{
CameraAim.Instance.AimTargetSet(_enemy.Vision.VisionTransform.position, 0.1f, 3f, ((Component)this).gameObject, 90);
}
}
[PunRPC]
private void HaywireFXRPC(bool stare)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
SemiFunc.CameraShake(0.1f, 0.1f);
SemiFunc.PlayerEyesOverride(_target, _enemy.Vision.VisionTransform.position, 0.25f, ((Component)this).gameObject);
if (_target.isLocal && !stare)
{
SemiFunc.DoNotLookEffect(((Component)this).gameObject, true, true, true, true, true, false);
}
}
[PunRPC]
private void WalkAnimationRPC(float mag)
{
animator.AnimateWalk(mag);
}
[PunRPC]
private void TogglePlayerCollision(bool collide)
{
playerCollider.enabled = collide;
}
}
public class EnemyFreddyAnim : MonoBehaviour
{
private int haywire = Animator.StringToHash("haywiring");
private int walkSpeed = Animator.StringToHash("walking");
private int attack = Animator.StringToHash("attack");
private int spawn = Animator.StringToHash("spawn");
[SerializeField]
private Animator _animator;
[SerializeField]
private Enemy _enemy;
[SerializeField]
private EnemyFreddy controller;
[Header("SFX")]
[Header("One Shots")]
public Sound sfxAttackLocal;
public Sound sfxAttackGlobal;
public Sound sfxMove;
public Sound sfxHurt;
public Sound sfxDeath;
public Sound laughSound;
[Header("Loops")]
public Sound sfxStunnedLoop;
public Sound sfxHaywireLoop;
public Sound sfxCloakedLoop;
private bool stunned;
private bool cloaked;
private bool haywiring;
private float idleBreakerTimer;
private float storedMagnitude = 0f;
[Space(10f)]
[Header("Particle Systems")]
public ParticleSystem sparkParticles;
private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;
private EnemyRigidbody _rigidbody => _enemy.Rigidbody;
private void Update()
{
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
if (_rigidbody.frozen)
{
_animator.speed = 0f;
}
else
{
_animator.speed = 1f;
}
DamageLogic();
AnimationLogic();
stunned = controller.CurrentState == EnemyFreddy.State.Stun;
haywiring = controller.CurrentState == EnemyFreddy.State.Haywire;
cloaked = controller.CurrentState == EnemyFreddy.State.Stalk;
SfxStunnedLoop();
SfxHaywireLoop();
SfxCloakedLoop();
if (controller.CurrentState == EnemyFreddy.State.Roam || controller.CurrentState == EnemyFreddy.State.Idle || (controller.CurrentState == EnemyFreddy.State.Leave && SemiFunc.IsMasterClientOrSingleplayer()))
{
idleBreakerTimer += Time.deltaTime;
if (idleBreakerTimer > 10f)
{
idleBreakerTimer = 0f;
if (Random.Range(0, 100) < 35)
{
controller.IdleBreakerSet();
}
}
}
if (controller.idleBreakerTrigger)
{
laughSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
controller.idleBreakerTrigger = false;
}
}
private void DamageLogic()
{
float num = (float)_enemy.Health.healthCurrent / (float)_enemy.Health.health;
_animator.SetLayerWeight(1, 1f - num);
}
private void AnimationLogic()
{
if (controller.attackImpulse)
{
controller.attackImpulse = false;
if (!_enemy.IsStunned())
{
_animator.SetTrigger(attack);
}
}
}
public void SetHaywire(bool animate)
{
_animator.SetBool(haywire, animate);
}
public void OnSpawn()
{
_animator.SetTrigger(spawn);
}
public void SfxAttack()
{
//IL_000d: 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)
sfxAttackLocal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
sfxAttackGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
public void SfxMove()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (storedMagnitude > 0.1f)
{
sfxMove.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
public void SfxHurt()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
sfxHurt.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
public void SfxDeath()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
sfxDeath.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
public void SfxHaywireLoop()
{
sfxHaywireLoop.PlayLoop(haywiring, 5f, 5f, 1f);
}
public void SfxStunnedLoop()
{
sfxStunnedLoop.PlayLoop(stunned, 5f, 5f, 1f);
}
public void SfxCloakedLoop()
{
sfxCloakedLoop.PlayLoop(cloaked, 5f, 5f, 1f);
}
public void AnimateWalk(float mag)
{
_animator.SetFloat(walkSpeed, mag);
storedMagnitude = mag;
}
}
}