use of net.runelite.api.Player in project runelite by runelite.
the class RSClientMixin method getPlayers.
@Inject
@Override
public List<Player> getPlayers() {
int validPlayerIndexes = getPlayerIndexesCount();
int[] playerIndexes = getPlayerIndices();
Player[] cachedPlayers = getCachedPlayers();
List<Player> players = new ArrayList<Player>(validPlayerIndexes);
for (int i = 0; i < validPlayerIndexes; ++i) {
players.add(cachedPlayers[playerIndexes[i]]);
}
return players;
}
use of net.runelite.api.Player in project runelite by runelite.
the class IdleNotifierPlugin method checkOutOfCombat.
private boolean checkOutOfCombat(Duration waitDuration, Player local) {
Actor opponent = local.getInteracting();
boolean isPlayer = opponent instanceof Player;
if (opponent != null && !isPlayer && opponent.getCombatLevel() > 0) {
resetTimers();
lastOpponent = opponent;
} else if (opponent == null) {
lastOpponent = null;
}
if (lastOpponent != null && opponent == lastOpponent) {
lastInteracting = Instant.now();
}
if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0) {
lastInteracting = null;
return true;
}
return false;
}
use of net.runelite.api.Player in project runelite by runelite.
the class MotherlodeRocksOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
if (!config.showRocks()) {
return null;
}
Player local = client.getLocalPlayer();
renderTiles(graphics, local);
return null;
}
use of net.runelite.api.Player in project runelite by runelite.
the class KourendLibraryOverlay method render.
@Override
public Dimension render(Graphics2D g) {
Player player = client.getLocalPlayer();
if (player == null) {
return null;
}
WorldPoint playerLoc = player.getWorldLocation();
if (playerLoc.distanceTo2D(LIBRARY_CENTER) > ROUGH_ENABLE_DISTANCE) {
return null;
}
List<Bookcase> allBookcases = library.getBookcasesOnLevel(client.getPlane());
if (allBookcases == null) {
return null;
}
for (Bookcase bookcase : allBookcases) {
// AABB
WorldPoint caseLoc = bookcase.getLocation();
if (Math.abs(playerLoc.getX() - caseLoc.getX()) > MAXIMUM_DISTANCE || Math.abs(playerLoc.getY() - caseLoc.getY()) > MAXIMUM_DISTANCE) {
continue;
}
LocalPoint localBookcase = LocalPoint.fromWorld(client, caseLoc);
if (localBookcase == null) {
continue;
}
Point screenBookcase = Perspective.worldToCanvas(client, localBookcase.getX(), localBookcase.getY(), caseLoc.getPlane(), 25);
if (screenBookcase != null) {
boolean bookIsKnown = bookcase.isBookSet();
Book book = bookcase.getBook();
Set<Book> possible = bookcase.getPossibleBooks();
if (bookIsKnown && book == null) {
for (Book b : possible) {
if (b != null && b.isDarkManuscript()) {
book = b;
break;
}
}
}
if (!bookIsKnown && possible.size() == 1) {
book = possible.iterator().next();
bookIsKnown = true;
}
Color color = bookIsKnown ? Color.ORANGE : Color.WHITE;
// Render the poly on the floor
if (!(bookIsKnown && book == null) && (library.getState() == SolvedState.NO_DATA || book != null || possible.size() > 0)) {
Polygon poly = getCanvasTilePoly(client, localBookcase);
if (poly != null) {
OverlayUtil.renderPolygon(g, poly, color);
}
}
int height = 0;
// If the book is singled out, render the text and the book's icon
if (bookIsKnown) {
if (book != null) {
FontMetrics fm = g.getFontMetrics();
Rectangle2D bounds = fm.getStringBounds(book.getShortName(), g);
height = (int) bounds.getHeight() + book.getIcon().getHeight() + 6;
Point textLoc = new Point((int) (screenBookcase.getX() - (bounds.getWidth() / 2)), screenBookcase.getY() - (height / 2) + (int) bounds.getHeight());
OverlayUtil.renderTextLocation(g, textLoc, book.getShortName(), color);
g.drawImage(book.getIcon(), screenBookcase.getX() - (book.getIcon().getWidth() / 2), screenBookcase.getY() + (height / 2) - book.getIcon().getHeight(), null);
}
} else {
// otherwise render up to 9 icons of the possible books in the bookcase in a square
final int BOOK_ICON_SIZE = 32;
Book[] books = possible.stream().filter(Objects::nonNull).limit(9).toArray(Book[]::new);
if (books.length > 1 && books.length <= 9) {
int cols = (int) Math.ceil(Math.sqrt(books.length));
int rows = (int) Math.ceil((double) books.length / cols);
height = rows * BOOK_ICON_SIZE;
int xbase = screenBookcase.getX() - ((cols * BOOK_ICON_SIZE) / 2);
int ybase = screenBookcase.getY() - rows * BOOK_ICON_SIZE / 2;
for (int i = 0; i < books.length; i++) {
int col = i % cols;
int row = i / cols;
int x = col * BOOK_ICON_SIZE;
int y = row * BOOK_ICON_SIZE;
if (row == rows - 1) {
x += (BOOK_ICON_SIZE * (books.length % rows)) / 2;
}
g.drawImage(books[i].getIcon(), xbase + x, ybase + y, null);
}
}
}
// Draw the bookcase's ID on top
if (KourendLibraryPlugin.debug) {
FontMetrics fm = g.getFontMetrics();
String str = bookcase.getIndex().stream().map(Object::toString).collect(Collectors.joining(", "));
Rectangle2D bounds = fm.getStringBounds(str, g);
Point textLoc = new Point((int) (screenBookcase.getX() - (bounds.getWidth() / 2)), screenBookcase.getY() - (height / 2));
OverlayUtil.renderTextLocation(g, textLoc, str, Color.WHITE);
}
}
}
// Render the customer's wanted book on their head and a poly under their feet
LibraryCustomer customer = library.getCustomer();
if (customer != null) {
client.getNpcs().stream().filter(n -> n.getId() == customer.getId()).forEach(n -> {
Book b = library.getCustomerBook();
LocalPoint local = n.getLocalLocation();
Polygon poly = getCanvasTilePoly(client, local);
OverlayUtil.renderPolygon(g, poly, Color.WHITE);
Point screen = Perspective.worldToCanvas(client, local.getX(), local.getY(), client.getPlane(), n.getLogicalHeight());
if (screen != null) {
g.drawImage(b.getIcon(), screen.getX() - (b.getIcon().getWidth() / 2), screen.getY() - b.getIcon().getHeight(), null);
}
});
}
return null;
}
use of net.runelite.api.Player in project runelite by runelite.
the class DevToolsOverlay method renderTileObjects.
private void renderTileObjects(Graphics2D graphics) {
Region region = client.getRegion();
Tile[][][] tiles = region.getTiles();
int z = client.getPlane();
for (int x = 0; x < REGION_SIZE; ++x) {
for (int y = 0; y < REGION_SIZE; ++y) {
Tile tile = tiles[z][x][y];
if (tile == null) {
continue;
}
Player player = client.getLocalPlayer();
if (player == null) {
continue;
}
if (plugin.isToggleGroundItems()) {
renderGroundItems(graphics, tile, player);
}
if (plugin.isToggleGroundObjects()) {
renderGroundObject(graphics, tile, player);
}
if (plugin.isToggleGameObjects()) {
renderGameObjects(graphics, tile, player);
}
if (plugin.isToggleWalls()) {
renderWallObject(graphics, tile, player);
}
if (plugin.isToggleDecor()) {
renderDecorObject(graphics, tile, player);
}
}
}
}
Aggregations