3 using System.Collections.Immutable;
4 using Microsoft.Xna.Framework;
8 internal sealed
class AbilityConditionNearbyCharacterCount : AbilityConditionDataless
10 private readonly
float distance;
11 private readonly
int count;
12 private readonly ImmutableHashSet<TargetType> targetTypes;
14 public AbilityConditionNearbyCharacterCount(CharacterTalent characterTalent, ContentXElement conditionElement) : base(characterTalent, conditionElement)
16 distance = conditionElement.GetAttributeFloat(
"distance", 10f);
17 count = conditionElement.GetAttributeInt(
"count", 1);
18 targetTypes = ParseTargetTypes(conditionElement.GetAttributeStringArray(
"targettypes", Array.Empty<
string>(), convertToLowerInvariant:
true)).ToImmutableHashSet();
21 protected override bool MatchesConditionSpecific()
23 int amountNeeded = count;
24 foreach (Character otherCharacter
in Character.CharacterList)
26 if (character.Submarine != otherCharacter.Submarine) {
continue; }
27 if (!IsViableTarget(targetTypes, otherCharacter)) {
continue; }
29 if (Vector2.DistanceSquared(character.WorldPosition, otherCharacter.WorldPosition) < distance * distance)
33 if (amountNeeded <= 0) {
return true; }
@ Character
Characters only