Package org.rspeer.game.coord.collision
Enum CollisionFlag
- java.lang.Object
-
- java.lang.Enum<CollisionFlag>
-
- org.rspeer.game.coord.collision.CollisionFlag
-
- All Implemented Interfaces:
Serializable,Comparable<CollisionFlag>
public enum CollisionFlag extends Enum<CollisionFlag>
Represents the full set of collision and movement-blocking flags used by the OSRS tile collision system. EachCollisionFlagcorresponds to a bitmask value that describes obstacles, walls, decorations, and other movement restrictions on a tile.This enum provides:
- Strongly typed access to individual collision flags.
- Utility methods for combining and testing bitmask values.
- Helpers for determining whether a movement direction is walkable between tiles.
The underlying collision system stores all flags as raw integer masks, where each bit indicates the presence of a specific obstruction. This enum acts as a higher-level interface for interpreting those masks.
Example:
int mask = collisionMap[x][y]; if (CollisionFlag.isSet(mask, CollisionFlag.WALL_NORTH)) { // Tile contains a north wall }
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BLOCKEDFOV_EASTFOV_NORTHFOV_SOUTHFOV_WESTIMPENETRABLEOCCUPIEDOCCUPIED_DECORSOLIDUNINITIALIZEDWALL_EASTWALL_NORTHWALL_NORTH_EASTWALL_NORTH_WESTWALL_SOUTHWALL_SOUTH_EASTWALL_SOUTH_WESTWALL_WEST
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcombine(CollisionFlag... flags)Combines multipleCollisionFlagvalues into a single integer mask.static EnumSet<CollisionFlag>fromValue(int mask)Converts a raw collision mask into anEnumSetof individual flags.intgetValue()static booleanisAllSet(int mask, CollisionFlag... flags)Checks whether all specified flags are present in the mask.static booleanisAnySet(int mask, CollisionFlag... flags)Checks whether any of the given flags are present in the mask.static booleanisBlocked(int mask)Determines whether a tile is fundamentally blocked for movement.static booleanisDirectionWalkable(Direction dir, int startFlag, int endFlag, boolean ignoreStartBlocked)Determines whether movement in the given direction is allowed based on the start and end tile collision masks.static booleanisSet(int mask, CollisionFlag flag)Checks whether a specific flag is present in the given collision mask.static StringtoString(int mask)Produces a human-readable string listing all flags present in the mask.static CollisionFlagvalueOf(String name)Returns the enum constant of this type with the specified name.static CollisionFlag[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
OCCUPIED
public static final CollisionFlag OCCUPIED
-
OCCUPIED_DECOR
public static final CollisionFlag OCCUPIED_DECOR
-
BLOCKED
public static final CollisionFlag BLOCKED
-
UNINITIALIZED
public static final CollisionFlag UNINITIALIZED
-
IMPENETRABLE
public static final CollisionFlag IMPENETRABLE
-
WALL_NORTH
public static final CollisionFlag WALL_NORTH
-
WALL_EAST
public static final CollisionFlag WALL_EAST
-
WALL_SOUTH
public static final CollisionFlag WALL_SOUTH
-
WALL_WEST
public static final CollisionFlag WALL_WEST
-
WALL_NORTH_WEST
public static final CollisionFlag WALL_NORTH_WEST
-
WALL_NORTH_EAST
public static final CollisionFlag WALL_NORTH_EAST
-
WALL_SOUTH_EAST
public static final CollisionFlag WALL_SOUTH_EAST
-
WALL_SOUTH_WEST
public static final CollisionFlag WALL_SOUTH_WEST
-
SOLID
public static final CollisionFlag SOLID
-
FOV_NORTH
public static final CollisionFlag FOV_NORTH
-
FOV_EAST
public static final CollisionFlag FOV_EAST
-
FOV_SOUTH
public static final CollisionFlag FOV_SOUTH
-
FOV_WEST
public static final CollisionFlag FOV_WEST
-
-
Method Detail
-
values
public static CollisionFlag[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CollisionFlag c : CollisionFlag.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CollisionFlag valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
combine
public static int combine(CollisionFlag... flags)
Combines multipleCollisionFlagvalues into a single integer mask.- Parameters:
flags- the flags to combine- Returns:
- a bitmask containing all provided flags
-
isSet
public static boolean isSet(int mask, CollisionFlag flag)Checks whether a specific flag is present in the given collision mask.- Parameters:
mask- the raw collision maskflag- the flag to test- Returns:
trueif the flag's bit is set in the mask
-
isAnySet
public static boolean isAnySet(int mask, CollisionFlag... flags)Checks whether any of the given flags are present in the mask.- Parameters:
mask- the collision bitmaskflags- flags to test- Returns:
trueif at least one flag is set
-
isAllSet
public static boolean isAllSet(int mask, CollisionFlag... flags)Checks whether all specified flags are present in the mask.- Parameters:
mask- the collision bitmaskflags- flags to test- Returns:
trueif all flags are present
-
isBlocked
public static boolean isBlocked(int mask)
Determines whether a tile is fundamentally blocked for movement. This includes objects, decorations, full-tile blockers, and impenetrable tiles.- Parameters:
mask- the collision mask- Returns:
trueif the tile cannot be stepped on
-
fromValue
public static EnumSet<CollisionFlag> fromValue(int mask)
Converts a raw collision mask into anEnumSetof individual flags. Useful for debugging or inspection.- Parameters:
mask- the raw collision mask- Returns:
- an
EnumSetcontaining all flags present in the mask
-
toString
public static String toString(int mask)
Produces a human-readable string listing all flags present in the mask.- Parameters:
mask- the collision mask- Returns:
- comma-separated list of flag names
-
isDirectionWalkable
public static boolean isDirectionWalkable(Direction dir, int startFlag, int endFlag, boolean ignoreStartBlocked)
Determines whether movement in the given direction is allowed based on the start and end tile collision masks. Directional blocking checks walls, diagonal obstructions, and tile-level blocking rules consistent with the OSRS movement system.This method enforces:
- Start and end tiles must not be fully blocked.
- Directional walls must not obstruct movement (e.g., north wall blocks north movement).
- Diagonal movement must not pass through corner-blocked tiles.
- Parameters:
dir- the movement directionstartFlag- collision mask of the origin tileendFlag- collision mask of the destination tileignoreStartBlocked- iftrue, the start tile's blockage is ignored- Returns:
trueif movement in the given direction is permitted
-
getValue
public int getValue()
-
-