Class AITargetSelection
Target-picking strategies shared by the attacking states and the behaviour tree.
public static class AITargetSelection
- Inheritance
-
AITargetSelection
- Inherited Members
Remarks
Kept separate from AggressionController because these modes deliberately ignore the threat table — a rampaging beast or a critter that just bites whatever is nearest has no interest in who has done the most damage to it.
Methods
GetHealthPercent(ICharacter)
Returns a character's health as a fraction (0-1) of its maximum, or 1 when unknown.
public static float GetHealthPercent(ICharacter character)
Parameters
characterICharacterThe character to measure.
Returns
- float
The health fraction.
IsValidTarget(ICharacter)
Returns true when a candidate is a legal target: present, active, and alive.
public static bool IsValidTarget(ICharacter candidate)
Parameters
candidateICharacterThe candidate to test.
Returns
- bool
True if the candidate can be attacked.
PickNearest(List<ICharacter>, Vector3)
Picks the living candidate physically closest to a position.
public static ICharacter PickNearest(List<ICharacter> candidates, Vector3 origin)
Parameters
candidatesList<ICharacter>Candidates to choose from.
originVector3The position to measure from.
Returns
- ICharacter
The nearest valid candidate, or null when none are valid.
PickRandom(List<ICharacter>, DeterministicRNG)
Picks a uniformly random living candidate using the NPC's seeded RNG.
public static ICharacter PickRandom(List<ICharacter> candidates, DeterministicRNG rng)
Parameters
candidatesList<ICharacter>Candidates to choose from.
rngDeterministicRNGThe NPC's deterministic RNG. Falls back to the shared RNG when null.
Returns
- ICharacter
A random valid candidate, or null when none are valid.
PickWeakest(List<ICharacter>)
Picks the living candidate with the lowest health fraction.
public static ICharacter PickWeakest(List<ICharacter> candidates)
Parameters
candidatesList<ICharacter>Candidates to choose from.
Returns
- ICharacter
The most wounded valid candidate, or null when none are valid.