using System;
using System.Collections;
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 GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NBPCSDC.Sacha_Mod.NetcodePatcher;
using Sacha_Mod.Configuration;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NBPCSDC.Sacha_Mod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+3cf8c6938c495fc09d2003d8fd0872680c0fe921")]
[assembly: AssemblyProduct("Sacha_Mod")]
[assembly: AssemblyTitle("NBPCSDC.Sacha_Mod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Sacha_Mod
{
public class AudioPlay : MonoBehaviour
{
public AudioSource audioSource;
public AudioClip[] audiosRun;
public AudioClip[] audioWalk;
private void Start()
{
}
private void Update()
{
}
[ClientRpc]
public void playRunSoundClientRpc()
{
AudioClip val = selectRandomSound(audiosRun);
if ((Object)(object)val != (Object)null)
{
audioSource.clip = val;
audioSource.Play();
}
}
[ClientRpc]
public void playWalkSoundClientRpc()
{
AudioClip val = selectRandomSound(audioWalk);
if ((Object)(object)val != (Object)null)
{
audioSource.clip = val;
audioSource.Play();
}
}
private AudioClip? selectRandomSound(AudioClip[] audios)
{
if (audios.Length == 0 || (Object)(object)audioSource == (Object)null)
{
return null;
}
int num = Random.Range(0, audios.Length);
return audios[num];
}
}
[RequireComponent(typeof(Animator))]
public class IKControl : MonoBehaviour
{
protected Animator animator;
public Transform lookObj;
public bool ikActive;
private void Start()
{
animator = ((Component)this).GetComponent<Animator>();
}
private void OnAnimatorIK()
{
if (Object.op_Implicit((Object)(object)animator) && ikActive)
{
moveHeadClientRpc();
}
}
[ClientRpc]
private void moveHeadClientRpc()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lookObj != (Object)null)
{
animator.SetLookAtWeight(1f);
animator.SetLookAtPosition(lookObj.position);
}
else
{
animator.SetLookAtWeight(0f);
}
}
}
[BepInPlugin("NBPCSDC.Sacha_Mod", "Sacha_Mod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static AssetBundle? ModAssets;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
InitializeNetworkBehaviours();
string path = "sachamodassets";
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
if ((Object)(object)ModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets.");
return;
}
EnemyType val = ModAssets.LoadAsset<EnemyType>("Sacha");
TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("SachaTN");
TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("SachaTK");
Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>
{
{
(LevelTypes)4,
50
},
{
(LevelTypes)8,
20
},
{
(LevelTypes)16,
15
},
{
(LevelTypes)32,
15
},
{
(LevelTypes)64,
60
},
{
(LevelTypes)128,
10
},
{
(LevelTypes)256,
35
},
{
(LevelTypes)512,
63
},
{
(LevelTypes)(-1),
20
},
{
(LevelTypes)1024,
20
}
};
Dictionary<string, int> dictionary2 = new Dictionary<string, int>
{
{ "EGyptLevel", 50 },
{ "46 Infernis", 69 }
};
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Enemies.RegisterEnemy(val, dictionary, dictionary2, val2, val3);
Logger.LogInfo((object)"Plugin NBPCSDC.Sacha_Mod is loaded!");
}
private static void InitializeNetworkBehaviours()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
}
internal class SachaAI : EnemyAI
{
private enum State
{
SearchingForPlayer,
FollowPlayer,
IsInCombat,
RunAway,
AttackInProgress,
ReceiveHitInProgress,
EmotePlaying,
HelloInProgress,
ClapInProgress
}
public Transform turnCompass;
public Transform attackArea;
public Transform view;
public IKControl ik_Control;
public AudioClip[] hi_SFX;
public AudioClip[] clap_SFX;
public AudioClip[] combat_SFX;
public AudioClip[] attack_SFX;
public AudioClip[] hit_SFX;
public AudioClip[] randomSound_SFX;
public AudioClip flee_SFX;
public AudioClip song_SFX;
public AudioClip stopTarget_SFX;
private AudioClip currentAudioClip;
private Transform farestNodeFromPos;
private float timeSinceHittingLocalPlayer;
private float attackDelay;
private float attackedDelay;
private float tryAttackDelay;
private float randomSoundDelay;
private float emoteDelay;
private bool isFirstEncounter;
private bool isSongPlaying;
private bool helloDone;
private Vector3 targetPosition;
private Random enemyRandom;
private bool isDeadAnimationDone;
private float walkSpeed = 2f;
private float runSpeed = 4f;
private bool isWalking;
private bool isRunning;
private bool hasClaped;
private float stamina = 10f;
private float animationMaxDelay = 10f;
private float maxTargetDistance = 15f;
private bool isStaminaFilling;
private float backupDistance = 3f;
private float idleDistance = 4f;
private bool updateRotation = true;
private float runDistance = 6f;
private bool useVoiceSFX = true;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
base.creatureAnimator.applyRootMotion = false;
timeSinceHittingLocalPlayer = 0f;
isFirstEncounter = true;
attackDelay = 0f;
attackedDelay = 0f;
tryAttackDelay = 0f;
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
isDeadAnimationDone = false;
base.currentBehaviourStateIndex = 0;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
}
public override void Update()
{
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: 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)
((EnemyAI)this).Update();
if (base.isEnemyDead)
{
if (!isDeadAnimationDone)
{
isDeadAnimationDone = true;
base.creatureVoice.Stop();
base.creatureVoice.PlayOneShot(base.dieSFX);
StopSongClientRpc();
}
return;
}
timeSinceHittingLocalPlayer += Time.deltaTime;
attackDelay += Time.deltaTime;
randomSoundDelay += Time.deltaTime;
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
switch (currentBehaviourStateIndex)
{
case 4:
tryAttackDelay += Time.deltaTime;
break;
case 6:
emoteDelay += Time.deltaTime;
break;
case 2:
attackedDelay += Time.deltaTime;
break;
}
if ((Object)(object)base.targetPlayer != (Object)null && currentBehaviourStateIndex != 4)
{
if (updateRotation)
{
turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
}
((Component)view).transform.position = ((Component)base.targetPlayer.gameplayCamera).transform.position;
}
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
}
Vector3 val = targetPosition - ((Component)this).transform.position;
val = ((Vector3)(ref val)).normalized;
float num = Vector3.Dot(((Component)this).transform.forward, val);
Vector3 velocity = base.agent.velocity;
UpdateAnimationClientRpc(((Vector3)(ref velocity)).magnitude, num < 0f);
velocity = base.agent.velocity;
isRunning = ((Vector3)(ref velocity)).magnitude > walkSpeed + 0.1f;
velocity = base.agent.velocity;
isWalking = ((Vector3)(ref velocity)).magnitude > 0.1f && !isRunning;
}
public override void DoAIInterval()
{
((EnemyAI)this).DoAIInterval();
if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
{
switch (base.currentBehaviourStateIndex)
{
case 0:
handleSearchingForPlayer();
break;
case 1:
handleFollowPlayer();
break;
case 2:
handleCombatState();
break;
case 6:
handleEmote();
break;
}
updateStamina();
}
}
private void handleSearchingForPlayer()
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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)
if (!isFirstEncounter && tryDoRandomAnimation())
{
((EnemyAI)this).StopSearch(base.currentSearch, true);
return;
}
base.agent.speed = walkSpeed;
ik_Control.ikActive = false;
if (FoundClosestPlayerInRange(maxTargetDistance, 3f))
{
ik_Control.ikActive = true;
if (isFirstEncounter)
{
isFirstEncounter = false;
((EnemyAI)this).SwitchToBehaviourClientRpc(7);
((MonoBehaviour)this).StartCoroutine(PlayHelloAndWait());
playSong();
}
else if (helloDone)
{
if (enemyRandom.Next(0, 3) == 0)
{
playSong();
}
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
targetPosition = ((Component)this).transform.position;
((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
((EnemyAI)this).StopSearch(base.currentSearch, true);
}
else
{
TryPlayRandomSound();
}
}
private void handleCombatState()
{
if (!isPlayerStillTarget())
{
return;
}
if (attackedDelay > 10f)
{
attackedDelay = 0f;
base.creatureAnimator.SetBool("isCombat", false);
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
return;
}
base.creatureAnimator.SetBool("isMarteloAttack", false);
if (!tryAttack(20))
{
FollowPlayer();
}
}
private void handleFollowPlayer()
{
if (!isPlayerStillTarget())
{
return;
}
TryPlayRandomSound();
if (!reactToEmote())
{
base.creatureAnimator.SetBool("isMarteloAttack", true);
if (!tryAttack(40) && !tryDoRandomAnimation())
{
FollowPlayer();
}
}
}
private void handleRunAway()
{
//IL_0052: 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_003a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)farestNodeFromPos == (Object)null)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
DoAnimationClientRpc("stopRunAway");
}
else if (!TargetClosestPlayerInAnyCase() || Vector3.Distance(((Component)this).transform.position, farestNodeFromPos.position) <= 10f)
{
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
DoAnimationClientRpc("stopRunAway");
updateRotation = true;
ik_Control.ikActive = true;
}
}
private void resetEmote()
{
emoteDelay = 0f;
DoAnimationClientRpc("stopEmote");
switchBackToRoutineState();
}
private void TryPlayRandomSound()
{
if (randomSoundDelay > 15f && !isVoiceSoundPlaying())
{
randomSoundDelay = 0f;
playRandomSoundFromSounds(randomSound_SFX);
}
}
private bool isVoiceSoundPlaying()
{
return base.creatureVoice.isPlaying;
}
private bool isPlayerStillTarget()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.targetPlayer == (Object)null)
{
return false;
}
float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
if (num > maxTargetDistance && (!TargetClosestPlayerInAnyCase() || !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 45f, 60, -1f, (Transform)null)))
{
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.creatureAnimator.SetBool("isCombat", false);
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
playSound(stopTarget_SFX, useVoice: true);
StopSongClientRpc();
return false;
}
return true;
}
private void handleEmote()
{
//IL_0022: 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)
if ((Object)(object)base.targetPlayer != (Object)null)
{
if (emoteDelay >= animationMaxDelay || Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > runDistance)
{
resetEmote();
}
}
else if (emoteDelay >= animationMaxDelay)
{
resetEmote();
}
}
private bool tryAttack(int chance)
{
if (attackDelay > 2f && enemyRandom.Next(0, chance) == 0)
{
attackDelay = 0f;
((EnemyAI)this).SwitchToBehaviourClientRpc(4);
((MonoBehaviour)this).StartCoroutine(attack());
return true;
}
return false;
}
private bool reactToEmote()
{
if (base.targetPlayer.performingEmote || base.targetPlayer.disableLookInput)
{
if (!hasClaped)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(8);
((MonoBehaviour)this).StartCoroutine(clap());
hasClaped = true;
}
}
else
{
hasClaped = false;
}
return hasClaped;
}
private void updateStamina()
{
if (isRunning)
{
stamina -= 0.2f;
if (stamina < 0f)
{
isStaminaFilling = true;
}
}
else
{
stamina += 0.2f;
if (stamina >= 10f)
{
isStaminaFilling = false;
}
}
stamina = Mathf.Clamp(stamina, 0f, 10f);
}
private bool hasStamina()
{
if (stamina > 0f)
{
return !isStaminaFilling;
}
return false;
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_0049: 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)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
if ((Object)(object)base.targetPlayer != (Object)null)
{
return Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
return false;
}
private bool TargetClosestPlayerInAnyCase()
{
//IL_001d: 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)
base.mostOptimalDistance = 2000f;
base.targetPlayer = null;
for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
{
base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
if (base.tempDist < base.mostOptimalDistance)
{
base.mostOptimalDistance = base.tempDist;
base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
}
}
if ((Object)(object)base.targetPlayer == (Object)null)
{
return false;
}
return true;
}
private void FollowPlayer()
{
//IL_001d: 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_00b8: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.targetPlayer == (Object)null || !((NetworkBehaviour)this).IsOwner)
{
return;
}
float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
if (num > runDistance)
{
if (hasStamina())
{
base.agent.speed = runSpeed;
}
else
{
base.agent.speed = walkSpeed;
}
targetPosition = ((Component)base.targetPlayer).transform.position;
((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
}
else if (num > idleDistance)
{
base.agent.speed = walkSpeed;
targetPosition = ((Component)base.targetPlayer).transform.position;
((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
}
else if (num < backupDistance)
{
base.agent.speed = walkSpeed;
Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
targetPosition = -((Vector3)(ref val)).normalized;
targetPosition = ((Component)this).transform.position + targetPosition * 2f;
((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
}
else
{
base.agent.speed = 0f;
}
}
private IEnumerator clap()
{
base.agent.speed = 0f;
yield return (object)new WaitForSeconds(0.5f);
playRandomSoundFromSounds(clap_SFX);
DoAnimationClientRpc("clap");
yield return (object)new WaitForSeconds(3f);
switchBackToRoutineState();
}
private IEnumerator PlayHelloAndWait()
{
yield return (object)new WaitUntil((Func<bool>)(() => IsPlayerLookingAtEnemy()));
yield return (object)new WaitForSeconds(0.5f);
playRandomSoundFromSounds(hi_SFX);
DoAnimationClientRpc("hello");
yield return (object)new WaitForSeconds(2f);
helloDone = true;
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
private IEnumerator attack()
{
if ((Object)(object)base.targetPlayer == (Object)null || Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) >= idleDistance)
{
switchBackToRoutineState();
yield break;
}
base.agent.speed = 4f;
tryAttackDelay = 0f;
float distanceToPlayer = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
while (distanceToPlayer > 1f)
{
if (distanceToPlayer > runDistance || tryAttackDelay >= 6f)
{
switchBackToRoutineState();
yield break;
}
if ((Object)(object)base.targetPlayer != (Object)null)
{
Vector3 val = ((Component)this).transform.position - ((Component)base.targetPlayer).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
targetPosition = ((Component)base.targetPlayer).transform.position + normalized * 0.5f;
((EnemyAI)this).SetDestinationToPosition(targetPosition, false);
distanceToPlayer = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
yield return null;
continue;
}
switchBackToRoutineState();
yield break;
}
DoAnimationClientRpc("attack");
yield return (object)new WaitUntil((Func<bool>)delegate
{
//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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Hit"))
{
currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("martelo"))
{
return true;
}
}
currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f;
});
attackHitClientRpc();
switchBackToRoutineState();
}
private IEnumerator TakeHit(int force)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(5);
ik_Control.ikActive = false;
base.creatureAnimator.SetInteger("hitIndex", enemyRandom.Next(0, 2));
DoAnimationClientRpc("hit");
playRandomSoundFromSounds(hit_SFX);
if (base.enemyHP - force <= 0)
{
((MonoBehaviour)this).StopCoroutine(attack());
StopSongClientRpc();
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
base.creatureAnimator.SetBool("isCombat", false);
playSound(flee_SFX, useVoice: true);
DoAnimationClientRpc("runAway");
updateRotation = false;
farestNodeFromPos = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, false, 0, false, 50, false);
targetPosition = farestNodeFromPos.position;
((EnemyAI)this).SetDestinationToPosition(targetPosition, true);
base.agent.speed = runSpeed * 3f;
}
else
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
base.creatureAnimator.SetBool("isCombat", true);
attackedDelay = 0f;
ik_Control.ikActive = true;
yield return (object)new WaitForSeconds(0.5f);
playRandomSoundFromSounds(combat_SFX);
}
}
private void switchBackToRoutineState()
{
base.agent.speed = walkSpeed;
if ((Object)(object)base.targetPlayer != (Object)null)
{
if (attackedDelay != 0f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
}
else
{
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
}
else
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
}
private bool IsPlayerLookingAtEnemy()
{
//IL_0016: 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)
//IL_0030: 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_0038: 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_004e: 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_0073: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.targetPlayer == (Object)null)
{
return false;
}
Vector3 val = ((Component)this).transform.position - ((Component)base.targetPlayer.gameplayCamera).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
float num = Vector3.Dot(((Component)base.targetPlayer.gameplayCamera).transform.forward, normalized);
if (num > 0.5f)
{
return ((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 45f, 60, -1f, (Transform)null);
}
return false;
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if (timeSinceHittingLocalPlayer < 1f || base.currentBehaviourStateIndex == 3 || base.currentBehaviourStateIndex == 4)
{
return;
}
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
if (base.currentBehaviourStateIndex == 6)
{
resetEmote();
}
timeSinceHittingLocalPlayer = 0f;
base.creatureAnimator.SetBool("isMarteloAttack", false);
DoAnimationClientRpc("attack");
playRandomSoundFromSounds(attack_SFX);
val.DamagePlayer(25, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
switchBackToRoutineState();
}
}
public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
if (base.isEnemyDead)
{
return;
}
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner)
{
if (base.enemyHP <= 0 && !base.isEnemyDead)
{
((MonoBehaviour)this).StopCoroutine(attack());
((MonoBehaviour)this).StopCoroutine(TakeHit(force));
((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
ik_Control.ikActive = false;
((EnemyAI)this).KillEnemyOnOwnerClient(false);
}
else
{
((MonoBehaviour)this).StartCoroutine(TakeHit(force));
}
}
}
private bool tryDoRandomAnimation()
{
if (enemyRandom.Next(0, 60) == 0)
{
base.creatureAnimator.SetInteger("randomEmote", enemyRandom.Next(0, 4));
DoAnimationClientRpc("startEmote");
((EnemyAI)this).SwitchToBehaviourClientRpc(6);
base.agent.speed = 0f;
return true;
}
return false;
}
[ClientRpc]
public void DoAnimationClientRpc(string animationName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1641506680u, val, (RpcDelivery)0);
bool flag = animationName != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1641506680u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureAnimator.SetTrigger(animationName);
}
}
[ClientRpc]
public void UpdateAnimationClientRpc(float speed, bool isGoingBackward)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3827431406u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isGoingBackward, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3827431406u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureAnimator.SetFloat("speed", speed);
base.creatureAnimator.SetBool("goBackward", isGoingBackward);
}
}
}
[ClientRpc]
public void attackHitClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2977610776u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2977610776u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
playRandomSoundFromSounds(attack_SFX);
int num = 8;
Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
if (array.Length == 0)
{
return;
}
Collider[] array2 = array;
foreach (Collider val3 in array2)
{
PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
if ((Object)(object)val4 != (Object)null)
{
timeSinceHittingLocalPlayer = 0f;
val4.DamagePlayer(30, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
private void playRandomSoundFromSounds(AudioClip[] sounds)
{
if (sounds != null && sounds.Length != 0)
{
int num = enemyRandom.Next(0, sounds.Length);
playSound(sounds[num], useVoice: true);
}
}
private void playSong()
{
if (!isSongPlaying)
{
playSound(song_SFX, useVoice: false);
}
}
private void playSound(AudioClip sound, bool useVoice)
{
currentAudioClip = sound;
useVoiceSFX = useVoice;
PlaySoundFromAudioClientRpc();
}
[ClientRpc]
public void PlaySoundFromAudioClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1518822893u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1518822893u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)currentAudioClip != (Object)null)
{
if (useVoiceSFX)
{
base.creatureVoice.Stop();
base.creatureVoice.PlayOneShot(currentAudioClip);
}
else
{
base.creatureSFX.Stop();
base.creatureSFX.PlayOneShot(currentAudioClip);
}
}
}
[ClientRpc]
public void StopSongClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3632992405u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3632992405u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureSFX.Stop();
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_SachaAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1641506680u, new RpcReceiveHandler(__rpc_handler_1641506680));
NetworkManager.__rpc_func_table.Add(3827431406u, new RpcReceiveHandler(__rpc_handler_3827431406));
NetworkManager.__rpc_func_table.Add(2977610776u, new RpcReceiveHandler(__rpc_handler_2977610776));
NetworkManager.__rpc_func_table.Add(1518822893u, new RpcReceiveHandler(__rpc_handler_1518822893));
NetworkManager.__rpc_func_table.Add(3632992405u, new RpcReceiveHandler(__rpc_handler_3632992405));
}
private static void __rpc_handler_1641506680(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string animationName = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((SachaAI)(object)target).DoAnimationClientRpc(animationName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3827431406(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
float speed = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speed, default(ForPrimitives));
bool isGoingBackward = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isGoingBackward, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((SachaAI)(object)target).UpdateAnimationClientRpc(speed, isGoingBackward);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2977610776(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((SachaAI)(object)target).attackHitClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1518822893(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((SachaAI)(object)target).PlaySoundFromAudioClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3632992405(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((SachaAI)(object)target).StopSongClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "SachaAI";
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "NBPCSDC.Sacha_Mod";
public const string PLUGIN_NAME = "Sacha_Mod";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace Sacha_Mod.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> SpawnWeight;
public PluginConfig(ConfigFile cfg)
{
SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for Sacha_Mod, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
ClearUnusedEntries(cfg);
}
private void ClearUnusedEntries(ConfigFile cfg)
{
PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
dictionary.Clear();
cfg.Save();
}
}
}
namespace NBPCSDC.Sacha_Mod.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}