1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-18 04:49:34 +08:00

Use hit object pooling for Droplet and TinyDroplet.

This commit is contained in:
ekrctb 2020-11-30 19:04:09 +09:00
parent 05aaa377e7
commit 94fd607a7c
4 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,7 @@
// 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.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Utils;
@ -13,7 +14,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public override bool StaysOnPlate => false;
public DrawableDroplet(CatchHitObject h)
public DrawableDroplet()
: this(null)
{
}
public DrawableDroplet([CanBeNull] CatchHitObject h)
: base(h)
{
}

View File

@ -1,13 +1,20 @@
// 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.
using JetBrains.Annotations;
namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public class DrawableTinyDroplet : DrawableDroplet
{
protected override float ScaleFactor => base.ScaleFactor / 2;
public DrawableTinyDroplet(TinyDroplet h)
public DrawableTinyDroplet()
: this(null)
{
}
public DrawableTinyDroplet([CanBeNull] TinyDroplet h)
: base(h)
{
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
@ -56,6 +57,13 @@ namespace osu.Game.Rulesets.Catch.UI
};
}
[BackgroundDependencyLoader]
private void load()
{
RegisterPool<Droplet, DrawableDroplet>(1);
RegisterPool<TinyDroplet, DrawableTinyDroplet>(1);
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -55,12 +55,6 @@ namespace osu.Game.Rulesets.Catch.UI
case BananaShower shower:
return new DrawableBananaShower(shower, CreateDrawableRepresentation);
case TinyDroplet tiny:
return new DrawableTinyDroplet(tiny);
case Droplet droplet:
return new DrawableDroplet(droplet);
}
return null;