Files
MonoGame.Extended/Source/MonoGame.Extended.Entities/Entities/EntityComponentPool.cs
T
Lucas Girouard-StranksandDylan Wilson 2725d02715 Artemis Entity Component System (#360)
* artemis ecs

* Working on StarWarrior

* Refactor for bugs

* demo works :)

* Fix pool bug

* Fix string typo

* ObjectPool garbage optimization

* Aspect attribute

* Remove BigInteger

* Fix demo

* Refactor for events

* wip on platformer demo

* Fix typo
2017-04-02 18:16:39 +10:00

28 lines
681 B
C#

using MonoGame.Extended.Collections;
namespace MonoGame.Extended.Entities
{
internal interface IComponentPool
{
EntityComponent New();
}
internal class ComponentPool<T> : ObjectPool<T>, IComponentPool where T : EntityComponent, IPoolable, new()
{
public ComponentPool(int intitialSize = 16, ObjectPoolIsFullPolicy isFullPolicy = ObjectPoolIsFullPolicy.ReturnNull)
: base(CreateObject, intitialSize, isFullPolicy)
{
}
private static T CreateObject()
{
return new T();
}
EntityComponent IComponentPool.New()
{
return base.New();
}
}
}