osu/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.2 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 09:19:50 +00:00
2022-06-17 07:37:17 +00:00
#nullable disable
using System.Diagnostics;
using JetBrains.Annotations;
2019-02-21 10:04:31 +00:00
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Scoring;
2018-04-13 09:19:50 +00:00
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>();
2018-11-09 04:58:46 +00:00
protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle;
2020-11-12 06:59:48 +00:00
public DrawableSliderHead()
{
}
public DrawableSliderHead(SliderHeadCircle h)
: base(h)
{
2018-11-09 04:58:46 +00:00
}
2018-04-13 09:19:50 +00:00
protected override void OnFree()
2020-11-12 06:59:48 +00:00
{
base.OnFree();
2020-11-12 06:59:48 +00:00
2020-12-03 11:03:39 +00:00
pathVersion.UnbindFrom(DrawableSlider.PathVersion);
2020-11-12 06:59:48 +00:00
}
protected override void UpdatePosition()
{
// Slider head is always drawn at (0,0).
}
2020-12-03 10:46:42 +00:00
protected override void OnApply()
2020-11-12 06:59:48 +00:00
{
2020-12-03 10:46:42 +00:00
base.OnApply();
2020-11-12 06:59:48 +00:00
2020-12-03 11:03:39 +00:00
pathVersion.BindTo(DrawableSlider.PathVersion);
2020-11-12 06:59:48 +00:00
CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit;
}
2018-04-13 09:19:50 +00:00
protected override HitResult ResultFor(double timeOffset)
{
Debug.Assert(HitObject != null);
if (HitObject.JudgeAsNormalHitCircle)
return base.ResultFor(timeOffset);
2021-02-10 10:04:23 +00:00
// 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);
2021-02-10 09:38:31 +00:00
return result.IsHit() ? HitResult.LargeTickHit : HitResult.LargeTickMiss;
}
public override void Shake()
{
base.Shake();
DrawableSlider.Shake();
}
}
}