-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBreakTimeParser.cs
61 lines (56 loc) · 1.62 KB
/
BreakTimeParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OsuRTDataProvider.BeatmapInfo;
namespace IngameOverlay
{
class BreakTimeParser
{
class BreakTime
{
public int Start { get; set; }
public int End { get; set; }
}
private Beatmap _beatmap;
private List<BreakTime> _breakTimes = new List<BreakTime>();
public BreakTimeParser(Beatmap beatmap)
{
_beatmap = beatmap;
Parser();
}
private void Parser()
{
string blockName = "";
foreach (string line in File.ReadLines(_beatmap.FilenameFull))
{
if (line.StartsWith("["))
{
blockName = line.Trim();
}
else if (blockName.StartsWith("[Events]"))
{
IList<string> parms = line.Split(',');
if (parms[0].StartsWith("2"))
{
_breakTimes.Add(new BreakTime()
{
Start = int.Parse(parms[1]),
End = int.Parse(parms[2])
});
}
else if(line==string.Empty)
{
break;
}
}
}
}
public bool InBraekTime(int time)
{
return _breakTimes.Exists(breakTime => time > breakTime.Start && time < breakTime.End);
}
}
}