From 6cfb5d4978354740ded9179849890c210d1e8fa7 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Feb 2018 12:59:35 -0500 Subject: [PATCH] perspective: add method for checking if world location is in scene --- .../java/net/runelite/api/Perspective.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/Perspective.java b/runelite-api/src/main/java/net/runelite/api/Perspective.java index f2d6d6cd1c..f058646213 100644 --- a/runelite-api/src/main/java/net/runelite/api/Perspective.java +++ b/runelite-api/src/main/java/net/runelite/api/Perspective.java @@ -45,6 +45,8 @@ public class Perspective public static final int LOCAL_COORD_BITS = 7; public static final int LOCAL_TILE_SIZE = 1 << LOCAL_COORD_BITS; // 128 - size of a tile in local coordinates + public static final int SCENE_SIZE = 104; // in tiles + public static final int[] SINE = new int[2048]; // sine angles for each of the 2048 units, * 65536 and stored as an int public static final int[] COSINE = new int[2048]; // cosine @@ -57,6 +59,25 @@ public class Perspective } } + /** + * Check if a world location is in the scene + * @param point world location + * @return + */ + public static boolean isWorldInScene(Client client, Point point) + { + int x = point.getX(); + int y = point.getY(); + + int baseX = client.getBaseX(); + int baseY = client.getBaseY(); + + int maxX = baseX + SCENE_SIZE; + int maxY = baseY + SCENE_SIZE; + + return x >= baseX && x < maxX && y >= baseY && y < maxY; + } + /** * Translates two-dimensional ground coordinates within the 3D world to * their corresponding coordinates on the game screen.