diff --git a/BepInEx5Plugins.Ash.Alisa.Shortcuts/BepInEx5Plugins.Ash.Alisa.Shortcuts.csproj b/BepInEx5Plugins.Ash.Alisa.Shortcuts/BepInEx5Plugins.Ash.Alisa.Shortcuts.csproj new file mode 100644 index 0000000..9c3db05 --- /dev/null +++ b/BepInEx5Plugins.Ash.Alisa.Shortcuts/BepInEx5Plugins.Ash.Alisa.Shortcuts.csproj @@ -0,0 +1,37 @@ + + + + net35 + BepInEx5Plugins.Ash.Alisa.Shortcuts + Shortcuts + 1.0.0 + true + 9.0 + + + + + + + + + + + + + + + + ..\lib\SteamRelease\Assembly-CSharp.dll + false + + + ..\lib\UnityEngine\UnityEngine.UI.dll + false + + + + + + + diff --git a/BepInEx5Plugins.Ash.Alisa.Shortcuts/HarmonyPatches/Settings_Update.cs b/BepInEx5Plugins.Ash.Alisa.Shortcuts/HarmonyPatches/Settings_Update.cs new file mode 100644 index 0000000..a748c24 --- /dev/null +++ b/BepInEx5Plugins.Ash.Alisa.Shortcuts/HarmonyPatches/Settings_Update.cs @@ -0,0 +1,62 @@ +using HarmonyLib; +using System.Collections; +using UnityEngine; +using UnityEngine.SceneManagement; +using Object = UnityEngine.Object; + +namespace BepInEx5Plugins.Ash.Alisa.Shortcuts.HarmonyPatches +{ + [HarmonyPatch(typeof(Settings), "Update")] + public class Settings_Update + { + public static bool fadeOut = true; + + private static bool locked = false; + + // Quit game upon pressing a combination of keys. + private static bool Prefix(Settings __instance) + { + if (!locked + && Input.GetKey(__instance.keys["Action"]) + && Input.GetKey(__instance.keys["Sprint"]) + && Input.GetKey(__instance.keys["Cancel"]) + && Input.GetKey(__instance.keys["SwitchWeapon"]) + && Input.GetKey(__instance.keys["Submit"]) + && Input.GetKey(__instance.keys["Select"])) + { + locked = true; + + __instance.StartCoroutine(QuitGame()); + + return false; + } + + return true; + } + + private static IEnumerator QuitGame() + { + GameObject.FindWithTag("MusicPlayer")?.GetComponent()?.StopMusic(); + + if (fadeOut) + { + GameObject.FindWithTag("FadeEffect")?.GetComponent()?.SetBool("Fade", true); + + yield return new WaitForSeconds(1.5f); + } + + Camera.main.gameObject.SetActive(false); + + Object.Destroy(GameObject.FindWithTag("MusicPlayer")); + Object.Destroy(ProgressManager.instance.gameObject); + Object.Destroy(GameObject.FindWithTag("Player")); + Object.Destroy(GameObject.FindWithTag("PlayerUIHolder")); + Object.Destroy(GameObject.FindWithTag("RenderTextureSet")); + Object.Destroy(GameObject.Find("MakeUpSet")); + + locked = false; + + SceneManager.LoadScene("InfoSplashScreen"); + } + } +} diff --git a/BepInEx5Plugins.Ash.Alisa.Shortcuts/NuGet.Config b/BepInEx5Plugins.Ash.Alisa.Shortcuts/NuGet.Config new file mode 100644 index 0000000..1864ded --- /dev/null +++ b/BepInEx5Plugins.Ash.Alisa.Shortcuts/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/BepInEx5Plugins.Ash.Alisa.Shortcuts/Plugin.cs b/BepInEx5Plugins.Ash.Alisa.Shortcuts/Plugin.cs new file mode 100644 index 0000000..a1ef3de --- /dev/null +++ b/BepInEx5Plugins.Ash.Alisa.Shortcuts/Plugin.cs @@ -0,0 +1,55 @@ +using BepInEx; +using BepInEx.Configuration; +using HarmonyLib; +using System; + +namespace BepInEx5Plugins.Ash.Alisa.Shortcuts +{ + [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] + public class Plugin : BaseUnityPlugin + { + private static ConfigEntry fadeOut; + + private Plugin() + { + try + { + fadeOut = Config.Bind("Quick Quit Game", "Fade Out", true); + + Config.SettingChanged += Config_SettingChanged; + + ApplySettings(); + } + catch (Exception exception) + { + Console.WriteLine(exception); + } + } + + private static void Config_SettingChanged(object sender, EventArgs e) + { + ApplySettings(); + } + + private static void ApplySettings() + { + HarmonyPatches.Settings_Update.fadeOut = fadeOut.Value; + } + + private void Awake() + { + try + { + Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!"); + + var harmony = new Harmony(Info.Metadata.GUID); + + harmony.PatchAll(); + } + catch (Exception exception) + { + Console.WriteLine(exception); + } + } + } +}