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