From 5bb38caca59b13c1678da1d2393fae7e565ede92 Mon Sep 17 00:00:00 2001 From: Auros Nexus Date: Thu, 14 Apr 2022 18:36:45 -0400 Subject: [PATCH] Fixed for 1.21.0 --- Enhancements/Breaktime/BreaktimeManager.cs | 22 ++++++++-------------- Enhancements/Misc/BPM360Verifier.cs | 16 ++++++---------- Enhancements/Properties/AssemblyInfo.cs | 4 ++-- Enhancements/manifest.json | 4 ++-- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Enhancements/Breaktime/BreaktimeManager.cs b/Enhancements/Breaktime/BreaktimeManager.cs index e644f88..fc86ea1 100644 --- a/Enhancements/Breaktime/BreaktimeManager.cs +++ b/Enhancements/Breaktime/BreaktimeManager.cs @@ -8,35 +8,29 @@ namespace Enhancements.Breaktime public class BreaktimeManager : IInitializable, IDisposable { private readonly BreaktimeSettings _settings; - private readonly IDifficultyBeatmap _difficultyBeatmap; + private readonly IReadonlyBeatmapData _readonlyBeatmapData; private readonly BeatmapObjectManager _beatmapObjectManager; private readonly Dictionary, BeatmapObjectData> breaks = new Dictionary, BeatmapObjectData>(); public event Action BreakDetected; - public BreaktimeManager(BreaktimeSettings settings, [InjectOptional] IDifficultyBeatmap difficultyBeatmap, [InjectOptional] BeatmapObjectManager beatmapObjectManager) + public BreaktimeManager(BreaktimeSettings settings, [InjectOptional] IReadonlyBeatmapData readonlyBeatmapData, [InjectOptional] BeatmapObjectManager beatmapObjectManager) { _settings = settings; - _difficultyBeatmap = difficultyBeatmap; + _readonlyBeatmapData = readonlyBeatmapData; _beatmapObjectManager = beatmapObjectManager; } public void Initialize() { - if (_difficultyBeatmap != null) + if (_readonlyBeatmapData != null) { List objects = new List(); - var lines = _difficultyBeatmap.beatmapData.beatmapLinesData; - for (int i = 0; i < lines.Count(); i++) + foreach (var item in _readonlyBeatmapData.allBeatmapDataItems) { - var line = lines[i]; - for (int n = 0; n < line.beatmapObjectsData.Count(); n++) + if (item is NoteData noteData) { - var objectData = line.beatmapObjectsData[n]; - if (objectData.beatmapObjectType == BeatmapObjectType.Note) - { - objects.Add(objectData); - } + objects.Add(noteData); } } objects = objects.OrderBy(x => x.time).ToList(); @@ -71,7 +65,7 @@ private void NoteEnded(NoteController noteController) public void Dispose() { - if (_difficultyBeatmap != null) + if (_readonlyBeatmapData != null) { _beatmapObjectManager.noteWasMissedEvent -= NoteEnded; _beatmapObjectManager.noteWasCutEvent -= NoteCut; diff --git a/Enhancements/Misc/BPM360Verifier.cs b/Enhancements/Misc/BPM360Verifier.cs index 654b178..765c122 100644 --- a/Enhancements/Misc/BPM360Verifier.cs +++ b/Enhancements/Misc/BPM360Verifier.cs @@ -8,33 +8,29 @@ namespace Enhancements.Misc [HarmonyPatch(typeof(GameplayCoreInstaller), "InstallBindings")] internal class BPM360Verifier { - internal static readonly PropertyAccessor.Setter SetRotationCount = PropertyAccessor.GetSetter("spawnRotationEventsCount"); internal static readonly PropertyAccessor.Getter GetDiContainer = PropertyAccessor.GetGetter("Container"); - internal static void Prefix(ref GameplayCoreInstaller __instance, ref GameplayCoreSceneSetupData ____sceneSetupData) + internal static void Postfix(ref GameplayCoreInstaller __instance, ref GameplayCoreSceneSetupData ____sceneSetupData) { var container = GetContainer(__instance); var settings = container.Resolve(); if (settings.BPMFixEnabled) { bool actually360 = false; - var data = ____sceneSetupData.difficultyBeatmap.beatmapData.beatmapEventsData; - var spawnRotationProcessor = new SpawnRotationProcessor(); - for (int i = 0; i < data.Count; i++) + foreach (var item in ____sceneSetupData.transformedBeatmapData.allBeatmapDataItems) { - var bmEvent = data[i]; - if (bmEvent.type == BeatmapEventType.Event14 || bmEvent.type == BeatmapEventType.Event15) + if (item is SpawnRotationBeatmapEventData rotation) { - if (spawnRotationProcessor.RotationForEventValue(bmEvent.value) != 0) + if (rotation.rotation != 0) { actually360 = true; + break; } } } if (!actually360) { - var beatmapData = ____sceneSetupData.difficultyBeatmap.beatmapData; - SetRotationCount(ref beatmapData, 0); + container.Unbind(); } } } diff --git a/Enhancements/Properties/AssemblyInfo.cs b/Enhancements/Properties/AssemblyInfo.cs index 91d2096..0b30e6c 100644 --- a/Enhancements/Properties/AssemblyInfo.cs +++ b/Enhancements/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.12")] -[assembly: AssemblyFileVersion("3.0.12")] +[assembly: AssemblyVersion("3.0.13")] +[assembly: AssemblyFileVersion("3.0.13")] diff --git a/Enhancements/manifest.json b/Enhancements/manifest.json index fc9d575..bfcd2c9 100644 --- a/Enhancements/manifest.json +++ b/Enhancements/manifest.json @@ -7,8 +7,8 @@ "BeatSaberMarkupLanguage": "^1.3.5" }, "description": "Adds various extra features and tweaks into Beat Saber like a clock and volume adjustment!", - "gameVersion": "1.19.0", + "gameVersion": "1.21.0", "id": "Enhancements", "name": "Enhancements", - "version": "3.0.12" + "version": "3.0.13" } \ No newline at end of file