Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public RSTile getNewPosition() {//
- RSArea areaPlayer = new RSArea(Player.getPosition(), 1);
- ArrayList<RSTile> usableTiles = new ArrayList<RSTile>();
- for (RSTile tile : areaPlayer.getAllTiles()) {
- if (!PathFinding.isTileWalkable(tile))
- continue; // The player is unable to walk here. Do not add this tile to the usable tiles
- // list.
- RSObject[] objects = Objects.getAt(tile);
- if (objects.length > 0) {
- for (int i = 0; i < objects.length; i++) {
- RSObjectDefinition def = objects[i].getDefinition();
- if (def != null) {
- String name = def.getName();
- if (name != null)
- if (!name.equals("null")) // If the object has an actual name, other than "null" (fungus,
- // flowers etc.)
- continue; // This tile is not usable. Do not add it to the usable tiles list.
- }
- }
- // Objects found on the tile, but they are named "null" and they are
- // non-interactable
- usableTiles.add(tile); // This tile is usable and can be added to the
- } else {
- // No objects found on the tile. This tile is usable and can be added to the
- // list.
- usableTiles.add(tile);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement