Class CustomTargetingStrategy

java.lang.Object
de.gurkenlabs.litiengine.abilities.targeting.TargetingStrategy
de.gurkenlabs.litiengine.abilities.targeting.CustomTargetingStrategy

public class CustomTargetingStrategy extends TargetingStrategy

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 Details

    • CustomTargetingStrategy

      public CustomTargetingStrategy(BiPredicate<ICombatEntity, ICombatEntity> customPredicate, boolean multiTarget, boolean sortByDistance)
      Creates a new CustomTargetingStrategy with the specified targeting condition.
      Parameters:
      customPredicate - The condition to determine valid targets. It takes the executor and a potential target as arguments and returns true if 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

      public Collection<ICombatEntity> findTargetsInternal(Shape impactArea, ICombatEntity executor)

      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:
      findTargetsInternal in class TargetingStrategy
      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.