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-03-16 16:24:41 +08:00
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
|
|
|
|
using osu.Game.Database;
|
2017-04-21 15:18:34 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-04-05 20:59:07 +08:00
|
|
|
|
using System.Collections.Generic;
|
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-04-21 15:18:34 +08:00
|
|
|
|
public double StartTime;
|
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-03-16 16:24:41 +08:00
|
|
|
|
/// <param name="difficulty">The difficulty settings to use.</param>
|
|
|
|
|
/// <param name="timing">The timing settings to use.</param>
|
2017-04-05 20:59:07 +08:00
|
|
|
|
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
|
|
|
|
{
|
2017-04-06 10:41:16 +08:00
|
|
|
|
ControlPoint overridePoint;
|
|
|
|
|
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
|
|
|
|
|
2017-04-21 15:18:34 +08:00
|
|
|
|
ControlPoint samplePoint = overridePoint ?? timingPoint;
|
2017-04-05 20:59:07 +08:00
|
|
|
|
|
2017-04-21 15:18:34 +08:00
|
|
|
|
// Initialize first sample
|
2017-04-21 17:49:49 +08:00
|
|
|
|
Samples.ForEach(s => initializeSampleInfo(s, samplePoint));
|
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;
|
|
|
|
|
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";
|
2017-04-05 20:59:07 +08:00
|
|
|
|
}
|
2016-08-31 11:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|