1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Simplify process of adding catcher trails

This commit is contained in:
Salman Ahmed 2020-04-21 11:41:53 +03:00
parent a82efa626e
commit ee62739b08
2 changed files with 10 additions and 23 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Catch.UI
public Container ExplodingFruitTarget;
private Container additiveTarget;
private readonly Container additiveTarget;
private Container<CatcherTrailSprite> dashTrails;
private Container<CatcherTrailSprite> hyperDashTrails;
private Container<CatcherTrailSprite> endGlowSprites;
@ -116,8 +116,10 @@ namespace osu.Game.Rulesets.Catch.UI
private int hyperDashDirection;
private float hyperDashTargetPosition;
public Catcher(BeatmapDifficulty difficulty = null)
public Catcher(BeatmapDifficulty difficulty = null, Container additiveTarget = null)
{
this.additiveTarget = additiveTarget;
RelativePositionAxes = Axes.X;
X = 0.5f;
@ -155,27 +157,14 @@ namespace osu.Game.Rulesets.Catch.UI
}
};
updateCatcher();
}
/// <summary>
/// Sets container target to provide catcher additive trails content in.
/// </summary>
/// <param name="target">The container to add catcher trails in.</param>
public void SetAdditiveTarget(Container target)
{
if (additiveTarget == target)
return;
additiveTarget?.RemoveRange(new[] { dashTrails, hyperDashTrails, endGlowSprites });
additiveTarget = target;
additiveTarget?.AddRange(new[]
{
dashTrails ??= new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = Color4.White },
hyperDashTrails ??= new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = hyperDashColour },
endGlowSprites ??= new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = hyperDashEndGlowColour },
dashTrails = new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = Color4.White },
hyperDashTrails = new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = hyperDashColour },
endGlowSprites = new Container<CatcherTrailSprite> { RelativeSizeAxes = Axes.Both, Colour = hyperDashEndGlowColour }
});
updateCatcher();
}
/// <summary>

View File

@ -33,9 +33,7 @@ namespace osu.Game.Rulesets.Catch.UI
{
RelativeSizeAxes = Axes.X;
Height = CATCHER_SIZE;
Child = MovableCatcher = new Catcher(difficulty);
MovableCatcher.SetAdditiveTarget(this);
Child = MovableCatcher = new Catcher(difficulty, this);
}
public static float GetCatcherSize(BeatmapDifficulty difficulty)