using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using PiShockClassLibrary.Models; using PiShockClassLibrary.Services; using PiShockLibrary.Enums; using PiShockLibrary.Models; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("WKShock")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WKShock")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("C2826ADF-39EB-463A-9FDD-F5A4A478A93A")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace WKShock { public class PiShockController { private PiShockAPI _piShockAPI; private PiShockUserInfo _userInfo; private ManualLogSource _logger; public PiShockController(PiShockAPI piShockAPI, PiShockUserInfo piShockUserInfo, ManualLogSource logger) { _piShockAPI = piShockAPI; _userInfo = piShockUserInfo; _logger = logger; } public void OperatePiShock(int intensity, int duration, PiShockOperations op) { //IL_000d: 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) Task.Run(async delegate { List> list = new List>(); foreach (PiShockDeviceInfo device in _userInfo.Devices) { PiShockOperateRequestBody val = new PiShockOperateRequestBody(_userInfo, op, device.ShareCode, intensity, duration, "White Knuckle"); list.Add(_piShockAPI.SendOperationRequest(val)); } if ((await Task.WhenAll(list)).Any((bool success) => !success)) { _logger.LogWarning((object)"One or more PiShock requests failed to execute!"); } }); } } public class PiShockLogin { private readonly ManualLogSource _logger; private readonly PiShockAPI _api; private ConfigEntry _username; private ConfigEntry _apiKey; private ConfigEntry _shareCodes; public ConfigEntry ModEnabled { get; private set; } public ConfigEntry EnableShock { get; private set; } public ConfigEntry ShockIntensity { get; private set; } public ConfigEntry ShockDuration { get; private set; } public ConfigEntry EnableVibrate { get; private set; } public ConfigEntry VibrateIntensity { get; private set; } public ConfigEntry VibrateDuration { get; private set; } public ConfigEntry EnableDeathShock { get; private set; } public ConfigEntry DeathShockIntensity { get; private set; } public ConfigEntry DeathShockDuration { get; private set; } public PiShockController Controller { get; private set; } public PiShockLogin(ConfigFile config, ManualLogSource logger) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown _logger = logger; _api = new PiShockAPI(new HttpClient()); _username = config.Bind("1. PiShock Credentials", "Username", "", "Your PiShock Username"); _apiKey = config.Bind("1. PiShock Credentials", "APIKey", "", "Your PiShock API Key"); _shareCodes = config.Bind("1. PiShock Credentials", "ShareCodes", "", "Comma separated share codes"); ModEnabled = config.Bind("2. Gameplay Settings", "Mod Enabled", true, "Master switch to enable or disable all mod triggers."); EnableShock = config.Bind("3. Shock Settings", "Enable Shock", true, "Send a shock when taking damage."); ShockIntensity = config.Bind("3. Shock Settings", "Shock Intensity", 25, new ConfigDescription("Intensity of the shock (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); ShockDuration = config.Bind("3. Shock Settings", "Shock Duration", 1, new ConfigDescription("Duration of the shock in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); EnableVibrate = config.Bind("4. Vibrate Settings", "Enable Vibrate", false, "Send a vibration when taking damage."); VibrateIntensity = config.Bind("4. Vibrate Settings", "Vibrate Intensity", 50, new ConfigDescription("Intensity of the vibration (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); VibrateDuration = config.Bind("4. Vibrate Settings", "Vibrate Duration", 1, new ConfigDescription("Duration of the vibration in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); EnableDeathShock = config.Bind("5. Death Settings", "Enable Death Shock", true, "Send a massive shock when dying."); DeathShockIntensity = config.Bind("5. Death Settings", "Death Shock Intensity", 50, new ConfigDescription("Intensity of the death shock (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); DeathShockDuration = config.Bind("5. Death Settings", "Death Shock Duration", 3, new ConfigDescription("Duration of the death shock in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); } public async Task InitializeAsync() { try { if (string.IsNullOrEmpty(_username.Value) || string.IsNullOrEmpty(_apiKey.Value)) { _logger.LogError((object)"PiShock: Username or APIKey missing in config file!"); return; } if (string.IsNullOrEmpty(_shareCodes.Value)) { _logger.LogError((object)"PiShock: ShareCode missing in config file!"); return; } string[] array = _shareCodes.Value.Split(new char[1] { ',' }); List devices = new List(); for (int i = 0; i < array.Length; i++) { devices.Add(new PiShockDeviceInfo($"Shocker {i}", array[i].Trim())); } PiShockUserInfo piShockUserInfo = (await _api.GetUserInfoFromAPI(_username.Value, _apiKey.Value)).WithDevices(devices); Controller = new PiShockController(_api, piShockUserInfo, _logger); _logger.LogInfo((object)"PiShock login successful."); } catch (Exception ex) { _logger.LogError((object)("PiShock login failed: " + ex.Message)); } } } [BepInPlugin("com.xironix.wkshock", "WKShock", "1.0.0")] public class WKShockPlugin : BaseUnityPlugin { public static PiShockLogin PiShock { get; private set; } private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogInfo((object)"WKShock is waking up..."); PiShock = new PiShockLogin(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); PiShock.InitializeAsync(); new Harmony("com.xironix.wkshock").PatchAll(); } } } namespace WKShock.HarmonyPatches { [HarmonyPatch(typeof(ENT_Player))] public class PlayerDamagePatch { [HarmonyPatch("Damage")] [HarmonyPrefix] public static void BeforePlayerTakesDamage(ENT_Player __instance, DamageInfo info, bool ___godmode, float ___health) { if (WKShockPlugin.PiShock != null && WKShockPlugin.PiShock.Controller != null && WKShockPlugin.PiShock.ModEnabled.Value && !___godmode && !(info.amount <= 0f) && !(___health - info.amount <= 0f)) { Debug.Log((object)$"Player hit for {info.amount} damage."); if (WKShockPlugin.PiShock.EnableShock.Value) { WKShockPlugin.PiShock.Controller.OperatePiShock(WKShockPlugin.PiShock.ShockIntensity.Value, WKShockPlugin.PiShock.ShockDuration.Value, (PiShockOperations)0); } if (WKShockPlugin.PiShock.EnableVibrate.Value) { WKShockPlugin.PiShock.Controller.OperatePiShock(WKShockPlugin.PiShock.VibrateIntensity.Value, WKShockPlugin.PiShock.VibrateDuration.Value, (PiShockOperations)1); } } } } [HarmonyPatch(typeof(ENT_Player))] public class PlayerDeathPatch { [HarmonyPatch("Kill")] [HarmonyPrefix] public static void BeforePlayerDies(bool ___dead, bool ___godmode) { if (WKShockPlugin.PiShock != null && WKShockPlugin.PiShock.Controller != null && WKShockPlugin.PiShock.ModEnabled.Value && !(___dead || ___godmode)) { Debug.Log((object)"Player died."); if (WKShockPlugin.PiShock.EnableDeathShock.Value) { WKShockPlugin.PiShock.Controller.OperatePiShock(WKShockPlugin.PiShock.DeathShockIntensity.Value, WKShockPlugin.PiShock.DeathShockDuration.Value, (PiShockOperations)0); } } } } }