osu/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs

47 lines
1.8 KiB
C#
Raw Normal View History

// 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
using osu.Framework.Allocation;
2019-02-21 10:04:31 +00:00
using osu.Framework.Bindables;
2018-04-13 09:19:50 +00:00
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.UI.Scrolling
{
/// <summary>
/// A type of <see cref="Playfield"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
/// </summary>
public abstract class ScrollingPlayfield : Playfield
2018-04-13 09:19:50 +00:00
{
2018-11-06 06:46:36 +00:00
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
public new ScrollingHitObjectContainer HitObjectContainer => (ScrollingHitObjectContainer)base.HitObjectContainer;
2018-11-06 06:46:36 +00:00
[Resolved]
protected IScrollingInfo ScrollingInfo { get; private set; }
2018-04-13 09:19:50 +00:00
[BackgroundDependencyLoader]
private void load()
{
Direction.BindTo(ScrollingInfo.Direction);
2018-04-13 09:19:50 +00:00
}
protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
{
drawableHitObject.HitObjectApplied += d => HitObjectContainer.InvalidateHitObject(d);
}
/// <summary>
/// Given a position in screen space, return the time within this column.
/// </summary>
public virtual double TimeAtScreenSpacePosition(Vector2 screenSpacePosition) => HitObjectContainer.TimeAtScreenSpacePosition(screenSpacePosition);
/// <summary>
/// Given a time, return the screen space position within this column.
/// </summary>
public virtual Vector2 ScreenSpacePositionAtTime(double time) => HitObjectContainer.ScreenSpacePositionAtTime(time);
2018-11-06 06:46:36 +00:00
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
2018-04-13 09:19:50 +00:00
}
}