Rework and rename to OnNewDrawableHitObject.

The semantics is changed and hopefully more clear.
This commit is contained in:
ekrctb
2020-11-21 00:27:19 +09:00
parent 27f5a99726
commit 82aefa3868
6 changed files with 36 additions and 32 deletions

View File

@ -74,6 +74,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
public event Action<DrawableHitObject, JudgementResult> OnRevertResult;
/// <summary>
/// Invoked when a new nested hit object is created by <see cref="CreateNestedHitObject" />.
/// </summary>
internal event Action<DrawableHitObject> OnNestedDrawableCreated;
/// <summary>
/// Whether a visual indicator should be displayed when a scoring result occurs.
/// </summary>
@ -214,10 +219,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
foreach (var h in HitObject.NestedHitObjects)
{
var drawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h)
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h);
var drawableNested = pooledDrawableNested
?? CreateNestedHitObject(h)
?? throw new InvalidOperationException($"{nameof(CreateNestedHitObject)} returned null for {h.GetType().ReadableName()}.");
// Invoke the event only if this nested object is just created by `CreateNestedHitObject`.
if (pooledDrawableNested == null)
OnNestedDrawableCreated?.Invoke(drawableNested);
drawableNested.OnNewResult += onNewResult;
drawableNested.OnRevertResult += onRevertResult;
drawableNested.ApplyCustomUpdateState += onApplyCustomUpdateState;