using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalEscape")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalEscape")]
[assembly: AssemblyTitle("LethalEscape")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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;
}
}
}
namespace UpdatedEscape
{
internal class LETimerFunctions : MonoBehaviour
{
public static float MinuteEscapeTimerPuffer;
public static float MinuteEscapeTimerBracken;
public static float MinuteEscapeTimerHoardingBug;
public static LETimerFunctions instance;
private void Awake()
{
instance = this;
}
private void Update()
{
MinuteEscapeTimerBracken += Time.deltaTime;
MinuteEscapeTimerHoardingBug += Time.deltaTime;
MinuteEscapeTimerPuffer += Time.deltaTime;
}
}
[BepInPlugin("xCeezy.LethalEscape", "Lethal Escape", "0.9.1")]
public class Plugin : BaseUnityPlugin
{
public static GameObject ExtraValues;
private const string modGUID = "xCeezy.LethalEscape";
private const string modName = "Lethal Escape";
private const string modVersion = "0.9.1";
private Harmony _harmony = new Harmony("LethalEscape");
public static ManualLogSource mls;
public static float TimeStartTeleport;
public static ConfigEntry<bool> CanThumperEscape;
public static ConfigEntry<bool> CanCaveDwellerEscape;
public static ConfigEntry<bool> CanBrackenEscape;
public static ConfigEntry<bool> CanJesterEscape;
public static ConfigEntry<bool> CanHoardingBugEscape;
public static ConfigEntry<bool> CanCoilHeadEscape;
public static ConfigEntry<bool> CanSpiderEscape;
public static ConfigEntry<bool> CanNutCrackerEscape;
public static ConfigEntry<bool> CanHygrodereEscape;
public static ConfigEntry<bool> goofyahh;
public static ConfigEntry<float> ClaySurgeonEscapeChance;
public static ConfigEntry<bool> CanPufferEscape;
public static ConfigEntry<bool> CanButlerEscape;
public static ConfigEntry<float> ButlerChanceToSpawnOutside;
public static ConfigEntry<float> CaveDwellerChanceToSpawnOutside;
public static ConfigEntry<bool> CanClaySurgeonEscape;
public static ConfigEntry<float> ClaySurgeonChanceToSpawnOutside;
public static ConfigEntry<float> ButlerEscapeDelay;
public static float JesterSpeedWindup;
public static ConfigEntry<float> BrackenChanceToEscapeEveryMinute;
public static ConfigEntry<float> PufferChanceToEscapeEveryMinute;
public static ConfigEntry<float> HoardingBugChanceToEscapeEveryMinute;
public static ConfigEntry<float> HoardingBugChanceToNestNearShip;
public static ConfigEntry<float> HoardingBugChanceToSpawnOutside;
public static ConfigEntry<float> BrackenChanceToSpawnOutside;
public static ConfigEntry<float> PufferChanceToSpawnOutside;
public static ConfigEntry<float> JesterChanceToSpawnOutside;
public static ConfigEntry<float> HygrodereChanceToSpawnOutside;
public static ConfigEntry<float> NutCrackerChanceToSpawnOutside;
public static ConfigEntry<float> ThumperChanceToSpawnOutside;
public static ConfigEntry<float> SpiderChanceToSpawnOutside;
public static ConfigEntry<float> JesterSpeedIncreasePerSecond;
public static ConfigEntry<float> MaxJesterOutsideSpeed;
public static ConfigEntry<float> BrackenEscapeDelay;
public static ConfigEntry<float> ThumperEscapeDelay;
public static ConfigEntry<int> SpiderMinWebsOutside;
public static ConfigEntry<int> SpiderMaxWebsOutside;
private void Awake()
{
//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ed: Expected O, but got Unknown
CanThumperEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "ThumperEscape", true, "Whether or not the Thumper can escape");
CanBrackenEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "BrackenEscape", true, "Whether or not the Bracken can escape");
CanJesterEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "JesterEscape", true, "Whether or not the Jester can escape");
CanHoardingBugEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HoardingBugEscape", true, "Whether or not the Hoarding Bugs can escape");
CanCaveDwellerEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CaveDwellerEscape", true, "Whether or not the Cave Dweller can escape");
CaveDwellerChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "CaveDwellerSpawnOutsideChance", 10f, "The chance that the Cave Dweller will spawn outside");
CanCoilHeadEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CoilHeadEscape", true, "Whether or not Coil Head can escape");
CanSpiderEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "SpiderEscape", true, "Whether or not the Spider can escape");
CanClaySurgeonEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "ClaySurgeonEscape", true, "Whether or not the Clay Surgeon can escape");
ClaySurgeonChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "ClaySurgeonSpawnOutsideChance", 10f, "The chance that the Clay Surgeon will spawn outside");
CanNutCrackerEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "NutCrackerEscape", true, "Whether or not the Nut Cracker can escape");
CanHygrodereEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HygrodereEscape", false, "Whether or not the Hygrodere/Slime can escape");
CanPufferEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CanPufferEscape", true, "Whether or not the Puffer/Spore Lizard can escape");
ThumperChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "ThumperSpawnOutsideChance", 5f, "The chance that the Thumper will spawn outside");
BrackenChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "BrackenSpawnOutsideChance", 10f, "The chance that the Bracken will spawn outside");
JesterChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "JesterSpawnOutsideChance", 0f, "The chance that the Jester will spawn outside");
HoardingBugChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HoardingBugSpawnOutsideChance", 30f, "The chance that the Hoarding Bug will spawn outside");
SpiderChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "SpiderSpawnOutsideChance", 5f, "The chance that the Spider will spawn outside");
NutCrackerChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "NutCrackerSpawnOutsideChance", 5f, "The chance that the NutCracker will spawn outside");
HygrodereChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HygrodereSpawnOutsideChance", 0f, "The chance that the Hygrodere will spawn outside");
PufferChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "PufferSpawnOutsideChance", 5f, "The chance that the Puffer will spawn outside");
CanButlerEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "ButlerEscape", true, "Whether or not the Butler can escape");
ButlerChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "ButlerSpawnOutsideChance", 5f, "The chance that the Butler will spawn outside");
ButlerEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Butler Escape Delay", 7f, "Time it takes for the Butler to follow a player outside");
ClaySurgeonEscapeChance = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "ClaySurgeonEscapeChance", 10f, "The chance that the Clay Surgeon will escape randomly every minute");
PufferChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Puffer Escape Chance", 10f, "The chance that the Puffer/Spore Lizard will escape randomly every minute");
BrackenChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Chance", 10f, "The chance that the Bracken will escape randomly every minute");
HoardingBugChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBug Escape Chance", 15f, "The chance that the Hoarding Bug will escape randomly every minute");
HoardingBugChanceToNestNearShip = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBugShipNestChance", 50f, "The chance that the Hoarding Bug will make their nest at/near the ship");
BrackenEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Delay", 5f, "Time it takes for the Bracken to follow a player outside");
ThumperEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Thumper Escape Delay", -5f, "Time it takes for the Thumper to follow a player outside which is based on how long the player was seen minus this value (Might break when under -15 and will force thumper outside when it sees someone when above 0)");
SpiderMaxWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Max Spider Webs Outside", 28, "The maximum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 7 or 9 if update 47)");
SpiderMinWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Min Spider Webs Outside", 20, "The minimum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 4 or 6 if update 47)");
goofyahh = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Message Settings", true, "Enable or disable the message when the ship lands.");
JesterSpeedIncreasePerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Speed Increase", 1.35f, "How much speed the jester gets per second");
MaxJesterOutsideSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Outside Speed", 10f, "The max speed the Jester moves while outside (5 is the speed its at while in the box and 18 is jesters max speed inside the facility)");
if ((Object)(object)ExtraValues == (Object)null)
{
ExtraValues = new GameObject();
Object.DontDestroyOnLoad((Object)(object)ExtraValues);
((Object)ExtraValues).hideFlags = (HideFlags)61;
ExtraValues.AddComponent<LETimerFunctions>();
}
mls = Logger.CreateLogSource("GameMaster");
mls.LogInfo((object)"Loaded xCeezy.LethalEscape. Patching.");
_harmony.PatchAll(typeof(Plugin));
}
[HarmonyPatch(typeof(CrawlerAI), "Update")]
[HarmonyPrefix]
private static void CrawlerLEPrefixAI(CrawlerAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanThumperEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if (((EnemyAI)__instance).currentBehaviourStateIndex != 0 && __instance.noticePlayerTimer < ThumperEscapeDelay.Value && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void ThumperAILEOutsideAttack(CrawlerAI __instance, ref Collider other)
{
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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)
if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>() <= 0.65f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
component.DamagePlayer(40, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(40, Vector3.zero, -1);
((EnemyAI)__instance).agent.speed = 0f;
__instance.HitPlayerServerRpc((int)component.playerClientId);
component.JumpToFearLevel(1f, true);
}
}
}
[HarmonyPatch(typeof(CrawlerAI), "Start")]
[HarmonyPostfix]
private static void CrawlerAILEPostfixStart(CrawlerAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ThumperChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= ThumperChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(JesterAI), "Update")]
[HarmonyPrefix]
private static void JesterLEPrefixAI(JesterAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
JesterSpeedWindup = 0f;
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(JesterAI), "Update")]
[HarmonyPostfix]
private static void JesterLEPostfixAI(JesterAI __instance)
{
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
if (!CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost || !((EnemyAI)__instance).isOutside)
{
return;
}
if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
bool flag = false;
PlayerControllerB val = null;
float num = float.MaxValue;
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[i];
if (val2.isPlayerControlled && !val2.isInsideFactory)
{
flag = true;
float num2 = Vector3.Distance(((Component)__instance).transform.position, ((Component)val2).transform.position);
if (num2 < num)
{
num = num2;
val = val2;
}
}
}
NavMeshHit val3 = default(NavMeshHit);
if (flag && (Object)(object)val != (Object)null)
{
((EnemyAI)__instance).SwitchToBehaviourState(2);
((EnemyAI)__instance).agent.stoppingDistance = 0f;
((EnemyAI)__instance).targetPlayer = val;
((EnemyAI)__instance).SetMovingTowardsTargetPlayer(val);
((EnemyAI)__instance).agent.isStopped = false;
}
else if ((((EnemyAI)__instance).agent.remainingDistance < 0.1f || !((EnemyAI)__instance).agent.hasPath) && NavMesh.SamplePosition(((Component)__instance).transform.position + Random.insideUnitSphere * 10f, ref val3, 10f, -1))
{
((EnemyAI)__instance).agent.SetDestination(((NavMeshHit)(ref val3)).position);
}
JesterSpeedWindup = Mathf.Clamp(JesterSpeedWindup + Time.deltaTime * JesterSpeedIncreasePerSecond.Value, 0f, MaxJesterOutsideSpeed.Value);
((EnemyAI)__instance).agent.speed = JesterSpeedWindup;
}
[HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void JesterAILEOutsideAttack(JesterAI __instance, ref Collider other)
{
if (!((EnemyAI)__instance).isEnemyDead && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside)
{
if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && ((EnemyAI)__instance).currentBehaviourStateIndex == 2)
{
__instance.KillPlayerServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(JesterAI), "Start")]
[HarmonyPostfix]
private static void JesterAILEPostfixStart(JesterAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && JesterChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= JesterChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(HoarderBugAI), "Update")]
[HarmonyPrefix]
private static void HoardingBugAILEPrefixAI(HoarderBugAI __instance)
{
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !CanHoardingBugEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && __instance.searchForPlayer.inProgress)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
else
{
if (!(LETimerFunctions.MinuteEscapeTimerHoardingBug >= 60f) || !((Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null))
{
return;
}
LETimerFunctions.MinuteEscapeTimerHoardingBug = 0f;
if ((float)Random.Range(1, 100) <= HoardingBugChanceToEscapeEveryMinute.Value / (float)Object.FindObjectsOfType(typeof(HoarderBugAI)).Length)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
if (HoardingBugChanceToNestNearShip.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToNestNearShip.Value)
{
StartOfRound val = (StartOfRound)Object.FindObjectOfType(typeof(StartOfRound));
Transform val2 = ((EnemyAI)__instance).ChooseClosestNodeToPosition(val.elevatorTransform.position, false, 0);
__instance.nestPosition = val2.position;
}
}
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void HoardingBugAILEOutsideAttack(HoarderBugAI __instance, ref Collider other)
{
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
float value = Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>();
bool value2 = Traverse.Create((object)__instance).Field("inChase").GetValue<bool>();
if (!(value <= 0.5f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f) && value2)
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
component.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(30, Vector3.zero, -1);
__instance.HitPlayerServerRpc();
}
}
}
[HarmonyPatch(typeof(HoarderBugAI), "Start")]
[HarmonyPostfix]
private static void HoardingBugAILEPostfixStart(HoarderBugAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HoardingBugChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(SpringManAI), "Update")]
[HarmonyPrefix]
private static void CoilHeadAILEPrefixAI(SpringManAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanCoilHeadEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void CoilHeadAILEOutsideAttack(SpringManAI __instance, ref Collider other)
{
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
bool value = Traverse.Create((object)__instance).Field("stoppingMovement").GetValue<bool>();
float value2 = Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>();
if (!value && ((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !(value2 >= 0f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0.2f);
component.DamagePlayer(90, true, true, (CauseOfDeath)6, 2, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
component.JumpToFearLevel(1f, true);
}
}
}
[HarmonyPatch(typeof(SandSpiderAI), "Update")]
[HarmonyPrefix]
private static void SpiderAILEPrefixAI(SandSpiderAI __instance)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !CanSpiderEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
__instance.maxWebTrapsToPlace += Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void SpiderAILEOutsideAttack(SandSpiderAI __instance, ref Collider other)
{
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
bool value = Traverse.Create((object)__instance).Field("onWall").GetValue<bool>();
float value2 = Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>();
if (!value && !(value2 <= 1f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
component.DamagePlayer(90, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
__instance.HitPlayerServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(SandSpiderAI), "Start")]
[HarmonyPostfix]
private static void SpiderAILEPostfixStart(SandSpiderAI __instance)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && SpiderChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= SpiderChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
__instance.maxWebTrapsToPlace = Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI), "Update")]
[HarmonyPrefix]
private static void NutCrackerAILEPrefixAI(NutcrackerEnemyAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanNutCrackerEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void NutCrackerAILEOutsideAttack(NutcrackerEnemyAI __instance, ref Collider other)
{
if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
float value = Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>();
if (!(((EnemyAI)__instance).stunNormalizedTimer >= 0f) && !(value < 1f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
__instance.LegKickPlayerServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")]
[HarmonyPostfix]
private static void NutCrackerAILEPostfixStart(NutcrackerEnemyAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && NutCrackerChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= NutCrackerChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Update")]
[HarmonyPrefix]
private static void ClaySurgeonLEPrefixAI(ClaySurgeonAI __instance)
{
Traverse val = Traverse.Create((object)__instance);
if (val.Field("isEnemyDead").GetValue<bool>() || !CanClaySurgeonEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!val.Field("isOutside").GetValue<bool>())
{
PlayerControllerB value = val.Field("targetPlayer").GetValue<PlayerControllerB>();
if ((Object)(object)value != (Object)null && !value.isInsideFactory && (float)Random.Range(1, 100) <= ClaySurgeonEscapeChance.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
val.Method("ChangeOwnershipOfEnemy", new object[1] { GameNetworkManager.Instance.localPlayerController.actualClientId }).GetValue();
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void ClaySurgeonAILEOutsideAttack(ClaySurgeonAI __instance, ref Collider other)
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
Traverse val = Traverse.Create((object)__instance);
if (!val.Field("isEnemyDead").GetValue<bool>() && val.Field("isOutside").GetValue<bool>() && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(val.Field("timeSinceHittingPlayer").GetValue<float>() < 0.4f))
{
val.Field("timeSinceHittingPlayer").SetValue((object)0f);
component.DamagePlayer(50, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(50, Vector3.zero, -1);
val.Method("HitPlayerServerRpc", new object[1] { (int)component.playerClientId }).GetValue();
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Start")]
[HarmonyPostfix]
private static void ClaySurgeonAILEPostfixStart(ClaySurgeonAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ClaySurgeonChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= ClaySurgeonChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(BlobAI), "Update")]
[HarmonyPrefix]
private static void BlobAILEPrefixAI(BlobAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanHygrodereEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
__instance.centerPoint = ((Component)__instance).transform;
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void BlobAILEOutsideAttack(BlobAI __instance, ref Collider other)
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if (!((Object)(object)component != (Object)null) || component.isPlayerDead || !component.isPlayerControlled || !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
return;
}
float value = Traverse.Create((object)__instance).Field("timeSinceHittingLocalPlayer").GetValue<float>();
float value2 = Traverse.Create((object)__instance).Field("tamedTimer").GetValue<float>();
float value3 = Traverse.Create((object)__instance).Field("angeredTimer").GetValue<float>();
if (!(value < 0.25f) && (!(value2 > 0f) || !(value3 < 0f)))
{
Traverse.Create((object)__instance).Field("timeSinceHittingLocalPlayer").SetValue((object)0f);
component.DamagePlayerFromOtherClientServerRpc(35, Vector3.zero, -1);
component.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
if (component.isPlayerDead)
{
__instance.SlimeKillPlayerEffectServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(BlobAI), "Start")]
[HarmonyPostfix]
private static void HygrodereAILEPostfixStart(BlobAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HygrodereChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HygrodereChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
__instance.centerPoint = ((Component)__instance).transform;
}
}
[HarmonyPatch(typeof(FlowermanAI), "Update")]
[HarmonyPrefix]
private static void FlowermanAILEPrefixAI(FlowermanAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanBrackenEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
int value = Traverse.Create((object)__instance).Field("currentBehaviourStateIndex").GetValue<int>();
float value2 = Traverse.Create((object)__instance).Field("evadeStealthTimer").GetValue<float>();
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && (value == 1 || value2 > 0f) && Time.time - TimeStartTeleport >= BrackenEscapeDelay.Value + 5f)
{
TimeStartTeleport = Time.time;
}
if (Time.time - TimeStartTeleport > BrackenEscapeDelay.Value && Time.time - TimeStartTeleport < BrackenEscapeDelay.Value + 5f)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
else if (LETimerFunctions.MinuteEscapeTimerBracken >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
{
LETimerFunctions.MinuteEscapeTimerBracken = 0f;
if (BrackenChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToEscapeEveryMinute.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
}
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(FlowermanAI), "Update")]
[HarmonyPostfix]
private static void FlowermanAILEPostfixAI(FlowermanAI __instance)
{
if (!((EnemyAI)__instance).isEnemyDead && CanBrackenEscape.Value && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void FlowerManAILEOutsideAttack(FlowermanAI __instance, ref Collider other, bool ___startingKillAnimationLocalClient)
{
if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !Traverse.Create((object)__instance).Field("inKillAnimation").GetValue<bool>() && !___startingKillAnimationLocalClient)
{
__instance.KillPlayerAnimationServerRpc((int)component.playerClientId);
___startingKillAnimationLocalClient = true;
}
}
}
[HarmonyPatch(typeof(FlowermanAI), "Start")]
[HarmonyPostfix]
private static void FlowermanAILEPostfixStart(FlowermanAI __instance)
{
TimeStartTeleport = 0f;
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && BrackenChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(ButlerEnemyAI), "Update")]
[HarmonyPrefix]
private static void ButlerLEPrefixAI(ButlerEnemyAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanButlerEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
Traverse val = Traverse.Create((object)__instance);
if (!val.Field("isOutside").GetValue<bool>())
{
if (val.Field("currentBehaviourStateIndex").GetValue<int>() != 0 && val.Field("noticePlayerTimer").GetValue<float>() < ButlerEscapeDelay.Value && (Object)(object)val.Field("targetPlayer").GetValue<PlayerControllerB>() != (Object)null && !val.Field("targetPlayer").GetValue<PlayerControllerB>().isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(ButlerEnemyAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void ButlerAILEOutsideAttack(ButlerEnemyAI __instance, ref Collider other)
{
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
if (((EnemyAI)__instance).isEnemyDead)
{
return;
}
Traverse val = Traverse.Create((object)__instance);
if (val.Field("isOutside").GetValue<bool>() && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(val.Field("timeSinceHittingPlayer").GetValue<float>() <= 0.65f) && !(val.Field("stunNormalizedTimer").GetValue<float>() > 0f))
{
val.Field("timeSinceHittingPlayer").SetValue((object)0f);
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
component.DamagePlayer(50, true, true, (CauseOfDeath)14, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(50, Vector3.zero, -1);
val.Field("agent").Field("speed").SetValue((object)0f);
__instance.StabPlayerServerRpc((int)component.playerClientId, true);
}
}
}
[HarmonyPatch(typeof(ButlerEnemyAI), "Start")]
[HarmonyPostfix]
private static void ButlerAILEPostfixStart(ButlerEnemyAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ButlerChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= ButlerChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool LoadNewLevel(SelectableLevel newLevel)
{
if (!goofyahh.Value)
{
return true;
}
if (!((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost)
{
return true;
}
HUDManager.Instance.AddTextToChatOnServer("<color=red>Lethal Escape 0.9.1 is active, monsters can escape the facility now!</color>", -1);
return true;
}
[HarmonyPatch(typeof(CaveDwellerAI), "Update")]
[HarmonyPrefix]
private static void CaveDwellerLEPrefixAI(CaveDwellerAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanCaveDwellerEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(CaveDwellerAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void CaveDwellerAILEOutsideAttack(CaveDwellerAI __instance, ref Collider other)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>() <= 1f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
component.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(30, Vector3.zero, -1);
__instance.KillPlayerAnimationServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(CaveDwellerAI), "Start")]
[HarmonyPostfix]
private static void CaveDwellerAILEPostfixStart(CaveDwellerAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && CaveDwellerChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= CaveDwellerChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(PufferAI), "Update")]
[HarmonyPrefix]
private static void PufferAILEPrefixAI(PufferAI __instance)
{
if (((EnemyAI)__instance).isEnemyDead || !CanPufferEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
return;
}
if (!((EnemyAI)__instance).isOutside)
{
if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
}
else if (LETimerFunctions.MinuteEscapeTimerPuffer >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
{
LETimerFunctions.MinuteEscapeTimerPuffer = 0f;
if (PufferChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToEscapeEveryMinute.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
}
}
}
else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
}
[HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void PufferAILEOutsideAttack(PufferAI __instance, ref Collider other)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>() <= 1f))
{
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f);
component.DamagePlayer(20, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
component.DamagePlayerFromOtherClientServerRpc(20, Vector3.zero, -1);
__instance.BitePlayerServerRpc((int)component.playerClientId);
}
}
}
[HarmonyPatch(typeof(PufferAI), "Start")]
[HarmonyPostfix]
private static void PufferAILEPostfixStart(PufferAI __instance)
{
if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && PufferChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToSpawnOutside.Value)
{
SendEnemyOutside((EnemyAI)(object)__instance);
}
}
public static void SendEnemyInside(EnemyAI instance)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
instance.isOutside = false;
instance.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
EntranceTeleport val = null;
EntranceTeleport[] array2 = array;
foreach (EntranceTeleport val2 in array2)
{
if (((Object)val2).name == "EntranceTeleportB(Clone)" && !val2.isEntranceToBuilding)
{
val = val2;
break;
}
}
if ((Object)(object)val != (Object)null)
{
instance.SetDestinationToPosition(val.entrancePoint.position, false);
while (Vector3.Distance(((Component)instance).transform.position, val.entrancePoint.position) > 0.5f)
{
}
instance.serverPosition = val.entrancePoint.position;
}
else
{
Debug.LogWarning((object)"EntranceTeleportB(Clone) not found. Using fallback method, the world is so cruel");
for (int j = 0; j < array.Length; j++)
{
if (array[j].entranceId == 0 && !array[j].isEntranceToBuilding)
{
instance.serverPosition = array[j].entrancePoint.position;
break;
}
}
}
Transform val3 = instance.ChooseClosestNodeToPosition(instance.serverPosition, false, 0);
if (Vector3.Magnitude(val3.position - instance.serverPosition) > 10f)
{
instance.serverPosition = val3.position;
((Component)instance).transform.position = instance.serverPosition;
}
((Component)instance).transform.position = instance.serverPosition;
instance.agent.Warp(instance.serverPosition);
instance.SyncPositionToClients();
}
public static void SendEnemyOutside(EnemyAI instance, bool SpawnOnDoor = true)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: 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)
instance.isOutside = true;
instance.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
EntranceTeleport val = null;
EntranceTeleport[] array2 = array;
foreach (EntranceTeleport val2 in array2)
{
if (((Object)val2).name == "EntranceTeleportA(Clone)" && val2.isEntranceToBuilding)
{
val = val2;
break;
}
}
if ((Object)(object)val != (Object)null)
{
instance.SetDestinationToPosition(val.entrancePoint.position, false);
while (Vector3.Distance(((Component)instance).transform.position, val.entrancePoint.position) > 0.5f)
{
}
instance.serverPosition = val.entrancePoint.position;
}
else
{
Debug.LogWarning((object)"EntranceTeleportA(Clone) not found. Using fallback method, the world is so cruel");
float num = 999f;
for (int j = 0; j < array.Length; j++)
{
if (!array[j].isEntranceToBuilding)
{
continue;
}
for (int k = 0; k < StartOfRound.Instance.connectedPlayersAmount + 1; k++)
{
if (!StartOfRound.Instance.allPlayerScripts[k].isInsideFactory && Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[k]).transform.position - array[j].entrancePoint.position) < num)
{
num = Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[k]).transform.position - array[j].entrancePoint.position);
instance.serverPosition = array[j].entrancePoint.position;
}
}
}
}
if (((NetworkBehaviour)instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
instance.ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
}
Transform val3 = instance.ChooseClosestNodeToPosition(instance.serverPosition, false, 0);
if (Vector3.Magnitude(val3.position - instance.serverPosition) > 10f || !SpawnOnDoor)
{
instance.serverPosition = val3.position;
}
((Component)instance).transform.position = instance.serverPosition;
instance.agent.Warp(instance.serverPosition);
instance.SyncPositionToClients();
if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
instance.EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
}
}
}
}