1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:07:25 +08:00

Expose via CreateProxiedContent method

This commit is contained in:
Dean Herbert 2020-07-16 15:35:19 +09:00
parent 3666599053
commit c42b315abb
2 changed files with 15 additions and 9 deletions

View File

@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Catch.UI
InternalChildren = new[] InternalChildren = new[]
{ {
explodingFruitContainer, explodingFruitContainer,
CatcherArea.MovableCatcher.CaughtFruitContainer.CreateProxy(), CatcherArea.MovableCatcher.CreateProxiedContent(),
HitObjectContainer, HitObjectContainer,
CatcherArea CatcherArea
}; };

View File

@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Catch.UI
public Container ExplodingFruitTarget; public Container ExplodingFruitTarget;
public Container<DrawableHitObject> CaughtFruitContainer { get; } = new Container<DrawableHitObject> private Container<DrawableHitObject> caughtFruitContainer { get; } = new Container<DrawableHitObject>
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
@ -122,7 +122,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
CaughtFruitContainer, caughtFruitContainer,
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle) catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -145,6 +145,12 @@ namespace osu.Game.Rulesets.Catch.UI
updateCatcher(); updateCatcher();
} }
/// <summary>
/// Creates proxied content to be displayed beneath hitobjects.
/// </summary>
/// <returns></returns>
public Drawable CreateProxiedContent() => caughtFruitContainer.CreateProxy();
/// <summary> /// <summary>
/// Calculates the scale of the catcher based off the provided beatmap difficulty. /// Calculates the scale of the catcher based off the provided beatmap difficulty.
/// </summary> /// </summary>
@ -176,7 +182,7 @@ namespace osu.Game.Rulesets.Catch.UI
const float allowance = 10; const float allowance = 10;
while (CaughtFruitContainer.Any(f => while (caughtFruitContainer.Any(f =>
f.LifetimeEnd == double.MaxValue && f.LifetimeEnd == double.MaxValue &&
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2))) 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); fruit.X = Math.Clamp(fruit.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
CaughtFruitContainer.Add(fruit); caughtFruitContainer.Add(fruit);
AddInternal(new HitExplosion(fruit) AddInternal(new HitExplosion(fruit)
{ {
@ -342,7 +348,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
public void Drop() public void Drop()
{ {
foreach (var f in CaughtFruitContainer.ToArray()) foreach (var f in caughtFruitContainer.ToArray())
Drop(f); Drop(f);
} }
@ -351,7 +357,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
public void Explode() public void Explode()
{ {
foreach (var f in CaughtFruitContainer.ToArray()) foreach (var f in caughtFruitContainer.ToArray())
Explode(f); Explode(f);
} }
@ -450,9 +456,9 @@ namespace osu.Game.Rulesets.Catch.UI
if (ExplodingFruitTarget != null) if (ExplodingFruitTarget != null)
{ {
fruit.Anchor = Anchor.TopLeft; 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). // 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. // this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice.
return; return;