mirror of
https://github.com/ppy/osu
synced 2025-02-16 18:17:01 +00:00
Use early return for if-pattern-matching.
This commit is contained in:
parent
20f01ff3e9
commit
4cd7d67fe4
@ -263,16 +263,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
/// <returns></returns>
|
||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||
{
|
||||
if (HitObject is IHasCurve curveData)
|
||||
{
|
||||
if (!(HitObject is IHasCurve curveData))
|
||||
return HitObject.Samples;
|
||||
|
||||
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
|
||||
|
||||
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||
return curveData.NodeSamples[index];
|
||||
}
|
||||
|
||||
return HitObject.Samples;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -474,17 +474,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
/// <returns></returns>
|
||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||
{
|
||||
if (HitObject is IHasCurve curveData)
|
||||
{
|
||||
if (!(HitObject is IHasCurve curveData))
|
||||
return HitObject.Samples;
|
||||
|
||||
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
|
||||
|
||||
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||
return curveData.NodeSamples[index];
|
||||
}
|
||||
|
||||
return HitObject.Samples;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and adds a note to a pattern.
|
||||
/// </summary>
|
||||
|
@ -380,8 +380,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
{
|
||||
if (judgedObject is DrawableOsuHitObject osuObject)
|
||||
{
|
||||
if (!(judgedObject is DrawableOsuHitObject osuObject))
|
||||
return;
|
||||
|
||||
OsuSpriteText text;
|
||||
Add(text = new OsuSpriteText
|
||||
{
|
||||
@ -401,4 +402,3 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
|
||||
|
||||
if (hitObject is Slider slider)
|
||||
{
|
||||
if (!(hitObject is Slider slider))
|
||||
return;
|
||||
|
||||
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));
|
||||
|
||||
@ -35,4 +36,3 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +125,9 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
|
||||
foreach (var c in Children)
|
||||
{
|
||||
if (c is ScrollingTeam stc)
|
||||
{
|
||||
if (!(c is ScrollingTeam stc))
|
||||
continue;
|
||||
|
||||
if (closest == null)
|
||||
{
|
||||
closest = stc;
|
||||
@ -139,7 +140,6 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
if (o < lastOffset)
|
||||
closest = stc;
|
||||
}
|
||||
}
|
||||
|
||||
Trace.Assert(closest != null, "closest != null");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user