2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-10-02 04:41:22 +00:00
|
|
|
|
using System.Diagnostics;
|
2020-12-03 05:28:37 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2020-10-02 04:41:22 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-10-02 04:41:22 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Skinning;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
2020-10-02 04:41:22 +00:00
|
|
|
|
public class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking, ITrackSnaking
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-11-12 06:59:48 +00:00
|
|
|
|
public new SliderTailCircle HitObject => (SliderTailCircle)base.HitObject;
|
2018-10-29 06:36:43 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
[CanBeNull]
|
|
|
|
|
public Slider Slider => drawableSlider?.HitObject;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The judgement text is provided by the <see cref="DrawableSlider"/>.
|
|
|
|
|
/// </summary>
|
2018-08-06 02:31:46 +00:00
|
|
|
|
public override bool DisplayResult => false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public bool Tracking { get; set; }
|
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
private DrawableSlider drawableSlider;
|
2020-11-05 04:51:46 +00:00
|
|
|
|
private SkinnableDrawable circlePiece;
|
|
|
|
|
private Container scaleContainer;
|
2020-10-02 04:41:22 +00:00
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
|
public DrawableSliderTail()
|
|
|
|
|
: base(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 04:51:46 +00:00
|
|
|
|
public DrawableSliderTail(SliderTailCircle tailCircle)
|
2020-10-02 05:20:55 +00:00
|
|
|
|
: base(tailCircle)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-11-05 04:51:46 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-11-05 04:51:46 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
2020-10-02 04:41:22 +00:00
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-10-02 04:41:22 +00:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
scaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// no default for this; only visible in legacy skins.
|
|
|
|
|
circlePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
|
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
|
2020-10-02 04:41:22 +00:00
|
|
|
|
}
|
2018-11-14 05:29:22 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
protected override void OnParentReceived(DrawableHitObject parent)
|
|
|
|
|
{
|
|
|
|
|
base.OnParentReceived(parent);
|
|
|
|
|
|
|
|
|
|
drawableSlider = (DrawableSlider)parent;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 04:41:22 +00:00
|
|
|
|
protected override void UpdateInitialTransforms()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateInitialTransforms();
|
2019-10-08 08:56:56 +00:00
|
|
|
|
|
2020-10-02 04:41:22 +00:00
|
|
|
|
circlePiece.FadeInFromZero(HitObject.TimeFadeIn);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 07:19:07 +00:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2020-10-02 04:41:22 +00:00
|
|
|
|
{
|
2020-11-04 07:19:07 +00:00
|
|
|
|
base.UpdateHitStateTransforms(state);
|
2020-10-02 04:41:22 +00:00
|
|
|
|
|
|
|
|
|
Debug.Assert(HitObject.HitWindows != null);
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut(500);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
// todo: temporary / arbitrary
|
|
|
|
|
this.Delay(800).FadeOut();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (!userTriggered && timeOffset >= 0)
|
2020-09-29 05:35:43 +00:00
|
|
|
|
ApplyResult(r => r.Type = Tracking ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2018-10-29 06:36:43 +00:00
|
|
|
|
|
2020-10-02 05:20:55 +00:00
|
|
|
|
public void UpdateSnakingPosition(Vector2 start, Vector2 end) =>
|
2020-11-12 06:59:48 +00:00
|
|
|
|
Position = HitObject.RepeatIndex % 2 == 0 ? end : start;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|