using AI.Base; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UIElements; using static EnemySpawnerManager; public class EnemySpawnerManager : MonoBehaviour { public static EnemySpawnerManager Instance; [SerializeField] public GameObject GoblerPreFab; private GameObjectPool GoblerPool; public static Dictionary Goblers = new Dictionary(); public static Action UpdateTick; public static Action GizmoTick; public static int MaxGoblers = 100; public class Gobler { public GameObject Object; public GoblerStateManager Manager; public Gobler(GameObject obj, GoblerStateManager manager) { Object = obj; Manager = manager; } } public void Awake() { Instance = this; Goblers.Clear(); GoblerPool = new GameObjectPool(GoblerPreFab, 50, 200); } public static void RemoveGobler(GoblerStateManager goblerManager) { Destroy(Goblers[goblerManager]); Goblers.Remove(goblerManager); } public void Update() { while (Goblers.Count() < MaxGoblers) { var gobler = GoblerPool.Get(transform.position, Quaternion.identity); Goblers.Add(new GoblerStateManager(gobler), gobler); } UpdateTick?.Invoke(); } public static void OnDrawGizmos() { GizmoTick?.Invoke(); } }