mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Don't recreate pieces when catch DHO is reused
This commit is contained in:
parent
87189452d1
commit
d51d2c5331
@ -5,11 +5,8 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
public enum CatchSkinComponents
|
||||
{
|
||||
FruitBananas,
|
||||
FruitApple,
|
||||
FruitGrapes,
|
||||
FruitOrange,
|
||||
FruitPear,
|
||||
Fruit,
|
||||
Banana,
|
||||
Droplet,
|
||||
CatcherIdle,
|
||||
CatcherFail,
|
||||
|
@ -25,17 +25,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
HyperDash.BindValueChanged(_ => updatePiece(), true);
|
||||
}
|
||||
|
||||
private void updatePiece()
|
||||
{
|
||||
ScaleContainer.Child = new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Droplet),
|
||||
_ => new DropletPiece
|
||||
{
|
||||
HyperDash = { BindTarget = HyperDash }
|
||||
HyperDash = { BindTarget = HyperDash },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -35,21 +34,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
VisualRepresentation.Value = GetVisualRepresentation(change.NewValue);
|
||||
}, true);
|
||||
|
||||
VisualRepresentation.BindValueChanged(_ => updatePiece());
|
||||
HyperDash.BindValueChanged(_ => updatePiece(), true);
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
{
|
||||
base.UpdateInitialTransforms();
|
||||
|
||||
ScaleContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
||||
}
|
||||
|
||||
private void updatePiece()
|
||||
{
|
||||
ScaleContainer.Child = new SkinnableDrawable(
|
||||
new CatchSkinComponent(getComponent(VisualRepresentation.Value)),
|
||||
new CatchSkinComponent(this is DrawableBanana ? CatchSkinComponents.Banana : CatchSkinComponents.Fruit),
|
||||
_ => new FruitPiece
|
||||
{
|
||||
VisualRepresentation = { BindTarget = VisualRepresentation },
|
||||
@ -57,28 +43,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
});
|
||||
}
|
||||
|
||||
private CatchSkinComponents getComponent(FruitVisualRepresentation hitObjectVisualRepresentation)
|
||||
protected override void UpdateInitialTransforms()
|
||||
{
|
||||
switch (hitObjectVisualRepresentation)
|
||||
{
|
||||
case FruitVisualRepresentation.Pear:
|
||||
return CatchSkinComponents.FruitPear;
|
||||
base.UpdateInitialTransforms();
|
||||
|
||||
case FruitVisualRepresentation.Grape:
|
||||
return CatchSkinComponents.FruitGrapes;
|
||||
|
||||
case FruitVisualRepresentation.Pineapple:
|
||||
return CatchSkinComponents.FruitApple;
|
||||
|
||||
case FruitVisualRepresentation.Raspberry:
|
||||
return CatchSkinComponents.FruitOrange;
|
||||
|
||||
case FruitVisualRepresentation.Banana:
|
||||
return CatchSkinComponents.FruitBananas;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(hitObjectVisualRepresentation), hitObjectVisualRepresentation, null);
|
||||
}
|
||||
ScaleContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Humanizer;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using static osu.Game.Skinning.LegacySkinConfiguration;
|
||||
|
||||
@ -40,20 +38,21 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
||||
|
||||
switch (catchSkinComponent.Component)
|
||||
{
|
||||
case CatchSkinComponents.FruitApple:
|
||||
case CatchSkinComponents.FruitBananas:
|
||||
case CatchSkinComponents.FruitOrange:
|
||||
case CatchSkinComponents.FruitGrapes:
|
||||
case CatchSkinComponents.FruitPear:
|
||||
var lookupName = catchSkinComponent.Component.ToString().Kebaberize();
|
||||
if (GetTexture(lookupName) != null)
|
||||
return new LegacyFruitPiece(lookupName);
|
||||
case CatchSkinComponents.Fruit:
|
||||
if (GetTexture("fruit-pear") != null)
|
||||
return new LegacyFruitPiece();
|
||||
|
||||
break;
|
||||
|
||||
case CatchSkinComponents.Banana:
|
||||
if (GetTexture("fruit-bananas") != null)
|
||||
return new LegacyFruitPiece();
|
||||
|
||||
break;
|
||||
|
||||
case CatchSkinComponents.Droplet:
|
||||
if (GetTexture("fruit-drop") != null)
|
||||
return new LegacyFruitPiece("fruit-drop") { Scale = new Vector2(0.8f) };
|
||||
return new LegacyDropletPiece();
|
||||
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user