import org.osbot.script.rs2.map.Position;
import org.osbot.script.rs2.model.Entity;
import java.awt.*;
/**
* Created with IntelliJ IDEA
* User: Anthony
* Date: 3/23/2014
*/
@SuppressWarnings("serial")
public class PolygonArea extends Polygon {
public PolygonArea(Position... positions) {
super(retrieveXPoints(positions), retrieveYPoints(positions), positions.length);
}
public boolean contains(Entity entity) {
return contains(entity.getX(), entity.getY());
}
public boolean contains(Position position) {
return contains(position.getX(), position.getY());
}
private static final int[] retrieveXPoints(Position[] positions) {
int[] xPoints = new int[positions.length];
for (int i = 0; i < positions.length; i++)
xPoints[i] = positions[i].getX();
return xPoints;
}
private static final int[] retrieveYPoints(Position[] positions) {
int[] yPoints = new int[positions.length];
for (int i = 0; i < positions.length; i++)
yPoints[i] = positions[i].getY();
return yPoints;
}
}
No idea why you extend polygon then use a local variable polygon. Also no idea why the hell my indents were removed when I pasted this here...