57 lines
1.1 KiB
C#
57 lines
1.1 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年08月07日 星期四 15:08:51
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Logic.PrefabPool
|
|
{
|
|
public enum PrefabType
|
|
{
|
|
Fog,
|
|
Treasure,
|
|
Hurt,
|
|
Fire,
|
|
Die,
|
|
Flag,
|
|
Heal,
|
|
Skill,
|
|
Damage,
|
|
Max,
|
|
}
|
|
|
|
|
|
public class PrefabConfig: ScriptableObject
|
|
{
|
|
public List<PrefabItem> PrefabList = new List<PrefabItem>();
|
|
private Dictionary<PrefabType, PrefabItem> _prefabDict = new Dictionary<PrefabType, PrefabItem>();
|
|
|
|
public void RefreshPrefabDict()
|
|
{
|
|
if (_prefabDict.Count == PrefabList.Count) return;
|
|
_prefabDict.Clear();
|
|
foreach (var item in PrefabList) _prefabDict[item.Type] = item;
|
|
}
|
|
|
|
public PrefabItem GetPrefab(PrefabType type)
|
|
{
|
|
RefreshPrefabDict();
|
|
return _prefabDict.GetValueOrDefault(type);
|
|
}
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
public class PrefabItem
|
|
{
|
|
public PrefabType Type;
|
|
public GameObject Prefab;
|
|
}
|
|
} |