Client LuaCsForBarotrauma
AbilityConditionIsAiming.cs
2 using System.Xml.Linq;
3 
4 namespace Barotrauma.Abilities
5 {
7  {
8  private enum WeaponType
9  {
10  Any = 0,
11  Melee = 1,
12  Ranged = 2
13  };
14 
15  private readonly bool hittingCountsAsAiming;
16 
17  private readonly WeaponType weapontype;
18  public AbilityConditionIsAiming(CharacterTalent characterTalent, ContentXElement conditionElement) : base(characterTalent, conditionElement)
19  {
20  hittingCountsAsAiming = conditionElement.GetAttributeBool("hittingcountsasaiming", false);
21  switch (conditionElement.GetAttributeString("weapontype", ""))
22  {
23  case "melee":
24  weapontype = WeaponType.Melee;
25  break;
26  case "ranged":
27  weapontype = WeaponType.Ranged;
28  break;
29  }
30  }
31 
32  protected override bool MatchesConditionSpecific()
33  {
34  if (character.AnimController is HumanoidAnimController animController)
35  {
36  foreach (Item item in character.HeldItems)
37  {
38  switch (weapontype)
39  {
40  case WeaponType.Melee:
41  var meleeWeapon = item.GetComponent<MeleeWeapon>();
42  if (meleeWeapon != null)
43  {
44  if (animController.IsAimingMelee || (meleeWeapon.Hitting && hittingCountsAsAiming)) { return true; }
45  }
46  break;
47  case WeaponType.Ranged:
48  if (animController.IsAiming && item.GetComponent<RangedWeapon>() != null) { return true; }
49  break;
50  default:
51  if (animController.IsAiming || animController.IsAimingMelee) { return true; }
52  break;
53  }
54  }
55  }
56 
57  return false;
58  }
59  }
60 }
AbilityConditionIsAiming(CharacterTalent characterTalent, ContentXElement conditionElement)
IEnumerable< Item >?? HeldItems
Items the character has in their hand slots. Doesn't return nulls and only returns items held in both...
string? GetAttributeString(string key, string? def)
bool GetAttributeBool(string key, bool def)