Files
AppleHillsProduction/Assets/Scripts/Minigames/DivingForPictures/Bubbles/BubblePool.cs

44 lines
1.2 KiB
C#
Raw Normal View History

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