1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Change AdditiveTarget into a set method

This commit is contained in:
Salman Ahmed 2020-04-04 19:33:52 +03:00
parent fbe95a52e3
commit 19f39fe632
2 changed files with 22 additions and 22 deletions

View File

@ -42,25 +42,6 @@ namespace osu.Game.Rulesets.Catch.UI
private Container<CatcherTrailSprite> hyperDashTrails;
private Container<CatcherTrailSprite> endGlowSprites;
public Container AdditiveTarget
{
get => additiveTarget;
set
{
if (additiveTarget == value)
return;
additiveTarget?.RemoveRange(new[] { dashTrails, hyperDashTrails, endGlowSprites });
additiveTarget = value;
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 },
});
}
}
public CatcherAnimationState CurrentState { get; private set; }
@ -167,6 +148,26 @@ 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 },
});
}
/// <summary>
/// Add a caught fruit to the catcher's stack.
/// </summary>

View File

@ -33,10 +33,9 @@ namespace osu.Game.Rulesets.Catch.UI
{
RelativeSizeAxes = Axes.X;
Height = CATCHER_SIZE;
Child = MovableCatcher = new Catcher(difficulty);
// this property adds containers to 'this' so it must not be set in the object initializer.
MovableCatcher.AdditiveTarget = this;
Child = MovableCatcher = new Catcher(difficulty);
MovableCatcher.SetAdditiveTarget(this);
}
public static float GetCatcherSize(BeatmapDifficulty difficulty)