Please disclose if your mod was created primarily 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 Lethal Doors Fixed v1.2.1
Lethal_Doors.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using LethalDoors; using Lethal_Doors.Config; using Lethal_Doors.Patches; using Microsoft.CodeAnalysis; using UnityEngine; [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 = ".NET Standard 2.1")] [assembly: AssemblyCompany("Lethal_Doors")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Lethal_Doors")] [assembly: AssemblyTitle("Lethal_Doors")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalDoors { [BepInPlugin("Entity378.LethalDoorsFixed", "Lethal Doors Fixed", "1.2.0")] public class Plugin : BaseUnityPlugin { private const string GUID = "Entity378.LethalDoorsFixed"; private const string NAME = "Lethal Doors Fixed"; private const string VERSION = "1.2.0"; private readonly Harmony harmony = new Harmony("Entity378.LethalDoorsFixed"); public static List<string> Blacklist; public static bool Players; public static bool Enemies; public static Plugin Instance { get; private set; } public static Config cfg { get; private set; } private void Awake() { cfg = new Config(((BaseUnityPlugin)this).Config); cfg.BindConfig(); Players = cfg.PLAYERS; Enemies = cfg.ENEMIES; Blacklist = cfg.BLACKLISTED.Split(',').ToList(); if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(typeof(DoorInteractionPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Lethal Doors Fixed Loaded"); } } } namespace Lethal_Doors { public static class PluginInfo { public const string PLUGIN_GUID = "Lethal_Doors"; public const string PLUGIN_NAME = "Lethal_Doors"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Lethal_Doors.Patches { [HarmonyPatch(typeof(HangarShipDoor))] internal class DoorInteractionPatch { private static readonly Vector3 doorPosition = new Vector3(-5.72f, 1.305f, -14.1f); private static float doorClosingTimer = -1f; private static readonly float doorClosingDuration = 0.3f; [HarmonyPostfix] [HarmonyPatch("Update")] private static void PostfixUpdate(HangarShipDoor __instance) { if (StartOfRound.Instance.shipIsLeaving || !StartOfRound.Instance.shipHasLanded) { return; } if (IsDoorClosing(__instance)) { if (doorClosingTimer < 0f) { doorClosingTimer = 0f; } if (doorClosingTimer < doorClosingDuration && IsDoorClosed(__instance.shipDoorsAnimator)) { if (Plugin.Players) { CheckForPlayersAndApplyDamage(); } if (Plugin.Enemies) { CheckForEnemiesAndApplyDamage(); } } doorClosingTimer += Time.deltaTime; } else { doorClosingTimer = -1f; } } private static bool IsDoorClosing(HangarShipDoor door) { return door.doorPower < 1f; } private static void CheckForPlayersAndApplyDamage() { if (!((Object)(object)StartOfRound.Instance != (Object)null) || StartOfRound.Instance.allPlayerScripts == null) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && IsPlayerInDangerZone(val)) { Debug.Log((object)("[Lethal Doors Fixed] Player " + val.playerUsername + " is in danger zone")); ApplyLethalDamageOrInjurePlayer(val); Debug.Log((object)"[Lethal Doors Fixed] Added to affected list added"); } } } private static bool IsPlayerInDangerZone(PlayerControllerB player) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) float num = 1f; float num2 = 1.25f; float num3 = 1.25f; float x = ((Component)player).transform.position.x; float y = ((Component)player).transform.position.y; float z = ((Component)player).transform.position.z; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(x, 1.305f, -14.1f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(-5.72f, y, -14.1f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(-5.72f, 1.305f, z); float num4 = Vector3.Distance(val, doorPosition); float num5 = Vector3.Distance(val2, doorPosition); float num6 = Vector3.Distance(val3, doorPosition); if (num4 < num && num5 < num2 && num6 < num3) { return true; } return false; } private static bool IsEnemyInDangerZone(EnemyAI enemy) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) float num = 3f; float num2 = 2.25f; float num3 = 2.25f; float x = ((Component)enemy).transform.position.x; float y = ((Component)enemy).transform.position.y; float z = ((Component)enemy).transform.position.z; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(x, 1.305f, -14.1f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(-5.72f, y, -14.1f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(-5.72f, 1.305f, z); float num4 = Vector3.Distance(val, doorPosition); float num5 = Vector3.Distance(val2, doorPosition); float num6 = Vector3.Distance(val3, doorPosition); if (num4 < num && num5 < num2 && num6 < num3) { return true; } return false; } private static void ApplyLethalDamageOrInjurePlayer(PlayerControllerB player) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"[Lethal Doors Fixed] {player.playerUsername} in danger zone, Position:{((Component)player).transform.position} "); Debug.Log((object)("[Lethal Doors Fixed] Applying lethal damange to player " + player.playerUsername)); if (player.criticallyInjured) { player.DamagePlayer(110, true, true, (CauseOfDeath)8, 0, false, default(Vector3)); Debug.Log((object)$"[Lethal Doors Fixed] Heads: kill player ClientID:{(int)player.playerClientId} "); return; } Debug.Log((object)$"[Lethal Doors Fixed] Tails: injure player ClientID:{(int)player.playerClientId} "); player.DamagePlayer(90, true, true, (CauseOfDeath)8, 0, false, default(Vector3)); player.AddBloodToBody(); player.MakeCriticallyInjured(true); } private static bool IsDoorClosed(Animator animator) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("ShipDoorClose"); } private static void CheckForEnemiesAndApplyDamage() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) List<EnemyAI> list = new List<EnemyAI>(); Debug.Log((object)"[Lethal Doors Fixed] Checking for enemies to apply damage"); RoundManager val = Object.FindObjectOfType<RoundManager>(); if (!((Object)(object)val != (Object)null) || val.SpawnedEnemies == null) { return; } foreach (EnemyAI spawnedEnemy in val.SpawnedEnemies) { if ((Object)(object)spawnedEnemy != (Object)null && !Plugin.Blacklist.Contains(spawnedEnemy.enemyType.enemyName) && IsEnemyInDangerZone(spawnedEnemy) && !spawnedEnemy.isEnemyDead && !list.Contains(spawnedEnemy)) { Debug.Log((object)$"[Lethal Doors Fixed] {((Object)spawnedEnemy).name} is in danger zone at position {((Component)spawnedEnemy).transform.position}"); ((Component)spawnedEnemy).GetComponent<EnemyAI>().HitEnemyOnLocalClient(9999, new Vector3(0f, 0f, 0f), (PlayerControllerB)null, false, -1); list.Add(spawnedEnemy); if (spawnedEnemy.isEnemyDead) { Debug.Log((object)("[Lethal Doors Fixed] " + ((Object)spawnedEnemy).name + " killed")); } } } list.Clear(); } } } namespace Lethal_Doors.Config { public class Config { public ConfigFile configFile; public bool PLAYERS { get; set; } public bool ENEMIES { get; set; } public string BLACKLISTED { get; set; } public Config(ConfigFile cfg) { configFile = cfg; } private T ConfigEntry<T>(string section, string key, T defaultVal, string description) { return configFile.Bind<T>(section, key, defaultVal, description).Value; } public void BindConfig() { PLAYERS = ConfigEntry("General", "Players", defaultVal: true, "the doors will do damage to players"); ENEMIES = ConfigEntry("General", "Enemies", defaultVal: true, "the doors will do damage to enemies"); BLACKLISTED = ConfigEntry("Blacklist", "Blacklist", "", "The mod will ignore entities in this list \nExemple: itemName1,itemName2,itemName3,"); } } }