Files
Continentis/Assets/Mods/Basic/Characters/CombatBuffs/General/CounterAttack.cs
2025-11-12 23:44:20 -06:00

38 lines
1.4 KiB
C#

using Continentis.MainGame;
using Continentis.MainGame.Character;
using SLSFramework.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 =>
{
attachedCharacter.Attack(atkResult.attacker, unitedStackSubmodule.stackAmount, 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;
}
}
}