44 lines
1.7 KiB
C#
44 lines
1.7 KiB
C#
using Continentis.MainGame;
|
||
using Continentis.MainGame.Character;
|
||
using SLSUtilities.General;
|
||
using UnityEngine;
|
||
|
||
namespace Continentis.Mods.Basic.Buffs
|
||
{
|
||
public class CounterAttack : CharacterCombatBuffBase
|
||
{
|
||
public CounterAttack(int stack)
|
||
{
|
||
Initialize(BuffType.Positive, BuffDispelLevel.Strong);
|
||
|
||
this.contentSubmodule = new ContentSubmodule(this)
|
||
.AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString());
|
||
|
||
this.iconSubmodule = new IconSubmodule(this);
|
||
this.unitedStackSubmodule = new UnitedStackSubmodule(this, true, -1, stack, true);
|
||
this.eventSubmodule = new EventSubmodule(this);
|
||
this.eventSubmodule.onGetAttacked.Add(this.GetType().FullName, new PrioritizedAction<AttackResult>(atkResult =>
|
||
{
|
||
// 将反击入队到 Reaction Lane,确保反击动画/特效与主流程不穿插
|
||
int counterDamage = unitedStackSubmodule.stackAmount;
|
||
CharacterBase attacker = atkResult.attacker;
|
||
EnqueueReaction(Cmd.Do(() =>
|
||
{
|
||
attachedCharacter.Attack(attacker, counterDamage, null, false, true);
|
||
}));
|
||
}));
|
||
}
|
||
|
||
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||
{
|
||
MainGameManager.Instance.basePrefabs.GenerateInfoText("Counter Attack", attachedCharacter.characterView);
|
||
if (FindExistingSameBuff(out existingBuff))
|
||
{
|
||
existingBuff.unitedStackSubmodule.ModifyStack(this.unitedStackSubmodule.stackAmount);
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
}
|
||
}
|