Search in sources :

Example 26 with Player

use of org.powerbot.script.rt4.Player in project powerbot by powerbot.

the class TPlayer method draw.

public int draw(int idx, final Graphics render) {
    final Player player = ctx.players.local();
    drawLine(render, idx++, String.format("[%s] A: %d, CBL: %d, HP: %d, T: %d, S: %d, INT: %s", player.name(), player.animation(), player.combatLevel(), player.healthPercent(), player.team(), player.speed(), player.interacting()));
    drawLine(render, idx++, String.format("ORIENT: %d, COMBAT: %s, APP (VE): %s", player.orientation(), Boolean.toString(player.inCombat()), Arrays.toString(player.appearance())));
    return idx;
}
Also used : Player(org.powerbot.script.rt6.Player)

Example 27 with Player

use of org.powerbot.script.rt4.Player in project powerbot by powerbot.

the class DrawGroundItems method repaint.

public void repaint(final Graphics render) {
    if (ctx.game.clientState() != Constants.GAME_LOADED) {
        return;
    }
    final Player player = ctx.players.local();
    if (player == null) {
        return;
    }
    final Tile tile = player.tile();
    if (tile == null) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    final int tHeight = metrics.getHeight();
    final List<GroundItem> check = new ArrayList<GroundItem>();
    ctx.groundItems.select(10).addTo(check);
    for (int x = -10; x <= 10; x++) {
        for (int y = -10; y <= 10; y++) {
            int d = 0;
            final Tile loc = tile.derive(x, y);
            final Point screen = new TileMatrix(ctx, loc).centerPoint();
            if (screen.x == -1) {
                continue;
            }
            for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
                final String name = groundItem.name();
                String s = "";
                s += groundItem.id();
                if (!name.isEmpty()) {
                    s += " " + name;
                }
                final int stack = groundItem.stackSize();
                if (stack > 1) {
                    s += " (" + stack + ")";
                }
                final int ty = screen.y - tHeight * (++d) + tHeight / 2;
                final int tx = screen.x - metrics.stringWidth(s) / 2;
                render.setColor(Color.green);
                render.drawString(s, tx, ty);
            }
        }
    }
}
Also used : Player(org.powerbot.script.rt4.Player) FontMetrics(java.awt.FontMetrics) GroundItem(org.powerbot.script.rt4.GroundItem) ArrayList(java.util.ArrayList) Tile(org.powerbot.script.Tile) Point(java.awt.Point) Point(java.awt.Point) TileMatrix(org.powerbot.script.rt4.TileMatrix)

Example 28 with Player

use of org.powerbot.script.rt4.Player in project powerbot by powerbot.

the class DrawPlayers method repaint.

@SuppressWarnings("deprecation")
public void repaint(final Graphics render) {
    if (ctx.game.clientState() != Constants.GAME_LOADED) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    for (final Player player : ctx.players.select()) {
        final Point location = player.centerPoint();
        if (location.x == -1 || location.y == -1) {
            continue;
        }
        render.setColor(Color.RED);
        render.fillRect((int) location.getX() - 1, (int) location.getY() - 1, 2, 2);
        String s = player.name() + " (" + player.combatLevel() + " [" + player.health() + "])";
        render.setColor(player.inCombat() ? Color.RED : player.inMotion() ? Color.GREEN : Color.WHITE);
        render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() / 2);
        final String msg = player.overheadMessage();
        boolean raised = false;
        if (player.animation() != -1) {
            s = "";
            s += "(";
            if (player.animation() != -1) {
                s += "A: " + player.animation() + " | ST: -1 | ";
            }
            s = s.substring(0, s.lastIndexOf(" | "));
            s += ")";
            render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() * 3 / 2);
            raised = true;
        }
        if (msg != null) {
            render.setColor(Color.ORANGE);
            render.drawString(msg, location.x - metrics.stringWidth(msg) / 2, location.y - metrics.getHeight() * (raised ? 5 : 3) / 2);
        }
    }
}
Also used : Player(org.powerbot.script.rt4.Player) FontMetrics(java.awt.FontMetrics) Point(java.awt.Point)

Example 29 with Player

use of org.powerbot.script.rt4.Player in project ExoPlayer by google.

the class ImaAdsLoader method getCurrentAdTagLoader.

@Nullable
private AdTagLoader getCurrentAdTagLoader() {
    @Nullable Player player = this.player;
    if (player == null) {
        return null;
    }
    Timeline timeline = player.getCurrentTimeline();
    if (timeline.isEmpty()) {
        return null;
    }
    int periodIndex = player.getCurrentPeriodIndex();
    @Nullable Object adsId = timeline.getPeriod(periodIndex, period).getAdsId();
    if (adsId == null) {
        return null;
    }
    @Nullable AdTagLoader adTagLoader = adTagLoaderByAdsId.get(adsId);
    if (adTagLoader == null || !adTagLoaderByAdsMediaSource.containsValue(adTagLoader)) {
        return null;
    }
    return adTagLoader;
}
Also used : Player(com.google.android.exoplayer2.Player) VideoAdPlayer(com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer) Timeline(com.google.android.exoplayer2.Timeline) Nullable(androidx.annotation.Nullable) Nullable(androidx.annotation.Nullable)

Example 30 with Player

use of org.powerbot.script.rt4.Player in project ExoPlayer by google.

the class SessionPlayerConnectorTest method play_withForwardingPlayer_isSkipped.

@Test
@LargeTest
public void play_withForwardingPlayer_isSkipped() throws Exception {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    Player forwardingPlayer = null;
    SessionPlayerConnector playerConnector = null;
    try {
        Player exoPlayer = new ExoPlayer.Builder(context).setLooper(Looper.myLooper()).build();
        forwardingPlayer = new ForwardingPlayer(exoPlayer) {

            @Override
            public boolean isCommandAvailable(int command) {
                if (command == COMMAND_PLAY_PAUSE) {
                    return false;
                }
                return super.isCommandAvailable(command);
            }

            @Override
            public Commands getAvailableCommands() {
                return super.getAvailableCommands().buildUpon().remove(COMMAND_PLAY_PAUSE).build();
            }
        };
        playerConnector = new SessionPlayerConnector(forwardingPlayer);
        assertPlayerResult(playerConnector.play(), RESULT_INFO_SKIPPED);
    } finally {
        if (playerConnector != null) {
            playerConnector.close();
        }
        if (forwardingPlayer != null) {
            forwardingPlayer.release();
        }
    }
}
Also used : Player(com.google.android.exoplayer2.Player) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) SessionPlayer(androidx.media2.common.SessionPlayer) ForwardingPlayer(com.google.android.exoplayer2.ForwardingPlayer) ForwardingPlayer(com.google.android.exoplayer2.ForwardingPlayer) MediumTest(androidx.test.filters.MediumTest) LargeTest(androidx.test.filters.LargeTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Aggregations

Player (com.google.android.exoplayer2.Player)39 Nullable (androidx.annotation.Nullable)25 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)14 MediaItem (com.google.android.exoplayer2.MediaItem)11 Test (org.junit.Test)10 VideoAdPlayer (com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer)8 Timeline (com.google.android.exoplayer2.Timeline)8 Context (android.content.Context)6 ApplicationProvider (androidx.test.core.app.ApplicationProvider)6 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)6 ForwardingPlayer (com.google.android.exoplayer2.ForwardingPlayer)6 TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled (com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled)6 Tile (org.powerbot.script.Tile)6 SuppressLint (android.annotation.SuppressLint)5 Pair (android.util.Pair)5 Surface (android.view.Surface)5 SurfaceTexture (android.graphics.SurfaceTexture)4 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)4 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)4 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)4