mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 18:30:34 +08:00
71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
// 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;
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
{
|
|
public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject>
|
|
{
|
|
public const float TIME_PREEMPT = 600;
|
|
public const float TIME_FADEIN = 400;
|
|
|
|
/// <summary>
|
|
/// The number of milliseconds used to fade in.
|
|
/// </summary>
|
|
public virtual double FadeInDuration { get; set; } = TIME_FADEIN;
|
|
|
|
public override bool IsPresent => base.IsPresent || State.Value == ArmedState.Idle && Time.Current >= HitObject.StartTime - TIME_PREEMPT;
|
|
|
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
|
: base(hitObject)
|
|
{
|
|
AccentColour = HitObject.ComboColour;
|
|
Alpha = 0;
|
|
}
|
|
|
|
protected sealed override void UpdateState(ArmedState state)
|
|
{
|
|
double transformTime = HitObject.StartTime - TIME_PREEMPT;
|
|
|
|
base.ApplyTransformsAt(transformTime, true);
|
|
base.ClearTransformsAfter(transformTime, true);
|
|
|
|
using (BeginAbsoluteSequence(transformTime, true))
|
|
{
|
|
UpdatePreemptState();
|
|
|
|
using (BeginDelayedSequence(TIME_PREEMPT + (Judgements.FirstOrDefault()?.TimeOffset ?? 0), true))
|
|
UpdateCurrentState(state);
|
|
}
|
|
}
|
|
|
|
protected virtual void UpdatePreemptState() => this.FadeIn(FadeInDuration);
|
|
|
|
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);
|
|
}
|
|
|
|
public enum ComboResult
|
|
{
|
|
[Description(@"")]
|
|
None,
|
|
[Description(@"Good")]
|
|
Good,
|
|
[Description(@"Amazing")]
|
|
Perfect
|
|
}
|
|
}
|