1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 21:53:21 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuPool.cs

33 lines
1.1 KiB
C#
Raw Normal View History

2020-11-10 23:22:06 +08:00
// 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 System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Objects.Drawables;
2020-11-14 17:04:59 +08:00
namespace osu.Game.Rulesets.Osu.Objects.Drawables
2020-11-10 23:22:06 +08:00
{
2020-11-14 17:05:30 +08:00
public class DrawableOsuPool<T> : DrawablePool<T>
2020-11-10 23:22:06 +08:00
where T : DrawableHitObject, new()
{
private readonly Func<DrawableHitObject, double, bool> checkHittable;
private readonly Action<Drawable> onLoaded;
2020-11-14 17:05:30 +08:00
public DrawableOsuPool(Func<DrawableHitObject, double, bool> checkHittable, Action<Drawable> onLoaded, int initialSize, int? maximumSize = null)
2020-11-10 23:22:06 +08:00
: base(initialSize, maximumSize)
{
this.checkHittable = checkHittable;
this.onLoaded = onLoaded;
}
protected override T CreateNewDrawable() => base.CreateNewDrawable().With(o =>
{
var osuObject = (DrawableOsuHitObject)(object)o;
osuObject.CheckHittable = checkHittable;
osuObject.OnLoadComplete += onLoaded;
});
}
}