using Continentis.MainGame; using Continentis.MainGame.Character; using SLSUtilities.General; namespace Continentis.Mods.Basic.Buffs { /// /// 圣盾(骑士):免疫下一次受到的伤害(不论伤害量)。 /// 每次免疫消耗 1 层;响应式攻击和生命移除不触发免疫。 /// public class HolyShield : CharacterCombatBuffBase { public HolyShield(int stack) { Initialize(BuffType.Positive, BuffDispelLevel.Strong); this.contentSubmodule = new ContentSubmodule(this) .AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString()); this.iconSubmodule = new IconSubmodule(this).SetTextFunctions("Stack"); this.unitedStackSubmodule = new UnitedStackSubmodule(this, stack); this.eventSubmodule = new EventSubmodule(this); this.eventSubmodule.onBeforeReceiveDamage.Add("HolyShield", new PrioritizedAction(OnBeforeReceiveDamage)); } private void OnBeforeReceiveDamage(IncomingDamageModifier modifier) { if (modifier.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval)) return; if (unitedStackSubmodule.stackAmount <= 0) return; modifier.isCancelled = true; MainGameManager.Instance.basePrefabs.GenerateInfoText( contentSubmodule.displayName, attachedCharacter.characterView); unitedStackSubmodule.ReduceStack(1); iconSubmodule.Update(); } public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff) { MainGameManager.Instance.basePrefabs.GenerateInfoText( contentSubmodule.displayName, attachedCharacter.characterView); if (FindExistingSameBuff(out existingBuff)) { existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount); return false; } existingBuff = null; return true; } } }