From 6c04c2f1f7d85b27d4777331196d0bc84a4e0fcb Mon Sep 17 00:00:00 2001 From: MyDragonBreath <38029594+MyDragonBreath@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:52:09 +1000 Subject: [PATCH] Repositions + Coroutine Changes --- MCI/Components/Debugger.cs | 2 +- MCI/Embedded/ReactorCoroutines/Coroutines.cs | 10 ++++++-- MCI/MCIPlugin.cs | 25 +++++++++++++++++++- MCI/Patches/Countdown.cs | 7 +++++- MCI/Patches/KeyboardJoystick.cs | 2 +- MCI/Patches/PingTracker.cs | 3 ++- 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/MCI/Components/Debugger.cs b/MCI/Components/Debugger.cs index fb59644..e9c1cb9 100644 --- a/MCI/Components/Debugger.cs +++ b/MCI/Components/Debugger.cs @@ -46,7 +46,7 @@ public Debugger(System.IntPtr ptr) : base(ptr) { Keyboard_Joystick.CreatePlayer(); } - GUILayout.Label("Hold F6 when pressing to bypass player limit."); + GUILayout.Label("Hold LftShft when pressing to bypass player limit."); if (GUILayout.Button("Remove Last Bot")) InstanceControl.RemovePlayer((byte)InstanceControl.Clients.Count); diff --git a/MCI/Embedded/ReactorCoroutines/Coroutines.cs b/MCI/Embedded/ReactorCoroutines/Coroutines.cs index ba60f2f..f8bb64e 100644 --- a/MCI/Embedded/ReactorCoroutines/Coroutines.cs +++ b/MCI/Embedded/ReactorCoroutines/Coroutines.cs @@ -28,14 +28,20 @@ private void OnDestroy() } } - private static readonly ConditionalWeakTable _ourCoroutineStore = new(); + internal static readonly ConditionalWeakTable _ourCoroutineStore = new(); + + internal static IEnumerator GenericRoutine(IEnumerator coroutine) + { + yield return coroutine; + _ourCoroutineStore.Remove(coroutine); + } [return: NotNullIfNotNull("coroutine")] public static IEnumerator? Start(IEnumerator? coroutine) { if (coroutine != null) { - _ourCoroutineStore.AddOrUpdate(coroutine, Component.Instance!.StartCoroutine(coroutine)); + _ourCoroutineStore.AddOrUpdate(coroutine, Component.Instance!.StartCoroutine(GenericRoutine(coroutine))); } return coroutine; diff --git a/MCI/MCIPlugin.cs b/MCI/MCIPlugin.cs index 28893ad..06d0110 100644 --- a/MCI/MCIPlugin.cs +++ b/MCI/MCIPlugin.cs @@ -1,4 +1,5 @@ using BepInEx; +using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; @@ -13,11 +14,12 @@ namespace MCI; [BepInDependency(SubmergedCompatibility.SUBMERGED_GUID, BepInDependency.DependencyFlags.SoftDependency)] public partial class MCIPlugin : BasePlugin { - public const string VersionString = "0.0.6"; + public const string VersionString = "0.0.7"; public static Version vVersion = new(VersionString); public Harmony Harmony { get; } = new(Id); public static MCIPlugin Singleton { get; private set; } = null; + internal static ManualLogSource Logger { get; private set; } public static string RobotName { get; set; } = "Bot"; @@ -31,6 +33,7 @@ public override void Load() { if (Singleton != null) return; + Logger = this.Log; Singleton = this; Harmony.PatchAll(); @@ -47,5 +50,25 @@ public override void Load() if (scene.name == "MainMenu") ModManager.Instance.ShowModStamp(); })); + + Logger.LogWarning($"\n-------------------------\n" + // Yellow stands out. + $"| MultiClientInstancing |\n" + + $"| |\n" + + $"| Developed By: |\n" + + $"| MyDragonBreath |\n" + + $"| WhichTwix |\n" + + $"| AlchlcDvl |\n" + + $"| lekillerdesgames |\n" + + $"-------------------------\n" + + $"| Controls: |\n" + + $"| F5: Add Players |\n" + + $"| + LSHIFT To Bypass 15|\n" + + $"| F6: Toggle Bot Removal|\n" + + $"| + LSHIFT IKWIDM |\n" + + $"| F9: Cycle Upwards |\n" + + $"| F10: Cycle Downwards |\n" + + $"| F11: Remove All |\n" + + $"| F1: Toggle Debugger |\n" + + $"-------------------------"); } } diff --git a/MCI/Patches/Countdown.cs b/MCI/Patches/Countdown.cs index 22c744b..971c216 100644 --- a/MCI/Patches/Countdown.cs +++ b/MCI/Patches/Countdown.cs @@ -1,9 +1,14 @@ using HarmonyLib; +using MCI.Embedded.ReactorCoroutines; +using System.Linq; namespace MCI.Patches; [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))] public static class CountdownPatch { - public static void Prefix(GameStartManager __instance) => __instance.countDownTimer = 0; + public static void Prefix(GameStartManager __instance) { + __instance.countDownTimer = 0; + if (Coroutines._ourCoroutineStore.Any(x => x.Value != null)) __instance.countDownTimer = 1; + } } diff --git a/MCI/Patches/KeyboardJoystick.cs b/MCI/Patches/KeyboardJoystick.cs index 000feeb..9b54098 100644 --- a/MCI/Patches/KeyboardJoystick.cs +++ b/MCI/Patches/KeyboardJoystick.cs @@ -49,7 +49,7 @@ internal static void CreatePlayer() { ControllingFigure = PlayerControl.LocalPlayer.PlayerId; - if (PlayerControl.AllPlayerControls.Count == 15 && !Input.GetKeyDown(KeyCode.F6)) + if (PlayerControl.AllPlayerControls.Count == 15 && !Input.GetKeyDown(KeyCode.LeftShift)) return; //press f6 and f5 to bypass limit InstanceControl.CleanUpLoad(); diff --git a/MCI/Patches/PingTracker.cs b/MCI/Patches/PingTracker.cs index 5f75344..2f2aec9 100644 --- a/MCI/Patches/PingTracker.cs +++ b/MCI/Patches/PingTracker.cs @@ -10,7 +10,8 @@ public static void Postfix(PingTracker __instance) { var position = __instance.GetComponent(); position.Alignment = AspectPosition.EdgeAlignments.Top; - position.DistanceFromEdge = new(3.6f, 0.1f, 0); + position.DistanceFromEdge = new(0f, 0.1f, 0); + //position.DistanceFromEdge = new(3.6f, 0.1f, 0); position.AdjustPosition(); __instance.text.text += "\nMCI v" + MCIPlugin.VersionString + ""; __instance.text.text += MCIPlugin.Enabled ? " [Active]" : " [InActive]";