using System.Collections.Generic; using Continentis.MainGame; using Continentis.MainGame.Character; using SLSUtilities.General; using UnityEngine; namespace Continentis.Mods.Basic.Buffs { /// /// 被挑衅:标记该角色正在被一个或多个角色挑衅。 /// 具有 Provoked 状态,目标选择系统会检测该状态并限制该角色只能攻击挑衅者。 /// public class Provoked : CharacterCombatBuffBase { public List provokingSources; public Provoked() { Initialize(BuffType.Negative, BuffDispelLevel.DeathOnly, 100); this.provokingSources = new List(); this.statusSubmodule = new StatusSubmodule(this, StatusType.Provoked); this.contentSubmodule = new ContentSubmodule(this) .AddParameterGetter("Provoker", GetProvokerNames); this.iconSubmodule = new IconSubmodule(this).SetTextFunctions(); } /// 获取所有挑衅者角色(去重)。 public List GetProvokers() { List provokers = new List(); foreach (Provoking provoking in provokingSources) { if (!provokers.Contains(provoking.attachedCharacter)) { provokers.Add(provoking.attachedCharacter); } } return provokers; } public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff) { MainGameManager.Instance.basePrefabs.GenerateInfoText( contentSubmodule.displayName, attachedCharacter.characterView); if (FindExistingSameBuff(out existingBuff)) { return false; } existingBuff = null; return true; } private string GetProvokerNames() { List names = new List(); foreach (Provoking provoker in provokingSources) { names.Add(provoker.attachedCharacter.data.displayName); } return names.Count == 1 ? names[0] : string.Join(", ", names); } } }