2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using OpenTK.Graphics;
|
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>
|
|
|
|
|
{
|
|
|
|
|
public override bool IsPresent => base.IsPresent || State.Value == ArmedState.Idle && Time.Current >= HitObject.StartTime - HitObject.TimePreempt;
|
|
|
|
|
|
2018-07-05 21:48:54 +08:00
|
|
|
|
private readonly ShakeContainer shakeContainer;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
2018-07-05 21:48:54 +08:00
|
|
|
|
shakeContainer = new ShakeContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
base.AddInternal(shakeContainer);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Alpha = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 21:48:54 +08:00
|
|
|
|
// Forward all internal management to shakeContainer
|
|
|
|
|
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 17:19:50 +08: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();
|
|
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(HitObject.TimePreempt + (Judgements.FirstOrDefault()?.TimeOffset ?? 0), true))
|
|
|
|
|
UpdateCurrentState(state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
|
|
|
|
{
|
|
|
|
|
base.SkinChanged(skin, allowFallback);
|
|
|
|
|
|
|
|
|
|
if (HitObject is IHasComboInformation combo)
|
|
|
|
|
AccentColour = skin.GetValue<SkinConfiguration, Color4>(s => s.ComboColours.Count > 0 ? s.ComboColours[combo.ComboIndex % s.ComboColours.Count] : (Color4?)null) ?? Color4.White;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void UpdatePreemptState() => this.FadeIn(HitObject.TimeFadein);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null) { }
|
|
|
|
|
public override void ApplyTransformsAt(double time, bool propagateChildren = false) { }
|
|
|
|
|
|
|
|
|
|
private OsuInputManager osuActionInputManager;
|
|
|
|
|
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
2018-06-28 21:33:59 +08:00
|
|
|
|
|
2018-07-06 10:52:58 +08:00
|
|
|
|
protected virtual void Shake()
|
2018-06-28 21:33:59 +08:00
|
|
|
|
{
|
2018-07-05 21:48:54 +08:00
|
|
|
|
shakeContainer.Shake();
|
2018-06-28 21:33:59 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ComboResult
|
|
|
|
|
{
|
|
|
|
|
[Description(@"")]
|
|
|
|
|
None,
|
|
|
|
|
[Description(@"Good")]
|
|
|
|
|
Good,
|
|
|
|
|
[Description(@"Amazing")]
|
|
|
|
|
Perfect
|
|
|
|
|
}
|
|
|
|
|
}
|