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 FallingLadderKillsEnemies v1.2.0
BepInEx/plugins/FallingLadderKillsEnemies.dll
Decompiled 11 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 FallingLadderKillsEnemies { internal class LadderKillTriggerBehaviour : MonoBehaviour { private const float DangerWindowSeconds = 3.5f; private Collider _myCollider; private ExtensionLadderItem _ladderItem; private float _activationTime; private readonly Collider[] _overlapBuffer = (Collider[])(object)new Collider[16]; private void Awake() { _myCollider = ((Component)this).GetComponent<Collider>(); _activationTime = Time.time; if ((Object)(object)_myCollider == (Object)null) { Plugin.Log.LogWarning((object)("LadderKillTriggerBehaviour on '" + ((Object)this).name + "' has no Collider to check against.")); } } public void Initialize(ExtensionLadderItem ladderItem) { _ladderItem = ladderItem; _activationTime = Time.time; } private void FixedUpdate() { if (Time.time - _activationTime <= 3.5f && (Object)(object)_myCollider != (Object)null) { CheckForEnemyKills(); } } private void CheckForEnemyKills() { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = _myCollider.bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, _overlapBuffer, ((Component)this).transform.rotation, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { Collider val = _overlapBuffer[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)_myCollider)) { TryKillEnemy(val); } } } private static void TryKillEnemy(Collider other) { EnemyAI componentInParent = ((Component)other).GetComponentInParent<EnemyAI>(); if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.isEnemyDead && ((NetworkBehaviour)componentInParent).IsOwner) { Plugin.Log.LogInfo((object)("Falling ladder kill trigger caught enemy '" + ((Object)componentInParent).name + "'.")); componentInParent.KillEnemyOnOwnerClient(false); } } } internal static class LadderKillTriggerPatch { public static void Apply(Harmony harmony) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(ExtensionLadderItem), "StartLadderAnimation", (Type[])null, (Type[])null); if (methodInfo == null) { Plugin.Log.LogError((object)"Could not find ExtensionLadderItem.StartLadderAnimation on this game version. The falling-ladder enemy/player-kill feature will be disabled, but the rest of the game is unaffected."); return; } HarmonyMethod val = new HarmonyMethod(typeof(LadderKillTriggerPatch), "StartLadderAnimation_Postfix", (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Log.LogInfo((object)"Patched ExtensionLadderItem.StartLadderAnimation successfully."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to patch ExtensionLadderItem.StartLadderAnimation: {arg}"); } } private static void StartLadderAnimation_Postfix(ExtensionLadderItem __instance) { TryAttachEnemyKillTrigger(__instance); } private static void TryAttachEnemyKillTrigger(ExtensionLadderItem ladderItem) { try { if ((Object)(object)ladderItem == (Object)null) { return; } Collider killTrigger = ladderItem.killTrigger; if ((Object)(object)killTrigger == (Object)null) { Plugin.Log.LogWarning((object)("ExtensionLadderItem.killTrigger was null on '" + ((Object)ladderItem).name + "'.")); return; } LadderKillTriggerBehaviour ladderKillTriggerBehaviour = ((Component)killTrigger).GetComponent<LadderKillTriggerBehaviour>(); if ((Object)(object)ladderKillTriggerBehaviour == (Object)null) { ladderKillTriggerBehaviour = ((Component)killTrigger).gameObject.AddComponent<LadderKillTriggerBehaviour>(); Plugin.Log.LogInfo((object)("Enabled enemy/player kill detection on ladder KillTrigger for '" + ((Object)ladderItem).name + "'.")); } ladderKillTriggerBehaviour.Initialize(ladderItem); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error attaching ladder enemy-kill trigger: {arg}"); } } } [BepInPlugin("yourname.fallingladderkillsenemies", "Falling Ladder Kills Enemies", "1.2.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "yourname.fallingladderkillsenemies"; public const string PluginName = "Falling Ladder Kills Enemies"; public const string PluginVersion = "1.2.0"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { _harmony = new Harmony("yourname.fallingladderkillsenemies"); LadderKillTriggerPatch.Apply(_harmony); Log.LogInfo((object)"Falling Ladder Kills Enemies v1.2.0 loaded."); } catch (Exception arg) { Log.LogError((object)string.Format("{0} failed to initialize: {1}", "Falling Ladder Kills Enemies", arg)); } } } }