File-By-File
Zone

Zone

The Zone class acts as a wrapper for a Shape, providing additional utilities and simplifying the use of generics associated with the Shape class. Zones enable your robot to perform specific actions or behave in certain ways when its position meets predefined requirements. Each zone is based on a single parent shape.

Zone Behavior

You can customize a zone's behavior by overloading the following methods:

  • onEnter(Voyager): Executed once when the robot enters the zone. It will not be executed again until the robot leaves and re-enters the zone.
  • onExit(Voyager): Executed when the robot exits the zone.
  • whileInside(Voyager): Executed every time Pathfinder's tick() method is called while the robot is inside the zone.

Constructors

  • Zone(Shape<?> shape, Runnable onEnter, Runnable onExit, Runnable whileInside): Creates a Zone based on a Shape, with specified Runnable actions for entering, exiting, and being inside the zone.
  • Zone(Shape<?> shape): Creates a Zone based on a Shape without any predefined actions for entering, exiting, or being inside the zone.

Static Methods

  • inflate(Zone zone, double inflationRadius): Creates a new Zone by expanding the given zone's shape by a specified inflationRadius. The new zone inherits the onEnter, onExit, and whileInside behaviors of the original zone.
  • inflate(List<Zone> zones, double inflationRadius): Inflates a list of zones by a specified inflationRadius, returning a new list of inflated zones.

Instance Methods

  • getShape(): Returns the underlying Shape of the zone.
  • isPointInShape(PointXY point): Checks if a given PointXY is contained within the zone's parent shape.
  • isPointOutsideOfShape(PointXY point): Checks if a given PointXY is not contained within the zone's parent shape.
  • doesCollideWith(Zone zone): Checks if this zone collides with another Zone.
  • doesCollideWith(Shape<?> shape): Checks if this zone collides with a given Shape.
  • onEnter(Voyager voyager): Executes the onEnter action defined for this zone.
  • onExit(Voyager voyager): Executes the onExit action defined for this zone.
  • whileInside(Voyager voyager): Executes the whileInside action defined for this zone.
  • isSolid(): Indicates whether the zone is considered "solid." Currently, this always returns true but is intended for future implementation.