Implement RepeatSamples in IHasRepeats.

This commit is contained in:
smoogipooo
2017-04-21 16:18:34 +09:00
parent b4a4597366
commit ca824de91c
4 changed files with 32 additions and 10 deletions

View File

@ -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
/// <summary>
/// The time at which the HitObject starts.
/// </summary>
public double StartTime { get; set; }
public double StartTime;
/// <summary>
/// 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";
}
}
}