1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 19:37:51 +08:00
osu-lazer/osu.Game/Screens/Play/SongProgressGraph.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2017-02-08 01:26:17 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
2017-02-07 13:49:41 +08:00
using System.Collections.Generic;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Objects;
2017-02-04 03:22:02 +08:00
namespace osu.Game.Screens.Play
{
public class SongProgressGraph : SquareGraph
2017-02-04 03:22:02 +08:00
{
private IEnumerable<HitObject> objects;
2017-02-07 13:49:41 +08:00
public IEnumerable<HitObject> Objects
{
set
{
objects = value;
const int granularity = 200;
var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0;
if (lastHit == 0)
lastHit = objects.Last().StartTime;
var interval = (lastHit + 1) / granularity;
var values = new int[granularity];
foreach (var h in objects)
2017-03-23 17:37:12 +08:00
{
IHasEndTime end = h as IHasEndTime;
2017-03-23 17:37:12 +08:00
int startRange = (int)(h.StartTime / interval);
int endRange = (int)((end?.EndTime > 0 ? end.EndTime : h.StartTime) / interval);
for (int i = startRange; i <= endRange; i++)
values[i]++;
2017-03-23 17:37:12 +08:00
}
Values = values;
2017-03-23 17:37:12 +08:00
}
}
}
}