DI the scrolling info rather than pass by ctor

This commit is contained in:
smoogipoo
2018-06-08 20:13:24 +09:00
parent 0fb4e6b41b
commit ca5103615d
14 changed files with 146 additions and 118 deletions

View File

@ -1,40 +1,15 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
public abstract class DrawableManiaHitObject : DrawableHitObject<ManiaHitObject>
{
protected DrawableManiaHitObject(ManiaHitObject hitObject)
: base(hitObject)
{
}
/// <summary>
/// Sets the scrolling direction.
/// </summary>
public virtual ScrollingDirection Direction
{
set
{
Anchor = value == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
Origin = Anchor;
if (!HasNestedHitObjects)
return;
foreach (var obj in NestedHitObjects.OfType<DrawableManiaHitObject>())
obj.Direction = value;
}
}
}
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject
public abstract class DrawableManiaHitObject<TObject> : DrawableHitObject<ManiaHitObject>
where TObject : ManiaHitObject
{
/// <summary>
@ -47,15 +22,19 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected DrawableManiaHitObject(TObject hitObject, ManiaAction? action = null)
: base(hitObject)
{
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
HitObject = hitObject;
if (action != null)
Action = action.Value;
}
[BackgroundDependencyLoader]
private void load(ScrollingInfo scrollingInfo)
{
Anchor = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
Origin = Anchor;
}
protected override void UpdateState(ArmedState state)
{
switch (state)