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,15 +263,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
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);
|
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
|
||||||
return curveData.NodeSamples[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return HitObject.Samples;
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||||
|
return curveData.NodeSamples[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,15 +474,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
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);
|
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
|
||||||
return curveData.NodeSamples[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return HitObject.Samples;
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||||
|
return curveData.NodeSamples[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -380,25 +380,25 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
{
|
{
|
||||||
if (judgedObject is DrawableOsuHitObject osuObject)
|
if (!(judgedObject is DrawableOsuHitObject osuObject))
|
||||||
|
return;
|
||||||
|
|
||||||
|
OsuSpriteText text;
|
||||||
|
Add(text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
OsuSpriteText text;
|
Anchor = Anchor.Centre,
|
||||||
Add(text = new OsuSpriteText
|
Origin = Anchor.Centre,
|
||||||
{
|
Text = result.IsHit ? "Hit!" : "Miss!",
|
||||||
Anchor = Anchor.Centre,
|
Colour = result.IsHit ? Color4.Green : Color4.Red,
|
||||||
Origin = Anchor.Centre,
|
Font = OsuFont.GetFont(size: 30),
|
||||||
Text = result.IsHit ? "Hit!" : "Miss!",
|
Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45)
|
||||||
Colour = result.IsHit ? Color4.Green : Color4.Red,
|
});
|
||||||
Font = OsuFont.GetFont(size: 30),
|
|
||||||
Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45)
|
|
||||||
});
|
|
||||||
|
|
||||||
text.Delay(150)
|
text.Delay(150)
|
||||||
.Then().FadeOut(200)
|
.Then().FadeOut(200)
|
||||||
.Then().Expire();
|
.Then().Expire();
|
||||||
|
|
||||||
judgementOffsetDirection *= -1;
|
judgementOffsetDirection *= -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,17 @@ 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);
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
var newControlPoints = new Vector2[slider.Path.ControlPoints.Length];
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
for (int i = 0; i < slider.Path.ControlPoints.Length; i++)
|
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
newControlPoints[i] = new Vector2(slider.Path.ControlPoints[i].X, -slider.Path.ControlPoints[i].Y);
|
|
||||||
|
|
||||||
slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
|
var newControlPoints = new Vector2[slider.Path.ControlPoints.Length];
|
||||||
}
|
for (int i = 0; i < slider.Path.ControlPoints.Length; i++)
|
||||||
|
newControlPoints[i] = new Vector2(slider.Path.ControlPoints[i].X, -slider.Path.ControlPoints[i].Y);
|
||||||
|
|
||||||
|
slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,20 +125,20 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
|
|
||||||
foreach (var c in Children)
|
foreach (var c in Children)
|
||||||
{
|
{
|
||||||
if (c is ScrollingTeam stc)
|
if (!(c is ScrollingTeam stc))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (closest == null)
|
||||||
{
|
{
|
||||||
if (closest == null)
|
closest = stc;
|
||||||
{
|
continue;
|
||||||
closest = stc;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
|
|
||||||
if (o < lastOffset)
|
|
||||||
closest = stc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
|
||||||
|
if (o < lastOffset)
|
||||||
|
closest = stc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace.Assert(closest != null, "closest != null");
|
Trace.Assert(closest != null, "closest != null");
|
||||||
|
Loading…
Reference in New Issue
Block a user