Add pooling for mania judgements

This commit is contained in:
smoogipoo 2020-07-29 16:41:10 +09:00
parent 91ce06aaa7
commit 5df406a035
2 changed files with 14 additions and 6 deletions

View File

@ -15,6 +15,10 @@ public DrawableManiaJudgement(JudgementResult result, DrawableHitObject judgedOb
{
}
public DrawableManiaJudgement()
{
}
[BackgroundDependencyLoader]
private void load()
{

View File

@ -6,6 +6,7 @@
using osu.Framework.Allocation;
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;
@ -33,8 +34,8 @@ public class Stage : ScrollingPlayfield
public IReadOnlyList<Column> Columns => columnFlow.Children;
private readonly FillFlowContainer<Column> columnFlow;
public Container<DrawableManiaJudgement> Judgements => judgements;
private readonly JudgementContainer<DrawableManiaJudgement> judgements;
private readonly DrawablePool<DrawableManiaJudgement> judgementPool;
private readonly Drawable barLineContainer;
private readonly Container topLevelContainer;
@ -63,6 +64,7 @@ public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction n
InternalChildren = new Drawable[]
{
judgementPool = new DrawablePool<DrawableManiaJudgement>(2),
new Container
{
Anchor = Anchor.TopCentre,
@ -208,12 +210,14 @@ internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
return;
judgements.Clear();
judgements.Add(new DrawableManiaJudgement(result, judgedObject)
judgements.Clear(false);
judgements.Add(judgementPool.Get(j =>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
j.Apply(result, judgedObject);
j.Anchor = Anchor.Centre;
j.Origin = Anchor.Centre;
}));
}
protected override void Update()