using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using FairAI;
using FairAI.Component;
using FairAI.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalThings;
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: AssemblyTitle("FairAI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FairAI")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("42deea12-f73e-4d63-81e9-5359e98c8d53")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
internal class TurretAIPatch
{
public static float viewRadius = 16f;
public static float viewAngle = 90f;
public static bool PatchUpdate(ref Turret __instance)
{
//IL_0012: 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_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected I4, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Invalid comparison between Unknown and I4
//IL_0156: 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)
//IL_0213: 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_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance == (Object)null) && Plugin.AllowFairness(((Component)__instance).transform.position))
{
FAIR_AI fAIR_AI = ((Component)__instance).gameObject.GetComponent<FAIR_AI>() ?? ((Component)__instance).gameObject.AddComponent<FAIR_AI>();
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("wasTargetingPlayerLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("rotatingClockwise", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method = typeFromHandle.GetMethod("SetTargetToPlayerBody", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method2 = typeFromHandle.GetMethod("TurnTowardsTargetIfHasLOS", BindingFlags.Instance | BindingFlags.NonPublic);
if (!__instance.turretActive)
{
field.SetValue(__instance, false);
__instance.turretMode = (TurretMode)0;
__instance.targetPlayerWithRotation = null;
fAIR_AI.targetWithRotation = null;
return false;
}
if ((Object)(object)fAIR_AI.targetWithRotation != (Object)null || (Object)(object)__instance.targetPlayerWithRotation != (Object)null)
{
if (!(bool)field.GetValue(__instance))
{
field.SetValue(__instance, true);
if ((int)__instance.turretMode == 0)
{
if ((Object)(object)fAIR_AI.targetWithRotation != (Object)null)
{
__instance.turretMode = (TurretMode)2;
}
else
{
__instance.turretMode = (TurretMode)1;
}
}
}
SetTargetToEnemyBody(ref __instance);
TurnTowardsTargetEnemyIfHasLOS(ref __instance);
}
else if ((bool)field.GetValue(__instance))
{
field.SetValue(__instance, false);
__instance.turretMode = (TurretMode)0;
}
TurretMode turretMode = __instance.turretMode;
TurretMode val = turretMode;
switch ((int)val)
{
case 0:
DetectionFunction(__instance, fAIR_AI);
break;
case 1:
ChargingFunction(__instance, fAIR_AI);
break;
case 2:
FiringFunction(__instance);
break;
case 3:
BerserkFunction(__instance);
break;
}
if ((bool)field2.GetValue(__instance))
{
__instance.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, __instance.turretRod.localEulerAngles.y - Time.deltaTime * 20f, 180f);
__instance.turretRod.rotation = Quaternion.RotateTowards(__instance.turretRod.rotation, __instance.turnTowardsObjectCompass.rotation, __instance.rotationSpeed * Time.deltaTime);
return false;
}
if ((bool)field3.GetValue(__instance))
{
__instance.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, Mathf.Clamp(__instance.targetRotation, 0f - __instance.rotationRange, __instance.rotationRange), 180f);
}
__instance.turretRod.rotation = Quaternion.RotateTowards(__instance.turretRod.rotation, __instance.turnTowardsObjectCompass.rotation, __instance.rotationSpeed * Time.deltaTime);
return false;
}
return false;
}
public static void DetectionFunction(Turret turret, FAIR_AI turret_ai)
{
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_0371: Unknown result type (might be due to invalid IL or missing references)
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("turretModeLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("rotatingClockwise", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("fadeBulletAudioCoroutine", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field5 = typeFromHandle.GetField("turretInterval", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field6 = typeFromHandle.GetField("switchRotationTimer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field7 = typeFromHandle.GetField("rotatingRight", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method2 = typeFromHandle.GetMethod("FadeBulletAudio", BindingFlags.Instance | BindingFlags.NonPublic);
if ((int)field.GetValue(turret) != 0)
{
field.SetValue(turret, (object)(TurretMode)0);
field2.SetValue(turret, false);
turret.mainAudio.Stop();
turret.farAudio.Stop();
turret.berserkAudio.Stop();
if (field3.GetValue(turret) != null)
{
((MonoBehaviour)turret).StopCoroutine((Coroutine)field3.GetValue(turret));
}
field3.SetValue(turret, ((MonoBehaviour)turret).StartCoroutine((IEnumerator)method2.Invoke(turret, new object[0])));
turret.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
if (Plugin.turretSettings.Count > 7)
{
turret.rotationSpeed = Plugin.turretSettings[5];
}
else
{
turret.rotationSpeed = 28f;
}
field4.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
field5.SetValue(turret, Random.Range(0f, 0.15f));
}
if (!((NetworkBehaviour)turret).IsServer)
{
return;
}
if (Plugin.turretSettings.Count > 7)
{
if ((float)field6.GetValue(turret) >= Plugin.turretSettings[3])
{
field6.SetValue(turret, 0f);
bool flag = !(bool)field7.GetValue(turret);
turret.SwitchRotationClientRpc(flag);
turret.SwitchRotationOnInterval(flag);
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
}
else if ((float)field6.GetValue(turret) >= 7f)
{
field6.SetValue(turret, 0f);
bool flag2 = !(bool)field7.GetValue(turret);
turret.SwitchRotationClientRpc(flag2);
turret.SwitchRotationOnInterval(flag2);
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
if ((float)field5.GetValue(turret) >= 0.25f)
{
field5.SetValue(turret, 0f);
EnemyAICollisionDetect val = CheckForEnemiesInLineOfSight(turret, 15f);
if ((Object)(object)val != (Object)null && !val.mainScript.isEnemyDead && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", val.mainScript.enemyType.enemyName))
{
turret_ai.targetWithRotation = val.mainScript;
turret.turretMode = (TurretMode)2;
turret.SetToModeClientRpc(2);
method.Invoke(turret, new object[1] { (object)(TurretMode)2 });
turret_ai.SwitchedTargetedEnemyClientRpc(turret, val.mainScript);
Plugin.logger.LogInfo((object)"Detected Enemy!");
return;
}
field5.SetValue(turret, 0f);
PlayerControllerB val2 = CheckForPlayersInLOS(turret, 1.35f, angleRangeCheck: true);
if ((Object)(object)val2 != (Object)null && !val2.isPlayerDead)
{
turret.targetPlayerWithRotation = val2;
method.Invoke(turret, new object[1] { 1 });
turret.SwitchTargetedPlayerClientRpc((int)val2.playerClientId, true);
Plugin.logger.LogInfo((object)"Detected Player!");
}
}
else
{
field5.SetValue(turret, (float)field5.GetValue(turret) + Time.deltaTime);
}
}
public static void ChargingFunction(Turret turret, FAIR_AI turret_ai)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("hasLineOfSight", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("turretModeLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("rotatingClockwise", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field5 = typeFromHandle.GetField("turretInterval", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field6 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
if ((int)(TurretMode)field2.GetValue(turret) != 1)
{
field2.SetValue(turret, (object)(TurretMode)1);
field3.SetValue(turret, false);
turret.mainAudio.PlayOneShot(turret.detectPlayerSFX);
turret.berserkAudio.Stop();
WalkieTalkie.TransmitOneShotAudio(turret.mainAudio, turret.detectPlayerSFX, 1f);
if (Plugin.turretSettings.Count > 7)
{
turret.rotationSpeed = Plugin.turretSettings[6];
}
else
{
turret.rotationSpeed = 95f;
}
field4.SetValue(turret, false);
field6.SetValue(turret, 0f);
turret.turretAnimator.SetInteger("TurretMode", 1);
}
if (!((NetworkBehaviour)turret).IsServer)
{
return;
}
if ((float)field5.GetValue(turret) >= 1.5f)
{
field5.SetValue(turret, 0f);
Plugin.logger.LogInfo((object)"Charging timer is up, setting to firing mode");
if (!(bool)field.GetValue(turret))
{
Plugin.logger.LogInfo((object)"hasLineOfSight is false");
turret.targetPlayerWithRotation = null;
turret.RemoveTargetedPlayerClientRpc();
turret_ai.targetWithRotation = null;
turret_ai.RemoveTargetedEnemyClientRpc();
}
else
{
method.Invoke(turret, new object[1] { 2 });
turret.SetToModeClientRpc(2);
}
}
else
{
field5.SetValue(turret, (float)field5.GetValue(turret) + Time.deltaTime);
}
}
public static void FiringFunction(Turret turret)
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Invalid comparison between Unknown and I4
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_081c: Unknown result type (might be due to invalid IL or missing references)
//IL_0827: Unknown result type (might be due to invalid IL or missing references)
//IL_082c: Unknown result type (might be due to invalid IL or missing references)
//IL_083e: Unknown result type (might be due to invalid IL or missing references)
//IL_084c: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
//IL_08da: Unknown result type (might be due to invalid IL or missing references)
//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
//IL_08ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0901: Unknown result type (might be due to invalid IL or missing references)
//IL_0906: Unknown result type (might be due to invalid IL or missing references)
//IL_0914: Unknown result type (might be due to invalid IL or missing references)
//IL_0919: Unknown result type (might be due to invalid IL or missing references)
//IL_0872: Unknown result type (might be due to invalid IL or missing references)
//IL_0894: Unknown result type (might be due to invalid IL or missing references)
//IL_0899: Unknown result type (might be due to invalid IL or missing references)
//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
//IL_08aa: Unknown result type (might be due to invalid IL or missing references)
//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
//IL_077b: Unknown result type (might be due to invalid IL or missing references)
//IL_0781: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_0428: Unknown result type (might be due to invalid IL or missing references)
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_043b: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0801: Unknown result type (might be due to invalid IL or missing references)
//IL_0807: Unknown result type (might be due to invalid IL or missing references)
//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
//IL_051a: Unknown result type (might be due to invalid IL or missing references)
//IL_0a99: Unknown result type (might be due to invalid IL or missing references)
//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
//IL_064a: Unknown result type (might be due to invalid IL or missing references)
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("wasTargetingPlayerLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("turretModeLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = typeFromHandle.GetField("fadeBulletAudioCoroutine", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field5 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field6 = typeFromHandle.GetField("turretInterval", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field7 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field8 = typeFromHandle.GetField("shootRay", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field9 = typeFromHandle.GetField("hit", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
if ((int)(TurretMode)field2.GetValue(turret) != 2)
{
field2.SetValue(turret, (object)(TurretMode)2);
turret.berserkAudio.Stop();
RoundManager.Instance.PlayAudibleNoise(((Component)turret.berserkAudio).transform.position, 15f, 0.9f, 0, false, 0);
turret.mainAudio.clip = turret.firingSFX;
turret.mainAudio.Play();
turret.farAudio.clip = turret.firingFarSFX;
turret.farAudio.Play();
turret.bulletParticles.Play(true);
turret.bulletCollisionAudio.Play();
if (field4 != null && field4.GetValue(turret) != null)
{
((MonoBehaviour)turret).StopCoroutine((Coroutine)field4.GetValue(turret));
}
turret.bulletCollisionAudio.volume = 1f;
field5.SetValue(turret, false);
field7.SetValue(turret, 0f);
turret.turretAnimator.SetInteger("TurretMode", 2);
}
Ray val5;
if (Plugin.turretSettings.Count > 7)
{
if ((float)field6.GetValue(turret) >= Plugin.turretSettings[1])
{
Plugin.logger.LogInfo((object)"Attacking Target");
field6.SetValue(turret, 0f);
if ((Object)(object)CheckForPlayersInLOS(turret, 3f) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
int num = (int)Plugin.turretSettings[0];
if (num <= 0)
{
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
GameNetworkManager.Instance.localPlayerController.DamagePlayer(num, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
}
else if ((float)GameNetworkManager.Instance.localPlayerController.health > Plugin.turretSettings[0])
{
GameNetworkManager.Instance.localPlayerController.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
}
else
{
GameNetworkManager.Instance.localPlayerController.KillPlayer(turret.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0, default(Vector3), false);
}
}
field8.SetValue(turret, (object)new Ray(turret.aimPoint.position, turret.aimPoint.forward));
RaycastHit val = default(RaycastHit);
if (Physics.Raycast((Ray)field8.GetValue(turret), ref val, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
{
field9.SetValue(turret, val);
Transform transform = ((Component)turret.bulletCollisionAudio).transform;
Ray val2 = (Ray)field8.GetValue(turret);
RaycastHit val3 = (RaycastHit)field9.GetValue(turret);
Ray val4 = val2;
val5 = val4;
transform.position = ((Ray)(ref val5)).GetPoint(((RaycastHit)(ref val3)).distance - 0.5f);
}
Vector3 forward = turret.aimPoint.forward;
forward = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 3f, 0f) * forward;
Plugin.AttackTargets(((Component)turret).GetComponent<FAIR_AI>(), turret.aimPoint.position, forward, 30f);
FAIR_AI component = ((Component)turret).GetComponent<FAIR_AI>();
if ((Object)(object)component.targetWithRotation != (Object)null)
{
EnemyAICollisionDetect component2 = ((Component)component.targetWithRotation).GetComponent<EnemyAICollisionDetect>();
if ((Object)(object)component2 != (Object)null && (component2.mainScript.isEnemyDead || component2.mainScript.enemyHP <= 0))
{
component.targetWithRotation = null;
component.RemoveTargetedEnemyClientRpc();
}
}
if ((Object)(object)turret.targetPlayerWithRotation != (Object)null && turret.targetPlayerWithRotation.isPlayerDead)
{
turret.targetPlayerWithRotation = null;
turret.RemoveTargetedPlayerClientRpc();
}
if ((Object)(object)turret.targetPlayerWithRotation == (Object)null && (Object)(object)component.targetWithRotation == (Object)null)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
else
{
if (!((Object)(object)turret.targetTransform != (Object)null))
{
return;
}
if ((Object)(object)((Component)turret.targetTransform).GetComponent<EnemyAI>() != (Object)null)
{
if (((Component)turret.targetTransform).GetComponent<EnemyAI>().isEnemyDead)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
}
else if (Object.op_Implicit((Object)(object)((Component)turret.targetTransform).GetComponent<EnemyAICollisionDetect>()) && ((Component)turret.targetTransform).GetComponent<EnemyAICollisionDetect>().mainScript.isEnemyDead)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
}
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
}
else if ((float)field6.GetValue(turret) >= 0.21f)
{
Plugin.logger.LogInfo((object)"Attacking Target");
field6.SetValue(turret, 0f);
if ((Object)(object)CheckForPlayersInLOS(turret, 3f) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
int @int = Plugin.GetInt("TurretConfig", "Player Damage");
if (@int <= 0)
{
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
GameNetworkManager.Instance.localPlayerController.DamagePlayer(@int, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
}
else if (GameNetworkManager.Instance.localPlayerController.health > 50)
{
GameNetworkManager.Instance.localPlayerController.DamagePlayer(@int, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
}
else
{
GameNetworkManager.Instance.localPlayerController.KillPlayer(turret.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0, default(Vector3), false);
}
}
field8.SetValue(turret, (object)new Ray(turret.aimPoint.position, turret.aimPoint.forward));
RaycastHit val6 = default(RaycastHit);
if (Physics.Raycast((Ray)field8.GetValue(turret), ref val6, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
{
field9.SetValue(turret, val6);
Transform transform2 = ((Component)turret.bulletCollisionAudio).transform;
Ray val7 = (Ray)field8.GetValue(turret);
RaycastHit val8 = (RaycastHit)field9.GetValue(turret);
Ray val9 = val7;
val5 = val9;
transform2.position = ((Ray)(ref val5)).GetPoint(((RaycastHit)(ref val8)).distance - 0.5f);
}
Vector3 forward2 = turret.aimPoint.forward;
forward2 = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 3f, 0f) * forward2;
Plugin.AttackTargets(((Component)turret).GetComponent<FAIR_AI>(), turret.aimPoint.position, forward2, 30f);
FAIR_AI component3 = ((Component)turret).GetComponent<FAIR_AI>();
if ((Object)(object)component3.targetWithRotation != (Object)null)
{
EnemyAICollisionDetect component4 = ((Component)component3.targetWithRotation).GetComponent<EnemyAICollisionDetect>();
if ((Object)(object)component4 != (Object)null && (component4.mainScript.isEnemyDead || component4.mainScript.enemyHP <= 0))
{
component3.targetWithRotation = null;
component3.RemoveTargetedEnemyClientRpc();
}
}
if ((Object)(object)turret.targetPlayerWithRotation != (Object)null && turret.targetPlayerWithRotation.isPlayerDead)
{
turret.targetPlayerWithRotation = null;
turret.RemoveTargetedPlayerClientRpc();
}
if ((Object)(object)turret.targetPlayerWithRotation == (Object)null && (Object)(object)component3.targetWithRotation == (Object)null)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
else
{
if (!((Object)(object)turret.targetTransform != (Object)null))
{
return;
}
if ((Object)(object)((Component)turret.targetTransform).GetComponent<EnemyAI>() != (Object)null)
{
if (((Component)turret.targetTransform).GetComponent<EnemyAI>().isEnemyDead)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
}
else if (Object.op_Implicit((Object)(object)((Component)turret.targetTransform).GetComponent<EnemyAICollisionDetect>()) && ((Component)turret.targetTransform).GetComponent<EnemyAICollisionDetect>().mainScript.isEnemyDead)
{
turret.turretMode = (TurretMode)0;
turret.SetToModeClientRpc(0);
field.SetValue(turret, false);
field3.SetValue(turret, true);
turret.turretAnimator.SetInteger("TurretMode", 0);
method.Invoke(turret, new object[1] { (object)(TurretMode)0 });
}
}
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
}
public static void BerserkFunction(Turret turret)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Invalid comparison between Unknown and I4
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Expected O, but got Unknown
//IL_0684: Unknown result type (might be due to invalid IL or missing references)
//IL_068f: Unknown result type (might be due to invalid IL or missing references)
//IL_0694: Unknown result type (might be due to invalid IL or missing references)
//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_041e: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_0739: Unknown result type (might be due to invalid IL or missing references)
//IL_073e: Unknown result type (might be due to invalid IL or missing references)
//IL_075e: Unknown result type (might be due to invalid IL or missing references)
//IL_0763: Unknown result type (might be due to invalid IL or missing references)
//IL_0765: Unknown result type (might be due to invalid IL or missing references)
//IL_076a: Unknown result type (might be due to invalid IL or missing references)
//IL_0778: Unknown result type (might be due to invalid IL or missing references)
//IL_077d: Unknown result type (might be due to invalid IL or missing references)
//IL_06da: Unknown result type (might be due to invalid IL or missing references)
//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0701: Unknown result type (might be due to invalid IL or missing references)
//IL_070b: Unknown result type (might be due to invalid IL or missing references)
//IL_0710: Unknown result type (might be due to invalid IL or missing references)
//IL_0714: Unknown result type (might be due to invalid IL or missing references)
//IL_0716: Unknown result type (might be due to invalid IL or missing references)
//IL_0727: Unknown result type (might be due to invalid IL or missing references)
//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0507: Unknown result type (might be due to invalid IL or missing references)
//IL_050c: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0655: Unknown result type (might be due to invalid IL or missing references)
//IL_065f: Unknown result type (might be due to invalid IL or missing references)
//IL_0669: Unknown result type (might be due to invalid IL or missing references)
//IL_066f: Unknown result type (might be due to invalid IL or missing references)
//IL_0633: Unknown result type (might be due to invalid IL or missing references)
//IL_0639: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("wasTargetingPlayerLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("turretModeLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("rotatingClockwise", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = typeFromHandle.GetField("fadeBulletAudioCoroutine", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field5 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field6 = typeFromHandle.GetField("turretInterval", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field7 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field8 = typeFromHandle.GetField("shootRay", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field9 = typeFromHandle.GetField("hit", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field10 = typeFromHandle.GetField("berserkTimer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field11 = typeFromHandle.GetField("enteringBerserkMode", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
if ((int)(TurretMode)field2.GetValue(turret) != 3)
{
field2.SetValue(turret, (object)(TurretMode)3);
turret.turretAnimator.SetInteger("TurretMode", 1);
field10.SetValue(turret, 1.3f);
turret.berserkAudio.Play();
if (Plugin.turretSettings.Count > 7)
{
turret.rotationSpeed = Plugin.turretSettings[7];
}
else
{
turret.rotationSpeed = 77f;
}
field11.SetValue(turret, true);
field5.SetValue(turret, true);
field7.SetValue(turret, 0f);
field.SetValue(turret, false);
turret.targetPlayerWithRotation = null;
}
if ((bool)field11.GetValue(turret))
{
field10.SetValue(turret, (float)field10.GetValue(turret) - Time.deltaTime);
if ((float)field10.GetValue(turret) <= 0f)
{
field11.SetValue(turret, false);
field3.SetValue(turret, true);
field10.SetValue(turret, 9f);
turret.turretAnimator.SetInteger("TurretMode", 2);
turret.mainAudio.clip = turret.firingSFX;
turret.mainAudio.Play();
turret.farAudio.clip = turret.firingFarSFX;
turret.farAudio.Play();
turret.bulletParticles.Play(true);
turret.bulletCollisionAudio.Play();
if (field4 != null)
{
((MonoBehaviour)turret).StopCoroutine((Coroutine)field4.GetValue(turret));
}
turret.bulletCollisionAudio.volume = 1f;
}
return;
}
Ray val4;
if (Plugin.turretSettings.Count > 7)
{
if ((float)field6.GetValue(turret) >= Plugin.turretSettings[1])
{
field6.SetValue(turret, 0f);
if ((Object)(object)CheckForPlayersInLOS(turret, 3f) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
int num = (int)Plugin.turretSettings[0];
if (num <= 0)
{
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
GameNetworkManager.Instance.localPlayerController.DamagePlayer(num, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
}
else if (GameNetworkManager.Instance.localPlayerController.health > num)
{
GameNetworkManager.Instance.localPlayerController.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
}
else
{
GameNetworkManager.Instance.localPlayerController.KillPlayer(turret.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0, default(Vector3), false);
}
}
field8.SetValue(turret, (object)new Ray(turret.aimPoint.position, turret.aimPoint.forward));
RaycastHit val = default(RaycastHit);
if (Physics.Raycast((Ray)field8.GetValue(turret), ref val, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
{
field9.SetValue(turret, val);
Transform transform = ((Component)turret.bulletCollisionAudio).transform;
Ray val2 = (Ray)field8.GetValue(turret);
RaycastHit val3 = (RaycastHit)field9.GetValue(turret);
val4 = val2;
transform.position = ((Ray)(ref val4)).GetPoint(((RaycastHit)(ref val3)).distance - 0.5f);
}
Vector3 forward = turret.aimPoint.forward;
forward = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 3f, 0f) * forward;
Plugin.AttackTargets(((Component)turret).GetComponent<FAIR_AI>(), turret.centerPoint.position, forward, 30f);
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
}
else if ((float)field6.GetValue(turret) >= 0.21f)
{
field6.SetValue(turret, 0f);
if ((Object)(object)CheckForPlayersInLOS(turret, 3f) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
int @int = Plugin.GetInt("TurretConfig", "Player Damage");
if (@int <= 0)
{
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
GameNetworkManager.Instance.localPlayerController.DamagePlayer(@int, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
}
else if (GameNetworkManager.Instance.localPlayerController.health > 50)
{
GameNetworkManager.Instance.localPlayerController.DamagePlayer(@int, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
}
else
{
GameNetworkManager.Instance.localPlayerController.KillPlayer(turret.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0, default(Vector3), false);
}
}
field8.SetValue(turret, (object)new Ray(turret.aimPoint.position, turret.aimPoint.forward));
RaycastHit val5 = default(RaycastHit);
if (Physics.Raycast((Ray)field8.GetValue(turret), ref val5, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
{
field9.SetValue(turret, val5);
Transform transform2 = ((Component)turret.bulletCollisionAudio).transform;
Ray val6 = (Ray)field8.GetValue(turret);
RaycastHit val7 = (RaycastHit)field9.GetValue(turret);
val4 = val6;
transform2.position = ((Ray)(ref val4)).GetPoint(((RaycastHit)(ref val7)).distance - 0.5f);
}
Vector3 forward2 = turret.aimPoint.forward;
forward2 = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 3f, 0f) * forward2;
Plugin.AttackTargets(((Component)turret).GetComponent<FAIR_AI>(), turret.centerPoint.position, forward2, 30f);
}
else
{
field6.SetValue(turret, (float)field6.GetValue(turret) + Time.deltaTime);
}
if (((NetworkBehaviour)turret).IsServer)
{
field10.SetValue(turret, (float)field10.GetValue(turret) - Time.deltaTime);
if ((float)field10.GetValue(turret) <= 0f)
{
method.Invoke(turret, new object[1] { 0 });
turret.SetToModeClientRpc(0);
}
}
}
public static bool CheckForTargetsInLOS(ref Turret __instance, float radius = 2f, bool angleRangeCheck = false)
{
FAIR_AI component = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
PlayerControllerB val = CheckForPlayersInLOS(__instance, radius, angleRangeCheck);
EnemyAICollisionDetect val2 = CheckForEnemiesInLineOfSight(__instance, radius, angleRangeCheck);
if ((Object)(object)val != (Object)null)
{
component.targets = new Dictionary<int, GameObject> {
{
0,
((Component)val).gameObject
} };
return true;
}
if ((Object)(object)val2 != (Object)null)
{
component.targets = new Dictionary<int, GameObject> {
{
1,
((Component)val2).gameObject
} };
return true;
}
return false;
}
public static PlayerControllerB CheckForPlayersInLOS(Turret turret, float radius = 2f, bool angleRangeCheck = false)
{
//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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_008f: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Invalid comparison between Unknown and I4
//IL_010a: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Invalid comparison between Unknown and I4
//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_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = turret.aimPoint.forward;
val = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / radius, 0f) * val;
float num = turret.rotationRange / radius * 2f;
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("shootRay", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("hit", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("enteringBerserkMode", BindingFlags.Instance | BindingFlags.NonPublic);
RaycastHit val2 = default(RaycastHit);
for (int i = 0; i <= 6; i++)
{
field.SetValue(turret, (object)new Ray(turret.centerPoint.position, val));
if (Physics.Raycast((Ray)field.GetValue(turret), ref val2, 30f, 1051400, (QueryTriggerInteraction)1))
{
field2.SetValue(turret, val2);
RaycastHit val3 = (RaycastHit)field2.GetValue(turret);
if (((Component)((RaycastHit)(ref val3)).transform).CompareTag("Player"))
{
val3 = (RaycastHit)field2.GetValue(turret);
PlayerControllerB component = ((Component)((RaycastHit)(ref val3)).transform).GetComponent<PlayerControllerB>();
if (!((Object)(object)component == (Object)null))
{
if (angleRangeCheck && Vector3.Angle(((Component)component).transform.position + Vector3.up * 1.75f - turret.centerPoint.position, turret.forwardFacingPos.forward) > turret.rotationRange)
{
return null;
}
return component;
}
continue;
}
if ((int)turret.turretMode == 2 || ((int)turret.turretMode == 3 && !(bool)field3.GetValue(turret)))
{
val3 = (RaycastHit)field2.GetValue(turret);
if (((Component)((RaycastHit)(ref val3)).transform).tag.StartsWith("PlayerRagdoll"))
{
val3 = (RaycastHit)field2.GetValue(turret);
Rigidbody component2 = ((Component)((RaycastHit)(ref val3)).transform).GetComponent<Rigidbody>();
if ((Object)(object)component2 != (Object)null)
{
component2.AddForce(((Vector3)(ref val)).normalized * 42f, (ForceMode)1);
}
}
}
}
val = Quaternion.Euler(0f, num / 6f, 0f) * val;
}
return null;
}
public static EnemyAICollisionDetect CheckForEnemiesInLineOfSight(Turret turret, float radius = 2f, bool angleRangeCheck = false)
{
//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_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_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
Vector3 forward = turret.aimPoint.forward;
forward = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 3f, 0f) * forward;
List<EnemyAICollisionDetect> enemyTargets = Plugin.GetEnemyTargets(Plugin.GetTargets(((Component)turret).GetComponent<FAIR_AI>(), turret.aimPoint.position, forward, radius));
if (enemyTargets == null || !enemyTargets.Any())
{
return null;
}
return enemyTargets[0];
}
public static bool SetTargetToEnemyBody(ref Turret __instance)
{
if (!((Object)(object)__instance == (Object)null))
{
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
FAIR_AI component = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
if ((Object)(object)component.targetWithRotation != (Object)null)
{
if (!((Object)(object)((Component)component.targetWithRotation).GetComponent<EnemyAICollisionDetect>() != (Object)null))
{
if ((Object)(object)__instance.targetPlayerWithRotation != (Object)null)
{
if (__instance.targetPlayerWithRotation.isPlayerDead)
{
if (!(bool)field.GetValue(__instance))
{
field.SetValue(__instance, true);
}
if ((Object)(object)__instance.targetPlayerWithRotation.deadBody != (Object)null)
{
__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.deadBody.bodyParts[5]).transform;
}
}
else
{
field.SetValue(__instance, false);
__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.gameplayCamera).transform;
}
}
return false;
}
EnemyAICollisionDetect component2 = ((Component)component.targetWithRotation).GetComponent<EnemyAICollisionDetect>();
if (component2.mainScript.isEnemyDead)
{
if (!(bool)field.GetValue(__instance))
{
field.SetValue(__instance, true);
}
}
else if ((Object)(object)__instance.targetPlayerWithRotation == (Object)null)
{
field.SetValue(__instance, false);
__instance.targetTransform = ((Component)component.targetWithRotation).transform;
}
}
else if ((Object)(object)__instance.targetPlayerWithRotation != (Object)null)
{
if (__instance.targetPlayerWithRotation.isPlayerDead)
{
if (!(bool)field.GetValue(__instance))
{
field.SetValue(__instance, true);
}
if ((Object)(object)__instance.targetPlayerWithRotation.deadBody != (Object)null)
{
__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.deadBody.bodyParts[5]).transform;
}
}
else
{
field.SetValue(__instance, false);
__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.gameplayCamera).transform;
}
}
}
return false;
}
public static bool TurnTowardsTargetEnemyIfHasLOS(ref Turret __instance)
{
//IL_0092: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance == (Object)null))
{
FAIR_AI component = ((Component)__instance).GetComponent<FAIR_AI>();
Type typeFromHandle = typeof(Turret);
FieldInfo field = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeFromHandle.GetField("hasLineOfSight", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
bool flag = true;
if ((Object)(object)__instance.targetTransform != (Object)null && (Object)(object)__instance.centerPoint != (Object)null && (Object)(object)__instance.forwardFacingPos != (Object)null)
{
Vector3 val = __instance.targetTransform.position - __instance.centerPoint.position;
float num = Vector3.Angle(val, __instance.forwardFacingPos.forward);
if (num > __instance.rotationRange)
{
flag = false;
}
}
EnemyAICollisionDetect val2 = CheckForEnemiesInLineOfSight(__instance, 15f);
if ((Object)(object)val2 == (Object)null)
{
flag = false;
}
if (flag)
{
__instance.targetTransform = ((Component)val2.mainScript).transform;
field2.SetValue(__instance, true);
field3.SetValue(__instance, 0f);
__instance.tempTransform.position = __instance.targetTransform.position;
Transform tempTransform = __instance.tempTransform;
tempTransform.position -= Vector3.up * 0.15f;
__instance.turnTowardsObjectCompass.LookAt(__instance.tempTransform);
return false;
}
bool flag2 = true;
if ((bool)field.GetValue(__instance) || Vector3.Angle(__instance.targetTransform.position - __instance.centerPoint.position, __instance.forwardFacingPos.forward) > __instance.rotationRange)
{
flag2 = false;
}
if (Physics.Linecast(__instance.aimPoint.position, __instance.targetTransform.position, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
{
flag2 = false;
}
if (flag2)
{
field2.SetValue(__instance, true);
field3.SetValue(__instance, 0f);
__instance.tempTransform.position = __instance.targetTransform.position;
Transform tempTransform2 = __instance.tempTransform;
tempTransform2.position -= Vector3.up * 0.15f;
__instance.turnTowardsObjectCompass.LookAt(__instance.tempTransform);
return false;
}
if ((bool)field2.GetValue(__instance))
{
field2.SetValue(__instance, false);
field3.SetValue(__instance, 0f);
}
if (!((NetworkBehaviour)__instance).IsServer)
{
return false;
}
field3.SetValue(__instance, (float)field3.GetValue(__instance) + Time.deltaTime);
if ((float)field3.GetValue(__instance) >= 2f)
{
field3.SetValue(__instance, 0f);
Plugin.logger.LogInfo((object)"Turret: LOS timer ended on server. checking for new player target");
PlayerControllerB val3 = CheckForPlayersInLOS(__instance);
if ((Object)(object)val3 != (Object)null)
{
__instance.targetPlayerWithRotation = val3;
__instance.SwitchTargetedPlayerClientRpc((int)val3.playerClientId, false);
Plugin.logger.LogInfo((object)"Turret: Got new player target");
}
else
{
Plugin.logger.LogInfo((object)"Turret: No new player to target; returning to detection mode.");
__instance.targetPlayerWithRotation = null;
__instance.RemoveTargetedPlayerClientRpc();
}
}
if ((Object)(object)__instance.targetPlayerWithRotation != (Object)null)
{
return false;
}
if ((bool)field2.GetValue(__instance))
{
field2.SetValue(__instance, false);
field3.SetValue(__instance, 0f);
}
if (!((NetworkBehaviour)__instance).IsServer)
{
return false;
}
field3.SetValue(__instance, (float)field3.GetValue(__instance) + Time.deltaTime);
if ((float)field3.GetValue(__instance) >= 2f)
{
field3.SetValue(__instance, 0f);
Plugin.logger.LogInfo((object)"Turret: LOS timer ended on server. checking for new enemy target");
EnemyAICollisionDetect val4 = CheckForEnemiesInLineOfSight(__instance, 15f);
if ((Object)(object)val4 != (Object)null)
{
component.targetWithRotation = val4.mainScript;
component.SwitchedTargetedEnemyClientRpc(__instance, val4.mainScript);
Plugin.logger.LogInfo((object)"Turret: Got new enemy target");
}
else
{
Plugin.logger.LogInfo((object)"Turret: No new enemy to target; returning to detection mode.");
component.targetWithRotation = null;
component.RemoveTargetedEnemyClientRpc();
}
}
}
return false;
}
}
namespace FairAI
{
public class FAIR_AI : NetworkBehaviour
{
public EnemyAI targetWithRotation;
public Dictionary<int, GameObject> targets;
private void Awake()
{
targetWithRotation = null;
}
[ClientRpc]
public void SwitchedTargetedEnemyClientRpc(Turret turret, EnemyAI enemy, bool setModeToCharging = false)
{
targetWithRotation = enemy;
if (setModeToCharging)
{
Type typeFromHandle = typeof(Turret);
MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(turret, new object[1] { 2 });
}
}
[ClientRpc]
public void RemoveTargetedEnemyClientRpc()
{
targetWithRotation = null;
}
}
[BepInPlugin("GoldenKitten.FairAI", "Fair AI", "1.5.7")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "GoldenKitten.FairAI";
private const string modName = "Fair AI";
private const string modVersion = "1.5.7";
private Harmony harmony = new Harmony("GoldenKitten.FairAI");
private static readonly float onMeshThreshold = 3f;
public static Plugin Instance = null;
public static ManualLogSource logger;
public static List<EnemyType> allEnemies;
public static List<EnemyType> enemies;
public static List<Item> items;
public static List<EnemyType> enemyList;
public static List<Item> itemList;
public static List<float> turretSettings;
public static Dictionary<string, float[]> speeds;
public static Dictionary<int, Vector3> positions;
public static Dictionary<int, float> sinkingValues;
public static Dictionary<int, float> sinkingProgress;
public static Assembly codeRebirthAssembly;
public static Assembly lethalConfigAssembly;
public static Assembly lguAssembly;
public static Assembly surfacedAssembly;
public static Assembly turretSettingsAssembly;
public static Type rubberBootsType;
public static PropertyInfo tsBoundConfig;
public const string ltModID = "evaisa.lethalthings";
public const string surfacedModID = "Surfaced";
public static bool codeRebirthEnabled = false;
public static bool lethalConfigEnabled = false;
public static bool lethalThingsEnabled = false;
public static bool lguEnabled = false;
public static bool playersEnteredInside = false;
public static bool roundHasStarted = false;
public static bool surfacedEnabled = false;
public static bool turretSettingsEnabled = false;
public static int wallsAndEnemyLayerMask = 524288;
public static int enemyMask = 524288;
public static int allHittablesMask;
private async void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = Logger.CreateLogSource("GoldenKitten.FairAI");
allEnemies = new List<EnemyType>();
enemies = new List<EnemyType>();
items = new List<Item>();
itemList = new List<Item>();
enemyList = new List<EnemyType>();
speeds = new Dictionary<string, float[]>();
positions = new Dictionary<int, Vector3>();
sinkingProgress = new Dictionary<int, float>();
turretSettings = new List<float>();
sinkingValues = new Dictionary<int, float>();
harmony = new Harmony("GoldenKitten.FairAI");
harmony.PatchAll(typeof(Plugin));
CreateHarmonyPatch(harmony, typeof(RoundManager), "Start", null, typeof(RoundManagerPatch), "PatchStart", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(StartOfRound), "Awake", null, typeof(LevelGenManPatch), "PatchAwake", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(StartOfRound), "Start", null, typeof(StartOfRoundPatch), "PatchStart", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(StartOfRound), "Update", null, typeof(StartOfRoundPatch), "PatchUpdate", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(FlowermanAI), "HitEnemy", new Type[4]
{
typeof(int),
typeof(PlayerControllerB),
typeof(bool),
typeof(int)
}, typeof(EnemyAIPatch), "BrackenHitEnemyPatch", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(HoarderBugAI), "HitEnemy", new Type[4]
{
typeof(int),
typeof(PlayerControllerB),
typeof(bool),
typeof(int)
}, typeof(EnemyAIPatch), "HoardingBugHitEnemyPatch", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(EnemyAI), "KillEnemyOnOwnerClient", new Type[1] { typeof(bool) }, typeof(EnemyAIPatch), "KillEnemyOnOwnerClientPatch", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(QuicksandTrigger), "OnTriggerStay", new Type[1] { typeof(Collider) }, typeof(QuickSandPatch), "OnTriggerStayPatch", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(QuicksandTrigger), "StopSinkingLocalPlayer", new Type[1] { typeof(PlayerControllerB) }, typeof(QuickSandPatch), "StopSinkingLocalPlayerPatch", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(QuicksandTrigger), "OnTriggerExit", new Type[1] { typeof(Collider) }, typeof(QuickSandPatch), "OnTriggerExitPatch", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(Turret), "Update", null, typeof(TurretAIPatch), "PatchUpdate", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(Turret), "CheckForPlayersInLineOfSight", new Type[2]
{
typeof(float),
typeof(bool)
}, typeof(TurretAIPatch), "CheckForTargetsInLOS", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(Turret), "SetTargetToPlayerBody", null, typeof(TurretAIPatch), "SetTargetToEnemyBody", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(Turret), "TurnTowardsTargetIfHasLOS", null, typeof(TurretAIPatch), "TurnTowardsTargetEnemyIfHasLOS", isPrefix: true);
CreateHarmonyPatch(harmony, typeof(Landmine), "SpawnExplosion", new Type[8]
{
typeof(Vector3),
typeof(bool),
typeof(float),
typeof(float),
typeof(int),
typeof(float),
typeof(GameObject),
typeof(bool)
}, typeof(MineAIPatch), "PatchSpawnExplosion", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(Landmine), "OnTriggerEnter", null, typeof(MineAIPatch), "PatchOnTriggerEnter", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(Landmine), "OnTriggerExit", null, typeof(MineAIPatch), "PatchOnTriggerExit", isPrefix: false);
CreateHarmonyPatch(harmony, typeof(Landmine), "Detonate", null, typeof(MineAIPatch), "DetonatePatch", isPrefix: false);
await WaitForProcess(1);
GetTurretSettings();
logger.LogInfo((object)"Fair AI initiated!");
}
public static void ImmortalAffected()
{
if (!GetBool("General", "ImmortalAffected"))
{
enemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
where (Object)(object)e != (Object)null && e.canDie
select e).ToList();
}
allEnemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
where (Object)(object)e != (Object)null
select e).ToList();
}
public static float[] SpeedAndAccelerationEnemyList(EnemyAICollisionDetect enemy)
{
if ((Object)(object)enemy != (Object)null)
{
EnemyAI mainScript = enemy.mainScript;
if ((Object)(object)mainScript != (Object)null)
{
EnemyType enemyType = mainScript.enemyType;
if ((Object)(object)enemyType != (Object)null)
{
string text = RemoveInvalidCharacters(enemyType.enemyName);
float[] array = GetSpeeds(text);
if (array != null)
{
return array;
}
NavMeshAgent componentInChildren = ((Component)mainScript).GetComponentInChildren<NavMeshAgent>();
array = ((!((Object)(object)componentInChildren != (Object)null)) ? new float[2] { 1f, 1f } : new float[2] { componentInChildren.speed, componentInChildren.acceleration });
speeds.Add(text, array);
return speeds[text];
}
logger.LogWarning((object)"No EnemyType associated with AI To Get Speeds!");
}
else
{
logger.LogWarning((object)"No EnemyAI To Get Speeds!");
}
}
else
{
logger.LogWarning((object)"No EnemyCollision To Get Speeds!");
}
return new float[2] { 1f, 1f };
}
public static float[] GetSpeeds(string name)
{
if (speeds.TryGetValue(name, out var value))
{
return value;
}
logger.LogWarning((object)("Speeds missing on: " + name));
return null;
}
public static void GetTurretSettings()
{
if (turretSettingsEnabled)
{
object value = tsBoundConfig.GetValue(null);
Type type = null;
if (value != null)
{
type = value.GetType();
if (type == null)
{
logger.LogInfo((object)"Bound Config Type not gotten!");
}
}
else
{
logger.LogInfo((object)"Unable to get BoundConfig");
}
FieldInfo field = type.GetField("turretDamage", BindingFlags.Instance | BindingFlags.Public);
if (field != null)
{
object value2 = field.GetValue(value);
float item = (int)(value2?.GetType().GetProperty("Value"))?.GetValue(value2);
turretSettings.Add(item);
}
FieldInfo field2 = type.GetField("turretFireRate", BindingFlags.Instance | BindingFlags.Public);
if (field2 != null)
{
object value3 = field2.GetValue(value);
float item2 = (float)(value3?.GetType().GetProperty("Value"))?.GetValue(value3);
turretSettings.Add(item2);
}
FieldInfo field3 = type.GetField("turretWarmupTime", BindingFlags.Instance | BindingFlags.Public);
if (field3 != null)
{
object value4 = field3.GetValue(value);
float item3 = (float)(value4?.GetType().GetProperty("Value"))?.GetValue(value4);
turretSettings.Add(item3);
}
FieldInfo field4 = type.GetField("turretRotateTimer", BindingFlags.Instance | BindingFlags.Public);
if (field4 != null)
{
object value5 = field4.GetValue(value);
float item4 = (float)(value5?.GetType().GetProperty("Value"))?.GetValue(value5);
turretSettings.Add(item4);
}
FieldInfo field5 = type.GetField("turretRotationRange", BindingFlags.Instance | BindingFlags.Public);
if (field5 != null)
{
object value6 = field5.GetValue(value);
float item5 = (float)(value6?.GetType().GetProperty("Value"))?.GetValue(value6);
turretSettings.Add(item5);
}
FieldInfo field6 = type.GetField("turretIdleRotationSpeed", BindingFlags.Instance | BindingFlags.Public);
if (field6 != null)
{
object value7 = field6.GetValue(value);
float item6 = (float)(value7?.GetType().GetProperty("Value"))?.GetValue(value7);
turretSettings.Add(item6);
}
FieldInfo field7 = type.GetField("turretFiringRotationSpeed", BindingFlags.Instance | BindingFlags.Public);
if (field7 != null)
{
object value8 = field7.GetValue(value);
float item7 = (float)(value8?.GetType().GetProperty("Value"))?.GetValue(value8);
turretSettings.Add(item7);
}
FieldInfo field8 = type.GetField("turretBerzerkRotationSpeed", BindingFlags.Instance | BindingFlags.Public);
if (field8 != null)
{
object value9 = field8.GetValue(value);
float item8 = (float)(value9?.GetType().GetProperty("Value"))?.GetValue(value9);
turretSettings.Add(item8);
}
logger.LogInfo((object)("Got Turret Settings: " + turretSettings.Count));
}
else
{
turretSettings = new List<float>();
}
}
public static async Task<IEnumerable<int>> WaitForProcess(int waitTime)
{
await Task.Delay(waitTime);
bool done = false;
while (!done)
{
await Instance.DelayedInitialization();
done = true;
}
return Array.Empty<int>();
}
private async Task DelayedInitialization()
{
await Task.Run(delegate
{
TryLoadCodeRebirth();
TryLoadLategameUpgrades();
TryLoadLethalConfig();
TryLoadLethalThings();
TryLoadSurfaced();
TryLoadTurretSettings();
logger.LogInfo((object)"Optional Components initiated!");
});
}
private void TryLoadLethalThings()
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly assembly = null;
Assembly[] array = assemblies;
foreach (Assembly assembly2 in array)
{
if (assembly2.GetName().Name == "LethalThings")
{
assembly = assembly2;
break;
}
}
if (assembly != null)
{
Type type = assembly.GetType("LethalThings.RoombaAI");
if (type != null && BoombaPatch.enabled)
{
CreateHarmonyPatch(harmony, type, "Start", null, typeof(BoombaPatch), "PatchStart", isPrefix: false);
CreateHarmonyPatch(harmony, type, "DoAIInterval", null, typeof(BoombaPatch), "PatchDoAIInterval", isPrefix: false);
lethalThingsEnabled = true;
logger.LogInfo((object)"LethalThings Component Initiated!");
}
}
else
{
logger.LogWarning((object)"LethalThings assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for LethalThings: " + ex.Message));
}
}
}
private void TryLoadSurfaced()
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
if (assembly.GetName().Name == "Surfaced")
{
surfacedAssembly = assembly;
break;
}
}
if (surfacedAssembly != null)
{
Type type = surfacedAssembly.GetType("Seamine");
Type type2 = surfacedAssembly.GetType("Bertha");
if (type != null)
{
if (SurfacedMinePatch.enabled)
{
CreateHarmonyPatch(harmony, type, "OnTriggerEnter", new Type[1] { typeof(Collider) }, typeof(SurfacedMinePatch), "PatchOnTriggerEnter", isPrefix: false);
surfacedEnabled = true;
logger.LogInfo((object)"Surfaced Component Seamine Initiated!");
}
}
else
{
logger.LogInfo((object)"Surfaced Component Seamine Not Found!");
}
if (type2 != null)
{
if (SurfacedMinePatch.enabled)
{
CreateHarmonyPatch(harmony, type2, "OnTriggerEnter", new Type[1] { typeof(Collider) }, typeof(SurfacedMinePatch), "PatchBerthaOnTriggerEnter", isPrefix: false);
surfacedEnabled = true;
logger.LogInfo((object)"Surfaced Component Bertha Initiated!");
}
}
else
{
logger.LogInfo((object)"Surfaced Component Bertha Not Found!");
}
}
else
{
logger.LogWarning((object)"Surfaced assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for Surfaced: " + ex.Message));
}
}
}
private void TryLoadTurretSettings()
{
try
{
Assembly assembly = Assembly.Load("TheNameIsTyler.TurretSettings");
if (assembly != null)
{
turretSettingsAssembly = assembly;
Type type = turretSettingsAssembly.GetType("TurretSettings.TurretSettings");
if (type != null)
{
PropertyInfo property = type.GetProperty("BoundConfig", BindingFlags.Static | BindingFlags.NonPublic);
if (property != null)
{
tsBoundConfig = property;
turretSettingsEnabled = true;
logger.LogInfo((object)"TurretSettings Component Initiated!");
}
else
{
logger.LogWarning((object)"TurretSettings config not found. Skipping optional patch.");
}
}
else
{
logger.LogWarning((object)"TurretSettings type not found. Skipping optional patch.");
}
}
else
{
logger.LogWarning((object)"TurretSettings assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for TurretSettings: " + ex.Message));
}
}
}
private void TryLoadLategameUpgrades()
{
try
{
Assembly assembly = Assembly.Load("MoreShipUpgrades");
if (assembly != null)
{
lguAssembly = assembly;
Type type = lguAssembly.GetType("MoreShipUpgrades.UpgradeComponents.TierUpgrades.Player.RubberBoots");
if (type != null)
{
MethodInfo method = type.GetMethod("ReduceMovementHinderance");
if (method != null)
{
rubberBootsType = type;
lguEnabled = true;
logger.LogInfo((object)"LategameUpgrades Component Initiated!");
}
else
{
logger.LogWarning((object)"LategameUpgrades not found. Skipping optional patch.");
}
}
else
{
logger.LogWarning((object)"LategameUpgrades type not found. Skipping optional patch.");
}
}
else
{
logger.LogWarning((object)"LategameUpgrades assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for LategameUpgrades: " + ex.Message));
}
}
}
private void TryLoadLethalConfig()
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
lethalConfigAssembly = null;
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
if (assembly.GetName().Name == "LethalConfig")
{
lethalConfigAssembly = assembly;
break;
}
}
if (lethalConfigAssembly != null)
{
Type type = lethalConfigAssembly.GetType("LethalConfig.LethalConfigManager");
if (type != null)
{
lethalConfigEnabled = true;
logger.LogInfo((object)"LethalConfig Component Initiated!");
}
}
else
{
logger.LogWarning((object)"LethalConfig assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for LethalConfig: " + ex.Message));
}
}
}
private void TryLoadCodeRebirth()
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
codeRebirthAssembly = null;
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
if (assembly.GetName().Name == "CodeRebirth")
{
codeRebirthAssembly = assembly;
break;
}
}
if (codeRebirthAssembly != null)
{
Type type = codeRebirthAssembly.GetType("CodeRebirth.CodeRebirthEnemyKeys.CutieFly");
if (type != null)
{
codeRebirthEnabled = true;
logger.LogInfo((object)"CodeRebirth Component Initiated!");
}
}
else
{
logger.LogWarning((object)"CodeRebirth assembly not found. Skipping optional patch.");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("Could not load the file"))
{
logger.LogError((object)("An error occurred while trying to apply patches for CodeRebirth: " + ex.Message));
}
}
}
public static List<PlayerControllerB> GetActivePlayers()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
List<PlayerControllerB> list = new List<PlayerControllerB>();
PlayerControllerB[] array = allPlayerScripts;
foreach (PlayerControllerB val in array)
{
if ((Object)val != (Object)null && !val.isPlayerDead && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled)
{
list.Add(val);
}
}
return list;
}
public static bool AllowFairness(Vector3 position)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)StartOfRound.Instance != (Object)null && Can("CheckForPlayersInside") && StartOfRound.Instance.shipHasLanded)
{
if (IsAPlayersOutside())
{
if (!(position.y > -80f))
{
Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
if (!((Bounds)(ref bounds)).Contains(position))
{
goto IL_006c;
}
}
return true;
}
goto IL_006c;
}
return true;
IL_006c:
return playersEnteredInside;
}
public static bool IsAPlayersOutside()
{
if (StartOfRound.Instance.shipHasLanded)
{
List<PlayerControllerB> activePlayers = GetActivePlayers();
for (int i = 0; i < activePlayers.Count; i++)
{
PlayerControllerB val = activePlayers[i];
if (!val.isInsideFactory)
{
return true;
}
}
}
return false;
}
public static bool IsAPlayerInsideShip()
{
if (StartOfRound.Instance.shipHasLanded)
{
List<PlayerControllerB> activePlayers = GetActivePlayers();
for (int i = 0; i < activePlayers.Count; i++)
{
PlayerControllerB val = activePlayers[i];
if (val.isInHangarShipRoom)
{
return true;
}
}
}
return false;
}
public static bool IsAPlayerInsideDungeon()
{
if (StartOfRound.Instance.shipHasLanded)
{
List<PlayerControllerB> activePlayers = GetActivePlayers();
for (int i = 0; i < activePlayers.Count; i++)
{
PlayerControllerB val = activePlayers[i];
if (val.isInsideFactory)
{
return true;
}
}
}
return false;
}
public static bool CanMob(string parentIdentifier, string identifier, string mobName)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
string text = RemoveInvalidCharacters(mobName).ToUpper();
if (((BaseUnityPlugin)Instance).Config[new ConfigDefinition("Mobs", parentIdentifier)].BoxedValue.ToString().ToUpper().Equals("TRUE"))
{
foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys)
{
if (RemoveInvalidCharacters(key.Key.ToUpper()).Equals(RemoveInvalidCharacters(text + identifier).ToUpper()))
{
return ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString().ToUpper().Equals("TRUE");
}
}
return false;
}
return false;
}
public static bool Can(string identifier)
{
foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys)
{
if (RemoveInvalidCharacters(key.Key.ToUpper()).Equals(RemoveInvalidCharacters(identifier.ToUpper())))
{
return ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString().ToUpper().Equals("TRUE");
}
}
return false;
}
public static int GetInt(string parentIdentifier, string identifier)
{
try
{
int.TryParse(((BaseUnityPlugin)Instance).Config[parentIdentifier, identifier].BoxedValue.ToString(), out var result);
return result;
}
catch
{
return 1;
}
}
public static float GetFloat(string parentIdentifier, string identifier)
{
try
{
float.TryParse(((BaseUnityPlugin)Instance).Config[parentIdentifier, identifier].BoxedValue.ToString(), out var result);
return result;
}
catch
{
return 1f;
}
}
public static bool GetBool(string parentIdentifier, string identifier)
{
string text = ((BaseUnityPlugin)Instance).Config[parentIdentifier, identifier].BoxedValue.ToString().ToUpper();
if (text.Equals("TRUE"))
{
return true;
}
return false;
}
public static string RemoveWhitespaces(string source)
{
return string.Join("", source.Split((string[]?)null, StringSplitOptions.RemoveEmptyEntries));
}
public static string RemoveSpecialCharacters(string source)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (char c in source)
{
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString();
}
public static string RemoveInvalidCharacters(string source)
{
return RemoveWhitespaces(RemoveSpecialCharacters(source));
}
public static Type FindType(string fullName)
{
try
{
if ((from a in AppDomain.CurrentDomain.GetAssemblies()
where !a.IsDynamic
select a).SelectMany((Assembly a) => a.GetTypes()).FirstOrDefault((Type t) => t.FullName.Equals(fullName)) != null)
{
return (from a in AppDomain.CurrentDomain.GetAssemblies()
where !a.IsDynamic
select a).SelectMany((Assembly a) => a.GetTypes()).FirstOrDefault((Type t) => t.FullName.Equals(fullName));
}
}
catch
{
return null;
}
return null;
}
public static void CreateHarmonyPatch(Harmony harmony, Type typeToPatch, string methodToPatch, Type[] parameters, Type patchType, string patchMethod, bool isPrefix, bool isTranspiler = false)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
if (typeToPatch == null || patchType == null)
{
logger.LogInfo((object)"Type is either incorrect or does not exist!");
return;
}
MethodInfo methodInfo = AccessTools.Method(typeToPatch, methodToPatch, parameters, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(patchType, patchMethod, (Type[])null, (Type[])null);
if (isTranspiler)
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null);
}
else if (isPrefix)
{
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public static bool IsAgentOnNavMesh(GameObject agentObject)
{
//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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_0039: 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_0058: 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)
Vector3 position = agentObject.transform.position;
NavMeshHit val = default(NavMeshHit);
if (NavMesh.SamplePosition(position, ref val, onMeshThreshold, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z))
{
return position.y >= ((NavMeshHit)(ref val)).position.y;
}
return false;
}
public static bool AttackTargets(FAIR_AI turret_ai, Vector3 aimPoint, Vector3 forward, float range)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return HitTargets(GetTargets(turret_ai, aimPoint, forward, range), forward);
}
public static List<GameObject> GetTargets(FAIR_AI turret_ai, Vector3 aimPoint, Vector3 forward, float range)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: 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_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: 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_0153: Unknown result type (might be due to invalid IL or missing references)
List<GameObject> list = new List<GameObject>();
Ray val = default(Ray);
((Ray)(ref val))..ctor(aimPoint, forward);
RaycastHit[] array = Physics.RaycastAll(val, range, -5, (QueryTriggerInteraction)2);
Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
Vector3 val2 = aimPoint + forward * range;
IHittable val3 = default(IHittable);
EnemyAI val6 = default(EnemyAI);
for (int i = 0; i < array.Length; i++)
{
GameObject gameObject = ((Component)((RaycastHit)(ref array[i])).transform).gameObject;
Transform transform = ((RaycastHit)(ref array[i])).transform;
if (((Component)transform).TryGetComponent<IHittable>(ref val3))
{
EnemyAI val4 = null;
EnemyAICollisionDetect val5 = (EnemyAICollisionDetect)(object)((val3 is EnemyAICollisionDetect) ? val3 : null);
if (val5 != null)
{
val4 = val5.mainScript;
}
if ((Object)(object)val4 != (Object)null && !val4.isEnemyDead && val4.enemyHP > 0)
{
list.Add(((Component)transform).gameObject);
}
if (!(val3 is EnemyAICollisionDetect) && !(val3 is PlayerControllerB) && !(val3 is SandSpiderWebTrap))
{
if (!(val3 is Turret))
{
val3.Hit(1, val2, (PlayerControllerB)null, false, -1);
}
else if (GetBool("TurretConfig", "HitOtherTurrets"))
{
val3.Hit(1, val2, (PlayerControllerB)null, false, -1);
}
}
val2 = ((RaycastHit)(ref array[i])).point;
}
else
{
if (((Component)transform).TryGetComponent<EnemyAI>(ref val6) && !val6.isEnemyDead && val6.enemyHP > 0)
{
list.Add(((Component)val6).gameObject);
val2 = ((RaycastHit)(ref array[i])).point;
}
val2 = ((RaycastHit)(ref array[i])).point;
}
}
return list;
}
public static List<EnemyAICollisionDetect> GetEnemyTargets(List<GameObject> originalTargets)
{
List<EnemyAICollisionDetect> hits = new List<EnemyAICollisionDetect>();
originalTargets.ForEach(delegate(GameObject t)
{
if ((Object)(object)t != (Object)null && t.GetComponent<IHittable>() != null)
{
IHittable component = t.GetComponent<IHittable>();
EnemyAICollisionDetect val = (EnemyAICollisionDetect)(object)((component is EnemyAICollisionDetect) ? component : null);
if (val != null)
{
hits.Add(val);
}
}
});
return hits;
}
public static bool HitTargets(List<GameObject> targets, Vector3 forward)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
bool hits = false;
if (!targets.Any())
{
return hits;
}
targets.ForEach(delegate(GameObject t)
{
//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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)t != (Object)null)
{
if ((Object)(object)t.GetComponent<EnemyAI>() != (Object)null)
{
EnemyAI component = t.GetComponent<EnemyAI>();
int @int = GetInt("TurretConfig", "Enemy Damage");
if (CanMob("TurretDamageAllMobs", ".Turret Damage", component.enemyType.enemyName))
{
NutcrackerEnemyAI val = (NutcrackerEnemyAI)(object)((component is NutcrackerEnemyAI) ? component : null);
if (val != null)
{
if (((EnemyAI)val).currentBehaviourStateIndex > 0)
{
component.HitEnemyOnLocalClient(@int, default(Vector3), (PlayerControllerB)null, false, -1);
hits = true;
}
}
else
{
component.HitEnemyOnLocalClient(@int, default(Vector3), (PlayerControllerB)null, false, -1);
hits = true;
}
}
}
else if (t.GetComponent<IHittable>() != null)
{
IHittable component2 = t.GetComponent<IHittable>();
EnemyAICollisionDetect val2 = (EnemyAICollisionDetect)(object)((component2 is EnemyAICollisionDetect) ? component2 : null);
if (val2 != null)
{
int int2 = GetInt("TurretConfig", "Enemy Damage");
if (CanMob("TurretDamageAllMobs", ".Turret Damage", val2.mainScript.enemyType.enemyName))
{
EnemyAI mainScript = val2.mainScript;
NutcrackerEnemyAI val3 = (NutcrackerEnemyAI)(object)((mainScript is NutcrackerEnemyAI) ? mainScript : null);
if (val3 != null)
{
if (((EnemyAI)val3).currentBehaviourStateIndex > 0)
{
val2.mainScript.HitEnemyOnLocalClient(int2, default(Vector3), (PlayerControllerB)null, false, -1);
hits = true;
}
}
else
{
val2.mainScript.HitEnemyOnLocalClient(int2, default(Vector3), (PlayerControllerB)null, false, -1);
hits = true;
}
}
}
else if (!(component2 is PlayerControllerB))
{
if (!(component2 is Turret))
{
component2.Hit(1, forward, (PlayerControllerB)null, true, -1);
hits = true;
}
else if (GetBool("TurretConfig", "HitOtherTurrets"))
{
component2.Hit(1, forward, (PlayerControllerB)null, true, -1);
hits = true;
}
}
}
}
});
return hits;
}
}
public class Utils
{
[CompilerGenerated]
private sealed class <WaitForTime>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Action onComplete;
public float timeToWait;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForTime>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(timeToWait);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
onComplete?.Invoke();
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static void AddLethalConfigBoolItem(ConfigEntry<bool> tempEntry)
{
Type type = Plugin.lethalConfigAssembly.GetType("LethalConfig.ConfigItems.BoolCheckBoxConfigItem");
ConstructorInfo constructor = type.GetConstructor(new Type[1] { typeof(ConfigEntry<bool>) });
object obj = constructor.Invoke(new object[1] { tempEntry });
Type type2 = Plugin.lethalConfigAssembly.GetType("LethalConfig.LethalConfigManager");
MethodInfo method = type2.GetMethod("AddConfigItem", new Type[1] { type.BaseType });
method.Invoke(null, new object[1] { obj });
}
public static void AddLethalConfigFloatItem(ConfigEntry<float> tempEntry)
{
Type type = Plugin.lethalConfigAssembly.GetType("LethalConfig.ConfigItems.FloatInputFieldConfigItem");
ConstructorInfo constructor = type.GetConstructor(new Type[1] { typeof(ConfigEntry<float>) });
object obj = constructor.Invoke(new object[1] { tempEntry });
Type type2 = Plugin.lethalConfigAssembly.GetType("LethalConfig.LethalConfigManager");
MethodInfo method = type2.GetMethod("AddConfigItem", new Type[1] { type.BaseType });
method.Invoke(null, new object[1] { obj });
}
[IteratorStateMachine(typeof(<WaitForTime>d__2))]
public static IEnumerator WaitForTime(Action onComplete, float timeToWait)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForTime>d__2(0)
{
onComplete = onComplete,
timeToWait = timeToWait
};
}
public static bool WaitInSeconds(float timeToWait, MonoBehaviour objectToTime = null)
{
if ((Object)(object)objectToTime == (Object)null)
{
objectToTime = (MonoBehaviour)(object)Plugin.Instance;
}
bool done = false;
objectToTime.StartCoroutine(WaitForTime(delegate
{
done = true;
}, timeToWait));
return done;
}
public static void SetupConfig()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Expected O, but got Unknown
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Expected O, but got Unknown
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Expected O, but got Unknown
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0477: Expected O, but got Unknown
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Expected O, but got Unknown
//IL_052f: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Expected O, but got Unknown
//IL_058c: Unknown result type (might be due to invalid IL or missing references)
//IL_0596: Expected O, but got Unknown
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_05f3: Expected O, but got Unknown
//IL_0646: Unknown result type (might be due to invalid IL or missing references)
//IL_0650: Expected O, but got Unknown
//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
//IL_06ad: Expected O, but got Unknown
//IL_0700: Unknown result type (might be due to invalid IL or missing references)
//IL_070a: Expected O, but got Unknown
//IL_075d: Unknown result type (might be due to invalid IL or missing references)
//IL_0767: Expected O, but got Unknown
//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
//IL_07c4: Expected O, but got Unknown
//IL_0817: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: Expected O, but got Unknown
//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
//IL_08af: Expected O, but got Unknown
//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
//IL_09dc: Expected O, but got Unknown
//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
//IL_0a4d: Expected O, but got Unknown
//IL_0ab4: Unknown result type (might be due to invalid IL or missing references)
//IL_0abe: Expected O, but got Unknown
//IL_0b25: Unknown result type (might be due to invalid IL or missing references)
//IL_0b2f: Expected O, but got Unknown
//IL_0b96: Unknown result type (might be due to invalid IL or missing references)
//IL_0ba0: Expected O, but got Unknown
//IL_0c07: Unknown result type (might be due to invalid IL or missing references)
//IL_0c11: Expected O, but got Unknown
if (!Plugin.itemList.SequenceEqual(Plugin.items) || Plugin.items.Count == 0)
{
Plugin.items = Resources.FindObjectsOfTypeAll<Item>().ToList();
Plugin.itemList = Plugin.items;
}
Plugin.allHittablesMask = StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers | 0x280008 | Plugin.enemyMask;
if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("General", "ImmortalAffected")))
{
ConfigEntry<bool> tempEntry = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("General", "ImmortalAffected", false, "If set to on/true immortal enemies will be targeted and trip off traps.");
if (Plugin.lethalConfigEnabled)
{
AddLethalConfigBoolItem(tempEntry);
}
if (Plugin.enemies.Count == 0)
{
if (!Plugin.GetBool("General", "ImmortalAffected"))
{
Plugin.enemies = (from e in Resources.FindObjectsOfTypeAll<EnemyType>()
where e.canDie
select e).ToList();
Plugin.allEnemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
where (Object)(object)e != (Object)null
select e).ToList();
Plugin.enemyList = Plugin.enemies;
}
else
{
Plugin.enemies = (from e in Resources.FindObjectsOfTypeAll<EnemyType>()
where (Object)(object)e != (Object)null
select e).ToList();
Plugin.allEnemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
where (Object)(object)e != (Object)null
select e).ToList();
Plugin.enemyList = Plugin.enemies;
}
}
else if (!Plugin.enemyList.SequenceEqual(Plugin.enemies))
{
if (!Plugin.GetBool("General", "ImmortalAffected"))
{
Plugin.enemies = (from e in Resources.FindObjectsOfTypeAll<EnemyType>()
where (Object)(object)e != (Object)null && e.canDie
select e).ToList();
Plugin.allEnemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
where (Object)(object)e != (Object)null
select e).ToList();
Plugin.enemyList = Plugin.enemies;
}
else
{
Plugin.enemies = (from e in Resources.FindObjectsOfTypeAl