using Continentis.MainGame; using Continentis.MainGame.Character; using SLSUtilities.General; using UnityEngine; namespace Continentis.Mods.Basic.Buffs { /// /// 流血:受到攻击时,额外受到等同于层数的伤害(响应式,不会递归触发)。 /// 每次行动开始时层数减半(至少减 1)。 /// public sealed class Bleed : CharacterCombatBuffBase { public Bleed(int stack) { Initialize(BuffType.Negative, BuffDispelLevel.Basic); this.contentSubmodule = new ContentSubmodule(this) .AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString()); this.iconSubmodule = new IconSubmodule(this); this.unitedStackSubmodule = new UnitedStackSubmodule(this, stack); this.eventSubmodule = new EventSubmodule(this); this.eventSubmodule.onActionStart.Add("Bleed", new PrioritizedAction(OnActionStart)); this.eventSubmodule.onGetAttacked.Add("Bleed", new PrioritizedAction(OnGetAttacked)); } private void OnGetAttacked(AttackResult result) { // 响应式 / 生命移除 / 反弹伤害不触发流血 if (result.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval, AttackTags.Reflected)) return; int stackAmount = unitedStackSubmodule.stackAmount; var ctx = new AttackContext().WithTag(AttackTags.Reactive).WithTag(AttackTags.GuaranteedHit); attachedCharacter.Attack(attachedCharacter, stackAmount, ctx); } private void OnActionStart() { int reducedStack = Mathf.Max(1, Mathf.FloorToInt(unitedStackSubmodule.stackAmount * 0.5f)); unitedStackSubmodule.ReduceStack(reducedStack); iconSubmodule.Update(); } public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff) { MainGameManager.Instance.basePrefabs.GenerateInfoText("Bleed", attachedCharacter.characterView); if (FindExistingSameBuff(out existingBuff)) { existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount); return false; } return true; } } }