using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using BaseGames.Combat;
namespace BaseGames.VFX
{
///
/// VFX 资产映射字典:HitFxType → VFX Prefab Addressable 引用。
/// 在 GameManager.OnGameplayStarted 中调用 Initialize() 建立快速查表。
/// 资产路径:Assets/ScriptableObjects/VFX/VFX_Catalog.asset
///
[CreateAssetMenu(menuName = "VFX/VFXCatalog")]
public class VFXCatalogSO : ScriptableObject
{
[Header("命中特效映射")]
public VFXEntry[] hitEffects;
[Header("预热配置")]
public VFXWarmupEntry[] warmups;
private Dictionary _map;
/// 建立快速查表字典。在 Gameplay 开始前调用一次。
public void Initialize()
{
_map = new Dictionary();
if (hitEffects == null) return;
foreach (var e in hitEffects)
_map[e.type] = e.vfxRef;
}
/// 根据 HitFxType 查找对应 VFX Prefab 引用。调用前必须先调用 Initialize()。
public bool TryGetHitFX(HitFxType type, out AssetReferenceGameObject vfxRef)
{
Debug.Assert(_map != null, "[VFXCatalogSO] TryGetHitFX 被调用前必须先调用 Initialize()。");
return _map.TryGetValue(type, out vfxRef);
}
}
[Serializable]
public struct VFXEntry
{
public HitFxType type;
public AssetReferenceGameObject vfxRef;
}
[Serializable]
public struct VFXWarmupEntry
{
public AssetReferenceGameObject vfxRef;
[Min(1)] public int warmupCount;
}
}