using System; using System.Collections.Generic; using Cielonos.MainGame.Buffs.Character; using Cielonos.MainGame.Characters; using SLSUtilities.General; using SLSUtilities.WwiseAssistance; namespace Cielonos.MainGame.Inventory.Collections { /// /// 衰变传播器 / Decay Propagator /// Fusion 引爆时,将 Decay 扩散到引爆范围内的其他敌人。 /// public class DecayPropagator : PassiveEquipmentBase { private const string EventKey = nameof(DecayPropagator); public override void OnObtained() { base.OnObtained(); Action onApplyBuff = OnApplyBuffToOther; player.eventSm.onApplyBuffToTarget.Add(EventKey, onApplyBuff.ToPrioritized()); } public override void OnDiscarded() { player.eventSm.onApplyBuffToTarget.Remove(EventKey); base.OnDiscarded(); } /// /// 在 Fusion 被应用到目标时,注册一个事件监听器,当 Fusion 引爆时触发 SpreadDecay 方法。 /// private void OnApplyBuffToOther(CharacterBuffBase buff) { if (buff is not Fusion fusion) return; fusion.onExploded.TryAdd(EventKey, new PrioritizedAction(SpreadDecay)); } /// /// 当 Fusion 引爆时,获取引爆范围内的所有敌人,并对它们应用 Decay 效果。 /// private void SpreadDecay(Fusion fusion, AttackAreaBase attackArea) { CharacterBase target = fusion.attachedCharacter; List affectedTargets = CombatManager.EnemySm.GetEnemiesInRadius(target.centerPosition, 10f); float decayDamage = passiveAttributeSm.GetItemAttribute("DecayDamage"); affectedTargets.ForEach(t => new Decay(decayDamage).Apply(t)); } } }