Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AssemblyName>BepInEx5Plugins.Ash.Alisa.Shortcuts</AssemblyName>
<Description>Shortcuts</Description>
<Version>1.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="5.6.7" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\lib\SteamRelease\Assembly-CSharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\lib\UnityEngine\UnityEngine.UI.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /Y /Q /C /I &quot;$(OutDir)&quot; &quot;..\$(OutDir)\$(TargetName)\&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -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<MusicPlayer>()?.StopMusic();

if (fadeOut)
{
GameObject.FindWithTag("FadeEffect")?.GetComponent<Animator>()?.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");
}
}
}
6 changes: 6 additions & 0 deletions BepInEx5Plugins.Ash.Alisa.Shortcuts/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>
55 changes: 55 additions & 0 deletions BepInEx5Plugins.Ash.Alisa.Shortcuts/Plugin.cs
Original file line number Diff line number Diff line change
@@ -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<bool> 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);
}
}
}
}