Move around scripts to cleanup the Minigame structure
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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()
|
||||
{
|
||||
Debug.Log($"[BubblePool] Pooled bubbles: {pooledObjects.Count}/{maxPoolSize} (Created: {totalCreated}, Returned: {totalReturned})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user