Files
MonoGame.Extended/Source/MonoGame.Extended.Entities/EntityComponentPool.cs
T
2017-11-30 20:55:05 +10:00

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();
}
}
}