diff --git a/osu.Game.Rulesets.Mania/UI/Stage.cs b/osu.Game.Rulesets.Mania/UI/Stage.cs index fa9af6d157..36286940a8 100644 --- a/osu.Game.Rulesets.Mania/UI/Stage.cs +++ b/osu.Game.Rulesets.Mania/UI/Stage.cs @@ -1,22 +1,23 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - +using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Pooling; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mania.Skinning; using osu.Game.Rulesets.Mania.UI.Components; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Skinning; @@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly ColumnFlow columnFlow; private readonly JudgementContainer judgements; - private readonly DrawablePool judgementPool; + private readonly JudgementPooler judgementPooler; private readonly Drawable barLineContainer; @@ -48,6 +49,8 @@ namespace osu.Game.Rulesets.Mania.UI private readonly int firstColumnIndex; + private ISkinSource currentSkin = null!; + public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction) { this.firstColumnIndex = firstColumnIndex; @@ -65,7 +68,6 @@ namespace osu.Game.Rulesets.Mania.UI InternalChildren = new Drawable[] { - judgementPool = new DrawablePool(2), new Container { Anchor = Anchor.TopCentre, @@ -104,7 +106,7 @@ namespace osu.Game.Rulesets.Mania.UI { RelativeSizeAxes = Axes.Y, }, - new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.StageForeground), _ => null) + new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.StageForeground)) { RelativeSizeAxes = Axes.Both }, @@ -137,11 +139,13 @@ namespace osu.Game.Rulesets.Mania.UI AddNested(column); } + var hitWindows = new ManiaHitWindows(); + + AddInternal(judgementPooler = new JudgementPooler(Enum.GetValues().Where(r => hitWindows.IsHitResultAllowed(r)))); + RegisterPool(50, 200); } - private ISkinSource currentSkin; - [BackgroundDependencyLoader] private void load(ISkinSource skin) { @@ -170,7 +174,7 @@ namespace osu.Game.Rulesets.Mania.UI base.Dispose(isDisposing); - if (currentSkin != null) + if (currentSkin.IsNotNull()) currentSkin.SourceChanged -= onSkinChanged; } @@ -196,13 +200,13 @@ namespace osu.Game.Rulesets.Mania.UI return; judgements.Clear(false); - judgements.Add(judgementPool.Get(j => + judgements.Add(judgementPooler.Get(result.Type, j => { j.Apply(result, judgedObject); j.Anchor = Anchor.Centre; j.Origin = Anchor.Centre; - })); + })!); } protected override void Update()