Merge pull request #38 from KronosDesign/pest-control-plugin
Added plugin for Pest Control
This commit is contained in:
@@ -40,6 +40,7 @@ import net.runelite.client.plugins.hiscore.Hiscore;
|
||||
import net.runelite.client.plugins.idlenotifier.IdleNotifier;
|
||||
import net.runelite.client.plugins.mousehighlight.MouseHighlight;
|
||||
import net.runelite.client.plugins.opponentinfo.OpponentInfo;
|
||||
import net.runelite.client.plugins.pestcontrol.PestControl;
|
||||
import net.runelite.client.plugins.runecraft.Runecraft;
|
||||
import net.runelite.client.plugins.xtea.Xtea;
|
||||
import org.slf4j.Logger;
|
||||
@@ -69,6 +70,7 @@ public class PluginManager
|
||||
plugins.add(new IdleNotifier());
|
||||
plugins.add(new Runecraft());
|
||||
plugins.add(new MouseHighlight());
|
||||
plugins.add(new PestControl());
|
||||
|
||||
if (RuneLite.getOptions().has("developer-mode"))
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DevTools extends Plugin
|
||||
|
||||
ui.getNavigationPanel().addNavigation(navButton);
|
||||
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("runescape.ttf"));
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/runescape.ttf"));
|
||||
|
||||
font = font.deriveFont(Font.PLAIN, 16);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.BLUE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.RED;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Game
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Game.class);
|
||||
|
||||
// Game starts with all possible rotations
|
||||
private Rotation[] possibleRotations = Rotation.values();
|
||||
// Number of shields dropped
|
||||
private int shieldsDropped;
|
||||
|
||||
private final PortalContext purple = new PortalContext(PURPLE);
|
||||
private final PortalContext blue = new PortalContext(BLUE);
|
||||
private final PortalContext yellow = new PortalContext(YELLOW);
|
||||
private final PortalContext red = new PortalContext(RED);
|
||||
|
||||
public void fall(PortalContext portal)
|
||||
{
|
||||
if (!portal.isShielded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug("Shield dropped for {}", portal.getPortal());
|
||||
|
||||
portal.setIsShielded(false);
|
||||
int shieldDrop = shieldsDropped++;
|
||||
|
||||
// Remove impossible rotations
|
||||
List<Rotation> rotations = new ArrayList<>();
|
||||
|
||||
for (Rotation rotation : possibleRotations)
|
||||
{
|
||||
if (rotation.getPortal(shieldDrop) == portal.getPortal())
|
||||
{
|
||||
rotations.add(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
possibleRotations = rotations.toArray(new Rotation[rotations.size()]);
|
||||
}
|
||||
|
||||
public void die(PortalContext portal)
|
||||
{
|
||||
if (portal.isIsDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug("Portal {} died", portal.getPortal());
|
||||
|
||||
portal.setIsDead(true);
|
||||
}
|
||||
|
||||
public Collection<Portal> getNextPortals()
|
||||
{
|
||||
List<Portal> portals = new ArrayList<>();
|
||||
|
||||
for (Rotation rotation : possibleRotations)
|
||||
{
|
||||
Portal portal = rotation.getPortal(shieldsDropped);
|
||||
|
||||
if (portal != null && !portals.contains(portal))
|
||||
{
|
||||
portals.add(portal);
|
||||
}
|
||||
}
|
||||
|
||||
return portals;
|
||||
}
|
||||
|
||||
public PortalContext getPurple()
|
||||
{
|
||||
return purple;
|
||||
}
|
||||
|
||||
public PortalContext getBlue()
|
||||
{
|
||||
return blue;
|
||||
}
|
||||
|
||||
public PortalContext getYellow()
|
||||
{
|
||||
return yellow;
|
||||
}
|
||||
|
||||
public PortalContext getRed()
|
||||
{
|
||||
return red;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Kronos <https://github.com/KronosDesign>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
public class PestControl extends Plugin
|
||||
{
|
||||
private final Overlay overlay = new PestControlOverlay(this);
|
||||
|
||||
private Font font;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/runescape.ttf"));
|
||||
font = font.deriveFont(Font.BOLD, 16);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
ge.registerFont(font);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
|
||||
public Font getFont()
|
||||
{
|
||||
return font;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Kronos <https://github.com/KronosDesign>
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.RuneLite;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.BLUE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.RED;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PestControlOverlay extends Overlay
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(PestControlOverlay.class);
|
||||
|
||||
private final Client client = RuneLite.getClient();
|
||||
private final PestControl plugin;
|
||||
|
||||
// Pest control game
|
||||
private Game game;
|
||||
|
||||
public PestControlOverlay(PestControl plugin)
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// See if we are in a game or not
|
||||
if (client.getWidget(WidgetInfo.PESTCONTROL_BLUE_SHIELD) == null)
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
logger.debug("Pest control game has ended");
|
||||
game = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (game == null)
|
||||
{
|
||||
logger.debug("Pest control game has started");
|
||||
game = new Game();
|
||||
}
|
||||
|
||||
Font font = plugin.getFont();
|
||||
if (font != null)
|
||||
{
|
||||
graphics.setFont(font);
|
||||
}
|
||||
|
||||
renderSpinners(graphics);
|
||||
renderPortalWidgets(graphics);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderSpinners(Graphics2D graphics)
|
||||
{
|
||||
NPC[] npcs = client.getNpcs();
|
||||
if (npcs == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (NPC npc : npcs)
|
||||
{
|
||||
if (npc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = npc.getName();
|
||||
|
||||
if (name.toLowerCase().contains("spinner"))
|
||||
{
|
||||
renderActorOverlay(graphics, npc, name, Color.CYAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPortalWidgets(Graphics2D graphics)
|
||||
{
|
||||
PortalContext purple = game.getPurple();
|
||||
PortalContext blue = game.getBlue();
|
||||
PortalContext yellow = game.getYellow();
|
||||
PortalContext red = game.getRed();
|
||||
|
||||
Widget purpleShield = client.getWidget(PURPLE.getShield());
|
||||
Widget blueShield = client.getWidget(BLUE.getShield());
|
||||
Widget yellowShield = client.getWidget(YELLOW.getShield());
|
||||
Widget redShield = client.getWidget(RED.getShield());
|
||||
|
||||
Widget purpleHealth = client.getWidget(PURPLE.getHitpoints());
|
||||
Widget blueHealth = client.getWidget(BLUE.getHitpoints());
|
||||
Widget yellowHealth = client.getWidget(YELLOW.getHitpoints());
|
||||
Widget redHealth = client.getWidget(RED.getHitpoints());
|
||||
|
||||
assert purpleShield != null;
|
||||
assert blueShield != null;
|
||||
assert yellowShield != null;
|
||||
assert redShield != null;
|
||||
|
||||
// Check for fallen portals
|
||||
if (purpleShield.isHidden())
|
||||
{
|
||||
game.fall(purple);
|
||||
}
|
||||
if (blueShield.isHidden())
|
||||
{
|
||||
game.fall(blue);
|
||||
}
|
||||
if (yellowShield.isHidden())
|
||||
{
|
||||
game.fall(yellow);
|
||||
}
|
||||
if (redShield.isHidden())
|
||||
{
|
||||
game.fall(red);
|
||||
}
|
||||
|
||||
// Check for dead portals
|
||||
if (isZero(purpleHealth))
|
||||
{
|
||||
game.die(purple);
|
||||
}
|
||||
if (isZero(blueHealth))
|
||||
{
|
||||
game.die(blue);
|
||||
}
|
||||
if (isZero(yellowHealth))
|
||||
{
|
||||
game.die(yellow);
|
||||
}
|
||||
if (isZero(redHealth))
|
||||
{
|
||||
game.die(red);
|
||||
}
|
||||
|
||||
// display "ATK" overlay on recorded portals without shields
|
||||
renderAttack(graphics, purple);
|
||||
renderAttack(graphics, blue);
|
||||
renderAttack(graphics, yellow);
|
||||
renderAttack(graphics, red);
|
||||
|
||||
// display "NEXT" overlay on predicted portals
|
||||
for (Portal portal : game.getNextPortals())
|
||||
{
|
||||
renderWidgetOverlay(graphics, portal, "NEXT", Color.ORANGE);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderActorOverlay(Graphics2D graphics, Actor actor, String text, Color color)
|
||||
{
|
||||
Polygon poly = actor.getCanvasTilePoly();
|
||||
if (poly != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.drawPolygon(poly);
|
||||
graphics.setColor(new Color(0, 0, 0, 50));
|
||||
graphics.fillPolygon(poly);
|
||||
}
|
||||
|
||||
Point minimapLocation = actor.getMinimapLocation();
|
||||
if (minimapLocation != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.setStroke(new BasicStroke(1));
|
||||
graphics.drawOval(minimapLocation.getX(), minimapLocation.getY(), 5, 5);
|
||||
}
|
||||
|
||||
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getModelHeight() + 40);
|
||||
if (textLocation != null)
|
||||
{
|
||||
int x = textLocation.getX();
|
||||
int y = textLocation.getY();
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, x + 1, y + 1);
|
||||
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderWidgetOverlay(Graphics2D graphics, Portal portal, String text, Color color)
|
||||
{
|
||||
Widget shield = client.getWidget(portal.getShield());
|
||||
Widget icon = client.getWidget(portal.getIcon());
|
||||
|
||||
// create one rectangle from two different widget bounds
|
||||
Rectangle2D bounds = union(shield.getBounds().getBounds2D(), icon.getBounds().getBounds2D());
|
||||
graphics.setColor(color);
|
||||
graphics.draw(bounds);
|
||||
|
||||
FontMetrics fm = graphics.getFontMetrics();
|
||||
Rectangle2D textBounds = fm.getStringBounds(text, graphics);
|
||||
int x = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
|
||||
int y = (int) (bounds.getY() + bounds.getHeight() + textBounds.getHeight());
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(text, x + 1, y + 1);
|
||||
graphics.setColor(color);
|
||||
graphics.drawString(text, x, y);
|
||||
}
|
||||
|
||||
private static Rectangle2D union(Rectangle2D src1, Rectangle2D src2)
|
||||
{
|
||||
double x1 = Math.min(src1.getMinX(), src2.getMinX());
|
||||
double y1 = Math.min(src1.getMinY(), src2.getMinY());
|
||||
double x2 = Math.max(src1.getMaxX(), src2.getMaxX());
|
||||
double y2 = Math.max(src1.getMaxY(), src2.getMaxY());
|
||||
|
||||
Rectangle2D result = new Rectangle2D.Double();
|
||||
result.setFrameFromDiagonal(x1, y1, x2, y2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void renderAttack(Graphics2D graphics, PortalContext portal)
|
||||
{
|
||||
if (portal.isShielded() || portal.isIsDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
renderWidgetOverlay(graphics, portal.getPortal(), "ATK", Color.RED);
|
||||
}
|
||||
|
||||
private static boolean isZero(Widget widget)
|
||||
{
|
||||
return widget.getText().trim().equals("0");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
|
||||
public enum Portal
|
||||
{
|
||||
PURPLE(WidgetInfo.PESTCONTROL_PURPLE_SHIELD, WidgetInfo.PESTCONTROL_PURPLE_HEALTH, WidgetInfo.PESTCONTROL_PURPLE_ICON),
|
||||
BLUE(WidgetInfo.PESTCONTROL_BLUE_SHIELD, WidgetInfo.PESTCONTROL_BLUE_HEALTH, WidgetInfo.PESTCONTROL_BLUE_ICON),
|
||||
YELLOW(WidgetInfo.PESTCONTROL_YELLOW_SHIELD, WidgetInfo.PESTCONTROL_YELLOW_HEALTH, WidgetInfo.PESTCONTROL_YELLOW_ICON),
|
||||
RED(WidgetInfo.PESTCONTROL_RED_SHIELD, WidgetInfo.PESTCONTROL_RED_HEALTH, WidgetInfo.PESTCONTROL_RED_ICON);
|
||||
|
||||
private final WidgetInfo shield;
|
||||
private final WidgetInfo hitpoints;
|
||||
private final WidgetInfo icon;
|
||||
|
||||
private Portal(WidgetInfo shield, WidgetInfo hitpoints, WidgetInfo icon)
|
||||
{
|
||||
this.shield = shield;
|
||||
this.hitpoints = hitpoints;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Portal(" + name() + ")";
|
||||
}
|
||||
|
||||
public WidgetInfo getShield()
|
||||
{
|
||||
return shield;
|
||||
}
|
||||
|
||||
public WidgetInfo getHitpoints()
|
||||
{
|
||||
return hitpoints;
|
||||
}
|
||||
|
||||
public WidgetInfo getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
|
||||
public class PortalContext
|
||||
{
|
||||
private final Portal portal;
|
||||
private boolean isShielded = true;
|
||||
private boolean isDead;
|
||||
|
||||
public PortalContext(Portal portal)
|
||||
{
|
||||
this.portal = portal;
|
||||
}
|
||||
|
||||
public Portal getPortal()
|
||||
{
|
||||
return portal;
|
||||
}
|
||||
|
||||
public boolean isShielded()
|
||||
{
|
||||
return isShielded;
|
||||
}
|
||||
|
||||
public void setIsShielded(boolean isShielded)
|
||||
{
|
||||
this.isShielded = isShielded;
|
||||
}
|
||||
|
||||
public boolean isIsDead()
|
||||
{
|
||||
return isDead;
|
||||
}
|
||||
|
||||
public void setIsDead(boolean isDead)
|
||||
{
|
||||
this.isDead = isDead;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.pestcontrol;
|
||||
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.BLUE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.RED;
|
||||
import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW;
|
||||
|
||||
public enum Rotation
|
||||
{
|
||||
PBYR(PURPLE, BLUE, YELLOW, RED),
|
||||
PYBR(PURPLE, YELLOW, BLUE, RED),
|
||||
BRYP(BLUE, RED, YELLOW, PURPLE),
|
||||
BPRY(BLUE, PURPLE, RED, YELLOW),
|
||||
YRPB(YELLOW, RED, PURPLE, BLUE),
|
||||
YPRB(YELLOW, PURPLE, RED, BLUE);
|
||||
|
||||
private final Portal[] portals;
|
||||
|
||||
private Rotation(Portal first, Portal second, Portal third, Portal fourth)
|
||||
{
|
||||
portals = new Portal[]
|
||||
{
|
||||
first, second, third, fourth
|
||||
};
|
||||
}
|
||||
|
||||
public Portal getPortal(int index)
|
||||
{
|
||||
if (index < 0 || index >= portals.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return portals[index];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user