A pooling mechanism for entities with an API like C# ArrayPool<T>. Useful for situations where you are creating and deleting many entities with a limited lifespan.
- Generics support. Any type implementing IEntity (any Entity) and contains a parameterless constructor will suffice.
- Limited capacity pools. This helps you maintain sensible entity counts and prevent excessive creations.
- Overridable entity rent/return logic. Simply add the IPooledEntity interface to your entity.
- Timed asynchronous returning of entities. Useful for fire and forget renting.
- Networkable (All required functionality is implemented but is currently unusable due to S&box issues.)
You can either download from this repo or you can reference it with gooman.entity_pools
using asset.party
// Get yourself an existing or new instance of MyEntity.
var rentedEntity = EntityPool<MyEntity>.Shared.Rent();
// Mess with your rented entity.
// Return the entity back to the pool for reuse.
EntityPool<MyEntity>.Shared.Return( rentedEntity );
Distributed under the MIT License. See the license for more information.