1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-31 06:13:06 +08:00
osu-lazer/osu.Game/Screens/Play/SongProgressGraph.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.4 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System.Linq;
2017-02-07 13:49:41 +08:00
using System.Collections.Generic;
using System.Diagnostics;
using osu.Game.Rulesets.Objects;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Play
{
public class SongProgressGraph : SquareGraph
2017-02-04 03:22:02 +08:00
{
private IEnumerable<HitObject> objects;
2018-04-13 17:19:50 +08:00
public IEnumerable<HitObject> Objects
{
set
{
objects = value;
2018-04-13 17:19:50 +08:00
const int granularity = 200;
Values = new int[granularity];
2018-04-13 17:19:50 +08:00
if (!objects.Any())
return;
2018-04-13 17:19:50 +08:00
double firstHit = objects.First().StartTime;
double lastHit = objects.Max(o => o.GetEndTime());
2018-04-13 17:19:50 +08:00
if (lastHit == 0)
lastHit = objects.Last().StartTime;
2018-04-13 17:19:50 +08:00
double interval = (lastHit - firstHit + 1) / granularity;
2018-04-13 17:19:50 +08:00
foreach (var h in objects)
2017-03-23 17:37:12 +08:00
{
double endTime = h.GetEndTime();
2018-04-13 17:19:50 +08:00
2017-09-14 12:13:54 +08:00
Debug.Assert(endTime >= h.StartTime);
2018-04-13 17:19:50 +08:00
int startRange = (int)((h.StartTime - firstHit) / interval);
int endRange = (int)((endTime - firstHit) / interval);
for (int i = startRange; i <= endRange; i++)
Values[i]++;
2017-03-23 17:37:12 +08:00
}
}
}
}
}