OneShotOneKill/Assets/Script/Info/ActorInfo.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2026-01-07 21:27:42 +00:00
using System.Collections.Generic;
using UnityEngine;
public class ActorInfo : MonoBehaviour
{
//[RuntimeInitializeOnLoadMethod]
//static void OnRuntimeMethodLoad() { new GameObject("ActorInfo").AddComponent<ActorInfo>(); }
public static ActorInfo Ins;
private void Awake() { Ins = this; DontDestroyOnLoad(gameObject); }
private ObjectPool<List<Actor>> listPool = new ObjectPool<List<Actor>>();
/// <summary>
/// 타입, <노드, 액터들>
/// </summary>
Dictionary<eRole, Dictionary<int, List<Actor>>> dic_actor = new Dictionary<eRole, Dictionary<int, List<Actor>>>();
public void Destroy_Mob()
{
foreach (var role in dic_actor)
{
if (role.Key == eRole.Mob)
{
foreach (var actor in role.Value)
{
for (int i = 0; i < actor.Value.Count; i++)
{
Destroy(actor.Value[i].gameObject);
}
}
role.Value.Clear();
}
}
}
public void Add_Actor(Actor actor, eRole role, int node = 0)
{ // 생성한 액터 추가
if (!dic_actor[role].ContainsKey(node))
dic_actor[role].Add(node, new List<Actor>());
dic_actor[role][node].Add(actor);
}
public void Release_Actors(List<Actor> actors)
{
actors.Clear();
listPool.Release(actors);
}
}