From ab3c06afeebb8b8142fa4fb12d8edeb3f85526db Mon Sep 17 00:00:00 2001 From: Shadnix Date: Sun, 25 Oct 2020 21:11:00 +0100 Subject: [PATCH] Fixed unpause unintentionally enabling saber trails again --- HarmonyPatches/Patches/SaberTrailInit.cs | 10 ++--- .../Patches/SaberTrailRendererOnEnable.cs | 19 ++++++++ Plugin.cs | 5 --- Properties/AssemblyInfo.cs | 4 +- SaberTailor.csproj | 2 +- Tweaks/SaberTrailTweak.cs | 45 ------------------- manifest.json | 2 +- 7 files changed, 28 insertions(+), 59 deletions(-) create mode 100644 HarmonyPatches/Patches/SaberTrailRendererOnEnable.cs delete mode 100644 Tweaks/SaberTrailTweak.cs diff --git a/HarmonyPatches/Patches/SaberTrailInit.cs b/HarmonyPatches/Patches/SaberTrailInit.cs index aa751df..1ba36c6 100644 --- a/HarmonyPatches/Patches/SaberTrailInit.cs +++ b/HarmonyPatches/Patches/SaberTrailInit.cs @@ -9,13 +9,13 @@ internal class SaberTrailInit { private static void Prefix(SaberTrail __instance, ref float ____trailDuration, ref int ____granularity, ref float ____whiteSectionMaxDuration) { - if (!Configuration.Trail.TweakEnabled) + if (Configuration.Trail.TweakEnabled && Configuration.Trail.TrailEnabled) { - return; + ____trailDuration = Configuration.Trail.Duration / 1000f; + ____granularity = Configuration.Trail.Granularity; + ____whiteSectionMaxDuration = Configuration.Trail.WhiteSectionDuration / 1000f; + Logger.log.Info("Successfully modified trails!"); } - ____trailDuration = Configuration.Trail.Duration / 1000f; - ____granularity = Configuration.Trail.Granularity; - ____whiteSectionMaxDuration = Configuration.Trail.WhiteSectionDuration / 1000f; } } } diff --git a/HarmonyPatches/Patches/SaberTrailRendererOnEnable.cs b/HarmonyPatches/Patches/SaberTrailRendererOnEnable.cs new file mode 100644 index 0000000..300a5a8 --- /dev/null +++ b/HarmonyPatches/Patches/SaberTrailRendererOnEnable.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using SaberTailor.Settings; + +namespace SaberTailor.HarmonyPatches.Patches +{ + [HarmonyPatch(typeof(SaberTrailRenderer))] + [HarmonyPatch("OnEnable")] + internal class SaberTrailRendererOnEnable + { + private static void Postfix(SaberTrailRenderer __instance) + { + if (Configuration.Trail.TweakEnabled && !Configuration.Trail.TrailEnabled) + { + __instance.enabled = false; + Logger.log.Info("Successfully disabled trails!"); + } + } + } +} diff --git a/Plugin.cs b/Plugin.cs index dd7994f..239a349 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -42,11 +42,6 @@ public void OnActiveSceneChanged(Scene prevScene, Scene nextScene) { if (nextScene.name == "GameCore") { - if (Configuration.Trail.TweakEnabled) - { - new GameObject(PluginName).AddComponent(); - } - if (Configuration.Scale.TweakEnabled) { new GameObject(PluginName).AddComponent(); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index f40ef74..b6b8b0b 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -13,5 +13,5 @@ [assembly: ComVisible(false)] [assembly: Guid("a2d66447-9928-4292-9a82-87abbaa401ff")] -[assembly: AssemblyVersion("3.0.2")] -[assembly: AssemblyFileVersion("3.0.2")] +[assembly: AssemblyVersion("3.0.3")] +[assembly: AssemblyFileVersion("3.0.3")] diff --git a/SaberTailor.csproj b/SaberTailor.csproj index fb2a783..7c1428b 100644 --- a/SaberTailor.csproj +++ b/SaberTailor.csproj @@ -35,6 +35,7 @@ + @@ -55,7 +56,6 @@ - diff --git a/Tweaks/SaberTrailTweak.cs b/Tweaks/SaberTrailTweak.cs deleted file mode 100644 index 61005c8..0000000 --- a/Tweaks/SaberTrailTweak.cs +++ /dev/null @@ -1,45 +0,0 @@ -using IPA.Utilities; -using SaberTailor.Settings; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace SaberTailor.Tweaks -{ - public class SaberTrailTweak : MonoBehaviour - { - public static string Name => "SaberTrail"; - public static bool IsPreventingScoreSubmission => false; - -#pragma warning disable IDE0051 // Used by MonoBehaviour - private void Awake() => Load(); -#pragma warning restore IDE0051 // Used by MonoBehaviour - - private void Load() - { - StartCoroutine(ApplyGameCoreModifications()); - } - - private IEnumerator ApplyGameCoreModifications() - { - yield return new WaitForSeconds(0.1f); - - IEnumerable saberTrailRenderers = Resources.FindObjectsOfTypeAll(); - foreach (SaberTrailRenderer saberTrailRenderer in saberTrailRenderers) - { - ModifyTrail(saberTrailRenderer, Configuration.Trail.Duration, Configuration.Trail.Granularity, Configuration.Trail.WhiteSectionDuration); - Logger.log.Info("Successfully modified trails!"); - } - - yield return null; - } - - private void ModifyTrail(SaberTrailRenderer trail, int duration, int granularity, int whiteSectionDuration) - { - if (!Configuration.Trail.TrailEnabled) - { - trail.enabled = false; - } - } - } -} diff --git a/manifest.json b/manifest.json index 570978e..9ae83c2 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "icon": "SaberTailor.Resources.icon.png", "id": "SaberTailor", "name": "SaberTailor", - "version": "3.0.2", + "version": "3.0.3", "dependsOn": { "BSIPA": "^4.0.0", "BeatSaberMarkupLanguage": "^1.4.0",