Enum 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. Each CollisionFlag corresponds 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
     }
     
    • 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 name
        NullPointerException - if the argument is null
      • combine

        public static int combine​(CollisionFlag... flags)
        Combines multiple CollisionFlag values 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 mask
        flag - the flag to test
        Returns:
        true if 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 bitmask
        flags - flags to test
        Returns:
        true if 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 bitmask
        flags - flags to test
        Returns:
        true if 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:
        true if the tile cannot be stepped on
      • fromValue

        public static EnumSet<CollisionFlag> fromValue​(int mask)
        Converts a raw collision mask into an EnumSet of individual flags. Useful for debugging or inspection.
        Parameters:
        mask - the raw collision mask
        Returns:
        an EnumSet containing 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 direction
        startFlag - collision mask of the origin tile
        endFlag - collision mask of the destination tile
        ignoreStartBlocked - if true, the start tile's blockage is ignored
        Returns:
        true if movement in the given direction is permitted
      • getValue

        public int getValue()