Package squidpony.squidai
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.
-
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
-
Field Details
-
minDistance
The minimum distance in cells that this Reach can target. Distance will be measured using themetric
field. -
maxDistance
The maximum distance in cells that this Reach can target. Distance will be measured using themetric
field. -
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
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
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
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 negativemaxDistance
- 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
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 negativemaxDistance
- 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 minDistancemetric
- a Radius enum that determines how distance will be calculated
-
Reach
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 negativemaxDistance
- 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 minDistancemetric
- a Radius enum that determines how distance will be calculatedlimit
- an AimLimit enum that can be used to limit targeting to specific angles, or not at all (if null or equal to AimLimit.FREE)
-