Rename Region to Scene

This commit is contained in:
Max Weber
2018-07-16 02:39:03 -06:00
parent 10ad7897a8
commit d7473bdb07
34 changed files with 161 additions and 182 deletions

View File

@@ -276,11 +276,9 @@ public interface Client extends GameEngine
int getPlane();
/**
* Gets the current region the local player is in.
*
* @return the region
* Gets the current scene
*/
Region getRegion();
Scene getScene();
/**
* Gets the logged in player instance.
@@ -333,8 +331,7 @@ public interface Client extends GameEngine
* Returns the x-axis base coordinate.
* <p>
* This value is the x-axis world coordinate of tile (0, 0) in
* the current scene (ie. the bottom-left most coordinates in
* the rendered region).
* the current scene (ie. the bottom-left most coordinates in the scene).
*
* @return the base x-axis coordinate
*/
@@ -344,8 +341,7 @@ public interface Client extends GameEngine
* Returns the y-axis base coordinate.
* <p>
* This value is the y-axis world coordinate of tile (0, 0) in
* the current scene (ie. the bottom-left most coordinates in
* the rendered region).
* the current scene (ie. the bottom-left most coordinates in the scene).
*
* @return the base y-axis coordinate
*/
@@ -359,12 +355,11 @@ public interface Client extends GameEngine
int getMouseCurrentButton();
/**
* Gets the currently selected region tile (ie. last right clicked
* tile).
* Gets the currently selected tile (ie. last right clicked tile).
*
* @return the selected region tile
* @return the selected tile
*/
Tile getSelectedRegionTile();
Tile getSelectedSceneTile();
/**
* Checks whether a widget is currently being dragged.

View File

@@ -25,22 +25,22 @@
package net.runelite.api;
/**
* Represents tile collision data for a world region.
* Represents tile collision data for the scene
*/
public interface CollisionData
{
/**
* Gets a 2D array of tile collision flags.
* <p>
* The array covers all tiles in a region (104x104), and the index into
* the array is of format [x][y] where x and y are the tiles region
* The array covers all tiles in the scene (104x104), and the index into
* the array is of format [x][y] where x and y are the tiles scene
* coordinates, respectively.
* <p>
* Collision flags are checked using the bitwise and (&amp;) operator. Flag
* values can be obtained and used with the {@link CollisionDataFlag} class.
*
* @return all collision flags for the tiles in the region
* @see Constants#REGION_SIZE
* @return all collision flags for the tiles in the scene
* @see Constants#SCENE_SIZE
*/
int[][] getFlags();
}

View File

@@ -57,9 +57,9 @@ public class Constants
*/
public static final int CHUNK_SIZE = 8;
/**
* The width and length of a region (13 chunks x 8 tiles).
* The width and length of the scene (13 chunks x 8 tiles).
*/
public static final int REGION_SIZE = 104;
public static final int SCENE_SIZE = 104;
/**
* The max allowed plane by the game.
* <p>

View File

@@ -37,21 +37,21 @@ public interface GameObject extends TileObject
{
/**
* Gets the minimum x and y region coordinate pair for this game object.
* Gets the minimum x and y scene coordinate pair for this game object.
*
* @return the minimum region coordinate
* @return the minimum scene coordinate
*/
Point getRegionMinLocation();
Point getSceneMinLocation();
/**
* Gets the maximum x and y region coordinate pair for this game object.
* Gets the maximum x and y scene coordinate pair for this game object.
* <p>
* This value differs from {@link #getRegionMinLocation()} when the size
* This value differs from {@link #getSceneMinLocation()} when the size
* of the object is more than 1 tile.
*
* @return the minimum region coordinate
* @return the maximum scene coordinate
*/
Point getRegionMaxLocation();
Point getSceneMaxLocation();
/**
* Gets the convex hull of the actors model.

View File

@@ -25,16 +25,14 @@
package net.runelite.api;
/**
* Represents a region of chunks.
* <p>
* A region is an area that contains 8x8 chunks on the map.
* Represents the entire 3D scene
*/
public interface Region
public interface Scene
{
/**
* Gets the tiles in this region.
* Gets the tiles in the scene
*
* @return the regions tile
* @return the tiles in [plane][x][y]
*/
Tile[][][] getTiles();
}

View File

@@ -90,12 +90,11 @@ public interface Tile
WorldPoint getWorldLocation();
/**
* Gets the location coordinate of the tile relative to the current
* region start point.
* Gets the location coordinate of the tile in scene coords
*
* @return the region location
* @return the scene location
*/
Point getRegionLocation();
Point getSceneLocation();
/**
* Gets the local coordinate of the tile.

View File

@@ -81,7 +81,7 @@ public class LocalPoint
int baseX = client.getBaseX();
int baseY = client.getBaseY();
return fromRegion(x - baseX, y - baseY);
return fromScene(x - baseX, y - baseY);
}
/**
@@ -97,18 +97,12 @@ public class LocalPoint
/**
* Gets the coordinate at the center of the passed tile.
* <p>
* The coordinate returned by this method is the true tile location,
* in LocalPoint units, relative to tile (0, 0).
* <p>
* e.g. If the local player is standing on tile 3170, the method returns
* 405823, or 3170 * 128 + 64.
*
* @param x x-axis coordinate of the tile
* @param y y-axis coordinate of the tile
* @param x x-axis coordinate of the tile in Scene coords
* @param y y-axis coordinate of the tile in Scene coords
* @return true coordinate of the tile
*/
public static LocalPoint fromRegion(int x, int y)
public static LocalPoint fromScene(int x, int y)
{
return new LocalPoint(
(x << Perspective.LOCAL_COORD_BITS) + (1 << Perspective.LOCAL_COORD_BITS - 1) - 1,
@@ -121,7 +115,7 @@ public class LocalPoint
*
* @return x-axis coordinate
*/
public int getRegionX()
public int getSceneX()
{
return x >>> Perspective.LOCAL_COORD_BITS;
}
@@ -131,7 +125,7 @@ public class LocalPoint
*
* @return y-axis coordinate
*/
public int getRegionY()
public int getSceneY()
{
return y >>> Perspective.LOCAL_COORD_BITS;
}

View File

@@ -230,8 +230,8 @@ public class WorldArea
LocalPoint lp = LocalPoint.fromWorld(client, x, y);
int startX = lp.getRegionX() + dx;
int startY = lp.getRegionY() + dy;
int startX = lp.getSceneX() + dx;
int startY = lp.getSceneY() + dy;
int checkX = startX + (dx > 0 ? width - 1 : 0);
int checkY = startY + (dy > 0 ? height - 1 : 0);
int endX = startX + width - 1;
@@ -303,7 +303,7 @@ public class WorldArea
for (int y = startY; y <= endY; y++)
{
if ((collisionDataFlags[checkX][y] & xFlags) != 0 ||
!extraCondition.test(WorldPoint.fromRegion(client, checkX, y, plane)))
!extraCondition.test(WorldPoint.fromScene(client, checkX, y, plane)))
{
// Collision while attempting to travel along the x axis
return false;
@@ -334,7 +334,7 @@ public class WorldArea
for (int x = startX; x <= endX; x++)
{
if ((collisionDataFlags[x][checkY] & yFlags) != 0 ||
!extraCondition.test(WorldPoint.fromRegion(client, x, checkY, client.getPlane())))
!extraCondition.test(WorldPoint.fromScene(client, x, checkY, client.getPlane())))
{
// Collision while attempting to travel along the y axis
return false;
@@ -362,7 +362,7 @@ public class WorldArea
if (dx != 0 && dy != 0)
{
if ((collisionDataFlags[checkX][checkY] & xyFlags) != 0 ||
!extraCondition.test(WorldPoint.fromRegion(client, checkX, checkY, client.getPlane())))
!extraCondition.test(WorldPoint.fromScene(client, checkX, checkY, client.getPlane())))
{
// Collision while attempting to travel diagonally
return false;
@@ -374,7 +374,7 @@ public class WorldArea
if (width == 1)
{
if ((collisionDataFlags[checkX][checkY - dy] & xFlags) != 0 &&
extraCondition.test(WorldPoint.fromRegion(client, checkX, startY, client.getPlane())))
extraCondition.test(WorldPoint.fromScene(client, checkX, startY, client.getPlane())))
{
return false;
}
@@ -382,7 +382,7 @@ public class WorldArea
if (height == 1)
{
if ((collisionDataFlags[checkX - dx][checkY] & yFlags) != 0 &&
extraCondition.test(WorldPoint.fromRegion(client, startX, checkY, client.getPlane())))
extraCondition.test(WorldPoint.fromScene(client, startX, checkY, client.getPlane())))
{
return false;
}
@@ -486,10 +486,10 @@ public class WorldArea
LocalPoint lp = LocalPoint.fromWorld(client, x, y);
if (lp == null ||
lp.getRegionX() + dx < 0 || lp.getRegionX() + dy >= Constants.REGION_SIZE ||
lp.getRegionY() + dx < 0 || lp.getRegionY() + dy >= Constants.REGION_SIZE)
lp.getSceneX() + dx < 0 || lp.getSceneX() + dy >= Constants.SCENE_SIZE ||
lp.getSceneY() + dx < 0 || lp.getSceneY() + dy >= Constants.SCENE_SIZE)
{
// NPC is travelling out of region, so collision data isn't available
// NPC is travelling out of the scene, so collision data isn't available
return null;
}
@@ -552,10 +552,10 @@ public class WorldArea
return false;
}
int thisX = sourceLp.getRegionX();
int thisY = sourceLp.getRegionY();
int otherX = targetLp.getRegionX();
int otherY = targetLp.getRegionY();
int thisX = sourceLp.getSceneX();
int thisY = sourceLp.getSceneY();
int otherX = targetLp.getSceneX();
int otherY = targetLp.getSceneY();
int cmpThisX, cmpThisY, cmpOtherX, cmpOtherY;
@@ -611,7 +611,7 @@ public class WorldArea
cmpOtherY = thisY;
}
Tile[][][] tiles = client.getRegion().getTiles();
Tile[][][] tiles = client.getScene().getTiles();
Tile sourceTile = tiles[plane][cmpThisX][cmpThisY];
Tile targetTile = tiles[other.getPlane()][cmpOtherX][cmpOtherY];
if (sourceTile == null || targetTile == null)

View File

@@ -195,15 +195,9 @@ public class WorldPoint
}
/**
* Gets the coordinate of the tile that contains the passed local point.
*
* @param client the client
* @param x the local x-axis coordinate
* @param y the local x-axis coordinate
* @param plane the plane
* @return the tile coordinate containing the local point
* Converts the passed scene coordinates to a world space
*/
public static WorldPoint fromRegion(Client client, int x, int y, int plane)
public static WorldPoint fromScene(Client client, int x, int y, int plane)
{
return new WorldPoint(
x + client.getBaseX(),

View File

@@ -60,9 +60,9 @@ public interface Callbacks
void updateNpcs();
/**
* Called after region is drawn.
* Called after the scene is drawn.
*/
void drawRegion();
void drawScene();
/**
* Called after logic that is drawing 2D objects is processed.

View File

@@ -26,8 +26,9 @@ package net.runelite.api.queries;
import static java.lang.Math.abs;
import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.Query;
import net.runelite.api.Region;
import net.runelite.api.Scene;
import net.runelite.api.Tile;
import net.runelite.api.TileObject;
@@ -38,17 +39,15 @@ import net.runelite.api.coords.WorldPoint;
public abstract class TileObjectQuery<EntityType extends TileObject, QueryType> extends Query<EntityType, QueryType>
{
private static final int REGION_SIZE = 104;
protected List<Tile> getTiles(Client client)
{
List<Tile> tilesList = new ArrayList<>();
Region region = client.getRegion();
Tile[][][] tiles = region.getTiles();
Scene scene = client.getScene();
Tile[][][] tiles = scene.getTiles();
int z = client.getPlane();
for (int x = 0; x < REGION_SIZE; ++x)
for (int x = 0; x < Constants.SCENE_SIZE; ++x)
{
for (int y = 0; y < REGION_SIZE; ++y)
for (int y = 0; y < Constants.SCENE_SIZE; ++y)
{
Tile tile = tiles[z][x][y];
if (tile == null)