52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace AlicizaX
|
|
{
|
|
[CreateAssetMenu(fileName = "PoolConfig", menuName = "GameplaySystem/PoolConfig", order = 10)]
|
|
public class PoolConfigScriptableObject : ScriptableObject
|
|
{
|
|
public List<PoolEntry> entries = new List<PoolEntry>();
|
|
|
|
public PoolConfigCatalog BuildCatalog()
|
|
{
|
|
Normalize();
|
|
|
|
var normalizedEntries = new List<PoolEntry>(entries.Count);
|
|
for (int i = 0; i < entries.Count; i++)
|
|
{
|
|
PoolEntry entry = entries[i];
|
|
if (entry == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
normalizedEntries.Add(entry);
|
|
}
|
|
|
|
normalizedEntries.Sort(PoolEntry.CompareByPriority);
|
|
return new PoolConfigCatalog(normalizedEntries);
|
|
}
|
|
|
|
public void Normalize()
|
|
{
|
|
if (entries == null)
|
|
{
|
|
entries = new List<PoolEntry>();
|
|
}
|
|
|
|
for (int i = 0; i < entries.Count; i++)
|
|
{
|
|
entries[i]?.Normalize();
|
|
}
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
private void OnValidate()
|
|
{
|
|
Normalize();
|
|
}
|
|
#endif
|
|
}
|
|
}
|