Decompiled source of LethalBots v1.0.1
plugins/TRizzle-LethalBot/LethalBots.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BetterEmote.AssetScripts; using BunkbedRevive; using CSync.Extensions; using CSync.Lib; using CustomItemBehaviourLibrary.AbstractItems; using FacilityMeltdown.API; using GameNetcodeStuff; using HarmonyLib; using LCPeeper; using LethalBots.AI; using LethalBots.AI.AIStates; using LethalBots.Configs; using LethalBots.Constants; using LethalBots.Enums; using LethalBots.Inputs; using LethalBots.Managers; using LethalBots.NetcodePatcher; using LethalBots.NetworkSerializers; using LethalBots.Patches.EnemiesPatches; using LethalBots.Patches.GameEnginePatches; using LethalBots.Patches.MapHazardsPatches; using LethalBots.Patches.MapPatches; using LethalBots.Patches.ModPatches.AdditionalNetworking; using LethalBots.Patches.ModPatches.BetterEmotes; using LethalBots.Patches.ModPatches.BunkbedRevive; using LethalBots.Patches.ModPatches.ButteryFixes; using LethalBots.Patches.ModPatches.LethalPhones; using LethalBots.Patches.ModPatches.LethalProgression; using LethalBots.Patches.ModPatches.ModelRplcmntAPI; using LethalBots.Patches.ModPatches.MoreEmotes; using LethalBots.Patches.ModPatches.Peepers; using LethalBots.Patches.ModPatches.ReviveCompany; using LethalBots.Patches.ModPatches.ShowCapacity; using LethalBots.Patches.ModPatches.TooManyEmotes; using LethalBots.Patches.ModPatches.Zaprillator; using LethalBots.Patches.NpcPatches; using LethalBots.Patches.ObjectsPatches; using LethalBots.SaveAdapter; using LethalBots.Utils; using LethalCompanyInputUtils.Api; using LethalInternship.AI; using LethalInternship.Managers; using LethalLib.Modules; using LethalMin; using Microsoft.CodeAnalysis; using ModelReplacement; using ModelReplacement.Monobehaviors; using ModelReplacement.Patches; using MoreCompany; using MoreCompany.Cosmetics; using MoreEmotes.Patch; using MoreEmotes.Scripts; using Newtonsoft.Json; using OPJosMod.ReviveCompany; using PySpeech; using Scoops.misc; using Scoops.patch; using Steamworks; using TMPro; using TooManyEmotes; using TooManyEmotes.Networking; using TooManyEmotes.Patches; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations.Rigging; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [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("LethalBots")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+a2c8c457bf5a665deb0a2cf0e42cf75ee5f3bf11")] [assembly: AssemblyProduct("LethalBots")] [assembly: AssemblyTitle("LethalBots")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [assembly: TypeForwardedTo(typeof(AllowNullAttribute))] [assembly: TypeForwardedTo(typeof(DisallowNullAttribute))] [assembly: TypeForwardedTo(typeof(MaybeNullAttribute))] [assembly: TypeForwardedTo(typeof(MaybeNullWhenAttribute))] [assembly: TypeForwardedTo(typeof(NotNullAttribute))] [assembly: TypeForwardedTo(typeof(NotNullIfNotNullAttribute))] [assembly: TypeForwardedTo(typeof(NotNullWhenAttribute))] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalBots { [BepInPlugin("T-Rizzle.LethalBots", "LethalBots", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGUID = "T-Rizzle.LethalBots"; public static AssetBundle ModAssets; internal static string DirectoryName; internal static EnemyType LethalBotNPCPrefab; internal static int PluginIrlPlayersCount; internal static ManualLogSource Logger; internal static Config Config; internal static LethalBotsInputs InputActionsInstance; internal static bool IsModTooManyEmotesLoaded; internal static bool IsModModelReplacementAPILoaded; internal static bool IsModCustomItemBehaviourLibraryLoaded; internal static bool IsModMoreCompanyLoaded; internal static bool IsModReviveCompanyLoaded; internal static bool IsModBunkbedReviveLoaded; internal static bool IsModLethalMinLoaded; internal static bool IsModLethalInternsLoaded; internal static bool IsModFacilityMeltdownLoaded; internal static bool IsModNavmeshInCompanyLoaded; private readonly Harmony _harmony = new Harmony("T-Rizzle.LethalBots"); private void Awake() { string text = "lethalbotnpcmodassets"; DirectoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Logger = ((BaseUnityPlugin)this).Logger; Config = new Config(((BaseUnityPlugin)this).Config); InputActionsInstance = new LethalBotsInputs(); InitializeNetworkBehaviours(); ModAssets = AssetBundle.LoadFromFile(Path.Combine(DirectoryName, text)); if ((Object)(object)ModAssets == (Object)null) { Logger.LogFatal((object)"Unknown to load custom assets."); return; } Object[] array = ModAssets.LoadAllAssets(); for (int i = 0; i < array.Length; i++) { Logger.LogInfo((object)$"Found {array[i]} in asset bundle"); Object obj = array[i]; EnemyType val = (EnemyType)(object)((obj is EnemyType) ? obj : null); if (val != null) { LethalBotNPCPrefab = val; break; } } if ((Object)(object)LethalBotNPCPrefab == (Object)null) { Logger.LogFatal((object)"LethalBotNPC prefab failed to load."); return; } foreach (Transform item in (from x in LethalBotNPCPrefab.enemyPrefab.GetComponentsInChildren<Transform>() where (Object)(object)x.parent != (Object)null && ((Object)x.parent).name == "LethalBotNPCObj" && ((Object)x).name != "Collision" && ((Object)x).name != "TurnCompass" && ((Object)x).name != "CreatureSFX" && ((Object)x).name != "CreatureVoice" select x).ToList()) { Object.DestroyImmediate((Object)(object)((Component)item).gameObject); } byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + ((Object)((Component)this).gameObject).name + text)); uint num = BitConverter.ToUInt32(value, 0); Type typeFromHandle = typeof(NetworkObject); FieldInfo field = typeFromHandle.GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); NetworkObject component = LethalBotNPCPrefab.enemyPrefab.GetComponent<NetworkObject>(); field.SetValue(component, num); NetworkPrefabs.RegisterNetworkPrefab(LethalBotNPCPrefab.enemyPrefab); InitPluginManager(); PatchBaseGame(); PatchOtherMods(); RegisterVoiceCommands(); Logger.LogInfo((object)"Plugin LethalBots is loaded!"); } private void PatchBaseGame() { _harmony.PatchAll(typeof(AudioMixerPatch)); _harmony.PatchAll(typeof(AudioReverbTriggerPatch)); _harmony.PatchAll(typeof(DebugPatch)); _harmony.PatchAll(typeof(GameNetworkManagerPatch)); _harmony.PatchAll(typeof(HUDManagerPatch)); _harmony.PatchAll(typeof(NetworkSceneManagerPatch)); _harmony.PatchAll(typeof(NetworkObjectPatch)); _harmony.PatchAll(typeof(RoundManagerPatch)); _harmony.PatchAll(typeof(SoundManagerPatch)); _harmony.PatchAll(typeof(StartOfRoundPatch)); _harmony.PatchAll(typeof(EnemyAIPatch)); _harmony.PatchAll(typeof(PlayerControllerBPatch)); _harmony.PatchAll(typeof(EnemyAICollisionDetect)); _harmony.PatchAll(typeof(BaboonBirdAIPatch)); _harmony.PatchAll(typeof(BlobAIPatch)); _harmony.PatchAll(typeof(BushWolfEnemyPatch)); _harmony.PatchAll(typeof(ButlerBeesEnemyAIPatch)); _harmony.PatchAll(typeof(ButlerEnemyAIPatch)); _harmony.PatchAll(typeof(CaveDwellerAIPatch)); _harmony.PatchAll(typeof(CentipedeAIPatch)); _harmony.PatchAll(typeof(CrawlerAIPatch)); _harmony.PatchAll(typeof(FlowermanAIPatch)); _harmony.PatchAll(typeof(FlowerSnakeEnemyPatch)); _harmony.PatchAll(typeof(ForestGiantAIPatch)); _harmony.PatchAll(typeof(GiantKiwiAIPatch)); _harmony.PatchAll(typeof(JesterAIPatch)); _harmony.PatchAll(typeof(MaskedPlayerEnemyPatch)); _harmony.PatchAll(typeof(MouthDogAIPatch)); _harmony.PatchAll(typeof(NutcrackerEnemyAIPatch)); _harmony.PatchAll(typeof(RadMechAIPatch)); _harmony.PatchAll(typeof(RadMechMissilePatch)); _harmony.PatchAll(typeof(RedLocustBeesPatch)); _harmony.PatchAll(typeof(SandSpiderAIPatch)); _harmony.PatchAll(typeof(SandWormAIPatch)); _harmony.PatchAll(typeof(SpringManAIPatch)); _harmony.PatchAll(typeof(LandminePatch)); _harmony.PatchAll(typeof(QuicksandTriggerPatch)); _harmony.PatchAll(typeof(SpikeRoofTrapPatch)); _harmony.PatchAll(typeof(TurretPatch)); _harmony.PatchAll(typeof(DoorLockPatch)); _harmony.PatchAll(typeof(InteractTriggerPatch)); _harmony.PatchAll(typeof(ShipTeleporterPatch)); _harmony.PatchAll(typeof(VehicleControllerPatch)); _harmony.PatchAll(typeof(DepositItemsDeskPatch)); _harmony.PatchAll(typeof(CaveDwellerPhysicsPropPatch)); _harmony.PatchAll(typeof(DeadBodyInfoPatch)); _harmony.PatchAll(typeof(GrabbableObjectPatch)); _harmony.PatchAll(typeof(RagdollGrabbableObjectPatch)); _harmony.PatchAll(typeof(ShotgunItemPatch)); _harmony.PatchAll(typeof(StunGrenadeItemPatch)); _harmony.PatchAll(typeof(TetraChemicalItemPatch)); } private void PatchOtherMods() { //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Expected O, but got Unknown //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Expected O, but got Unknown //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Expected O, but got Unknown //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Expected O, but got Unknown //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Expected O, but got Unknown //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Expected O, but got Unknown IsModTooManyEmotesLoaded = IsModLoaded("FlipMods.TooManyEmotes"); IsModModelReplacementAPILoaded = IsModLoaded("meow.ModelReplacementAPI"); IsModCustomItemBehaviourLibraryLoaded = IsModLoaded("com.github.WhiteSpike.CustomItemBehaviourLibrary"); IsModMoreCompanyLoaded = IsModLoaded("me.swipez.melonloader.morecompany"); IsModReviveCompanyLoaded = IsModLoaded("OpJosMod.ReviveCompany"); IsModBunkbedReviveLoaded = IsModLoaded("viviko.BunkbedRevive"); IsModLethalMinLoaded = IsModLoaded("NoteBoxz.LethalMin"); IsModLethalInternsLoaded = IsModLoaded("Szumi57.LethalInterns"); IsModFacilityMeltdownLoaded = IsModLoaded("me.loaforc.facilitymeltdown"); IsModNavmeshInCompanyLoaded = IsModLoaded("dev.kittenji.NavMeshInCompany"); bool flag = IsModLoaded("MoreEmotes"); bool flag2 = IsModLoaded("BetterEmotes"); bool flag3 = IsModLoaded("LethalPhones"); bool flag4 = IsModLoaded("Piggy.ShowCapacity"); bool flag5 = IsModLoaded("FlipMods.ReservedItemSlotCore"); bool flag6 = IsModLoaded("Stoneman.LethalProgression"); bool flag7 = IsModLoaded("suskitech.LCAlwaysHearActiveWalkie"); bool flag8 = IsModLoaded("Zaprillator"); bool flag9 = IsModLoaded("butterystancakes.lethalcompany.butteryfixes"); bool flag10 = IsModLoaded("x753.Peepers"); List<string> list = new List<string>(); string[] files = Directory.GetFiles(Path.GetFullPath(Paths.PatcherPluginPath), "*.dll", SearchOption.AllDirectories); foreach (string path in files) { list.Add(Path.GetFileName(path)); } bool flag11 = IsPreLoaderLoaded("AdditionalNetworking_Preloader.dll", list); if (flag) { _harmony.PatchAll(typeof(MoreEmotesPatch)); } if (flag2) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("BetterEmote.Patches.EmotePatch"), "StartPostfix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BetterEmotesPatch), "StartPostfix_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("BetterEmote.Patches.EmotePatch"), "UpdatePostfix", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BetterEmotesPatch), "UpdatePostfix_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("BetterEmote.Patches.EmotePatch"), "PerformEmotePrefix", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BetterEmotesPatch), "PerformEmotePrefix_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } if (IsModTooManyEmotesLoaded) { _harmony.PatchAll(typeof(EmoteControllerPlayerPatch)); _harmony.PatchAll(typeof(ThirdPersonEmoteControllerPatch)); } if (IsModModelReplacementAPILoaded) { _harmony.PatchAll(typeof(BodyReplacementBasePatch)); _harmony.PatchAll(typeof(ModelReplacementPlayerControllerBPatchPatch)); _harmony.PatchAll(typeof(ModelReplacementAPIPatch)); } if (flag3) { _harmony.PatchAll(typeof(PlayerPhonePatchPatch)); _harmony.PatchAll(typeof(PhoneBehaviorPatch)); _harmony.PatchAll(typeof(PlayerPhonePatchLI)); } if (flag11) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("AdditionalNetworking.Patches.Inventory.PlayerControllerBPatch"), "OnStart", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(AdditionalNetworkingPatch), "Start_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } if (flag4) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("ShowCapacity.Patches.PlayerControllerBPatch"), "Update_PreFix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ShowCapacityPatch), "Update_PreFix_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (IsModReviveCompanyLoaded) { _harmony.PatchAll(typeof(ReviveCompanyGeneralUtilPatch)); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("OPJosMod.ReviveCompany.Patches.PlayerControllerBPatch"), "setHoverTipAndCurrentInteractTriggerPatch", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ReviveCompanyPlayerControllerBPatchPatch), "SetHoverTipAndCurrentInteractTriggerPatch_Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } if (IsModBunkbedReviveLoaded) { _harmony.PatchAll(typeof(BunkbedControllerPatch)); } if (flag8) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("Zaprillator.Behaviors.RevivablePlayer"), "IShockableWithGun.StopShockingWithGun", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RevivablePlayerPatch), "StopShockingWithGun_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (flag6) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("LethalProgression.Skills.HPRegen"), "HPRegenUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HPRegenPatch), "HPRegenUpdate_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("LethalProgression.Skills.Oxygen"), "EnteredWater", (Type[])null, (Type[])null), new HarmonyMethod(typeof(OxygenPatch), "EnteredWater_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("LethalProgression.Skills.Oxygen"), "LeftWater", (Type[])null, (Type[])null), new HarmonyMethod(typeof(OxygenPatch), "LeftWater_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("LethalProgression.Skills.Oxygen"), "ShouldDrown", (Type[])null, (Type[])null), new HarmonyMethod(typeof(OxygenPatch), "ShouldDrown_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("LethalProgression.Skills.Oxygen"), "OxygenUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(OxygenPatch), "OxygenUpdate_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (flag9) { _harmony.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("ButteryFixes.Patches.Player.BodyPatches"), "DeadBodyInfoPostStart", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BodyPatchesPatch), "DeadBodyInfoPostStart_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (flag10) { _harmony.PatchAll(typeof(PeeperAttachHitboxPatch)); } } private void RegisterVoiceCommands() { string[] ValidCommands = new string[8] { "jester", "start the ship", "hop off the terminal", "request monitoring", "request teleport", "clear monitoring", "man the ship", "transmit" }; Speech.RegisterPhrases(ValidCommands); FieldInfo bestMatchField = AccessTools.Field(typeof(Speech), "bestMatch"); Speech.RegisterCustomHandler((EventHandler<SpeechEventArgs>)handler); void handler(object speechInstance, SpeechEventArgs text) { if (Config.AllowVoiceRecognition.Value) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val != (Object)null && Speech.IsAboveThreshold(ValidCommands, (double)Config.VoiceRecognitionSimilarityThreshold.Value)) { LethalBotManager.Instance?.TransmitVoiceChatAndSync((string)bestMatchField.GetValue(null), (int)val.playerClientId); } } } } private bool IsModLoaded(string modGUID) { bool flag = Chainloader.PluginInfos.ContainsKey(modGUID); if (flag) { LogInfo("Mod compatibility loaded for mod : GUID " + modGUID); } return flag; } private bool IsPreLoaderLoaded(string dllFileName, List<string> fileNames) { bool flag = fileNames.Contains(dllFileName); if (flag) { LogInfo("Mod compatibility loaded for preloader : " + dllFileName); } return flag; } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } catch { } } } } private static void InitPluginManager() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("PluginManager"); val.AddComponent<PluginManager>(); PluginManager.Instance.InitManagers(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogDebug(string debugLog) { if (Config.EnableDebugLog.Value) { Logger.LogDebug((object)debugLog); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogInfo(string infoLog) { Logger.LogInfo((object)infoLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogWarning(string warningLog) { Logger.LogWarning((object)warningLog); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogError(string errorLog) { Logger.LogError((object)errorLog); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LethalBots"; public const string PLUGIN_NAME = "LethalBots"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace LethalBots.Utils { internal static class ComponentUtil { public static void ListAllComponents(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } Plugin.LogDebug(" "); Plugin.LogDebug("List of components :"); Component[] components = gameObject.GetComponents(typeof(Component)); Component[] array = components; foreach (Component val in array) { if (!((Object)(object)val == (Object)null)) { Plugin.LogDebug(((object)val).ToString()); } } Plugin.LogDebug("Child components :"); components = gameObject.GetComponentsInChildren(typeof(Component)); Component[] array2 = components; foreach (Component val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { Plugin.LogDebug(((object)val2).ToString()); } } Plugin.LogDebug("Parent components :"); components = gameObject.GetComponentsInParent(typeof(Component)); Component[] array3 = components; foreach (Component val3 in array3) { if (!((Object)(object)val3 == (Object)null)) { Plugin.LogDebug(((object)val3).ToString()); } } } public static void ListAllColliders(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } Plugin.LogDebug(" "); Plugin.LogDebug("List of Colliders: "); Component[] components = gameObject.GetComponents(typeof(Collider)); Component[] array = components; foreach (Component val in array) { if (!((Object)(object)val == (Object)null)) { Plugin.LogDebug(((object)val).ToString()); } } Plugin.LogDebug("Child Colliders: "); components = gameObject.GetComponentsInChildren(typeof(Collider)); Component[] array2 = components; foreach (Component val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { Plugin.LogDebug(((object)val2).ToString()); } } Plugin.LogDebug("Parent Colliders: "); components = gameObject.GetComponentsInParent(typeof(Collider)); Component[] array3 = components; foreach (Component val3 in array3) { if (!((Object)(object)val3 == (Object)null)) { Plugin.LogDebug(((object)val3).ToString()); } } } public static void SetFieldValue(object obj, string fieldName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(obj, value); } public static void SetPropertyValue(object obj, string propertyName, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); property.SetValue(obj, value); } public static T GetCopyOf<T>(this Component comp, T other) where T : Component { Type type = ((object)comp).GetType(); if (type != ((object)other).GetType()) { return default(T); } BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo[] properties = type.GetProperties(bindingAttr); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (propertyInfo.CanWrite && propertyInfo.CanRead && !(propertyInfo.Name == "name")) { try { propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null); } catch { } } } FieldInfo[] allFields = PropertiesAndFieldsUtils.GetAllFields(type); FieldInfo[] array2 = allFields; foreach (FieldInfo fieldInfo in array2) { if (!fieldInfo.IsStatic) { fieldInfo.SetValue(comp, fieldInfo.GetValue(other)); } } return (T)(object)((comp is T) ? comp : null); } public static T AddCopyOfComponent<T>(this GameObject go, T toAdd) where T : Component { return ((Component)(object)go.AddComponent<T>()).GetCopyOf(toAdd); } public static T CopyComponent<T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component component = destination.GetComponent(type); T val = (T)(object)((component is T) ? component : null); if (!Object.op_Implicit((Object)(object)val)) { Component obj = destination.AddComponent(type); val = (T)(object)((obj is T) ? obj : null); } FieldInfo[] allFields = PropertiesAndFieldsUtils.GetAllFields(type); FieldInfo[] array = allFields; foreach (FieldInfo fieldInfo in array) { if (!fieldInfo.IsStatic) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } } PropertyInfo[] properties = type.GetProperties(); PropertyInfo[] array2 = properties; foreach (PropertyInfo propertyInfo in array2) { if (propertyInfo.CanWrite && propertyInfo.CanWrite && !(propertyInfo.Name == "name")) { propertyInfo.SetValue(val, propertyInfo.GetValue(original, null), null); } } return val; } } internal static class DrawUtil { public static void DrawWhiteLine(LineRenderer? lr, Ray ray, float length) { //IL_0001: 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) DrawLine(lr, ray, length, Color.white); } public static void DrawLine(LineRenderer? lr, Ray ray, float length, Color color) { //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) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 origin = ((Ray)(ref ray)).origin; Vector3 origin2 = ((Ray)(ref ray)).origin; Vector3 direction = ((Ray)(ref ray)).direction; DrawLine(lr, origin, origin2 + ((Vector3)(ref direction)).normalized * length, color); } public static void DrawLine(LineRenderer? lr, Vector3 start, Vector3 end, Color color) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0020: 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_0045: 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) if (!((Object)(object)lr == (Object)null)) { ((Renderer)lr).material = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply")); lr.startColor = color; lr.endColor = color; lr.startWidth = 0.1f; lr.endWidth = 0.1f; lr.SetPosition(0, start); lr.SetPosition(1, end); } } } public class LineRendererUtil { private LineRenderer[] _listLineRenderers; private Transform _transformToParent; private int _index; public LineRendererUtil(int nbMaxLineRenderer, Transform transformToParent) { _listLineRenderers = (LineRenderer[])(object)new LineRenderer[nbMaxLineRenderer]; _transformToParent = transformToParent; } public LineRenderer? GetLineRenderer() { return null; } private LineRenderer CreateLineRenderer() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) LineRenderer lineRenderer = new GameObject().AddComponent<LineRenderer>(); return InitLineRenderer(ref lineRenderer); } private LineRenderer InitLineRenderer(ref LineRenderer lineRenderer) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) ((Component)lineRenderer).gameObject.transform.SetParent(((Component)_transformToParent).transform, false); ((Component)lineRenderer).gameObject.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); return lineRenderer; } } internal static class PatchesUtil { public static readonly FieldInfo FieldInfoWasUnderwaterLastFrame = AccessTools.Field(typeof(PlayerControllerB), "wasUnderwaterLastFrame"); public static readonly FieldInfo FieldInfoPlayerClientId = AccessTools.Field(typeof(PlayerControllerB), "playerClientId"); public static readonly FieldInfo FieldInfoPreviousAnimationStateHash = AccessTools.Field(typeof(PlayerControllerB), "previousAnimationStateHash"); public static readonly FieldInfo FieldInfoCurrentAnimationStateHash = AccessTools.Field(typeof(PlayerControllerB), "currentAnimationStateHash"); public static readonly FieldInfo FieldInfoTargetPlayer = AccessTools.Field(typeof(BushWolfEnemy), "targetPlayer"); public static readonly FieldInfo FieldInfoDraggingPlayer = AccessTools.Field(typeof(BushWolfEnemy), "draggingPlayer"); public static readonly MethodInfo AllEntitiesCountMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AllEntitiesCount())); public static readonly MethodInfo AllRealPlayersCountMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => AllRealPlayersCount())); public static readonly MethodInfo IsPlayerLocalOrLethalBotOwnerLocalMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsPlayerLocalOrLethalBotMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsColliderFromLocalOrLethalBotOwnerLocalMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(Collider))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsPlayerLethalBotMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsPlayerLocalMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsIdPlayerLethalBotMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => IsIdPlayerLethalBot(0))); public static readonly MethodInfo IsRagdollPlayerIdLethalBotMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(RagdollGrabbableObject))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsPlayerLethalBotOwnerLocalMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo IsAnLethalBotAiOwnerOfObjectMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => IsAnLethalBotAiOwnerOfObject((GrabbableObject)new object()))); public static readonly MethodInfo DisableOriginalGameDebugLogsMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => DisableOriginalGameDebugLogs())); public static readonly MethodInfo IsPlayerLethalBotControlledAndOwnerMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo GetDamageFromSlimeIfLethalBotMethod = SymbolExtensions.GetMethodInfo(Expression.Lambda<Action>(Expression.Call(null, (MethodInfo)MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), Expression.New(typeof(PlayerControllerB))), Array.Empty<ParameterExpression>())); public static readonly MethodInfo SyncJumpMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => SyncJump(0uL))); public static readonly MethodInfo SyncLandFromJumpMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => SyncLandFromJump(0uL, fallHard: false))); public static List<CodeInstruction> InsertIsPlayerLethalBotInstructions(List<CodeInstruction> codes, ILGenerator generator, int startIndex, int indexToJumpTo) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown List<Label> labels = codes[startIndex].labels; List<Label> labels2 = codes[startIndex + indexToJumpTo].labels; Label label = generator.DefineLabel(); labels2.Add(label); if (labels.Count > 0) { codes.Insert(startIndex + 1, new CodeInstruction(codes[startIndex].opcode, codes[startIndex].operand)); codes[startIndex].opcode = OpCodes.Nop; codes[startIndex].operand = null; startIndex++; } List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)IsPlayerLethalBotMethod), new CodeInstruction(OpCodes.Brtrue_S, (object)label) }; codes.InsertRange(startIndex, collection); return codes; } public static List<CodeInstruction> InsertLogOfFieldOfThis(string logWithZeroParameter, FieldInfo fieldInfo, Type fieldType) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Plugin), "Logger"))); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)logWithZeroParameter)); list.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)); list.Add(new CodeInstruction(OpCodes.Box, (object)fieldType)); list.Add(new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => string.Format(new string(new char[0]), new object()))))); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Plugin.LogDebug(new string(new char[0])))))); return list; } public static List<CodeInstruction> InsertLogWithoutParameters(string log) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Plugin), "Logger"))); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)log)); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Plugin.LogDebug(new string(new char[0])))))); return list; } public static List<CodeInstruction> InsertIsBypass(List<CodeInstruction> codes, ILGenerator generator, int startIndex, int indexToJumpTo) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown List<Label> labels = codes[startIndex].labels; List<Label> labels2 = codes[startIndex + indexToJumpTo].labels; Label label = generator.DefineLabel(); labels2.Add(label); if (labels.Count > 0) { codes.Insert(startIndex + 1, new CodeInstruction(codes[startIndex].opcode, codes[startIndex].operand)); codes[startIndex].opcode = OpCodes.Nop; codes[startIndex].operand = null; startIndex++; } List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Call, (object)DisableOriginalGameDebugLogsMethod), new CodeInstruction(OpCodes.Brtrue_S, (object)label) }; codes.InsertRange(startIndex, collection); return codes; } public static bool IsGrabbableObjectEqualsToNull(GrabbableObject grabbableObject) { return (Object)(object)grabbableObject == (Object)null; } private static bool DisableOriginalGameDebugLogs() { return false; } private static bool IsPlayerLocal(PlayerControllerB player) { return LethalBotManager.IsPlayerLocal(player); } private static bool IsPlayerLocalOrLethalBot(PlayerControllerB player) { return LethalBotManager.Instance.IsPlayerLocalOrLethalBot(player); } private static bool IsPlayerLocalOrLethalBotOwnerLocal(PlayerControllerB player) { return LethalBotManager.Instance.IsPlayerLocalOrLethalBotOwnerLocal(player); } private static int AllEntitiesCount() { return LethalBotManager.Instance.AllEntitiesCount; } private static int AllRealPlayersCount() { return Math.Clamp(LethalBotManager.Instance.AllRealPlayersCount - 1, 0, AllEntitiesCount()); } private static bool IsColliderFromLocalOrLethalBotOwnerLocal(Collider collider) { return LethalBotManager.Instance.IsColliderFromLocalOrLethalBotOwnerLocal(collider); } private static bool IsPlayerLethalBot(PlayerControllerB player) { return LethalBotManager.Instance.IsPlayerLethalBot(player); } private static bool IsIdPlayerLethalBot(int id) { return LethalBotManager.Instance.IsPlayerLethalBot(id); } private static bool IsRagdollPlayerIdLethalBot(RagdollGrabbableObject ragdollGrabbableObject) { return LethalBotManager.Instance.IsPlayerLethalBot((int)ragdollGrabbableObject.ragdoll.playerScript.playerClientId); } private static bool IsPlayerLethalBotOwnerLocal(PlayerControllerB player) { return LethalBotManager.Instance.IsPlayerLethalBotOwnerLocal(player); } private static bool IsPlayerLethalBotControlledAndOwner(PlayerControllerB player) { return LethalBotManager.Instance.IsPlayerLethalBotControlledAndOwner(player); } private static int GetDamageFromSlimeIfLethalBot(PlayerControllerB player) { return LethalBotManager.Instance.GetDamageFromSlimeIfLethalBot(player); } private static bool IsAnLethalBotAiOwnerOfObject(GrabbableObject grabbableObject) { return LethalBotManager.Instance.IsAnLethalBotAiOwnerOfObject(grabbableObject); } private static void SyncJump(ulong playerClientId) { LethalBotManager.Instance.GetLethalBotAI((int)playerClientId)?.SyncJump(); } private static void SyncLandFromJump(ulong playerClientId, bool fallHard) { LethalBotManager.Instance.GetLethalBotAI((int)playerClientId)?.SyncLandFromJump(fallHard); } } internal static class PropertiesAndFieldsUtils { public static void ListNamesOfObjectsArray<T>(T[] array) { Type typeFromHandle = typeof(T); Plugin.LogDebug(" "); if (array == null) { Plugin.LogDebug($"Array of type {typeFromHandle} is null"); return; } if (array.Length == 0) { Plugin.LogDebug($"Array of type {typeFromHandle} is empty"); return; } PropertyInfo[] readablePropertiesOf = GetReadablePropertiesOf(typeFromHandle); Plugin.LogDebug($"- List of type : {typeFromHandle}"); for (int i = 0; i < array.Length; i++) { T val = array[i]; if (val != null) { Plugin.LogDebug($" Object {i}: \"{NameOfObject(val, readablePropertiesOf)}\""); } } } public static void ListPropertiesAndFieldsOfArray<T>(T[] array, bool hasToListProperties = true, bool hasToListFields = true) { Type typeFromHandle = typeof(T); if (array == null) { Plugin.LogDebug($"Array of type {typeFromHandle} is null"); return; } if (array.Length == 0) { Plugin.LogDebug($"Array of type {typeFromHandle} is empty"); return; } PropertyInfo[] readablePropertiesOf = GetReadablePropertiesOf(typeFromHandle); FieldInfo[] allFields = GetAllFields(typeFromHandle); for (int i = 0; i < array.Length; i++) { if (hasToListProperties) { LogProperties(array[i], typeFromHandle, readablePropertiesOf); } Plugin.LogDebug(" "); Plugin.LogDebug($"- Fields of \"{NameOfObject(array[i], readablePropertiesOf)}\" of type \"{typeFromHandle}\" :"); if (hasToListFields) { LogFields(array[i], typeFromHandle, allFields); } } } public static void ListPropertiesAndFields<T>(T obj, bool hasToListProperties = true, bool hasToListFields = true) { Type typeFromHandle = typeof(T); PropertyInfo[] readablePropertiesOf = GetReadablePropertiesOf(typeFromHandle); if (hasToListProperties) { LogProperties(obj, typeFromHandle, readablePropertiesOf); } Plugin.LogDebug(" "); Plugin.LogDebug($"- Fields of \"{NameOfObject(obj, readablePropertiesOf)}\" of type \"{typeFromHandle}\" :"); FieldInfo[] allFields = GetAllFields(typeFromHandle); if (hasToListFields) { LogFields(obj, typeFromHandle, allFields); } } public static NetworkObject? GetNetworkObjectByHash(uint hashID) { FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Plugin.LogError("GlobalObjectIdHash field is null."); return null; } NetworkObject[] array = Resources.FindObjectsOfTypeAll<NetworkObject>(); foreach (NetworkObject val in array) { uint num = (uint)field.GetValue(val); if (num == hashID) { return val; } } return null; } private static void LogProperties<T>(T obj, Type typeObj, PropertyInfo[] arrObjProperties) { if (obj == null) { Plugin.LogDebug($"Object of type {typeObj} is null"); return; } Plugin.LogDebug(" "); Plugin.LogDebug($"- Properties of \"{NameOfObject(obj, arrObjProperties)}\" of type \"{typeObj}\" :"); foreach (PropertyInfo propertyInfo in arrObjProperties) { Plugin.LogDebug($" {propertyInfo.Name} = {GetValueOfProperty(obj, propertyInfo)}"); } } private static string NameOfObject<T>(T obj, PropertyInfo[] propertyInfos) { object valueOfProperty = GetValueOfProperty(obj, propertyInfos.FirstOrDefault((PropertyInfo x) => x.Name == "name")); if (valueOfProperty != null) { return valueOfProperty.ToString(); } return "name null"; } private static void LogFields<T>(T obj, Type typeObj, FieldInfo[] arrObjFields) { if (obj == null) { Plugin.LogDebug($"Object of type {typeObj} is null"); return; } Plugin.LogDebug(" "); foreach (FieldInfo fieldInfo in arrObjFields) { Plugin.LogDebug($" {fieldInfo.Name} = {GetValueOfField(obj, fieldInfo)}"); } } public static FieldInfo[] GetAllFields(Type t) { if (t == null) { return new FieldInfo[0]; } BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; return t.GetFields(bindingAttr).Concat(GetAllFields(t.BaseType)).ToArray(); } private static PropertyInfo[] GetReadablePropertiesOf(Type type) { return (from x in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy) where x.CanRead select x).ToArray(); } private static object? GetValueOfProperty<T>(T obj, PropertyInfo propertyInfo) { if (propertyInfo == null) { return null; } if (!propertyInfo.GetAccessors(nonPublic: true)[0].IsStatic) { return propertyInfo.GetValue(obj, null); } return propertyInfo.GetValue(null); } private static object? GetValueOfField<T>(T obj, FieldInfo fieldInfo) { if (fieldInfo == null) { return null; } if (!fieldInfo.IsStatic) { return fieldInfo.GetValue(obj); } return fieldInfo.GetValue(null); } } public class RayUtil { public static void RayCastAndDrawFromPointWithColor(LineRenderer? lr, Vector3 origin, Vector3 endPoint, Color color) { //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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Ray ray = default(Ray); ((Ray)(ref ray))..ctor(origin, endPoint - origin); float length = Vector3.Distance(endPoint, origin); DrawUtil.DrawLine(lr, ray, length, color); } public static bool RayCastAndDraw(LineRenderer? lr, Vector3 origin, Vector3 directionOrigin, float angle, float length) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) Vector3 val = Vector3.Cross(directionOrigin, Vector3.up); if (val == Vector3.zero) { val = Vector3.right; } Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(origin, Quaternion.AngleAxis(angle, val) * directionOrigin); if (Physics.Raycast(val2, length, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1)) { DrawUtil.DrawLine(lr, val2, length, Color.red); return true; } DrawUtil.DrawWhiteLine(lr, val2, length); return false; } public static bool RayCastForwardAndDraw(LineRenderer? lr, Vector3 origin, Vector3 directionForward, float length) { //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_0009: 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_001e: 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) Ray val = default(Ray); ((Ray)(ref val))..ctor(origin, directionForward); if (Physics.Raycast(val, length, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1)) { DrawUtil.DrawLine(lr, val, length, Color.red); return true; } DrawUtil.DrawWhiteLine(lr, val, length); return false; } public static bool RayCastDownAndDraw(LineRenderer? lr, Vector3 origin, float length) { //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_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Ray val = default(Ray); ((Ray)(ref val))..ctor(origin, Vector3.down); if (Physics.Raycast(val, length, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1)) { DrawUtil.DrawLine(lr, val, length, Color.red); return true; } DrawUtil.DrawWhiteLine(lr, val, length); return false; } } internal static class TreesUtils { public static void PrintTransformTree(Transform[] tree, string? parent = null) { if (tree == null) { Plugin.LogDebug("Tree of transform is null"); return; } if (tree.Length == 0) { Plugin.LogDebug("Tree of transform is empty"); return; } if (Utility.IsNullOrWhiteSpace(parent)) { Transform? obj = tree.FirstOrDefault(); object obj2; if (obj == null) { obj2 = null; } else { Transform parent2 = obj.parent; if (parent2 == null) { obj2 = null; } else { Transform root = parent2.root; obj2 = ((root != null) ? ((Object)root).name : null); } } parent = (string?)obj2; } TransformTreeTraversal(tree, parent, 0); } private static void TransformTreeTraversal(Transform[] tree, string? parent, int depth) { StringBuilder stringBuilder = new StringBuilder(); foreach (Transform val in tree) { if ((string.IsNullOrWhiteSpace(parent) && ((Object)(object)val.parent == (Object)null || string.IsNullOrWhiteSpace(((Object)val.parent).name))) || ((Object)(object)val.parent != (Object)null && ((Object)val.parent).name == parent)) { for (int j = 1; j <= depth - 1; j++) { stringBuilder.Append("│ "); } if (depth > 0) { stringBuilder.Append("├──"); } Plugin.LogDebug(stringBuilder.ToString() + ((Object)val).name); stringBuilder.Clear(); TransformTreeTraversal(tree, ((Object)val).name, depth + 1); } } } public static void PrintComponentsTreeOfGameObject(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { Plugin.LogDebug("GameObject is null"); return; } Component[] array = (from x in gameObject.GetComponentsInChildren(typeof(Component)) where (Object)(object)x != (Object)null select x).ToArray(); if (array.Length == 0) { Plugin.LogDebug("GameObject has no components"); } else { ComponentTreeTraversal(array); } } private static int ComponentTreeTraversal(Component[] tree, string? parent = null, int index = 0, int depth = 0, string lastTransformName = "") { StringBuilder stringBuilder = new StringBuilder(); for (int i = index; i < tree.Length; i++) { Component val = tree[i]; Transform val2 = (Transform)(object)((val is Transform) ? val : null); bool flag = (Object)(object)val2 != (Object)null; if ((Object)(object)val2 == (Object)null) { val2 = val.transform; } if (string.IsNullOrWhiteSpace(parent)) { Transform parent2 = val2.parent; if (string.IsNullOrWhiteSpace((parent2 != null) ? ((Object)parent2).name : null)) { Plugin.LogDebug((flag ? ((Object)val2).name : ((object)val).ToString()) ?? ""); } } if (string.IsNullOrWhiteSpace(parent)) { Transform parent3 = val2.parent; if (!string.IsNullOrWhiteSpace((parent3 != null) ? ((Object)parent3).name : null)) { parent = ((Object)val2.parent).name; } } if (parent == ((Object)val2).name) { for (int j = 1; j <= depth - 1; j++) { stringBuilder.Append("│ "); } if (depth > 0) { stringBuilder.Append("├──"); } Plugin.LogDebug($"{stringBuilder}{(flag ? ((Object)val2).name : ((object)val).ToString())}"); stringBuilder.Clear(); continue; } Transform parent4 = val2.parent; if (((parent4 != null) ? ((Object)parent4).name : null) == parent && flag) { for (int k = 1; k <= depth - 1; k++) { stringBuilder.Append("│ "); } if (depth > 0) { stringBuilder.Append("├──"); } if (!(((Object)val2).name == lastTransformName)) { lastTransformName = ((Object)val2).name; Plugin.LogDebug($"{stringBuilder}{((Object)val2).name}"); stringBuilder.Clear(); i = ComponentTreeTraversal(tree, ((Object)val2).name, i + 1, depth + 1, lastTransformName); index = i; } } } return index; } } } namespace LethalBots.SaveAdapter { [Serializable] public class SaveFile { public IdentitySaveFile[] IdentitiesSaveFiles; } [Serializable] public class IdentitySaveFile { public int IdIdentity; public int SuitID; public int Hp; public int Status; public int XP; public int Level; public override string ToString() { return $"IdIdentity: {IdIdentity}, suitID {SuitID}, Hp {Hp}, XP {XP}, Level {Level}, Status {Status} {(EnumStatusIdentity)Status}"; } } } namespace LethalBots.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] public class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("LethalBot.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal Resources() { } } } namespace LethalBots.Patches.ObjectsPatches { [HarmonyPatch(typeof(CaveDwellerPhysicsProp))] public class CaveDwellerPhysicsPropPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(CaveDwellerPhysicsProp __instance) { LethalBotManager.Instance.GrabbableObjectSpawned((GrabbableObject)(object)__instance); } [HarmonyPatch("Update")] [HarmonyPrefix] private static bool Update_Prefix(CaveDwellerPhysicsProp __instance) { PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; CaveDwellerAI caveDwellerScript = __instance.caveDwellerScript; if ((Object)(object)caveDwellerScript == (Object)null || (Object)(object)playerHeldBy == (Object)null) { return true; } LethalBotAI lethalBotAIIfLocalIsOwner = LethalBotManager.Instance.GetLethalBotAIIfLocalIsOwner(playerHeldBy); if (((GrabbableObject)__instance).isHeld && (Object)(object)lethalBotAIIfLocalIsOwner != (Object)null && caveDwellerScript.rockingBaby > 0) { float value = lethalBotAIIfLocalIsOwner.FearLevel.Value; if (caveDwellerScript.rockingBaby < 2 && value > 0.75f) { caveDwellerScript.rockingBaby = 2; playerHeldBy.playerBodyAnimator.SetInteger("RockBaby", 2); __instance.SetRockingBabyServerRpc(true); } else if (value < 0.6f && caveDwellerScript.rockingBaby > 2) { caveDwellerScript.rockingBaby = 1; playerHeldBy.playerBodyAnimator.SetInteger("RockBaby", 1); __instance.SetRockingBabyServerRpc(false); } } return true; } [HarmonyPatch("DropBabyClientRpc")] [HarmonyPrefix] private static bool DropBabyClientRpc_Prefix(CaveDwellerAI __instance, int playerId) { LethalBotAI lethalBotAIIfLocalIsOwner = LethalBotManager.Instance.GetLethalBotAIIfLocalIsOwner(playerId); if ((Object)(object)lethalBotAIIfLocalIsOwner != (Object)null) { return false; } return true; } [HarmonyPatch("DiscardItem")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> DiscardItem_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(GameNetworkManager), "Instance"); FieldInfo fieldInfo = AccessTools.Field(typeof(GameNetworkManager), "localPlayerController"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(GrabbableObject), "playerHeldBy"); FieldInfo fieldInfo3 = AccessTools.Field(typeof(PlayerControllerB), "playerBodyAnimator"); FieldInfo fieldInfo4 = AccessTools.Field(typeof(PlayerControllerB), "playerClientId"); Plugin.LogDebug("Beginning to patch CaveDwellerPhysicsProp.DiscardItem!"); for (int i = 0; i < list.Count - 2; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo) && CodeInstructionExtensions.LoadsField(list[i + 1], fieldInfo, false) && CodeInstructionExtensions.LoadsField(list[i + 2], fieldInfo3, false)) { Plugin.LogDebug($"Patching localPlayerController usage at index {i}..."); Plugin.LogDebug($"Original Codes: 1: {list[i]}, 2: {list[i + 1]}, 3: {list[i + 2]}"); num = i; break; } } if (num != -1) { list.RemoveRange(num, 3); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo2), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo3) }; list.InsertRange(num, collection); num = -1; } else { Plugin.LogError("LethalBot.Patches.ObjectPatches.CaveDwellerPhysicsProp.DiscardItem_Transpiler could not find the localPlayerController reference for animations!"); } for (int j = 0; j < list.Count - 2; j++) { if (CodeInstructionExtensions.Calls(list[j], methodInfo) && CodeInstructionExtensions.LoadsField(list[j + 1], fieldInfo, false) && CodeInstructionExtensions.LoadsField(list[j + 2], fieldInfo4, false)) { Plugin.LogDebug($"Patching localPlayerController usage at index {j}..."); Plugin.LogDebug($"Original Codes: 1: {list[j]}, 2: {list[j + 1]}, 3: {list[j + 2]}"); num = j; break; } } if (num != -1) { list.RemoveRange(num, 3); List<CodeInstruction> collection2 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo2), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo4) }; list.InsertRange(num, collection2); num = -1; } else { Plugin.LogError("LethalBot.Patches.ObjectPatches.CaveDwellerPhysicsProp.DiscardItem_Transpiler could not find the localPlayerController reference for RPC!"); } Plugin.LogDebug("Finished patching CaveDwellerPhysicsProp.DiscardItem!"); return list.AsEnumerable(); } } [HarmonyPatch(typeof(DeadBodyInfo))] public class DeadBodyInfoPatch { private class DeadBodyInfoMonitor : UpdateLimiter { public Dictionary<LethalBotAI, bool> lethalBotAIs = new Dictionary<LethalBotAI, bool>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetBotSeenBody(LethalBotAI bot) { lethalBotAIs[bot] = true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool HasBotSeenBody(LethalBotAI bot) { return lethalBotAIs.GetValueOrDefault(bot, defaultValue: false); } } private static ConditionalWeakTable<DeadBodyInfo, DeadBodyInfoMonitor> lethalBotDeadBodyInfoMonitor = new ConditionalWeakTable<DeadBodyInfo, DeadBodyInfoMonitor>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static DeadBodyInfoMonitor GetOrCreateMonitor(DeadBodyInfo body) { return lethalBotDeadBodyInfoMonitor.GetOrCreateValue(body); } [HarmonyPatch("DetectIfSeenByLocalPlayer")] [HarmonyPostfix] private static void DetectIfSeenByLocalPlayer_PostFix(DeadBodyInfo __instance) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) DeadBodyInfoMonitor orCreateMonitor = GetOrCreateMonitor(__instance); if (!orCreateMonitor.CanUpdate()) { orCreateMonitor.Update(Time.deltaTime); return; } orCreateMonitor.Invalidate(); LethalBotAI[] lethalBotsAIOwnedByLocal = LethalBotManager.Instance.GetLethalBotsAIOwnedByLocal(); LethalBotAI[] array = lethalBotsAIOwnedByLocal; foreach (LethalBotAI lethalBotAI in array) { PlayerControllerB npc = lethalBotAI.NpcController.Npc; if (!((Object)(object)npc != (Object)null) || orCreateMonitor.HasBotSeenBody(lethalBotAI)) { continue; } Rigidbody val = null; float num = Vector3.Distance(((Component)npc.gameplayCamera).transform.position, ((Component)__instance).transform.position); Rigidbody[] bodyParts = __instance.bodyParts; foreach (Rigidbody val2 in bodyParts) { if ((Object)(object)val == (Object)(object)val2) { continue; } val = val2; if (npc.HasLineOfSightToPosition(((Component)val).transform.position, 30f / (num / 5f), 60, -1f)) { if (num < 10f) { npc.JumpToFearLevel(0.9f, true); } else { npc.JumpToFearLevel(0.55f, true); } orCreateMonitor.SetBotSeenBody(lethalBotAI); break; } } } } [HarmonyPatch("Start")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Start_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count - 8; i++) { if (((object)list[i]).ToString().StartsWith("ldarg.0 NULL") && ((object)list[i + 3]).ToString().StartsWith("ldarg.0 NULL") && ((object)list[i + 8]).ToString() == "ldstr \"PlayerRagdoll\"") { num = i; break; } } if (num > -1) { List<Label> labels = list[num + 3].labels; Label label = generator.DefineLabel(); labels.Add(label); List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DeadBodyInfo), "playerObjectId"))); list2.Add(new CodeInstruction(OpCodes.Call, (object)PatchesUtil.IsIdPlayerLethalBotMethod)); list2.Add(new CodeInstruction(OpCodes.Brtrue_S, (object)label)); List<CodeInstruction> collection = list2; list.InsertRange(num, collection); num = -1; } else { Plugin.LogError("LethalBot.Patches.ObjectsPatches.DeadBodyInfoPatch.Start_Transpiler remplace with correct tag if bot."); } return list.AsEnumerable(); } [HarmonyPatch("OnDestroy")] [HarmonyPostfix] private static void OnDestroy_Postfix(DeadBodyInfo __instance) { if (lethalBotDeadBodyInfoMonitor.TryGetValue(__instance, out DeadBodyInfoMonitor _)) { lethalBotDeadBodyInfoMonitor.Remove(__instance); } } } [HarmonyPatch(typeof(GrabbableObject))] public class GrabbableObjectPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(GrabbableObject __instance) { LethalBotManager.Instance.GrabbableObjectSpawned(__instance); } [HarmonyPatch("SetControlTipsForItem")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool SetControlTipsForItem_PreFix(GrabbableObject __instance) { return !LethalBotManager.Instance.IsAnLethalBotAiOwnerOfObject(__instance); } [HarmonyPatch("DiscardItemOnClient")] [HarmonyPrefix] private static bool DiscardItemOnClient_PreFix(GrabbableObject __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner) { return true; } PlayerControllerB playerHeldBy = __instance.playerHeldBy; if ((Object)(object)playerHeldBy != (Object)null) { LethalBotAI lethalBotAIIfLocalIsOwner = LethalBotManager.Instance.GetLethalBotAIIfLocalIsOwner(playerHeldBy); if ((Object)(object)lethalBotAIIfLocalIsOwner != (Object)null) { __instance.DiscardItem(); lethalBotAIIfLocalIsOwner.SyncBatteryLethalBotServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), (int)(__instance.insertedBattery.charge * 100f)); if (__instance.itemProperties.syncDiscardFunction) { __instance.isSendingItemRPC++; lethalBotAIIfLocalIsOwner.DiscardItemServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject)); } return false; } } return true; } [HarmonyPatch("DiscardItem")] [HarmonyPrefix] private static bool DiscardItem_PreFix(GrabbableObject __instance) { PlayerControllerB playerHeldBy = __instance.playerHeldBy; if ((Object)(object)playerHeldBy == (Object)null || !LethalBotManager.Instance.IsPlayerLethalBot(playerHeldBy)) { return true; } __instance.playerHeldBy.IsInspectingItem = false; __instance.playerHeldBy.activatingItem = false; __instance.playerHeldBy = null; return false; } [HarmonyPatch("SetScrapValue")] [HarmonyPrefix] private static bool SetScrapValue_PreFix(GrabbableObject __instance, int setValueTo) { RagdollGrabbableObject val = (RagdollGrabbableObject)(object)((__instance is RagdollGrabbableObject) ? __instance : null); if ((Object)(object)val == (Object)null) { return true; } LethalBotAI lethalBotAI = LethalBotManager.Instance.GetLethalBotAI(val.bodyID.Value); if ((Object)(object)lethalBotAI == (Object)null) { if ((Object)(object)((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>() == (Object)null) { __instance.scrapValue = setValueTo; return false; } return true; } if (lethalBotAI.NpcController.Npc.isPlayerDead && (Object)(object)((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>() == (Object)null) { if ((Object)(object)((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>() == (Object)null) { __instance.scrapValue = setValueTo; return false; } return true; } return false; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPriority(0)] [HarmonyPatch("Update")] public static void GrabbableObject_Update_ReversePatch(RagdollGrabbableObject instance) { throw new NotImplementedException("Stub LethalBot.Patches.NpcPatches.GrabbableObjectPatch.GrabbableObject_Update_ReversePatch"); } [HarmonyPatch("EquipItem")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> EquipItem_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count - 3; i++) { if (((object)list[i]).ToString() == "call static HUDManager HUDManager::get_Instance()" && ((object)list[i + 1]).ToString() == "callvirt void HUDManager::ClearControlTips()" && ((object)list[i + 3]).ToString() == "callvirt virtual void GrabbableObject::SetControlTipsForItem()") { num = i; break; } } if (num > -1) { List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)PatchesUtil.IsAnLethalBotAiOwnerOfObjectMethod), new CodeInstruction(OpCodes.Brtrue_S, (object)list[num + 4].labels[0]) }; list.InsertRange(num, collection); num = -1; } else { Plugin.LogError("LethalBot.Patches.ObjectsPatches.EquipItem_Transpiler could not remove check if holding player is bot"); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(RagdollGrabbableObject))] public class RagdollGrabbableObjectPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix(RagdollGrabbableObject __instance) { LethalBotManager.Instance.GrabbableObjectSpawned((GrabbableObject)(object)__instance); } [HarmonyPatch("Update")] [HarmonyPrefix] private static bool Update_PreFix(RagdollGrabbableObject __instance, ref bool ___foundRagdollObject) { int value = __instance.bodyID.Value; if (value == -2) { if ((Object)(object)__instance.ragdoll == (Object)null) { return false; } ___foundRagdollObject = true; ((GrabbableObject)__instance).grabbableToEnemies = false; return true; } if (___foundRagdollObject && (Object)(object)StartOfRound.Instance.allPlayerScripts[value].deadBody != (Object)null && (Object)(object)__instance.ragdoll != (Object)null && value != (int)__instance.ragdoll.playerScript.playerClientId) { ___foundRagdollObject = false; } return true; } [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update_PostFix(RagdollGrabbableObject __instance) { if (__instance.bodyID.Value == -2) { ((GrabbableObject)__instance).grabbableToEnemies = false; } } } [HarmonyPatch(typeof(ShotgunItem))] public class ShotgunItemPatch { [HarmonyPatch("ShootGunAndSync")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ShootGunAndSync_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { bool flag = false; int num = 0; List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(GameNetworkManager), "Instance"); FieldInfo fieldInfo = AccessTools.Field(typeof(GameNetworkManager), "localPlayerController"); FieldInfo operand = AccessTools.Field(typeof(ShotgunItem), "previousPlayerHeldBy"); Plugin.LogDebug("Beginning to patch ShotgunItem.ShootGunAndSync!"); for (int i = 0; i < list.Count - 1; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo) && CodeInstructionExtensions.LoadsField(list[i + 1], fieldInfo, false)) { Plugin.LogDebug($"Patching localPlayerController at index {i}..."); Plugin.LogDebug($"Original Codes: 1: {list[i]} and 2: {list[i + 1]}"); list[i].opcode = OpCodes.Ldarg_0; list[i].operand = null; list[i + 1].opcode = OpCodes.Ldfld; list[i + 1].operand = operand; flag = true; num++; } } if (!flag) { Plugin.LogError("LethalBot.Patches.ObjectPatches.ShotgunItem.ShootGunAndSync_Transpiler could not check if player local or bot local 1"); } else { Plugin.LogDebug($"Patched out localPlayerController {num} times!"); } return list.AsEnumerable(); } [HarmonyPatch("ShootGun")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ShootGun_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(GameNetworkManager), "Instance"); FieldInfo fieldInfo = AccessTools.Field(typeof(GameNetworkManager), "localPlayerController"); MethodInfo methodInfo2 = AccessTools.Method(typeof(Object), "op_Equality", (Type[])null, (Type[])null); FieldInfo fieldInfo2 = AccessTools.Field(typeof(GrabbableObject), "playerHeldBy"); Plugin.LogDebug("Beginning to patch ShotgunItem.ShootGun!"); for (int i = 0; i < list.Count - 2; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo) && CodeInstructionExtensions.LoadsField(list[i + 1], fieldInfo, false) && CodeInstructionExtensions.Calls(list[i + 2], methodInfo2)) { Plugin.LogDebug($"Patching localPlayerController comparison at index {i}..."); Plugin.LogDebug($"Original Codes: 1: {list[i]}, 2: {list[i + 1]}, 3: {list[i + 2]}"); num = i; break; } } if (num != -1) { list.RemoveRange(num, 3); list.Insert(num, new CodeInstruction(OpCodes.Call, (object)PatchesUtil.IsPlayerLocalOrLethalBotOwnerLocalMethod)); num = -1; } else { Plugin.LogError("LethalBot.Patches.ObjectPatches.ShotgunItem.ShootGun_Transpiler could not find the localPlayerController reference!"); } for (int j = 0; j < list.Count - 1; j++) { if (list[j].opcode == OpCodes.Ldc_I4_1 && list[j + 1].opcode == OpCodes.Stloc_0) { Plugin.LogDebug($"Patching flag assignment at index {j}..."); Plugin.LogDebug($"Original Codes: 1: {list[j]} and 2: {list[j + 1]}"); num = j; break; } } if (num != -1) { CodeInstruction item = list[num + 1]; List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo2), new CodeInstruction(OpCodes.Call, (object)PatchesUtil.IsPlayerLocalMethod), item }; list.RemoveRange(num, 2); list.InsertRange(num, collection); } else { Plugin.LogError("LethalBot.Patches.ObjectPatches.ShotgunItem.ShootGun_Transpiler could not change the flag!"); } Plugin.LogDebug("Finished patching ShotgunItem.ShootGun!"); return list.AsEnumerable(); } [HarmonyPatch("SetControlTipsForItem")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool SetControlTipsForItem_PreFix(ShotgunItem __instance) { return !LethalBotManager.Instance.IsAnLethalBotAiOwnerOfObject((GrabbableObject)(object)__instance); } [HarmonyPatch("SetSafetyControlTip")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool SetSafetyControlTip_PreFix(ShotgunItem __instance) { return !LethalBotManager.Instance.IsAnLethalBotAiOwnerOfObject((GrabbableObject)(object)__instance); } [HarmonyPatch("ShootGun")] [HarmonyPostfix] private static void ShootGun_PostFix(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < LethalBotManager.Instance.AllEntitiesCount; i++) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i]; if (val.isPlayerDead || !val.isPlayerControlled) { continue; } LethalBotAI lethalBotAIIfLocalIsOwner = LethalBotManager.Instance.GetLethalBotAIIfLocalIsOwner(val); if ((Object)(object)lethalBotAIIfLocalIsOwner == (Object)null || (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)val) { continue; } int num = 0; Vector3 val2 = ((Component)val).transform.position + new Vector3(0f, 1f, 0f); float num2 = Vector3.Distance(val2, ((Component)__instance.shotgunRayPoint).transform.position); Vector3 val3 = val2; if (Vector3.Angle(shotgunForward, val3 - shotgunPosition) < 30f && !Physics.Linecast(shotgunPosition, val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { if (num2 < 5f) { num = 100; } if (num2 < 15f) { num = 100; } else if (num2 < 23f) { num = 40; } else if (num2 < 30f) { num = 20; } val.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, __instance.shotgunRayPoint.forward * 30f); } } } } [HarmonyPatch(typeof(StunGrenadeItem))] public class StunGrenadeItemPatch { [HarmonyPatch("SetControlTipForGrenade")] [HarmonyPrefix] private static bool SetControlTipForGrenade_PreFix(StunGrenadeItem __instance) { if (LethalBotManager.Instance.IsAnLethalBotAiOwnerOfObject((GrabbableObject)(object)__instance)) { return false; } return true; } [HarmonyPatch("StunExplosion")] [HarmonyPostfix] private static void StunExplosion_PostFix(Vector3 explosionPosition, bool isHeldItem, PlayerControllerB playerHeldBy) { } } [HarmonyPatch(typeof(TetraChemicalItem))] public class TetraChemicalItemPatch { [HarmonyPatch("Update")] [HarmonyPostfix] public static void Update_Postfix(TetraChemicalItem __instance, ref bool ___emittingGas, ref PlayerControllerB ___previousPlayerHeldBy) { if (___emittingGas && ((NetworkBehaviour)___previousPlayerHeldBy).IsOwner && ___previousPlayerHeldBy.isPlayerControlled && LethalBotManager.Instance.IsPlayerLethalBot(___previousPlayerHeldBy) && (__instance.localHelmetSFX.isPlaying || !__instance.thisAudioSource.isPlaying)) { __instance.localHelmetSFX.Stop(); __instance.thisAudioSource.clip = __instance.releaseGasSFX; __instance.thisAudioSource.Play(); __instance.thisAudioSource.PlayOneShot(__instance.twistCanSFX); } } } } namespace LethalBots.Patches.NpcPatches { [HarmonyPatch(typeof(EnemyAICollisionDetect))] public class EnemyAICollisionDetectPatch { [HarmonyPatch("OnTriggerStay")] [HarmonyPrefix] private static void Prefix(EnemyAICollisionDetect __instance, Collider other) { if (__instance.mainScript is LethalBotAI) { PlayerControllerB componentInParent = ((Component)other).gameObject.GetComponentInParent<PlayerControllerB>(); if ((Object)(object)componentInParent != (Object)null) { Physics.IgnoreCollision(((Component)__instance).GetComponent<Collider>(), other); } } } } [HarmonyPatch(typeof(EnemyAI))] public class EnemyAIPatch { [HarmonyPatch("ChangeOwnershipOfEnemy")] [HarmonyPrefix] private static bool ChangeOwnershipOfEnemy_PreFix(ref ulong newOwnerClientId) { Plugin.LogDebug($"[PREFIX]: Try ChangeOwnershipOfEnemy newOwnerClientId : {(int)newOwnerClientId}"); if (newOwnerClientId > 200000) { LethalBotAI lethalBotAI = LethalBotManager.Instance.GetLethalBotAI((int)(newOwnerClientId - 200000)); if ((Object)(object)lethalBotAI == (Object)null) { Plugin.LogDebug($"Could not find lethalBot with id : {(int)(newOwnerClientId - 200000)}, aborting ChangeOwnershipOfEnemy."); return false; } Plugin.LogDebug($"ChangeOwnershipOfEnemy not on lethalBot but on lethalBot owner : {((NetworkBehaviour)lethalBotAI).OwnerClientId}"); newOwnerClientId = ((NetworkBehaviour)lethalBotAI).OwnerClientId; } return true; } [HarmonyPatch("ChangeOwnershipOfEnemy")] [HarmonyPostfix] private static void ChangeOwnershipOfEnemy_PostFix(EnemyAI __instance, ulong newOwnerClientId) { LethalBotAI lethalBotAI = __instance as LethalBotAI; if ((Object)(object)lethalBotAI != (Object)null) { Plugin.LogDebug($"[POSTFIX]: Try ChangeOwnershipOfEnemy for lethalBot newOwnerClientId : {(int)newOwnerClientId}"); lethalBotAI.ChangeOwnershipOfBotInventoryServerRpc(newOwnerClientId); } } [HarmonyPatch("HitEnemyOnLocalClient")] [HarmonyPrefix] private static bool HitEnemyOnLocalClient(EnemyAI __instance) { if (__instance is LethalBotAI) { return false; } return true; } [HarmonyPatch("MeetsStandardPlayerCollisionConditions")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> MeetsStandardPlayerCollisionConditions_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count - 8; i++) { if (list[i].opcode == OpCodes.Brtrue && list[i + 1].opcode == OpCodes.Ldloc_0 && list[i + 2].opcode == OpCodes.Call && list[i + 3].opcode == OpCodes.Ldfld && list[i + 4].opcode == OpCodes.Call && list[i + 8].opcode == OpCodes.Ldarg_0) { num = i; break; } } if (num > -1) { List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Call, (object)PatchesUtil.IsColliderFromLocalOrLethalBotOwnerLocalMethod), new CodeInstruction(OpCodes.Brtrue_S, (object)list[num + 8].labels.First()) }; list.InsertRange(num + 1, collection); } else { Plugin.LogError("LethalBot.Patches.NpcPatches.EnemyAIPatch.MeetsStandardPlayerCollisionConditions_Transpiler could not insert instruction if is lethalBot for \"component != GameNetworkManager.Instance.localPlayerController\"."); } return list.AsEnumerable(); } [HarmonyPatch("CheckLineOfSightForPlayer")] [HarmonyPostfix] private static void CheckLineOfSightForPlayer_PostFix(EnemyAI __instance, ref PlayerControllerB __result, float width, ref int range, int proximityAwareness) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; if (__instance.isOutside && !__instance.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3) { range = Mathf.Clamp(range, 0, 30); } for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[i]; if (!__instance.PlayerIsTargetable(val2, false, false) || !LethalBotManager.Instance.IsPlayerLethalBot(val2)) { continue; } Vector3 position = ((Component)val2.gameplayCamera).transform.position; if (Vector3.Distance(position, __instance.eye.position) < (float)range && !Physics.Linecast(__instance.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) { Vector3 val3 = position - __instance.eye.position; if (Vector3.Angle(__instance.eye.forward, val3) < width || (proximityAwareness != -1 && Vector3.Distance(__instance.eye.position, position) < (float)proximityAwareness)) { val = val2; } } } if ((Object)(object)__result == (Object)null && (Object)(object)val == (Object)null) { return; } if ((Object)(object)__result == (Object)null && (Object)(object)val != (Object)null) { Plugin.LogDebug("bot found, no player found"); __result = val; } else if ((Object)(object)__result != (Object)null && (Object)(object)val == (Object)null) { Plugin.LogDebug("bot not found, player found"); } else if (!((Object)(object)__result == (Object)null) && !((Object)(object)val == (Object)null)) { Vector3 position2 = ((Component)__result.gameplayCamera).transform.position; Vector3 position3 = ((Component)val.gameplayCamera).transform.position; Vector3 val4 = (((Object)(object)__instance.eye == (Object)null) ? ((Component)__instance).transform.position : __instance.eye.position); Vector3 val5 = position3 - val4; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; val5 = position2 - val4; if (sqrMagnitude < ((Vector3)(ref val5)).sqrMagnitude) { Plugin.LogDebug("lethalBot closer"); __result = val; } else { Plugin.LogDebug("player closer"); } } } [HarmonyPatch("TargetClosestPlayer")] [HarmonyPostfix] private static void TargetClosestPlayer_PostFix(EnemyAI __instance, ref bool __result, float bufferDistance, bool requireLineOfSight, float viewWidth) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0067: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB targetPlayer = __instance.targetPlayer; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i]; if (LethalBotManager.Instance.IsPlayerLethalBot(val) && !((Object)(object)targetPlayer == (Object)(object)val) && __instance.PlayerIsTargetable(val, false, false) && !__instance.PathIsIntersectedByLineOfSight(((Component)val).transform.position, false, false, false) && (!requireLineOfSight || __instance.CheckLineOfSightForPosition(((Component)val.gameplayCamera).transform.position, viewWidth, 40, -1f, (Transform)null))) { __instance.tempDist = Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position); if (__instance.tempDist < __instance.mostOptimalDistance) { __instance.mostOptimalDistance = __instance.tempDist; __instance.targetPlayer = val; } } } if ((Object)(object)__instance.targetPlayer != (Object)null && bufferDistance > 0f && (Object)(object)targetPlayer != (Object)null && Mathf.Abs(__instance.mostOptimalDistance - Vector3.Distance(((Component)__instance).transform.position, ((Component)targetPlayer).transform.position)) < bufferDistance) { __instance.targetPlayer = targetPlayer; } __result = (Object)(object)__instance.targetPlayer != (Object)null; } } [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyAfter(new string[] { "MoreEmotes" })] [HarmonyPrefix] private static bool Update_PreFix(PlayerControllerB __instance, ref bool ___isCameraDisabled, bool ___isJumping, bool ___isFallingFromJump, ref float ___crouchMeter, ref bool ___isWalking, ref float ___playerSlidingTimer, ref bool ___disabledJetpackControlsThisFrame, ref bool ___startedJetpackControls, ref float ___upperBodyAnimationsWeight, ref float ___timeSinceSwitchingSlots, ref float ___timeSinceTakingGravityDamage, ref bool ___teleportingThisFrame, ref float ___previousFrameDeltaTime, ref float ___cameraUp, ref float ___updatePlayerLookInterval, ref float ___bloodDropTimer) { LethalBotAI lethalBotAI = LethalBotManager.Instance.GetLethalBotAI(__instance); if ((Object)(object)lethalBotAI == (Object)null) { return true; } lethalBotAI.NpcController.IsCameraDisabled = ___isCameraDisabled; lethalBotAI.NpcController.IsJumping = ___isJumping; lethalBotAI.NpcController.IsFallingFromJump = ___isFallingFromJump; lethalBotAI.NpcController.CrouchMeter = ___crouchMeter; lethalBotAI.NpcController.IsWalking = ___isWalking; lethalBotAI.NpcController.PlayerSlidingTimer = ___playerSlidingTimer; lethalBotAI.NpcController.DisabledJetpackControlsThisFrame = ___disabledJetpackControlsThisFrame; lethalBotAI.NpcController.StartedJetpackControls = ___startedJetpackControls; lethalBotAI.NpcController.UpperBodyAnimationsWeight = ___upperBodyAnimationsWeight; lethalBotAI.NpcController.TimeSinceSwitchingSlots = ___timeSinceSwitchingSlots; lethalBotAI.NpcController.TimeSinceTakingGravityDamage = ___timeSinceTakingGravityDamage; lethalBotAI.NpcController.TeleportingThisFrame = ___teleportingThisFrame; lethalBotAI.NpcController.PreviousFrameDeltaTime = ___previousFrameDeltaTime; lethalBotAI.NpcController.CameraUp = ___cameraUp; lethalBotAI.NpcController.UpdatePlayerLookInterval = ___updatePlayerLookInterval; lethalBotAI.NpcController.BloodDropTimer = ___bloodDropTimer; lethalBotAI.UpdateController(); ___isCameraDisabled = lethalBotAI.NpcController.IsCameraDisabled; ___crouchMeter = lethalBotAI.NpcController.CrouchMeter; ___isWalking = lethalBotAI.NpcController.IsWalking; ___playerSlidingTimer = lethalBotAI.NpcController.PlayerSlidingTimer; ___startedJetpackControls = lethalBotAI.NpcController.StartedJetpackControls; ___upperBodyAnimationsWeight = lethalBotAI.NpcController.UpperBodyAnimationsWeight; ___timeSinceSwitchingSlots = lethalBotAI.NpcController.TimeSinceSwitchingSlots; ___timeSinceTakingGravityDamage = lethalBotAI.NpcController.TimeSinceTakingGravityDamage; ___teleportingThisFrame = lethalBotAI.NpcController.TeleportingThisFrame; ___previousFrameDeltaTime = lethalBotAI.NpcController.PreviousFrameDeltaTime; ___cameraUp = lethalBotAI.NpcController.CameraUp; ___updatePlayerLookInterval = lethalBotAI.NpcController.UpdatePlayerLookInterval; ___bloodDropTimer = leth