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 LethalShockCompany v1.0.1
plugins/LethalShockCompany/LethalCompanyShock.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyShock.Patches; using Newtonsoft.Json; using Unity.Netcode; [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: AssemblyCompany("LethalCompanyShock")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalCompanyShock")] [assembly: AssemblyTitle("LethalCompanyShock")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace LethalCompanyShock { [BepInPlugin("LethalCompanyShock", "LethalCompanyShock", "1.0.0")] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static HttpClient HttpClient = new HttpClient(); internal static ConfigEntry<string> ConfigUsername; internal static ConfigEntry<string> ConfigCode; internal static ConfigEntry<string> ConfigApiKey; internal static ConfigEntry<int> ConfigMaxIntensity; internal static ConfigEntry<bool> ConfigVibrateOnDamage; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_005f: 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_0072: Expected O, but got Unknown //IL_0072: Expected O, but got Unknown //IL_00c0: 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_00d4: Expected O, but got Unknown //IL_00d4: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.volcano.patches.LethalCompanyShock"); MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), "KillPlayer", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ManualPatches), "PreKillPlayer", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(ManualPatches), "PostKillPlayer", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo4 = AccessTools.Method(typeof(PlayerControllerB), "DamagePlayer", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(ManualPatches), "PreDamagePlayer", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(ManualPatches), "PostDamagePlayer", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo4, new HarmonyMethod(methodInfo5), new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ConfigUsername = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Username", "Username", "Username to access pi shock api with"); ConfigCode = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Code", "Code", "Share code to access pi shock api with"); ConfigApiKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ApiKey", "ApiKey", "Api key to access pi shock api with"); ConfigMaxIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxIntensity", 100, "Maximum intensity of the shock"); ConfigVibrateOnDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "VibrateOnDamage", false, "Vibrate when taking damage, in some cases this may prevent a shock when dying"); HttpClient.BaseAddress = new Uri("http://localhost:8080"); Log.LogInfo((object)"Plugin LethalCompanyShock is loaded!"); Log.LogInfo((object)"Sending test beep..."); SendPost(100, 1, 2); } public static void SendPost(int intensity, int duration, int op) { object obj = new { Username = ConfigUsername.Value, Code = ConfigCode.Value, ApiKey = ConfigApiKey.Value, Op = op, Intensity = intensity, Duration = duration }; StringContent content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); HttpClient.PostAsync("/api/apioperate", content); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LethalCompanyShock"; public const string PLUGIN_NAME = "LethalCompanyShock"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace LethalCompanyShock.Patches { public class ManualPatches { [HarmonyPrefix] public static void PreKillPlayer(PlayerControllerB __instance, ref bool __state) { Plugin.Log.LogDebug((object)"PlayerControllerB.KillPlayer() was called!"); __state = __instance.isPlayerDead; } [HarmonyPostfix] public static void PostKillPlayer(PlayerControllerB __instance, bool __state) { Plugin.Log.LogDebug((object)"PlayerControllerB.KillPlayer() was called!"); if (__instance.isPlayerDead && !__state && ((NetworkBehaviour)__instance).IsOwner) { Plugin.SendPost(Plugin.ConfigMaxIntensity.Value, 1, 0); Plugin.Log.LogInfo((object)("Player " + __instance.playerUsername + " has died, sending shock!")); } } [HarmonyPrefix] public static void PreDamagePlayer(PlayerControllerB __instance, ref int __state) { Plugin.Log.LogDebug((object)"PlayerControllerB.DamagePlayer() was called!"); __state = __instance.health; } [HarmonyPostfix] public static void PostDamagePlayer(PlayerControllerB __instance, int __state, CauseOfDeath causeOfDeath) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 if (!__instance.isPlayerDead && ((NetworkBehaviour)__instance).IsOwner && Plugin.ConfigVibrateOnDamage.Value) { int num = __state - __instance.health; if (num > 0) { int num2 = Plugin.ConfigMaxIntensity.Value * num / 100; int op = (((int)causeOfDeath != 11) ? 1 : 0); Plugin.SendPost(num2, 1, op); string text = (((int)causeOfDeath == 11) ? "shock" : "vibration"); Plugin.Log.LogInfo((object)$"Player {__instance.playerUsername} has taken {num} damage, sending {text} with intensity {num2}!"); } } } } }