diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/CaughtObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/CaughtObject.cs index 0f3a143553..d3555ea771 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/CaughtObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/CaughtObject.cs @@ -12,12 +12,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables { - [Cached(typeof(CaughtObject))] - public abstract class CaughtObject : SkinnableDrawable + [Cached(typeof(IHasCatchObjectState))] + public abstract class CaughtObject : SkinnableDrawable, IHasCatchObjectState { - public readonly Bindable AccentColour = new Bindable(); - public CatchHitObject HitObject { get; private set; } + public Bindable AccentColour { get; } = new Bindable(); + public Bindable HyperDash { get; } = new Bindable(); /// /// Whether this hit object should stay on the catcher plate when the object is caught by the catcher. @@ -36,30 +36,31 @@ protected CaughtObject(CatchSkinComponents skinComponent, Func VisualRepresentation = new Bindable(); + public Bindable VisualRepresentation { get; } = new Bindable(); public CaughtFruit() : base(CatchSkinComponents.Fruit, _ => new FruitPiece()) { } - public override void CopyFrom(DrawablePalpableCatchHitObject drawableObject) + public override void CopyFrom(IHasCatchObjectState objectState) { - base.CopyFrom(drawableObject); + base.CopyFrom(objectState); - var drawableFruit = (DrawableFruit)drawableObject; - VisualRepresentation.Value = drawableFruit.VisualRepresentation.Value; + var fruitState = (IHasFruitState)objectState; + VisualRepresentation.Value = fruitState.VisualRepresentation.Value; } } diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs index 4bc5da2396..34d89eb188 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables { - public class DrawableBanana : DrawablePalpableCatchHitObject + public class DrawableBanana : DrawablePalpableHasCatchHitObject { public DrawableBanana() : this(null) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableDroplet.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableDroplet.cs index c5f0bb8b18..acdb3bb38c 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableDroplet.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableDroplet.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables { - public class DrawableDroplet : DrawablePalpableCatchHitObject + public class DrawableDroplet : DrawablePalpableHasCatchHitObject { public DrawableDroplet() : this(null) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs index 8135a31b43..6ec46f6535 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableFruit.cs @@ -10,9 +10,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables { - public class DrawableFruit : DrawablePalpableCatchHitObject + public class DrawableFruit : DrawablePalpableHasCatchHitObject, IHasFruitState { - public readonly Bindable VisualRepresentation = new Bindable(); + public Bindable VisualRepresentation { get; } = new Bindable(); public DrawableFruit() : this(null) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableHasCatchHitObject.cs similarity index 78% rename from osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableCatchHitObject.cs rename to osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableHasCatchHitObject.cs index 34d9cf820e..ee893f7880 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableCatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawablePalpableHasCatchHitObject.cs @@ -6,18 +6,22 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osuTK; +using osuTK.Graphics; namespace osu.Game.Rulesets.Catch.Objects.Drawables { - public abstract class DrawablePalpableCatchHitObject : DrawableCatchHitObject + [Cached(typeof(IHasCatchObjectState))] + public abstract class DrawablePalpableHasCatchHitObject : DrawableCatchHitObject, IHasCatchObjectState { public new PalpableCatchHitObject HitObject => (PalpableCatchHitObject)base.HitObject; - public readonly Bindable HyperDash = new Bindable(); + Bindable IHasCatchObjectState.AccentColour => AccentColour; - public readonly Bindable ScaleBindable = new Bindable(1); + public Bindable HyperDash { get; } = new Bindable(); - public readonly Bindable IndexInBeatmap = new Bindable(); + public Bindable ScaleBindable { get; } = new Bindable(1); + + public Bindable IndexInBeatmap { get; } = new Bindable(); /// /// The multiplicative factor applied to relative to scale. @@ -26,7 +30,7 @@ public abstract class DrawablePalpableCatchHitObject : DrawableCatchHitObject public float DisplayRadius => CatchHitObject.OBJECT_RADIUS * HitObject.Scale * ScaleFactor; - protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h) + protected DrawablePalpableHasCatchHitObject([CanBeNull] CatchHitObject h) : base(h) { Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/IHasCatchObjectState.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/IHasCatchObjectState.cs new file mode 100644 index 0000000000..01d833b61a --- /dev/null +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/IHasCatchObjectState.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Rulesets.Catch.Objects.Drawables +{ + public interface IHasCatchObjectState + { + CatchHitObject HitObject { get; } + Bindable AccentColour { get; } + Bindable HyperDash { get; } + + float Rotation { get; } + Vector2 Scale { get; } + } + + public interface IHasFruitState : IHasCatchObjectState + { + Bindable VisualRepresentation { get; } + } +} diff --git a/osu.Game.Rulesets.Catch/Skinning/Default/CatchHitObjectPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Default/CatchHitObjectPiece.cs index cb326b77e2..b105fb4034 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Default/CatchHitObjectPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Default/CatchHitObjectPiece.cs @@ -7,7 +7,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Catch.Objects.Drawables; -using osu.Game.Rulesets.Objects.Drawables; using osuTK.Graphics; namespace osu.Game.Rulesets.Catch.Skinning.Default @@ -17,13 +16,8 @@ public abstract class CatchHitObjectPiece : CompositeDrawable public readonly Bindable AccentColour = new Bindable(); public readonly Bindable HyperDash = new Bindable(); - [Resolved(canBeNull: true)] - [CanBeNull] - protected DrawableHitObject DrawableHitObject { get; private set; } - - [Resolved(canBeNull: true)] - [CanBeNull] - protected CaughtObject CaughtObject { get; private set; } + [Resolved] + protected IHasCatchObjectState ObjectState { get; private set; } /// /// A part of this piece that will be faded out while falling in the playfield. @@ -41,16 +35,8 @@ protected override void LoadComplete() { base.LoadComplete(); - var hitObject = (DrawablePalpableCatchHitObject)DrawableHitObject; - - if (hitObject != null) - { - AccentColour.BindTo(hitObject.AccentColour); - HyperDash.BindTo(hitObject.HyperDash); - } - - if (CaughtObject != null) - AccentColour.BindTo(CaughtObject.AccentColour); + AccentColour.BindTo(ObjectState.AccentColour); + HyperDash.BindTo(ObjectState.HyperDash); HyperDash.BindValueChanged(hyper => { @@ -61,13 +47,8 @@ protected override void LoadComplete() protected override void Update() { - if (BorderPiece != null) - { - if (DrawableHitObject?.HitObject != null) - BorderPiece.Alpha = (float)Math.Clamp((DrawableHitObject.HitObject.StartTime - Time.Current) / 500, 0, 1); - else - BorderPiece.Alpha = 0; - } + if (BorderPiece != null && ObjectState?.HitObject != null) + BorderPiece.Alpha = (float)Math.Clamp((ObjectState.HitObject.StartTime - Time.Current) / 500, 0, 1); } } } diff --git a/osu.Game.Rulesets.Catch/Skinning/Default/FruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Default/FruitPiece.cs index 8c705cec4f..49f128c960 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Default/FruitPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Default/FruitPiece.cs @@ -39,14 +39,8 @@ protected override void LoadComplete() { base.LoadComplete(); - var fruit = (DrawableFruit)DrawableHitObject; - - if (fruit != null) - VisualRepresentation.BindTo(fruit.VisualRepresentation); - - var caughtFruit = (CaughtFruit)CaughtObject; - if (caughtFruit != null) - VisualRepresentation.BindTo(caughtFruit.VisualRepresentation); + var fruitState = (IHasFruitState)ObjectState; + VisualRepresentation.BindTo(fruitState.VisualRepresentation); } } } diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs index 5140c62d3e..969cc38e5b 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs @@ -14,14 +14,8 @@ protected override void LoadComplete() { base.LoadComplete(); - var fruit = (DrawableFruit)DrawableHitObject; - - if (fruit != null) - VisualRepresentation.BindTo(fruit.VisualRepresentation); - - var caughtFruit = (CaughtFruit)CaughtObject; - if (caughtFruit != null) - VisualRepresentation.BindTo(caughtFruit.VisualRepresentation); + var fruitState = (IHasFruitState)ObjectState; + VisualRepresentation.BindTo(fruitState.VisualRepresentation); VisualRepresentation.BindValueChanged(visual => setTexture(visual.NewValue), true); } diff --git a/osu.Game.Rulesets.Catch/Skinning/LegacyCatchHitObjectPiece.cs b/osu.Game.Rulesets.Catch/Skinning/LegacyCatchHitObjectPiece.cs index 9527f15ff1..4b1f5a4724 100644 --- a/osu.Game.Rulesets.Catch/Skinning/LegacyCatchHitObjectPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/LegacyCatchHitObjectPiece.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -10,7 +9,6 @@ using osu.Framework.Graphics.Textures; using osu.Game.Rulesets.Catch.Objects.Drawables; using osu.Game.Rulesets.Catch.UI; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Skinning; using osuTK; using osuTK.Graphics; @@ -29,13 +27,8 @@ public abstract class LegacyCatchHitObjectPiece : PoolableDrawable [Resolved] protected ISkinSource Skin { get; private set; } - [Resolved(canBeNull: true)] - [CanBeNull] - protected DrawableHitObject DrawableHitObject { get; private set; } - - [Resolved(canBeNull: true)] - [CanBeNull] - protected CaughtObject CaughtObject { get; private set; } + [Resolved] + protected IHasCatchObjectState ObjectState { get; private set; } protected LegacyCatchHitObjectPiece() { @@ -69,16 +62,8 @@ protected override void LoadComplete() { base.LoadComplete(); - var hitObject = (DrawablePalpableCatchHitObject)DrawableHitObject; - - if (hitObject != null) - { - AccentColour.BindTo(hitObject.AccentColour); - HyperDash.BindTo(hitObject.HyperDash); - } - - if (CaughtObject != null) - AccentColour.BindTo(CaughtObject.AccentColour); + AccentColour.BindTo(ObjectState.AccentColour); + HyperDash.BindTo(ObjectState.HyperDash); hyperSprite.Colour = Skin.GetConfig(CatchSkinColour.HyperDashFruit)?.Value ?? Skin.GetConfig(CatchSkinColour.HyperDash)?.Value ?? diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index 756582e3f2..4d540bce03 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -215,7 +215,7 @@ public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult r catchResult.CatcherAnimationState = CurrentState; catchResult.CatcherHyperDash = HyperDashing; - if (!(drawableObject is DrawablePalpableCatchHitObject palpableObject)) return; + if (!(drawableObject is DrawablePalpableHasCatchHitObject palpableObject)) return; var hitObject = palpableObject.HitObject; @@ -450,7 +450,7 @@ private void updateState(CatcherAnimationState state) updateCatcher(); } - private void placeCaughtObject(DrawablePalpableCatchHitObject drawableObject, Vector2 position) + private void placeCaughtObject(DrawablePalpableHasCatchHitObject drawableObject, Vector2 position) { var caughtObject = createCaughtObject(drawableObject.HitObject); @@ -458,6 +458,7 @@ private void placeCaughtObject(DrawablePalpableCatchHitObject drawableObject, Ve caughtObject.CopyFrom(drawableObject); caughtObject.Position = position; + caughtObject.Scale /= 2; caughtFruitContainer.Add(caughtObject);