更新
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using System.Collections.Generic;
|
||||
using Continentis.MainGame;
|
||||
using Continentis.MainGame.Character;
|
||||
using SLSUtilities.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.Mods.Basic.Buffs
|
||||
{
|
||||
/// <summary>
|
||||
/// 挑衅:标记该角色正在挑衅某个敌方目标。
|
||||
/// 关系追踪器,不直接影响目标选择——过滤逻辑通过被挑衅者身上的 Provoked 状态实现。
|
||||
/// 持续行动次数由 roundFirstActionCountSubmodule 决定。
|
||||
/// </summary>
|
||||
public class Provoking : CharacterCombatBuffBase
|
||||
{
|
||||
public CharacterBase target;
|
||||
public Provoked provokedBuff;
|
||||
|
||||
public Provoking(CharacterBase target, int actionCount, Provoked provokedBuff)
|
||||
{
|
||||
Initialize(BuffType.Neutral, BuffDispelLevel.DeathOnly, 100);
|
||||
this.target = target;
|
||||
this.provokedBuff = provokedBuff;
|
||||
|
||||
if (this.provokedBuff == null)
|
||||
{
|
||||
Debug.LogError("Provoking buff requires a Provoked buff on the target.");
|
||||
}
|
||||
|
||||
this.contentSubmodule = new ContentSubmodule(this)
|
||||
.AddParameterGetter("Count", () => roundFirstActionCountSubmodule.remainingCount.ToString())
|
||||
.AddParameterGetter("Target", () => target.data.displayName);
|
||||
|
||||
this.iconSubmodule = new IconSubmodule(this).SetTextFunctions("Count");
|
||||
|
||||
this.roundFirstActionCountSubmodule = new CountSubmodule(this, actionCount);
|
||||
}
|
||||
|
||||
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||||
{
|
||||
MainGameManager.Instance.basePrefabs.GenerateInfoText(
|
||||
contentSubmodule.displayName, attachedCharacter.characterView);
|
||||
|
||||
// 如果已存在对同一目标的挑衅,累加持续时间
|
||||
if (FindExistingSameBuffs(out List<Provoking> existingProvokings))
|
||||
{
|
||||
var sameProvoking = existingProvokings.Find(ep => ep.target == this.target);
|
||||
if (sameProvoking != null)
|
||||
{
|
||||
existingBuff = sameProvoking;
|
||||
sameProvoking.roundFirstActionCountSubmodule.AddCount(
|
||||
this.roundFirstActionCountSubmodule.remainingCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
existingBuff = null;
|
||||
return true; // 对不同目标的挑衅可以共存
|
||||
}
|
||||
|
||||
existingBuff = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnAfterFirstApply()
|
||||
{
|
||||
base.OnAfterFirstApply();
|
||||
provokedBuff.provokingSources.Add(this);
|
||||
|
||||
// 同步到 StatusSubmodule,使核心框架可读取挑衅者列表
|
||||
if (!provokedBuff.attachedCharacter.statusSubmodule.provokers.Contains(attachedCharacter))
|
||||
{
|
||||
provokedBuff.attachedCharacter.statusSubmodule.provokers.Add(attachedCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBuffRemove()
|
||||
{
|
||||
base.OnBuffRemove();
|
||||
provokedBuff.provokingSources.Remove(this);
|
||||
|
||||
// 检查是否还有其他 Provoking 指向同一挑衅者
|
||||
bool hasOtherFromSameProvoker = provokedBuff.provokingSources.Exists(p => p.attachedCharacter == attachedCharacter);
|
||||
if (!hasOtherFromSameProvoker)
|
||||
{
|
||||
provokedBuff.attachedCharacter.statusSubmodule.provokers.Remove(attachedCharacter);
|
||||
}
|
||||
|
||||
if (provokedBuff.provokingSources.Count == 0)
|
||||
{
|
||||
provokedBuff.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user