Table of Contents

Method GetHashPool

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

GetHashPool<T>(int, Func<T>, Action<T>, Action<T>, Action<T>)

Gets a hash pool for any type - hashable or not.

public static IPool<IPoolObject<T>> GetHashPool<T>(int initialCapacity, Func<T> create, Action<T> destroy = null, Action<T> activate = null, Action<T> deactivate = null)

Parameters

initialCapacity int

The initial capacity of the pool.

create Func<T>

The function that creates a new object of type T. This should create objects in the active state; they will be deactivated by the pool.

destroy Action<T>

The function that destroys an object of type T. If it is an ordinary C# object, you do not need to provide a destroy method - the object will be removed from the pool, and (provided you do not have references to it), it will be released naturally like any C# object. If T is a Unity object, or a component whose game object you want to be destroyed, this action should do that. Also consider using the MonoBehaviourPool<T> class instead.

activate Action<T>

A function called when an object is activated, when it is acquired.

deactivate Action<T>

A function called when an object is deactivated, either when releasing it, or when it is created for the first time.

Returns

IPool<IPoolObject<T>>

A new hash pool.

Type Parameters

T

The type of the objects to pool.

Remarks

Objects acquired from this pool will be wrapped in a PoolExtensions.PoolObject<T> object. Access the original object using Value.