Client LuaCsForBarotrauma
CharacterAbilityGainSimultaneousSkill.cs
1 namespace Barotrauma.Abilities
2 {
4  {
5  private readonly Identifier skillIdentifier;
6 
7  private readonly bool ignoreAbilitySkillGain,
8  targetAllies;
9 
10  public CharacterAbilityGainSimultaneousSkill(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
11  {
12  skillIdentifier = abilityElement.GetAttributeIdentifier("skillidentifier", "");
13  ignoreAbilitySkillGain = abilityElement.GetAttributeBool("ignoreabilityskillgain", true);
14  targetAllies = abilityElement.GetAttributeBool("targetallies", false);
15  if (skillIdentifier.IsEmpty)
16  {
17  DebugConsole.ThrowError($"Error in talent {CharacterTalent.DebugIdentifier}: skill identifier not defined.",
18  contentPackage: abilityElement.ContentPackage);
19  }
20  }
21 
22  protected override void ApplyEffect(AbilityObject abilityObject)
23  {
24  if (abilityObject is AbilitySkillGain abilitySkillGain)
25  {
26  if (ignoreAbilitySkillGain && abilitySkillGain.GainedFromAbility) { return; }
27  Identifier identifier = skillIdentifier == "inherit" ? abilitySkillGain.SkillIdentifier : skillIdentifier;
28  if (targetAllies)
29  {
30  foreach (Character otherCharacter in Character.GetFriendlyCrew(Character))
31  {
32  if (otherCharacter == Character) { continue; }
33  otherCharacter.Info?.IncreaseSkillLevel(identifier, abilitySkillGain.Value, gainedFromAbility: true);
34  }
35  }
36  else
37  {
38  Character.Info?.IncreaseSkillLevel(identifier, abilitySkillGain.Value, gainedFromAbility: true);
39  }
40  }
41  else
42  {
44  }
45  }
46  }
47 }
CharacterAbilityGainSimultaneousSkill(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
static IEnumerable< Character > GetFriendlyCrew(Character character)
void IncreaseSkillLevel(Identifier skillIdentifier, float increase, bool gainedFromAbility=false, bool forceNotification=false)
Increase the skill by a specific amount. Talents may affect the actual, final skill increase.
ContentPackage? ContentPackage
bool GetAttributeBool(string key, bool def)
Identifier GetAttributeIdentifier(string key, string def)