mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
28 lines
653 B
C#
28 lines
653 B
C#
using MonoGame.Extended.Collections;
|
|
|
|
namespace MonoGame.Extended.Entities
|
|
{
|
|
internal interface IComponentPool
|
|
{
|
|
object New();
|
|
}
|
|
|
|
internal class ComponentPool<T> : ObjectPool<T>, IComponentPool where T : class, IPoolable, new()
|
|
{
|
|
public ComponentPool(int intitialSize = 16, ObjectPoolIsFullPolicy isFullPolicy = ObjectPoolIsFullPolicy.ReturnNull)
|
|
: base(CreateObject, intitialSize, isFullPolicy)
|
|
{
|
|
}
|
|
|
|
private static T CreateObject()
|
|
{
|
|
return new T();
|
|
}
|
|
|
|
object IComponentPool.New()
|
|
{
|
|
return base.New();
|
|
}
|
|
}
|
|
}
|