Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Volatile Employees v1.0.0
volatileEmployees.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; using volatileEmployees.NetcodePatcher; using volatileEmployees.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: AssemblyCompany("volatileEmployees")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("[]")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("volatileEmployees")] [assembly: AssemblyTitle("volatileEmployees")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: NetcodePatchedAssembly] namespace volatileEmployees { internal class Config : SyncedConfig2<Config> { [SyncedEntryField] public SyncedEntry<bool> playerImmunity; [SyncedEntryField] public SyncedEntry<bool> patchGiantKiwi; [SyncedEntryField] public SyncedEntry<bool> enemiesExplode; public Config(ConfigFile cfg) : base("cookiecaker.volatileEmployees") { //IL_0019: 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: Expected O, but got Unknown //IL_0034: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0060: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_008c: Expected O, but got Unknown playerImmunity = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition("Player", "playerImmunity"), true, new ConfigDescription("Is the player immune to explosion damage and death?", (AcceptableValueBase)null, Array.Empty<object>())); enemiesExplode = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition("Enemies", "enemiesExplode"), true, new ConfigDescription("Will most enemies explode?", (AcceptableValueBase)null, Array.Empty<object>())); patchGiantKiwi = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition("Enemies", "patchGiantKiwi"), false, new ConfigDescription("Will Giant Sapsuckers explode? (Slightly bugged)", (AcceptableValueBase)null, Array.Empty<object>())); ConfigManager.Register<Config>((SyncedConfig2<Config>)this); Plugin.mls.LogDebug((object)"Configs created!"); } } internal static class ILExtensions { internal static void Add(this List<CodeInstruction> instructions, OpCode op, object operand = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown instructions.Add(new CodeInstruction(op, operand)); } internal static void Insert(this List<CodeInstruction> instructions, int index, OpCode op, object operand = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown instructions.Insert(index, new CodeInstruction(op, operand)); } internal static void PrintCodeList(this List<CodeInstruction> codes, bool isNew) { if (isNew) { Plugin.mls.LogDebug((object)"\n\nNew codes:\n"); } else { Plugin.mls.LogDebug((object)"\n\nOld codes:\n"); } foreach (CodeInstruction code in codes) { Plugin.mls.LogDebug((object)code); } } } [BepInPlugin("cookiecaker.volatileEmployees", "Volatile_Employees", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string modGUID = "cookiecaker.volatileEmployees"; public const string modName = "Volatile_Employees"; public const string modVersion = "1.0.0"; private static Harmony _harmony = new Harmony("cookiecaker.volatileEmployees"); internal static ManualLogSource mls = Logger.CreateLogSource("cookiecaker.volatileEmployees"); internal static Config Config; private void Awake() { Config = new Config(((BaseUnityPlugin)this).Config); NetcodePatcher(); _harmony.PatchAll(typeof(NetworkPatch)); mls.LogInfo((object)"Network patch successful!"); _harmony.PatchAll(typeof(PlayerPatches)); mls.LogInfo((object)"Player patches successful!"); _harmony.PatchAll(typeof(EnemyPatches)); mls.LogInfo((object)"Enemy patches successful!"); } public static bool GetPlayerImmunity() { return Config.playerImmunity.Value; } public static bool GetEnemiesExplode() { return Config.enemiesExplode.Value; } public static bool GetPatchGiantKiwi() { return Config.patchGiantKiwi.Value; } private void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } internal class VENetworker : NetworkBehaviour { internal static GameObject prefab; internal static VENetworker Instance { get; private set; } internal static void Init() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if ((Object)(object)prefab != (Object)null) { Plugin.mls.LogDebug((object)"Network handler already initialized!"); return; } try { prefab = new GameObject("VENetworker") { hideFlags = (HideFlags)61 }; NetworkObject val = prefab.AddComponent<NetworkObject>(); byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(typeof(VENetworker).Assembly.GetName().Name + ((Object)prefab).name)); val.GlobalObjectIdHash = BitConverter.ToUInt32(value, 0); prefab.AddComponent<VENetworker>(); NetworkManager.Singleton.AddNetworkPrefab(prefab); Plugin.mls.LogDebug((object)"Successfully created VENetworker!"); } catch (Exception arg) { Plugin.mls.LogError((object)string.Format("Something went wrong!\n{0}\n{1} will not work!", arg, "Volatile_Employees")); } } internal static void Create() { try { if (NetworkManager.Singleton.IsServer && (Object)(object)prefab != (Object)null) { Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(true); } } catch (Exception arg) { Plugin.mls.LogError((object)string.Format("Something went wrong!\n{0}\n{1} will not work!", arg, "Volatile_Employees")); } } private void Awake() { Instance = this; } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)Instance != (Object)(object)this) { NetworkObject val = default(NetworkObject); if (((Component)Instance).TryGetComponent<NetworkObject>(ref val) && !val.IsSpawned && (Object)(object)Instance != (Object)(object)prefab) { Object.Destroy((Object)(object)Instance); } Plugin.mls.LogWarning((object)"2 VENetworker objects exist! Reassigning to correct instance."); Instance = this; } Plugin.mls.LogDebug((object)"Successfully spawned network object!"); } public static void SpawnExplosionEntity(NetworkObject entity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Instance.SpawnExplosionEntityRpc(NetworkObjectReference.op_Implicit(entity)); } [Rpc(/*Could not decode attribute arguments.*/)] public void SpawnExplosionEntityRpc(NetworkObjectReference entity) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1039257923u, val2, val, (SendTo)6, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkObjectReference>(ref entity, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 1039257923u, val2, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); if (((NetworkObjectReference)(ref entity)).TryGet(ref val4, (NetworkManager)null)) { Plugin.mls.LogDebug((object)$"netObj: {val4}"); EnemyAI component = ((Component)val4).GetComponent<EnemyAI>(); PlayerControllerB component2 = ((Component)val4).GetComponent<PlayerControllerB>(); Landmine.SpawnExplosion(((Object)(object)component != (Object)null) ? ((Component)component).transform.position : ((Component)component2).transform.position, true, 5.7f, 6f, 50, 2f, (GameObject)null, false); } else { Plugin.mls.LogDebug((object)"No netObj found!"); } } } public static void DespawnEnemy(NetworkObject enemy) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Instance.DespawnEnemyRpc(NetworkObjectReference.op_Implicit(enemy)); } [Rpc(/*Could not decode attribute arguments.*/)] public void DespawnEnemyRpc(NetworkObjectReference enemy) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3429199271u, val2, val, (SendTo)0, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 3429199271u, val2, val, (SendTo)0, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); if (((NetworkObjectReference)(ref enemy)).TryGet(ref val4, (NetworkManager)null)) { Plugin.mls.LogDebug((object)$"Enemy: {val4}"); val4.Despawn(true); } else { Plugin.mls.LogDebug((object)"No netObj found!"); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1039257923u, new RpcReceiveHandler(__rpc_handler_1039257923), "SpawnExplosionEntityRpc"); ((NetworkBehaviour)this).__registerRpc(3429199271u, new RpcReceiveHandler(__rpc_handler_3429199271), "DespawnEnemyRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1039257923(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference entity = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref entity, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((VENetworker)(object)target).SpawnExplosionEntityRpc(entity); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3429199271(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference enemy = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemy, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((VENetworker)(object)target).DespawnEnemyRpc(enemy); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "VENetworker"; } } public static class PluginInfo { public const string PLUGIN_GUID = "volatileEmployees"; public const string PLUGIN_NAME = "volatileEmployees"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace volatileEmployees.Patches { internal class EnemyPatches { private static MethodInfo getConfig = typeof(Plugin).GetMethod("GetEnemiesExplode"); private static MethodInfo getNetObj = typeof(NetworkBehaviour).GetProperty("NetworkObject").GetMethod; private static MethodInfo spawnExplosion = typeof(VENetworker).GetMethod("SpawnExplosionEntity"); private static MethodInfo despawnEnemy = typeof(VENetworker).GetMethod("DespawnEnemy"); [HarmonyPatch(typeof(BaboonBirdAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> BaboonBirdAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "BaboonBirdAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> BlobAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "BlobAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(BushWolfEnemy), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> BushWolfEnemy_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "BushWolfEnemy"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Brfalse)) { continue; } num3++; if (num3 != 7) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { MethodInfo method = typeof(BushWolfEnemy).GetMethod("KillEnemyOnOwnerClient"); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, method); ILExtensions.Insert(list, num, OpCodes.Ldc_I4_0); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); } Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); return list.AsEnumerable(); } [HarmonyPatch(typeof(ButlerBeesEnemyAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ButlerBeesEnemyAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "ButlerBeesEnemyAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Brfalse)) { continue; } num3++; if (num3 != 2) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(ButlerEnemyAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il) { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown string text = "ButlerEnemyAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; int num4 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); Label label3 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode.Equals(OpCodes.Beq)) { num4++; if (num4 == 2) { list[i].operand = label3; break; } } } for (int j = 0; j < list.Count; j++) { if (!list[j].opcode.Equals(OpCodes.Stfld)) { continue; } num3++; if (num3 != 3) { continue; } num = j + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int k = num; k < list.Count; k++) { if (list[k].opcode.Equals(OpCodes.Callvirt)) { num2 = k; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)getConfig); val.labels.Add(label3); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, val); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(CadaverBloomAI), "BurstForth")] [HarmonyPrefix] private static void YesBlooming() { PlayerPatches.isBlooming = true; } [HarmonyPatch(typeof(CadaverBloomAI), "BurstForth")] [HarmonyPostfix] private static void NoBlooming() { PlayerPatches.isBlooming = false; } [HarmonyPatch(typeof(CadaverBloomAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CadaverGrowthAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "CadaverBloomAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Call)) { continue; } num3++; if (num3 != 6) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j + 1; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { MethodInfo method = typeof(CadaverBloomAI).GetMethod("KillEnemyOnOwnerClient"); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, method); ILExtensions.Insert(list, num, OpCodes.Ldc_I4_0); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(CadaverGrowthAI), "OnLocalPlayerDie")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CadaverGrowthAI_DeathBloom(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "CadaverGrowthAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count - 1; i++) { list[i].opcode = OpCodes.Nop; } Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); return list.AsEnumerable(); } [HarmonyPatch(typeof(CaveDwellerAI), "KillPlayerAnimationClientRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CaveDwellerAI_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "CaveDwellerAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Brfalse)) { continue; } num3++; if (num3 != 5) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { MethodInfo method = typeof(CaveDwellerAI).GetMethod("KillEnemyOnOwnerClient"); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, method); ILExtensions.Insert(list, num, OpCodes.Ldc_I4_0); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(CentipedeAI), "DamagePlayerOnIntervals")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CentipedeAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown string text = "CentipedeAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); List<Label> list2 = new List<Label>(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode.Equals(OpCodes.Ldfld)) { num3++; } if (num3 != 8) { continue; } num = i - 1; list2.AddRange(list[num].labels); list[num].labels.Clear(); list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)getConfig); val.labels.AddRange(list2); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, val); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(ClaySurgeonAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ClaySurgeonAI_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "ClaySurgeonAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Brfalse)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Ret)) { num2 = j - 1; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CrawlerAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "CrawlerAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(GiantKiwiAI), "AnimationEventB")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> GiantKiwiAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "GiantKiwiAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num3++; if (num3 != 3) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j + 1; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { MethodInfo method = typeof(Plugin).GetMethod("GetPatchGiantKiwi"); MethodInfo method2 = typeof(GiantKiwiAI).GetMethod("KillEnemyOnOwnerClient"); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, method2); ILExtensions.Insert(list, num, OpCodes.Ldc_I4_0); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, method); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> HoarderBugAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "HoarderBugAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> JesterAI_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "JesterAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Call)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> MouthDogAI_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "MouthDogAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Bne_Un)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Call)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(NutcrackerEnemyAI), "LegKickPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> NutcrackerEnemyAI_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "NutcrackerEnemyAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stloc_1)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { MethodInfo method = typeof(NutcrackerEnemyAI).GetMethod("KillEnemyOnOwnerClient"); list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, method); ILExtensions.Insert(list, num, OpCodes.Ldc_I4_0); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PufferAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "PufferAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(PumaAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PumaAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "PumaAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num3++; if (num3 != 2) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(RadMechAI), "Stomp")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RadMechAI_DamageStomp(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "RadMechAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); list[list.Count - 1].labels.Add(label2); for (int i = 0; i < list.Count; i++) { if (list[i].opcode.Equals(OpCodes.Conv_R8)) { num = i - 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); break; } } if (num != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(RadMechAI), "BeginTorchPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RadMechAI_DamageTorch(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "RadMechAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; int num3 = 0; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Ldfld)) { continue; } num3++; if (num3 != 13) { continue; } num = i + 2; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Stfld)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(RedLocustBees), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RedLocustBees_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "RedLocustBees"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> SandSpiderAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "SandSpiderAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } [HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> SpringManAI_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "SpringManAI"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; int num2 = -1; Label label = il.DefineLabel(); Label label2 = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Stfld)) { continue; } num = i + 1; list[num].labels.Add(label); Plugin.mls.LogDebug((object)$"{text} startIndex: {num}"); for (int j = num; j < list.Count; j++) { if (list[j].opcode.Equals(OpCodes.Callvirt)) { num2 = j; list[num2 + 1].labels.Add(label2); Plugin.mls.LogDebug((object)$"{text} endIndex: {num2}"); break; } } break; } if (num != -1 && num2 != -1) { list.Insert(num, OpCodes.Br, label2); list.Insert(num, OpCodes.Call, despawnEnemy); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Call, spawnExplosion); list.Insert(num, OpCodes.Call, getNetObj); ILExtensions.Insert(list, num, OpCodes.Ldarg_0); list.Insert(num, OpCodes.Brfalse, label); list.Insert(num, OpCodes.Call, getConfig); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); } return list.AsEnumerable(); } } internal class NetworkPatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void StartOfRound_Post_Awake() { VENetworker.Create(); } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] public static void GameNetworkManager_Post_Start() { VENetworker.Init(); Plugin.mls.LogDebug((object)"Initialized VENetworker object!"); } } internal class PlayerPatches { private static MethodInfo getConfig = typeof(Plugin).GetMethod("GetPlayerImmunity"); internal static bool isBlooming = false; [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PlayerControllerB_Kill(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "PlayerControllerB.KillPlayer"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = new List<CodeInstruction>(); Label label = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode.Equals(OpCodes.Ldarg_0)) { list[i].labels.Add(label); break; } } list2.Add(OpCodes.Call, getConfig); list2.Add(OpCodes.Brfalse, label); list2.Add(OpCodes.Ldarg_S, 3); ILExtensions.Add(list2, OpCodes.Ldc_I4_3); ILExtensions.Add(list2, OpCodes.Ceq); list2.Add(OpCodes.Brfalse_S, label); ILExtensions.Add(list2, OpCodes.Ret); list2.AddRange(list); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); return list2.AsEnumerable(); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] private static void KillPlayerPatch(PlayerControllerB __instance, CauseOfDeath causeOfDeath) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).IsOwner && __instance.AllowPlayerDeath() && (int)causeOfDeath != 3 && !isBlooming) { VENetworker.Instance.SpawnExplosionEntityRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject)); } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PlayerControllerB_Damage(IEnumerable<CodeInstruction> instructions, ILGenerator il) { string text = "PlayerControllerB.DamagePlayer"; List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = new List<CodeInstruction>(); Label label = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode.Equals(OpCodes.Ldarg_0)) { list[i].labels.Add(label); break; } } list2.Add(OpCodes.Call, getConfig); list2.Add(OpCodes.Brfalse, label); list2.Add(OpCodes.Ldarg_S, 4); ILExtensions.Add(list2, OpCodes.Ldc_I4_3); ILExtensions.Add(list2, OpCodes.Ceq); list2.Add(OpCodes.Brfalse_S, label); ILExtensions.Add(list2, OpCodes.Ret); list2.AddRange(list); Plugin.mls.LogDebug((object)("Successfully patched " + text + "!")); return list2.AsEnumerable(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace volatileEmployees.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }