using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using Kill_Bind.Config;
using Kill_Bind.Patches;
using Kill_Bind.SoftDeps;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using On;
using UnityEngine;
using UnityEngine.InputSystem;
using com.github.zehsteam.ToilHead;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Confusified.KillBind")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.2.0")]
[assembly: AssemblyInformationalVersion("2.2.2+75ecbd094669817da7edef804c98f3bef49152de")]
[assembly: AssemblyProduct("KillBind")]
[assembly: AssemblyTitle("com.Confusified.KillBind")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 Kill_Bind
{
public class LC_InputActions : LcInputActions
{
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction KillBindKey { get; set; }
}
[BepInPlugin("com.Confusified.KillBind", "KillBind", "2.2.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Kill_Bind : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__UpdateRagdollList;
public static Action<CallbackContext> <1>__OnPressKillBind;
}
public static readonly string configLocation;
public static ConfigFile modConfig;
internal static readonly LC_InputActions InputActionInstance;
private static WaitForEndOfFrame waitForFrameEnd;
public static Kill_Bind Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
ConfigHandler.InitialiseConfig();
EnableSoftDeps();
object obj = <>O.<0>__UpdateRagdollList;
if (obj == null)
{
hook_Start val = StartOfRoundPatch.UpdateRagdollList;
<>O.<0>__UpdateRagdollList = val;
obj = (object)val;
}
StartOfRound.Start += (hook_Start)obj;
InputActionInstance.KillBindKey.performed += OnPressKillBind;
Logger.LogInfo((object)"KillBind 2.2.2 has loaded!");
}
internal static void EnableSoftDeps()
{
Dictionary<string, Action> dictionary = new Dictionary<string, Action>
{
{
"BMX.LobbyCompatibility",
delegate
{
LobbyCompatibilityPatch.RegisterMod();
}
},
{
"ainavt.lc.lethalconfig",
delegate
{
LethalConfigPatch.InitialiseLethalConfigEntries();
}
},
{
"com.github.zehsteam.ToilHead",
delegate
{
ToilHead.SetAsPresent();
}
}
};
foreach (KeyValuePair<string, Action> item in dictionary)
{
if (Chainloader.PluginInfos.ContainsKey(item.Key))
{
item.Value();
Logger.LogDebug((object)("Soft Dependency Found: " + item.Key));
}
}
}
public static void OnPressKillBind(CallbackContext callbackContext)
{
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
Terminal val2 = Object.FindObjectOfType<Terminal>();
HUDManager instance = HUDManager.Instance;
if (((CallbackContext)(ref callbackContext)).performed && ConfigSettings.ModEnabled.Value && Object.op_Implicit((Object)(object)val) && !val.isPlayerDead && Object.op_Implicit((Object)(object)val.thisController) && Object.op_Implicit((Object)(object)instance) && !((Behaviour)instance.typingIndicator).enabled && !val.isTypingChat && Object.op_Implicit((Object)(object)val2) && (!val2.terminalInUse || !val.inTerminalMenu) && Object.op_Implicit((Object)(object)val.quickMenuManager) && !val.quickMenuManager.isMenuOpen)
{
Logger.LogDebug((object)"Passed KillBind's checks, attempting to kill after yielding until end of frame");
CoroutineHelper.Start(KillAfterYield(val));
}
}
public static IEnumerator KillAfterYield(PlayerControllerB localPlayer)
{
List<GameObject> ragdollList = localPlayer.playersManager.playerRagdolls;
yield return waitForFrameEnd;
GameObject val = ragdollList.Find((GameObject x) => ((Object)x).name.Contains(ConfigSettings.DeathAnimation.Value));
int num = ((!(ConfigSettings.DeathAnimation.Value == "Normal")) ? 1 : 0);
num = (((Object)(object)val != (Object)null) ? ragdollList.IndexOf(val) : num);
localPlayer.KillPlayer(localPlayer.thisController.velocity, true, ConfigSettings.DeathCause.Value, num, default(Vector3));
if (ToilHead.ToilHeadMod_Present && ConfigSettings.DeathAnimation.Value == "Spring")
{
Logger.LogDebug((object)"Attempting to replace the ragdoll with a ToilHead variant");
ToilHead.CreateToilheadRagdoll(localPlayer);
}
}
static Kill_Bind()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
string[] array = new string[1];
string configPath = Paths.ConfigPath;
string text = "com.Confusified.KillBind";
array[0] = configPath + "\\" + text.Substring(4, text.Length - 4).Replace(".", "\\");
configLocation = Utility.CombinePaths(array);
modConfig = new ConfigFile(configLocation + ".cfg", false);
InputActionInstance = new LC_InputActions();
Logger = null;
waitForFrameEnd = new WaitForEndOfFrame();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.Confusified.KillBind";
public const string PLUGIN_NAME = "KillBind";
public const string PLUGIN_VERSION = "2.2.2";
}
}
namespace Kill_Bind.SoftDeps
{
internal class DependencyStrings
{
internal const string LobbyCompatibility = "BMX.LobbyCompatibility";
internal const string LethalConfig = "ainavt.lc.lethalconfig";
internal const string InputUtils = "com.rune580.LethalCompanyInputUtils";
internal const string ToilHead = "com.github.zehsteam.ToilHead";
}
internal class LethalConfigPatch
{
internal static TextDropDownConfigItem DeathAnimationEntry;
internal static void InitialiseLethalConfigEntries()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
LethalConfigManager.SkipAutoGen();
BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(ConfigSettings.ModEnabled, false);
EnumDropDownConfigItem<CauseOfDeath> val2 = new EnumDropDownConfigItem<CauseOfDeath>(ConfigSettings.DeathCause, false);
DeathAnimationEntry = new TextDropDownConfigItem(ConfigSettings.DeathAnimation, false);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)DeathAnimationEntry);
Kill_Bind.Logger.LogDebug((object)"Finished adding entries to LethalConfig");
LethalConfigManager.SetModDescription("Become a ragdoll with just one button press");
}
internal static void UpdateConfigEntries()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
DeathAnimationEntry = new TextDropDownConfigItem(ConfigSettings.DeathAnimation, false);
Kill_Bind.Logger.LogDebug((object)"Updated Ragdoll List in LethalConfig");
}
}
internal class LobbyCompatibilityPatch
{
internal static void RegisterMod()
{
PluginHelper.RegisterPlugin("KillBind", Version.Parse("2.2.2"), (CompatibilityLevel)0, (VersionStrictness)0);
}
}
public class ToilHead
{
public static bool ToilHeadMod_Present = false;
public static float ToilSlayerRagdollChance = 10f;
private static ConfigEntry<float> ToilPlayerSlayerChance;
internal static void CreateToilheadRagdoll(PlayerControllerB self)
{
bool flag = Utils.RandomPercent(ToilSlayerRagdollChance);
TurretHeadManager.SetDeadBodyTurretHead(self, flag);
}
internal static void SetAsPresent()
{
ToilHeadMod_Present = true;
ConfigFile config = Chainloader.PluginInfos["com.github.zehsteam.ToilHead"].Instance.Config;
foreach (ConfigDefinition key in config.Keys)
{
if (key.Section == "Toil-Player Settings" && key.Key == "ToilPlayerSlayerChance")
{
config.TryGetEntry<float>(key, ref ToilPlayerSlayerChance);
ToilSlayerRagdollChance = ToilPlayerSlayerChance.Value;
Kill_Bind.Logger.LogDebug((object)$"Updated ToilSlayerRagdollChance to {ToilSlayerRagdollChance}");
ToilPlayerSlayerChance.SettingChanged += UpdateChanceValue;
return;
}
}
Kill_Bind.Logger.LogDebug((object)$"Could not find ToilPlayerSlayerChance config setting. ToilSlayerRagdollChance will use the default value ({ToilSlayerRagdollChance})");
}
private static void UpdateChanceValue(object sender = null, EventArgs args = null)
{
ToilSlayerRagdollChance = ToilPlayerSlayerChance.Value;
Kill_Bind.Logger.LogDebug((object)$"Updated ToilSlayerRagdollChance to {ToilSlayerRagdollChance}");
}
}
}
namespace Kill_Bind.Patches
{
internal class StartOfRoundPatch
{
internal static void UpdateRagdollList(orig_Start original, StartOfRound self)
{
original.Invoke(self);
ConfigSettings.DeathAnimationCreatedList = "";
foreach (GameObject playerRagdoll in self.playerRagdolls)
{
string text = CleanRagdollName(((Object)playerRagdoll).name);
ConfigSettings.DeathAnimationCreatedList = ((self.playerRagdolls.IndexOf(playerRagdoll) == 0) ? text : (ConfigSettings.DeathAnimationCreatedList + ";" + text));
Kill_Bind.Logger.LogDebug((object)$"{((Object)playerRagdoll).name} => {text} => Count: {self.playerRagdolls.IndexOf(playerRagdoll)}");
}
ConfigHandler.UpdateConfigValues();
if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
{
LethalConfigPatch.UpdateConfigEntries();
}
}
internal static string CleanRagdollName(string ragdollName)
{
if (ragdollName == "PlayerRagdoll")
{
return "Normal";
}
string pattern = "Player|Ragdoll|With|Variant|Prefab| ";
ragdollName = Regex.Replace(ragdollName, pattern, "", RegexOptions.IgnoreCase);
return ragdollName;
}
}
}
namespace Kill_Bind.Config
{
internal class ConfigHandler
{
internal static void InitialiseConfig()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
ConfigSettings.ModEnabled = Kill_Bind.modConfig.Bind<bool>("Mod Settings", "Mod Enabled", true, "Enable the killbind");
ConfigSettings.DeathCause = Kill_Bind.modConfig.Bind<CauseOfDeath>("Mod Settings", "Cause of Death", (CauseOfDeath)0, "The cause of death your ragdoll while have");
ConfigSettings.DeathAnimation = Kill_Bind.modConfig.Bind<string>("Mod Settings", "Type of Ragdoll", "HeadBurst", new ConfigDescription("The type of ragdoll you will have\nThe amount of types may vary when other mods are installed", (AcceptableValueBase)(object)new AcceptableValueList<string>(ConfigSettings.DeathAnimationList.ToArray()), Array.Empty<object>()));
ConfigSettings.ConfigVersion = Kill_Bind.modConfig.Bind<byte>("z Do Not Touch z", "Config Version", (byte)0, "The current version of the config file");
ConfigSettings.DeathAnimationString_List = Kill_Bind.modConfig.Bind<string>("z Do Not Touch z", "Ragdoll List", ConfigSettings.DeathAnimationCreatedList, "The list of ragdolls found while playing\nThis is updated every time you enter a lobby");
UpdateOldConfig();
}
internal static void UpdateOldConfig()
{
string text = Kill_Bind.configLocation + ".private";
bool flag = File.Exists(text);
int num = ES3.Load<int>("ConfigVersion", text, (int)ConfigSettings.ConfigVersion.Value);
if (num == ConfigSettings.currentVersion)
{
return;
}
if (num < 2)
{
ConfigEntry<int> val = Kill_Bind.modConfig.Bind<int>("Mod Settings", "HeadType", 1, (ConfigDescription)null);
ConfigSettings.DeathAnimation.Value = ConvertIntToStringRagdoll(val.Value);
Kill_Bind.modConfig.Remove(((ConfigEntryBase)val).Definition);
}
if (num < 3)
{
ConfigEntry<int> val = Kill_Bind.modConfig.Bind<int>("Mod Settings", "Ragdoll Type", 1, (ConfigDescription)null);
ConfigSettings.DeathAnimation.Value = ConvertIntToStringRagdoll(val.Value);
Kill_Bind.modConfig.Remove(((ConfigEntryBase)val).Definition);
val = Kill_Bind.modConfig.Bind<int>("Mod Settings", "Death Cause", 0, (ConfigDescription)null);
ConfigSettings.DeathCause.Value = (CauseOfDeath)val.Value;
Kill_Bind.modConfig.Remove(((ConfigEntryBase)val).Definition);
if (flag)
{
File.Delete(text);
Kill_Bind.Logger.LogDebug((object)"Deleted .private file as it is no longer used as of v2.2.0");
}
}
ConfigSettings.ConfigVersion.Value = ConfigSettings.currentVersion;
Kill_Bind.Logger.LogDebug((object)$"Succesfully updated config file version {num} => {ConfigSettings.currentVersion}");
}
internal static void UpdateConfigValues()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
ConfigSettings.DeathAnimationList = new List<string>(Regex.Split(ConfigSettings.DeathAnimationCreatedList, ";"));
ConfigSettings.DeathAnimationString_List.Value = ConfigSettings.DeathAnimationCreatedList;
string value = ConfigSettings.DeathAnimation.Value;
ConfigSettings.DeathAnimation = Kill_Bind.modConfig.Bind<string>("Mod Settings", "Type of Ragdoll", "HeadBurst", new ConfigDescription("The type of ragdoll you will have\nThe amount of types may vary when other mods are installed", (AcceptableValueBase)(object)new AcceptableValueList<string>(ConfigSettings.DeathAnimationList.ToArray()), Array.Empty<object>()));
ConfigSettings.DeathAnimation.Value = value;
}
internal static string ConvertIntToStringRagdoll(int RagdollInt)
{
if (ConfigSettings.DeathAnimationList[RagdollInt] == null)
{
return "HeadBurst";
}
return ConfigSettings.DeathAnimationList[RagdollInt].ToString();
}
}
public class ConfigSettings
{
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<CauseOfDeath> DeathCause;
public static ConfigEntry<string> DeathAnimation;
public static ConfigEntry<string> DeathAnimationString_List;
public static ConfigEntry<byte> ConfigVersion;
public static byte currentVersion = 3;
public static string DeathAnimationCreatedList = "Normal;HeadBurst;Spring;Electrocuted;ComedyMask;TragedyMask;Burnt";
public static List<string> DeathAnimationList = new List<string>(Regex.Split(DeathAnimationCreatedList, ";"));
}
}