Fix subscribing to `ApplyCustomUpdateState` too much

This commit is contained in:
Bartłomiej Dach 2024-02-28 13:20:41 +01:00
parent bbdd85020c
commit b5ce2642aa
No known key found for this signature in database
1 changed files with 8 additions and 1 deletions

View File

@ -85,7 +85,12 @@ protected override void UpdateInitialTransforms()
// as they may be cleared via the `updateState()` DHO flow,
// so use `ApplyCustomUpdateState` instead. which does not have this pitfall.
if (piece is DrawableHitObject drawableObjectPiece)
drawableObjectPiece.ApplyCustomUpdateState += (dho, _) => applyDim(dho);
{
// this method can be called multiple times, and we don't want to subscribe to the event more than once,
// so this is what it is going to have to be...
drawableObjectPiece.ApplyCustomUpdateState -= applyDimToDrawableHitObject;
drawableObjectPiece.ApplyCustomUpdateState += applyDimToDrawableHitObject;
}
else
applyDim(piece);
}
@ -96,6 +101,8 @@ void applyDim(Drawable piece)
using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW))
piece.FadeColour(Color4.White, 100);
}
void applyDimToDrawableHitObject(DrawableHitObject dho, ArmedState _) => applyDim(dho);
}
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;