Class Area

java.lang.Object
net.botwithus.rs3.game.Area
All Implemented Interfaces:
Locatable
Direct Known Subclasses:
Area.Circular, Area.Polygonal, Area.Rectangular, Area.Singular

public abstract sealed class Area extends Object implements Locatable permits Area.Singular, Area.Rectangular, Area.Circular, Area.Polygonal
An Area represents a group of Coordinates in the world graph.
  • Constructor Details

    • Area

      public Area()
  • Method Details

    • getArea

      @NonNull public @NonNull Area getArea()
      Description copied from interface: Locatable
      Gets the area that the entity occupies on the world graph
      Specified by:
      getArea in interface Locatable
      Returns:
      The area of the entity, or null if it cannot be determined or is no longer on the world graph.
    • getOverlap

      public final Set<Coordinate> getOverlap(Area area)
    • getOverlap

      @NonNull public @NonNull Set<Coordinate> getOverlap(Area area, boolean ignorePlane)
      Gets a set of the overlapping coordinates between this area and the provided area.
      Parameters:
      area - The area to compare with for overlap. If it's null or it has no coordinates, an empty set is returned.
      ignorePlane - If true, only X and Y coordinates are considered for overlap. If false, the Z (plane) coordinate is also considered.
      Returns:
      A set of overlapping coordinates. If there are no overlapping coordinates, an empty set is returned.
    • overlaps

      public final boolean overlaps(Locatable locatable)
    • overlaps

      public boolean overlaps(Area area, boolean ignorePlane)
    • toSingular

      @Nullable public Area.Singular toSingular()
      Gets this area as an Area.Singular which is comprised of a single Coordinate
      Returns:
      This area as an Area.Singular if it has a single Coordinate, otherwise null.
    • getRandomCoordinate

      @Nullable public @Nullable Coordinate getRandomCoordinate()
    • getRandomWalkableCoordinate

      public Coordinate getRandomWalkableCoordinate()
    • getWalkableCoordinates

      public List<Coordinate> getWalkableCoordinates()
    • getCoordinatesInArea

      public List<Coordinate> getCoordinatesInArea(Coordinate checkCoords)
    • toRectangular

      @NonNull public abstract Area.Rectangular toRectangular()
    • toPolygonal

      @NonNull public abstract Area.Polygonal toPolygonal()
    • toCircular

      @NonNull public abstract Area.Circular toCircular()
    • contains

      public abstract boolean contains(Locatable locatable)
    • getCoordinates

      @NonNull public abstract @NonNull List<Coordinate> getCoordinates()
    • getCentroid

      @Nullable public @Nullable Coordinate getCentroid()
      This method calculates and returns the centroid of a set of coordinates. The centroid is the arithmetic mean position of all the points in the shape. The method first checks if the list of coordinates is empty. If it is, it returns null. If the list is not empty, it calculates the total sum of x, y, and z coordinates separately. After that, it calculates the average of x, y, and z by dividing the total sum by the number of coordinates. The method then returns a new Coordinate object with the average x, y, and z values.
      Returns:
      The centroid of the set of coordinates as a Coordinate object. If the list of coordinates is empty, returns null.