Files
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

75 lines
2.7 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.
using System.Collections.Generic;
using Continentis.MainGame;
using Continentis.MainGame.Character;
using Continentis.MainGame.Combat;
using SLSUtilities.General;
using UnityEngine;
namespace Continentis.Mods.Basic.Buffs
{
/// <summary>
/// 感电Storm 元素):承载者每次被攻击时,
/// 对随机 1 个其他敌方目标造成等同于层数的雷电伤害,然后层数 -1。
/// 对单敌战斗退化(无其他目标时无效)。
/// 过滤 Reactive/HpRemoval/Reflected 防递归。
/// </summary>
public sealed class Shocked : CharacterCombatBuffBase
{
public Shocked(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.onGetAttacked.Add("Shocked", new PrioritizedAction<AttackResult>(OnGetAttacked));
}
private void OnGetAttacked(AttackResult result)
{
// 响应式 / 生命移除 / 反弹伤害不触发感电
if (result.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval, AttackTags.Reflected))
return;
// 收集除自身以外的其他同阵营敌方角色
List<CharacterBase> others = CombatMainManager.Instance.characterController
.GetAllEnemies(attachedCharacter);
others.Remove(attachedCharacter);
if (others.Count == 0) return;
CharacterBase spreadTarget = others[Random.Range(0, others.Count)];
int damage = unitedStackSubmodule.stackAmount;
var ctx = new AttackContext()
.WithTag(AttackTags.Reactive)
.WithTag(AttackTags.GuaranteedHit)
.WithDamageKeywords("Storm");
sourceCharacter.Attack(spreadTarget, damage, ctx);
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;
}
return true;
}
}
}