diff --git a/OppaiSharp/Beatmap.cs b/OppaiSharp/Beatmap.cs index 8a53a2c..9bdda1c 100644 --- a/OppaiSharp/Beatmap.cs +++ b/OppaiSharp/Beatmap.cs @@ -10,7 +10,7 @@ public class Beatmap public int FormatVersion { get; internal set; } public GameMode Mode { get; internal set; } public string Title { get; internal set; } - public string TitleUnicode { get; internal set; } + public string TitleUnicode { get; internal set; } public string Artist { get; internal set; } public string ArtistUnicode { get; internal set; } @@ -20,19 +20,105 @@ public class Beatmap /// Difficulty name public string Version { get; internal set; } - public int CountCircles { get; set; } - public int CountSliders { get; set; } - public int CountSpinners { get; set; } + private int _allCountCircles; + private int _allCountSliders; + private int _allCountSpinners; + private int _cutCountCircles; + private int _cutCountSliders; + private int _cutCountSpinners; + + public int CountCircles + { + get + { + if (Cutting) + return _cutCountCircles; + return _allCountCircles; + } + set { _allCountCircles = value; } + } + + public int CountSliders + { + get + { + if (Cutting) + return _cutCountSliders; + return _allCountSliders; + } + set { _allCountSliders = value; } + } + + public int CountSpinners + { + get + { + if (Cutting) + return _cutCountSpinners; + return _allCountSpinners; + } + set { _allCountSpinners = value; } + } + public float HP { get; set; } = 5f; public float CS { get; set; } = 5f; public float OD { get; set; } = 5f; public float AR { get; set; } = 5f; public float SliderVelocity { get; set; } = 1f; public float TickRate { get; set; } = 1f; + public bool Cutting { get; private set; } = false; + private List _allObjects = new List(512); + private List CutObjects { get; set; } + public List Objects + { + get + { + if (Cutting) + return CutObjects; + return _allObjects; + } + set { _allObjects = value; } + } + + public List TimingPoints { get; set; } = new List(32); + + public void Cut(int startTime, int endTime) + { + if (endTime <= 0) + throw new ArgumentException(nameof(endTime)); + if (startTime < 0 || startTime > endTime) + throw new ArgumentException(nameof(endTime)); + Cutting = true; + CutObjects = new List(); + foreach (var o in _allObjects) + { + //Assuming chronological order + if (o.Time < startTime) + continue; + if (o.Time < endTime) + CutObjects.Add(o); + else + break; + } - public List Objects { get; } = new List(512); - public List TimingPoints { get; } = new List(32); + _cutCountCircles = 0; + _cutCountSpinners = 0; + _cutCountSliders = 0; + foreach (var o in CutObjects) + { + if ((o.Type & HitObjectType.Circle) != 0) + _cutCountCircles++; + else if ((o.Type & HitObjectType.Slider) != 0) + _cutCountSliders++; + else if ((o.Type & HitObjectType.Spinner) != 0) + _cutCountSpinners++; + } + } + public void ResetCut() + { + Cutting = false; + } public static Beatmap Read(StreamReader reader) => Parser.Read(reader); internal Beatmap() { } @@ -67,8 +153,8 @@ public override string ToString() + $" hp={HP}, cs={CS}, od={OD}, ar={AR}, sv={SliderVelocity}, tick_rate={TickRate}, " + $"tpoints=[ {timingPoints} ], objects=[ {objects} ] }}"; } - - public int GetMaxCombo() + + public int GetMaxCombo(bool onlyCount300=false) { int res = 0; int tIndex = -1; @@ -77,7 +163,8 @@ public int GetMaxCombo() foreach (HitObject obj in Objects) { - if ((obj.Type & HitObjectType.Slider) == 0) { + if (onlyCount300 || (obj.Type & HitObjectType.Slider) == 0) + { //non-sliders add 1 combo res++; continue;