72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame;
|
|
using Continentis.MainGame.Character;
|
|
using SLSUtilities.General;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.Mods.Basic.Buffs
|
|
{
|
|
/// <summary>
|
|
/// 被挑衅:标记该角色正在被一个或多个角色挑衅。
|
|
/// 具有 Provoked 状态,目标选择系统会检测该状态并限制该角色只能攻击挑衅者。
|
|
/// </summary>
|
|
public class Provoked : CharacterCombatBuffBase
|
|
{
|
|
public List<Provoking> provokingSources;
|
|
|
|
public Provoked()
|
|
{
|
|
Initialize(BuffType.Negative, BuffDispelLevel.DeathOnly, 100);
|
|
|
|
this.provokingSources = new List<Provoking>();
|
|
|
|
this.statusSubmodule = new StatusSubmodule(this, StatusType.Provoked);
|
|
|
|
this.contentSubmodule = new ContentSubmodule(this)
|
|
.AddParameterGetter("Provoker", GetProvokerNames);
|
|
|
|
this.iconSubmodule = new IconSubmodule(this).SetTextFunctions();
|
|
}
|
|
|
|
/// <summary>获取所有挑衅者角色(去重)。</summary>
|
|
public List<CharacterBase> GetProvokers()
|
|
{
|
|
List<CharacterBase> provokers = new List<CharacterBase>();
|
|
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<string> names = new List<string>();
|
|
foreach (Provoking provoker in provokingSources)
|
|
{
|
|
names.Add(provoker.attachedCharacter.data.displayName);
|
|
}
|
|
|
|
return names.Count == 1 ? names[0] : string.Join(", ", names);
|
|
}
|
|
}
|
|
}
|