2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2018-07-26 11:07:16 +00:00
|
|
|
|
using System;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-08-02 11:36:38 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-08-02 11:36:38 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2018-07-26 11:07:16 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Skinning;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-07-05 13:48:54 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject>
|
|
|
|
|
{
|
2018-07-05 13:48:54 +00:00
|
|
|
|
private readonly ShakeContainer shakeContainer;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
2018-12-04 11:33:29 +00:00
|
|
|
|
base.AddInternal(shakeContainer = new ShakeContainer
|
|
|
|
|
{
|
|
|
|
|
ShakeDuration = 30,
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Alpha = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-06 04:02:00 +00: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 13:48:54 +00: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);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
protected sealed override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
double transformTime = HitObject.StartTime - HitObject.TimePreempt;
|
|
|
|
|
|
|
|
|
|
base.ApplyTransformsAt(transformTime, true);
|
|
|
|
|
base.ClearTransformsAfter(transformTime, true);
|
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(transformTime, true))
|
|
|
|
|
{
|
|
|
|
|
UpdatePreemptState();
|
|
|
|
|
|
2018-08-03 06:38:48 +00:00
|
|
|
|
var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Result?.TimeOffset ?? 0);
|
2018-07-26 11:07:16 +00:00
|
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true))
|
2018-04-13 09:19:50 +00:00
|
|
|
|
UpdateCurrentState(state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
|
|
|
|
{
|
|
|
|
|
base.SkinChanged(skin, allowFallback);
|
|
|
|
|
|
|
|
|
|
if (HitObject is IHasComboInformation combo)
|
2019-01-07 11:12:39 +00:00
|
|
|
|
AccentColour = skin.GetValue<SkinConfiguration, Color4>(s => s.ComboColours.Count > 0 ? s.ComboColours[combo.ComboIndex % s.ComboColours.Count] : Color4.White);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 02:32:09 +00:00
|
|
|
|
protected virtual void UpdatePreemptState() => this.FadeIn(HitObject.TimeFadeIn);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
protected virtual void UpdateCurrentState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Todo: At some point we need to move these to DrawableHitObject after ensuring that all other Rulesets apply
|
|
|
|
|
// transforms in the same way and don't rely on them not being cleared
|
2018-08-02 11:36:38 +00:00
|
|
|
|
public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ApplyTransformsAt(double time, bool propagateChildren = false)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private OsuInputManager osuActionInputManager;
|
|
|
|
|
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
2018-06-28 13:33:59 +00:00
|
|
|
|
|
2018-07-06 08:24:30 +00:00
|
|
|
|
protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-08-06 02:07:41 +00:00
|
|
|
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(judgement);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|