diff --git a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs index 4b95a6754e..162624da57 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs @@ -28,18 +28,20 @@ namespace osu.Game.Rulesets.Catch.Tests protected override IEnumerable CreateConvertValue(HitObject hitObject) { - if (hitObject is JuiceStream stream) + switch (hitObject) { - foreach (var nested in stream.NestedHitObjects) - yield return new ConvertValue((CatchHitObject)nested); + case JuiceStream stream: + foreach (var nested in stream.NestedHitObjects) + yield return new ConvertValue((CatchHitObject)nested); + break; + case BananaShower shower: + foreach (var nested in shower.NestedHitObjects) + yield return new ConvertValue((CatchHitObject)nested); + break; + default: + yield return new ConvertValue((CatchHitObject)hitObject); + break; } - else if (hitObject is BananaShower shower) - { - foreach (var nested in shower.NestedHitObjects) - yield return new ConvertValue((CatchHitObject)nested); - } - else - yield return new ConvertValue((CatchHitObject)hitObject); } protected override Ruleset CreateRuleset() => new CatchRuleset(); diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 31c56c37c4..a763989750 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -46,13 +46,16 @@ namespace osu.Game.Rulesets.Catch.Difficulty foreach (var hitObject in beatmap.HitObjects) { - // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. - if (hitObject is Fruit) + switch (hitObject) { - difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, halfCatchWidth)); + // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. + case Fruit fruit: + difficultyHitObjects.Add(new CatchDifficultyHitObject(fruit, halfCatchWidth)); + break; + case JuiceStream _: + difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth))); + break; } - if (hitObject is JuiceStream) - difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth))); } difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index b902ee63c6..06b4b8a27e 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -33,15 +33,19 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy bool generateHold = endTime - HitObject.StartTime >= 100; - if (TotalColumns == 8) + switch (TotalColumns) { - if (HitObject.Samples.Any(s => s.Name == SampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000) + case 8 when HitObject.Samples.Any(s => s.Name == SampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000: addToPattern(pattern, 0, generateHold); - else + break; + case 8: addToPattern(pattern, getNextRandomColumn(RandomStart), generateHold); + break; + default: + if (TotalColumns > 0) + addToPattern(pattern, getNextRandomColumn(0), generateHold); + break; } - else if (TotalColumns > 0) - addToPattern(pattern, getNextRandomColumn(0), generateHold); return pattern; } diff --git a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs index d006a3e1c7..0eef540d97 100644 --- a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs +++ b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs @@ -56,10 +56,15 @@ namespace osu.Game.Rulesets.Mania.Replays { foreach (var point in group) { - if (point is HitPoint) - actions.Add(columnActions[point.Column]); - if (point is ReleasePoint) - actions.Remove(columnActions[point.Column]); + switch (point) + { + case HitPoint _: + actions.Add(columnActions[point.Column]); + break; + case ReleasePoint _: + actions.Remove(columnActions[point.Column]); + break; + } } Replay.Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray())); diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index ad4ea343d2..7322f65066 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -285,44 +285,45 @@ namespace osu.Game.Rulesets.Osu.Replays AddFrameToReplay(startFrame); - // We add intermediate frames for spinning / following a slider here. - if (h is Spinner) + switch (h) { - Spinner s = h as Spinner; - - Vector2 difference = startPosition - SPINNER_CENTRE; - - float radius = difference.Length; - float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X); - - double t; - - for (double j = h.StartTime + FrameDelay; j < s.EndTime; j += FrameDelay) + // We add intermediate frames for spinning / following a slider here. + case Spinner spinner: { - t = ApplyModsToTime(j - h.StartTime) * spinnerDirection; + Vector2 difference = startPosition - SPINNER_CENTRE; - Vector2 pos = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS); - AddFrameToReplay(new OsuReplayFrame((int)j, new Vector2(pos.X, pos.Y), action)); + float radius = difference.Length; + float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X); + + double t; + + for (double j = h.StartTime + FrameDelay; j < spinner.EndTime; j += FrameDelay) + { + t = ApplyModsToTime(j - h.StartTime) * spinnerDirection; + + Vector2 pos = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS); + AddFrameToReplay(new OsuReplayFrame((int)j, new Vector2(pos.X, pos.Y), action)); + } + + t = ApplyModsToTime(spinner.EndTime - h.StartTime) * spinnerDirection; + Vector2 endPosition = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS); + + AddFrameToReplay(new OsuReplayFrame(spinner.EndTime, new Vector2(endPosition.X, endPosition.Y), action)); + + endFrame.Position = endPosition; + break; } - - t = ApplyModsToTime(s.EndTime - h.StartTime) * spinnerDirection; - Vector2 endPosition = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS); - - AddFrameToReplay(new OsuReplayFrame(s.EndTime, new Vector2(endPosition.X, endPosition.Y), action)); - - endFrame.Position = endPosition; - } - else if (h is Slider) - { - Slider s = h as Slider; - - for (double j = FrameDelay; j < s.Duration; j += FrameDelay) + case Slider slider: { - Vector2 pos = s.StackedPositionAt(j / s.Duration); - AddFrameToReplay(new OsuReplayFrame(h.StartTime + j, new Vector2(pos.X, pos.Y), action)); - } + for (double j = FrameDelay; j < slider.Duration; j += FrameDelay) + { + Vector2 pos = slider.StackedPositionAt(j / slider.Duration); + AddFrameToReplay(new OsuReplayFrame(h.StartTime + j, new Vector2(pos.X, pos.Y), action)); + } - AddFrameToReplay(new OsuReplayFrame(s.EndTime, new Vector2(s.StackedEndPosition.X, s.StackedEndPosition.Y), action)); + AddFrameToReplay(new OsuReplayFrame(slider.EndTime, new Vector2(slider.StackedEndPosition.X, slider.StackedEndPosition.Y), action)); + break; + } } // We only want to let go of our button if we are at the end of the current replay. Otherwise something is still going on after us so we need to keep the button pressed! diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index c18d180783..4bc6992445 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -34,14 +34,16 @@ namespace osu.Game.Rulesets.Osu.UI protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h) { - if (h is HitCircle circle) - return new DrawableHitCircle(circle); + switch (h) + { + case HitCircle circle: + return new DrawableHitCircle(circle); + case Slider slider: + return new DrawableSlider(slider); + case Spinner spinner: + return new DrawableSpinner(spinner); + } - if (h is Slider slider) - return new DrawableSlider(slider); - - if (h is Spinner spinner) - return new DrawableSpinner(spinner); return null; } diff --git a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs index c7f75e44fa..7dd50ab8b8 100644 --- a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs +++ b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs @@ -80,30 +80,31 @@ namespace osu.Game.Rulesets.Taiko.Scoring foreach (var obj in beatmap.HitObjects) { - if (obj is Hit) + switch (obj) { - AddJudgement(new TaikoJudgement { Result = HitResult.Great }); - if (obj.IsStrong) - AddJudgement(new TaikoStrongHitJudgement()); - } - else if (obj is DrumRoll) - { - for (int i = 0; i < ((DrumRoll)obj).NestedHitObjects.OfType().Count(); i++) - { - AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great }); + case Hit _: + AddJudgement(new TaikoJudgement { Result = HitResult.Great }); + if (obj.IsStrong) + AddJudgement(new TaikoStrongHitJudgement()); + break; + case DrumRoll drumRoll: + var count = drumRoll.NestedHitObjects.OfType().Count(); + for (int i = 0; i < count; i++) + { + AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great }); + + if (obj.IsStrong) + AddJudgement(new TaikoStrongHitJudgement()); + } + + AddJudgement(new TaikoJudgement { Result = HitResult.Great }); if (obj.IsStrong) AddJudgement(new TaikoStrongHitJudgement()); - } - - AddJudgement(new TaikoJudgement { Result = HitResult.Great }); - - if (obj.IsStrong) - AddJudgement(new TaikoStrongHitJudgement()); - } - else if (obj is Swell) - { - AddJudgement(new TaikoJudgement { Result = HitResult.Great }); + break; + case Swell _: + AddJudgement(new TaikoJudgement { Result = HitResult.Great }); + break; } } } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index a47c433631..bb5994c2f2 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -213,13 +213,15 @@ namespace osu.Game.Rulesets.Taiko.UI base.Add(h); - var barline = h as DrawableBarLine; - if (barline != null) - barlineContainer.Add(barline.CreateProxy()); - - var taikoObject = h as DrawableTaikoHitObject; - if (taikoObject != null) - topLevelHitContainer.Add(taikoObject.CreateProxiedContent()); + switch (h) + { + case DrawableBarLine barline: + barlineContainer.Add(barline.CreateProxy()); + break; + case DrawableTaikoHitObject taikoObject: + topLevelHitContainer.Add(taikoObject.CreateProxiedContent()); + break; + } } internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs index e04b4d45f6..2fa4627bde 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs @@ -98,32 +98,22 @@ namespace osu.Game.Rulesets.Taiko.UI protected override DrawableHitObject GetVisualRepresentation(TaikoHitObject h) { - var centreHit = h as CentreHit; - if (centreHit != null) + switch (h) { - if (h.IsStrong) + case CentreHit centreHit when h.IsStrong: return new DrawableCentreHitStrong(centreHit); - return new DrawableCentreHit(centreHit); - } - - var rimHit = h as RimHit; - if (rimHit != null) - { - if (h.IsStrong) + case CentreHit centreHit: + return new DrawableCentreHit(centreHit); + case RimHit rimHit when h.IsStrong: return new DrawableRimHitStrong(rimHit); - return new DrawableRimHit(rimHit); + case RimHit rimHit: + return new DrawableRimHit(rimHit); + case DrumRoll drumRoll: + return new DrawableDrumRoll(drumRoll); + case Swell swell: + return new DrawableSwell(swell); } - var drumRoll = h as DrumRoll; - if (drumRoll != null) - { - return new DrawableDrumRoll(drumRoll); - } - - var swell = h as Swell; - if (swell != null) - return new DrawableSwell(swell); - return null; } diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 7a227f4bfa..223ca1c904 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -73,12 +73,17 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons downloader.Download(); }; - downloader.DownloadState.ValueChanged += d => + downloader.DownloadState.ValueChanged += state => { - if (d == BeatmapSetDownloader.DownloadStatus.Downloaded) - this.FadeOut(200); - else if (d == BeatmapSetDownloader.DownloadStatus.NotDownloaded) - this.FadeIn(200); + switch (state) + { + case BeatmapSetDownloader.DownloadStatus.Downloaded: + this.FadeOut(200); + break; + case BeatmapSetDownloader.DownloadStatus.NotDownloaded: + this.FadeIn(200); + break; + } }; } } diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 48963a91e8..c9e6f39270 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Direct public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) { - Width = 400; + Width = 380; Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) } diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 753cd33cc6..5a5b90ee25 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -188,16 +188,17 @@ namespace osu.Game.Overlays int optionCount = 0; int selectedOption = -1; - if (description.RawValue is bool) + switch (description.RawValue) { - optionCount = 1; - if ((bool)description.RawValue) selectedOption = 0; - } - else if (description.RawValue is Enum) - { - var values = Enum.GetValues(description.RawValue.GetType()); - optionCount = values.Length; - selectedOption = Convert.ToInt32(description.RawValue); + case bool val: + optionCount = 1; + if (val) selectedOption = 0; + break; + case Enum _: + var values = Enum.GetValues(description.RawValue.GetType()); + optionCount = values.Length; + selectedOption = Convert.ToInt32(description.RawValue); + break; } textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre; diff --git a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs index 8f9651ab09..0de0a620e3 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs @@ -62,15 +62,19 @@ namespace osu.Game.Rulesets.Difficulty IEnumerable createDifficultyAdjustmentModCombinations(IEnumerable currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0) { - // Initial-case: Empty current set - if (currentSetCount == 0) - yield return new NoModMod(); - - if (currentSetCount == 1) - yield return currentSet.Single(); - - if (currentSetCount > 1) - yield return new MultiMod(currentSet.ToArray()); + switch (currentSetCount) + { + case 0: + // Initial-case: Empty current set + yield return new NoModMod(); + break; + case 1: + yield return currentSet.Single(); + break; + default: + yield return new MultiMod(currentSet.ToArray()); + break; + } // Apply mods in the adjustment set recursively. Using the entire adjustment set would result in duplicate multi-mod mod // combinations in further recursions, so a moving subset is used to eliminate this effect