using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("EnterThePishock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnterThePishock")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("57445610-0892-47c3-be16-453172104123")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 Mod
{
public class PiShock
{
[CompilerGenerated]
private sealed class <SendShock>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string shareCode;
public string Name;
public Shock shock;
public PiShock <>4__this;
private UnityWebRequest <request>5__1;
private byte[] <bodyRaw>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SendShock>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<request>5__1 = null;
<bodyRaw>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
Debug.Log((object)$"Shocking for {shock.Duration}s at {shock.Intensity} intensity");
<request>5__1 = new UnityWebRequest("https://do.pishock.com/api/apioperate/", "POST");
<bodyRaw>5__2 = Encoding.UTF8.GetBytes($"{{\"Username\": \"{<>4__this.USERNAME}\",\"ApiKey\":\"{<>4__this.API_KEY}\",\"Code\":\"{shareCode}\",\"Name\":\"{Name}\",\"Op\":0,\"Duration\":{shock.Duration},\"Intensity\":{shock.Intensity}}}");
<request>5__1.uploadHandler = (UploadHandler)new UploadHandlerRaw(<bodyRaw>5__2);
<request>5__1.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
<request>5__1.SetRequestHeader("Content-Type", "application/json");
<>2__current = <request>5__1.SendWebRequest();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Debug.Log((object)("Status Code: " + <request>5__1.responseCode));
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private readonly string API_KEY;
private readonly string USERNAME;
private const string API_URL = "https://do.pishock.com/api/apioperate/";
public PiShock(string apiKey, string userName)
{
API_KEY = apiKey;
USERNAME = userName;
}
public IEnumerator SendShock(string shareCode, string Name, Shock shock)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SendShock>d__4(0)
{
<>4__this = this,
shareCode = shareCode,
Name = Name,
shock = shock
};
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("kenshi1453.enterthepishock", "ENTER THE PISHOCK", "0.0.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <ShockCoroutine>d__18 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private Shock <shock>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ShockCoroutine>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<shock>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<shock>5__1 = <>4__this.shocks.Dequeue();
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.piShock.SendShock(<>4__this.shareCodeEntry.Value, "ETG_Shock", <shock>5__1));
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime((float)<shock>5__1.Duration);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<shock>5__1 = null;
break;
}
<>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.shocks.Count > 0));
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string GUID = "kenshi1453.enterthepishock";
public const string NAME = "ENTER THE PISHOCK";
public const string VERSION = "0.0.0";
public const string TEXT_COLOR = "#00FFFF";
private GameManager gameManager;
private PlayerController playerController;
private Queue<Shock> shocks = new Queue<Shock>();
private PiShock piShock;
private ConfigEntry<string> apiKeyEntry;
private ConfigEntry<string> usernameEntry;
private ConfigEntry<string> shareCodeEntry;
private ConfigEntry<int> maxShockIntensity;
private ConfigEntry<int> minShockIntensity;
private ConfigEntry<int> maxShockDuration;
private ConfigEntry<int> minShockDuration;
public void Start()
{
InitConfig();
piShock = new PiShock(apiKeyEntry.Value, usernameEntry.Value);
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
private void InitConfig()
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
apiKeyEntry = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PiShock API Key", "APIKEY", (ConfigDescription)null);
usernameEntry = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PiShock Username", "USERNAME", (ConfigDescription)null);
shareCodeEntry = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PiShock Sharecode", "SHARECODE", (ConfigDescription)null);
maxShockIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Shock Values", "Max Intensity", 100, new ConfigDescription("The maximum intensity to shock", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), new object[0]));
minShockIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Shock Values", "Min Intensity", 70, new ConfigDescription("The minimum intensity to shock", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), new object[0]));
maxShockDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Shock Values", "Max Duration", 15, new ConfigDescription("The maximum duration to shock", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 15), new object[0]));
minShockDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Shock Values", "Min Duration", 10, new ConfigDescription("The minimum duration to shock", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 15), new object[0]));
}
public void GMStart(GameManager g)
{
Log("ENTER THE PISHOCK v0.0.0 started successfully.", "#00FFFF");
gameManager = g;
g.OnNewLevelFullyLoaded += G_OnNewLevelFullyLoaded;
((MonoBehaviour)this).StartCoroutine(ShockCoroutine());
}
private IEnumerator ShockCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ShockCoroutine>d__18(0)
{
<>4__this = this
};
}
private void G_OnNewLevelFullyLoaded()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
if ((Object)(object)playerController != (Object)(object)gameManager.m_player)
{
playerController = gameManager.m_player;
((BraveBehaviour)gameManager.m_player).healthHaver.OnDamaged += new OnDamagedEvent(OnDamaged);
}
}
private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
{
Console.WriteLine($"Health changed. New health is '{resultValue}'");
int intensity = (int)Math.Round(Lerp(resultValue, 0.0, maxValue, maxShockIntensity.Value, minShockIntensity.Value));
int duration = (int)Math.Round(Lerp(resultValue, 0.0, maxValue, maxShockDuration.Value, minShockDuration.Value));
shocks.Enqueue(new Shock(duration, intensity));
}
private double Lerp(double x, double x0, double x1, double y0, double y1)
{
double a = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
return Math.Round(a);
}
public static void Log(string text, string color = "FFFFFF")
{
ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
}
}
public class Shock
{
public readonly int Duration;
public readonly int Intensity;
public Shock(int duration, int intensity)
{
Duration = duration;
Intensity = intensity;
}
}
}