using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
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: AssemblyCompany("VyrusGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9f0d30e2d959c7c4eb74f4a4b3744becd24e8a78")]
[assembly: AssemblyProduct("PuppetEnemy")]
[assembly: AssemblyTitle("PuppetEnemy")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 PuppetEnemy
{
[BepInPlugin("VyrusGames.PuppetEnemy", "PuppetEnemy", "1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class PuppetEnemy : BaseUnityPlugin
{
internal static PuppetEnemy 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;
}
Logger.LogInfo((object)"Patching PuppetEnemy...");
Logger.LogInfo((object)"Loading assets...");
LoadAssets();
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private static void LoadAssets()
{
AssetBundle val = LoadAssetBundle("puppet");
Logger.LogInfo((object)"Loaded Puppet asset bundle!");
Logger.LogInfo((object)"Loading Puppet enemy prefab...");
GameObject val2 = val.LoadAsset<GameObject>("Assets/REPO/Mods/plugins/PuppetEnemy/Enemy - Puppet.prefab");
NetworkPrefabs.RegisterNetworkPrefab(val2);
Logger.LogInfo((object)"Loading Puppet enemy setup...");
EnemySetup val3 = val.LoadAsset<EnemySetup>("Assets/REPO/Mods/plugins/PuppetEnemy/Enemy - Puppet.asset");
Enemies.RegisterEnemy(val3);
Logger.LogDebug((object)"Loaded Puppet enemy!");
}
public static AssetBundle LoadAssetBundle(string name)
{
Logger.LogDebug((object)("Loading Asset Bundle: " + name));
AssetBundle val = null;
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
return AssetBundle.LoadFromFile(text);
}
}
}
namespace PuppetEnemy.AI
{
public class EnemyPuppet : MonoBehaviour
{
public enum State
{
Spawn,
Idle,
Roam,
Curious,
Investigate,
Leave,
Stun
}
private Enemy _enemy;
private PhotonView _photonView;
private PlayerAvatar _targetPlayer;
private bool _stateImpulse;
private bool _deathImpulse;
private Quaternion _horizontalRotationTarget = Quaternion.identity;
private Vector3 _agentDestination;
private Vector3 _targetPosition;
private bool _hurtImpulse;
private float hurtLerp;
private int _hurtAmount;
private Material _hurtableMaterial;
private float _pitCheckTimer;
private bool _pitCheck;
private float _talkTimer;
private bool _talkImpulse;
[Header("State")]
[SerializeField]
public State currentState;
[SerializeField]
public float stateTimer;
[Header("Animation")]
[SerializeField]
private EnemyPuppetAnimationController animator;
[SerializeField]
private SkinnedMeshRenderer _renderer;
[SerializeField]
private AnimationCurve hurtCurve;
[Header("Rotation and LookAt")]
public SpringQuaternion horizontalRotationSpring;
public SpringQuaternion headLookAtSpring;
public Transform headLookAtTarget;
public Transform headLookAtSource;
private EnemyNavMeshAgent _navMeshAgent => EnemyUtil.GetEnemyNavMeshAgent(_enemy);
private EnemyRigidbody _rigidbody => EnemyUtil.GetEnemyRigidbody(_enemy);
private EnemyParent _enemyParent => EnemyUtil.GetEnemyParent(_enemy);
private EnemyVision _vision => EnemyUtil.GetEnemyVision(_enemy);
private EnemyStateInvestigate _investigate => EnemyUtil.GetEnemyStateInvestigate(_enemy);
public Enemy Enemy => _enemy;
public bool DeathImpulse
{
get
{
return _deathImpulse;
}
set
{
_deathImpulse = value;
}
}
private void Awake()
{
_enemy = ((Component)this).GetComponent<Enemy>();
_photonView = ((Component)this).GetComponent<PhotonView>();
_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
if ((Object)(object)_renderer != (Object)null)
{
_hurtableMaterial = ((Renderer)_renderer).sharedMaterial;
}
hurtCurve = AssetManager.instance.animationCurveImpact;
Debug.Log((object)"THE CHUD HAS ARRIVED!!");
}
private void Update()
{
if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
{
return;
}
if (!_enemy.IsStunned())
{
if (_enemy.IsStunned())
{
UpdateState(State.Stun);
}
switch (currentState)
{
case State.Spawn:
StateSpawn();
break;
case State.Idle:
StateIdle();
break;
case State.Roam:
StateRoam();
break;
case State.Curious:
StateCurious();
break;
case State.Investigate:
StateInvestigate();
break;
case State.Leave:
StateLeave();
break;
case State.Stun:
StateStun();
break;
default:
throw new ArgumentOutOfRangeException();
}
RotationLogic();
TargetingLogic();
}
HurtEffect();
if (_talkTimer > 0f)
{
_talkTimer -= Time.deltaTime;
}
else
{
_talkImpulse = true;
}
}
private void LateUpdate()
{
HeadLookAtLogic();
}
private void UpdateState(State _newState)
{
if (currentState != _newState)
{
currentState = _newState;
stateTimer = 0f;
_stateImpulse = true;
if (GameManager.Multiplayer())
{
_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
}
else
{
UpdateStateRPC(currentState);
}
}
}
[PunRPC]
private void UpdateStateRPC(State _state)
{
currentState = _state;
}
[PunRPC]
private void UpdatePlayerTargetRPC(int viewID)
{
foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
{
if (item.photonView.ViewID == viewID)
{
_targetPlayer = item;
break;
}
}
}
private void TargetingLogic()
{
//IL_002b: 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_0045: 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_004f: 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_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
if (currentState == State.Curious && Object.op_Implicit((Object)(object)_targetPlayer))
{
Vector3 val = ((Component)_targetPlayer).transform.position + ((Component)_targetPlayer).transform.forward * 1.5f;
if (_pitCheckTimer <= 0f)
{
_pitCheckTimer = 0.1f;
_pitCheck = !Physics.Raycast(val + Vector3.up, Vector3.down, 4f, LayerMask.GetMask(new string[1] { "Default" }));
}
else
{
_pitCheckTimer -= Time.deltaTime;
}
if (_pitCheck)
{
val = ((Component)_targetPlayer).transform.position;
}
_targetPosition = Vector3.Lerp(_targetPosition, val, 20f * Time.deltaTime);
}
}
private void RotationLogic()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_0091: 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_00c0: 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)
if (currentState == State.Spawn || currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate || currentState == State.Leave)
{
horizontalRotationSpring.speed = 5f;
horizontalRotationSpring.damping = 0.7f;
}
else
{
Vector3 val = EnemyUtil.GetAgentVelocity(_navMeshAgent);
val = ((Vector3)(ref val)).normalized;
if (((Vector3)(ref val)).magnitude > 0.1f)
{
val = EnemyUtil.GetAgentVelocity(_navMeshAgent);
_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
}
else
{
horizontalRotationSpring.speed = 10f;
horizontalRotationSpring.damping = 0.8f;
}
}
((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
}
private void HeadLookAtLogic()
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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)
//IL_0063: 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_0069: 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_007a: 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_008c: 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)
if (currentState == State.Curious && !_enemy.IsStunned() && currentState != State.Stun && Object.op_Implicit((Object)(object)_targetPlayer) && !EnemyUtil.IsPlayerDisabled(_targetPlayer))
{
Vector3 val = _targetPlayer.PlayerVisionTarget.VisionTransform.position - headLookAtTarget.position;
val = SemiFunc.ClampDirection(val, headLookAtTarget.forward, 60f);
headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, Quaternion.LookRotation(val), -1f);
}
else
{
headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, headLookAtTarget.rotation, -1f);
}
}
private void HurtEffect()
{
if (!_hurtImpulse)
{
return;
}
hurtLerp += 2.5f * Time.deltaTime;
hurtLerp = Mathf.Clamp01(hurtLerp);
if ((Object)(object)_hurtableMaterial != (Object)null)
{
_hurtableMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
}
if (hurtLerp > 1f)
{
_hurtImpulse = false;
if ((Object)(object)_hurtableMaterial != (Object)null)
{
_hurtableMaterial.SetFloat(_hurtAmount, 0f);
}
}
}
private void StateSpawn()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
_stateImpulse = false;
stateTimer = 2f;
}
if (stateTimer > 0f)
{
stateTimer -= Time.deltaTime;
}
else
{
UpdateState(State.Idle);
}
}
private void StateIdle()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
stateTimer = Random.Range(4f, 8f);
_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
_navMeshAgent.ResetPath();
}
if (!SemiFunc.EnemySpawnIdlePause())
{
stateTimer -= Time.deltaTime;
if (stateTimer <= 0f)
{
UpdateState(State.Roam);
}
if (SemiFunc.EnemyForceLeave(_enemy))
{
UpdateState(State.Leave);
}
}
}
private void StateRoam()
{
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_0090: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
bool flag = false;
_talkTimer = Random.Range(5f, 15f);
stateTimer = Random.Range(4f, 8f);
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;
}
EnemyUtil.SetNotMovingTimer(_rigidbody, 0f);
_stateImpulse = false;
}
else
{
_navMeshAgent.SetDestination(_agentDestination);
if (EnemyUtil.GetNotMovingTimer(_rigidbody) > 2f)
{
stateTimer -= Time.deltaTime;
}
if (stateTimer <= 0f)
{
UpdateState(State.Idle);
}
}
if (SemiFunc.EnemyForceLeave(_enemy))
{
UpdateState(State.Leave);
}
if (_talkImpulse)
{
_talkImpulse = false;
animator.PlayRoamSound();
_talkTimer = Random.Range(15f, 20f);
}
}
private void StateCurious()
{
//IL_0045: 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_0104: 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_0121: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
stateTimer = Random.Range(24f, 30f);
_talkTimer = Random.Range(5f, 15f);
}
_navMeshAgent.SetDestination(_targetPosition);
stateTimer -= Time.deltaTime;
_vision.StandOverride(0.25f);
if (stateTimer <= 0f || !Object.op_Implicit((Object)(object)_targetPlayer) || EnemyUtil.IsPlayerDisabled(_targetPlayer))
{
UpdateState(State.Idle);
return;
}
if (_talkImpulse)
{
_talkImpulse = false;
animator.PlayCuriousSound();
_talkTimer = Random.Range(15f, 20f);
}
NavMeshHit val = default(NavMeshHit);
if (_navMeshAgent.CanReach(_targetPosition, 1f) && Vector3.Distance(((Component)_rigidbody).transform.position, _navMeshAgent.GetPoint()) < 2f && !NavMesh.SamplePosition(_targetPosition, ref val, 0.5f, -1))
{
UpdateState(State.Roam);
}
}
private void StateInvestigate()
{
//IL_0045: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_stateImpulse = false;
stateTimer = Random.Range(24f, 30f);
_talkTimer = Random.Range(5f, 15f);
}
_navMeshAgent.SetDestination(_targetPosition);
stateTimer -= Time.deltaTime;
_vision.StandOverride(0.25f);
if (stateTimer <= 0f)
{
UpdateState(State.Idle);
return;
}
if (_talkImpulse)
{
_talkImpulse = false;
animator.PlayVisionSound();
_talkTimer = Random.Range(15f, 20f);
}
NavMeshHit val = default(NavMeshHit);
if (_navMeshAgent.CanReach(_targetPosition, 1f) && Vector3.Distance(((Component)_rigidbody).transform.position, _navMeshAgent.GetPoint()) < 2f && !NavMesh.SamplePosition(_targetPosition, ref val, 0.5f, -1))
{
UpdateState(State.Roam);
}
}
private void StateLeave()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: 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_0063: 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_0087: 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_0096: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_0101: Unknown result type (might be due to invalid IL or missing references)
if (_stateImpulse)
{
_talkTimer = Random.Range(5f, 15f);
stateTimer = 5f;
bool flag = false;
LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false);
if (!Object.op_Implicit((Object)(object)val))
{
val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
}
NavMeshHit val2 = default(NavMeshHit);
if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 1f, 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)
{
_enemy.NavMeshAgent.SetDestination(_agentDestination);
EnemyUtil.SetNotMovingTimer(_rigidbody, 0f);
_stateImpulse = false;
}
}
else
{
if (EnemyUtil.GetNotMovingTimer(_rigidbody) > 2f)
{
stateTimer -= Time.deltaTime;
}
SemiFunc.EnemyCartJump(_enemy);
if (Vector3.Distance(((Component)this).transform.position, _agentDestination) < 1f || stateTimer <= 0f)
{
SemiFunc.EnemyCartJumpReset(_enemy);
UpdateState(State.Idle);
}
}
if (_talkImpulse)
{
_talkImpulse = false;
animator.PlayRoamSound();
_talkTimer = Random.Range(15f, 20f);
}
}
private void StateStun()
{
if (_stateImpulse)
{
_stateImpulse = false;
}
if (!_enemy.IsStunned())
{
UpdateState(State.Idle);
}
}
public void OnSpawn()
{
if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
{
UpdateState(State.Spawn);
}
}
public void OnInvestigate()
{
//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)
if (SemiFunc.IsMasterClientOrSingleplayer() && (currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate))
{
_targetPosition = EnemyUtil.GetOnInvestigateTriggeredPosition(_investigate);
UpdateState(State.Investigate);
}
}
public void OnVision()
{
if ((currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate) && !_enemy.IsStunned() && SemiFunc.IsMasterClientOrSingleplayer())
{
_targetPlayer = EnemyUtil.GetVisionTriggeredPlayer(_vision);
if (SemiFunc.IsMultiplayer())
{
_photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { _photonView.ViewID });
}
UpdateState(State.Curious);
animator.PlayVisionSound();
}
}
public void OnHurt()
{
_hurtImpulse = true;
animator.PlayHurtSound();
}
public void OnDeath()
{
_deathImpulse = true;
animator.PlayDeathSound();
if (SemiFunc.IsMasterClientOrSingleplayer())
{
_enemyParent.SpawnedTimerSet(0f);
}
}
}
public class EnemyPuppetAnimationController : MonoBehaviour
{
[Header("References")]
public EnemyPuppet controller;
public Animator animator;
[Header("Particles")]
public ParticleSystem[] deathParticles;
[Header("Sounds")]
[SerializeField]
private Sound roamSounds;
[SerializeField]
private Sound visionSounds;
[SerializeField]
private Sound curiousSounds;
[SerializeField]
private Sound hurtSounds;
[SerializeField]
private Sound deathSound;
private void Awake()
{
animator = ((Component)this).GetComponent<Animator>();
}
private void Update()
{
//IL_0063: 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)
if (controller.DeathImpulse)
{
controller.DeathImpulse = false;
animator.SetTrigger("Dies");
}
if (!controller.Enemy.IsStunned())
{
Animator obj = animator;
Vector3 agentVelocity = EnemyUtil.GetAgentVelocity(EnemyUtil.GetEnemyNavMeshAgent(controller.Enemy));
obj.SetFloat("Walking", ((Vector3)(ref agentVelocity)).magnitude);
}
}
public void SetDespawn()
{
EnemyUtil.GetEnemyParent(controller.Enemy).Despawn();
}
public void DeathParticlesImpulse()
{
ParticleSystem[] array = deathParticles;
for (int i = 0; i < array.Length; i++)
{
array[i].Play();
}
}
public void PlayRoamSound()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
roamSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
public void PlayVisionSound()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
visionSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
public void PlayCuriousSound()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
curiousSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
public void PlayHurtSound()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
hurtSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
public void PlayDeathSound()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
deathSound.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
}
}
public class EnemyUtil
{
public static EnemyNavMeshAgent GetEnemyNavMeshAgent(Enemy enemy)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("NavMeshAgent", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (EnemyNavMeshAgent)field.GetValue(enemy);
}
Debug.LogError((object)"NavMeshAgent field not found!");
return null;
}
public static EnemyRigidbody GetEnemyRigidbody(Enemy enemy)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("Rigidbody", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (EnemyRigidbody)field.GetValue(enemy);
}
Debug.LogError((object)"Rigidbody field not found!");
return null;
}
public static EnemyParent GetEnemyParent(Enemy enemy)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("EnemyParent", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (EnemyParent)field.GetValue(enemy);
}
Debug.LogError((object)"EnemyParent field not found!");
return null;
}
public static EnemyVision GetEnemyVision(Enemy enemy)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("Vision", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (EnemyVision)field.GetValue(enemy);
}
Debug.LogError((object)"Vision field not found!");
return null;
}
public static EnemyStateInvestigate GetEnemyStateInvestigate(Enemy enemy)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("StateInvestigate", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (EnemyStateInvestigate)field.GetValue(enemy);
}
Debug.LogError((object)"StateInvestigate field not found!");
return null;
}
public static bool IsEnemyJumping(Enemy enemy)
{
Type type = ((object)enemy).GetType();
FieldInfo field = type.GetField("Jump", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
Type fieldType = field.FieldType;
FieldInfo field2 = fieldType.GetField("jumping", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 != null)
{
return (bool)field2.GetValue(field.GetValue(enemy));
}
Debug.LogError((object)"Jumping field not found!");
return false;
}
Debug.LogError((object)"Jump field not found!");
return false;
}
public static bool IsPlayerDisabled(PlayerAvatar playerTarget)
{
Type type = ((object)playerTarget).GetType();
FieldInfo field = type.GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (bool)field.GetValue(playerTarget);
}
Debug.LogError((object)"isDisabled field not found!");
return false;
}
public static Vector3 GetAgentVelocity(EnemyNavMeshAgent agent)
{
//IL_003d: 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_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references)
Type type = ((object)agent).GetType();
FieldInfo field = type.GetField("AgentVelocity", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (Vector3)field.GetValue(agent);
}
Debug.LogError((object)"AgentVelocity field not found!");
return Vector3.zero;
}
public static Vector3 GetOnInvestigateTriggeredPosition(EnemyStateInvestigate investigate)
{
//IL_003d: 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_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references)
Type type = ((object)investigate).GetType();
FieldInfo field = type.GetField("onInvestigateTriggeredPosition", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (Vector3)field.GetValue(investigate);
}
Debug.LogError((object)"onInvestigateTriggeredPosition field not found!");
return Vector3.zero;
}
public static PlayerAvatar GetVisionTriggeredPlayer(EnemyVision vision)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Type type = ((object)vision).GetType();
FieldInfo field = type.GetField("onVisionTriggeredPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (PlayerAvatar)field.GetValue(vision);
}
Debug.LogError((object)"onVisionTriggeredPlayer field not found!");
return null;
}
public static float GetNotMovingTimer(EnemyRigidbody rb)
{
Type type = ((object)rb).GetType();
FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return (float)field.GetValue(rb);
}
Debug.LogError((object)"NotMovingTimer field not found!");
return 0f;
}
public static void SetNotMovingTimer(EnemyRigidbody rb, float value)
{
Type type = ((object)rb).GetType();
FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(rb, value);
}
else
{
Debug.LogError((object)"NotMovingTimer field not found!");
}
}
}
}