using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Kill_Bind.Config;
using Kill_Bind.Hooks;
using Kill_Bind.Hooks.DependencyRelated;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.github.zehsteam.ToilHead")]
[assembly: AssemblyCompany("KillBind.Confusified.com.GitHub")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.3.3.0")]
[assembly: AssemblyInformationalVersion("2.3.3+9baba56ba126476d5529bac59d979ee05a764650")]
[assembly: AssemblyProduct("Kill Bind")]
[assembly: AssemblyTitle("KillBind.Confusified.com.GitHub")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.3.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 KillBind_Inputs : LcInputActions
{
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction ActionKillBind { get; set; }
}
[SoftDependency("BMX.LobbyCompatibility", typeof(RegisterPlugin_LobbyCompatibility))]
[SoftDependency("com.github.zehsteam.ToilHead", typeof(ToilHead))]
[SoftDependency("ainavt.lc.lethalconfig", typeof(SetupConfig_LethalConfig))]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("KillBind.Confusified.com.GitHub", "Kill Bind", "2.3.3")]
public class Main : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__UpdateRagdollTypeList;
public static Action<CallbackContext> <1>__OnPressKillBind;
}
private static readonly string configLocation = Utility.CombinePaths(new string[1] { Paths.ConfigPath + "\\" + "KillBind.Confusified.com.GitHub".Substring(9, 12).Replace(".", "\\") }) + "KillBind.Confusified.com.GitHub".Substring(0, 8);
internal static ConfigFile killbindConfig = new ConfigFile(configLocation + ".cfg", false);
public static readonly KillBind_Inputs InputActionInstance = new KillBind_Inputs();
public static Main Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
ConfigHandler.InitialiseConfig();
InitialiseSoftDependencies();
HookMethods();
Logger.LogInfo((object)"Kill Bind v2.3.3 has loaded!");
}
private static void InitialiseSoftDependencies()
{
Logger.LogDebug((object)"Activating Soft Dependencies...");
SoftDependencyAttribute.Init((BaseUnityPlugin)(object)Instance);
Logger.LogDebug((object)"Soft Dependencies Activated.");
}
private static void HookMethods()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
Logger.LogDebug((object)"Hooking...");
object obj = <>O.<0>__UpdateRagdollTypeList;
if (obj == null)
{
hook_Start val = StartOfRoundHooks.UpdateRagdollTypeList;
<>O.<0>__UpdateRagdollTypeList = val;
obj = (object)val;
}
StartOfRound.Start += (hook_Start)obj;
Logger.LogDebug((object)"Hooked: StartOfRound, Start");
InputActionInstance.ActionKillBind.performed += KillBindHandler.OnPressKillBind;
Logger.LogDebug((object)"Bound KillBind's Keybind.");
Logger.LogDebug((object)"Finished Hooking.");
}
}
internal class SoftDependencyAttribute : BepInDependency
{
public Type Handler;
public SoftDependencyAttribute(string guid, Type handlerType)
: base(guid, (DependencyFlags)2)
{
Handler = handlerType;
}
internal static void Init(BaseUnityPlugin source)
{
IEnumerable<SoftDependencyAttribute> customAttributes = ((MemberInfo)((object)source).GetType()).GetCustomAttributes<SoftDependencyAttribute>();
foreach (SoftDependencyAttribute item in customAttributes)
{
if (item != null && Chainloader.PluginInfos.ContainsKey(((BepInDependency)item).DependencyGUID))
{
Main.Logger.LogDebug((object)("Found compatible mod: " + ((BepInDependency)item).DependencyGUID));
item.Handler.GetMethod("Activate", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, null);
item.Handler = null;
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "KillBind.Confusified.com.GitHub";
public const string PLUGIN_NAME = "Kill Bind";
public const string PLUGIN_VERSION = "2.3.3";
}
}
namespace Kill_Bind.Hooks
{
public class StartOfRoundHooks
{
public static StartOfRound StartOfRoundInstance;
private static bool ragdollListCreated;
public static void UpdateRagdollTypeConfig()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
ConfigSettings.ListRagdollType = new List<string>(Regex.Split(ConfigSettings.RagdollTypeList.Value, ";"));
ConfigHandler.RagdollTypeDescription = new ConfigDescription("Determines what ragdoll will be used.", (AcceptableValueBase)(object)new AcceptableValueList<string>(ConfigSettings.ListRagdollType.ToArray()), Array.Empty<object>());
string value = ConfigSettings.RagdollType.Value;
Main.killbindConfig.SaveOnConfigSet = false;
Main.killbindConfig.Remove(((ConfigEntryBase)ConfigSettings.RagdollType).Definition);
ConfigSettings.RagdollType = Main.killbindConfig.Bind<string>("Mod Settings", "Type of Ragdoll", "HeadBurst", ConfigHandler.RagdollTypeDescription);
ConfigSettings.RagdollType.Value = value;
Main.killbindConfig.Save();
if (SetupConfig_LethalConfig.LethalConfigFound)
{
SetupConfig_LethalConfig.UpdateRagdollTypeDropdown();
}
Main.killbindConfig.SaveOnConfigSet = true;
}
public static void UpdateRagdollTypeList(orig_Start orig, StartOfRound self)
{
orig.Invoke(self);
StartOfRoundInstance = self;
if (ragdollListCreated)
{
return;
}
Main.Logger.LogDebug((object)"Creating ragdoll list...");
ConfigSettings.RagdollTypeList.Value = "";
foreach (GameObject playerRagdoll in self.playerRagdolls)
{
string text = CleanRagdollName(((Object)playerRagdoll).name);
ConfigSettings.RagdollTypeList.Value = ((self.playerRagdolls.IndexOf(playerRagdoll) == 0) ? text : (ConfigSettings.RagdollTypeList.Value + ";" + text));
Main.Logger.LogDebug((object)$"{self.playerRagdolls.IndexOf(playerRagdoll)}: {text}");
}
UpdateRagdollTypeConfig();
Main.Logger.LogDebug((object)"Finished creating ragdoll list");
ragdollListCreated = true;
}
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);
char[] array = ragdollName.ToCharArray();
foreach (char c in array)
{
string text = c.ToString();
int num = ragdollName.IndexOf(text);
if (num != 0 && num != -1)
{
string text2 = ragdollName.ToUpper().ToCharArray().GetValue(num)
.ToString();
if (text2 == text)
{
string text3 = ragdollName.Substring(0, num);
string text4 = ragdollName;
int num2 = num;
ragdollName = text3 + " " + text4.Substring(num2, text4.Length - num2);
}
}
}
return ragdollName;
}
}
}
namespace Kill_Bind.Hooks.DependencyRelated
{
public class KillBindHandler : MonoBehaviour
{
internal static WaitForEndOfFrame waitForFrameEnd = new WaitForEndOfFrame();
private static GameNetworkManager? networkManager;
private static PlayerControllerB? player;
private static Terminal? terminal;
private static HUDManager? hudManagerInstance;
private static QuickMenuManager? quickmenuInstance;
public static void OnPressKillBind(CallbackContext callbackContext)
{
Main.Logger.LogDebug((object)"Keybind for KillBind has been pressed.");
networkManager = GameNetworkManager.Instance;
player = networkManager.localPlayerController;
terminal = Object.FindObjectOfType<Terminal>();
hudManagerInstance = HUDManager.Instance;
quickmenuInstance = player?.quickMenuManager;
if (((CallbackContext)(ref callbackContext)).performed && ConfigSettings.ModEnabled.Value && !((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)networkManager.localPlayerController) && !player.isPlayerDead && !StartOfRoundHooks.StartOfRoundInstance.inShipPhase && !((Object)(object)hudManagerInstance == (Object)null) && !((Behaviour)hudManagerInstance.typingIndicator).enabled && !player.isTypingChat && !((Object)(object)terminal == (Object)null) && (!terminal.terminalInUse || !player.inTerminalMenu) && !((Object)(object)quickmenuInstance == (Object)null) && !quickmenuInstance.isMenuOpen)
{
Main.Logger.LogDebug((object)"Passed KillBind's checks, attempting to kill after yielding until end of frame");
CoroutineHelper.Start(KillAfterYield(player));
}
}
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(Regex.Replace(ConfigSettings.RagdollType.Value, " ", "", RegexOptions.None)));
int num = ((!(ConfigSettings.RagdollType.Value == "Normal")) ? 1 : 0);
num = (((Object)(object)val != (Object)null) ? ragdollList.IndexOf(val) : num);
CauseOfDeath value = ConfigSettings.DeathCause.Value;
localPlayer.KillPlayer(localPlayer.thisController.velocity, true, value, num, default(Vector3));
Main.Logger.LogDebug((object)"Player should have died now");
Main.Logger.LogDebug((object)$"Ragdoll: {ConfigSettings.RagdollType.Value}, Ragdoll Int: {num}, CoD: {value}");
if (ToilHead.ToilHeadMod_Present && ConfigSettings.RagdollType.Value == "Spring")
{
Main.Logger.LogDebug((object)"Attempting to replace the ragdoll with a ToilHead variant");
ToilHead.CreateToilheadRagdoll(localPlayer);
}
}
}
public static class RegisterPlugin_LobbyCompatibility
{
private static void Activate()
{
PluginHelper.RegisterPlugin("KillBind.Confusified.com.GitHub", Version.Parse("2.3.3"), (CompatibilityLevel)0, (VersionStrictness)0);
}
}
public class SetupConfig_LethalConfig
{
public static bool LethalConfigFound;
private static void Activate()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
LethalConfigFound = true;
LethalConfigManager.SkipAutoGen();
BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(ConfigSettings.ModEnabled, new BoolCheckBoxOptions
{
Section = "Mod Settings",
Name = "Mod Enabled",
Description = "Determines whether the mod is enabled.",
RequiresRestart = false
});
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
EnumDropDownConfigItem<CauseOfDeath> val2 = new EnumDropDownConfigItem<CauseOfDeath>(ConfigSettings.DeathCause, new EnumDropDownOptions
{
Section = "Mod Settings",
Name = "Cause of Death",
Description = "Determines what the cause of death will be for your ragdoll.",
RequiresRestart = false
});
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
LethalConfigManager.SetModDescription("Become a ragdoll with just one button press");
}
public static void UpdateRagdollTypeDropdown()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_003c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
TextDropDownConfigItem val = new TextDropDownConfigItem(ConfigSettings.RagdollType, new TextDropDownOptions(Array.Empty<string>())
{
Section = "Mod Settings",
Name = "Type of Ragdoll",
Description = "Determines what ragdoll will be used.",
RequiresRestart = false
});
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
}
}
public class ToilHead
{
public static bool ToilHeadMod_Present = false;
public static float ToilSlayerRagdollChance = 10f;
internal static ConfigEntry<float> ToilPlayerSlayerChance = null;
internal static void CreateToilheadRagdoll(PlayerControllerB self)
{
bool flag = Utils.RandomPercent(ToilSlayerRagdollChance);
TurretHeadManager.SetDeadBodyTurretHead(self, flag);
}
private static void Activate()
{
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;
Main.Logger.LogDebug((object)$"Updated ToilSlayerRagdollChance to {ToilSlayerRagdollChance}");
ToilPlayerSlayerChance.SettingChanged += UpdateChanceValue;
return;
}
}
Main.Logger.LogDebug((object)$"Could not find ToilPlayerSlayerChance config setting. ToilSlayerRagdollChance will use the default value set by KillBind ({ToilSlayerRagdollChance})");
}
private static void UpdateChanceValue(object sender = null, EventArgs args = null)
{
ToilSlayerRagdollChance = ToilPlayerSlayerChance.Value;
Main.Logger.LogDebug((object)$"Updated ToilSlayerRagdollChance to {ToilSlayerRagdollChance}");
}
}
}
namespace Kill_Bind.Config
{
public class ConfigHandler
{
internal static ConfigDescription RagdollTypeDescription;
public static void InitialiseConfig()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
ConfigFile killbindConfig = Main.killbindConfig;
killbindConfig.SaveOnConfigSet = false;
ConfigSettings.RagdollTypeList = killbindConfig.Bind<string>("z Do Not Touch z", "Ragdoll List String", "Head Burst", "This is used to retain the config setting for the type of ragdoll. Editing this may cause issues");
ConfigSettings.ListRagdollType = new List<string>(Regex.Split(ConfigSettings.RagdollTypeList.Value, ";"));
RagdollTypeDescription = new ConfigDescription("Determines what ragdoll will be used.", (AcceptableValueBase)(object)new AcceptableValueList<string>(ConfigSettings.ListRagdollType.ToArray()), Array.Empty<object>());
ConfigSettings.ModEnabled = killbindConfig.Bind<bool>("Mod Settings", "Mod Enabled", true, "Determines whether the mod is enabled.");
ConfigSettings.DeathCause = killbindConfig.Bind<CauseOfDeath>("Mod Settings", "Cause of Death", (CauseOfDeath)0, "Determines what the cause of death will be for your ragdoll.");
ConfigSettings.RagdollType = killbindConfig.Bind<string>("Mod Settings", "Type of Ragdoll", "Head Burst", RagdollTypeDescription);
ClearOrphanedEntries(killbindConfig);
killbindConfig.Save();
killbindConfig.SaveOnConfigSet = true;
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
}
public class ConfigSettings
{
internal const string CONFIG_SECTION = "Mod Settings";
public const string DEFAULT_RAGDOLL_TYPE = "Head Burst";
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<string> RagdollType;
public static ConfigEntry<CauseOfDeath> DeathCause;
public static ConfigEntry<string> RagdollTypeList;
public static List<string> ListRagdollType;
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}