44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Core;
|
|
using UnityEngine;
|
|
using Pooling;
|
|
|
|
namespace Minigames.DivingForPictures
|
|
{
|
|
/// <summary>
|
|
/// Manages a pool of bubble objects to reduce garbage collection overhead.
|
|
/// </summary>
|
|
public class BubblePool : BaseObjectPool<Bubble>
|
|
{
|
|
/// <summary>
|
|
/// Gets a bubble from the pool, or creates a new one if the pool is empty
|
|
/// </summary>
|
|
/// <returns>A bubble instance ready to use</returns>
|
|
public Bubble GetBubble()
|
|
{
|
|
Bubble bubble = Get();
|
|
|
|
// Set reference to this pool so the bubble can return itself
|
|
bubble.SetPool(this);
|
|
|
|
return bubble;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a bubble to the pool
|
|
/// </summary>
|
|
/// <param name="bubble">The bubble to return to the pool</param>
|
|
public void ReturnBubble(Bubble bubble)
|
|
{
|
|
Return(bubble);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Logs pool statistics
|
|
/// </summary>
|
|
public override void LogPoolStats()
|
|
{
|
|
Logging.Debug($"[BubblePool] Pooled bubbles: {pooledObjects.Count}/{maxPoolSize} (Created: {totalCreated}, Returned: {totalReturned})");
|
|
}
|
|
}
|
|
}
|