1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Fix osu!taiko judgments not being pooled correctly

They weren't being initialised correctly on initial pool.
This commit is contained in:
Dean Herbert 2024-01-15 20:49:00 +09:00
parent e9812fac7a
commit 0fbca59523
No known key found for this signature in database

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -10,7 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -42,29 +39,29 @@ namespace osu.Game.Rulesets.Taiko.UI
public Container UnderlayElements { get; private set; } = null!; public Container UnderlayElements { get; private set; } = null!;
private Container<HitExplosion> hitExplosionContainer; private Container<HitExplosion> hitExplosionContainer = null!;
private Container<KiaiHitExplosion> kiaiExplosionContainer; private Container<KiaiHitExplosion> kiaiExplosionContainer = null!;
private JudgementContainer<DrawableTaikoJudgement> judgementContainer; private JudgementContainer<DrawableTaikoJudgement> judgementContainer = null!;
private ScrollingHitObjectContainer drumRollHitContainer; private ScrollingHitObjectContainer drumRollHitContainer = null!;
internal Drawable HitTarget; internal Drawable HitTarget = null!;
private SkinnableDrawable mascot; private SkinnableDrawable mascot = null!;
private readonly IDictionary<HitResult, DrawablePool<DrawableTaikoJudgement>> judgementPools = new Dictionary<HitResult, DrawablePool<DrawableTaikoJudgement>>(); private JudgementPooler<DrawableTaikoJudgement> judgementPooler = null!;
private readonly IDictionary<HitResult, HitExplosionPool> explosionPools = new Dictionary<HitResult, HitExplosionPool>(); private readonly IDictionary<HitResult, HitExplosionPool> explosionPools = new Dictionary<HitResult, HitExplosionPool>();
private ProxyContainer topLevelHitContainer; private ProxyContainer topLevelHitContainer = null!;
private InputDrum inputDrum; private InputDrum inputDrum = null!;
private Container rightArea; private Container rightArea = null!;
/// <remarks> /// <remarks>
/// <see cref="Playfield.AddNested"/> is purposefully not called on this to prevent i.e. being able to interact /// <see cref="Playfield.AddNested"/> is purposefully not called on this to prevent i.e. being able to interact
/// with bar lines in the editor. /// with bar lines in the editor.
/// </remarks> /// </remarks>
private BarLinePlayfield barLinePlayfield; private BarLinePlayfield barLinePlayfield = null!;
private Container barLineContent; private Container barLineContent = null!;
private Container hitObjectContent; private Container hitObjectContent = null!;
private Container overlayContent; private Container overlayContent = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
@ -202,13 +199,12 @@ namespace osu.Game.Rulesets.Taiko.UI
var hitWindows = new TaikoHitWindows(); var hitWindows = new TaikoHitWindows();
foreach (var result in Enum.GetValues<HitResult>().Where(r => hitWindows.IsHitResultAllowed(r))) HitResult[] usableHitResults = Enum.GetValues<HitResult>().Where(r => hitWindows.IsHitResultAllowed(r)).ToArray();
{
judgementPools.Add(result, new DrawablePool<DrawableTaikoJudgement>(15));
explosionPools.Add(result, new HitExplosionPool(result));
}
AddRangeInternal(judgementPools.Values); AddInternal(judgementPooler = new JudgementPooler<DrawableTaikoJudgement>(usableHitResults));
foreach (var result in usableHitResults)
explosionPools.Add(result, new HitExplosionPool(result));
AddRangeInternal(explosionPools.Values); AddRangeInternal(explosionPools.Values);
} }
@ -339,7 +335,12 @@ namespace osu.Game.Rulesets.Taiko.UI
if (!result.Type.IsScorable()) if (!result.Type.IsScorable())
break; 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; var type = (judgedObject.HitObject as Hit)?.Type ?? HitType.Centre;
addExplosion(judgedObject, result.Type, type); addExplosion(judgedObject, result.Type, type);