Class Reach

java.lang.Object
squidpony.squidai.Reach
All Implemented Interfaces:
Serializable

public class Reach
extends Object
implements Serializable
A struct-like class that holds information about targeting rules for actions or other effects that reach from one square into another one, with certain potential restrictions.
See Also:
AreaUtils and its verifyReach method may be useful with this Created by Tommy Ettinger on 12/17/2015., Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    AimLimit limit
    An AimLimit enum that may be used to determine limitations to targeting cells; defaults to FREE (no limits other than those from distance), but can also be set to ORTHOGONAL (rook move in chess), DIAGONAL (bishop move in chess), EIGHT_WAY (queen or king move in chess), or null (which usually)
    int maxDistance
    The maximum distance in cells that this Reach can target.
    Radius metric
    Determines how distance will be measured.
    int minDistance
    The minimum distance in cells that this Reach can target.
  • Constructor Summary

    Constructors 
    Constructor Description
    Reach()
    Constructs a Reach with all fields given default values; maxDistance is set to 1, minDistance is set to 0, limit is set to AimLimit.FREE, and metric is set to Radius.SQUARE (8-way movement).
    Reach​(int maxDistance)
    Constructs a Reach with the specified maxDistance, to a minimum of 0.
    Reach​(int minDistance, int maxDistance)
    Constructs a Reach with the specified minDistance, to a minimum of 0, and maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0).
    Reach​(int minDistance, int maxDistance, Radius metric)
    Constructs a Reach with the specified minDistance, to a minimum of 0, maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0), and distance calculation metric as a Radius enum.
    Reach​(int minDistance, int maxDistance, Radius metric, AimLimit limit)
    Constructs a Reach with the specified minDistance, to a minimum of 0, maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0), and distance calculation metric as a Radius enum.
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • minDistance

      public int minDistance
      The minimum distance in cells that this Reach can target. Distance will be measured using the metric field.
    • maxDistance

      public int maxDistance
      The maximum distance in cells that this Reach can target. Distance will be measured using the metric field.
    • limit

      public AimLimit limit
      An AimLimit enum that may be used to determine limitations to targeting cells; defaults to FREE (no limits other than those from distance), but can also be set to ORTHOGONAL (rook move in chess), DIAGONAL (bishop move in chess), EIGHT_WAY (queen or king move in chess), or null (which usually)
    • metric

      public Radius metric
      Determines how distance will be measured. SQUARE or CUBE correspond to 8-way or Chebyshev movement, DIAMOND or OCTAHEDRON correspond to 4-way or Manhattan movement, and CIRCLE or SPHERE correspond to Euclidean movement.
  • Constructor Details

    • Reach

      public Reach()
      Constructs a Reach with all fields given default values; maxDistance is set to 1, minDistance is set to 0, limit is set to AimLimit.FREE, and metric is set to Radius.SQUARE (8-way movement).
    • Reach

      public Reach​(int maxDistance)
      Constructs a Reach with the specified maxDistance, to a minimum of 0. Other fields are given default values; minDistance is set to 0, limit is set to AimLimit.FREE, and metric is set to Radius.SQUARE (8-way movement).
      Parameters:
      maxDistance - the longest distance in cells this Reach can target; will be set to 0 if negative
    • Reach

      public Reach​(int minDistance, int maxDistance)
      Constructs a Reach with the specified minDistance, to a minimum of 0, and maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0). Other fields are given default values; limit is set to AimLimit.FREE, and metric is set to Radius.SQUARE (8-way movement).
      Parameters:
      minDistance - the shortest distance in cells this Reach can target; will be set to 0 if negative
      maxDistance - the longest distance in cells this Reach can target; will be set to the final value of minDistance if it is lower than the calculated minDistance
    • Reach

      public Reach​(int minDistance, int maxDistance, Radius metric)
      Constructs a Reach with the specified minDistance, to a minimum of 0, maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0), and distance calculation metric as a Radius enum. Other than that, limit is set to AimLimit.FREE.
      Parameters:
      minDistance - the shortest distance in cells this Reach can target; will be set to 0 if negative
      maxDistance - the longest distance in cells this Reach can target; will be set to the final value of minDistance if it is lower than the calculated minDistance
      metric - a Radius enum that determines how distance will be calculated
    • Reach

      public Reach​(int minDistance, int maxDistance, Radius metric, AimLimit limit)
      Constructs a Reach with the specified minDistance, to a minimum of 0, maxDistance, to a minimum equal to minDistance (after factoring in any change to meet the minimum of 0), and distance calculation metric as a Radius enum. Other than that, limit is set to AimLimit.FREE.
      Parameters:
      minDistance - the shortest distance in cells this Reach can target; will be set to 0 if negative
      maxDistance - the longest distance in cells this Reach can target; will be set to the final value of minDistance if it is lower than the calculated minDistance
      metric - a Radius enum that determines how distance will be calculated
      limit - an AimLimit enum that can be used to limit targeting to specific angles, or not at all (if null or equal to AimLimit.FREE)