多轮审查和修复
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.Core;
|
||||
using BaseGames.Core.Events;
|
||||
using BaseGames.Combat;
|
||||
|
||||
namespace BaseGames.VFX
|
||||
@@ -13,30 +15,31 @@ namespace BaseGames.VFX
|
||||
[SerializeField] private HitConfirmedEventChannelSO _onHitConfirmed;
|
||||
[SerializeField] private VFXCatalogSO _catalog;
|
||||
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_catalog != null)
|
||||
_catalog.Initialize();
|
||||
Debug.Assert(_catalog != null, "[HitFXSpawner] _catalog 未赋值,请在 Inspector 中指定 VFXCatalogSO。", this);
|
||||
_catalog.Initialize();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_onHitConfirmed != null)
|
||||
_onHitConfirmed.OnEventRaised += HandleHit;
|
||||
_onHitConfirmed?.Subscribe(HandleHit).AddTo(_subs);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_onHitConfirmed != null)
|
||||
_onHitConfirmed.OnEventRaised -= HandleHit;
|
||||
_subs.Clear();
|
||||
}
|
||||
|
||||
private void HandleHit(HitInfo info)
|
||||
{
|
||||
if (_catalog == null || VFXPool.Instance == null) return;
|
||||
var pool = ServiceLocator.GetOrDefault<IVFXPoolService>();
|
||||
if (pool == null) return;
|
||||
|
||||
if (_catalog.TryGetHitFX(info.DamageInfo.FxType, out var vfxRef))
|
||||
VFXPool.Instance.Play(vfxRef, info.HitPoint);
|
||||
pool.Play(vfxRef, info.HitPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user