mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00: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)
|
||||
{
|
||||
double lastTrailTime = CatcherTrails.LastDashTrail?.LifetimeStart ?? double.NegativeInfinity;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
@ -20,13 +19,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
public class CatcherTrailDisplay : SkinReloadableDrawable
|
||||
{
|
||||
/// <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.
|
||||
/// Returns <see cref="double.NegativeInfinity"/> if no dash trail is alive.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public CatcherTrail LastDashTrail => dashTrails.Concat(hyperDashTrails)
|
||||
.OrderByDescending(trail => trail.LifetimeStart)
|
||||
.FirstOrDefault();
|
||||
public double LastDashTrailTime => getLastDashTrailTime();
|
||||
|
||||
public Color4 HyperDashTrailsColour => hyperDashTrails.Colour;
|
||||
|
||||
@ -97,5 +94,18 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
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