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

View File

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

View File

@@ -57,9 +57,9 @@ public class Constants
*/ */
public static final int CHUNK_SIZE = 8; 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. * The max allowed plane by the game.
* <p> * <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> * <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. * 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. * Gets the convex hull of the actors model.

View File

@@ -25,16 +25,14 @@
package net.runelite.api; package net.runelite.api;
/** /**
* Represents a region of chunks. * Represents the entire 3D scene
* <p>
* A region is an area that contains 8x8 chunks on the map.
*/ */
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(); Tile[][][] getTiles();
} }

View File

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

View File

@@ -81,7 +81,7 @@ public class LocalPoint
int baseX = client.getBaseX(); int baseX = client.getBaseX();
int baseY = client.getBaseY(); 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. * 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 x x-axis coordinate of the tile in Scene coords
* @param y y-axis coordinate of the tile * @param y y-axis coordinate of the tile in Scene coords
* @return true coordinate of the tile * @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( return new LocalPoint(
(x << Perspective.LOCAL_COORD_BITS) + (1 << Perspective.LOCAL_COORD_BITS - 1) - 1, (x << Perspective.LOCAL_COORD_BITS) + (1 << Perspective.LOCAL_COORD_BITS - 1) - 1,
@@ -121,7 +115,7 @@ public class LocalPoint
* *
* @return x-axis coordinate * @return x-axis coordinate
*/ */
public int getRegionX() public int getSceneX()
{ {
return x >>> Perspective.LOCAL_COORD_BITS; return x >>> Perspective.LOCAL_COORD_BITS;
} }
@@ -131,7 +125,7 @@ public class LocalPoint
* *
* @return y-axis coordinate * @return y-axis coordinate
*/ */
public int getRegionY() public int getSceneY()
{ {
return y >>> Perspective.LOCAL_COORD_BITS; return y >>> Perspective.LOCAL_COORD_BITS;
} }

View File

@@ -230,8 +230,8 @@ public class WorldArea
LocalPoint lp = LocalPoint.fromWorld(client, x, y); LocalPoint lp = LocalPoint.fromWorld(client, x, y);
int startX = lp.getRegionX() + dx; int startX = lp.getSceneX() + dx;
int startY = lp.getRegionY() + dy; int startY = lp.getSceneY() + dy;
int checkX = startX + (dx > 0 ? width - 1 : 0); int checkX = startX + (dx > 0 ? width - 1 : 0);
int checkY = startY + (dy > 0 ? height - 1 : 0); int checkY = startY + (dy > 0 ? height - 1 : 0);
int endX = startX + width - 1; int endX = startX + width - 1;
@@ -303,7 +303,7 @@ public class WorldArea
for (int y = startY; y <= endY; y++) for (int y = startY; y <= endY; y++)
{ {
if ((collisionDataFlags[checkX][y] & xFlags) != 0 || 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 // Collision while attempting to travel along the x axis
return false; return false;
@@ -334,7 +334,7 @@ public class WorldArea
for (int x = startX; x <= endX; x++) for (int x = startX; x <= endX; x++)
{ {
if ((collisionDataFlags[x][checkY] & yFlags) != 0 || 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 // Collision while attempting to travel along the y axis
return false; return false;
@@ -362,7 +362,7 @@ public class WorldArea
if (dx != 0 && dy != 0) if (dx != 0 && dy != 0)
{ {
if ((collisionDataFlags[checkX][checkY] & xyFlags) != 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 // Collision while attempting to travel diagonally
return false; return false;
@@ -374,7 +374,7 @@ public class WorldArea
if (width == 1) if (width == 1)
{ {
if ((collisionDataFlags[checkX][checkY - dy] & xFlags) != 0 && 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; return false;
} }
@@ -382,7 +382,7 @@ public class WorldArea
if (height == 1) if (height == 1)
{ {
if ((collisionDataFlags[checkX - dx][checkY] & yFlags) != 0 && 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; return false;
} }
@@ -486,10 +486,10 @@ public class WorldArea
LocalPoint lp = LocalPoint.fromWorld(client, x, y); LocalPoint lp = LocalPoint.fromWorld(client, x, y);
if (lp == null || if (lp == null ||
lp.getRegionX() + dx < 0 || lp.getRegionX() + dy >= Constants.REGION_SIZE || lp.getSceneX() + dx < 0 || lp.getSceneX() + dy >= Constants.SCENE_SIZE ||
lp.getRegionY() + dx < 0 || lp.getRegionY() + dy >= Constants.REGION_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; return null;
} }
@@ -552,10 +552,10 @@ public class WorldArea
return false; return false;
} }
int thisX = sourceLp.getRegionX(); int thisX = sourceLp.getSceneX();
int thisY = sourceLp.getRegionY(); int thisY = sourceLp.getSceneY();
int otherX = targetLp.getRegionX(); int otherX = targetLp.getSceneX();
int otherY = targetLp.getRegionY(); int otherY = targetLp.getSceneY();
int cmpThisX, cmpThisY, cmpOtherX, cmpOtherY; int cmpThisX, cmpThisY, cmpOtherX, cmpOtherY;
@@ -611,7 +611,7 @@ public class WorldArea
cmpOtherY = thisY; cmpOtherY = thisY;
} }
Tile[][][] tiles = client.getRegion().getTiles(); Tile[][][] tiles = client.getScene().getTiles();
Tile sourceTile = tiles[plane][cmpThisX][cmpThisY]; Tile sourceTile = tiles[plane][cmpThisX][cmpThisY];
Tile targetTile = tiles[other.getPlane()][cmpOtherX][cmpOtherY]; Tile targetTile = tiles[other.getPlane()][cmpOtherX][cmpOtherY];
if (sourceTile == null || targetTile == null) 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. * Converts the passed scene coordinates to a world space
*
* @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
*/ */
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( return new WorldPoint(
x + client.getBaseX(), x + client.getBaseX(),

View File

@@ -60,9 +60,9 @@ public interface Callbacks
void updateNpcs(); 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. * 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 static java.lang.Math.abs;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.Query; import net.runelite.api.Query;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.TileObject; 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> 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) protected List<Tile> getTiles(Client client)
{ {
List<Tile> tilesList = new ArrayList<>(); List<Tile> tilesList = new ArrayList<>();
Region region = client.getRegion(); Scene scene = client.getScene();
Tile[][][] tiles = region.getTiles(); Tile[][][] tiles = scene.getTiles();
int z = client.getPlane(); 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]; Tile tile = tiles[z][x][y];
if (tile == null) if (tile == null)

View File

@@ -341,7 +341,7 @@ public class Hooks implements Callbacks
} }
@Override @Override
public void drawRegion() public void drawScene()
{ {
MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider(); MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider();
BufferedImage image = (BufferedImage) bufferProvider.getImage(); BufferedImage image = (BufferedImage) bufferProvider.getImage();

View File

@@ -67,7 +67,7 @@ import net.runelite.client.events.PluginChanged;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
import net.runelite.client.task.ScheduledMethod; import net.runelite.client.task.ScheduledMethod;
import net.runelite.client.task.Scheduler; import net.runelite.client.task.Scheduler;
import net.runelite.client.util.RegionTileManager; import net.runelite.client.util.SceneTileManager;
@Singleton @Singleton
@Slf4j @Slf4j
@@ -91,7 +91,7 @@ public class PluginManager
ScheduledExecutorService executor; ScheduledExecutorService executor;
@Inject @Inject
RegionTileManager regionTileManager; SceneTileManager sceneTileManager;
@Setter @Setter
boolean isOutdated; boolean isOutdated;
@@ -314,7 +314,7 @@ public class PluginManager
}); });
log.debug("Plugin {} is now running", plugin.getClass().getSimpleName()); log.debug("Plugin {} is now running", plugin.getClass().getSimpleName());
regionTileManager.simulateObjectSpawns(plugin); sceneTileManager.simulateObjectSpawns(plugin);
eventBus.register(plugin); eventBus.register(plugin);
schedule(plugin); schedule(plugin);
eventBus.post(new PluginChanged(plugin, true)); eventBus.post(new PluginChanged(plugin, true));

View File

@@ -90,7 +90,7 @@ public class BlastMineRockOverlay extends Overlay
return null; return null;
} }
final Tile[][][] tiles = client.getRegion().getTiles(); final Tile[][][] tiles = client.getScene().getTiles();
final Widget viewport = client.getViewportWidget(); final Widget viewport = client.getViewportWidget();
for (final BlastMineRock rock : rocks.values()) for (final BlastMineRock rock : rocks.values())

View File

@@ -49,7 +49,7 @@ import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Query; import net.runelite.api.Query;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
@@ -339,9 +339,9 @@ public class ClueScrollPlugin extends Plugin
if (localLocation != null) if (localLocation != null)
{ {
final Region region = client.getRegion(); final Scene scene = client.getScene();
final Tile[][][] tiles = region.getTiles(); final Tile[][][] tiles = scene.getTiles();
final Tile tile = tiles[client.getPlane()][localLocation.getRegionX()][localLocation.getRegionY()]; final Tile tile = tiles[client.getPlane()][localLocation.getSceneX()][localLocation.getSceneY()];
objectsToMark = Arrays.stream(tile.getGameObjects()) objectsToMark = Arrays.stream(tile.getGameObjects())
.filter(object -> object != null && object.getId() == objectId) .filter(object -> object != null && object.getId() == objectId)

View File

@@ -37,6 +37,7 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.DecorativeObject; import net.runelite.api.DecorativeObject;
import net.runelite.api.GameObject; import net.runelite.api.GameObject;
import net.runelite.api.GraphicsObject; import net.runelite.api.GraphicsObject;
@@ -50,7 +51,7 @@ import net.runelite.api.Perspective;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.Projectile; import net.runelite.api.Projectile;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.WallObject; import net.runelite.api.WallObject;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
@@ -79,7 +80,6 @@ public class DevToolsOverlay extends Overlay
private static final Color PURPLE = new Color(170, 0, 255); private static final Color PURPLE = new Color(170, 0, 255);
private static final Color GRAY = new Color(158, 158, 158); private static final Color GRAY = new Color(158, 158, 158);
private static final int REGION_SIZE = 104;
private static final int MAX_DISTANCE = 2400; private static final int MAX_DISTANCE = 2400;
private final Client client; private final Client client;
@@ -191,14 +191,14 @@ public class DevToolsOverlay extends Overlay
private void renderTileObjects(Graphics2D graphics) private void renderTileObjects(Graphics2D graphics)
{ {
Region region = client.getRegion(); Scene scene = client.getScene();
Tile[][][] tiles = region.getTiles(); Tile[][][] tiles = scene.getTiles();
int z = client.getPlane(); 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]; Tile tile = tiles[z][x][y];

View File

@@ -74,14 +74,14 @@ public class LocationOverlay extends Overlay
int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks(); int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
int z = client.getPlane(); int z = client.getPlane();
int chunkData = instanceTemplateChunks[z][localPoint.getRegionX() / CHUNK_SIZE][localPoint.getRegionY() / CHUNK_SIZE]; int chunkData = instanceTemplateChunks[z][localPoint.getSceneX() / CHUNK_SIZE][localPoint.getSceneY() / CHUNK_SIZE];
int rotation = chunkData >> 1 & 0x3; int rotation = chunkData >> 1 & 0x3;
int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE; int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;
int chunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE; int chunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE;
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left("Chunk " + localPoint.getRegionX() / CHUNK_SIZE + "," + localPoint.getRegionY() / CHUNK_SIZE) .left("Chunk " + localPoint.getSceneX() / CHUNK_SIZE + "," + localPoint.getSceneY() / CHUNK_SIZE)
.right(rotation + " " + chunkX + " " + chunkY) .right(rotation + " " + chunkX + " " + chunkY)
.build()); .build());
} }
@@ -97,8 +97,8 @@ public class LocationOverlay extends Overlay
.build()); .build());
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left("Region") .left("Scene")
.right(localPoint.getRegionX() + ", " + localPoint.getRegionY()) .right(localPoint.getSceneX() + ", " + localPoint.getSceneY())
.build()); .build());
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()

View File

@@ -253,7 +253,7 @@ public class DiscordPlugin extends Plugin
final LocalPoint localPoint = client.getLocalPlayer().getLocalLocation(); final LocalPoint localPoint = client.getLocalPlayer().getLocalLocation();
final int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks(); final int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
final int z = client.getPlane(); final int z = client.getPlane();
final int chunkData = instanceTemplateChunks[z][localPoint.getRegionX() / CHUNK_SIZE][localPoint.getRegionY() / CHUNK_SIZE]; final int chunkData = instanceTemplateChunks[z][localPoint.getSceneX() / CHUNK_SIZE][localPoint.getSceneY() / CHUNK_SIZE];
// extract world point from chunk data // extract world point from chunk data
final int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE; final int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;

View File

@@ -53,7 +53,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.Constants.REGION_SIZE; import static net.runelite.api.Constants.SCENE_SIZE;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
@@ -63,7 +63,7 @@ import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Node; import net.runelite.api.Node;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
@@ -232,16 +232,16 @@ public class GroundItemsPlugin extends Plugin
dirty = false; dirty = false;
final Region region = client.getRegion(); final Scene scene = client.getScene();
final Tile[][][] tiles = region.getTiles(); final Tile[][][] tiles = scene.getTiles();
final int z = client.getPlane(); final int z = client.getPlane();
final LocalPoint from = player.getLocalLocation(); final LocalPoint from = player.getLocalLocation();
groundItems.clear(); groundItems.clear();
for (int x = 0; x < REGION_SIZE; ++x) for (int x = 0; x < SCENE_SIZE; ++x)
{ {
for (int y = 0; y < REGION_SIZE; ++y) for (int y = 0; y < SCENE_SIZE; ++y)
{ {
Tile tile = tiles[z][x][y]; Tile tile = tiles[z][x][y];
if (tile == null) if (tile == null)
@@ -369,8 +369,8 @@ public class GroundItemsPlugin extends Plugin
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
{ {
int itemId = event.getIdentifier(); int itemId = event.getIdentifier();
Region region = client.getRegion(); Scene scene = client.getScene();
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()]; Tile tile = scene.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
ItemLayer itemLayer = tile.getItemLayer(); ItemLayer itemLayer = tile.getItemLayer();
if (itemLayer == null) if (itemLayer == null)

View File

@@ -285,7 +285,7 @@ public class GroundMarkerPlugin extends Plugin
return; return;
} }
Tile target = client.getSelectedRegionTile(); Tile target = client.getSelectedSceneTile();
markTile(target.getLocalLocation()); markTile(target.getLocalLocation());
} }
@@ -316,8 +316,8 @@ public class GroundMarkerPlugin extends Plugin
if (client.isInInstancedRegion()) if (client.isInInstancedRegion())
{ {
// get position in the scene // get position in the scene
int sceneX = localPoint.getRegionX(); int sceneX = localPoint.getSceneX();
int sceneY = localPoint.getRegionY(); int sceneY = localPoint.getSceneY();
// get chunk from scene // get chunk from scene
int chunkX = sceneX / CHUNK_SIZE; int chunkX = sceneX / CHUNK_SIZE;

View File

@@ -306,7 +306,7 @@ public class HunterPlugin extends Plugin
{ {
// Check if all traps are still there, and remove the ones that are not. // Check if all traps are still there, and remove the ones that are not.
Iterator<Map.Entry<WorldPoint, HunterTrap>> it = traps.entrySet().iterator(); Iterator<Map.Entry<WorldPoint, HunterTrap>> it = traps.entrySet().iterator();
Tile[][][] tiles = client.getRegion().getTiles(); Tile[][][] tiles = client.getScene().getTiles();
Instant expire = Instant.now().minus(HunterTrap.TRAP_TIME.multipliedBy(2)); Instant expire = Instant.now().minus(HunterTrap.TRAP_TIME.multipliedBy(2));
@@ -330,7 +330,7 @@ public class HunterPlugin extends Plugin
continue; continue;
} }
Tile tile = tiles[world.getPlane()][local.getRegionX()][local.getRegionY()]; Tile tile = tiles[world.getPlane()][local.getSceneX()][local.getSceneY()];
GameObject[] objects = tile.getGameObjects(); GameObject[] objects = tile.getGameObjects();
boolean containsBoulder = false; boolean containsBoulder = false;

View File

@@ -72,7 +72,7 @@ class InstanceMapOverlay extends Overlay
private final Client client; private final Client client;
/** /**
* Saved image of the region, no reason to draw the whole thing every * Saved image of the scene, no reason to draw the whole thing every
* frame. * frame.
*/ */
private volatile BufferedImage mapImage; private volatile BufferedImage mapImage;
@@ -182,8 +182,8 @@ class InstanceMapOverlay extends Overlay
*/ */
private Tile[][] getTiles() private Tile[][] getTiles()
{ {
Tile[][][] regionTiles = client.getRegion().getTiles(); Tile[][][] sceneTiles = client.getScene().getTiles();
return regionTiles[viewedPlane]; return sceneTiles[viewedPlane];
} }
/** /**
@@ -197,8 +197,8 @@ class InstanceMapOverlay extends Overlay
LocalPoint playerLoc = player.getLocalLocation(); LocalPoint playerLoc = player.getLocalLocation();
Tile[][] tiles = getTiles(); Tile[][] tiles = getTiles();
int tileX = playerLoc.getRegionX(); int tileX = playerLoc.getSceneX();
int tileY = (tiles[0].length - 1) - playerLoc.getRegionY(); // flip the y value int tileY = (tiles[0].length - 1) - playerLoc.getSceneY(); // flip the y value
int x = tileX * TILE_SIZE; int x = tileX * TILE_SIZE;
int y = tileY * TILE_SIZE; int y = tileY * TILE_SIZE;

View File

@@ -171,7 +171,7 @@ public class KourendLibraryPlugin extends Plugin
{ {
if (MenuAction.GAME_OBJECT_FIRST_OPTION == menuOpt.getMenuAction() && menuOpt.getMenuTarget().contains("Bookshelf")) if (MenuAction.GAME_OBJECT_FIRST_OPTION == menuOpt.getMenuAction() && menuOpt.getMenuTarget().contains("Bookshelf"))
{ {
lastBookcaseClick = WorldPoint.fromRegion(client, menuOpt.getActionParam(), menuOpt.getWidgetId(), client.getPlane()); lastBookcaseClick = WorldPoint.fromScene(client, menuOpt.getActionParam(), menuOpt.getWidgetId(), client.getPlane());
} }
} }

View File

@@ -410,7 +410,7 @@ public class RaidsPlugin extends Plugin
private Point findLobbyBase() private Point findLobbyBase()
{ {
Tile[][] tiles = client.getRegion().getTiles()[LOBBY_PLANE]; Tile[][] tiles = client.getScene().getTiles()[LOBBY_PLANE];
for (int x = 0; x < SCENE_SIZE; x++) for (int x = 0; x < SCENE_SIZE; x++)
{ {
@@ -423,7 +423,7 @@ public class RaidsPlugin extends Plugin
if (tiles[x][y].getWallObject().getId() == NullObjectID.NULL_12231) if (tiles[x][y].getWallObject().getId() == NullObjectID.NULL_12231)
{ {
return tiles[x][y].getRegionLocation(); return tiles[x][y].getSceneLocation();
} }
} }
} }
@@ -447,7 +447,7 @@ public class RaidsPlugin extends Plugin
for (int plane = 3; plane > 1; plane--) for (int plane = 3; plane > 1; plane--)
{ {
tiles = client.getRegion().getTiles()[plane]; tiles = client.getScene().getTiles()[plane];
if (tiles[gridBase.getX() + RaidRoom.ROOM_MAX_SIZE][gridBase.getY()] == null) if (tiles[gridBase.getX() + RaidRoom.ROOM_MAX_SIZE][gridBase.getY()] == null)
{ {
@@ -510,7 +510,7 @@ public class RaidsPlugin extends Plugin
private RaidRoom determineRoom(Tile base) private RaidRoom determineRoom(Tile base)
{ {
RaidRoom room = new RaidRoom(base, RaidRoom.Type.EMPTY); RaidRoom room = new RaidRoom(base, RaidRoom.Type.EMPTY);
int chunkData = client.getInstanceTemplateChunks()[base.getPlane()][(base.getRegionLocation().getX()) / 8][base.getRegionLocation().getY() / 8]; int chunkData = client.getInstanceTemplateChunks()[base.getPlane()][(base.getSceneLocation().getX()) / 8][base.getSceneLocation().getY() / 8];
InstanceTemplates template = InstanceTemplates.findMatch(chunkData); InstanceTemplates template = InstanceTemplates.findMatch(chunkData);
if (template == null) if (template == null)

View File

@@ -35,7 +35,7 @@ import javax.inject.Singleton;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.events.DecorativeObjectSpawned; import net.runelite.api.events.DecorativeObjectSpawned;
import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameObjectSpawned;
@@ -43,19 +43,19 @@ import net.runelite.api.events.GroundObjectSpawned;
import net.runelite.api.events.WallObjectSpawned; import net.runelite.api.events.WallObjectSpawned;
@Singleton @Singleton
public class RegionTileManager public class SceneTileManager
{ {
private final EventBus eventBus = new EventBus(); private final EventBus eventBus = new EventBus();
private final Provider<Client> clientProvider; private final Provider<Client> clientProvider;
@Inject @Inject
public RegionTileManager(Provider<Client> clientProvider) public SceneTileManager(Provider<Client> clientProvider)
{ {
this.clientProvider = clientProvider; this.clientProvider = clientProvider;
} }
/** /**
* Iterates over each tile in current region if player is logged in * Iterates over each tile in the scene if player is logged in
* @param consumer consumer accepting tile as parameter * @param consumer consumer accepting tile as parameter
*/ */
public void forEachTile(Consumer<Tile> consumer) public void forEachTile(Consumer<Tile> consumer)
@@ -67,14 +67,14 @@ public class RegionTileManager
return; return;
} }
final Region region = client.getRegion(); final Scene scene = client.getScene();
final Tile[][][] tiles = region.getTiles(); final Tile[][][] tiles = scene.getTiles();
for (int z = 0; z < Constants.MAX_Z; ++z) for (int z = 0; z < Constants.MAX_Z; ++z)
{ {
for (int x = 0; x < Constants.REGION_SIZE; ++x) for (int x = 0; x < Constants.SCENE_SIZE; ++x)
{ {
for (int y = 0; y < Constants.REGION_SIZE; ++y) for (int y = 0; y < Constants.SCENE_SIZE; ++y)
{ {
Tile tile = tiles[z][x][y]; Tile tile = tiles[z][x][y];

View File

@@ -40,8 +40,8 @@ public abstract class CameraMixin implements RSClient
@Shadow("clientInstance") @Shadow("clientInstance")
static RSClient client; static RSClient client;
@Shadow("isDrawingRegion") @Shadow("isDrawingScene")
static boolean isDrawingRegion; static boolean isDrawingScene;
@Inject @Inject
static boolean pitchRelaxEnabled = false; static boolean pitchRelaxEnabled = false;
@@ -91,13 +91,13 @@ public abstract class CameraMixin implements RSClient
lastPitch = pitch; lastPitch = pitch;
} }
// All of this is to bypass a check in Region.drawRegion // All of this is to bypass a check in Scene.drawScene
@FieldHook("pitchSin") @FieldHook("pitchSin")
@Inject @Inject
static void onPitchSinChanged(int idx) static void onPitchSinChanged(int idx)
{ {
if (pitchRelaxEnabled && isDrawingRegion) if (pitchRelaxEnabled && isDrawingScene)
{ {
client.setPitchSin(Perspective.SINE[client.getCameraPitch()]); client.setPitchSin(Perspective.SINE[client.getCameraPitch()]);
} }
@@ -108,7 +108,7 @@ public abstract class CameraMixin implements RSClient
@Inject @Inject
static void onPitchCosChanged(int idx) static void onPitchCosChanged(int idx)
{ {
if (pitchRelaxEnabled && isDrawingRegion) if (pitchRelaxEnabled && isDrawingScene)
{ {
client.setPitchCos(Perspective.COSINE[client.getCameraPitch()]); client.setPitchCos(Perspective.COSINE[client.getCameraPitch()]);
} }

View File

@@ -34,11 +34,11 @@ import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNPC; import net.runelite.rs.api.RSNPC;
import net.runelite.rs.api.RSPlayer; import net.runelite.rs.api.RSPlayer;
import net.runelite.rs.api.RSProjectile; import net.runelite.rs.api.RSProjectile;
import net.runelite.rs.api.RSRegion; import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSRenderable; import net.runelite.rs.api.RSRenderable;
@Mixin(RSRegion.class) @Mixin(RSScene.class)
public abstract class EntityHiderMixin implements RSRegion public abstract class EntityHiderMixin implements RSScene
{ {
@Shadow("clientInstance") @Shadow("clientInstance")
private static RSClient client; private static RSClient client;

View File

@@ -28,7 +28,7 @@ import static net.runelite.api.Perspective.SCENE_SIZE;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSRegion; import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSSpritePixels; import net.runelite.rs.api.RSSpritePixels;
@Mixin(RSClient.class) @Mixin(RSClient.class)
@@ -41,7 +41,7 @@ public abstract class MinimapMixin implements RSClient
RSSpritePixels ourSprite = createSpritePixels(new int[512 * 512], 512, 512); RSSpritePixels ourSprite = createSpritePixels(new int[512 * 512], 512, 512);
RSSpritePixels theirSprite = getMinimapSprite(); RSSpritePixels theirSprite = getMinimapSprite();
RSRegion region = getRegion(); RSScene scene = getScene();
int[] pixels = ourSprite.getPixels(); int[] pixels = ourSprite.getPixels();
byte[][][] tileSettings = getTileSettings(); byte[][][] tileSettings = getTileSettings();
@@ -58,12 +58,12 @@ public abstract class MinimapMixin implements RSClient
{ {
if ((tileSettings[z][y][x] & 24) == 0) if ((tileSettings[z][y][x] & 24) == 0)
{ {
region.drawTile(pixels, var4, 512, z, y, x); scene.drawTile(pixels, var4, 512, z, y, x);
} }
if (z < 3 && (tileSettings[z + 1][y][x] & 8) != 0) if (z < 3 && (tileSettings[z + 1][y][x] & 8) != 0)
{ {
region.drawTile(pixels, var4, 512, z + 1, y, x); scene.drawTile(pixels, var4, 512, z + 1, y, x);
} }
var4 += 4; var4 += 4;

View File

@@ -233,17 +233,17 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
@Override @Override
public Tile getSelectedRegionTile() public Tile getSelectedSceneTile()
{ {
int tileX = getSelectedRegionTileX(); int tileX = getSelectedSceneTileX();
int tileY = getSelectedRegionTileY(); int tileY = getSelectedSceneTileY();
if (tileX == -1 || tileY == -1) if (tileX == -1 || tileY == -1)
{ {
return null; return null;
} }
return getRegion().getTiles()[getPlane()][tileX][tileY]; return getScene().getTiles()[getPlane()][tileX][tileY];
} }
@Inject @Inject
@@ -590,11 +590,11 @@ public abstract class RSClientMixin implements RSClient
@Nullable @Nullable
public LocalPoint getLocalDestinationLocation() public LocalPoint getLocalDestinationLocation()
{ {
int regionX = getDestinationX(); int sceneX = getDestinationX();
int regionY = getDestinationY(); int sceneY = getDestinationY();
if (regionX != 0 && regionY != 0) if (sceneX != 0 && sceneY != 0)
{ {
return LocalPoint.fromRegion(regionX, regionY); return LocalPoint.fromScene(sceneX, sceneY);
} }
return null; return null;
} }
@@ -604,7 +604,7 @@ public abstract class RSClientMixin implements RSClient
public void changeMemoryMode(boolean lowMemory) public void changeMemoryMode(boolean lowMemory)
{ {
setLowMemory(lowMemory); setLowMemory(lowMemory);
setRegionLowMemory(lowMemory); setSceneLowMemory(lowMemory);
setAudioHighMemory(true); setAudioHighMemory(true);
setObjectCompositionLowDetail(lowMemory); setObjectCompositionLowDetail(lowMemory);
} }

View File

@@ -45,14 +45,14 @@ public abstract class RSGameObjectMixin implements RSGameObject
@Inject @Inject
@Override @Override
public Point getRegionMinLocation() public Point getSceneMinLocation()
{ {
return new Point(getRelativeX(), getRelativeY()); return new Point(getRelativeX(), getRelativeY());
} }
@Inject @Inject
@Override @Override
public Point getRegionMaxLocation() public Point getSceneMaxLocation()
{ {
return new Point(getOffsetX(), getOffsetY()); return new Point(getOffsetX(), getOffsetY());
} }

View File

@@ -36,33 +36,33 @@ import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDecorativeObject; import net.runelite.rs.api.RSDecorativeObject;
import net.runelite.rs.api.RSGroundObject; import net.runelite.rs.api.RSGroundObject;
import net.runelite.rs.api.RSItemLayer; import net.runelite.rs.api.RSItemLayer;
import net.runelite.rs.api.RSRegion; import net.runelite.rs.api.RSScene;
import net.runelite.rs.api.RSWallObject; import net.runelite.rs.api.RSWallObject;
@Mixin(RSRegion.class) @Mixin(RSScene.class)
public abstract class RSRegionMixin implements RSRegion public abstract class RSSceneMixin implements RSScene
{ {
@Shadow("clientInstance") @Shadow("clientInstance")
private static RSClient client; private static RSClient client;
@Inject @Inject
static boolean isDrawingRegion; static boolean isDrawingScene;
@Copy("drawRegion") @Copy("drawScene")
abstract void rs$drawRegion(int cameraX, int cameraY, int cameraZ, int cameraPitch, int cameraYaw, int plane); abstract void rs$drawScene(int cameraX, int cameraY, int cameraZ, int cameraPitch, int cameraYaw, int plane);
@Replace("drawRegion") @Replace("drawScene")
void rl$drawRegion(int cameraX, int cameraY, int cameraZ, int cameraPitch, int cameraYaw, int plane) void rl$drawScene(int cameraX, int cameraY, int cameraZ, int cameraPitch, int cameraYaw, int plane)
{ {
try try
{ {
isDrawingRegion = true; isDrawingScene = true;
rs$drawRegion(cameraX, cameraY, cameraZ, cameraPitch, cameraYaw, plane); rs$drawScene(cameraX, cameraY, cameraZ, cameraPitch, cameraYaw, plane);
client.getCallbacks().drawRegion(); client.getCallbacks().drawScene();
} }
finally finally
{ {
isDrawingRegion = false; isDrawingScene = false;
} }
} }

View File

@@ -87,12 +87,12 @@ public abstract class RSTileMixin implements RSTile
@Override @Override
public WorldPoint getWorldLocation() public WorldPoint getWorldLocation()
{ {
return WorldPoint.fromRegion(client, getX(), getY(), getPlane()); return WorldPoint.fromScene(client, getX(), getY(), getPlane());
} }
@Inject @Inject
@Override @Override
public Point getRegionLocation() public Point getSceneLocation()
{ {
return new Point(getX(), getY()); return new Point(getX(), getY());
} }
@@ -101,7 +101,7 @@ public abstract class RSTileMixin implements RSTile
@Override @Override
public LocalPoint getLocalLocation() public LocalPoint getLocalLocation()
{ {
return LocalPoint.fromRegion(getX(), getY()); return LocalPoint.fromScene(getX(), getY());
} }
@FieldHook("wallObject") @FieldHook("wallObject")
@@ -272,7 +272,7 @@ public abstract class RSTileMixin implements RSTile
{ {
if (client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOGGED_IN)
{ {
// during region loading this gets set to null 104x104 times // during loading this gets set to null 104x104 times
return; return;
} }
@@ -295,8 +295,8 @@ public abstract class RSTileMixin implements RSTile
int z = this.getPlane(); int z = this.getPlane();
int[][] collisionDataFlags = collisionData[z].getFlags(); int[][] collisionDataFlags = collisionData[z].getFlags();
Point p1 = this.getRegionLocation(); Point p1 = this.getSceneLocation();
Point p2 = other.getRegionLocation(); Point p2 = other.getSceneLocation();
if (p1.getX() == p2.getX() && p1.getY() == p2.getY()) if (p1.getX() == p2.getX() && p1.getY() == p2.getY())
{ {
return true; return true;

View File

@@ -131,11 +131,11 @@ public interface RSClient extends RSGameEngine, Client
@Override @Override
int getMouseCurrentButton(); int getMouseCurrentButton();
@Import("selectedRegionTileX") @Import("selectedSceneTileX")
int getSelectedRegionTileX(); int getSelectedSceneTileX();
@Import("selectedRegionTileY") @Import("selectedSceneTileY")
int getSelectedRegionTileY(); int getSelectedSceneTileY();
@Import("draggingWidget") @Import("draggingWidget")
@Override @Override
@@ -165,9 +165,9 @@ public interface RSClient extends RSGameEngine, Client
*/ */
RSWidget[] getGroup(int groupId); RSWidget[] getGroup(int groupId);
@Import("region") @Import("scene")
@Override @Override
RSRegion getRegion(); RSScene getScene();
@Import("localPlayer") @Import("localPlayer")
@Override @Override
@@ -460,8 +460,8 @@ public interface RSClient extends RSGameEngine, Client
@Import("lowMemory") @Import("lowMemory")
void setLowMemory(boolean lowMemory); void setLowMemory(boolean lowMemory);
@Import("regionLowMemory") @Import("sceneLowMemory")
void setRegionLowMemory(boolean lowMemory); void setSceneLowMemory(boolean lowMemory);
@Import("audioHighMemory") @Import("audioHighMemory")
void setAudioHighMemory(boolean highMemory); void setAudioHighMemory(boolean highMemory);

View File

@@ -24,11 +24,11 @@
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.api.Region; import net.runelite.api.Scene;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface RSRegion extends Region public interface RSScene extends Scene
{ {
@Import("objects") @Import("objects")
RSGameObject[] getObjects(); RSGameObject[] getObjects();