mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Avoid usage of LINQ in last dash trail computation
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user