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 LethalComFunny v1.1.0
LethalComFunny/LethalComFunny.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CreditedCompany; using GameNetcodeStuff; using HarmonyLib; using LC_API.Networking; using LC_API.Networking.Serializers; using LethalSettings.UI; using LethalSettings.UI.Components; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("LethalComFunny")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A funny mod for lethal company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+aadbf26692c41a7dd42c09c92d43ec935a70315c")] [assembly: AssemblyProduct("LethalComFunny")] [assembly: AssemblyTitle("LethalComFunny")] [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.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 LethalComFunny { [BepInPlugin("LethalComFunny", "LethalComFunny", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("LethalComFunny"); public static Plugin instance; private static InputAction action = new InputAction((string)null, (InputActionType)0, "<Keyboard>/y", (string)null, (string)null, (string)null); private static InputAction menuAction = new InputAction((string)null, (InputActionType)0, "<Keyboard>/u", (string)null, (string)null, (string)null); private static bool allowDeadSpawns = false; private static bool menuOpen = false; internal static ManualLogSource Logger; public static List<Landmine> mines = new List<Landmine>(); public static AssetBundle assets; private static Dictionary<ulong, GameObject> joinedPlayersUI = new Dictionary<ulong, GameObject>(); private static GameObject playerTogglesContainer = GameObject.Find("Systems/UI/Canvas/LethalComFunny"); private static StartOfRound gameInstance => StartOfRound.Instance; private static SelectableLevel currentLevel => gameInstance.currentLevel; public static MConfig LCFConfig { get; internal set; } private void Awake() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) //IL_011f: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; if ((Object)(object)instance == (Object)null) { instance = this; } action.performed += delegate { queueSpawnMine(); }; action.Enable(); menuAction.performed += delegate { toggleMenu(); }; menuAction.Enable(); Network.RegisterAll(); LCFConfig = new MConfig(((BaseUnityPlugin)this).Config); ModSettingsConfig val = new ModSettingsConfig(); val.Name = "Lethal ComFunny"; val.Id = "LethalComFunny"; val.Version = "1.0.1"; val.Description = "Become a funny asset to the company"; val.MenuComponents = (MenuComponent[])(object)new MenuComponent[2] { (MenuComponent)new ToggleComponent { Text = "Allow dead players to spawn mines?", OnValueChanged = delegate(ToggleComponent self, bool value) { MConfig.configDeadSpawns.Value = value; if ((Object)(object)gameInstance != (Object)null && ((NetworkBehaviour)gameInstance).IsHost) { SyncConfig(); } }, Value = MConfig.configDeadSpawns.Value }, (MenuComponent)new ToggleComponent { Text = "Allow other (non-host) players to spawn mines?", OnValueChanged = delegate(ToggleComponent self, bool value) { MConfig.configHostOnly.Value = !value; }, Value = !MConfig.configHostOnly.Value } }; ModMenu.RegisterMod(val, true, true); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string name = "LethalComFunny.Assets.lethalcomfunny"; Assembly executingAssembly = Assembly.GetExecutingAssembly(); using (Stream stream = executingAssembly.GetManifestResourceStream(name)) { if (stream != null) { assets = AssetBundle.LoadFromStream(stream); } else { Debug.LogError((object)"Embedded resource not found."); } } if ((Object)(object)assets == (Object)null) { Logger.LogError((object)"Failed to load custom assets."); return; } Plugin.credits.Add("Orangenal - Lethal ComFunny"); harmony.PatchAll(typeof(Plugin)); Logger.LogInfo((object)"Plugin LethalComFunny is loaded!"); } [HarmonyPatch(typeof(Landmine), "Detonate")] [HarmonyPostfix] private static void disableHitboxAfterExplosion(ref Landmine __instance) { ((MonoBehaviour)gameInstance).StartCoroutine(DestroyOnDelay(5f, __instance)); } [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void byebyeMines() { foreach (Landmine mine in mines) { Object.Destroy((Object)(object)((Component)((Component)mine).gameObject.transform.parent).gameObject); } mines = new List<Landmine>(); } [NetworkMessage("LethalCumFunnyMineDespawn", false)] public static void SpawnHandler(ulong sender, Landmine mine) { if (((NetworkBehaviour)gameInstance).IsHost) { ((Component)mine).GetComponent<NetworkObject>().Despawn(true); } } private static IEnumerator DestroyOnDelay(float delay, Landmine mine) { mines.Remove(mine); ((Component)mine).gameObject.transform.Find("BlastMark").parent = null; yield return (object)new WaitForSeconds(delay); if (((NetworkBehaviour)gameInstance).IsHost) { Object.Destroy((Object)(object)((Component)((Component)mine).gameObject.transform.parent).gameObject); } } private static void queueSpawnMine() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) if (gameInstance.localPlayerController.isPlayerDead && !allowDeadSpawns) { return; } Camera activeCamera = gameInstance.activeCamera; Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)activeCamera).transform.position, ((Component)activeCamera).transform.forward); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 20f, 268437761)) { Vector3 point = ((RaycastHit)(ref val2)).point; if (((NetworkBehaviour)gameInstance).IsHost) { spawnMine(point, 0uL); return; } Network.Broadcast<Vector3SClass>("LethalCumFunnyMineSpawn", new Vector3SClass { pos = Vector3S.op_Implicit(point) }); } } [NetworkMessage("LethalCumFunnyMineSpawn", false)] public static void SpawnHandler(ulong sender, Vector3SClass message) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)gameInstance).IsHost && !MConfig.configHostOnly.Value) { Vector3S pos = message.pos; spawnMine(((Vector3S)(ref pos)).vector3, sender); } } public static void spawnMine(Vector3 pos, ulong sender = 0uL) { //IL_0073: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)joinedPlayersUI[sender] != (Object)null && !joinedPlayersUI[sender].GetComponent<Toggle>().isOn) { return; } SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects; foreach (SpawnableMapObject val in spawnableMapObjects) { if (!((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() == (Object)null)) { GameObject val2 = Object.Instantiate<GameObject>(val.prefabToSpawn, pos, Quaternion.identity); val2.transform.position = pos; val2.transform.forward = new Vector3(1f, 0f, 0f); val2.GetComponent<NetworkObject>().Spawn(true); mines.Add(val2.GetComponentInChildren<Landmine>()); break; } } } public void toggleMenu() { if (!((NetworkBehaviour)gameInstance).IsHost || gameInstance.allPlayerScripts.Length == 1 || MConfig.configHostOnly.Value) { return; } PlayerControllerB localPlayerController = gameInstance.localPlayerController; if (!((Object)(object)localPlayerController == (Object)null)) { if (menuOpen) { menuOpen = false; Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } else { menuOpen = true; Cursor.lockState = (CursorLockMode)0; } localPlayerController.quickMenuManager.isMenuOpen = menuOpen; playerTogglesContainer.SetActive(menuOpen); } } public static void SyncConfig() { ((MonoBehaviour)gameInstance).StartCoroutine(SendConfigOnDelay(5f)); } [HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientConnectedCallback")] [HarmonyPostfix] public static void OnPlayerJoin(ref ulong clientId) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (((NetworkBehaviour)gameInstance).IsHost) { SyncConfig(); GameObject val = Object.Instantiate<GameObject>(assets.LoadAsset<GameObject>("Assets/AllowSpawningToggle.prefab")); GameObject val2 = GameObject.Find("Systems/UI/Canvas/"); if ((Object)(object)playerTogglesContainer == (Object)null) { playerTogglesContainer = new GameObject("LethalComFunny"); playerTogglesContainer.transform.SetParent(val2.transform, false); playerTogglesContainer.SetActive(menuOpen); } val.transform.SetParent(playerTogglesContainer.transform, false); RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).position = ((Transform)component).position + new Vector3(0f, 0.05f * (float)joinedPlayersUI.Count, 0f); string playerUsername = StartOfRound.Instance.allPlayerScripts[clientId].playerUsername; val.GetComponentInChildren<Text>().text = playerUsername; joinedPlayersUI.Add(clientId, val); } } [HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientDisconnectCallback")] [HarmonyPostfix] public static void OnPlayerLeave() { } private static IEnumerator SendConfigOnDelay(float delay) { yield return (object)new WaitForSeconds(delay); Logger.LogInfo((object)("Telling clients to set configDeadSpawns to " + MConfig.configDeadSpawns.Value)); Network.Broadcast<ConfigWrapper>("LethalCumFunnySendConfig", new ConfigWrapper { Value = MConfig.configDeadSpawns.Value }); allowDeadSpawns = MConfig.configDeadSpawns.Value; } [NetworkMessage("LethalCumFunnySendConfig", false)] public static void ConfigReceiver(ulong sender, ConfigWrapper configDeadSpawns) { Logger.LogInfo((object)("Setting allowDeadSpawns to " + configDeadSpawns.Value)); allowDeadSpawns = configDeadSpawns.Value; } [NetworkMessage("LethalCumFunnyRequestConfig", false)] public static void ConfigSender(ulong sender) { if (((NetworkBehaviour)gameInstance).IsHost) { Logger.LogInfo((object)("Telling clients to set configDeadSpawns to " + MConfig.configDeadSpawns.Value)); Network.Broadcast<ConfigEntry<bool>>("LethalCumFunnySendConfig", MConfig.configDeadSpawns); allowDeadSpawns = MConfig.configDeadSpawns.Value; } } } public class Vector3SClass { public Vector3S pos { get; set; } } public class ConfigWrapper { public bool Value { get; set; } } public class MConfig { public static ConfigEntry<bool> configDeadSpawns; public static ConfigEntry<bool> configHostOnly; public MConfig(ConfigFile cfg) { configDeadSpawns = cfg.Bind<bool>("General.Toggles", "AllowDeadSpawns", false, "Whether or not to allow dead players to spawn mines"); configHostOnly = cfg.Bind<bool>("General.Toggles", "OnlyHostAllowed", false, "If set to true, only the host can spawn mines"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalComFunny"; public const string PLUGIN_NAME = "LethalComFunny"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }