20 lines
550 B
C#
20 lines
550 B
C#
using System.Collections.Generic;
|
|
using UnityEngine.Pool;
|
|
|
|
namespace DanieleMarotta.RiversongCodeShowcase
|
|
{
|
|
public class PoolingService : IPoolingService
|
|
{
|
|
private Dictionary<int, object> _poolLookup = new();
|
|
|
|
public void AddPool<T>(int key, IObjectPool<T> pool) where T : class
|
|
{
|
|
_poolLookup.Add(key, pool);
|
|
}
|
|
|
|
public IObjectPool<T> GetPool<T>(int key) where T : class
|
|
{
|
|
return _poolLookup.TryGetValue(key, out var pool) ? (IObjectPool<T>)pool : null;
|
|
}
|
|
}
|
|
} |