2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-12-07 13:42:36 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2017-12-22 20:42:54 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
|
using osu.Framework.Lists;
|
2017-04-06 10:41:16 +08:00
|
|
|
|
using osu.Game.Audio;
|
2017-07-26 12:22:46 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
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
|
|
|
|
|
2017-12-25 15:41:18 +08:00
|
|
|
|
private List<SampleInfo> samples;
|
|
|
|
|
|
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-12-25 15:41:18 +08:00
|
|
|
|
public List<SampleInfo> Samples
|
|
|
|
|
{
|
|
|
|
|
get => samples ?? (samples = new List<SampleInfo>());
|
|
|
|
|
set => samples = value;
|
|
|
|
|
}
|
2017-03-16 15:55:08 +08:00
|
|
|
|
|
2017-12-21 15:02:33 +08:00
|
|
|
|
[JsonIgnore]
|
2017-12-23 15:31:45 +08:00
|
|
|
|
public SampleControlPoint SampleControlPoint;
|
2017-12-21 15:02:33 +08:00
|
|
|
|
|
2017-09-12 09:01:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this <see cref="HitObject"/> is in Kiai time.
|
|
|
|
|
/// </summary>
|
2017-12-07 13:42:36 +08:00
|
|
|
|
[JsonIgnore]
|
2017-09-12 09:01:07 +08:00
|
|
|
|
public bool Kiai { get; private set; }
|
|
|
|
|
|
2018-02-02 17:47:10 +08:00
|
|
|
|
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
|
|
|
|
|
|
|
|
|
private HitWindows hitWindows;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-02-08 16:38:46 +08:00
|
|
|
|
/// The hit windows for this <see cref="HitObject"/>.
|
2018-02-02 17:47:10 +08:00
|
|
|
|
/// </summary>
|
2018-02-02 17:53:05 +08:00
|
|
|
|
public HitWindows HitWindows
|
|
|
|
|
{
|
|
|
|
|
get => hitWindows ?? (hitWindows = new HitWindows(overallDifficulty));
|
|
|
|
|
protected set => hitWindows = value;
|
|
|
|
|
}
|
2018-02-02 17:47:10 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
private readonly SortedList<HitObject> nestedHitObjects = new SortedList<HitObject>((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects;
|
|
|
|
|
|
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-12-22 20:42:54 +08:00
|
|
|
|
public void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
|
|
|
|
{
|
|
|
|
|
ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
|
|
|
|
|
|
|
|
|
nestedHitObjects.Clear();
|
|
|
|
|
CreateNestedHitObjects();
|
|
|
|
|
nestedHitObjects.ForEach(h => h.ApplyDefaults(controlPointInfo, difficulty));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-04-05 20:59:07 +08:00
|
|
|
|
{
|
2017-12-23 15:31:45 +08:00
|
|
|
|
SampleControlPoint samplePoint = controlPointInfo.SamplePointAt(StartTime);
|
2017-09-12 09:01:07 +08:00
|
|
|
|
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
|
|
|
|
|
2017-12-07 13:42:36 +08:00
|
|
|
|
Kiai = effectPoint.KiaiMode;
|
2017-12-23 15:31:45 +08:00
|
|
|
|
SampleControlPoint = samplePoint;
|
2018-02-02 17:47:10 +08:00
|
|
|
|
|
|
|
|
|
overallDifficulty = difficulty.OverallDifficulty;
|
|
|
|
|
hitWindows = null;
|
2017-04-05 20:59:07 +08:00
|
|
|
|
}
|
2017-12-22 20:42:54 +08:00
|
|
|
|
|
|
|
|
|
protected virtual void CreateNestedHitObjects()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void AddNested(HitObject hitObject) => nestedHitObjects.Add(hitObject);
|
2016-08-31 11:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|