2019-07-22 13:45:25 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Framework.Graphics;
|
2018-08-02 19:36:38 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2018-07-05 21:48:54 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
{
|
|
|
|
public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject>
|
|
|
|
{
|
2018-07-05 21:48:54 +08:00
|
|
|
private readonly ShakeContainer shakeContainer;
|
|
|
|
|
2019-06-30 23:28:20 +08:00
|
|
|
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
|
2019-06-30 23:27:47 +08:00
|
|
|
public override bool HandlePositionalInput => true;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
|
|
|
: base(hitObject)
|
|
|
|
{
|
2018-12-04 19:33:29 +08:00
|
|
|
base.AddInternal(shakeContainer = new ShakeContainer
|
|
|
|
{
|
|
|
|
ShakeDuration = 30,
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
});
|
2019-07-16 12:45:59 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Alpha = 0;
|
|
|
|
}
|
|
|
|
|
2018-07-06 12:02:00 +08:00
|
|
|
// Forward all internal management to shakeContainer.
|
|
|
|
// This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690)
|
2018-07-05 21:48:54 +08:00
|
|
|
protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable);
|
|
|
|
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
|
|
|
|
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable);
|
|
|
|
|
2019-07-22 14:05:56 +08:00
|
|
|
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;
|
2018-08-02 19:36:38 +08:00
|
|
|
|
2019-07-22 14:33:12 +08:00
|
|
|
protected override void UpdateInitialTransforms() => this.FadeIn(HitObject.TimeFadeIn);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
private OsuInputManager osuActionInputManager;
|
|
|
|
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
2018-06-28 21:33:59 +08:00
|
|
|
|
2018-07-06 16:24:30 +08:00
|
|
|
protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-08-06 10:07:41 +08:00
|
|
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(judgement);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|