From c42b315abb65e1162dd97eb6f53d69b2182fbb09 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Jul 2020 15:35:19 +0900 Subject: [PATCH] Expose via CreateProxiedContent method --- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 2 +- osu.Game.Rulesets.Catch/UI/Catcher.cs | 22 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index 18dc3adf76..154e1576db 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Catch.UI InternalChildren = new[] { explodingFruitContainer, - CatcherArea.MovableCatcher.CaughtFruitContainer.CreateProxy(), + CatcherArea.MovableCatcher.CreateProxiedContent(), HitObjectContainer, CatcherArea }; diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index fd7a1fd3c3..8629a19470 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Catch.UI public Container ExplodingFruitTarget; - public Container CaughtFruitContainer { get; } = new Container + private Container caughtFruitContainer { get; } = new Container { Anchor = Anchor.TopCentre, Origin = Anchor.BottomCentre, @@ -122,7 +122,7 @@ namespace osu.Game.Rulesets.Catch.UI { InternalChildren = new Drawable[] { - CaughtFruitContainer, + caughtFruitContainer, catcherIdle = new CatcherSprite(CatcherAnimationState.Idle) { Anchor = Anchor.TopCentre, @@ -145,6 +145,12 @@ namespace osu.Game.Rulesets.Catch.UI updateCatcher(); } + /// + /// Creates proxied content to be displayed beneath hitobjects. + /// + /// + public Drawable CreateProxiedContent() => caughtFruitContainer.CreateProxy(); + /// /// Calculates the scale of the catcher based off the provided beatmap difficulty. /// @@ -176,7 +182,7 @@ namespace osu.Game.Rulesets.Catch.UI const float allowance = 10; - while (CaughtFruitContainer.Any(f => + while (caughtFruitContainer.Any(f => f.LifetimeEnd == double.MaxValue && Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2))) { @@ -187,7 +193,7 @@ namespace osu.Game.Rulesets.Catch.UI fruit.X = Math.Clamp(fruit.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2); - CaughtFruitContainer.Add(fruit); + caughtFruitContainer.Add(fruit); AddInternal(new HitExplosion(fruit) { @@ -342,7 +348,7 @@ namespace osu.Game.Rulesets.Catch.UI /// public void Drop() { - foreach (var f in CaughtFruitContainer.ToArray()) + foreach (var f in caughtFruitContainer.ToArray()) Drop(f); } @@ -351,7 +357,7 @@ namespace osu.Game.Rulesets.Catch.UI /// public void Explode() { - foreach (var f in CaughtFruitContainer.ToArray()) + foreach (var f in caughtFruitContainer.ToArray()) Explode(f); } @@ -450,9 +456,9 @@ namespace osu.Game.Rulesets.Catch.UI if (ExplodingFruitTarget != null) { fruit.Anchor = Anchor.TopLeft; - fruit.Position = CaughtFruitContainer.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget); + fruit.Position = caughtFruitContainer.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget); - if (!CaughtFruitContainer.Remove(fruit)) + if (!caughtFruitContainer.Remove(fruit)) // we may have already been removed by a previous operation (due to the weird OnLoadComplete scheduling). // this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice. return;