Rename Point3D to WorldPoint

This commit is contained in:
Max Weber
2018-03-08 00:57:20 -07:00
parent 5e887ed11c
commit 6f9b855520
5 changed files with 33 additions and 18 deletions

View File

@@ -22,15 +22,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.api; package net.runelite.api.coords;
import lombok.Value; import lombok.Value;
import net.runelite.api.Point; import net.runelite.api.Point;
@Value @Value
public class Point3D public class WorldPoint
{ {
private final int X, Y, Z; /**
* The X coordinate of the Point.
* Units are in tiles
*/
private final int X;
/**
* The Y coordinate of the Point.
* Units are in tiles
*/
private final int Y;
/**
* The plane coordinate of the Point.
*/
private final int plane;
public Point toPoint() public Point toPoint()
{ {

View File

@@ -30,18 +30,18 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.Point3D; import net.runelite.api.coords.WorldPoint;
class Bookcase class Bookcase
{ {
public Bookcase(Point3D location) public Bookcase(WorldPoint location)
{ {
this.location = location; this.location = location;
this.index = new ArrayList<>(); this.index = new ArrayList<>();
} }
@Getter @Getter
private final Point3D location; private final WorldPoint location;
@Getter @Getter
private final List<Integer> index; private final List<Integer> index;
@@ -99,7 +99,7 @@ class Bookcase
b.append(" "); b.append(" ");
switch (location.getZ()) switch (location.getPlane())
{ {
case 0: case 0:
b.append("ground floor"); b.append("ground floor");

View File

@@ -40,7 +40,7 @@ import net.runelite.api.Client;
import net.runelite.api.Perspective; 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.Point3D; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
@@ -93,7 +93,7 @@ public class KourendLibraryOverlay extends Overlay
for (Bookcase bookcase : allBookcases) for (Bookcase bookcase : allBookcases)
{ {
// AABB // AABB
Point3D caseLoc = bookcase.getLocation(); WorldPoint caseLoc = bookcase.getLocation();
if (Math.abs(playerLoc.getX() - caseLoc.getX()) > MAXIMUM_DISTANCE if (Math.abs(playerLoc.getX() - caseLoc.getX()) > MAXIMUM_DISTANCE
|| Math.abs(playerLoc.getY() - caseLoc.getY()) > MAXIMUM_DISTANCE) || Math.abs(playerLoc.getY() - caseLoc.getY()) > MAXIMUM_DISTANCE)
{ {
@@ -101,7 +101,7 @@ public class KourendLibraryOverlay extends Overlay
} }
Point localBookcase = Perspective.worldToLocal(client, caseLoc.toPoint()); Point localBookcase = Perspective.worldToLocal(client, caseLoc.toPoint());
Point screenBookcase = Perspective.worldToCanvas(client, localBookcase.getX(), localBookcase.getY(), caseLoc.getZ(), 25); Point screenBookcase = Perspective.worldToCanvas(client, localBookcase.getX(), localBookcase.getY(), caseLoc.getPlane(), 25);
if (screenBookcase != null) if (screenBookcase != null)
{ {

View File

@@ -37,7 +37,7 @@ import net.runelite.api.Client;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.Point3D; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
@@ -73,8 +73,8 @@ public class KourendLibraryPlugin extends Plugin
private KourendLibraryPanel panel; private KourendLibraryPanel panel;
private NavigationButton navButton; private NavigationButton navButton;
private Point3D lastBookcaseClick = null; private WorldPoint lastBookcaseClick = null;
private Point3D lastBookcaseAnimatedOn = null; private WorldPoint lastBookcaseAnimatedOn = null;
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
@@ -115,7 +115,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"))
{ {
Point worldPoint = Perspective.regionToWorld(client, new Point(menuOpt.getId() & 127, menuOpt.getId() >> 7 & 127)); Point worldPoint = Perspective.regionToWorld(client, new Point(menuOpt.getId() & 127, menuOpt.getId() >> 7 & 127));
lastBookcaseClick = new Point3D(worldPoint.getX(), worldPoint.getY(), client.getPlane()); lastBookcaseClick = new WorldPoint(worldPoint.getX(), worldPoint.getY(), client.getPlane());
} }
} }

View File

@@ -35,7 +35,7 @@ import java.util.stream.IntStream;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Point3D; import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.kourendlibrary.Book.*; import static net.runelite.client.plugins.kourendlibrary.Book.*;
@@ -59,7 +59,7 @@ import static net.runelite.client.plugins.kourendlibrary.Book.*;
@Slf4j @Slf4j
public class Library public class Library
{ {
private final Map<Point3D, Bookcase> byPoint = new HashMap<>(); private final Map<WorldPoint, Bookcase> byPoint = new HashMap<>();
private final Map<Integer, ArrayList<Bookcase>> byLevel = new HashMap<>(); private final Map<Integer, ArrayList<Bookcase>> byLevel = new HashMap<>();
private final List<Bookcase> byIndex = new ArrayList<>(); private final List<Bookcase> byIndex = new ArrayList<>();
@@ -110,7 +110,7 @@ public class Library
log.info("Library is now reset"); log.info("Library is now reset");
} }
public synchronized void mark(Point3D loc, Book book) public synchronized void mark(WorldPoint loc, Book book)
{ {
Bookcase bookcase = byPoint.get(loc); Bookcase bookcase = byPoint.get(loc);
if (bookcase == null) if (bookcase == null)
@@ -428,7 +428,7 @@ public class Library
private void add(int x, int y, int z, int i) private void add(int x, int y, int z, int i)
{ {
// 'i' is added as a parameter for readability // 'i' is added as a parameter for readability
Point3D p = new Point3D(x, y, z); WorldPoint p = new WorldPoint(x, y, z);
Bookcase b = byPoint.get(p); Bookcase b = byPoint.get(p);
if (b == null) if (b == null)
{ {