1package com.runehive.game.world.pathfinding;
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.Direction;
5import com.runehive.game.world.object.GameObject;
6import com.runehive.game.world.object.GameObjectDefinition;
7import com.runehive.game.world.object.ObjectDirection;
8import com.runehive.game.world.object.ObjectType;
9import com.runehive.game.world.position.Position;
10import com.runehive.game.world.region.Region;
11import com.runehive.util.RandomUtils;
13import java.util.LinkedList;
16import static com.runehive.game.world.object.ObjectType.*;
51 sizeX = def.getLength();
52 sizeY = def.getWidth();
54 sizeX = def.getWidth();
55 sizeY = def.getLength();
58 if (
object.getObjectType() == GROUND_PROP) {
59 if (def.hasActions() || def.isDecoration()) {
60 if (def.hasActions()) {
64 }
else if (
object.getObjectType() == GENERAL_PROP ||
object.getObjectType() == WALKABLE_PROP) {
66 }
else if (
object.getObjectType().getId() >= 12) {
68 }
else if (
object.getObjectType() == DIAGONAL_WALL) {
70 }
else if (
object.getObjectType().getId() >= 0 &&
object.getObjectType().getId() <= 3) {
78 if (list && (
object.getId() == 11700 ||
object.getDefinition().hasActions())) {
79 if (add)
region.addObject(
object);
80 else region.removeObject(
object);
174 case DIAGONAL_CORNER_WALL:
304 case DIAGONAL_CORNER_WALL:
368 public static void markOccupant(
Region region,
int height,
int x,
int y,
int width,
int length,
boolean impenetrable,
boolean add) {
373 for (
int xPos = x; xPos < x + width; xPos++) {
374 for (
int yPos = y; yPos < y + length; yPos++) {
375 if (add)
set(
region, height, xPos, yPos, flag);
403 for (
int offsetX = 0; offsetX < size; offsetX++) {
404 for (
int offsetY = 0; offsetY < size; offsetY++) {
454 for (
int offsetX = 0; offsetX < size; offsetX++) {
455 for (
int offsetY = 0; offsetY < size; offsetY++) {
505 for (
int offsetX = 0; offsetX < size; offsetX++) {
506 for (
int offsetY = 0; offsetY < size; offsetY++) {
556 for (
int width = 0; width < size; width++) {
557 for (
int length = 0; length < size; length++) {
607 for (
int offsetX = 0; offsetX < size; offsetX++) {
608 for (
int offsetY = 0; offsetY < size; offsetY++) {
658 for (
int offsetX = 0; offsetX < size; offsetX++) {
659 for (
int offsetY = 0; offsetY < size; offsetY++) {
709 for (
int offsetX = 0; offsetX < size; offsetX++) {
710 for (
int offsetY = 0; offsetY < size; offsetY++) {
760 for (
int offsetX = 0; offsetX < size; offsetX++) {
761 for (
int offsetY = 0; offsetY < size; offsetY++) {
808 public static void set(
Region region,
int height,
int x,
int y,
int flag) {
809 region.setFlags(height, x & 0x3F, y & 0x3F, flag);
823 private static boolean isInactive(
int height,
int x,
int y,
int flag) {
824 int localX = x & 0x3F;
825 int localY = y & 0x3F;
827 return (
region.getFlags(height, localX, localY) & flag) == 0;
839 region.unsetFlags(height, x & 0x3F, y & 0x3F, flag);
873 throw new IllegalArgumentException(
"direction: " + direction +
" is not valid");
908 throw new IllegalArgumentException(
"direction: " + direction +
" is not valid");
922 List<Position> positions =
new LinkedList<>();
923 for (
int y = 0; y < length; y++) {
924 for (
int x = 0; x < width; x++) {
928 positions.add(from.
north());
931 positions.add(from.
south());
934 positions.add(from.
east());
937 positions.add(from.
west());
956 List<Position> positions =
new LinkedList<>();
957 for (
int y = 0; y < length; y++) {
958 for (
int x = 0; x < width; x++) {
962 positions.add(from.
north());
965 positions.add(from.
south());
968 positions.add(from.
east());
971 positions.add(from.
west());
986 if (positions.isEmpty())
992 List<Position> positions =
new LinkedList<>();
995 positions.add(from.
north());
998 positions.add(from.
south());
1001 positions.add(from.
east());
1004 positions.add(from.
west());
1006 if (positions.isEmpty())
1013 int localX = x & 0x3F;
1014 int localY = y & 0x3F;
1016 return region.getFlags(height, localX, localY);
Represents the game world.
static RegionManager getRegions()
Represents a single type of object.
static final int MAX_DEFINITIONS
The maximum number of object definitions.
Represents flags for each of the traversals.
static final int IMPENETRABLE_BLOCKED
The flag for an object occupant, which is impenetrable.
static final int IMPENETRABLE_WALL_SOUTH_WEST
The flag for a impenetrable south west facing wall.
static final int BLOCKED
The flag which denotes a blocked tile.
static final int WALL_EAST
The flag for a east facing wall.
static final int IMPENETRABLE_WALL_SOUTH_EAST
The flag for a impenetrable south east facing wall.
static final int WALL_NORTH
The flag for a north facing wall.
static final int IMPENETRABLE_WALL_WEST
The flag for a impenetrable west facing wall.
static final int IMPENETRABLE_WALL_EAST
The flag for a impenetrable east facing wall.
static final int WALL_NORTH_WEST
The flag for a north west facing wall.
static final int IMPENETRABLE_WALL_NORTH_EAST
The flag for a impenetrable north east facing wall.
static final int WALL_WEST
The flag for a west facing wall.
static final int WALL_SOUTH
The flag for a south facing wall.
static final int WALL_NORTH_EAST
The flag for a north east facing wall.
static final int BRIDGE
The flag which denotes a bridge tile.
static final int IMPENETRABLE_WALL_NORTH_WEST
The flag for a impenetrable north west facing wall.
static final int WALL_SOUTH_WEST
The flag for a south west facing wall.
static final int IMPENETRABLE_WALL_NORTH
The flag for a impenetrable north facing wall.
static final int IMPENETRABLE_WALL_SOUTH
The flag for a impenetrable south facing wall.
static final int WALL_SOUTH_EAST
The flag for a south east facing wall.
static boolean isTraversableNorthWest(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed north west.
static boolean isTraversableNorth(int height, int x, int y, int size)
Tests if the specified position can be traversed north.
static boolean isTraversableNorthEast(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed north east.
static void block(Region region, int height, int localX, int localY)
Marks the specified set of coordinates blocked, unable to be passed through.
static boolean blockedSouth(Position position)
static void markObject(Region region, GameObject object, boolean add, boolean list)
Marks a GameObject with the specified attributes on the specified Position to the TraversalMap.
static boolean isTraversableSouthWest(int height, int x, int y, int size)
Tests if the specified position can be traversed south west.
static boolean isTraversableNorthEast(int height, int x, int y, int size)
Tests if the specified position can be traversed north east.
static Position getRandomTraversableTile(Position southWest, int width, int length)
static boolean isTraversableEast(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed east.
static boolean isTraversableSouthEast(int height, int x, int y, int size)
Tests if the specified position can be traversed south east.
static boolean blockedNorth(Position position)
static boolean isTraversableNorthWest(int height, int x, int y)
Tests if the specified position can be traversed north west.
static boolean isTraversableWest(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed west.
static boolean blockedEast(Position position)
static boolean isTraversableSouth(int height, int x, int y, int size)
Tests if the specified position can be traversed south.
static int getFlags(Position position)
static boolean isTraversableNorth(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed north.
static void markBridge(Region region, int height, int x, int y)
Marks the specified coordinates a bridge.
static boolean isInactive(int height, int x, int y, int flag)
Checks whether or not the specified flag is not active on the specified position.
static boolean isTraversable(Position from, Direction direction, int size)
Tests whether or not a specified position is traversable in the specified direction.
static boolean isTraversableSouthEast(int height, int x, int y)
Tests if the specified position can be traversed south east.
static boolean isTraversableNorth(int height, int x, int y)
Tests if the specified position can be traversed north.
static List< Position > getTraversableTiles(Position southWest, int width, int length)
Returns a List of positions that are traversable from the specified position.
static boolean isTraversableSouthEast(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed south east.
static boolean isTraversableNorthWest(int height, int x, int y, int size)
Tests if the specified position can be traversed north west.
static boolean blockedWest(Position position)
static void unset(Region region, int height, int x, int y, int flag)
Unsets the specified flag from the specified position.
static boolean isTraversableWest(int height, int x, int y, int size)
Tests if the specified position can be traversed west.
static boolean isTraversableWest(int height, int x, int y)
Tests if the specified position can be traversed west.
static boolean isTraversableNorthEast(int height, int x, int y)
Tests if the specified position can be traversed north east.
static void markWall(Region reg, ObjectDirection orientation, int height, int x, int y, ObjectType type, boolean impenetrable)
Informs the region of an existing wall.
static boolean isTraversableSouth(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed south.
static void unmarkWall(Region reg, ObjectDirection orientation, int height, int x, int y, ObjectType type, boolean impenetrable)
Informs the region of an existing wall being removed.
static boolean isTraversableSouthWest(int height, int x, int y, boolean impenetrable)
Tests if the specified position can be traversed south west.
static boolean isTraversableEast(int height, int x, int y)
Tests if the specified position can be traversed east.
static boolean isTraversableSouthWest(int height, int x, int y)
Tests if the specified position can be traversed south west.
static int getFlags(int x, int y, int height)
static void markOccupant(Region region, int height, int x, int y, int width, int length, boolean impenetrable, boolean add)
Marks the specified coordinates occupied by some object.
static boolean isTraversableEast(int height, int x, int y, int size)
Tests if the specified position can be traversed east.
static boolean isTraversableSouth(int height, int x, int y)
Tests if the specified position can be traversed south.
static boolean isTraversable(Position from, Direction direction, boolean impenetrable)
Tests whether or not a specified position is traversable in the specified direction.
static Position getRandomNonDiagonal(Position from)
Represents a single tile on the game world.
int getHeight()
Gets the height coordinate, or height.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
Position transform(int diffX, int diffY, int diffZ)
Creates a new location based on this location.
Represents a single region.
Region getRegion(Position position)
Gets a region by position.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static< T > T random(T[] array)
Pseudo-randomly retrieves a element from array.
Represents the enumerated directions an entity can walk or face.
The enumerated type whose elements represent the directions for objects.
SOUTH
The south orientation.
WEST
The west orientation.
EAST
The east orientation.
NORTH
The north orientation.
The enumerated type whose elements represent all of the object types.
Represents a game object.