diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs
index 13fa61f536..70604855e9 100644
--- a/osu.Game/Rulesets/Objects/HitObject.cs
+++ b/osu.Game/Rulesets/Objects/HitObject.cs
@@ -51,16 +51,10 @@ namespace osu.Game.Rulesets.Objects
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
- private HitWindows hitWindows;
-
///
/// The hit windows for this .
///
- public HitWindows HitWindows
- {
- get => hitWindows ?? (hitWindows = new HitWindows(overallDifficulty));
- protected set => hitWindows = value;
- }
+ public HitWindows HitWindows { get; set; }
private readonly SortedList nestedHitObjects = new SortedList((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
@@ -78,7 +72,11 @@ namespace osu.Game.Rulesets.Objects
nestedHitObjects.Clear();
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)
@@ -89,8 +87,9 @@ namespace osu.Game.Rulesets.Objects
Kiai = effectPoint.KiaiMode;
SampleControlPoint = samplePoint;
- overallDifficulty = difficulty.OverallDifficulty;
- hitWindows = null;
+ if (HitWindows == null)
+ HitWindows = CreateHitWindows();
+ HitWindows?.SetDifficulty(difficulty.OverallDifficulty);
}
protected virtual void CreateNestedHitObjects()
@@ -98,5 +97,11 @@ namespace osu.Game.Rulesets.Objects
}
protected void AddNested(HitObject hitObject) => nestedHitObjects.Add(hitObject);
+
+ ///
+ /// Creates the for this .
+ ///
+ ///
+ protected virtual HitWindows CreateHitWindows() => null;
}
}
diff --git a/osu.Game/Rulesets/Objects/HitWindows.cs b/osu.Game/Rulesets/Objects/HitWindows.cs
index bf0878a408..7610593d6a 100644
--- a/osu.Game/Rulesets/Objects/HitWindows.cs
+++ b/osu.Game/Rulesets/Objects/HitWindows.cs
@@ -63,10 +63,10 @@ namespace osu.Game.Rulesets.Objects
public bool AllowsOk;
///
- /// 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.
///
/// The parameter.
- public HitWindows(double difficulty)
+ public virtual void SetDifficulty(double difficulty)
{
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);