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 LockDoorsMod v1.0.0
BepInEx/plugins/LockDoorsMod.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Newtonsoft.Json; 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: AssemblyCompany("LockDoorsMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LockDoorsMod")] [assembly: AssemblyTitle("LockDoorsMod")] [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 LockDoorsMod { public static class Logger { public static readonly ManualLogSource logger = Logger.CreateLogSource("ENZDS.LockDoorsMod"); } [JsonObject] internal class LockDoorData { [JsonProperty] public ulong networkObjectId { get; set; } [JsonProperty] public ulong clientId { get; set; } } [HarmonyPatch(typeof(DoorLock))] public class DoorLockPatch { [CompilerGenerated] private static class <>O { public static GotStringEventDelegate <0>__CloseDoorReceived; } [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0015: 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) //IL_0020: Expected O, but got Unknown GotStringEventDelegate getString = Networking.GetString; object obj = <>O.<0>__CloseDoorReceived; if (obj == null) { GotStringEventDelegate val = CloseDoorReceived; <>O.<0>__CloseDoorReceived = val; obj = (object)val; } Networking.GetString = (GotStringEventDelegate)Delegate.Combine((Delegate?)(object)getString, (Delegate?)obj); } private static void CloseDoorReceived(string data, string signature) { LockDoorData lockDoorData = JsonConvert.DeserializeObject<LockDoorData>(data); Logger.logger.LogInfo((object)("[BROADCAST_RECEIVE] Got message \n data: " + data + " \n signature: " + signature)); if (signature == "lock_door") { GameObject val = FindObjectById(Convert.ToUInt64(lockDoorData.networkObjectId)); DoorLock componentInChildren = val.GetComponentInChildren<DoorLock>(); Logger.logger.LogInfo((object)$"[BROADCAST_RECEIVE] found object with id {lockDoorData.networkObjectId}: {val} \n {componentInChildren} \n doorLockNID: {((NetworkBehaviour)componentInChildren).NetworkObjectId}"); componentInChildren.LockDoor(30f); } } [HarmonyPatch("LockDoor")] [HarmonyPrefix] private static bool LockDoorPatch(ref DoorLock __instance, ref bool ___isDoorOpened, ref bool ___isLocked, ref AudioSource ___doorLockSFX, ref AudioClip ___unlockSFX) { if (___isDoorOpened | ___isLocked) { Logger.logger.LogInfo((object)"The door is opened or locked. Can't lock it"); return false; } ___doorLockSFX.PlayOneShot(___unlockSFX); return true; } public static void LockDoorPatchSyncWithServer(ulong networkObjectId) { LockDoorData obj = new LockDoorData { networkObjectId = networkObjectId, clientId = GameNetworkManager.Instance.localPlayerController.playerClientId }; Logger.logger.LogInfo((object)"[BROADCAST] Locking the door"); Networking.Broadcast(JsonConvert.SerializeObject((object)obj, (Formatting)0), "lock_door"); } private static GameObject FindObjectById(ulong networkId) { if (networkId != 0L) { return ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId]).gameObject; } return null; } } [HarmonyPatch(typeof(KeyItem))] internal class KeyItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static bool ItemActivatePatch(ref KeyItem __instance, bool used, bool buttonDown = true) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; bool isOwner = ((NetworkBehaviour)__instance).IsOwner; RaycastHit val = default(RaycastHit); if ((Object)(object)playerHeldBy == (Object)null || !isOwner || !Physics.Raycast(new Ray(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816)) { return false; } DoorLock component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>(); if ((Object)(object)component == (Object)null || component.isPickingLock) { return false; } if (!component.isLocked) { component.LockDoor(30f); DoorLockPatch.LockDoorPatchSyncWithServer(((NetworkBehaviour)component).NetworkObjectId); } else { component.UnlockDoorSyncWithServer(); } ((GrabbableObject)__instance).playerHeldBy.DespawnHeldObject(); return false; } } [BepInPlugin("ENZDS.LockDoorsMod", "Lock Doors Mod", "1.0.0")] public class LockingKeyModBase : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("ENZDS.LockDoorsMod"); private static LockingKeyModBase instance; private void Awake() { if (instance == null) { instance = this; } Logger.logger.LogInfo((object)"Lock Doors 1.0.0 :)"); harmony.PatchAll(); } } public static class PluginInfo { public const string PLUGIN_GUID = "ENZDS.LockDoorsMod"; public const string PLUGIN_NAME = "Lock Doors Mod"; public const string PLUGIN_VERSION = "1.0.0"; } }