diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index ad07c03b96..e6e3f1d07f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy HitObject firstObject = Beatmap.HitObjects.FirstOrDefault(); double drainTime = (lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0); - drainTime -= Beatmap.EventInfo.TotalBreakTime; + drainTime -= Beatmap.TotalBreakTime; if (drainTime == 0) drainTime = 10000; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs index d4957d41a9..d645882511 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs @@ -15,51 +15,51 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// /// Keep the same as last row. /// - ForceStack = 1, + ForceStack = 1 << 0, /// /// Keep different from last row. /// - ForceNotStack = 2, + ForceNotStack = 1 << 1, /// /// Keep as single note at its original position. /// - KeepSingle = 4, + KeepSingle = 1 << 2, /// /// Use a lower random value. /// - LowProbability = 8, + LowProbability = 1 << 3, /// /// Reserved. /// - Alternate = 16, + Alternate = 1 << 4, /// /// Ignore the repeat count. /// - ForceSigSlider = 32, + ForceSigSlider = 1 << 5, /// /// Convert slider to circle. /// - ForceNotSlider = 64, + ForceNotSlider = 1 << 6, /// /// Notes gathered together. /// - Gathered = 128, - Mirror = 256, + Gathered = 1 << 7, + Mirror = 1 << 8, /// /// Change 0 -> 6. /// - Reverse = 512, + Reverse = 1 << 9, /// /// 1 -> 5 -> 1 -> 5 like reverse. /// - Cycle = 1024, + Cycle = 1 << 10, /// /// Next note will be at column + 1. /// - Stair = 2048, + Stair = 1 << 11, /// /// Next note will be at column - 1. /// - ReverseStair = 4096 + ReverseStair = 1 << 12 } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs index cbde1f0f53..15d31406e9 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Mania.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns @@ -21,16 +20,16 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns public IEnumerable HitObjects => hitObjects; /// - /// Whether this pattern already contains a hit object in a code. + /// Check whether a column of this patterns contains a hit object. /// /// The column index. - /// Whether this pattern already contains a hit object in - public bool IsFilled(int column) => hitObjects.Exists(h => h.Column == column); + /// Whether the column with index contains a hit object. + public bool ColumnHasObject(int column) => hitObjects.Exists(h => h.Column == column); /// /// Amount of columns taken up by hit objects in this pattern. /// - public int ColumnsFilled => HitObjects.GroupBy(h => h.Column).Count(); + public int ColumnWithObjects => HitObjects.GroupBy(h => h.Column).Count(); /// /// Adds a hit object to this pattern. @@ -42,10 +41,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// Copies hit object from another pattern to this one. /// /// The other pattern. - public void Add(Pattern other) - { - other.HitObjects.ForEach(Add); - } + public void Add(Pattern other) => hitObjects.AddRange(other.HitObjects); /// /// Clears this pattern, removing all hit objects. diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index a64002e0b0..608b2fcd19 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -2,11 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Rulesets.Objects; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Beatmaps { @@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps { public BeatmapInfo BeatmapInfo; public TimingInfo TimingInfo = new TimingInfo(); - public EventInfo EventInfo = new EventInfo(); + public List Breaks = new List(); public readonly List ComboColors = new List { new Color4(17, 136, 170, 255), @@ -34,6 +34,11 @@ namespace osu.Game.Beatmaps /// public List HitObjects; + /// + /// Total amount of break time in the beatmap. + /// + public double TotalBreakTime => Breaks.Sum(b => b.Duration); + /// /// Constructs a new beatmap. /// @@ -42,7 +47,7 @@ namespace osu.Game.Beatmaps { BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo; TimingInfo = original?.TimingInfo ?? TimingInfo; - EventInfo = original?.EventInfo ?? EventInfo; + Breaks = original?.Breaks ?? Breaks; ComboColors = original?.ComboColors ?? ComboColors; } } diff --git a/osu.Game/Beatmaps/Events/BackgroundEvent.cs b/osu.Game/Beatmaps/Events/BackgroundEvent.cs deleted file mode 100644 index 215373bd3b..0000000000 --- a/osu.Game/Beatmaps/Events/BackgroundEvent.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Beatmaps.Events -{ - public class BackgroundEvent : Event - { - /// - /// The file name. - /// - public string Filename; - } -} diff --git a/osu.Game/Beatmaps/Events/Event.cs b/osu.Game/Beatmaps/Events/Event.cs deleted file mode 100644 index 3af3909462..0000000000 --- a/osu.Game/Beatmaps/Events/Event.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Beatmaps.Events -{ - public abstract class Event - { - /// - /// The event start time. - /// - public double StartTime; - } -} diff --git a/osu.Game/Beatmaps/Events/EventInfo.cs b/osu.Game/Beatmaps/Events/EventInfo.cs deleted file mode 100644 index 3ba3d5ba03..0000000000 --- a/osu.Game/Beatmaps/Events/EventInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Collections.Generic; -using System.Linq; - -namespace osu.Game.Beatmaps.Events -{ - public class EventInfo - { - /// - /// All the background events. - /// - public readonly List Backgrounds = new List(); - - /// - /// All the break events. - /// - public readonly List Breaks = new List(); - - /// - /// Total duration of all breaks. - /// - public double TotalBreakTime => Breaks.Sum(b => b.Duration); - - /// - /// Retrieves the active background at a time. - /// - /// The time to retrieve the background at. - /// The background. - public BackgroundEvent BackgroundAt(double time) => Backgrounds.FirstOrDefault(b => b.StartTime <= time); - } -} diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 772c0e9c07..04208337c7 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using System.IO; using OpenTK.Graphics; -using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Objects.Legacy; @@ -217,18 +216,12 @@ namespace osu.Game.Beatmaps.Formats case EventType.Background: string filename = split[2].Trim('"'); - beatmap.EventInfo.Backgrounds.Add(new BackgroundEvent - { - StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), - Filename = filename - }); - if (type == EventType.Background) beatmap.BeatmapInfo.Metadata.BackgroundFile = filename; break; case EventType.Break: - var breakEvent = new BreakEvent + var breakEvent = new BreakPeriod { StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo) @@ -237,7 +230,7 @@ namespace osu.Game.Beatmaps.Formats if (!breakEvent.HasEffect) return; - beatmap.EventInfo.Breaks.Add(breakEvent); + beatmap.Breaks.Add(breakEvent); break; } } diff --git a/osu.Game/Beatmaps/Events/BreakEvent.cs b/osu.Game/Beatmaps/Timing/BreakPeriod.cs similarity index 70% rename from osu.Game/Beatmaps/Events/BreakEvent.cs rename to osu.Game/Beatmaps/Timing/BreakPeriod.cs index 78e33f2fbb..fb307b7144 100644 --- a/osu.Game/Beatmaps/Events/BreakEvent.cs +++ b/osu.Game/Beatmaps/Timing/BreakPeriod.cs @@ -1,27 +1,32 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Beatmaps.Events +namespace osu.Game.Beatmaps.Timing { - public class BreakEvent : Event + public class BreakPeriod { /// /// The minimum duration required for a break to have any effect. /// private const double min_break_duration = 650; + /// + /// The break start time. + /// + public double StartTime; + /// /// The break end time. /// public double EndTime; /// - /// The duration of the break. + /// The break duration. /// public double Duration => EndTime - StartTime; /// - /// Whether the break has any effect. Breaks that are too short are culled before they reach the EventInfo. + /// Whether the break has any effect. Breaks that are too short are culled before they are added to the beatmap. /// public bool HasEffect => Duration >= min_break_duration; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index acc6fd4abe..1631311ef6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,10 +74,6 @@ - - - - @@ -91,6 +87,7 @@ +