Skip to content

Commit

Permalink
Fixed for 1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Auros committed Apr 14, 2022
1 parent a68d4c3 commit 5bb38ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
22 changes: 8 additions & 14 deletions Enhancements/Breaktime/BreaktimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tuple<NoteLineLayer, int, float>, BeatmapObjectData> breaks = new Dictionary<Tuple<NoteLineLayer, int, float>, BeatmapObjectData>();

public event Action<float> 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<BeatmapObjectData> objects = new List<BeatmapObjectData>();
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();
Expand Down Expand Up @@ -71,7 +65,7 @@ private void NoteEnded(NoteController noteController)

public void Dispose()
{
if (_difficultyBeatmap != null)
if (_readonlyBeatmapData != null)
{
_beatmapObjectManager.noteWasMissedEvent -= NoteEnded;
_beatmapObjectManager.noteWasCutEvent -= NoteCut;
Expand Down
16 changes: 6 additions & 10 deletions Enhancements/Misc/BPM360Verifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,29 @@ namespace Enhancements.Misc
[HarmonyPatch(typeof(GameplayCoreInstaller), "InstallBindings")]
internal class BPM360Verifier
{
internal static readonly PropertyAccessor<BeatmapData, int>.Setter SetRotationCount = PropertyAccessor<BeatmapData, int>.GetSetter("spawnRotationEventsCount");
internal static readonly PropertyAccessor<MonoInstallerBase, DiContainer>.Getter GetDiContainer = PropertyAccessor<MonoInstallerBase, DiContainer>.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<MiscSettings>();
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<BeatLineManager>();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Enhancements/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions Enhancements/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 5bb38ca

Please sign in to comment.