Resolve DroppedObjectContainer via DI

This commit is contained in:
ekrctb
2021-06-24 15:56:53 +09:00
parent 16d5893535
commit ae09c23e4e
6 changed files with 54 additions and 34 deletions

View File

@ -26,6 +26,9 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary>
public const float CENTER_X = WIDTH / 2;
[Cached]
private readonly DroppedObjectContainer droppedObjectContainer;
internal readonly CatcherArea CatcherArea;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
@ -34,9 +37,7 @@ namespace osu.Game.Rulesets.Catch.UI
public CatchPlayfield(BeatmapDifficulty difficulty)
{
var droppedObjectContainer = new DroppedObjectContainer();
CatcherArea = new CatcherArea(droppedObjectContainer, difficulty)
CatcherArea = new CatcherArea(difficulty)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
@ -44,7 +45,7 @@ namespace osu.Game.Rulesets.Catch.UI
InternalChildren = new[]
{
droppedObjectContainer,
droppedObjectContainer = new DroppedObjectContainer(),
CatcherArea.MovableCatcher.CreateProxiedContent(),
HitObjectContainer.CreateProxy(),
// This ordering (`CatcherArea` before `HitObjectContainer`) is important to

View File

@ -79,7 +79,8 @@ namespace osu.Game.Rulesets.Catch.UI
/// <summary>
/// Contains objects dropped from the plate.
/// </summary>
private readonly DroppedObjectContainer droppedObjectTarget;
[Resolved]
private DroppedObjectContainer droppedObjectTarget { get; set; }
public CatcherAnimationState CurrentState
{
@ -134,10 +135,9 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly DrawablePool<CaughtBanana> caughtBananaPool;
private readonly DrawablePool<CaughtDroplet> caughtDropletPool;
public Catcher([NotNull] Container trailsTarget, [NotNull] DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty = null)
public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = null)
{
this.trailsTarget = trailsTarget;
this.droppedObjectTarget = droppedObjectTarget;
Origin = Anchor.TopCentre;

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary>
private int currentDirection;
public CatcherArea(DroppedObjectContainer droppedObjectContainer, BeatmapDifficulty difficulty = null)
public CatcherArea(BeatmapDifficulty difficulty = null)
{
Size = new Vector2(CatchPlayfield.WIDTH, CATCHER_SIZE);
Children = new Drawable[]
@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Catch.UI
Margin = new MarginPadding { Bottom = 350f },
X = CatchPlayfield.CENTER_X
},
MovableCatcher = new Catcher(this, droppedObjectContainer, difficulty) { X = CatchPlayfield.CENTER_X },
MovableCatcher = new Catcher(this, difficulty) { X = CatchPlayfield.CENTER_X },
};
}