using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("HeartAttack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Gives each player a random chance to have a heart attack each tick")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HeartAttack")]
[assembly: AssemblyTitle("HeartAttack")]
[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 HeartAttack
{
[BepInPlugin("com.PizzaMan730.HeartAttack", "HeartAttack", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public class myPatches
{
public static void UpdateSim_Patch(PlayerBody __instance, ref IPlayerIdHolder ___idHolder, ref FixTransform ___fixTransform)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
if (!(Updater.RandomFix((Fix)0L, (Fix)100L) <= (Fix)chance.Value))
{
return;
}
FieldInfo field = typeof(GameSessionHandler).GetField("selfRef", BindingFlags.Static | BindingFlags.NonPublic);
FieldInfo field2 = typeof(GameSessionHandler).GetField("slimeControllers", BindingFlags.Instance | BindingFlags.NonPublic);
SlimeController[] array = (SlimeController[])field2.GetValue(field.GetValue(null));
SlimeController[] array2 = array;
foreach (SlimeController val in array2)
{
if (val.playerNumber == ___idHolder.GetPlayerId())
{
((PlayerCollision)Traverse.Create((object)val).Field("playerCollision").GetValue()).killPlayer(___idHolder.GetPlayerId(), true, true, (CauseOfDeath)0);
Updater.DestroyFix(((Component)___fixTransform).gameObject);
Debug.Log((object)"A player had a heart attack!");
}
}
}
}
public static ConfigFile config;
public static ConfigEntry<float> chance;
private void Awake()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"HeartAttack has loaded!");
config = ((BaseUnityPlugin)this).Config;
chance = config.Bind<float>("HeartAttack", "Heart attack chance", 1f, "Percent chance that you die each tick");
Harmony val = new Harmony("com.PizzaMan730.HeartAttack");
MethodInfo methodInfo = AccessTools.Method(typeof(PlayerBody), "UpdateSim", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(myPatches), "UpdateSim_Patch", (Type[])null, (Type[])null);
val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HeartAttack";
public const string PLUGIN_NAME = "HeartAttack";
public const string PLUGIN_VERSION = "1.0.0";
}
}