From 0fbca59523cea2bd7036581c5445c7173ff8123f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jan 2024 20:49:00 +0900 Subject: [PATCH] Fix osu!taiko judgments not being pooled correctly They weren't being initialised correctly on initial pool. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 49 ++++++++++---------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 31f8171290..7e3ed7a4d4 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -1,8 +1,6 @@ // 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; @@ -10,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; @@ -42,29 +39,29 @@ namespace osu.Game.Rulesets.Taiko.UI public Container UnderlayElements { get; private set; } = null!; - private Container hitExplosionContainer; - private Container kiaiExplosionContainer; - private JudgementContainer judgementContainer; - private ScrollingHitObjectContainer drumRollHitContainer; - internal Drawable HitTarget; - private SkinnableDrawable mascot; + private Container hitExplosionContainer = null!; + private Container kiaiExplosionContainer = null!; + private JudgementContainer judgementContainer = null!; + private ScrollingHitObjectContainer drumRollHitContainer = null!; + internal Drawable HitTarget = null!; + private SkinnableDrawable mascot = null!; - private readonly IDictionary> judgementPools = new Dictionary>(); + private JudgementPooler judgementPooler = null!; private readonly IDictionary explosionPools = new Dictionary(); - private ProxyContainer topLevelHitContainer; - private InputDrum inputDrum; - private Container rightArea; + private ProxyContainer topLevelHitContainer = null!; + private InputDrum inputDrum = null!; + private Container rightArea = null!; /// /// is purposefully not called on this to prevent i.e. being able to interact /// with bar lines in the editor. /// - private BarLinePlayfield barLinePlayfield; + private BarLinePlayfield barLinePlayfield = null!; - private Container barLineContent; - private Container hitObjectContent; - private Container overlayContent; + private Container barLineContent = null!; + private Container hitObjectContent = null!; + private Container overlayContent = null!; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -202,13 +199,12 @@ namespace osu.Game.Rulesets.Taiko.UI var hitWindows = new TaikoHitWindows(); - foreach (var result in Enum.GetValues().Where(r => hitWindows.IsHitResultAllowed(r))) - { - judgementPools.Add(result, new DrawablePool(15)); - explosionPools.Add(result, new HitExplosionPool(result)); - } + HitResult[] usableHitResults = Enum.GetValues().Where(r => hitWindows.IsHitResultAllowed(r)).ToArray(); - AddRangeInternal(judgementPools.Values); + AddInternal(judgementPooler = new JudgementPooler(usableHitResults)); + + foreach (var result in usableHitResults) + explosionPools.Add(result, new HitExplosionPool(result)); AddRangeInternal(explosionPools.Values); } @@ -339,7 +335,12 @@ namespace osu.Game.Rulesets.Taiko.UI if (!result.Type.IsScorable()) break; - judgementContainer.Add(judgementPools[result.Type].Get(j => j.Apply(result, judgedObject))); + var judgement = judgementPooler.Get(result.Type, j => j.Apply(result, judgedObject)); + + if (judgement == null) + return; + + judgementContainer.Add(judgement); var type = (judgedObject.HitObject as Hit)?.Type ?? HitType.Centre; addExplosion(judgedObject, result.Type, type);