Files

55 lines
1.6 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.
namespace BaseGames.Combat.StatusEffects
{
/// <summary>
/// 中毒效果(架构 06_CombatModule §11
/// 规则:最多叠加 3 层;每层叠加伤害 +1每 1 秒造成 StackCount 点 True 伤害。
/// </summary>
public class PoisonEffect : StatusEffect
{
private const float BaseDuration = 5.0f; // 持续 5 秒
private const float DotInterval = 1.0f; // 每 1 秒一次
public override StatusEffectType EffectType => StatusEffectType.Poison;
public override int MaxStacks => 3;
public PoisonEffect()
{
TickInterval = DotInterval;
}
public override void OnApply(StatusEffectManager owner)
{
base.OnApply(owner);
UpdateShader();
}
public override void OnStack()
{
base.OnStack();
UpdateShader();
}
public override void OnTick()
{
var info = new DamageInfo.Builder()
.SetRaw(StackCount) // 叠层越多伤害越高
.SetType(DamageType.True)
.SetFlags(DamageFlags.IgnoreIFrame)
.Build();
Owner?.ApplyDirectDamage(info);
}
public override void OnExpire()
{
StackCount = 0;
Owner?.SetShaderParam("_PoisonGlow", 0f);
}
private void UpdateShader()
=> Owner?.SetShaderParam("_PoisonGlow", StackCount / (float)MaxStacks);
protected override float GetBaseDuration() => BaseDuration;
public override string GetDisplayName() => $"中毒 ×{StackCount}";
}
}