Search in sources :

Example 11 with Component

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

the class WidgetCloser method poll.

@Override
public void poll() {
    final List<Integer> w = new ArrayList<Integer>();
    if (!ctx.bot().allowTrades()) {
        for (final int e : Constants.WIDGETCLOSER_TRADE_ITEMS) {
            w.add(e);
        }
    }
    for (final int id : w) {
        final AtomicInteger a = attempts.get(id);
        if (a.get() >= 3) {
            continue;
        }
        final Component c = ctx.widgets.component(id >> 16, id & 0xffff);
        final Point p = c.screenPoint();
        if (c.visible() && c.click()) {
            if (Condition.wait(new Condition.Check() {

                @Override
                public boolean poll() {
                    return !c.visible() || !c.screenPoint().equals(p);
                }
            })) {
                a.set(0);
            } else {
                a.incrementAndGet();
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Condition(org.powerbot.script.Condition) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(org.powerbot.script.rt4.Component) Point(java.awt.Point)

Aggregations

Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 Condition (org.powerbot.script.Condition)4 Component (org.sbolstandard.core2.Component)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Component (org.powerbot.script.rt4.Component)2 Item (org.powerbot.script.rt6.Item)2 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)2 SBOLDocument (org.sbolstandard.core2.SBOLDocument)2 Sequence (org.sbolstandard.core2.Sequence)2 Color (java.awt.Color)1 Rectangle (java.awt.Rectangle)1 Client (org.powerbot.bot.rt6.client.Client)1 Action (org.powerbot.script.rt6.Action)1 CollisionFlag (org.powerbot.script.rt6.CollisionFlag)1