mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 15:33:21 +08:00
Avoid usage of LINQ in last dash trail computation
This commit is contained in:
parent
da69867fd4
commit
846f539428
@ -114,10 +114,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (Catcher.Dashing || Catcher.HyperDashing)
|
if (Catcher.Dashing || Catcher.HyperDashing)
|
||||||
{
|
{
|
||||||
double lastTrailTime = CatcherTrails.LastDashTrail?.LifetimeStart ?? double.NegativeInfinity;
|
|
||||||
double generationInterval = Catcher.HyperDashing ? 25 : 50;
|
double generationInterval = Catcher.HyperDashing ? 25 : 50;
|
||||||
|
|
||||||
if (Time.Current - lastTrailTime >= generationInterval)
|
if (Time.Current - CatcherTrails.LastDashTrailTime >= generationInterval)
|
||||||
CatcherTrails.DisplayDashTrail(Catcher.CurrentState, Catcher.X, Catcher.BodyScale, Catcher.HyperDashing);
|
CatcherTrails.DisplayDashTrail(Catcher.CurrentState, Catcher.X, Catcher.BodyScale, Catcher.HyperDashing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
using System;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Pooling;
|
using osu.Framework.Graphics.Pooling;
|
||||||
@ -20,13 +19,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
public class CatcherTrailDisplay : SkinReloadableDrawable
|
public class CatcherTrailDisplay : SkinReloadableDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The most recent dash trail added in this container.
|
/// The most recent time a dash trail was added to this container.
|
||||||
/// Only alive (not faded out) trails are considered.
|
/// Only alive (not faded out) trails are considered.
|
||||||
|
/// Returns <see cref="double.NegativeInfinity"/> if no dash trail is alive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[CanBeNull]
|
public double LastDashTrailTime => getLastDashTrailTime();
|
||||||
public CatcherTrail LastDashTrail => dashTrails.Concat(hyperDashTrails)
|
|
||||||
.OrderByDescending(trail => trail.LifetimeStart)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
public Color4 HyperDashTrailsColour => hyperDashTrails.Colour;
|
public Color4 HyperDashTrailsColour => hyperDashTrails.Colour;
|
||||||
|
|
||||||
@ -97,5 +94,18 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double getLastDashTrailTime()
|
||||||
|
{
|
||||||
|
double maxTime = double.NegativeInfinity;
|
||||||
|
|
||||||
|
foreach (var trail in dashTrails)
|
||||||
|
maxTime = Math.Max(maxTime, trail.LifetimeStart);
|
||||||
|
|
||||||
|
foreach (var trail in hyperDashTrails)
|
||||||
|
maxTime = Math.Max(maxTime, trail.LifetimeStart);
|
||||||
|
|
||||||
|
return maxTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user