From 1c4dd32ea8cb3c0711f13f33afb4819fc6b71cbf Mon Sep 17 00:00:00 2001 From: DragonFire47 <46509577+DragonFire47@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:25:15 -0700 Subject: [PATCH] Added config for delays --- AutomaticShipSystems/Configs.cs | 12 ++++++++---- AutomaticShipSystems/EnhancementPatch.cs | 4 ++-- AutomaticShipSystems/GUI.cs | 16 ++++++++++++---- AutomaticShipSystems/PowerBreakerPatch.cs | 4 ++-- AutomaticShipSystems/ThrusterBoosterPatch.cs | 4 ++-- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/AutomaticShipSystems/Configs.cs b/AutomaticShipSystems/Configs.cs index 3933e44..247371a 100644 --- a/AutomaticShipSystems/Configs.cs +++ b/AutomaticShipSystems/Configs.cs @@ -4,19 +4,23 @@ namespace AutomaticShipSystems { internal class Configs { - internal const double CircuitBreakerDelay = 30 * 1000; - internal const double ThrusterBoosterDelay = 60 * 1000; - internal const double TrimDelay = 5 * 60 * 1000; - internal static ConfigEntry CircuitBreakerConfig; internal static ConfigEntry ThrusterBoosterConfig; internal static ConfigEntry TrimConfig; + internal static ConfigEntry CircuitBreakerDelay; + internal static ConfigEntry ThrusterBoosterDelay; + internal static ConfigEntry TrimDelay; + internal static void Load(BepinPlugin plugin) { CircuitBreakerConfig = plugin.Config.Bind("AutomaticShipSystems", "CircuitBreakers", true); ThrusterBoosterConfig = plugin.Config.Bind("AutomaticShipSystems", "ThrusterBooster", true); TrimConfig = plugin.Config.Bind("AutomaticShipSystems", "Trim", true); + + CircuitBreakerDelay = plugin.Config.Bind("AutomaticShipSystems", "CircuitBreakersTimer", (double)(30 * 1000)); + ThrusterBoosterDelay = plugin.Config.Bind("AutomaticShipSystems", "ThrusterBoosterTimer", (double)(60 * 1000)); + TrimDelay = plugin.Config.Bind("AutomaticShipSystems", "TrimTimer", (double)(5 * 60 * 1000)); } } } diff --git a/AutomaticShipSystems/EnhancementPatch.cs b/AutomaticShipSystems/EnhancementPatch.cs index d39bedc..6567046 100644 --- a/AutomaticShipSystems/EnhancementPatch.cs +++ b/AutomaticShipSystems/EnhancementPatch.cs @@ -28,7 +28,7 @@ namespace AutomaticShipSystems ClientGame.Current?.PlayerShip?.GetModule()?.Engine?.GetComponentsInChildren()?.Contains(__instance) == true && newState == EnhancementState.Inactive) { - Tools.DelayDoUnique(__instance, () => ResetTrim(__instance), Configs.TrimDelay); + Tools.DelayDoUnique(__instance, () => ResetTrim(__instance), Configs.TrimDelay.Value); } } @@ -55,7 +55,7 @@ namespace AutomaticShipSystems { if (trim.CurrentState.Value == EnhancementState.Inactive) { - Tools.DelayDoUnique(trim, () => ResetTrim(trim), Configs.TrimDelay); + Tools.DelayDoUnique(trim, () => ResetTrim(trim), Configs.TrimDelay.Value); } } } diff --git a/AutomaticShipSystems/GUI.cs b/AutomaticShipSystems/GUI.cs index 057d5c9..638f133 100644 --- a/AutomaticShipSystems/GUI.cs +++ b/AutomaticShipSystems/GUI.cs @@ -1,4 +1,5 @@ -using VoidManager.CustomGUI; +using UnityEngine; +using VoidManager.CustomGUI; using VoidManager.Utilities; namespace AutomaticShipSystems @@ -9,9 +10,16 @@ namespace AutomaticShipSystems public override void Draw() { - GUITools.DrawCheckbox("Circuit Breakers", ref Configs.CircuitBreakerConfig); - GUITools.DrawCheckbox("Thruster Boosters", ref Configs.ThrusterBoosterConfig); - GUITools.DrawCheckbox("Trims", ref Configs.TrimConfig); + GUILayout.Label("Timers in MS. 1000 is equal to 1 second.\n"); + + GUITools.DrawCheckbox("Auto Circuit Breakers Enabled", ref Configs.CircuitBreakerConfig); + GUITools.DrawTextField("Circut Breaker Timer", ref Configs.CircuitBreakerDelay); + GUILayout.Label(string.Empty); + GUITools.DrawCheckbox("Auto Thruster Boosters Enabled", ref Configs.ThrusterBoosterConfig); + GUITools.DrawTextField("Thruster Booster Timer", ref Configs.ThrusterBoosterDelay); + GUILayout.Label(string.Empty); + GUITools.DrawCheckbox("Auto Trims Enabled", ref Configs.TrimConfig); + GUITools.DrawTextField("Trim Timer", ref Configs.TrimDelay); } } } diff --git a/AutomaticShipSystems/PowerBreakerPatch.cs b/AutomaticShipSystems/PowerBreakerPatch.cs index 22d0755..acee96c 100644 --- a/AutomaticShipSystems/PowerBreakerPatch.cs +++ b/AutomaticShipSystems/PowerBreakerPatch.cs @@ -25,7 +25,7 @@ namespace AutomaticShipSystems if (!isOn && Configs.CircuitBreakerConfig.Value) { - Tools.DelayDoUnique(__instance, () => ResetCircuitBreakers(__instance), Configs.CircuitBreakerDelay); + Tools.DelayDoUnique(__instance, () => ResetCircuitBreakers(__instance), Configs.CircuitBreakerDelay.Value); } } @@ -49,7 +49,7 @@ namespace AutomaticShipSystems { if (!powerBreaker.IsOn.Value) { - Tools.DelayDoUnique(powerBreaker, () => powerBreaker.IsOn.RequestChange(true), Configs.CircuitBreakerDelay); + Tools.DelayDoUnique(powerBreaker, () => powerBreaker.IsOn.RequestChange(true), Configs.CircuitBreakerDelay.Value); } } } diff --git a/AutomaticShipSystems/ThrusterBoosterPatch.cs b/AutomaticShipSystems/ThrusterBoosterPatch.cs index eb6fce5..66b8faf 100644 --- a/AutomaticShipSystems/ThrusterBoosterPatch.cs +++ b/AutomaticShipSystems/ThrusterBoosterPatch.cs @@ -29,7 +29,7 @@ namespace AutomaticShipSystems if (state == ThrusterBoosterState.Off && Configs.ThrusterBoosterConfig.Value) { - Tools.DelayDoUnique(__instance, () => ChargeThrusterBooster(__instance), Configs.ThrusterBoosterDelay); + Tools.DelayDoUnique(__instance, () => ChargeThrusterBooster(__instance), Configs.ThrusterBoosterDelay.Value); } } @@ -56,7 +56,7 @@ namespace AutomaticShipSystems { if (booster.State == ThrusterBoosterState.Off) { - Tools.DelayDoUnique(booster, () => ChargeThrusterBooster(booster), Configs.ThrusterBoosterDelay); + Tools.DelayDoUnique(booster, () => ChargeThrusterBooster(booster), Configs.ThrusterBoosterDelay.Value); } } }