# PoolManager

A Pool System is used to manage object reuse efficiently, reducing instantiation and destruction overhead. Instead of creating and destroying objects repeatedly (which can hurt performance), a pool system pre-instantiates a set of objects and enables/disables them as needed.

This system improves performance, prevents frame-rate drops, and is easily customizable in FPS Engine.

{% hint style="info" %}
The Pool Manager can be found as a child of GeneralManagers object within the Player

![](https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2F9yBCb1E0tOofujQ0otcq%2Fimage.png?alt=media\&token=dd0086de-84e3-40b0-b27b-194e0582e18a)
{% endhint %}

### Functions & Accesors | PoolManager.cs

> <mark style="color:orange;">Instance ( PoolManager ) / Public Static Singleton</mark>
>
> PoolManager Singleton

> <mark style="color:orange;">WeaponEffectsSize ( int ) / Public Getter, Private Setter</mark>
>
> Returns the size of the pre-instantiated collection of Weapon Effects.

> <mark style="color:orange;">DamagePopUpsSize ( int ) / Public Getter, Private Setter</mark>
>
> Returns the size of the pre-instantiated collection of Damage Pop Up Effects.

> <mark style="color:orange;">BulletGraphicsSize ( int ) / Public Getter, Private Setter</mark>
>
> Returns the size of the pre-instantiated collection of Bullet Graphics Effects.

> <mark style="color:orange;">Default Return Time ( float ) / Public Getter, Private Setter</mark>
>
> If not specified, time to wait for an object to be returned to the pool.

> <mark style="color:orange;">Damage Pop Ups Time ( float ) / Public Getter, Private Setter</mark>
>
> Time to wait for a Damage Pop Up specifically to be returned to the pool.

> <mark style="color:green;">RegisterPool ( GameObject prefab, int size )</mark>
>
> Registers a new pool given a prefab and the size of the collection.
>
> * prefab: Prefab that defines the new collection of the Pool. "size" instances of this prefab will be pre-instantiated as soon as the new collection is registered.
> * size: Amount of instance of "prefab" to pre-instantiate when the collection is registered.

> <mark style="color:green;">GetFromPool ( GameObject prefab, Vector3 position, Quaternion rotation )</mark>
>
> Gets a specific prefab from an existing collection and places it at the desired position and rotation. Applies default return times as it is not specified.&#x20;
>
> * prefab: Prefab that defines the  collection of the Pool.
> * position: Position to locate the prefab on get from the pool.
> * rotation: Rotation to locate the prefab on get from the pool.

> <mark style="color:green;">GetFromPool ( GameObject prefab, Vector3 position, Quaternion rotation, float returnToPool )</mark>
>
> Gets a specific prefab from an existing collection and places it at the desired position and rotation. Specifies return times.
>
> * prefab: Prefab that defines the  collection of the Pool.
> * position: Position to locate the prefab on get from the pool.
> * rotation: Rotation to locate the prefab on get from the pool.
> * returnToPool: Time to return to pool.

> <mark style="color:green;">ReturnToPool ( GameObject obj, GameObject prefab )</mark>
>
> Returns an object to the pool if obj exists in the prefab collection.
>
> * obj: Object to return to pool.
> * prefab: Prefab that defines the collection of the pool.&#x20;
