Files
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

59 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Continentis.MainGame;
using Continentis.MainGame.Character;
using SLSUtilities.General;
namespace Continentis.Mods.Basic.Buffs
{
/// <summary>
/// 筑城FortificationBuff
/// 每回合首次行动开始时,获得等同于 Firm Buff Stack层数 * Fortification Buff Stack层数的格挡。
/// 前后施加层数会合并叠加。
/// </summary>
public class Fortification : CharacterCombatBuffBase
{
public Fortification(int stack)
{
Initialize(BuffType.Positive, BuffDispelLevel.Strong);
this.contentSubmodule = new ContentSubmodule(this)
.AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString());
this.iconSubmodule = new IconSubmodule(this);
// 无限持续时间 (-1),支持层数叠加
this.unitedStackSubmodule = new UnitedStackSubmodule(this, true, -1, stack, false);
this.eventSubmodule = new EventSubmodule(this);
this.eventSubmodule.onActionStart.InsertByPriority("Fortification_Block", new PrioritizedAction(() =>
{
if (attachedCharacter.actionCountThisRound == 0) // 每个回合首次行动开始时
{
if (attachedCharacter.combatBuffSubmodule.TryGetBuff<Firm>(out var firmBuff))
{
int firmStack = firmBuff.unitedStackSubmodule.stackAmount;
if (firmStack > 0)
{
int blockGain = firmStack * this.unitedStackSubmodule.stackAmount;
attachedCharacter.AddBlock(blockGain);
}
}
}
}));
}
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
{
MainGameManager.Instance.basePrefabs.GenerateInfoText("Fortification", attachedCharacter.characterView);
if (FindExistingSameBuff(out existingBuff))
{
// 新的层数直接叠加到原有的Buff上
existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount);
return false;
}
return true;
}
}
}