// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI.Scrolling; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public abstract class DrawableManiaHitObject : DrawableHitObject { /// /// Whether this should always remain alive. /// internal bool AlwaysAlive; /// /// The which causes this to be hit. /// protected readonly IBindable Action = new Bindable(); protected readonly IBindable Direction = new Bindable(); protected DrawableManiaHitObject(ManiaHitObject hitObject) : base(hitObject) { } [BackgroundDependencyLoader(true)] private void load([CanBeNull] IBindable action, [NotNull] IScrollingInfo scrollingInfo) { if (action != null) Action.BindTo(action); Direction.BindTo(scrollingInfo.Direction); Direction.BindValueChanged(OnDirectionChanged, true); } protected override bool ShouldBeAlive => AlwaysAlive || base.ShouldBeAlive; protected virtual void OnDirectionChanged(ScrollingDirection direction) { Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } } public abstract class DrawableManiaHitObject : DrawableManiaHitObject where TObject : ManiaHitObject { public new readonly TObject HitObject; protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; } protected override void UpdateState(ArmedState state) { switch (state) { case ArmedState.Miss: this.FadeOut(150, Easing.In).Expire(); break; case ArmedState.Hit: this.FadeOut(150, Easing.OutQuint).Expire(); break; } } } }