2019-08-20 18:17:27 +00: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 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2022-06-06 21:29:53 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
2019-08-20 18:17:27 +00:00
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
{
|
|
|
|
public partial class DrawableSpinnerTick : DrawableOsuHitObject
|
|
|
|
{
|
|
|
|
public override bool DisplayResult => false;
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
public DrawableSpinnerTick()
|
2022-06-06 21:29:53 +00:00
|
|
|
: this(null)
|
2020-11-12 06:59:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-20 18:17:27 +00:00
|
|
|
public DrawableSpinnerTick(SpinnerTick spinnerTick)
|
|
|
|
: base(spinnerTick)
|
|
|
|
{
|
2022-06-06 21:29:53 +00:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-08-20 18:17:27 +00: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-23 19:26:25 +00:00
|
|
|
protected override void OnApply()
|
|
|
|
{
|
|
|
|
base.OnApply();
|
|
|
|
|
2023-11-01 09:28:05 +00: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-23 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 02:34:12 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Apply a judgement result.
|
|
|
|
/// </summary>
|
2020-07-21 10:48:44 +00:00
|
|
|
/// <param name="hit">Whether this tick was reached.</param>
|
2024-01-25 16:25:41 +00:00
|
|
|
internal void TriggerResult(bool hit)
|
|
|
|
{
|
2024-02-05 12:35:41 +00:00
|
|
|
if (hit)
|
|
|
|
ApplyMaxResult();
|
|
|
|
else
|
|
|
|
ApplyMinResult();
|
2024-01-25 16:25:41 +00:00
|
|
|
}
|
2019-08-20 18:17:27 +00:00
|
|
|
}
|
|
|
|
}
|