2026-03-26 10:49:41 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace AlicizaX
|
|
|
|
|
{
|
|
|
|
|
[CreateAssetMenu(fileName = "PoolConfig", menuName = "GameplaySystem/PoolConfig", order = 10)]
|
|
|
|
|
public class PoolConfigScriptableObject : ScriptableObject
|
|
|
|
|
{
|
2026-04-17 21:01:20 +08:00
|
|
|
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);
|
|
|
|
|
}
|
2026-03-26 10:49:41 +08:00
|
|
|
|
|
|
|
|
public void Normalize()
|
|
|
|
|
{
|
2026-04-17 21:01:20 +08:00
|
|
|
if (entries == null)
|
2026-03-26 10:49:41 +08:00
|
|
|
{
|
2026-04-17 21:01:20 +08:00
|
|
|
entries = new List<PoolEntry>();
|
2026-03-26 10:49:41 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-17 21:01:20 +08:00
|
|
|
for (int i = 0; i < entries.Count; i++)
|
2026-03-26 10:49:41 +08:00
|
|
|
{
|
2026-04-17 21:01:20 +08:00
|
|
|
entries[i]?.Normalize();
|
2026-03-26 10:49:41 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
private void OnValidate()
|
|
|
|
|
{
|
|
|
|
|
Normalize();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|