Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of RageQuitButton v1.0.0
RageQuitButton.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; 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 = ".NET Framework 4.6")] [assembly: AssemblyCompany("RageQuitButton")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("RAGE QUIT!")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RageQuitButton")] [assembly: AssemblyTitle("RageQuitButton")] [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 MyFirstBoplPlugin { public static class PluginInfo { public const string PLUGIN_GUID = "RageQuitButton"; public const string PLUGIN_NAME = "RageQuitButton"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace RageQuitButton { [BepInPlugin("com.Melon.RageQuitButton", "RageQuitButton", "1.0.0")] public class RageQuitButton : BaseUnityPlugin { public class Patches { public static void ShowRageQuitPopup() { ShowPopup("Rage quit?", "Do you want to rage quit?", delegate { Application.Quit(); }); } private static void ShowPopup(string title, string text, Action onClose) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("Popup"); Popup popup = val.AddComponent<Popup>(); popup.title = title; popup.text = text; popup.onClose = onClose; } } public class Popup : MonoBehaviour { public string title; public string text; public int width = 300; public int textOffset = 20; public Rect okbutton = new Rect(0f, 0f, 75f, 20f); public Action onClose; private void OnGUI() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle { alignment = (TextAnchor)3 }; int num = (int)val.CalcHeight(new GUIContent(text), (float)width); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor((float)(Screen.width / 2 - width / 2), (float)(Screen.height / 2 - num / 2), (float)width, (float)(num + textOffset) + ((Rect)(ref okbutton)).height); Rect val3 = val2; ((Rect)(ref val3)).y = ((Rect)(ref val3)).y + (float)textOffset; ((Rect)(ref val3)).height = ((Rect)(ref val3)).height - ((float)textOffset + ((Rect)(ref okbutton)).height); ((Rect)(ref val2)).width = ((Rect)(ref val2)).width + 40f; ((Rect)(ref val2)).x = ((Rect)(ref val2)).x - 20f; ((Rect)(ref okbutton)).x = ((Rect)(ref val2)).x + ((Rect)(ref val2)).width - ((Rect)(ref okbutton)).width - 10f; ((Rect)(ref okbutton)).y = ((Rect)(ref val2)).y + ((Rect)(ref val2)).height - ((Rect)(ref okbutton)).height - 10f; Color backgroundColor = default(Color); ((Color)(ref backgroundColor))..ctor(0f, 1f, 1f); backgroundColor.a = 1f; GUI.backgroundColor = backgroundColor; GUI.Box(val2, title); GUI.color = Color.white; GUI.TextField(val3, text, val); if (GUI.Button(okbutton, "OK")) { Object.Destroy((Object)(object)((Component)this).gameObject); onClose?.Invoke(); } } } public void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RageQuitButton is loaded!"); Harmony val = new Harmony("com.Melon.RageQuitButton"); MethodInfo methodInfo = AccessTools.Method(typeof(Player), "Kill", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), "ShowRageQuitPopup", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } namespace MiniJSON { public static class Json { private sealed class Parser : IDisposable { private enum TOKEN { NONE, CURLY_OPEN, CURLY_CLOSE, SQUARED_OPEN, SQUARED_CLOSE, COLON, COMMA, STRING, NUMBER, TRUE, FALSE, NULL } private const string WORD_BREAK = "{}[],:\""; private const string HEX_DIGIT = "0123456789ABCDEFabcdef"; private StringReader json; private char PeekChar => Convert.ToChar(json.Peek()); private char NextChar => Convert.ToChar(json.Read()); private string NextWord { get { StringBuilder stringBuilder = new StringBuilder(); while (!IsWordBreak(PeekChar)) { stringBuilder.Append(NextChar); if (json.Peek() == -1) { break; } } return stringBuilder.ToString(); } } private TOKEN NextToken { get { EatWhitespace(); if (json.Peek() == -1) { return TOKEN.NONE; } switch (PeekChar) { case '{': return TOKEN.CURLY_OPEN; case '}': json.Read(); return TOKEN.CURLY_CLOSE; case '[': return TOKEN.SQUARED_OPEN; case ']': json.Read(); return TOKEN.SQUARED_CLOSE; case ',': json.Read(); return TOKEN.COMMA; case '"': return TOKEN.STRING; case ':': return TOKEN.COLON; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return TOKEN.NUMBER; default: return NextWord switch { "false" => TOKEN.FALSE, "true" => TOKEN.TRUE, "null" => TOKEN.NULL, _ => TOKEN.NONE, }; } } } public static bool IsWordBreak(char c) { return char.IsWhiteSpace(c) || "{}[],:\"".IndexOf(c) != -1; } public static bool IsHexDigit(char c) { return "0123456789ABCDEFabcdef".IndexOf(c) != -1; } private Parser(string jsonString) { json = new StringReader(jsonString); } public static object Parse(string jsonString) { using Parser parser = new Parser(jsonString); return parser.ParseValue(); } public void Dispose() { json.Dispose(); json = null; } private Dictionary<string, object> ParseObject() { Dictionary<string, object> dictionary = new Dictionary<string, object>(); json.Read(); while (true) { string text; object obj; switch (NextToken) { case TOKEN.NONE: return null; case TOKEN.CURLY_CLOSE: return dictionary; case TOKEN.STRING: { text = ParseString(); if (text == null) { return null; } if (NextToken != TOKEN.COLON) { return null; } json.Read(); TOKEN nextToken = NextToken; obj = ParseByToken(nextToken); if (obj == null && nextToken != TOKEN.NULL) { return null; } goto IL_00ba; } default: return null; case TOKEN.COMMA: break; } continue; IL_00ba: dictionary[text] = obj; } } private List<object> ParseArray() { List<object> list = new List<object>(); json.Read(); bool flag = true; while (flag) { TOKEN nextToken = NextToken; switch (nextToken) { case TOKEN.NONE: return null; case TOKEN.SQUARED_CLOSE: flag = false; continue; case TOKEN.COMMA: continue; } object obj = ParseByToken(nextToken); if (obj == null && nextToken != TOKEN.NULL) { return null; } list.Add(obj); } return list; } private object ParseValue() { TOKEN nextToken = NextToken; return ParseByToken(nextToken); } private object ParseByToken(TOKEN token) { return token switch { TOKEN.STRING => ParseString(), TOKEN.NUMBER => ParseNumber(), TOKEN.CURLY_OPEN => ParseObject(), TOKEN.SQUARED_OPEN => ParseArray(), TOKEN.TRUE => true, TOKEN.FALSE => false, TOKEN.NULL => null, _ => null, }; } private string ParseString() { StringBuilder stringBuilder = new StringBuilder(); json.Read(); bool flag = true; while (flag) { if (json.Peek() == -1) { flag = false; break; } char nextChar = NextChar; switch (nextChar) { case '"': flag = false; break; case '\\': if (json.Peek() == -1) { flag = false; break; } nextChar = NextChar; switch (nextChar) { case '"': case '/': case '\\': stringBuilder.Append(nextChar); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': { char[] array = new char[4]; for (int i = 0; i < 4; i++) { array[i] = NextChar; if (!IsHexDigit(array[i])) { return null; } } stringBuilder.Append((char)Convert.ToInt32(new string(array), 16)); break; } } break; default: stringBuilder.Append(nextChar); break; } } return stringBuilder.ToString(); } private object ParseNumber() { string nextWord = NextWord; if (nextWord.IndexOf('.') == -1 && nextWord.IndexOf('E') == -1 && nextWord.IndexOf('e') == -1) { long.TryParse(nextWord, NumberStyles.Any, CultureInfo.InvariantCulture, out var result); return result; } double.TryParse(nextWord, NumberStyles.Any, CultureInfo.InvariantCulture, out var result2); return result2; } private void EatWhitespace() { while (char.IsWhiteSpace(PeekChar)) { json.Read(); if (json.Peek() == -1) { break; } } } } private sealed class Serializer { private StringBuilder builder; private Serializer() { builder = new StringBuilder(); } public static string Serialize(object obj) { Serializer serializer = new Serializer(); serializer.SerializeValue(obj); return serializer.builder.ToString(); } private void SerializeValue(object value) { if (value == null) { builder.Append("null"); } else if (value is string str) { SerializeString(str); } else if (value is bool) { builder.Append(((bool)value) ? "true" : "false"); } else if (value is IList anArray) { SerializeArray(anArray); } else if (value is IDictionary obj) { SerializeObject(obj); } else if (value is char) { SerializeString(new string((char)value, 1)); } else { SerializeOther(value); } } private void SerializeObject(IDictionary obj) { bool flag = true; builder.Append('{'); foreach (object key in obj.Keys) { if (!flag) { builder.Append(','); } SerializeString(key.ToString()); builder.Append(':'); SerializeValue(obj[key]); flag = false; } builder.Append('}'); } private void SerializeArray(IList anArray) { builder.Append('['); bool flag = true; for (int i = 0; i < anArray.Count; i++) { object value = anArray[i]; if (!flag) { builder.Append(','); } SerializeValue(value); flag = false; } builder.Append(']'); } private void SerializeString(string str) { builder.Append('"'); char[] array = str.ToCharArray(); foreach (char c in array) { switch (c) { case '"': builder.Append("\\\""); continue; case '\\': builder.Append("\\\\"); continue; case '\b': builder.Append("\\b"); continue; case '\f': builder.Append("\\f"); continue; case '\n': builder.Append("\\n"); continue; case '\r': builder.Append("\\r"); continue; case '\t': builder.Append("\\t"); continue; } int num = Convert.ToInt32(c); if (num >= 32 && num <= 126) { builder.Append(c); continue; } builder.Append("\\u"); builder.Append(num.ToString("x4")); } builder.Append('"'); } private void SerializeOther(object value) { if (value is float) { builder.Append(((float)value).ToString("R", CultureInfo.InvariantCulture)); } else if (value is int || value is uint || value is long || value is sbyte || value is byte || value is short || value is ushort || value is ulong) { builder.Append(value); } else if (value is double || value is decimal) { builder.Append(Convert.ToDouble(value).ToString("R", CultureInfo.InvariantCulture)); } else { SerializeString(value.ToString()); } } } public static object Deserialize(string json) { if (json == null) { return null; } return Parser.Parse(json); } public static string Serialize(object obj) { return Serializer.Serialize(obj); } } }