#define DEBUG
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 ExampleEnemy.Configuration;
using ExampleEnemy.NetcodePatcher;
using GameNetcodeStuff;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
[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 = "")]
[assembly: AssemblyCompany("ExampleEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Example Enemy for Lethal Company.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExampleEnemy")]
[assembly: AssemblyTitle("ExampleEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace ExampleEnemy
{
internal class ExampleEnemy : EnemyAI
{
private enum State
{
IDLE,
STALK,
PRERUSH,
RUSH,
ROAM
}
public Transform turnCompass;
public Transform attackArea;
private bool isDeadAnimationDone;
public Vector3 spawnPosition;
public AISearchRoutine roamMap = null;
public float targetLostCooldown = 0f;
private float targetLostTime;
public bool targetLost;
private const int stalkingCooldownScared = 50;
private const int stalkingCooldownDetected = 40;
public float stalkingCooldown = 40f;
private int chaseDuration;
public float currentChase = 0f;
private const float distanceMult = 1f;
private const float closeDistance = 7f;
private const float longDistance = 14f;
private bool flag = false;
public float timeSinceHittingLocalPlayer;
private const int preRushTimeout = 35;
private const int roamTimeout = 45;
private float TimeTick = 0f;
private const float stunTime = 1f;
public float stunCooldown = 0f;
public int subState = 0;
public Vector3 mainEntrancePos;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
((EnemyAI)this).Start();
base.targetPlayer = null;
spawnPosition = ((Component)this).transform.position;
targetLost = true;
chaseDuration = 20 + StartOfRound.Instance.randomMapSeed % 11;
targetLostTime = StartOfRound.Instance.randomMapSeed % 6 + 10;
targetLostCooldown = targetLostTime;
LogIfDebugBuild("Man-stalker Spawned");
timeSinceHittingLocalPlayer = 0f;
isDeadAnimationDone = false;
base.currentBehaviourStateIndex = 0;
mainEntrancePos = RoundManager.FindMainEntrancePosition(false, false);
}
public override void Update()
{
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: 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);
}
base.creatureAnimator.SetBool("isAngry", false);
return;
}
if (targetLost && base.currentBehaviourStateIndex == 1)
{
targetLostCooldown -= Time.deltaTime;
stalkingCooldown += Time.deltaTime;
}
if (!targetLost && base.currentBehaviourStateIndex == 1)
{
stalkingCooldown -= Time.deltaTime;
}
if (stunCooldown > 0f)
{
stunCooldown -= Time.deltaTime;
}
else if (base.currentBehaviourStateIndex == 3 && stunCooldown < 0f)
{
base.creatureAnimator.SetBool("isAngry", true);
base.creatureAnimator.ResetTrigger("stunned");
}
if (base.currentBehaviourStateIndex == 3)
{
currentChase += Time.deltaTime;
}
if ((double)timeSinceHittingLocalPlayer < 0.75)
{
timeSinceHittingLocalPlayer += Time.deltaTime;
}
else if (base.currentBehaviourStateIndex == 3 && (double)timeSinceHittingLocalPlayer > 0.75)
{
base.creatureAnimator.SetBool("isAngry", true);
base.creatureAnimator.ResetTrigger("slash");
}
if (base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 4)
{
TimeTick += Time.deltaTime;
}
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 3))
{
Vector3 val = ((Component)base.targetPlayer.gameplayCamera).transform.position - ((Component)base.agent).transform.position;
turnCompass.LookAt(((Component)base.agent).transform.position - val);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
}
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
}
}
private void animationManager()
{
if (base.currentBehaviourStateIndex != 3)
{
base.creatureAnimator.SetBool("isAngry", false);
}
switch (base.currentBehaviourStateIndex)
{
case 3:
if ((double)timeSinceHittingLocalPlayer < 0.75)
{
LogIfDebugBuild("COOLDOWN ATTACK");
break;
}
if (stunCooldown > 0f)
{
LogIfDebugBuild("COOLDOWN STUN");
break;
}
base.creatureAnimator.speed = 1f;
base.creatureAnimator.SetBool("isAngry", true);
break;
case 1:
base.creatureAnimator.speed = 1f;
base.creatureAnimator.SetBool("isAngry", false);
if (subState == 2)
{
base.creatureAnimator.SetBool("forwardWalk", false);
base.creatureAnimator.SetBool("backwardWalk", false);
}
else if (subState == 0)
{
base.creatureAnimator.SetBool("forwardWalk", true);
base.creatureAnimator.SetBool("backwardWalk", false);
}
else if (subState == 1)
{
base.creatureAnimator.SetBool("forwardWalk", false);
base.creatureAnimator.SetBool("backwardWalk", true);
}
break;
case 2:
case 4:
base.creatureAnimator.SetBool("forwardWalk", true);
base.creatureAnimator.SetBool("backwardWalk", false);
base.creatureAnimator.speed = 2f;
break;
case 0:
base.creatureAnimator.SetBool("forwardWalk", false);
base.creatureAnimator.SetBool("backwardWalk", false);
break;
}
}
public override void DoAIInterval()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: 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_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0700: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0503: Unknown result type (might be due to invalid IL or missing references)
//IL_050b: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_057a: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
base.creatureAnimator.SetBool("isAngry", false);
return;
}
if (stunCooldown > 0f || base.stunNormalizedTimer > 0f)
{
base.agent.velocity = new Vector3(0f, 0f, 0f);
}
PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
PlayerControllerB closestPlayer2 = ((EnemyAI)this).GetClosestPlayer(true, false, false);
float num = 0f;
if ((Object)(object)closestPlayer2 != (Object)null)
{
num = Vector3.Distance(((Component)closestPlayer2).transform.position, ((Component)this).transform.position);
}
Vector3 val;
if ((Object)(object)closestPlayer == (Object)null)
{
base.agent.speed = 10f;
if (Vector3.Distance(((Component)this).transform.position, mainEntrancePos) >= 140f)
{
base.agent.speed = 0f;
val = base.agent.velocity;
((Vector3)(ref val)).Set(0f, 0f, 0f);
}
else
{
((EnemyAI)this).SetDestinationToPosition(((Component)((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePos, false, 0, false)).transform.position, false);
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
return;
}
float num2 = Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position);
animationManager();
switch (base.currentBehaviourStateIndex)
{
case 0:
{
base.creatureVoice.Stop();
base.openDoorSpeedMultiplier = 1f;
base.agent.speed = 5f;
PlayerControllerB closestPlayer3 = ((EnemyAI)this).GetClosestPlayer(false, true, true);
base.targetPlayer = null;
if ((closestPlayer3.isCrouching || (!closestPlayer3.isSprinting && !closestPlayer3.isCrouching)) && Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer3).transform.position) <= 7f)
{
if (roamMap.inProgress)
{
((EnemyAI)this).StopSearch(roamMap, true);
}
base.movingTowardsTargetPlayer = true;
base.targetPlayer = closestPlayer3;
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
stalkingCooldown = 50f;
}
else if ((closestPlayer3.isSprinting && Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer3).transform.position) <= 14f) || (Object)(object)closestPlayer2 != (Object)null)
{
if (roamMap.inProgress)
{
((EnemyAI)this).StopSearch(roamMap, true);
}
base.targetPlayer = closestPlayer3;
base.movingTowardsTargetPlayer = true;
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
stalkingCooldown = 40f;
}
else if ((Object)(object)base.targetPlayer == (Object)null && !roamMap.inProgress)
{
base.movingTowardsTargetPlayer = false;
((EnemyAI)this).StartSearch(spawnPosition, roamMap);
}
break;
}
case 1:
subState = 1;
if (stalkingCooldown < 0f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
break;
}
base.openDoorSpeedMultiplier = 1f;
if (num2 > 35f && (Object)(object)closestPlayer2 == (Object)null)
{
subState = 0;
base.agent.speed = 3f;
base.targetPlayer = closestPlayer;
((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
if (base.agent.velocity == new Vector3(0f, 0f, 0f) && ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false))
{
LogIfDebugBuild("");
}
targetLost = true;
if (targetLostCooldown < 0f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
targetLostCooldown = targetLostTime;
targetLost = true;
stalkingCooldown = 40f;
}
break;
}
targetLost = false;
targetLostCooldown = targetLostTime;
if (num2 <= 2f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
break;
}
if ((double)num2 < 21.0)
{
if (num2 < 10f)
{
val = ((Component)this).transform.position - ((Component)closestPlayer).transform.position;
Vector3 velocity = ((Vector3)(ref val)).normalized * 3f;
base.agent.velocity = velocity;
}
base.agent.speed = 10f;
AvoidClosestPlayer(21f, avoidLOS: true);
break;
}
if (num < 28f && (Object)(object)closestPlayer2 != (Object)null)
{
base.agent.speed = 8f;
AvoidClosestPlayer(28f, avoidLOS: true);
break;
}
if (base.agent.velocity == new Vector3(0f, 0f, 0f))
{
subState = 2;
}
base.agent.speed = 0f;
base.moveTowardsDestination = false;
base.movingTowardsTargetPlayer = false;
if ((Object)(object)closestPlayer2 != (Object)null)
{
base.targetPlayer = closestPlayer2;
}
else
{
base.targetPlayer = closestPlayer;
}
break;
case 2:
base.openDoorSpeedMultiplier = 1f;
base.agent.speed = 8f;
if (TimeTick > 35f)
{
TimeTick = 0f;
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
break;
}
if (num2 < 2f)
{
TimeTick = 0f;
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
}
if (num2 < 14f)
{
AvoidClosestPlayer(14f, avoidLOS: true);
}
break;
case 3:
base.agent.speed = 15f;
scareLocalPlayer();
base.openDoorSpeedMultiplier = 0.15f;
if (base.enemyHP <= 2)
{
base.openDoorSpeedMultiplier = 2f;
}
((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
if (base.agent.velocity == new Vector3(0f, 0f, 0f) && ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false))
{
LogIfDebugBuild("");
}
if (!flag || num2 > 14f)
{
currentChase = 0f;
break;
}
flag = true;
if (currentChase > (float)chaseDuration && (Object)(object)closestPlayer2 == (Object)null && num2 > 14f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(4);
flag = false;
currentChase = 0f;
}
break;
case 4:
if (num2 < 1.5f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
}
base.agent.speed = 10f;
AvoidClosestPlayer(14f, avoidLOS: true);
if (num2 > 28f && (Object)(object)closestPlayer2 == (Object)null && TimeTick > 45f)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
break;
default:
LogIfDebugBuild("Error : invalid behavior index");
break;
}
}
public void AvoidClosestPlayer(float optimalDistance, bool avoidLOS)
{
//IL_000d: 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_0048: 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)
Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, avoidLOS, 0, true);
if ((Object)(object)val != (Object)null && base.mostOptimalDistance > optimalDistance && Physics.Linecast(((Component)val).transform.position, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
{
base.targetNode = val;
((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
}
}
public void scareLocalPlayer()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 14f)
{
GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
}
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if (base.currentBehaviourStateIndex == 3 && !(timeSinceHittingLocalPlayer < 0.75f) && !(stunCooldown > 0f) && !base.isEnemyDead)
{
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
base.creatureAnimator.SetBool("isAngry", false);
DoAnimationClientRpc("slash");
base.creatureSFX.PlayOneShot(base.currentBehaviourState.SFXClip);
LogIfDebugBuild("Player " + val.playerUsername + " hit by dust stalker");
timeSinceHittingLocalPlayer = 0f;
val.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
{
if (base.isEnemyDead || stunCooldown > 0f)
{
return;
}
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX);
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner)
{
if (base.enemyHP <= 0 && !base.isEnemyDead)
{
((EnemyAI)this).KillEnemyOnOwnerClient(false);
return;
}
base.creatureAnimator.SetBool("isAngry", false);
DoAnimationClientRpc("stunned");
stunCooldown = 1f;
base.creatureVoice.PlayOneShot(base.dieSFX);
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
}
}
[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(3924887832u, 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, 3924887832u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
LogIfDebugBuild("Animation: " + animationName);
base.creatureAnimator.SetTrigger(animationName);
}
}
[ClientRpc]
public void SwingAttackHitClientRpc()
{
//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_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: 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(2359772908u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2359772908u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
LogIfDebugBuild("SwingAttackHitClientRPC");
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)
{
LogIfDebugBuild("Swing attack hit player!");
timeSinceHittingLocalPlayer = 0f;
val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_ExampleEnemy()
{
//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
NetworkManager.__rpc_func_table.Add(3924887832u, new RpcReceiveHandler(__rpc_handler_3924887832));
NetworkManager.__rpc_func_table.Add(2359772908u, new RpcReceiveHandler(__rpc_handler_2359772908));
}
private static void __rpc_handler_3924887832(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;
((ExampleEnemy)(object)target).DoAnimationClientRpc(animationName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2359772908(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;
((ExampleEnemy)(object)target).SwingAttackHitClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ExampleEnemy";
}
}
[BepInPlugin("snickerbarYaboiDucki.ExampleEnemy", "ExampleEnemy", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string pluginName = "Dust stalker (Hostile entity)";
public const string ModGUID = "snickerbarYaboiDucki.ExampleEnemy";
public const string pluginVersion = "1.0.0";
internal static ManualLogSource Logger;
public static AssetBundle ModAssets;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
BoundConfig = new PluginConfig((BaseUnityPlugin)(object)this);
InitializeNetworkBehaviours();
string path = "modassets";
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>("ExampleEnemy 1");
TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("duskStalkerTN");
TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("duskStalkerTK");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, val2, val3);
Logger.LogInfo((object)"Plugin ExampleEnemy 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);
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ExampleEnemy";
public const string PLUGIN_NAME = "ExampleEnemy";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace ExampleEnemy.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> SpawnWeight;
public PluginConfig(BaseUnityPlugin plugin)
{
SpawnWeight = plugin.Config.Bind<int>("Man stalker", "Spawn weight", 20, "The spawn chance weight for ExampleEnemy, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
ClearUnusedEntries(plugin);
}
private void ClearUnusedEntries(BaseUnityPlugin plugin)
{
PropertyInfo property = ((object)plugin.Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(plugin.Config, null);
dictionary.Clear();
plugin.Config.Save();
}
}
}
namespace ExampleEnemy.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}