1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 14:42:54 +08:00

Use pattern matching.

This commit is contained in:
Huo Yaoyuan 2019-11-12 18:16:51 +08:00
parent 7d7b9e36b2
commit e5e8e70704
13 changed files with 348 additions and 348 deletions

View File

@ -145,8 +145,8 @@ dotnet_style_prefer_compound_assignment = true:warning
#Style - null/type checks #Style - null/type checks
dotnet_style_coalesce_expression = true:warning dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning dotnet_style_null_propagation = true:warning
csharp_style_pattern_matching_over_is_with_cast_check = true:silent csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:silent csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_throw_expression = true:silent csharp_style_throw_expression = true:silent
csharp_style_conditional_delegate_call = true:suggestion csharp_style_conditional_delegate_call = true:suggestion

View File

@ -8,6 +8,7 @@ using System;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Catch.Beatmaps namespace osu.Game.Rulesets.Catch.Beatmaps
{ {
@ -22,15 +23,13 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap) protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
{ {
var curveData = obj as IHasCurve;
var positionData = obj as IHasXPosition; var positionData = obj as IHasXPosition;
var comboData = obj as IHasCombo; var comboData = obj as IHasCombo;
var endTime = obj as IHasEndTime;
var legacyOffset = obj as IHasLegacyLastTickOffset;
if (curveData != null) switch (obj)
{ {
yield return new JuiceStream case IHasCurve curveData:
return new JuiceStream
{ {
StartTime = obj.StartTime, StartTime = obj.StartTime,
Samples = obj.Samples, Samples = obj.Samples,
@ -40,30 +39,28 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH, X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset ?? 0 LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
}; }.Yield();
}
else if (endTime != null) case IHasEndTime endTime:
{ return new BananaShower
yield return new BananaShower
{ {
StartTime = obj.StartTime, StartTime = obj.StartTime,
Samples = obj.Samples, Samples = obj.Samples,
Duration = endTime.Duration, Duration = endTime.Duration,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
}; }.Yield();
}
else default:
{ return new Fruit
yield return new Fruit
{ {
StartTime = obj.StartTime, StartTime = obj.StartTime,
Samples = obj.Samples, Samples = obj.Samples,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
}; }.Yield();
} }
} }

View File

@ -156,37 +156,44 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
/// <returns>The hit objects generated.</returns> /// <returns>The hit objects generated.</returns>
private IEnumerable<ManiaHitObject> generateConverted(HitObject original, IBeatmap originalBeatmap) private IEnumerable<ManiaHitObject> generateConverted(HitObject original, IBeatmap originalBeatmap)
{ {
var endTimeData = original as IHasEndTime;
var distanceData = original as IHasDistance;
var positionData = original as IHasPosition;
Patterns.PatternGenerator conversion = null; Patterns.PatternGenerator conversion = null;
if (distanceData != null) switch (original)
{
case IHasDistance _:
{ {
var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap); var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
conversion = generator; conversion = generator;
var positionData = original as IHasPosition;
for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration) for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
{ {
recordNote(time, positionData?.Position ?? Vector2.Zero); recordNote(time, positionData?.Position ?? Vector2.Zero);
computeDensity(time); computeDensity(time);
} }
break;
} }
else if (endTimeData != null)
case IHasEndTime endTimeData:
{ {
conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap); conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);
recordNote(endTimeData.EndTime, new Vector2(256, 192)); recordNote(endTimeData.EndTime, new Vector2(256, 192));
computeDensity(endTimeData.EndTime); computeDensity(endTimeData.EndTime);
break;
} }
else if (positionData != null)
case IHasPosition positionData:
{ {
computeDensity(original.StartTime); computeDensity(original.StartTime);
conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap); conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);
recordNote(original.StartTime, positionData.Position); recordNote(original.StartTime, positionData.Position);
break;
}
} }
if (conversion == null) if (conversion == null)
@ -219,14 +226,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
private Pattern generate() private Pattern generate()
{ {
var endTimeData = HitObject as IHasEndTime;
var positionData = HitObject as IHasXPosition; var positionData = HitObject as IHasXPosition;
int column = GetColumn(positionData?.X ?? 0); int column = GetColumn(positionData?.X ?? 0);
var pattern = new Pattern(); var pattern = new Pattern();
if (endTimeData != null) if (HitObject is IHasEndTime endTimeData)
{ {
pattern.Add(new HoldNote pattern.Add(new HoldNote
{ {
@ -237,7 +243,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) }, Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) },
}); });
} }
else if (positionData != null) else if (HitObject is IHasXPosition)
{ {
pattern.Add(new Note pattern.Add(new Note
{ {
@ -257,16 +263,16 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
/// <returns></returns> /// <returns></returns>
private IList<HitSampleInfo> sampleInfoListAt(double time) private IList<HitSampleInfo> sampleInfoListAt(double time)
{ {
var curveData = HitObject as IHasCurve; if (HitObject is IHasCurve curveData)
{
if (curveData == null)
return HitObject.Samples;
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount(); double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.NodeSamples[index]; return curveData.NodeSamples[index];
} }
return HitObject.Samples;
}
} }
} }
} }

View File

@ -474,17 +474,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// <returns></returns> /// <returns></returns>
private IList<HitSampleInfo> sampleInfoListAt(double time) private IList<HitSampleInfo> sampleInfoListAt(double time)
{ {
var curveData = HitObject as IHasCurve; if (HitObject is IHasCurve curveData)
{
if (curveData == null)
return HitObject.Samples;
double segmentTime = (EndTime - HitObject.StartTime) / spanCount; double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.NodeSamples[index]; return curveData.NodeSamples[index];
} }
return HitObject.Samples;
}
/// <summary> /// <summary>
/// Constructs and adds a note to a pattern. /// Constructs and adds a note to a pattern.
/// </summary> /// </summary>

View File

@ -379,10 +379,8 @@ namespace osu.Game.Rulesets.Osu.Tests
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result) private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
var osuObject = judgedObject as DrawableOsuHitObject; if (judgedObject is DrawableOsuHitObject osuObject)
if (osuObject == null) {
return;
OsuSpriteText text; OsuSpriteText text;
Add(text = new OsuSpriteText Add(text = new OsuSpriteText
{ {
@ -401,4 +399,5 @@ namespace osu.Game.Rulesets.Osu.Tests
judgementOffsetDirection *= -1; judgementOffsetDirection *= -1;
} }
} }
}
} }

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using System; using System;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Osu.Beatmaps namespace osu.Game.Rulesets.Osu.Beatmaps
{ {
@ -23,15 +24,13 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap) protected override IEnumerable<OsuHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
{ {
var curveData = original as IHasCurve;
var endTimeData = original as IHasEndTime;
var positionData = original as IHasPosition; var positionData = original as IHasPosition;
var comboData = original as IHasCombo; var comboData = original as IHasCombo;
var legacyOffset = original as IHasLegacyLastTickOffset;
if (curveData != null) switch (original)
{ {
yield return new Slider case IHasCurve curveData:
return new Slider
{ {
StartTime = original.StartTime, StartTime = original.StartTime,
Samples = original.Samples, Samples = original.Samples,
@ -41,15 +40,14 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
Position = positionData?.Position ?? Vector2.Zero, Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
LegacyLastTickOffset = legacyOffset?.LegacyLastTickOffset, LegacyLastTickOffset = (original as IHasLegacyLastTickOffset)?.LegacyLastTickOffset,
// prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance. // prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance.
// this results in more (or less) ticks being generated in <v8 maps for the same time duration. // this results in more (or less) ticks being generated in <v8 maps for the same time duration.
TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1 TickDistanceMultiplier = beatmap.BeatmapInfo.BeatmapVersion < 8 ? 1f / beatmap.ControlPointInfo.DifficultyPointAt(original.StartTime).SpeedMultiplier : 1
}; }.Yield();
}
else if (endTimeData != null) case IHasEndTime endTimeData:
{ return new Spinner
yield return new Spinner
{ {
StartTime = original.StartTime, StartTime = original.StartTime,
Samples = original.Samples, Samples = original.Samples,
@ -57,18 +55,17 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2, Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
}; }.Yield();
}
else default:
{ return new HitCircle
yield return new HitCircle
{ {
StartTime = original.StartTime, StartTime = original.StartTime,
Samples = original.Samples, Samples = original.Samples,
Position = positionData?.Position ?? Vector2.Zero, Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
}; }.Yield();
} }
} }

View File

@ -22,10 +22,8 @@ namespace osu.Game.Rulesets.Osu.Mods
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y); osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
var slider = hitObject as Slider; if (hitObject is Slider slider)
if (slider == null) {
return;
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y)); slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y)); slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
@ -36,4 +34,5 @@ namespace osu.Game.Rulesets.Osu.Mods
slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance); slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
} }
} }
}
} }

View File

@ -73,20 +73,17 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap) protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap)
{ {
var distanceData = obj as IHasDistance;
var repeatsData = obj as IHasRepeats;
var endTimeData = obj as IHasEndTime;
var curveData = obj as IHasCurve;
// Old osu! used hit sounding to determine various hit type information // Old osu! used hit sounding to determine various hit type information
IList<HitSampleInfo> samples = obj.Samples; IList<HitSampleInfo> samples = obj.Samples;
bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH); bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
if (distanceData != null) switch (obj)
{
case IHasDistance distanceData:
{ {
// Number of spans of the object - one for the initial length and for each repeat // Number of spans of the object - one for the initial length and for each repeat
int spans = repeatsData?.SpanCount() ?? 1; int spans = (obj as IHasRepeats)?.SpanCount() ?? 1;
TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime); TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime);
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime); DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime);
@ -117,7 +114,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength) if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{ {
List<IList<HitSampleInfo>> allSamples = curveData != null ? curveData.NodeSamples : new List<IList<HitSampleInfo>>(new[] { samples }); List<IList<HitSampleInfo>> allSamples = obj is IHasCurve curveData ? curveData.NodeSamples : new List<IList<HitSampleInfo>>(new[] { samples });
int i = 0; int i = 0;
@ -160,8 +157,11 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4 TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
}; };
} }
break;
} }
else if (endTimeData != null)
case IHasEndTime endTimeData:
{ {
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier; double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
@ -172,8 +172,11 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
Duration = endTimeData.Duration, Duration = endTimeData.Duration,
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier) RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
}; };
break;
} }
else
default:
{ {
bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE); bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
@ -195,6 +198,9 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
IsStrong = strong IsStrong = strong
}; };
} }
break;
}
} }
} }

View File

@ -43,11 +43,9 @@ namespace osu.Game.Rulesets.Taiko.Replays
IHasEndTime endTimeData = h as IHasEndTime; IHasEndTime endTimeData = h as IHasEndTime;
double endTime = endTimeData?.EndTime ?? h.StartTime; double endTime = endTimeData?.EndTime ?? h.StartTime;
Swell swell = h as Swell; switch (h)
DrumRoll drumRoll = h as DrumRoll; {
Hit hit = h as Hit; case Swell swell:
if (swell != null)
{ {
int d = 0; int d = 0;
int count = 0; int count = 0;
@ -83,16 +81,22 @@ namespace osu.Game.Rulesets.Taiko.Replays
if (++count == req) if (++count == req)
break; break;
} }
break;
} }
else if (drumRoll != null)
case DrumRoll drumRoll:
{ {
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>()) foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{ {
Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre)); Frames.Add(new TaikoReplayFrame(tick.StartTime, hitButton ? TaikoAction.LeftCentre : TaikoAction.RightCentre));
hitButton = !hitButton; hitButton = !hitButton;
} }
break;
} }
else if (hit != null)
case Hit hit:
{ {
TaikoAction[] actions; TaikoAction[] actions;
@ -110,9 +114,12 @@ namespace osu.Game.Rulesets.Taiko.Replays
} }
Frames.Add(new TaikoReplayFrame(h.StartTime, actions)); Frames.Add(new TaikoReplayFrame(h.StartTime, actions));
break;
} }
else
default:
throw new InvalidOperationException("Unknown hit object type."); throw new InvalidOperationException("Unknown hit object type.");
}
var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button

View File

@ -125,11 +125,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
foreach (var c in Children) foreach (var c in Children)
{ {
var stc = c as ScrollingTeam; if (c is ScrollingTeam stc)
{
if (stc == null)
continue;
if (closest == null) if (closest == null)
{ {
closest = stc; closest = stc;
@ -142,6 +139,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
if (o < lastOffset) if (o < lastOffset)
closest = stc; closest = stc;
} }
}
Trace.Assert(closest != null, "closest != null"); Trace.Assert(closest != null, "closest != null");
@ -203,11 +201,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
foreach (var c in Children) foreach (var c in Children)
{ {
ScrollingTeam st = c as ScrollingTeam; if (c is ScrollingTeam st)
{
if (st == null)
continue;
if (st.Team == team) if (st.Team == team)
{ {
st.FadeOut(200); st.FadeOut(200);
@ -215,6 +210,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
} }
} }
} }
}
public void StartScrolling() public void StartScrolling()
{ {
@ -295,10 +291,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{ {
foreach (var c in Children) foreach (var c in Children)
{ {
ScrollingTeam st = c as ScrollingTeam; if (c is ScrollingTeam st)
if (st == null) {
continue;
if (st.Selected) if (st.Selected)
{ {
st.Selected = false; st.Selected = false;
@ -306,6 +300,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
} }
} }
} }
}
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) => private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
this.TransformTo(nameof(speed), value, duration, easing); this.TransformTo(nameof(speed), value, duration, easing);

View File

@ -297,9 +297,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
{ {
set set
{ {
var h = Header as UserDropdownHeader; if (Header is UserDropdownHeader h)
if (h == null) return;
h.StatusColour = value; h.StatusColour = value;
} }
} }

View File

@ -148,13 +148,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
// Generate the timing points, making non-timing changes use the previous timing change and vice-versa // Generate the timing points, making non-timing changes use the previous timing change and vice-versa
var timingChanges = allPoints.Select(c => var timingChanges = allPoints.Select(c =>
{ {
var timingPoint = c as TimingControlPoint; if (c is TimingControlPoint timingPoint)
var difficultyPoint = c as DifficultyControlPoint;
if (timingPoint != null)
lastTimingPoint = timingPoint; lastTimingPoint = timingPoint;
else if (c is DifficultyControlPoint difficultyPoint)
if (difficultyPoint != null)
lastDifficultyPoint = difficultyPoint; lastDifficultyPoint = difficultyPoint;
return new MultiplierControlPoint(c.Time) return new MultiplierControlPoint(c.Time)

View File

@ -17,10 +17,10 @@ namespace osu.Game.Screens.Backgrounds
public override bool Equals(BackgroundScreen other) public override bool Equals(BackgroundScreen other)
{ {
var backgroundScreenCustom = other as BackgroundScreenCustom; if (other is BackgroundScreenCustom backgroundScreenCustom)
if (backgroundScreenCustom == null) return false;
return base.Equals(other) && textureName == backgroundScreenCustom.textureName; return base.Equals(other) && textureName == backgroundScreenCustom.textureName;
return false;
} }
} }
} }