#define DEBUG
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 HauntedScrap.NetcodePatcher;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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("HauntedScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Haunted Scraps!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+46619184e748b9bf195407bcea4b161f0801657f")]
[assembly: AssemblyProduct("HauntedScrap")]
[assembly: AssemblyTitle("HauntedScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace HauntedScrap
{
internal class FlashbangGnomeAI : EnemyAI
{
private enum State
{
SearchingForPlayer,
PlayerFound
}
public Transform turnCompass;
public Transform attackArea;
private float timeSinceHittingLocalPlayer;
private float timeSinceNewRandPos;
private Vector3 lastKnownPlayerPos;
private bool gotLastPos = false;
public float stareDistance;
public Transform cornerDetection;
private LineRenderer line;
private float currentChaseSpeed = 6f;
private Random enemyRandom;
private bool isDeadAnimationDone;
public AudioClip gnomeTeleport;
private float chaseTime;
private bool startChase;
private bool chaseStarted;
private float teleportTimer;
public AudioClip flashbangSound;
private Vector3 newTeleport;
private PlayerControllerB previousTarget;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
LogIfDebugBuild("Blue Gnome Spawned");
stareDistance = 40f;
line = ((Component)this).gameObject.AddComponent<LineRenderer>();
line.widthMultiplier = 0.2f;
timeSinceHittingLocalPlayer = 0f;
base.creatureAnimator.SetTrigger("startWalk");
timeSinceNewRandPos = 0f;
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
isDeadAnimationDone = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.currentBehaviourStateIndex = 0;
}
public override void Update()
{
//IL_02ef: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: 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_0092: 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)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_00c1: 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_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (!chaseStarted)
{
teleportTimer += Time.deltaTime;
if (teleportTimer > 45f && (Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null && RoundManager.Instance.insideAINodes.Length != 0 && 0 == 0)
{
bool flag = true;
timeSinceHittingLocalPlayer = 0f;
newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
base.serverPosition = newTeleport;
((Component)this).transform.position = newTeleport;
base.agent.Warp(newTeleport);
((EnemyAI)this).SyncPositionToClients();
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
{
((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
teleportTimer = 0f;
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
}
timeSinceHittingLocalPlayer += Time.deltaTime;
timeSinceNewRandPos += Time.deltaTime;
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
bool flag2 = false;
if (chaseTime <= 3f)
{
base.agent.speed = 6f;
}
if (((NetworkBehaviour)this).IsOwner)
{
for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
{
if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f)
{
flag2 = true;
chaseTime = 0f;
}
if (startChase != flag2)
{
startChase = flag2;
}
}
}
if (chaseStarted && ((NetworkBehaviour)this).IsOwner)
{
chaseTime += Time.deltaTime;
base.agent.speed = 8f;
}
if (startChase)
{
if (!chaseStarted)
{
chaseStarted = true;
if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f))
{
chaseTime = 0f;
}
}
}
else if (chaseTime >= 6f)
{
chaseStarted = false;
if (((NetworkBehaviour)this).IsOwner)
{
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.agent.speed = 2f;
}
}
else
{
chaseTime += Time.deltaTime;
}
}
public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
{
if (((Behaviour)agent).enabled)
{
yield return (object)new WaitForEndOfFrame();
line.SetPosition(0, ((Component)agent).transform.position);
line.positionCount = agent.path.corners.Length;
for (int i = 1; i < agent.path.corners.Length; i++)
{
line.SetPosition(i, agent.path.corners[i]);
}
}
}
public override void DoAIInterval()
{
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
{
if (!((NetworkBehaviour)this).IsServer)
{
((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
break;
}
for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
{
if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f)
{
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
return;
}
}
base.movingTowardsTargetPlayer = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
break;
}
case 1:
base.agent.speed = 0f;
if (base.currentSearch != null)
{
((EnemyAI)this).StopSearch(base.currentSearch, true);
}
if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
{
if ((Object)(object)previousTarget != (Object)(object)base.targetPlayer)
{
previousTarget = base.targetPlayer;
((EnemyAI)this).ChangeEnemyOwnerServerRpc(base.targetPlayer.actualClientId);
}
base.movingTowardsTargetPlayer = true;
}
else
{
base.agent.speed = 2f;
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
break;
default:
LogIfDebugBuild("This Behavior State doesn't exist!");
break;
}
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_004e: 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)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
private bool TargetClosestPlayerInAnyCase()
{
//IL_001f: 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)
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;
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_0033: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00f2: 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)
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if (!((Object)(object)val != (Object)null))
{
return;
}
((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
StunExplosion(((Component)this).transform.position, affectAudio: true, 1f, 7.5f);
if (RoundManager.Instance.insideAINodes.Length != 0 && 0 == 0)
{
((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(flashbangSound);
((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
bool flag = true;
timeSinceHittingLocalPlayer = 0f;
newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
base.serverPosition = newTeleport;
((Component)this).transform.position = newTeleport;
base.agent.Warp(newTeleport);
((EnemyAI)this).SyncPositionToClients();
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
{
((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
}
private Vector3 GenerateTeleportLocation(Vector3 teleportposition, bool isPlayer)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: 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)
//IL_0134: 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_013b: 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_0141: 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_0144: 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_014e: 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_00de: 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)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
Plugin.Logger.LogInfo((object)"Generating Teleport Location!");
if (!isPlayer && (Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null)
{
while (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) <= 40f)
{
position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
if (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) >= 40f)
{
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
teleportposition = position;
return teleportposition;
}
}
return teleportposition;
}
position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
teleportposition = position;
return teleportposition;
}
private void StunExplosion(Vector3 explosionPosition, bool affectAudio, float flashSeverityMultiplier, float enemyStunTime, float flashSeverityDistanceRolloff = 1f, bool isHeldItem = false, float addToFlashSeverity = 0f)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = GameNetworkManager.Instance.localPlayerController;
if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && (Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)
{
val = GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript;
}
float num = Vector3.Distance(((Component)val).transform.position, explosionPosition);
float num2 = 7f / (num * flashSeverityDistanceRolloff);
if (Physics.Linecast(explosionPosition + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
{
num2 /= 13f;
}
else if (num < 2f)
{
num2 = 1f;
}
else if (!val.HasLineOfSightToPosition(explosionPosition, 60f, 15, 2f))
{
num2 = Mathf.Clamp(num2 / 3f, 0f, 1f);
}
num2 = Mathf.Clamp(num2 * flashSeverityMultiplier, 0f, 1f);
if (num2 > 0.6f)
{
num2 += addToFlashSeverity;
}
HUDManager.Instance.flashFilter = num2;
if (affectAudio)
{
SoundManager.Instance.earsRingingTimer = num2;
}
if (enemyStunTime <= 0f)
{
return;
}
Collider[] array = Physics.OverlapSphere(explosionPosition, 12f, 524288);
if (array.Length == 0)
{
return;
}
for (int i = 0; i < array.Length; i++)
{
EnemyAICollisionDetect component = ((Component)array[i]).GetComponent<EnemyAICollisionDetect>();
if (!((Object)(object)component == (Object)null))
{
Vector3 val2 = ((Component)component.mainScript).transform.position + Vector3.up * 0.5f;
if (((Component)component).GetComponentInParent<FlashbangGnomeAI>().DWHasLineOfSightToPosition(explosionPosition + Vector3.up * 0.5f, 120f, 23, 7f) || (!Physics.Linecast(explosionPosition + Vector3.up * 0.5f, ((Component)component.mainScript).transform.position + Vector3.up * 0.5f, 256) && Vector3.Distance(explosionPosition, val2) < 11f))
{
component.mainScript.SetEnemyStunned(true, enemyStunTime, (PlayerControllerB)null);
}
}
}
}
public bool DWHasLineOfSightToPosition(Vector3 pos, float width = 45f, int range = 30, float proximityAwareness = 7.5f)
{
//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_0040: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_008c: 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)
if ((Object)(object)base.eye == (Object)null)
{
_ = ((Component)this).transform;
}
else
{
_ = base.eye;
}
if (Vector3.Distance(base.eye.position, pos) < (float)range && !Physics.Linecast(base.eye.position, pos, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
{
Vector3 val = pos - base.eye.position;
if (Vector3.Angle(base.eye.forward, val) < width || Vector3.Distance(((Component)this).transform.position, pos) < proximityAwareness)
{
return true;
}
}
return false;
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "FlashbangGnomeAI";
}
}
internal class GnomeAI : EnemyAI
{
private enum State
{
SearchingForPlayer,
PlayerFound
}
public Transform turnCompass;
public Transform attackArea;
private float timeSinceHittingLocalPlayer;
private float timeSinceNewRandPos;
private Vector3 lastKnownPlayerPos;
private bool gotLastPos = false;
public float stareDistance;
public Transform cornerDetection;
private LineRenderer line;
private float currentChaseSpeed = 6f;
private Random enemyRandom;
private bool isDeadAnimationDone;
public AudioClip gnomeTeleport;
private Vector3 newTeleport;
private Vector3 newTeleportPlayer;
private bool stopmoving;
private bool hasStopped;
private bool wasOwnerLastFrame;
private float stopAndGoMinimumInterval;
private PlayerControllerB previousTarget;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
LogIfDebugBuild("Example Enemy Spawned");
stareDistance = 40f;
line = ((Component)this).gameObject.AddComponent<LineRenderer>();
line.widthMultiplier = 0.2f;
timeSinceHittingLocalPlayer = 0f;
base.creatureAnimator.SetTrigger("startWalk");
timeSinceNewRandPos = 0f;
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
isDeadAnimationDone = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.currentBehaviourStateIndex = 0;
}
public override void Update()
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
timeSinceHittingLocalPlayer += Time.deltaTime;
timeSinceNewRandPos += Time.deltaTime;
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
if (!((NetworkBehaviour)this).IsOwner)
{
return;
}
if (stopAndGoMinimumInterval > 0f)
{
stopAndGoMinimumInterval -= Time.deltaTime;
}
if (!wasOwnerLastFrame)
{
wasOwnerLastFrame = true;
if (!stopmoving)
{
base.agent.speed = currentChaseSpeed;
}
else
{
base.agent.speed = 0f;
}
}
bool flag = false;
for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
{
if ((((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f) || (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(cornerDetection.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f))
{
flag = true;
}
}
if (base.stunNormalizedTimer > 0f)
{
flag = true;
}
if (flag != stopmoving && stopAndGoMinimumInterval <= 0f)
{
stopAndGoMinimumInterval = 0.15f;
stopmoving = flag;
}
if (stopmoving)
{
if (!hasStopped)
{
hasStopped = true;
if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f) || GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(cornerDetection.position, 70f, 25, -1f))
{
base.agent.speed = 0f;
}
}
if (((NetworkBehaviour)this).IsOwner)
{
base.agent.speed = 0f;
}
}
else
{
if (hasStopped)
{
hasStopped = false;
}
if (((NetworkBehaviour)this).IsOwner)
{
base.agent.speed = Mathf.Lerp(base.agent.speed, currentChaseSpeed, 4.5f * Time.deltaTime);
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
}
}
public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
{
if (((Behaviour)agent).enabled)
{
yield return (object)new WaitForEndOfFrame();
line.SetPosition(0, ((Component)agent).transform.position);
line.positionCount = agent.path.corners.Length;
for (int i = 1; i < agent.path.corners.Length; i++)
{
line.SetPosition(i, agent.path.corners[i]);
}
}
}
public override void DoAIInterval()
{
//IL_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
{
if (!((NetworkBehaviour)this).IsServer)
{
((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
break;
}
for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
{
if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f)
{
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
return;
}
}
base.agent.speed = 6f;
if (base.currentSearch == null)
{
base.movingTowardsTargetPlayer = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
}
break;
}
case 1:
if (base.currentSearch != null)
{
((EnemyAI)this).StopSearch(base.currentSearch, true);
}
if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
{
if ((Object)(object)previousTarget != (Object)(object)base.targetPlayer)
{
previousTarget = base.targetPlayer;
((EnemyAI)this).ChangeEnemyOwnerServerRpc(base.targetPlayer.actualClientId);
}
base.movingTowardsTargetPlayer = true;
}
else
{
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
break;
default:
LogIfDebugBuild("This Behavior State doesn't exist!");
break;
}
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_004e: 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)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
private bool TargetClosestPlayerInAnyCase()
{
//IL_001f: 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)
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;
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_006d: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
if (timeSinceHittingLocalPlayer < 1f)
{
return;
}
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if (!((Object)(object)val != (Object)null))
{
return;
}
((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
if (RoundManager.Instance.insideAINodes.Length == 0)
{
return;
}
if (0 == 0)
{
bool flag = true;
newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: true);
val.movementAudio.PlayOneShot(gnomeTeleport);
val.averageVelocity = 0f;
StartOfRound.Instance.allPlayerScripts[val.playerClientId].TeleportPlayer(newTeleport, false, 0f, false, true);
}
if (0 == 0)
{
((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
bool flag2 = true;
timeSinceHittingLocalPlayer = 0f;
newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
base.serverPosition = newTeleport;
((Component)this).transform.position = newTeleport;
base.agent.Warp(newTeleport);
((EnemyAI)this).SyncPositionToClients();
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
{
((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
}
private Vector3 GenerateTeleportLocation(Vector3 teleportposition, bool isPlayer)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_0147: 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)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00ad: 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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
if (!isPlayer)
{
while (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) <= 60f && ((EnemyAI)this).GetClosestPlayer(false, false, false).isInsideFactory)
{
position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
if (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) >= 60f && ((EnemyAI)this).GetClosestPlayer(false, false, false).isInsideFactory)
{
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
teleportposition = position;
return teleportposition;
}
}
return teleportposition;
}
position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
teleportposition = position;
return teleportposition;
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "GnomeAI";
}
}
[BepInPlugin("sconeys.HauntedScrap", "HauntedScrap", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "sconeys.HauntedScrap";
internal static ManualLogSource Logger;
public static AssetBundle ModAssets;
private int poltergeistspawnrate = 100;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
loadConfig();
InitializeNetworkBehaviours();
string path = "hauntedscrap-dev";
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>("HauntedScrapAI");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Utilities.FixMixerGroups(val.enemyPrefab);
Enemies.RegisterEnemy(val, poltergeistspawnrate, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null);
Logger.LogInfo((object)"Plugin HauntedScrap 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 int RandomNumber(int value)
{
Random random = new Random(StartOfRound.Instance.randomMapSeed);
return random.Next(0, 100);
}
private void loadConfig()
{
poltergeistspawnrate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "poltergeistSpawnRate", 100, "What should the spawnrate of the poltergeist be?").Value;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HauntedScrap";
public const string PLUGIN_NAME = "HauntedScrap";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HauntedScrap.src
{
internal class DefaultADuck : EnemyAI
{
private enum State
{
TeleportingToPlayer,
PlayerFound
}
public Transform turnCompass;
public Transform attackArea;
private float timeSinceHittingLocalPlayer;
private float timeSinceNewRandPos;
private Vector3 lastKnownPlayerPos;
private bool gotLastPos = false;
public float stareDistance;
public Transform cornerDetection;
private Random enemyRandom;
private bool isDeadAnimationDone;
public AudioClip duckyTeleport;
private Random random;
private int realSeed;
private PlayerControllerB chosenPlayer;
private bool timerStart;
private float timer;
private float timerEnd;
private Vector3 teleportlocation;
private PlayerControllerB previousTarget;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
SyncSeedServerRpc();
base.agent.speed = 0f;
realSeed = StartOfRound.Instance.randomMapSeed;
random = new Random(realSeed);
LogIfDebugBuild("Duck Spawned");
timeSinceHittingLocalPlayer = 0f;
base.creatureAnimator.SetTrigger("startWalk");
timeSinceNewRandPos = 0f;
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
isDeadAnimationDone = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.currentBehaviourStateIndex = 0;
}
public override void Update()
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (timerStart)
{
timer += Time.deltaTime;
}
if (!(timer > timerEnd) || !((NetworkBehaviour)this).IsHost)
{
return;
}
int num = random.Next(0, StartOfRound.Instance.allPlayerScripts.Length);
chosenPlayer = StartOfRound.Instance.allPlayerScripts[num];
Plugin.Logger.LogInfo((object)("Chosen Player:" + (object)chosenPlayer));
for (int i = 0; i < RoundManager.Instance.insideAINodes.Length; i++)
{
if (Vector3.Distance(RoundManager.Instance.insideAINodes[i].transform.position, ((Component)chosenPlayer).transform.position) < 10f && chosenPlayer.isInsideFactory)
{
teleportlocation = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)chosenPlayer).transform.position, 10f, default(NavMeshHit));
}
}
Plugin.Logger.LogInfo((object)teleportlocation);
if (chosenPlayer.isInsideFactory)
{
_ = teleportlocation;
if (true)
{
((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(duckyTeleport);
base.serverPosition = teleportlocation;
((Component)this).transform.position = teleportlocation;
base.agent.Warp(teleportlocation);
((EnemyAI)this).SyncPositionToClients();
Plugin.Logger.LogInfo((object)("Ducky Teleported! Target: " + (object)chosenPlayer));
TimerServerRpc();
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
}
}
}
public override void DoAIInterval()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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_00a7: 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)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
if (!timerStart)
{
TimerServerRpc();
}
break;
case 1:
timerStart = false;
((EnemyAI)this).StopSearch(base.currentSearch, true);
if ((Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position, 45f, 60, -1f, (Transform)null) && ((NetworkBehaviour)this).IsHost)
{
((Component)this).transform.LookAt(((Component)chosenPlayer).transform.position);
}
if (Vector3.Distance(((Component)chosenPlayer).transform.position, ((Component)this).transform.position) > 25f && !timerStart)
{
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
break;
default:
LogIfDebugBuild("This Behavior State doesn't exist!");
break;
}
}
[ServerRpc]
private void TimerServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Invalid comparison between Unknown and I4
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(940042237u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 940042237u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
TimerClientRpc();
SyncSeedServerRpc();
}
}
[ClientRpc]
private void TimerClientRpc()
{
//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(2429757260u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2429757260u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
if (!timerStart)
{
timerStart = true;
timer = 0f;
timerEnd = random.Next(15, 90);
Plugin.Logger.LogInfo((object)("Timer End: " + timerEnd));
}
else
{
timerStart = false;
timer = 0f;
}
}
}
[ServerRpc]
private void SyncSeedServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Invalid comparison between Unknown and I4
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(545552982u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 545552982u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
{
realSeed++;
SyncSeedClientRpc(realSeed);
}
}
[ClientRpc]
private void SyncSeedClientRpc(int currentseed)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: 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)
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(248798015u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, currentseed);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 248798015u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
realSeed = currentseed;
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_DefaultADuck()
{
//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
NetworkManager.__rpc_func_table.Add(940042237u, new RpcReceiveHandler(__rpc_handler_940042237));
NetworkManager.__rpc_func_table.Add(2429757260u, new RpcReceiveHandler(__rpc_handler_2429757260));
NetworkManager.__rpc_func_table.Add(545552982u, new RpcReceiveHandler(__rpc_handler_545552982));
NetworkManager.__rpc_func_table.Add(248798015u, new RpcReceiveHandler(__rpc_handler_248798015));
}
private static void __rpc_handler_940042237(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0076: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((DefaultADuck)(object)target).TimerServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2429757260(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;
((DefaultADuck)(object)target).TimerClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_545552982(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0076: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((DefaultADuck)(object)target).SyncSeedServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_248798015(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int currentseed = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref currentseed);
target.__rpc_exec_stage = (__RpcExecStage)2;
((DefaultADuck)(object)target).SyncSeedClientRpc(currentseed);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "DefaultADuck";
}
}
internal class HauntedScrapAI : EnemyAI
{
private enum State
{
MovingToScrap,
SearchingForPlayer,
PlayerFound
}
public Transform turnCompass;
public Transform attackArea;
private List<GrabbableObject> scrapItemsOnMap = new List<GrabbableObject>();
public Transform fakeScrapPOS;
private Random random;
private int realSeed;
private Vector3 chosenScrapLocation;
private bool scrapGrabbed;
private float timer;
private float soundTimer;
private float throwTimer;
private int polterType;
public NavMeshObstacle hauntedPlayerObstacle;
private GrabbableObject chosenScrap;
private bool pickupChosenScrap;
private bool reachedPeak;
private bool onBreak;
private bool targetPlayerSelected;
private PlayerControllerB targetPlayer;
public bool yeetScrap;
public AnimationCurve floatCurve;
public AnimationCurve rotFloatCurve;
public AudioClip passiveSound;
public AnimationCurve itemFallCurve;
public AnimationCurve itemVerticalFallCurve;
public AnimationCurve itemVerticalFallCurveNoBounce;
public RaycastHit itemHit;
public Ray itemThrowRay;
private PlayerControllerB playerThrownBy;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_00e7: 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)
((EnemyAI)this).Start();
realSeed = StartOfRound.Instance.randomMapSeed;
random = new Random(realSeed);
polterType = 1;
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
for (int i = 1; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && array[i].scrapValue > 0 && !array[i].isInShipRoom && array[i].itemProperties.isScrap && ((NetworkBehaviour)array[i]).__getTypeName() != "LungProp")
{
scrapItemsOnMap.Add(array[i]);
MonoBehaviour.print((object)scrapItemsOnMap);
}
}
chosenScrap = scrapItemsOnMap[random.Next(0, scrapItemsOnMap.Count)];
chosenScrapLocation = ((Component)chosenScrap).transform.position;
SyncSeedServerRpc();
Plugin.Logger.LogInfo((object)("Chosen Haunted Scrap: " + (object)chosenScrap));
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
public override void Update()
{
((EnemyAI)this).Update();
timer += Time.deltaTime;
soundTimer += Time.deltaTime;
if (pickupChosenScrap)
{
throwTimer += Time.deltaTime;
if (throwTimer > 10f && random.Next(0, 100) > 1)
{
yeetScrap = true;
}
}
if (pickupChosenScrap)
{
SyncScrapPositionServerRpc();
}
if (timer > 30f)
{
onBreak = false;
}
if (soundTimer > (float)random.Next(15, 90))
{
SyncSeedServerRpc();
chosenScrap.ItemActivate(true, true);
soundTimer = 0f;
((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(passiveSound);
}
}
private void DropCurrentScrap()
{
//IL_0084: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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)
pickupChosenScrap = false;
chosenScrap.grabbable = true;
chosenScrap.parentObject = null;
if (((NetworkBehaviour)this).IsServer)
{
((Component)chosenScrap).transform.SetParent(StartOfRound.Instance.propsContainer, true);
}
chosenScrap.EnablePhysics(true);
chosenScrap.fallTime = 0f;
chosenScrap.startFallingPosition = ((Component)chosenScrap).transform.parent.InverseTransformPoint(((Component)chosenScrap).transform.position);
chosenScrap.targetFloorPosition = ((Component)chosenScrap).transform.parent.InverseTransformPoint(chosenScrap.GetItemFloorPosition(default(Vector3)));
chosenScrap.floorYRot = -1;
((Component)chosenScrap).transform.rotation = Quaternion.Euler(chosenScrap.itemProperties.restingRotation);
}
public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
Plugin.Logger.LogInfo((object)"CALL AN AMBULANCE, CALL AN AMBULANCE, FOR ME");
if (pickupChosenScrap)
{
onBreak = true;
pickupChosenScrap = false;
chosenScrap.grabbable = true;
scrapItemsOnMap.Remove(chosenScrap);
chosenScrap.parentObject = null;
if (((NetworkBehaviour)this).IsServer)
{
((Component)chosenScrap).transform.SetParent(StartOfRound.Instance.propsContainer, true);
}
chosenScrap.EnablePhysics(true);
chosenScrap.fallTime = 0f;
chosenScrap.startFallingPosition = ((Component)chosenScrap).transform.parent.InverseTransformPoint(((Component)chosenScrap).transform.position);
chosenScrap.targetFloorPosition = ((Component)chosenScrap).transform.parent.InverseTransformPoint(chosenScrap.GetItemFloorPosition(default(Vector3)));
chosenScrap.floorYRot = -1;
((Component)chosenScrap).transform.rotation = Quaternion.Euler(chosenScrap.itemProperties.restingRotation);
chosenScrap = scrapItemsOnMap[random.Next(0, scrapItemsOnMap.Count)];
chosenScrapLocation = ((Component)chosenScrap).transform.position;
SyncSeedServerRpc();
Plugin.Logger.LogInfo((object)("New Scrap Target: " + (object)chosenScrap));
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
}
public Vector3 GetItemThrowDestination()
{
//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_0013: 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_002b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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_0130: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)this).transform.position;
Debug.DrawRay(((Component)this).transform.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position, Color.yellow, 15f);
itemThrowRay = new Ray(((Component)this).transform.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position);
position = ((!Physics.Raycast(itemThrowRay, ref itemHit, 12f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) ? ((Ray)(ref itemThrowRay)).GetPoint(10f) : ((Ray)(ref itemThrowRay)).GetPoint(((RaycastHit)(ref itemHit)).distance - 0.05f));
Debug.DrawRay(position, Vector3.down, Color.blue, 15f);
if (Physics.OverlapSphere(position, 0.02f, StartOfRound.Instance.collidersAndRoomMaskAndDefault).Length != 0 && Physics.OverlapSphere(position + Vector3.down * 0.05f, 0.02f, StartOfRound.Instance.collidersAndRoomMaskAndDefault).Length == 0)
{
position += Vector3.down * 0.05f;
}
return ((Ray)(ref itemThrowRay)).GetPoint(30f);
}
public override void DoAIInterval()
{
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_045b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
{
if (!((Object)(object)chosenScrap != (Object)null) || onBreak)
{
break;
}
base.agent.speed = 5f;
bool flag = false;
for (int i = 0; i < 4; i++)
{
flag = ((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadius(chosenScrapLocation, 5f, default(NavMeshHit)), true);
if (flag)
{
break;
}
if (!flag)
{
Plugin.Logger.LogInfo((object)"Failed to path to scrap item! Finding new scrap...");
chosenScrap = scrapItemsOnMap[random.Next(0, scrapItemsOnMap.Count)];
chosenScrapLocation = ((Component)chosenScrap).transform.position;
SyncSeedServerRpc();
Plugin.Logger.LogInfo((object)("New Scrap Target: " + (object)chosenScrap));
break;
}
}
if (Vector3.Distance(((Component)this).transform.position, chosenScrapLocation) < 5f)
{
scrapGrabbed = true;
Plugin.Logger.LogInfo((object)"Scrap grabbed!");
chosenScrap.grabbable = false;
pickupChosenScrap = true;
((EnemyAI)this).StopSearch(base.currentSearch, true);
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
}
break;
}
case 1:
{
base.agent.speed = 7.5f;
float num = 2f;
bool flag2 = false;
if (timer > num)
{
for (int j = 0; j < 4; j++)
{
flag2 = ((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)this).transform.position, 30f, default(NavMeshHit)), true);
if (flag2)
{
break;
}
if (!flag2)
{
((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)this).transform.position, 30f, default(NavMeshHit)), false);
}
}
}
if (timer > (float)random.Next(30, 60))
{
timer = 0f;
DropCurrentScrap();
chosenScrap = scrapItemsOnMap[random.Next(0, scrapItemsOnMap.Count)];
chosenScrapLocation = ((Component)chosenScrap).transform.position;
SyncSeedServerRpc();
Plugin.Logger.LogInfo((object)("New Scrap Target: " + (object)chosenScrap));
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
for (int k = 0; k < GameNetworkManager.Instance.maxAllowedPlayers; k++)
{
if (StartOfRound.Instance.allPlayerScripts[k].HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f))
{
((EnemyAI)this).SwitchToBehaviourServerRpc(2);
}
}
break;
}
case 2:
{
base.agent.speed = 8f;
Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position, true, 0, true);
Plugin.Logger.LogInfo((object)Vector3.Distance(((Component)this).transform.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position));
if (polterType == 1)
{
if ((Object)(object)val != (Object)null && base.mostOptimalDistance > 5f && Physics.Linecast(((Component)val).transform.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
{
base.targetNode = val;
((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
}
if (Vector3.Distance(((Component)this).transform.position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) > 20f && !Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForClosestPlayer(45f, 60, -1, 0f)) && timer > 10f)
{
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
timer = 0f;
}
}
break;
}
default:
LogIfDebugBuild("This Behavior State doesn't exist!");
break;
}
}
[ServerRpc(RequireOwnership = false)]
private void SyncSeedServerRpc()
{
//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1425415174u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1425415174u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
{
realSeed++;
SyncSeedClientRpc(realSeed);
}
}
}
[ClientRpc]
private void SyncSeedClientRpc(int currentseed)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: 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)
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(3065679223u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, currentseed);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3065679223u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
realSeed = currentseed;
}
}
}
[ServerRpc(RequireOwnership = false)]
private void SyncScrapPositionServerRpc()
{
//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1494274796u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1494274796u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SyncScrapPositionClientRpc();
}
}
}
[ClientRpc]
private void SyncScrapPositionClientRpc()
{
//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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: 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_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
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(1792076212u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1792076212u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
floatCurve.ClearKeys();
floatCurve.AddKey(0f, ((Component)fakeScrapPOS).transform.position.y + 1f);
floatCurve.AddKey(2f, ((Component)fakeScrapPOS).transform.position.y + 0.75f);
floatCurve.AddKey(3f, ((Component)fakeScrapPOS).transform.position.y + 1.2f);
floatCurve.AddKey(4f, ((Component)fakeScrapPOS).transform.position.y + 1f);
rotFloatCurve.AddKey(0f, fakeScrapPOS.rotation.z);
rotFloatCurve.AddKey(2f, fakeScrapPOS.rotation.z - 0.75f);
rotFloatCurve.AddKey(2.5f, fakeScrapPOS.rotation.z);
chosenScrap.targetFloorPosition = new Vector3(((Component)fakeScrapPOS).transform.position.x, floatCurve.Evaluate(Time.time % (float)floatCurve.length), ((Component)fakeScrapPOS).transform.position.z);
((Component)chosenScrap).transform.Rotate(new Vector3(fakeScrapPOS.rotation.x, fakeScrapPOS.rotation.y, rotFloatCurve.Evaluate(Time.time % (float)rotFloatCurve.length)));
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_HauntedScrapAI()
{
//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
NetworkManager.__rpc_func_table.Add(1425415174u, new RpcReceiveHandler(__rpc_handler_1425415174));
NetworkManager.__rpc_func_table.Add(3065679223u, new RpcReceiveHandler(__rpc_handler_3065679223));
NetworkManager.__rpc_func_table.Add(1494274796u, new RpcReceiveHandler(__rpc_handler_1494274796));
NetworkManager.__rpc_func_table.Add(1792076212u, new RpcReceiveHandler(__rpc_handler_1792076212));
}
private static void __rpc_handler_1425415174(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)1;
((HauntedScrapAI)(object)target).SyncSeedServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3065679223(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int currentseed = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref currentseed);
target.__rpc_exec_stage = (__RpcExecStage)2;
((HauntedScrapAI)(object)target).SyncSeedClientRpc(currentseed);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1494274796(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)1;
((HauntedScrapAI)(object)target).SyncScrapPositionServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1792076212(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;
((HauntedScrapAI)(object)target).SyncScrapPositionClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "HauntedScrapAI";
}
}
}
namespace HauntedScrap.Configuration
{
public class PluginConfig
{
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 HauntedScrap.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}