Ayylmao420 Posted January 20, 2017 Share Posted January 20, 2017 How am i supposed to check if currently loaded region contains position ? Quote Link to comment Share on other sites More sharing options...
Hayase Posted January 20, 2017 Share Posted January 20, 2017 (edited) Untested but it seems like it could work /** * * @param position to check if it is within the region * @param player the current position of the player (myPosition()) * @return true if the position is within the region with respect to our players position */ public boolean isReachable(Position position, Position player) { int HOW_BIG_IS_REGION = 20;//idk how big a region is Position insidePos = new Position(position); int distance = insidePos.distance(player); //If the distance from the region is less than our current position, it is reachable return distance < HOW_BIG_IS_REGION; } Just noticed there's already a function for this: map.canReach(position); Edited January 20, 2017 by Hayase Quote Link to comment Share on other sites More sharing options...
FrostBug Posted January 20, 2017 Share Posted January 20, 2017 (edited) not sure why you want to do it but something like this is probably the most efficient, performance-wise private boolean isLoaded(Position pos) { return pos.getX() > getMap().getBaseX() && pos.getX() < (getMap().getBaseX() + 104) && pos.getY() > getMap().getBaseY() && pos.getY() < getMap().getBaseY() + 104; } Regions are 104x104 EDIT: Didn't test above method, btw Edited January 20, 2017 by FrostBug 2 Quote Link to comment Share on other sites More sharing options...
Ayylmao420 Posted January 20, 2017 Author Share Posted January 20, 2017 (edited) not sure why you want to do it but something like this is probably the most efficient, performance-wise private boolean isLoaded(Position pos) { return pos.getX() > getMap().getBaseX() && pos.getX() < (getMap().getBaseX() + 104) && pos.getY() > getMap().getBaseY() && pos.getY() < getMap().getBaseY() + 104; } Regions are 104x104 EDIT: Didn't test above method, btw Should works, thanks EDIT; For custom walker. Edited January 20, 2017 by Ayylmao420 Quote Link to comment Share on other sites More sharing options...