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<Task<bool>> list = new List<Task<bool>>();
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<string> _username;
private ConfigEntry<string> _apiKey;
private ConfigEntry<string> _shareCodes;
public ConfigEntry<bool> ModEnabled { get; private set; }
public ConfigEntry<bool> EnableShock { get; private set; }
public ConfigEntry<int> ShockIntensity { get; private set; }
public ConfigEntry<int> ShockDuration { get; private set; }
public ConfigEntry<bool> EnableVibrate { get; private set; }
public ConfigEntry<int> VibrateIntensity { get; private set; }
public ConfigEntry<int> VibrateDuration { get; private set; }
public ConfigEntry<bool> EnableDeathShock { get; private set; }
public ConfigEntry<int> DeathShockIntensity { get; private set; }
public ConfigEntry<int> DeathShockDuration { get; private set; }
public ConfigEntry<bool> EnableDeathVibrate { get; private set; }
public ConfigEntry<int> DeathVibrateIntensity { get; private set; }
public ConfigEntry<int> DeathVibrateDuration { 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
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Expected O, but got Unknown
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Expected O, but got Unknown
_logger = logger;
_api = new PiShockAPI(new HttpClient());
_username = config.Bind<string>("1. PiShock Credentials", "Username", "", "Your PiShock Username");
_apiKey = config.Bind<string>("1. PiShock Credentials", "APIKey", "", "Your PiShock API Key");
_shareCodes = config.Bind<string>("1. PiShock Credentials", "ShareCodes", "", "Comma separated share codes");
ModEnabled = config.Bind<bool>("2. Full Toggle", "Mod Enabled", true, "Master switch to enable or disable all mod triggers.");
EnableShock = config.Bind<bool>("3. Damage Settings", "Enable Shock", true, "Shock on damage.");
ShockIntensity = config.Bind<int>("3. Damage Settings", "Shock Intensity", 25, new ConfigDescription("Intensity of the shock (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
ShockDuration = config.Bind<int>("3. Damage Settings", "Shock Duration", 1, new ConfigDescription("Duration of the shock in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
EnableVibrate = config.Bind<bool>("3. Damage Settings", "Enable Vibrate", false, "Vibrate on damage.");
VibrateIntensity = config.Bind<int>("3. Damage Settings", "Vibrate Intensity", 50, new ConfigDescription("Intensity of the vibration (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
VibrateDuration = config.Bind<int>("3. Damage Settings", "Vibrate Duration", 1, new ConfigDescription("Duration of the vibration in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
EnableDeathShock = config.Bind<bool>("4. Death Settings", "Enable Death Shock", true, "Shock on death.");
DeathShockIntensity = config.Bind<int>("4. Death Settings", "Death Shock Intensity", 50, new ConfigDescription("Intensity of the death shock (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
DeathShockDuration = config.Bind<int>("4. Death Settings", "Death Shock Duration", 3, new ConfigDescription("Duration of the death shock in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
EnableDeathVibrate = config.Bind<bool>("4. Death Settings", "Enable Death Vibrate", true, "Vibrate on death.");
DeathVibrateIntensity = config.Bind<int>("4. Death Settings", "Death Vibrate Intensity", 50, new ConfigDescription("Intensity of the vibrate shock (1-100).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
DeathVibrateDuration = config.Bind<int>("4. Death Settings", "Death Vibrate Duration", 3, new ConfigDescription("Duration of the death shock in seconds (1-10).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
}
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<PiShockDeviceInfo> devices = new List<PiShockDeviceInfo>();
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.1.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 Prefix(float ___health, out float __state)
{
__state = ___health;
}
[HarmonyPatch("Damage")]
[HarmonyPostfix]
public static void Postfix(ENT_Player __instance, bool __result, float ___health, float __state)
{
if (WKShockPlugin.PiShock == null || WKShockPlugin.PiShock.Controller == null || !WKShockPlugin.PiShock.ModEnabled.Value)
{
return;
}
float num = __state - ___health;
if (!(num <= 0f) && !(___health <= 0f) && !__result)
{
Debug.Log((object)$"Player hit for {num} 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 Prefix(bool ___dead, out bool __state)
{
__state = ___dead;
}
[HarmonyPatch("Kill")]
[HarmonyPostfix]
public static void Postfix(bool ___dead, bool __state)
{
if (WKShockPlugin.PiShock != null && WKShockPlugin.PiShock.Controller != null && WKShockPlugin.PiShock.ModEnabled.Value && !__state && ___dead)
{
Debug.Log((object)"Player died.");
if (WKShockPlugin.PiShock.EnableDeathShock.Value)
{
WKShockPlugin.PiShock.Controller.OperatePiShock(WKShockPlugin.PiShock.DeathShockIntensity.Value, WKShockPlugin.PiShock.DeathShockDuration.Value, (PiShockOperations)0);
}
if (WKShockPlugin.PiShock.EnableDeathVibrate.Value)
{
WKShockPlugin.PiShock.Controller.OperatePiShock(WKShockPlugin.PiShock.DeathVibrateIntensity.Value, WKShockPlugin.PiShock.DeathVibrateDuration.Value, (PiShockOperations)1);
}
}
}
}
}