2017-02-07 04:59:30 +00: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 03:33:01 +00:00
|
|
|
|
|
2017-04-06 02:41:16 +00:00
|
|
|
|
using osu.Game.Audio;
|
2017-07-26 04:22:46 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 04:55:18 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-04-21 07:18:34 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2016-08-31 03:33:01 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Objects
|
2016-08-31 03:33:01 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-03-13 10:15:25 +00: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 03:33:01 +00:00
|
|
|
|
/// </summary>
|
2017-03-13 10:15:25 +00:00
|
|
|
|
public class HitObject
|
2016-08-31 03:33:01 +00:00
|
|
|
|
{
|
2017-03-13 10:15:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The time at which the HitObject starts.
|
|
|
|
|
/// </summary>
|
2017-05-26 06:53:49 +00:00
|
|
|
|
public virtual double StartTime { get; set; }
|
2017-03-13 10:15:25 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-06 02:41:16 +00:00
|
|
|
|
/// The samples to be played when this hit object is hit.
|
2017-04-21 09:49:49 +00:00
|
|
|
|
/// <para>
|
2017-04-21 11:42:13 +00:00
|
|
|
|
/// In the case of <see cref="IHasRepeats"/> types, this is the sample of the curve body
|
2017-04-21 09:49:49 +00:00
|
|
|
|
/// and can be treated as the default samples for the hit object.
|
|
|
|
|
/// </para>
|
2017-03-13 10:15:25 +00:00
|
|
|
|
/// </summary>
|
2017-04-26 05:12:21 +00:00
|
|
|
|
public SampleInfoList Samples = new SampleInfoList();
|
2017-03-16 07:55:08 +00:00
|
|
|
|
|
2017-09-12 01:01:07 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this <see cref="HitObject"/> is in Kiai time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Kiai { get; private set; }
|
|
|
|
|
|
2017-03-16 07:55:08 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Applies default values to this HitObject.
|
|
|
|
|
/// </summary>
|
2017-05-23 04:55:18 +00:00
|
|
|
|
/// <param name="controlPointInfo">The control points.</param>
|
2017-03-16 08:24:41 +00:00
|
|
|
|
/// <param name="difficulty">The difficulty settings to use.</param>
|
2017-05-23 04:55:18 +00:00
|
|
|
|
public virtual void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-04-05 12:59:07 +00:00
|
|
|
|
{
|
2017-05-23 04:55:18 +00:00
|
|
|
|
SoundControlPoint soundPoint = controlPointInfo.SoundPointAt(StartTime);
|
2017-09-12 01:01:07 +00:00
|
|
|
|
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
|
|
|
|
|
|
|
|
|
Kiai |= effectPoint.KiaiMode;
|
2017-04-05 12:59:07 +00:00
|
|
|
|
|
2017-04-21 07:18:34 +00:00
|
|
|
|
// Initialize first sample
|
2017-05-23 04:55:18 +00:00
|
|
|
|
Samples.ForEach(s => initializeSampleInfo(s, soundPoint));
|
2017-04-05 12:59:07 +00:00
|
|
|
|
|
2017-04-21 07:18:34 +00:00
|
|
|
|
// Initialize any repeat samples
|
|
|
|
|
var repeatData = this as IHasRepeats;
|
2017-05-23 04:55:18 +00:00
|
|
|
|
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, soundPoint)));
|
2017-04-21 07:18:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 04:55:18 +00:00
|
|
|
|
private void initializeSampleInfo(SampleInfo sample, SoundControlPoint soundPoint)
|
2017-04-21 07:18:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (sample.Volume == 0)
|
2017-05-23 04:55:18 +00:00
|
|
|
|
sample.Volume = soundPoint?.SampleVolume ?? 0;
|
2017-04-21 07:18:34 +00:00
|
|
|
|
|
|
|
|
|
// If the bank is not assigned a name, assign it from the control point
|
|
|
|
|
if (string.IsNullOrEmpty(sample.Bank))
|
2017-05-23 04:55:18 +00:00
|
|
|
|
sample.Bank = soundPoint?.SampleBank ?? @"normal";
|
2017-04-05 12:59:07 +00:00
|
|
|
|
}
|
2016-08-31 03:33:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|