using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 Elekrisk.IPMaster.NetcodePatcher;
using GameNetcodeStuff;
using GraphicsAPI.CustomPostProcessing;
using IPMaster.Configuration;
using IPMaster.Stalker;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UIElements.Collections;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Elekrisk.IPMaster")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+01e53a1e8bb881beed9c248ed3baabb093e1a8d4")]
[assembly: AssemblyProduct("IPMaster")]
[assembly: AssemblyTitle("Elekrisk.IPMaster")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace IPMaster
{
internal class ExampleEnemyAI : EnemyAI
{
private enum State
{
SearchingForPlayer,
StickingInFrontOfPlayer,
HeadSwingAttackInProgress
}
public Transform turnCompass;
public Transform attackArea;
private float timeSinceHittingLocalPlayer;
private float timeSinceNewRandPos;
private Vector3 positionRandomness;
private Vector3 StalkPos;
private Random enemyRandom;
private bool isDeadAnimationDone;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
timeSinceHittingLocalPlayer = 0f;
base.creatureAnimator.SetTrigger("startWalk");
timeSinceNewRandPos = 0f;
positionRandomness = new Vector3(0f, 0f, 0f);
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
isDeadAnimationDone = false;
base.currentBehaviourStateIndex = 0;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
}
public override void Update()
{
//IL_0091: 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_00b7: 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_00cb: 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)
((EnemyAI)this).Update();
if (base.isEnemyDead)
{
if (!isDeadAnimationDone)
{
isDeadAnimationDone = true;
base.creatureVoice.Stop();
base.creatureVoice.PlayOneShot(base.dieSFX);
}
return;
}
timeSinceHittingLocalPlayer += Time.deltaTime;
timeSinceNewRandPos += Time.deltaTime;
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 2))
{
turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
}
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
}
}
public override void DoAIInterval()
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
base.agent.speed = 3f;
if (FoundClosestPlayerInRange(25f, 3f))
{
((EnemyAI)this).StopSearch(base.currentSearch, true);
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
break;
case 1:
base.agent.speed = 5f;
if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
{
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
else
{
StickingInFrontOfPlayer();
}
break;
case 2:
break;
}
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
if ((Object)(object)base.targetPlayer != (Object)null)
{
return Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
return false;
}
private bool TargetClosestPlayerInAnyCase()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
base.mostOptimalDistance = 2000f;
base.targetPlayer = null;
for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
{
base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
if (base.tempDist < base.mostOptimalDistance)
{
base.mostOptimalDistance = base.tempDist;
base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
}
}
if ((Object)(object)base.targetPlayer == (Object)null)
{
return false;
}
return true;
}
private void StickingInFrontOfPlayer()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner && timeSinceNewRandPos > 0.7f)
{
timeSinceNewRandPos = 0f;
if (enemyRandom.Next(0, 5) == 0)
{
((MonoBehaviour)this).StartCoroutine(SwingAttack());
}
else
{
positionRandomness = new Vector3((float)enemyRandom.Next(-2, 2), 0f, (float)enemyRandom.Next(-2, 2));
StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-5f, 0f, -5f), ((Component)base.targetPlayer).transform.forward) + positionRandomness;
}
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
}
}
private IEnumerator SwingAttack()
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
StalkPos = ((Component)base.targetPlayer).transform.position;
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
yield return (object)new WaitForSeconds(0.5f);
if (!base.isEnemyDead)
{
DoAnimationClientRpc("swingAttack");
yield return (object)new WaitForSeconds(0.35f);
SwingAttackHitClientRpc();
if (base.currentBehaviourStateIndex == 2)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
}
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (!(timeSinceHittingLocalPlayer < 1f))
{
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
timeSinceHittingLocalPlayer = 0f;
val.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
if (!base.isEnemyDead)
{
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
{
((MonoBehaviour)this).StopCoroutine(SwingAttack());
((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
((EnemyAI)this).KillEnemyOnOwnerClient(false);
}
}
}
[ClientRpc]
public void DoAnimationClientRpc(string animationName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2886986324u, 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, 2886986324u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
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_00c3: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: 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)
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(2908619385u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2908619385u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
int num = 8;
Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
if (array.Length == 0)
{
return;
}
Collider[] array2 = array;
foreach (Collider val3 in array2)
{
PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
if ((Object)(object)val4 != (Object)null)
{
timeSinceHittingLocalPlayer = 0f;
val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_ExampleEnemyAI()
{
//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(2886986324u, new RpcReceiveHandler(__rpc_handler_2886986324));
NetworkManager.__rpc_func_table.Add(2908619385u, new RpcReceiveHandler(__rpc_handler_2908619385));
}
private static void __rpc_handler_2886986324(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;
((ExampleEnemyAI)(object)target).DoAnimationClientRpc(animationName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2908619385(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;
((ExampleEnemyAI)(object)target).SwingAttackHitClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ExampleEnemyAI";
}
}
[BepInPlugin("Elekrisk.IPMaster", "IPMaster", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static AssetBundle? ModAssets;
private static EnemyType stalker;
private static AudioMixer audioMixer;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
InitializeNetworkBehaviours();
string path = "elekrisk.ipmaster.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;
}
stalker = ModAssets.LoadAsset<EnemyType>("Stalker");
NetworkPrefabs.RegisterNetworkPrefab(stalker.enemyPrefab);
Enemies.RegisterEnemy(stalker, 25, (LevelTypes)(-1), (TerminalNode)null, (TerminalKeyword)null);
audioMixer = ModAssets.LoadAsset<AudioMixer>("StalkerAudioMixer");
CustomPostProcessingManager.OnLoad += CustomPostProcessingManager_OnLoad;
Logger.LogInfo((object)"Plugin Elekrisk.IPMaster is loaded!");
}
private void CustomPostProcessingManager_OnLoad(object sender, EventArgs e)
{
//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_0023: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
Material val = ModAssets.LoadAsset<Material>("StalkerMaterial");
PostProcess val2 = new PostProcess("elekrisk.IPMaster.Stalker", val)
{
InjectionType = (InjectionType)5
};
FullScreenCustomPass customPass = CustomPostProcessingManager.Instance.AddPostProcess(val2);
GameObject val3 = new GameObject("PostProcessorHandler");
PostProcessorHandler postProcessorHandler = val3.AddComponent<PostProcessorHandler>();
postProcessorHandler.Initialize(val, customPass);
postProcessorHandler.AudioMixer = audioMixer;
}
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 = "Elekrisk.IPMaster";
public const string PLUGIN_NAME = "IPMaster";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace IPMaster.Stalker
{
internal class PostProcessorHandler : MonoBehaviour
{
public float MinVolume = 40f;
private Material fullscreenMaterial;
private FullScreenCustomPass customPass;
private RenderTexture? renderTexture;
private GameObject? stalkerCamera;
private Dictionary<int, float> activeStalkers = new Dictionary<int, float>();
private int closestStalker = -1;
private float smallestDist = float.PositiveInfinity;
private float currentStrength;
private float _strengthTarget;
private float strengthDecay = 0.5f;
private bool passEnabled;
public AudioMixer AudioMixer;
private float StrengthTarget
{
get
{
return _strengthTarget;
}
set
{
_strengthTarget = value;
if (value > currentStrength)
{
UpdateStrengthValue(value);
}
}
}
public static PostProcessorHandler Instance { get; private set; }
private void UpdateStrengthValue(float value)
{
currentStrength = value;
fullscreenMaterial.SetFloat("_Strength", value);
if (!AudioMixer.SetFloat("AllExceptStalkerVolume", (0f - value) * MinVolume))
{
Plugin.Logger.LogWarning((object)"Cannot set AllExceptStalkerVolume property");
}
}
private void Awake()
{
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
Instance = this;
}
private void Update()
{
if (currentStrength > StrengthTarget)
{
currentStrength -= strengthDecay * Time.deltaTime;
if (currentStrength < StrengthTarget)
{
currentStrength = StrengthTarget;
}
UpdateStrengthValue(currentStrength);
}
RecreateRenderTextureIfNeeded();
if (!passEnabled && currentStrength == 0f && ((CustomPass)customPass).enabled)
{
passEnabled = false;
((CustomPass)customPass).enabled = false;
DestroyStalkerCamera();
RestoreAudioMixer();
}
}
public void Initialize(Material material, FullScreenCustomPass customPass)
{
fullscreenMaterial = material;
this.customPass = customPass;
((CustomPass)customPass).enabled = false;
}
private void CreateStalkerCamera()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
stalkerCamera = new GameObject("StalkerCamera");
Camera val = stalkerCamera.AddComponent<Camera>();
Camera gameplayCamera = StartOfRound.Instance.localPlayerController.gameplayCamera;
val.fieldOfView = gameplayCamera.fieldOfView;
val.backgroundColor = Color.black;
val.cullingMask = int.MinValue;
stalkerCamera.AddComponent<HDAdditionalCameraData>();
stalkerCamera.transform.SetParent(((Component)gameplayCamera).transform, false);
RecreateRenderTextureIfNeeded(force: true);
gameplayCamera.cullingMask &= 0x7FFFFFFF;
}
private void DestroyStalkerCamera()
{
if ((Object)(object)stalkerCamera != (Object)null)
{
Object.Destroy((Object)(object)stalkerCamera);
stalkerCamera = null;
}
}
public void RecreateRenderTextureIfNeeded(bool force = false)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
Camera gameplayCamera = StartOfRound.Instance.localPlayerController.gameplayCamera;
if (force || (Object)(object)renderTexture == (Object)null || !renderTexture.IsCreated() || ((Texture)renderTexture).width != gameplayCamera.pixelWidth || ((Texture)renderTexture).height != gameplayCamera.pixelHeight)
{
RenderTexture? obj = renderTexture;
if (obj != null)
{
obj.Release();
}
renderTexture = new RenderTexture(gameplayCamera.pixelWidth, gameplayCamera.pixelHeight, 0);
if ((Object)(object)stalkerCamera != (Object)null)
{
stalkerCamera.GetComponent<Camera>().targetTexture = renderTexture;
}
fullscreenMaterial.SetTexture("_StalkerRenderTexture", (Texture)(object)renderTexture);
}
}
public void RegisterStalker(StalkerAI stalker)
{
Plugin.Logger.LogInfo((object)("Registering stalker " + stalker.StalkerId));
if (activeStalkers.Count == 0)
{
Enable();
}
activeStalkers.Add(stalker.StalkerId, float.PositiveInfinity);
}
public void DeregisterStalker(StalkerAI stalker)
{
activeStalkers.Remove(stalker.StalkerId);
if (closestStalker == stalker.StalkerId)
{
RecalculateClosestStalker();
}
if (activeStalkers.Count == 0)
{
Disable();
}
}
public void UpdateDistance(StalkerAI stalker, float distance)
{
activeStalkers[stalker.StalkerId] = distance;
if (stalker.StalkerId == closestStalker)
{
if (distance > smallestDist)
{
RecalculateClosestStalker();
}
else
{
UpdateSmallestDistance(distance);
}
}
else if (distance < smallestDist)
{
closestStalker = stalker.StalkerId;
UpdateSmallestDistance(distance);
}
}
private void RecalculateClosestStalker()
{
KeyValuePair<int, float> keyValuePair = new KeyValuePair<int, float>(-1, float.PositiveInfinity);
if (activeStalkers.Count > 0)
{
keyValuePair = activeStalkers.Aggregate((KeyValuePair<int, float> l, KeyValuePair<int, float> r) => (!(l.Value < r.Value)) ? r : l);
}
closestStalker = keyValuePair.Key;
UpdateSmallestDistance(keyValuePair.Value);
}
private void UpdateSmallestDistance(float distance)
{
smallestDist = distance;
StrengthTarget = Mathf.Pow(Mathf.Clamp01(1f - smallestDist / 10f), 2f);
}
public void Enable()
{
passEnabled = true;
((CustomPass)customPass).enabled = true;
fullscreenMaterial.SetFloat("_Strength", 0f);
currentStrength = 0f;
_strengthTarget = 0f;
CreateStalkerCamera();
RecreateRenderTextureIfNeeded();
InjectAudioMixer();
}
public void InjectAudioMixer()
{
SoundManager.Instance.diageticMixer.outputAudioMixerGroup = AudioMixer.FindMatchingGroups("AllExceptStalker")[0];
}
public void RestoreAudioMixer()
{
SoundManager.Instance.diageticMixer.outputAudioMixerGroup = null;
}
public void Disable()
{
StrengthTarget = 0f;
passEnabled = false;
}
}
internal class StalkerAI : EnemyAI
{
private enum State
{
Searching,
JustSwitchedTarget,
Following
}
private static int nextId;
private int stalkerId = nextId++;
private bool registered;
private float timeSinceDeath;
private float effectRamp;
private float stareTimer;
private bool destroyed;
private float timeSinceLastAttack;
public int StalkerId => stalkerId;
public override void Start()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
Plugin.Logger.LogInfo((object)"Stalker Spawned");
base.agent.speed = 0.75f;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
base.creatureAnimator.SetTrigger("startWalk");
}
public override void Update()
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
AudioSource component = ((Component)((Component)this).transform.Find("NoiseSource")).gameObject.GetComponent<AudioSource>();
if (base.isEnemyDead)
{
if (!destroyed && timeSinceDeath >= 2f)
{
destroyed = true;
((EnemyAI)this).KillEnemy(true);
return;
}
component.volume = Mathf.Clamp01(Mathf.Pow(1f - timeSinceDeath / 2f, 2f));
timeSinceDeath += Time.deltaTime;
}
if (!base.isEnemyDead && !registered)
{
effectRamp = 0f;
((Behaviour)component).enabled = false;
return;
}
((Behaviour)component).enabled = true;
if (registered)
{
effectRamp = Mathf.MoveTowards(effectRamp, 1f, GetStareTimeIncreaseForDelta(Time.deltaTime));
component.volume = Mathf.Clamp01(Mathf.Pow(effectRamp, 2f));
GameObject gameObject = ((Component)StartOfRound.Instance.localPlayerController).gameObject;
float distance = Vector3.Distance(gameObject.transform.position, ((Component)this).gameObject.transform.position) + 10f * (1f - effectRamp);
PostProcessorHandler.Instance.UpdateDistance(this, distance);
}
}
public override void DoAIInterval()
{
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: 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_0077: 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_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: 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:
{
bool flag = ((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if (!flag && ((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
{
if (Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) > 10f)
{
base.targetPlayer = null;
}
else
{
flag = true;
}
}
if (flag)
{
Plugin.Logger.LogInfo((object)("Found player " + base.targetPlayer.playerUsername));
((EnemyAI)this).StopSearch(base.currentSearch, true);
TargetPlayer(base.targetPlayer);
Plugin.Logger.LogInfo((object)"Starting to stare...");
((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
stareTimer = 0f;
((EnemyAI)this).SwitchToBehaviourState(1);
}
break;
}
case 1:
((Component)this).transform.LookAt(((Component)base.targetPlayer).transform);
if (stareTimer >= 1f)
{
Plugin.Logger.LogInfo((object)"Starting to move towards player...");
((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
((EnemyAI)this).SwitchToBehaviourState(2);
}
stareTimer += GetStareTimeIncreaseForDelta(base.AIIntervalTime);
break;
case 2:
if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
{
Plugin.Logger.LogInfo((object)"Lost player");
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
TargetPlayer(null);
((EnemyAI)this).SwitchToBehaviourState(0);
}
else if (Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) < 2f && timeSinceLastAttack >= 1f)
{
timeSinceLastAttack = 0f;
DamagePlayerClientRpc(base.targetPlayer.playerClientId, 20);
}
break;
}
timeSinceLastAttack += base.AIIntervalTime;
}
private float GetStareTimeIncreaseForDelta(float delta)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
return delta * (1f / (11f - Mathf.Clamp(Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position), 1f, 10f)));
}
private void TargetPlayer(PlayerControllerB? player)
{
if (((NetworkBehaviour)this).IsServer)
{
TargetPlayerClientRpc((ulong)(((long?)player?.actualClientId) ?? (-1L)));
}
else if (((NetworkBehaviour)this).IsClient)
{
TargetPlayerServerRpc((ulong)(((long?)player?.actualClientId) ?? (-1L)));
}
}
[ServerRpc]
private void TargetPlayerServerRpc(ulong clientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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_00b7: 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_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(640718169u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, clientId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 640718169u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
TargetPlayerClientRpc(clientId);
}
}
[ClientRpc]
private void TargetPlayerClientRpc(ulong clientId)
{
//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)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1150960288u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, clientId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1150960288u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
PlayerControllerB val3 = null;
if (clientId != ulong.MaxValue)
{
int num = DictionaryExtensions.Get<ulong, int>((IDictionary<ulong, int>)StartOfRound.Instance.ClientPlayerList, clientId, 0);
val3 = StartOfRound.Instance.allPlayerScripts[num];
}
if ((Object)(object)val3 == (Object)null && clientId != ulong.MaxValue)
{
Plugin.Logger.LogWarning((object)$"Stalker could not switch to player with clientId : {clientId}");
return;
}
base.targetPlayer = val3;
if ((Object)(object)base.targetPlayer == (Object)(object)StartOfRound.Instance.localPlayerController)
{
Register();
}
else
{
Deregister();
}
}
private void Register()
{
if (!registered)
{
PostProcessorHandler.Instance.RegisterStalker(this);
registered = true;
}
}
private void Deregister()
{
if (registered)
{
PostProcessorHandler.Instance.DeregisterStalker(this);
registered = false;
}
}
public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
if (base.isEnemyDead)
{
return;
}
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner)
{
if (base.enemyHP <= 0 && !base.isEnemyDead)
{
((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
((EnemyAI)this).KillEnemyOnOwnerClient(false);
}
else if ((Object)(object)playerWhoHit != (Object)null && (Object)(object)playerWhoHit != (Object)(object)base.targetPlayer)
{
TargetPlayer(playerWhoHit);
((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
((EnemyAI)this).SwitchToBehaviourState(2);
}
}
}
public override void KillEnemy(bool destroy = false)
{
PostProcessorHandler.Instance.DeregisterStalker(this);
registered = false;
((EnemyAI)this).KillEnemy(false);
}
[ClientRpc]
private void DamagePlayerClientRpc(ulong playerClientId, int amount)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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)
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(2813933043u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerClientId);
BytePacker.WriteValueBitPacked(val2, amount);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2813933043u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && GameNetworkManager.Instance.localPlayerController.playerClientId == playerClientId)
{
Plugin.Logger.LogInfo((object)"Damaged player");
GameNetworkManager.Instance.localPlayerController.DamagePlayer(amount, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
~StalkerAI()
{
try
{
if (registered)
{
PostProcessorHandler.Instance.DeregisterStalker(this);
registered = false;
}
}
finally
{
((object)this).Finalize();
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_StalkerAI()
{
//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
NetworkManager.__rpc_func_table.Add(640718169u, new RpcReceiveHandler(__rpc_handler_640718169));
NetworkManager.__rpc_func_table.Add(1150960288u, new RpcReceiveHandler(__rpc_handler_1150960288));
NetworkManager.__rpc_func_table.Add(2813933043u, new RpcReceiveHandler(__rpc_handler_2813933043));
}
private static void __rpc_handler_640718169(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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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
{
ulong clientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((StalkerAI)(object)target).TargetPlayerServerRpc(clientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1150960288(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)
{
ulong clientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((StalkerAI)(object)target).TargetPlayerClientRpc(clientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2813933043(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0043: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong playerClientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId);
int amount = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref amount);
target.__rpc_exec_stage = (__RpcExecStage)2;
((StalkerAI)(object)target).DamagePlayerClientRpc(playerClientId, amount);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "StalkerAI";
}
}
}
namespace IPMaster.Configuration
{
public class PluginConfig
{
public PluginConfig(ConfigFile cfg)
{
ClearUnusedEntries(cfg);
}
private void ClearUnusedEntries(ConfigFile cfg)
{
PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
dictionary.Clear();
cfg.Save();
}
}
}
namespace Elekrisk.IPMaster.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}