Files
zeling_v2/Assets/_Game/Scripts/VFX/VFXCatalogSO.cs

56 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using BaseGames.Combat;
namespace BaseGames.VFX
{
/// <summary>
/// VFX 资产映射字典HitFxType → VFX Prefab Addressable 引用。
/// 在 GameManager.OnGameplayStarted 中调用 Initialize() 建立快速查表。
/// 资产路径Assets/ScriptableObjects/VFX/VFX_Catalog.asset
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/VFX/VFXCatalog")]
public class VFXCatalogSO : ScriptableObject
{
[Header("命中特效映射")]
public VFXEntry[] hitEffects;
[Header("预热配置")]
public VFXWarmupEntry[] warmups;
private Dictionary<HitFxType, AssetReferenceGameObject> _map;
/// <summary>建立快速查表字典。在 Gameplay 开始前调用一次。</summary>
public void Initialize()
{
_map = new Dictionary<HitFxType, AssetReferenceGameObject>();
if (hitEffects == null) return;
foreach (var e in hitEffects)
_map[e.type] = e.vfxRef;
}
/// <summary>根据 HitFxType 查找对应 VFX Prefab 引用。调用前必须先调用 Initialize()。</summary>
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;
}
}