2022-07-14 23:52:45 +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-07-19 09:08:53 +00:00
|
|
|
|
using System.Diagnostics;
|
2022-07-14 23:52:45 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
|
{
|
|
|
|
|
public abstract class FollowCircle : CompositeDrawable
|
|
|
|
|
{
|
2022-07-15 07:40:48 +00:00
|
|
|
|
[Resolved]
|
2022-07-14 23:52:45 +00:00
|
|
|
|
protected DrawableHitObject? ParentObject { get; private set; }
|
|
|
|
|
|
2022-07-15 00:08:52 +00:00
|
|
|
|
protected FollowCircle()
|
2022-07-14 23:52:45 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2022-07-19 09:08:53 +00:00
|
|
|
|
((DrawableSlider?)ParentObject)?.Tracking.BindValueChanged(tracking =>
|
|
|
|
|
{
|
|
|
|
|
Debug.Assert(ParentObject != null);
|
|
|
|
|
if (ParentObject.Judged)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (tracking.NewValue)
|
|
|
|
|
OnSliderPress();
|
|
|
|
|
else
|
|
|
|
|
OnSliderRelease();
|
|
|
|
|
}, true);
|
2022-07-14 23:52:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
if (ParentObject != null)
|
|
|
|
|
{
|
|
|
|
|
ParentObject.HitObjectApplied += onHitObjectApplied;
|
|
|
|
|
onHitObjectApplied(ParentObject);
|
|
|
|
|
|
|
|
|
|
ParentObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
|
updateStateTransforms(ParentObject, ParentObject.State.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onHitObjectApplied(DrawableHitObject drawableObject)
|
|
|
|
|
{
|
|
|
|
|
this.ScaleTo(1f)
|
|
|
|
|
.FadeOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableObject, ArmedState state)
|
|
|
|
|
{
|
2022-07-21 01:07:02 +00:00
|
|
|
|
Debug.Assert(ParentObject != null);
|
|
|
|
|
|
2022-07-22 02:46:46 +00:00
|
|
|
|
switch (state)
|
2022-07-19 09:08:53 +00:00
|
|
|
|
{
|
2022-07-22 02:46:46 +00:00
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
switch (drawableObject)
|
|
|
|
|
{
|
|
|
|
|
case DrawableSliderTail:
|
|
|
|
|
// Use ParentObject instead of drawableObject because slider tail's
|
|
|
|
|
// HitStateUpdateTime is ~36ms before the actual slider end (aka slider
|
|
|
|
|
// tail leniency)
|
|
|
|
|
using (BeginAbsoluteSequence(ParentObject.HitStateUpdateTime))
|
|
|
|
|
OnSliderEnd();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DrawableSliderTick:
|
|
|
|
|
case DrawableSliderRepeat:
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
|
OnSliderTick();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
switch (drawableObject)
|
|
|
|
|
{
|
|
|
|
|
case DrawableSliderTail:
|
|
|
|
|
case DrawableSliderTick:
|
|
|
|
|
case DrawableSliderRepeat:
|
|
|
|
|
// Despite above comment, ok to use drawableObject.HitStateUpdateTime
|
|
|
|
|
// here, since on stable, the break anim plays right when the tail is
|
|
|
|
|
// missed, not when the slider ends
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
|
OnSliderBreak();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2022-07-19 09:08:53 +00:00
|
|
|
|
}
|
2022-07-14 23:52:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (ParentObject != null)
|
|
|
|
|
{
|
|
|
|
|
ParentObject.HitObjectApplied -= onHitObjectApplied;
|
|
|
|
|
ParentObject.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-19 09:08:53 +00:00
|
|
|
|
protected abstract void OnSliderPress();
|
|
|
|
|
|
|
|
|
|
protected abstract void OnSliderRelease();
|
2022-07-14 23:52:45 +00:00
|
|
|
|
|
2022-07-19 09:27:04 +00:00
|
|
|
|
protected abstract void OnSliderEnd();
|
2022-07-22 02:46:46 +00:00
|
|
|
|
|
|
|
|
|
protected abstract void OnSliderTick();
|
|
|
|
|
|
|
|
|
|
protected abstract void OnSliderBreak();
|
2022-07-14 23:52:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|