From 534a4e989c3b913cab5259941b4885cf1e288384 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 2 Apr 2021 23:34:54 +0300 Subject: [PATCH 1/3] Remove unused using directive --- osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs b/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs index d24ee6f..aa1e001 100644 --- a/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs +++ b/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs @@ -11,7 +11,6 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Rush.Objects.Drawables.Pieces; using osu.Game.Rulesets.Rush.UI; -using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Skinning; From 9db976b3b2d4177f133542e56c13e281056e97c0 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 2 Apr 2021 23:34:14 +0300 Subject: [PATCH 2/3] Remove unnecssary members --- .../Visual/TestSceneRushPlayer.cs | 7 ++--- .../Beatmaps/RushGeneratedBeatmapConverter.cs | 27 +++++++++---------- .../Objects/Drawables/DrawableStarSheetCap.cs | 4 +-- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Rush.Tests/Visual/TestSceneRushPlayer.cs b/osu.Game.Rulesets.Rush.Tests/Visual/TestSceneRushPlayer.cs index 372b123..6256bad 100644 --- a/osu.Game.Rulesets.Rush.Tests/Visual/TestSceneRushPlayer.cs +++ b/osu.Game.Rulesets.Rush.Tests/Visual/TestSceneRushPlayer.cs @@ -1,12 +1,10 @@ // Copyright (c) Shane Woolcock. Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; using osu.Game.Tests.Visual; @@ -15,7 +13,6 @@ namespace osu.Game.Rulesets.Rush.Tests.Visual [TestFixture] public class TestSceneRushPlayer : PlayerTestScene { - private Checkbox pauseCheckbox; private readonly BindableBool pausedBindable = new BindableBool(); protected new RushPlayer Player => (RushPlayer)base.Player; @@ -27,7 +24,7 @@ public class TestSceneRushPlayer : PlayerTestScene [BackgroundDependencyLoader] private void load() { - Add(pauseCheckbox = new OsuCheckbox + Add(new OsuCheckbox { LabelText = "Pause", RelativeSizeAxes = Axes.None, @@ -36,7 +33,7 @@ private void load() Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, Margin = new MarginPadding { Top = 40f, Left = 10f }, - Depth = Single.NegativeInfinity, + Depth = float.NegativeInfinity, Current = { BindTarget = pausedBindable } }); diff --git a/osu.Game.Rulesets.Rush/Beatmaps/RushGeneratedBeatmapConverter.cs b/osu.Game.Rulesets.Rush/Beatmaps/RushGeneratedBeatmapConverter.cs index 9bc753f..b954802 100644 --- a/osu.Game.Rulesets.Rush/Beatmaps/RushGeneratedBeatmapConverter.cs +++ b/osu.Game.Rulesets.Rush/Beatmaps/RushGeneratedBeatmapConverter.cs @@ -47,7 +47,6 @@ public class RushGeneratedBeatmapConverter : BeatmapConverter private LanedHitLane? previousLane; private Vector2? previousSourcePosition; private double previousSourceTime; - private HitObjectFlags previousFlags; private readonly Dictionary currentStarSheets = new Dictionary(); @@ -86,12 +85,11 @@ private void reset() protected override IEnumerable ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken) { - void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) + void updatePrevious(LanedHitLane? newLane) { previousLane = newLane; previousSourceTime = original.GetEndTime(); previousSourcePosition = (original as IHasPosition)?.Position; - previousFlags = newFlags; } // if it's definitely a spinner, return a miniboss @@ -99,19 +97,19 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) { yield return createMiniBoss(original); - updatePrevious(null, HitObjectFlags.None); + updatePrevious(null); yield break; } // otherwise do some flag magic Random random = new Random((int)original.StartTime); - HitObjectFlags flags = flagsForHitObject(original, beatmap); + HitObjectFlags flags = flagsForHitObject(original); // if no flags, completely skip this object if (flags == HitObjectFlags.None) { - updatePrevious(previousLane, HitObjectFlags.None); + updatePrevious(previousLane); yield break; } @@ -192,7 +190,7 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) yield return currentStarSheets[otherLane]; } - updatePrevious(sheetLane, flags); + updatePrevious(sheetLane); yield break; } @@ -206,7 +204,7 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) // if it's low probability, potentially skip this object if (flags.HasFlagFast(HitObjectFlags.LowProbability) && random.NextDouble() < skip_probability) { - updatePrevious(lane ?? previousLane, flags); + updatePrevious(lane ?? previousLane); yield break; } @@ -219,7 +217,7 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) nextDualHitTime = original.StartTime + min_dualhit_time; yield return createDualHit(original); - updatePrevious(null, flags); + updatePrevious(null); yield break; } @@ -233,6 +231,9 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) ? LanedHitLane.Ground : (LanedHitLane?)null; + // ReSharper disable once MergeSequentialChecks + // weirdness, merging both checks result in IOE warning + // for accessing nullable value, just disable it for now. if (blockedLane != null && finalLane == blockedLane) finalLane = blockedLane.Value.Opposite(); @@ -256,10 +257,6 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) // if the new sawblade is too close to the previous hit in the same lane, skip it var tooCloseToSameLane = previousLane == null || previousLane == sawbladeLane && original.StartTime - previousSourceTime < sawblade_same_lane_safety_time; - // if a ground sawblade is too far from the previous hit in the air lane, skip it (as the player may not have time to jump upon landing) - var canFallOntoSawblade = previousLane == LanedHitLane.Air && sawbladeLane == LanedHitLane.Ground && original.StartTime - previousSourceTime > sawblade_fall_safety_near_time - && original.StartTime - previousSourceTime < sawblade_fall_safety_far_time; - // air sawblades may only appear in a kiai section, and not too close to a hit in the same lane (or laneless) // also need to account for a gap where the player may fall onto the blade if (sawbladeLane != blockedLane @@ -287,7 +284,7 @@ void updatePrevious(LanedHitLane? newLane, HitObjectFlags newFlags) if (finalLane != blockedLane && !tooCloseToLastSawblade && (!sawbladeAdded || !flags.HasFlagFast(HitObjectFlags.AllowSawbladeReplace))) yield return createNormalHit(original, finalLane); - updatePrevious(finalLane, flags); + updatePrevious(finalLane); } private LanedHit createNormalHit(HitObject original, LanedHitLane lane, IList samples = null, double? time = null) @@ -350,7 +347,7 @@ private Sawblade createSawblade(HitObject original, LanedHitLane lane) => private LanedHitLane? laneForHitObject(HitObject hitObject) => hitObject is IHasYPosition hasYPosition ? (LanedHitLane?)(hasYPosition.Y < half_height ? LanedHitLane.Air : LanedHitLane.Ground) : null; - private HitObjectFlags flagsForHitObject(HitObject hitObject, IBeatmap beatmap) + private HitObjectFlags flagsForHitObject(HitObject hitObject) { HitObjectFlags flags = HitObjectFlags.None; diff --git a/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheetCap.cs b/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheetCap.cs index 6f81697..f7b30ba 100644 --- a/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheetCap.cs +++ b/osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheetCap.cs @@ -22,8 +22,6 @@ public abstract class DrawableStarSheetCap : DrawableLanedHit { protected abstract RushSkinComponents Component { get; } - private readonly Drawable capPiece; - protected readonly DrawableStarSheet StarSheet; [Resolved] @@ -38,7 +36,7 @@ protected DrawableStarSheetCap(DrawableStarSheet starSheet, TObject hitObject) Size = new Vector2(DrawableStarSheet.NOTE_SHEET_SIZE * 1.1f); Origin = Anchor.Centre; - Content.Child = capPiece = new SkinnableDrawable(new RushSkinComponent(Component), _ => new StarSheetCapStarPiece()) + Content.Child = new SkinnableDrawable(new RushSkinComponent(Component), _ => new StarSheetCapStarPiece()) { Origin = Anchor.Centre, Anchor = Anchor.Centre, From 10c3c35b0160c271e87a0871d17a3f417f583cb3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 2 Apr 2021 23:34:42 +0300 Subject: [PATCH 3/3] Add new line after `return;` --- osu.Game.Rulesets.Rush/Objects/StarSheet.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Rush/Objects/StarSheet.cs b/osu.Game.Rulesets.Rush/Objects/StarSheet.cs index a430f93..06b2de1 100644 --- a/osu.Game.Rulesets.Rush/Objects/StarSheet.cs +++ b/osu.Game.Rulesets.Rush/Objects/StarSheet.cs @@ -72,7 +72,9 @@ protected override void CreateNestedHitObjects(CancellationToken cancellationTok private void updateNestedSamples() { - if (NodeSamples.Count == 0) return; + if (NodeSamples.Count == 0) + return; + Head.Samples = NodeSamples.First(); Tail.Samples = NodeSamples.Last(); }