59 lines
2.3 KiB
C#
59 lines
2.3 KiB
C#
using Continentis.MainGame;
|
||
using Continentis.MainGame.Character;
|
||
using SLSUtilities.General;
|
||
|
||
namespace Continentis.Mods.Basic.Buffs
|
||
{
|
||
/// <summary>
|
||
/// 筑城(Fortification)Buff:
|
||
/// 每回合首次行动开始时,获得等同于 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;
|
||
}
|
||
}
|
||
}
|