2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-12-03 13:28:37 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using JetBrains.Annotations;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2023-07-18 11:31:21 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2021-02-03 21:12:20 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-10 00:11:56 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public partial class DrawableSliderHead : DrawableHitCircle
|
|
|
|
|
{
|
2021-02-03 20:25:05 +08:00
|
|
|
|
public new SliderHeadCircle HitObject => (SliderHeadCircle)base.HitObject;
|
|
|
|
|
|
2020-12-03 13:28:37 +08:00
|
|
|
|
[CanBeNull]
|
2020-12-03 19:10:16 +08:00
|
|
|
|
public Slider Slider => DrawableSlider?.HitObject;
|
|
|
|
|
|
2021-09-01 18:34:57 +08:00
|
|
|
|
public DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
|
2020-12-03 13:28:37 +08:00
|
|
|
|
|
2021-02-03 21:12:20 +08:00
|
|
|
|
public override bool DisplayResult => HitObject?.JudgeAsNormalHitCircle ?? base.DisplayResult;
|
|
|
|
|
|
2019-12-05 18:53:31 +08:00
|
|
|
|
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
2018-11-09 12:58:46 +08:00
|
|
|
|
|
2020-03-28 12:39:08 +08:00
|
|
|
|
protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle;
|
|
|
|
|
|
2020-11-12 14:59:48 +08:00
|
|
|
|
public DrawableSliderHead()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DrawableSliderHead(SliderHeadCircle h)
|
2018-03-10 00:11:56 +08:00
|
|
|
|
: base(h)
|
|
|
|
|
{
|
2018-11-09 12:58:46 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-27 09:13:05 +08:00
|
|
|
|
protected override void OnFree()
|
2020-11-12 14:59:48 +08:00
|
|
|
|
{
|
2020-11-27 09:13:05 +08:00
|
|
|
|
base.OnFree();
|
2020-11-12 14:59:48 +08:00
|
|
|
|
|
2020-12-03 19:03:39 +08:00
|
|
|
|
pathVersion.UnbindFrom(DrawableSlider.PathVersion);
|
2020-11-12 14:59:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-26 14:26:20 +08:00
|
|
|
|
protected override void UpdatePosition()
|
|
|
|
|
{
|
|
|
|
|
// Slider head is always drawn at (0,0).
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 18:46:42 +08:00
|
|
|
|
protected override void OnApply()
|
2020-11-12 14:59:48 +08:00
|
|
|
|
{
|
2020-12-03 18:46:42 +08:00
|
|
|
|
base.OnApply();
|
2020-11-12 14:59:48 +08:00
|
|
|
|
|
2020-12-03 19:03:39 +08:00
|
|
|
|
pathVersion.BindTo(DrawableSlider.PathVersion);
|
2020-11-12 14:59:48 +08:00
|
|
|
|
|
2023-08-23 19:12:18 +08:00
|
|
|
|
CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit;
|
2018-03-10 00:11:56 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-03 21:12:20 +08:00
|
|
|
|
protected override HitResult ResultFor(double timeOffset)
|
|
|
|
|
{
|
|
|
|
|
Debug.Assert(HitObject != null);
|
|
|
|
|
|
|
|
|
|
if (HitObject.JudgeAsNormalHitCircle)
|
|
|
|
|
return base.ResultFor(timeOffset);
|
|
|
|
|
|
2021-02-10 18:04:23 +08:00
|
|
|
|
// If not judged as a normal hitcircle, judge as a slider tick instead. This is the classic osu!stable scoring.
|
2021-02-03 21:12:20 +08:00
|
|
|
|
var result = base.ResultFor(timeOffset);
|
2021-02-10 17:38:31 +08:00
|
|
|
|
return result.IsHit() ? HitResult.LargeTickHit : HitResult.LargeTickMiss;
|
2021-02-03 21:12:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 13:30:01 +08:00
|
|
|
|
public override void Shake()
|
|
|
|
|
{
|
|
|
|
|
base.Shake();
|
|
|
|
|
DrawableSlider.Shake();
|
|
|
|
|
}
|
2018-03-10 00:11:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|