added UI dodging nozzle on phones

This commit is contained in:
Mausham
2025-12-18 12:32:06 -08:00
parent f19bbb9d8c
commit ef015c6665
24 changed files with 534 additions and 22 deletions

View File

@@ -0,0 +1,57 @@
using Darkmatter.Core;
using System.Collections.Generic;
using UnityEngine;
using VContainer;
using VContainer.Unity;
namespace Darkmatter.Domain
{
public class ObjectPool<T> : MonoBehaviour,IPool<T> where T : Component
{
[SerializeField] T prefab;
[SerializeField] private Transform prefabParent;
[SerializeField] private int poolSize = 15;
public Queue<T> pool = new Queue<T>();
[Inject] IObjectResolver resolver;
public IReadOnlyCollection<T> All => pool;
private void Awake()
{
CreateObjectPool();
}
private void CreateObjectPool()
{
for(int i=0;i<poolSize; i++)
{
T obj = Instantiate(prefab, prefabParent);
resolver.InjectGameObject(obj.gameObject);
obj.gameObject.SetActive(false);
pool.Enqueue(obj);
}
}
public T GetFromPool()
{
if(pool.Count == 0)
{
T obj = Instantiate(prefab, prefabParent);
resolver.InjectGameObject(obj.gameObject);
obj.gameObject.SetActive(true);
pool.Enqueue(obj);
return obj;
}
T returningObj = pool.Dequeue();
returningObj.gameObject.SetActive(true);
return returningObj;
}
public void ReturnToPool(T obj)
{
obj.gameObject.SetActive(false);
pool.Enqueue(obj);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e060b99c1df2bec40871a980f4b6c339