2025-10-23 00:49:44 -04:00
|
|
|
|
using Continentis.MainGame;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
2026-04-17 12:01:50 -04:00
|
|
|
|
using SLSUtilities.General;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.Mods.Basic.Buffs
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 流血:受到攻击时,额外受到等同于层数的伤害(响应式,不会递归触发)。
|
|
|
|
|
|
/// 每次行动开始时层数减半(至少减 1)。
|
|
|
|
|
|
/// </summary>
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public sealed class Bleed : CharacterCombatBuffBase
|
2025-10-23 00:49:44 -04:00
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public Bleed(int stack)
|
2025-10-23 00:49:44 -04:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
2025-10-31 10:02:30 -04:00
|
|
|
|
this.eventSubmodule.onActionStart.Add("Bleed", new PrioritizedAction(OnActionStart));
|
|
|
|
|
|
this.eventSubmodule.onGetAttacked.Add("Bleed", new PrioritizedAction<AttackResult>(OnGetAttacked));
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnGetAttacked(AttackResult result)
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
// 响应式 / 生命移除 / 反弹伤害不触发流血
|
|
|
|
|
|
if (result.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval, AttackTags.Reflected))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
int stackAmount = unitedStackSubmodule.stackAmount;
|
2026-04-08 04:48:35 -04:00
|
|
|
|
var ctx = new AttackContext().WithTag(AttackTags.Reactive).WithTag(AttackTags.GuaranteedHit);
|
|
|
|
|
|
attachedCharacter.Attack(attachedCharacter, stackAmount, ctx);
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnActionStart()
|
|
|
|
|
|
{
|
|
|
|
|
|
int reducedStack = Mathf.Max(1, Mathf.FloorToInt(unitedStackSubmodule.stackAmount * 0.5f));
|
|
|
|
|
|
unitedStackSubmodule.ReduceStack(reducedStack);
|
|
|
|
|
|
iconSubmodule.Update();
|
|
|
|
|
|
}
|
2025-11-12 01:20:19 -06:00
|
|
|
|
|
|
|
|
|
|
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
MainGameManager.Instance.basePrefabs.GenerateInfoText("Bleed", attachedCharacter.characterView);
|
|
|
|
|
|
|
|
|
|
|
|
if (FindExistingSameBuff(out existingBuff))
|
|
|
|
|
|
{
|
|
|
|
|
|
existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-12 01:20:19 -06:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|