Fix osu!catch dropping fruit appearing above the plate instead of behind

This commit is contained in:
Dean Herbert
2020-07-15 20:58:09 +09:00
parent 940d97a677
commit 2624862e32
3 changed files with 31 additions and 28 deletions

View File

@ -35,22 +35,25 @@ namespace osu.Game.Rulesets.Catch.UI
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation) public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation)
{ {
Container explodingFruitContainer; var explodingFruitContainer = new Container
{
RelativeSizeAxes = Axes.Both,
};
CatcherArea = new CatcherArea(difficulty)
{
CreateDrawableRepresentation = createDrawableRepresentation,
ExplodingFruitTarget = explodingFruitContainer,
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
};
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
explodingFruitContainer = new Container explodingFruitContainer,
{ CatcherArea.MovableCatcher.CaughtFruitContainer.CreateProxy(),
RelativeSizeAxes = Axes.Both, HitObjectContainer,
}, CatcherArea
CatcherArea = new CatcherArea(difficulty)
{
CreateDrawableRepresentation = createDrawableRepresentation,
ExplodingFruitTarget = explodingFruitContainer,
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
},
HitObjectContainer
}; };
} }

View File

@ -46,6 +46,12 @@ namespace osu.Game.Rulesets.Catch.UI
public Container ExplodingFruitTarget; public Container ExplodingFruitTarget;
public Container<DrawableHitObject> CaughtFruitContainer { get; } = new Container<DrawableHitObject>
{
Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre,
};
[NotNull] [NotNull]
private readonly Container trailsTarget; private readonly Container trailsTarget;
@ -83,8 +89,6 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
private readonly float catchWidth; private readonly float catchWidth;
private Container<DrawableHitObject> caughtFruit;
private CatcherSprite catcherIdle; private CatcherSprite catcherIdle;
private CatcherSprite catcherKiai; private CatcherSprite catcherKiai;
private CatcherSprite catcherFail; private CatcherSprite catcherFail;
@ -118,11 +122,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
caughtFruit = new Container<DrawableHitObject> CaughtFruitContainer,
{
Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre,
},
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle) catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -176,7 +176,7 @@ namespace osu.Game.Rulesets.Catch.UI
const float allowance = 10; const float allowance = 10;
while (caughtFruit.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 +187,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);
caughtFruit.Add(fruit); CaughtFruitContainer.Add(fruit);
AddInternal(new HitExplosion(fruit) AddInternal(new HitExplosion(fruit)
{ {
@ -342,7 +342,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
public void Drop() public void Drop()
{ {
foreach (var f in caughtFruit.ToArray()) foreach (var f in CaughtFruitContainer.ToArray())
Drop(f); Drop(f);
} }
@ -351,7 +351,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
public void Explode() public void Explode()
{ {
foreach (var f in caughtFruit.ToArray()) foreach (var f in CaughtFruitContainer.ToArray())
Explode(f); Explode(f);
} }
@ -450,9 +450,9 @@ namespace osu.Game.Rulesets.Catch.UI
if (ExplodingFruitTarget != null) if (ExplodingFruitTarget != null)
{ {
fruit.Anchor = Anchor.TopLeft; fruit.Anchor = Anchor.TopLeft;
fruit.Position = caughtFruit.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget); fruit.Position = CaughtFruitContainer.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget);
if (!caughtFruit.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;

View File

@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Catch.UI
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation; public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
public readonly Catcher MovableCatcher;
public Container ExplodingFruitTarget public Container ExplodingFruitTarget
{ {
set => MovableCatcher.ExplodingFruitTarget = value; set => MovableCatcher.ExplodingFruitTarget = value;
@ -104,7 +106,5 @@ namespace osu.Game.Rulesets.Catch.UI
if (state?.CatcherX != null) if (state?.CatcherX != null)
MovableCatcher.X = state.CatcherX.Value; MovableCatcher.X = state.CatcherX.Value;
} }
protected internal readonly Catcher MovableCatcher;
} }
} }