mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 19:57:36 +08:00
78 lines
2.2 KiB
C#
78 lines
2.2 KiB
C#
// 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.
|
|
|
|
#nullable disable
|
|
|
|
using System.Diagnostics;
|
|
using JetBrains.Annotations;
|
|
using osu.Framework.Bindables;
|
|
using osu.Game.Rulesets.Osu.UI;
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
{
|
|
public partial class DrawableSliderHead : DrawableHitCircle
|
|
{
|
|
public new SliderHeadCircle HitObject => (SliderHeadCircle)base.HitObject;
|
|
|
|
[CanBeNull]
|
|
public Slider Slider => DrawableSlider?.HitObject;
|
|
|
|
public DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
|
|
|
|
public override bool DisplayResult => HitObject?.JudgeAsNormalHitCircle ?? base.DisplayResult;
|
|
|
|
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
|
|
|
protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle;
|
|
|
|
public DrawableSliderHead()
|
|
{
|
|
}
|
|
|
|
public DrawableSliderHead(SliderHeadCircle h)
|
|
: base(h)
|
|
{
|
|
}
|
|
|
|
protected override void OnFree()
|
|
{
|
|
base.OnFree();
|
|
|
|
pathVersion.UnbindFrom(DrawableSlider.PathVersion);
|
|
}
|
|
|
|
protected override void UpdatePosition()
|
|
{
|
|
// Slider head is always drawn at (0,0).
|
|
}
|
|
|
|
protected override void OnApply()
|
|
{
|
|
base.OnApply();
|
|
|
|
pathVersion.BindTo(DrawableSlider.PathVersion);
|
|
|
|
CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit;
|
|
}
|
|
|
|
protected override HitResult ResultFor(double timeOffset)
|
|
{
|
|
Debug.Assert(HitObject != null);
|
|
|
|
if (HitObject.JudgeAsNormalHitCircle)
|
|
return base.ResultFor(timeOffset);
|
|
|
|
// If not judged as a normal hitcircle, judge as a slider tick instead. This is the classic osu!stable scoring.
|
|
var result = base.ResultFor(timeOffset);
|
|
return result.IsHit() ? HitResult.LargeTickHit : HitResult.LargeTickMiss;
|
|
}
|
|
|
|
public override void Shake()
|
|
{
|
|
base.Shake();
|
|
DrawableSlider.Shake();
|
|
}
|
|
}
|
|
}
|