Move around scripts to cleanup the Minigame structure

This commit is contained in:
2025-09-22 14:50:48 +02:00
parent 96aad806a9
commit da07f778c3
45 changed files with 17 additions and 17 deletions

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
using UnityEngine;
using Pooling;
namespace Minigames.DivingForPictures
{
/// <summary>
/// Manages a pool of trench tile objects to reduce garbage collection overhead.
/// Optimized for handling a large number of different prefab types.
/// </summary>
public class TrenchTilePool : MultiPrefabPool<Tile>
{
/// <summary>
/// Returns a tile to the pool
/// </summary>
/// <param name="tile">The tile to return to the pool</param>
/// <param name="prefabIndex">The index of the prefab this tile was created from</param>
public void ReturnTile(GameObject tile, int prefabIndex)
{
if (tile != null)
{
Tile tileComponent = tile.GetComponent<Tile>();
if (tileComponent != null)
{
Return(tileComponent, prefabIndex);
}
else
{
Debug.LogWarning($"Attempted to return a GameObject without a Tile component: {tile.name}");
Destroy(tile);
}
}
}
/// <summary>
/// Gets a tile from the pool, or creates a new one if the pool is empty
/// </summary>
/// <returns>A tile instance ready to use</returns>
public GameObject GetTile(int prefabIndex)
{
Tile tileComponent = Get(prefabIndex);
return tileComponent.gameObject;
}
}
}