1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 10:17:32 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs

54 lines
1.8 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking
{
private readonly Slider slider;
2018-04-13 17:19:50 +08:00
/// <summary>
/// The judgement text is provided by the <see cref="DrawableSlider"/>.
/// </summary>
public override bool DisplayResult => false;
2018-04-13 17:19:50 +08:00
public bool Tracking { get; set; }
2018-11-09 12:58:46 +08:00
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> pathVersion = new Bindable<int>();
2018-11-09 12:58:46 +08:00
public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle)
2018-04-13 17:19:50 +08:00
: base(hitCircle)
{
this.slider = slider;
2018-04-13 17:19:50 +08:00
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fit;
AlwaysPresent = true;
2018-11-09 12:58:46 +08:00
positionBindable.BindTo(hitCircle.PositionBindable);
pathVersion.BindTo(slider.Path.Version);
2018-11-14 13:29:22 +08:00
positionBindable.BindValueChanged(_ => updatePosition());
pathVersion.BindValueChanged(_ => updatePosition(), true);
// TODO: This has no drawable content. Support for skins should be added.
2018-04-13 17:19:50 +08:00
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
2018-04-13 17:19:50 +08:00
{
if (!userTriggered && timeOffset >= 0)
2020-09-29 13:35:43 +08:00
ApplyResult(r => r.Type = Tracking ? r.Judgement.MaxResult : r.Judgement.MinResult);
2018-04-13 17:19:50 +08:00
}
private void updatePosition() => Position = HitObject.Position - slider.Position;
2018-04-13 17:19:50 +08:00
}
}