Class CustomTargetingStrategy
java.lang.Object
de.gurkenlabs.litiengine.abilities.targeting.TargetingStrategy
de.gurkenlabs.litiengine.abilities.targeting.CustomTargetingStrategy
A custom targeting strategy that allows defining a specific condition for selecting targets.
This strategy uses a BiPredicate to determine whether a combat entity
should be targeted based on the executor and the potential target. It supports multi-targeting and sorting by distance.
-
Constructor Summary
ConstructorsConstructorDescriptionCustomTargetingStrategy(BiPredicate<ICombatEntity, ICombatEntity> customPredicate, boolean multiTarget, boolean sortByDistance) Creates a newCustomTargetingStrategywith the specified targeting condition. -
Method Summary
Modifier and TypeMethodDescriptionfindTargetsInternal(Shape impactArea, ICombatEntity executor) Finds the targets within the specified impact area based on the targeting condition.Methods inherited from class TargetingStrategy
custom, enemies, executingEntity, findTargets, fixed, friendly, friendlyDead, isMultiTarget, none, prioritizeByDistance, setCustomTargetPriorityComparator, setMultiTarget, setPrioritizeByDistance, withCondition
-
Constructor Details
-
CustomTargetingStrategy
public CustomTargetingStrategy(BiPredicate<ICombatEntity, ICombatEntity> customPredicate, boolean multiTarget, boolean sortByDistance) Creates a newCustomTargetingStrategywith the specified targeting condition.- Parameters:
customPredicate- The condition to determine valid targets. It takes the executor and a potential target as arguments and returnstrueif the target is valid.multiTarget- Whether the strategy supports targeting multiple entities.sortByDistance- Whether the targets should be sorted by their distance to the executor.
-
-
Method Details
-
findTargetsInternal
Finds the targets within the specified impact area based on the targeting condition.
If the targeting condition or the game environment is not available, this method returns an empty collection.
- Specified by:
findTargetsInternalin classTargetingStrategy- Parameters:
impactArea- The area in which to search for targets.executor- The combat entity executing the ability.- Returns:
- A collection of combat entities that match the targeting condition.
-