Class OtherEntityTargetingStrategy

java.lang.Object
de.gurkenlabs.litiengine.abilities.targeting.TargetingStrategy
de.gurkenlabs.litiengine.abilities.targeting.OtherEntityTargetingStrategy
Direct Known Subclasses:
EnemyTargetingStrategy, FriendlyTargetingStrategy

public class OtherEntityTargetingStrategy extends TargetingStrategy

A targeting strategy that selects other combat entities within the ability's impact area, filtered by their relationship to the executor and their alive/dead state.

This strategy queries the current environment for combat entities intersecting the given impact area and filters them according to three configurable criteria:

  • friendly – whether to select allied entities or hostile ones,
  • includeExecutor – whether the executing entity itself may be returned,
  • includeDead – whether dead entities may be returned.

It serves as the common base for FriendlyTargetingStrategy and EnemyTargetingStrategy.

See Also:
  • Constructor Details

    • OtherEntityTargetingStrategy

      public OtherEntityTargetingStrategy(boolean multiTarget, boolean sortByDistance, boolean friendly)
      Creates a new OtherEntityTargetingStrategy that excludes both the executor and dead entities.
      Parameters:
      multiTarget - if true, the strategy may return multiple matching targets; otherwise only a single target is selected.
      sortByDistance - if true, the resulting targets are ordered by their distance to the executing entity (closest first).
      friendly - if true, only friendly entities are targeted; otherwise only hostile entities are targeted.
    • OtherEntityTargetingStrategy

      public OtherEntityTargetingStrategy(boolean multiTarget, boolean sortByDistance, boolean friendly, boolean includeExecutor, boolean includeDead)
      Creates a new OtherEntityTargetingStrategy with full control over inclusion rules.
      Parameters:
      multiTarget - if true, the strategy may return multiple matching targets; otherwise only a single target is selected.
      sortByDistance - if true, the resulting targets are ordered by their distance to the executing entity (closest first).
      friendly - if true, only friendly entities are targeted; otherwise only hostile entities are targeted.
      includeExecutor - if true, the executing entity itself may be included in the result; otherwise it is filtered out.
      includeDead - if true, dead entities are considered valid targets; otherwise only living entities are selected.
  • Method Details

    • findTargetsInternal

      protected Collection<ICombatEntity> findTargetsInternal(Shape impactArea, ICombatEntity executor)
      Finds all combat entities in the current environment that intersect the given impact area and satisfy this strategy's friendly/executor/dead filters.
      Specified by:
      findTargetsInternal in class TargetingStrategy
      Parameters:
      impactArea - the shape representing the ability's area of effect; only entities intersecting this area are considered.
      executor - the combat entity executing the ability; used as the reference for friend/foe classification and (optionally) excluded from the result.
      Returns:
      a collection of combat entities matching all configured filter criteria. May be empty if no entity qualifies.