Client LuaCsForBarotrauma
CharacterAbilityTandemFire.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma.Abilities
4 {
6  {
7  // this should just be its own class, misleading to inherit here
8  private readonly Identifier tag;
9  public CharacterAbilityTandemFire(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
10  {
11  tag = abilityElement.GetAttributeIdentifier("tag", Identifier.Empty);
12  }
13 
14  protected override void ApplyEffect()
15  {
16  if (!SelectedItemHasTag(Character, tag)) { return; }
17 
18  Character closestCharacter = null;
19  float closestDistance = squaredMaxDistance;
20 
21  foreach (Character crewCharacter in Character.GetFriendlyCrew(Character))
22  {
23  if (crewCharacter != Character &&
24  Vector2.DistanceSquared(Character.WorldPosition, crewCharacter.WorldPosition) is float tempDistance && tempDistance < closestDistance &&
25  SelectedItemHasTag(crewCharacter, tag))
26  {
27  closestCharacter = crewCharacter;
28  closestDistance = tempDistance;
29  }
30  }
31 
32  if (closestCharacter == null) { return; }
33 
34  if (closestDistance < squaredMaxDistance)
35  {
37  ApplyEffectSpecific(closestCharacter);
38  }
39 
40  static bool SelectedItemHasTag(Character character, Identifier tag) =>
41  (character.SelectedItem != null && character.SelectedItem.HasTag(tag)) ||
42  (character.SelectedSecondaryItem != null && character.SelectedSecondaryItem.HasTag(tag));
43  }
44  }
45 }
void ApplyEffectSpecific(Character targetCharacter, Limb targetLimb=null)
CharacterAbilityTandemFire(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
static IEnumerable< Character > GetFriendlyCrew(Character character)
Item????????? SelectedItem
The primary selected item. It can be any device that character interacts with. This excludes items li...
Item SelectedSecondaryItem
The secondary selected item. It's an item other than a device (see SelectedItem), e....
Identifier GetAttributeIdentifier(string key, string def)
virtual Vector2 WorldPosition
Definition: Entity.cs:49