mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 04:32:55 +08:00
Restructure HitWindows to allow outside setting
This commit is contained in:
parent
0afe33d32f
commit
8216bc311a
@ -51,16 +51,10 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
||||||
|
|
||||||
private HitWindows hitWindows;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The hit windows for this <see cref="HitObject"/>.
|
/// The hit windows for this <see cref="HitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitWindows HitWindows
|
public HitWindows HitWindows { get; set; }
|
||||||
{
|
|
||||||
get => hitWindows ?? (hitWindows = new HitWindows(overallDifficulty));
|
|
||||||
protected set => hitWindows = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly SortedList<HitObject> nestedHitObjects = new SortedList<HitObject>((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
private readonly SortedList<HitObject> nestedHitObjects = new SortedList<HitObject>((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
||||||
|
|
||||||
@ -78,7 +72,11 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
nestedHitObjects.Clear();
|
nestedHitObjects.Clear();
|
||||||
CreateNestedHitObjects();
|
CreateNestedHitObjects();
|
||||||
nestedHitObjects.ForEach(h => h.ApplyDefaults(controlPointInfo, difficulty));
|
nestedHitObjects.ForEach(h =>
|
||||||
|
{
|
||||||
|
h.HitWindows = HitWindows;
|
||||||
|
h.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
@ -89,8 +87,9 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
Kiai = effectPoint.KiaiMode;
|
Kiai = effectPoint.KiaiMode;
|
||||||
SampleControlPoint = samplePoint;
|
SampleControlPoint = samplePoint;
|
||||||
|
|
||||||
overallDifficulty = difficulty.OverallDifficulty;
|
if (HitWindows == null)
|
||||||
hitWindows = null;
|
HitWindows = CreateHitWindows();
|
||||||
|
HitWindows?.SetDifficulty(difficulty.OverallDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void CreateNestedHitObjects()
|
protected virtual void CreateNestedHitObjects()
|
||||||
@ -98,5 +97,11 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void AddNested(HitObject hitObject) => nestedHitObjects.Add(hitObject);
|
protected void AddNested(HitObject hitObject) => nestedHitObjects.Add(hitObject);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the <see cref="HitWindows"/> for this <see cref="HitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected virtual HitWindows CreateHitWindows() => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
public bool AllowsOk;
|
public bool AllowsOk;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs hit windows by fitting a parameter to a 2-part piecewise linear function for each hit window.
|
/// Sets hit windows with values that correspond to a difficulty parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="difficulty">The parameter.</param>
|
/// <param name="difficulty">The parameter.</param>
|
||||||
public HitWindows(double difficulty)
|
public virtual void SetDifficulty(double difficulty)
|
||||||
{
|
{
|
||||||
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
|
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
|
||||||
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
||||||
|
Loading…
Reference in New Issue
Block a user