2019-08-21 02:17:27 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-06-07 05:29:53 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
2019-08-21 02:17:27 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
{
|
|
|
|
public partial class DrawableSpinnerTick : DrawableOsuHitObject
|
|
|
|
{
|
|
|
|
public override bool DisplayResult => false;
|
|
|
|
|
2020-11-12 14:59:48 +08:00
|
|
|
public DrawableSpinnerTick()
|
2022-06-07 05:29:53 +08:00
|
|
|
: this(null)
|
2020-11-12 14:59:48 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-21 02:17:27 +08:00
|
|
|
public DrawableSpinnerTick(SpinnerTick spinnerTick)
|
|
|
|
: base(spinnerTick)
|
|
|
|
{
|
2022-06-07 05:29:53 +08:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-08-21 02:17:27 +08:00
|
|
|
}
|
|
|
|
|
Fix spinner ticks not playing samples correctly sometimes
Noticed this during work on https://github.com/ppy/osu/pull/25185.
In some circumstances, it seemed that spinner bonus ticks (and mostly
them specifically) would not always play with the correct volume.
Hours of debugging later pointed at a trace at
`DrawableAudioWrapper.refreshLayoutFromParent()` not firing sometimes.
Initially I thought it to be some sort of framework bug, but after
preparing a diff and running final checks, I noticed that sometimes
the sample was being played *by a `PoolableSkinnableSample` that wasn't
loaded*. And determining why *that* is the case turned out with this
diff.
As it happens, spinner ticks get assigned a start time proportionally,
i.e. the 1st of 10 ticks is placed at 10% of the duration, the 2nd
at 20%, and so on. The start time generally shouldn't matter,
because the spinner is manually judging the ticks. *However*, the ticks
*still* receive a lifetime start / end in the same way normal objects
do, which means that in some cases they can *not be alive* when they're
hit, which means that the `DrawableAudioWrapper` flow *hasn't had
a chance to run*, and rightly so.
To fix, ensure that all spinner ticks are alive throughout the entirety
of the spinner's duration.
2023-10-24 03:26:25 +08:00
|
|
|
protected override void OnApply()
|
|
|
|
{
|
|
|
|
base.OnApply();
|
|
|
|
|
2023-11-01 17:28:05 +08:00
|
|
|
// Lifetime will be managed by `DrawableSpinner`.
|
|
|
|
LifetimeStart = double.MaxValue;
|
Fix spinner ticks not playing samples correctly sometimes
Noticed this during work on https://github.com/ppy/osu/pull/25185.
In some circumstances, it seemed that spinner bonus ticks (and mostly
them specifically) would not always play with the correct volume.
Hours of debugging later pointed at a trace at
`DrawableAudioWrapper.refreshLayoutFromParent()` not firing sometimes.
Initially I thought it to be some sort of framework bug, but after
preparing a diff and running final checks, I noticed that sometimes
the sample was being played *by a `PoolableSkinnableSample` that wasn't
loaded*. And determining why *that* is the case turned out with this
diff.
As it happens, spinner ticks get assigned a start time proportionally,
i.e. the 1st of 10 ticks is placed at 10% of the duration, the 2nd
at 20%, and so on. The start time generally shouldn't matter,
because the spinner is manually judging the ticks. *However*, the ticks
*still* receive a lifetime start / end in the same way normal objects
do, which means that in some cases they can *not be alive* when they're
hit, which means that the `DrawableAudioWrapper` flow *hasn't had
a chance to run*, and rightly so.
To fix, ensure that all spinner ticks are alive throughout the entirety
of the spinner's duration.
2023-10-24 03:26:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-25 10:34:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Apply a judgement result.
|
|
|
|
/// </summary>
|
2020-07-21 18:48:44 +08:00
|
|
|
/// <param name="hit">Whether this tick was reached.</param>
|
2020-09-29 13:35:43 +08:00
|
|
|
internal void TriggerResult(bool hit) => ApplyResult(r => r.Type = hit ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2019-08-21 02:17:27 +08:00
|
|
|
}
|
|
|
|
}
|