From 75c6a676b42b4d51bd15b74a2254e0a559269169 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Mar 2022 16:58:36 +0900 Subject: [PATCH] Apply `nullable` to `OsuModRandom` rather than using jetbrains annotations --- osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs b/osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs index 895dc9a506..8ccfbf0da5 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs @@ -1,10 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; -using JetBrains.Annotations; using osu.Framework.Graphics.Primitives; using osu.Framework.Utils; using osu.Game.Beatmaps; @@ -33,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Mods /// private const int preceding_hitobjects_to_shift = 10; - private Random rng; + private Random? rng; public void ApplyToBeatmap(IBeatmap beatmap) { @@ -58,8 +60,10 @@ namespace osu.Game.Rulesets.Osu.Mods /// A list of s describing how each hit object should be placed. private List randomiseObjects(IEnumerable hitObjects) { + Debug.Assert(rng != null, $"{nameof(ApplyToBeatmap)} was not called before randomising objects"); + var randomObjects = new List(); - RandomObjectInfo previous = null; + RandomObjectInfo? previous = null; float rateOfChangeMultiplier = 0; foreach (OsuHitObject hitObject in hitObjects) @@ -102,7 +106,7 @@ namespace osu.Game.Rulesets.Osu.Mods /// A list of describing how each hit object should be placed. private void applyRandomisation(IReadOnlyList hitObjects, IReadOnlyList randomObjects) { - RandomObjectInfo previous = null; + RandomObjectInfo? previous = null; for (int i = 0; i < hitObjects.Count; i++) { @@ -158,7 +162,7 @@ namespace osu.Game.Rulesets.Osu.Mods /// The representing the hit object to have the randomised position computed for. /// The representing the hit object immediately preceding the current one. /// The representing the hit object immediately preceding the one. - private void computeRandomisedPosition(RandomObjectInfo current, [CanBeNull] RandomObjectInfo previous, [CanBeNull] RandomObjectInfo beforePrevious) + private void computeRandomisedPosition(RandomObjectInfo current, RandomObjectInfo? previous, RandomObjectInfo? beforePrevious) { float previousAbsoluteAngle = 0f;