From 82d076b87ddc91ff201c4fc7c9102bd6ac2703a4 Mon Sep 17 00:00:00 2001 From: Tianyi Cao Date: Tue, 6 Feb 2024 23:38:36 -0800 Subject: [PATCH] Add single player mode, enabled by default --- AquaMai/AquaMai.csproj | 3 ++- AquaMai/Main.cs | 1 + AquaMai/SinglePlayer.cs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 AquaMai/SinglePlayer.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 7fd4c82b..5800edb6 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -263,6 +263,7 @@ + - \ No newline at end of file + diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 79b646e5..d81b81e1 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -19,6 +19,7 @@ namespace AquaMai { MelonLogger.Msg("OnApplicationStart"); HarmonyLib.Harmony.CreateAndPatchAll(typeof(CutsceneSkipping)); + HarmonyLib.Harmony.CreateAndPatchAll(typeof(SinglePlayer)); } } } \ No newline at end of file diff --git a/AquaMai/SinglePlayer.cs b/AquaMai/SinglePlayer.cs new file mode 100644 index 00000000..e62018cc --- /dev/null +++ b/AquaMai/SinglePlayer.cs @@ -0,0 +1,30 @@ +using System; +using HarmonyLib; +using UnityEngine; + +namespace AquaMai { + // Hides the 2p (right hand side) UI. + // Note: this is not my original work. I simply interpreted the code and rewrote it as a mod. + public class SinglePlayer { + [HarmonyPrefix] + [HarmonyPatch(typeof(Main.GameMain), "LateInitialize", new Type[] { typeof(MonoBehaviour), typeof(Transform), typeof(Transform) })] + public static bool LateInitialize(MonoBehaviour gameMainObject, ref Transform left, ref Transform right) + { + left.transform.position = Vector3.zero; + right.localScale = Vector3.zero; + GameObject.Find("Mask").SetActive(false); + + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MeshButton), "IsPointInPolygon", new Type[] { typeof(Vector2[]), typeof(Vector2) })] + public static bool IsPointInPolygon(Vector2[] polygon, ref Vector2 point) + { + var screenWidth = Screen.width; + point = new Vector2(point.x - (screenWidth / 2), point.y); + + return true; + } + } +}