更新
This commit is contained in:
71
Assets/Mods/Basic/Characters/CombatBuffs/General/Provoked.cs
Normal file
71
Assets/Mods/Basic/Characters/CombatBuffs/General/Provoked.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user