2 using Microsoft.Xna.Framework;
6 internal sealed
class AbilityConditionAllyNearby : AbilityConditionDataless
8 private enum NearbyCharacterTruthy
14 private readonly NearbyCharacterTruthy truthyWhen;
15 private readonly
float distance;
17 public AbilityConditionAllyNearby(CharacterTalent characterTalent, ContentXElement conditionElement) : base(characterTalent, conditionElement)
19 truthyWhen = conditionElement.GetAttributeEnum(
"truthywhen", NearbyCharacterTruthy.OneCharacterMatches);
20 distance = conditionElement.GetAttributeFloat(
"distance", 10f);
23 protected override bool MatchesConditionSpecific()
25 bool trueCondition = truthyWhen
switch
27 NearbyCharacterTruthy.OneCharacterMatches =>
true,
28 NearbyCharacterTruthy.NoCharacterMatches =>
false,
29 _ =>
throw new ArgumentOutOfRangeException(nameof(truthyWhen))
32 foreach (Character ally
in Character.GetFriendlyCrew(character))
34 if (ally == character) {
continue; }
38 if (distanceToCharacter < distance * distance)
44 return !trueCondition;
virtual Vector2 WorldPosition
@ Character
Characters only