2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
2017-04-06 10:41:16 +08:00
|
|
|
|
using osu.Game.Audio;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-03-16 16:24:41 +08:00
|
|
|
|
using osu.Game.Database;
|
2017-04-21 15:18:34 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Objects
|
2016-08-31 11:33:01 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-03-13 18:15:25 +08:00
|
|
|
|
/// A HitObject describes an object in a Beatmap.
|
|
|
|
|
/// <para>
|
|
|
|
|
/// HitObjects may contain more properties for which you should be checking through the IHas* types.
|
|
|
|
|
/// </para>
|
2016-08-31 11:33:01 +08:00
|
|
|
|
/// </summary>
|
2017-03-13 18:15:25 +08:00
|
|
|
|
public class HitObject
|
2016-08-31 11:33:01 +08:00
|
|
|
|
{
|
2017-03-13 18:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The time at which the HitObject starts.
|
|
|
|
|
/// </summary>
|
2017-05-26 14:53:49 +08:00
|
|
|
|
public virtual double StartTime { get; set; }
|
2017-03-13 18:15:25 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-06 10:41:16 +08:00
|
|
|
|
/// The samples to be played when this hit object is hit.
|
2017-04-21 17:49:49 +08:00
|
|
|
|
/// <para>
|
2017-04-21 19:42:13 +08:00
|
|
|
|
/// In the case of <see cref="IHasRepeats"/> types, this is the sample of the curve body
|
2017-04-21 17:49:49 +08:00
|
|
|
|
/// and can be treated as the default samples for the hit object.
|
|
|
|
|
/// </para>
|
2017-03-13 18:15:25 +08:00
|
|
|
|
/// </summary>
|
2017-04-26 13:12:21 +08:00
|
|
|
|
public SampleInfoList Samples = new SampleInfoList();
|
2017-03-16 15:55:08 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Applies default values to this HitObject.
|
|
|
|
|
/// </summary>
|
2017-05-23 12:55:18 +08:00
|
|
|
|
/// <param name="controlPointInfo">The control points.</param>
|
2017-03-16 16:24:41 +08:00
|
|
|
|
/// <param name="difficulty">The difficulty settings to use.</param>
|
2017-05-23 12:55:18 +08:00
|
|
|
|
public virtual void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-04-05 20:59:07 +08:00
|
|
|
|
{
|
2017-05-23 12:55:18 +08:00
|
|
|
|
SoundControlPoint soundPoint = controlPointInfo.SoundPointAt(StartTime);
|
2017-04-05 20:59:07 +08:00
|
|
|
|
|
2017-04-21 15:18:34 +08:00
|
|
|
|
// Initialize first sample
|
2017-05-23 12:55:18 +08:00
|
|
|
|
Samples.ForEach(s => initializeSampleInfo(s, soundPoint));
|
2017-04-05 20:59:07 +08:00
|
|
|
|
|
2017-04-21 15:18:34 +08:00
|
|
|
|
// Initialize any repeat samples
|
|
|
|
|
var repeatData = this as IHasRepeats;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, soundPoint)));
|
2017-04-21 15:18:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 12:55:18 +08:00
|
|
|
|
private void initializeSampleInfo(SampleInfo sample, SoundControlPoint soundPoint)
|
2017-04-21 15:18:34 +08:00
|
|
|
|
{
|
|
|
|
|
if (sample.Volume == 0)
|
2017-05-23 12:55:18 +08:00
|
|
|
|
sample.Volume = soundPoint?.SampleVolume ?? 0;
|
2017-04-21 15:18:34 +08:00
|
|
|
|
|
|
|
|
|
// If the bank is not assigned a name, assign it from the control point
|
|
|
|
|
if (string.IsNullOrEmpty(sample.Bank))
|
2017-05-23 12:55:18 +08:00
|
|
|
|
sample.Bank = soundPoint?.SampleBank ?? @"normal";
|
2017-04-05 20:59:07 +08:00
|
|
|
|
}
|
2016-08-31 11:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|