2017-06-19 09:54:23 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using osu.Framework.Configuration;
|
2017-08-07 15:02:38 +08:00
|
|
|
using osu.Framework.Graphics;
|
2017-06-19 09:54:23 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Objects.Drawables
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A basic class that overrides <see cref="DrawableHitObject{TObject, TJudgement}"/> and implements <see cref="IScrollingHitObject"/>.
|
2017-08-07 15:43:54 +08:00
|
|
|
/// This object does not need to have its <see cref="Drawable.RelativePositionAxes"/> set to be able to scroll, as this will
|
|
|
|
/// will be set by the scrolling container that contains it.
|
2017-06-19 09:54:23 +08:00
|
|
|
/// </summary>
|
|
|
|
public abstract class DrawableScrollingHitObject<TObject, TJudgement> : DrawableHitObject<TObject, TJudgement>, IScrollingHitObject
|
|
|
|
where TObject : HitObject
|
|
|
|
where TJudgement : Judgement
|
|
|
|
{
|
|
|
|
public BindableDouble LifetimeOffset { get; } = new BindableDouble();
|
|
|
|
|
2017-08-07 15:02:38 +08:00
|
|
|
Axes IScrollingHitObject.ScrollingAxes
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
2017-08-08 08:20:54 +08:00
|
|
|
RelativePositionAxes |= value;
|
2017-08-07 15:02:38 +08:00
|
|
|
|
|
|
|
if ((value & Axes.X) > 0)
|
|
|
|
X = (float)HitObject.StartTime;
|
|
|
|
if ((value & Axes.Y) > 0)
|
|
|
|
Y = (float)HitObject.StartTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-21 19:17:15 +08:00
|
|
|
protected DrawableScrollingHitObject(TObject hitObject)
|
2017-06-19 09:54:23 +08:00
|
|
|
: base(hitObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-08-07 13:07:49 +08:00
|
|
|
private double? lifetimeStart;
|
2017-06-19 09:54:23 +08:00
|
|
|
public override double LifetimeStart
|
|
|
|
{
|
2017-08-07 13:07:49 +08:00
|
|
|
get { return lifetimeStart ?? HitObject.StartTime - LifetimeOffset; }
|
|
|
|
set { lifetimeStart = value; }
|
2017-06-19 09:54:23 +08:00
|
|
|
}
|
|
|
|
|
2017-08-07 13:07:49 +08:00
|
|
|
private double? lifetimeEnd;
|
2017-06-19 09:54:23 +08:00
|
|
|
public override double LifetimeEnd
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
|
2017-08-07 13:07:49 +08:00
|
|
|
return lifetimeEnd ?? endTime + LifetimeOffset;
|
2017-06-19 09:54:23 +08:00
|
|
|
}
|
2017-08-07 13:07:49 +08:00
|
|
|
set { lifetimeEnd = value; }
|
2017-06-19 09:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void AddNested(DrawableHitObject<TObject, TJudgement> h)
|
|
|
|
{
|
|
|
|
var scrollingHitObject = h as IScrollingHitObject;
|
|
|
|
scrollingHitObject?.LifetimeOffset.BindTo(LifetimeOffset);
|
|
|
|
|
|
|
|
base.AddNested(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|