using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("forcequit2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("forcequit2")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("53a43671-3fec-47c5-be95-c588e35ae622")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.user.lethalcompany.forcequit", "Force Quit Mod", "2.9.2")]
[BepInProcess("Lethal Company.exe")]
public class ForceQuitMod : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__2_0;
public static UnityAction <>9__2_1;
public static UnityAction <>9__3_0;
internal void <AddMainMenuButton>b__2_0()
{
Debug.Log((object)"Force quit to desktop pressed from main menu!");
Process.GetCurrentProcess().Kill();
}
internal void <AddMainMenuButton>b__2_1()
{
Debug.Log((object)"Force quit to desktop pressed from main menu!");
Process.GetCurrentProcess().Kill();
}
internal void <AddPauseMenuButton>b__3_0()
{
Debug.Log((object)"Force quit to desktop pressed from pause menu!");
Process.GetCurrentProcess().Kill();
}
}
private readonly Harmony _harmony = new Harmony("com.user.lethalcompany.forcequit");
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Force Quit Mod loaded!");
_harmony.PatchAll(typeof(ForceQuitMod));
}
[HarmonyPatch(typeof(MenuManager), "Awake")]
[HarmonyPostfix]
public static void AddMainMenuButton(ref MenuManager __instance)
{
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Expected O, but got Unknown
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Expected O, but got Unknown
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Expected O, but got Unknown
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Expected O, but got Unknown
if ((Object)(object)__instance?.versionNumberText == (Object)null)
{
return;
}
Canvas componentInParent = ((Component)__instance.versionNumberText).GetComponentInParent<Canvas>();
if ((Object)(object)GameObject.Find("QuitToDesktopMainButton") != (Object)null)
{
return;
}
TextMeshProUGUI[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren<TextMeshProUGUI>();
Button val = null;
TextMeshProUGUI[] array = componentsInChildren;
foreach (TextMeshProUGUI val2 in array)
{
if (((TMP_Text)val2).text.Contains("Quit") && !((TMP_Text)val2).text.Contains("Quit to Desktop"))
{
val = ((Component)val2).GetComponentInParent<Button>();
if ((Object)(object)val != (Object)null)
{
break;
}
}
}
Vector2 val4 = default(Vector2);
if ((Object)(object)val != (Object)null)
{
GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject);
((Object)val3).name = "QuitToDesktopMainButton";
val3.transform.SetParent(((Component)componentInParent).transform, false);
val3.transform.SetAsLastSibling();
RectTransform component = val3.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(200f, 30f);
((Vector2)(ref val4))..ctor(0f, 0f);
component.pivot = val4;
Vector2 anchorMin = (component.anchorMax = val4);
component.anchorMin = anchorMin;
component.anchoredPosition = new Vector2(20f, 5f);
TMP_Text componentInChildren = val3.GetComponentInChildren<TMP_Text>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.text = "> Quit to Desktop";
}
Button component2 = val3.GetComponent<Button>();
if ((Object)(object)component2 != (Object)null)
{
((UnityEventBase)component2.onClick).RemoveAllListeners();
ButtonClickedEvent onClick = component2.onClick;
object obj = <>c.<>9__2_0;
if (obj == null)
{
UnityAction val6 = delegate
{
Debug.Log((object)"Force quit to desktop pressed from main menu!");
Process.GetCurrentProcess().Kill();
};
<>c.<>9__2_0 = val6;
obj = (object)val6;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
}
else
{
GameObject val3 = new GameObject("QuitToDesktopMainButton");
RectTransform val7 = val3.AddComponent<RectTransform>();
Button val8 = val3.AddComponent<Button>();
ButtonClickedEvent onClick2 = val8.onClick;
object obj2 = <>c.<>9__2_1;
if (obj2 == null)
{
UnityAction val9 = delegate
{
Debug.Log((object)"Force quit to desktop pressed from main menu!");
Process.GetCurrentProcess().Kill();
};
<>c.<>9__2_1 = val9;
obj2 = (object)val9;
}
((UnityEvent)onClick2).AddListener((UnityAction)obj2);
val3.transform.SetParent(((Component)componentInParent).transform, false);
val3.transform.SetAsLastSibling();
val7.sizeDelta = new Vector2(200f, 30f);
((Vector2)(ref val4))..ctor(0f, 0f);
val7.pivot = val4;
Vector2 anchorMin = (val7.anchorMax = val4);
val7.anchorMin = anchorMin;
val7.anchoredPosition = new Vector2(20f, 5f);
GameObject val11 = new GameObject("QuitToDesktopLabel");
RectTransform val12 = val11.AddComponent<RectTransform>();
TextMeshProUGUI val13 = val11.AddComponent<TextMeshProUGUI>();
val11.transform.SetParent(val3.transform, false);
val12.sizeDelta = Vector2.zero;
val12.anchorMin = Vector2.zero;
val12.anchorMax = Vector2.one;
val12.offsetMin = Vector2.zero;
val12.offsetMax = Vector2.zero;
((TMP_Text)val13).text = "> Quit to Desktop";
((TMP_Text)val13).fontSize = 12f;
((TMP_Text)val13).alignment = (TextAlignmentOptions)513;
((Graphic)val13).color = new Color(1f, 0.6f, 0f, 1f);
}
Debug.Log((object)"Main menu force quit button added successfully!");
}
[HarmonyPatch(typeof(QuickMenuManager), "Start")]
[HarmonyPostfix]
public static void AddPauseMenuButton(ref QuickMenuManager __instance)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Expected O, but got Unknown
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Expected O, but got Unknown
GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu/");
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"Could not find QuickMenu object!");
return;
}
TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>();
TextMeshProUGUI val2 = null;
TextMeshProUGUI[] array = componentsInChildren;
foreach (TextMeshProUGUI val3 in array)
{
if (((TMP_Text)val3).text.Contains("Quit") && !((TMP_Text)val3).text.Contains("Quit to Desktop"))
{
val2 = val3;
break;
}
}
if ((Object)(object)val2 == (Object)null)
{
Debug.LogWarning((object)"Could not find Quit text in pause menu!");
}
else
{
if ((Object)(object)GameObject.Find("QuitToDesktopTextPause") != (Object)null)
{
return;
}
GameObject val4 = new GameObject("QuitToDesktopTextPause");
RectTransform val5 = val4.AddComponent<RectTransform>();
val4.transform.SetParent(((TMP_Text)val2).transform.parent, false);
RectTransform component = ((Component)val2).GetComponent<RectTransform>();
val5.sizeDelta = component.sizeDelta;
val5.anchorMin = component.anchorMin;
val5.anchorMax = component.anchorMax;
val5.pivot = component.pivot;
val5.anchoredPosition = component.anchoredPosition + new Vector2(0f, -30f);
GameObject val6 = new GameObject("HoverBackground");
RectTransform val7 = val6.AddComponent<RectTransform>();
Image val8 = val6.AddComponent<Image>();
val6.transform.SetParent(val4.transform, false);
val6.transform.SetAsFirstSibling();
val7.anchorMin = Vector2.zero;
val7.anchorMax = Vector2.one;
val7.sizeDelta = Vector2.zero;
val7.anchoredPosition = Vector2.zero;
((Graphic)val8).color = new Color(1f, 0.6f, 0f, 0f);
GameObject val9 = new GameObject("Text");
RectTransform val10 = val9.AddComponent<RectTransform>();
TextMeshProUGUI val11 = val9.AddComponent<TextMeshProUGUI>();
val9.transform.SetParent(val4.transform, false);
val10.anchorMin = Vector2.zero;
val10.anchorMax = Vector2.one;
val10.sizeDelta = Vector2.zero;
val10.anchoredPosition = Vector2.zero;
((TMP_Text)val11).text = "> Quit to Desktop";
((TMP_Text)val11).font = ((TMP_Text)val2).font;
((TMP_Text)val11).fontSize = ((TMP_Text)val2).fontSize;
((Graphic)val11).color = ((Graphic)val2).color;
((TMP_Text)val11).alignment = ((TMP_Text)val2).alignment;
((TMP_Text)val11).fontStyle = ((TMP_Text)val2).fontStyle;
Button val12 = val4.AddComponent<Button>();
((Selectable)val12).targetGraphic = (Graphic)(object)val8;
((Selectable)val12).transition = (Transition)1;
ColorBlock colors = default(ColorBlock);
((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0f);
((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.6f, 0f, 0.3f);
((ColorBlock)(ref colors)).pressedColor = new Color(1f, 0.6f, 0f, 0.5f);
((ColorBlock)(ref colors)).selectedColor = new Color(1f, 0.6f, 0f, 0.3f);
((ColorBlock)(ref colors)).disabledColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
((ColorBlock)(ref colors)).colorMultiplier = 1f;
((ColorBlock)(ref colors)).fadeDuration = 0.1f;
((Selectable)val12).colors = colors;
ButtonClickedEvent onClick = val12.onClick;
object obj = <>c.<>9__3_0;
if (obj == null)
{
UnityAction val13 = delegate
{
Debug.Log((object)"Force quit to desktop pressed from pause menu!");
Process.GetCurrentProcess().Kill();
};
<>c.<>9__3_0 = val13;
obj = (object)val13;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
Debug.Log((object)"Pause menu force quit text added successfully!");
}
}
[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
[HarmonyPostfix]
public static void EnsureTextVisible(ref QuickMenuManager __instance)
{
if (__instance.isMenuOpen)
{
GameObject val = GameObject.Find("QuitToDesktopPauseButton");
if ((Object)(object)val != (Object)null)
{
val.SetActive(true);
}
}
}
}