Files
riversong-code-showcase/Source/Riversong/Game/CommonServices/Pooling/PoolingService.cs
2026-05-21 16:04:49 +02:00

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;
}
}
}