1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-02 00:20:40 +08:00

Don't use CreateDrawableRepresentation in CatcherArea

This commit is contained in:
ekrctb
2020-11-30 19:02:49 +09:00
Unverified
parent b56e832e83
commit 05aaa377e7
3 changed files with 13 additions and 6 deletions
@@ -103,7 +103,6 @@ namespace osu.Game.Rulesets.Catch.Tests
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
CreateDrawableRepresentation = ((DrawableRuleset<CatchHitObject>)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation
},
});
}
@@ -42,7 +42,6 @@ namespace osu.Game.Rulesets.Catch.UI
CatcherArea = new CatcherArea(difficulty)
{
CreateDrawableRepresentation = createDrawableRepresentation,
ExplodingFruitTarget = explodingFruitContainer,
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
+13 -4
View File
@@ -10,7 +10,6 @@ using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.Replays;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osuTK;
@@ -21,8 +20,6 @@ namespace osu.Game.Rulesets.Catch.UI
{
public const float CATCHER_SIZE = 106.75f;
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
public readonly Catcher MovableCatcher;
private readonly CatchComboDisplay comboDisplay;
@@ -72,7 +69,7 @@ namespace osu.Game.Rulesets.Catch.UI
if (result.IsHit && hitObject is DrawablePalpableCatchHitObject fruit)
{
// create a new (cloned) fruit to stay on the plate. the original is faded out immediately.
var caughtFruit = (DrawableCatchHitObject)CreateDrawableRepresentation?.Invoke(fruit.HitObject);
var caughtFruit = createCaughtFruit(fruit);
if (caughtFruit == null) return;
@@ -127,5 +124,17 @@ namespace osu.Game.Rulesets.Catch.UI
comboDisplay.X = MovableCatcher.X;
}
private DrawableCatchHitObject createCaughtFruit(DrawablePalpableCatchHitObject hitObject)
{
return hitObject.HitObject switch
{
Banana banana => new DrawableBanana(banana),
Fruit fruit => new DrawableFruit(fruit),
TinyDroplet tiny => new DrawableTinyDroplet(tiny),
Droplet droplet => new DrawableDroplet(droplet),
_ => null
};
}
}
}