mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
* 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
28 lines
681 B
C#
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();
|
|
}
|
|
}
|
|
}
|