mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 20:32:56 +08:00
Simplify moving average
This commit is contained in:
parent
a5acc913ea
commit
0ccfaeb8d9
@ -14,6 +14,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HitErrorDisplay
|
namespace osu.Game.Screens.Play.HitErrorDisplay
|
||||||
{
|
{
|
||||||
@ -153,21 +154,17 @@ namespace osu.Game.Screens.Play.HitErrorDisplay
|
|||||||
|
|
||||||
private float getRelativeJudgementPosition(double value) => (float)(value / maxHitWindows);
|
private float getRelativeJudgementPosition(double value) => (float)(value / maxHitWindows);
|
||||||
|
|
||||||
private double sum;
|
|
||||||
|
|
||||||
private float calculateArrowPosition(JudgementResult newJudgement)
|
private float calculateArrowPosition(JudgementResult newJudgement)
|
||||||
{
|
{
|
||||||
var offset = newJudgement.TimeOffset;
|
judgementOffsets.Add(newJudgement.TimeOffset);
|
||||||
|
|
||||||
sum += offset;
|
if (judgementOffsets.Count < stored_judgements_amount)
|
||||||
|
return getRelativeJudgementPosition(judgementOffsets.Average());
|
||||||
|
|
||||||
judgementOffsets.Add(offset);
|
double sum = 0;
|
||||||
|
|
||||||
if (judgementOffsets.Count > stored_judgements_amount)
|
for (int i = judgementOffsets.Count - stored_judgements_amount; i < judgementOffsets.Count; i++)
|
||||||
{
|
sum += judgementOffsets[i];
|
||||||
sum -= judgementOffsets[0];
|
|
||||||
judgementOffsets.RemoveAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getRelativeJudgementPosition(sum / stored_judgements_amount);
|
return getRelativeJudgementPosition(sum / stored_judgements_amount);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user