diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 167bf21670..48c871d64d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -33,6 +33,8 @@ namespace osu.Game.Rulesets.Osu.Objects public double ProgressAt(double progress) => CurveObject.ProgressAt(progress); public int RepeatAt(double progress) => CurveObject.RepeatAt(progress); + public List> RepeatSamples => CurveObject.RepeatSamples; + public List ControlPoints => CurveObject.ControlPoints; public CurveType CurveType => CurveObject.CurveType; public double Distance => CurveObject.Distance; diff --git a/osu.Game/Rulesets/Objects/CurvedHitObject.cs b/osu.Game/Rulesets/Objects/CurvedHitObject.cs index 517c276242..b43c10476a 100644 --- a/osu.Game/Rulesets/Objects/CurvedHitObject.cs +++ b/osu.Game/Rulesets/Objects/CurvedHitObject.cs @@ -4,6 +4,10 @@ using OpenTK; using osu.Game.Rulesets.Objects.Types; using System.Collections.Generic; +using osu.Game.Audio; +using System; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Rulesets.Objects { @@ -34,6 +38,8 @@ namespace osu.Game.Rulesets.Objects set { Curve.Distance = value; } } + public List> RepeatSamples { get; set; } = new List>(); + public Vector2 PositionAt(double progress) => Curve.PositionAt(ProgressAt(progress)); public double ProgressAt(double progress) diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 240d110976..52f157d472 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -4,6 +4,7 @@ using osu.Game.Audio; using osu.Game.Beatmaps.Timing; using osu.Game.Database; +using osu.Game.Rulesets.Objects.Types; using System.Collections.Generic; namespace osu.Game.Rulesets.Objects @@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Objects /// /// The time at which the HitObject starts. /// - public double StartTime { get; set; } + public double StartTime; /// /// The samples to be played when this hit object is hit. @@ -36,17 +37,25 @@ namespace osu.Game.Rulesets.Objects ControlPoint overridePoint; ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint); - foreach (var sample in Samples) - { - if (sample.Volume == 0) - sample.Volume = (overridePoint ?? timingPoint)?.SampleVolume ?? 0; + ControlPoint samplePoint = overridePoint ?? timingPoint; - // If the bank is not assigned a name, assign it from the control point - if (!string.IsNullOrEmpty(sample.Bank)) - continue; + // Initialize first sample + foreach (SampleInfo sample in Samples) + initializeSampleInfo(sample, samplePoint); - sample.Bank = (overridePoint ?? timingPoint)?.SampleBank ?? @"normal"; - } + // Initialize any repeat samples + var repeatData = this as IHasRepeats; + repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, samplePoint))); + } + + private void initializeSampleInfo(SampleInfo sample, ControlPoint controlPoint) + { + if (sample.Volume == 0) + sample.Volume = controlPoint?.SampleVolume ?? 0; + + // If the bank is not assigned a name, assign it from the control point + if (string.IsNullOrEmpty(sample.Bank)) + sample.Bank = controlPoint?.SampleBank ?? @"normal"; } } } diff --git a/osu.Game/Rulesets/Objects/Types/IHasRepeats.cs b/osu.Game/Rulesets/Objects/Types/IHasRepeats.cs index f7058fd3c9..507f5974f7 100644 --- a/osu.Game/Rulesets/Objects/Types/IHasRepeats.cs +++ b/osu.Game/Rulesets/Objects/Types/IHasRepeats.cs @@ -1,6 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Audio; +using System.Collections.Generic; + namespace osu.Game.Rulesets.Objects.Types { /// @@ -12,5 +15,7 @@ namespace osu.Game.Rulesets.Objects.Types /// The amount of times the HitObject repeats. /// int RepeatCount { get; } + + List> RepeatSamples { get; } } }