Class TileService
- java.lang.Object
-
- com.kraken.api.service.tile.TileService
-
public class TileService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description TileService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description net.runelite.api.coords.WorldPointfromInstance(net.runelite.api.coords.WorldPoint worldPoint)Gets the coordinate of the tile that contains the passed world point, accounting for instances.net.runelite.api.coords.LocalPointfromWorldInstance(net.runelite.api.coords.WorldPoint worldPoint)Used to convert a WorldPoint in an instance to a LocalPointnet.runelite.api.ObjectCompositiongetObjectComposition(net.runelite.api.TileObject tileObject)Returns the object composition for a given TileObject.java.util.HashMap<net.runelite.api.coords.WorldPoint,java.lang.Integer>getReachableTilesFromTile(net.runelite.api.coords.WorldPoint tile, int distance, boolean ignoreCollision)This method calculates the distances to a specified tile in the game world using a breadth-first search (BFS) algorithm, considering movement restrictions and collision data.net.runelite.api.TilegetTile(int x, int y)This method retrieves the tile at the specified coordinates (x, y) on the current plane.booleanisObjectReachable(net.runelite.api.GameObject obj)Checks if a GameObject is reachable.booleanisTileReachable(net.runelite.api.coords.WorldPoint targetPoint)This method checks if a given target tile (WorldPoint) is reachable from the player's current location, considering collision data and the plane of the world.static java.lang.IntegerlocalToWorldDistance(int distance)Returns the distance from a local point to another local point in world point distance.java.util.ArrayList<net.runelite.api.coords.WorldPoint>toInstance(net.runelite.api.coords.WorldPoint worldPoint)Converts a world point into a list of instanced world pointsstatic java.lang.IntegerworldToLocalDistance(int distance)Returns the distance from a world point to another world point in local point distance.
-
-
-
Method Detail
-
getObjectComposition
public net.runelite.api.ObjectComposition getObjectComposition(net.runelite.api.TileObject tileObject)
Returns the object composition for a given TileObject.- Parameters:
tileObject- The tile object to retrieve the composition for- Returns:
- The object composition for a given tile object
-
getReachableTilesFromTile
public java.util.HashMap<net.runelite.api.coords.WorldPoint,java.lang.Integer> getReachableTilesFromTile(net.runelite.api.coords.WorldPoint tile, int distance, boolean ignoreCollision)This method calculates the distances to a specified tile in the game world using a breadth-first search (BFS) algorithm, considering movement restrictions and collision data. The distances are stored in a HashMap where the key is a WorldPoint (representing a tile location), and the value is the distance from the starting tile. The method accounts for movement flags that block movement in specific directions (east, west, north, south) and removes unreachable tiles based on collision data.The method iterates over a range of distances, progressively updating reachable tiles and adding them to the tileDistances map. It checks if a tile can be reached by verifying its collision flags and whether it’s blocked for movement in any direction.
- Parameters:
tile- The starting tile for the distance calculation.distance- The maximum distance to calculate to neighboring tiles.ignoreCollision- If true, ignores collision data during the calculation.- Returns:
- A HashMap containing WorldPoints and their corresponding distances from the start tile.
-
isObjectReachable
public boolean isObjectReachable(net.runelite.api.GameObject obj)
Checks if a GameObject is reachable. This considers the object's size and checks if the player can reach any tile touching the object's boundary (the "Interactable Halo").- Parameters:
obj- The game object to determine reachability for- Returns:
- true if the game object is reachable and false otherwise
-
isTileReachable
public boolean isTileReachable(net.runelite.api.coords.WorldPoint targetPoint)
This method checks if a given target tile (WorldPoint) is reachable from the player's current location, considering collision data and the plane of the world. The method uses a breadth-first search (BFS) algorithm to traverse neighboring tiles while checking for movement blocks in the four cardinal directions (north, south, east, west). It ensures the target tile is within the same plane as the player and that movement between tiles is not blocked.The method initializes a queue to explore the world grid, marking visited tiles to avoid revisiting. It checks the flags for collision data to determine whether movement is allowed in each direction, and only adds neighboring tiles to the queue if they are not blocked. Finally, it verifies if the target point has been visited during the traversal and returns true if reachable, false otherwise.
- Parameters:
targetPoint- The WorldPoint representing the target tile to check for reachability.- Returns:
- True if the target tile is reachable from the player's location, otherwise false.
-
getTile
public net.runelite.api.Tile getTile(int x, int y)This method retrieves the tile at the specified coordinates (x, y) on the current plane. It first creates a WorldPoint for the given coordinates and checks if the point is within the scene using the `isInScene` method. If the WorldPoint is valid and within the scene, it converts the WorldPoint to a LocalPoint, then retrieves and returns the corresponding Tile from the game scene.If the WorldPoint is out of bounds or the LocalPoint is null, the method returns null to indicate that no valid tile is found at the given coordinates.
- Parameters:
x- The x-coordinate of the tile.y- The y-coordinate of the tile.- Returns:
- The Tile at the specified coordinates, or null if the tile is invalid or not in the scene.
-
fromWorldInstance
public net.runelite.api.coords.LocalPoint fromWorldInstance(net.runelite.api.coords.WorldPoint worldPoint)
Used to convert a WorldPoint in an instance to a LocalPoint- Parameters:
worldPoint- The world point to convert- Returns:
- A local point representing the same global world point
-
fromInstance
public net.runelite.api.coords.WorldPoint fromInstance(net.runelite.api.coords.WorldPoint worldPoint)
Gets the coordinate of the tile that contains the passed world point, accounting for instances.- Parameters:
worldPoint- the instance worldpoint- Returns:
- the tile coordinate containing the local point
-
toInstance
public java.util.ArrayList<net.runelite.api.coords.WorldPoint> toInstance(net.runelite.api.coords.WorldPoint worldPoint)
Converts a world point into a list of instanced world points- Parameters:
worldPoint- World point to convert- Returns:
- List of instanced world points.
-
worldToLocalDistance
public static java.lang.Integer worldToLocalDistance(int distance)
Returns the distance from a world point to another world point in local point distance.- Parameters:
distance- Distance to convert- Returns:
- The distance in local points between a world point and another world point
-
localToWorldDistance
public static java.lang.Integer localToWorldDistance(int distance)
Returns the distance from a local point to another local point in world point distance.- Parameters:
distance- Distance to convert- Returns:
- The distance in world points between a local point and another local point
-
-