Merge remote-tracking branch 'adam/tile-events'

This commit is contained in:
Adam
2018-01-30 17:45:29 -05:00
15 changed files with 451 additions and 121 deletions

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018, 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.api.events;
import lombok.Data;
import net.runelite.api.GameObject;
import net.runelite.api.Tile;
@Data
public class GameObjectChanged
{
private Tile tile;
private GameObject previous;
private GameObject gameObject;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018, 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.api.events;
import lombok.Data;
import net.runelite.api.GameObject;
import net.runelite.api.Tile;
@Data
public class GameObjectDespawned
{
private Tile tile;
private GameObject gameObject;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Robin Weymans <Robin.weymans@gmail.com>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,11 @@ package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.GameObject;
import net.runelite.api.Tile;
@Data
public class GameObjectsChanged
public class GameObjectSpawned
{
private Tile tile;
private GameObject gameObject;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018, 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.api.events;
import lombok.Data;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
@Data
public class WallObjectChanged
{
private Tile tile;
private WallObject previous;
private WallObject wallObject;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018, 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.api.events;
import lombok.Data;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
@Data
public class WallObjectDespawned
{
private Tile tile;
private WallObject wallObject;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018, 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.api.events;
import lombok.Data;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
@Data
public class WallObjectSpawned
{
private Tile tile;
private WallObject wallObject;
}

View File

@@ -41,7 +41,7 @@ import net.runelite.api.Projectile;
import static net.runelite.api.ProjectileID.CANNONBALL;
import static net.runelite.api.ProjectileID.GRANITE_CANNONBALL;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameObjectsChanged;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.ProjectileMoved;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
@@ -94,7 +94,7 @@ public class CannonPlugin extends Plugin
}
@Subscribe
public void onGameObjectsChanged(GameObjectsChanged event)
public void onGameObjectSpawned(GameObjectSpawned event)
{
GameObject gameObject = event.getGameObject();

View File

@@ -49,7 +49,7 @@ import net.runelite.api.queries.GameObjectQuery;
import net.runelite.api.queries.PlayerQuery;
import net.runelite.client.config.ConfigManager;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameObjectsChanged;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -107,7 +107,7 @@ public class HunterPlugin extends Plugin
}
@Subscribe
public void onGameObjectsChanged(GameObjectsChanged event)
public void onGameObjectSpawned(GameObjectSpawned event)
{
if (!config.enabled())
{
@@ -285,6 +285,7 @@ public class HunterPlugin extends Plugin
}
//Check if all traps are still there, and remove the ones that are not.
//TODO: use despawn events
Iterator<HunterTrap> it = traps.iterator();
while (it.hasNext())
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ public interface MotherlodeConfig extends Config
)
default boolean enabled()
{
return false;
return true;
}
@ConfigItem(

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,21 +24,15 @@
*/
package net.runelite.client.plugins.motherlode;
import net.runelite.api.Client;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import javax.inject.Inject;
import com.google.common.collect.Sets;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_ADAMANT;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BLACK;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BRONZE;
@@ -49,11 +43,14 @@ import static net.runelite.api.AnimationID.MINING_MOTHERLODE_IRON;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_MITHRIL;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_RUNE;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_STEEL;
import net.runelite.api.Client;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
class MotherlodeOverlay extends Overlay
{
private static final List<Integer> MINING_ANIMATION_IDS = Arrays.asList
(
private static final Set<Integer> MINING_ANIMATION_IDS = Sets.newHashSet(
MINING_MOTHERLODE_BRONZE, MINING_MOTHERLODE_IRON, MINING_MOTHERLODE_STEEL,
MINING_MOTHERLODE_BLACK, MINING_MOTHERLODE_MITHRIL, MINING_MOTHERLODE_ADAMANT,
MINING_MOTHERLODE_RUNE, MINING_MOTHERLODE_DRAGON, MINING_MOTHERLODE_DRAGON_ORN,
@@ -111,16 +108,15 @@ class MotherlodeOverlay extends Overlay
}
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt mined:",
Integer.toString(session.getTotalMined())
"Pay-dirt mined:",
Integer.toString(session.getTotalMined())
));
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt/hr:",
session.getRecentMined() > 2
? Integer.toString(session.getPerHour())
: ""
"Pay-dirt/hr:",
session.getRecentMined() > 2
? Integer.toString(session.getPerHour())
: ""
));
return panelComponent.render(graphics, parent);

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,32 +25,54 @@
*/
package net.runelite.client.plugins.motherlode;
import com.google.common.collect.Sets;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Binder;
import com.google.inject.Provides;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule;
import net.runelite.client.ui.overlay.Overlay;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import java.awt.image.BufferedImage;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import static net.runelite.api.ObjectID.ORE_VEIN_26661;
import static net.runelite.api.ObjectID.ORE_VEIN_26662;
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
import static net.runelite.api.ObjectID.ORE_VEIN_26664;
import static net.runelite.api.ObjectID.ROCKFALL;
import static net.runelite.api.ObjectID.ROCKFALL_26680;
import net.runelite.api.WallObject;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameObjectChanged;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.WallObjectChanged;
import net.runelite.api.events.WallObjectDespawned;
import net.runelite.api.events.WallObjectSpawned;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule;
import net.runelite.client.ui.overlay.Overlay;
@PluginDescriptor(
name = "Motherlode plugin"
)
public class MotherlodePlugin extends Plugin
{
private static final Set<Integer> MINE_SPOTS = Sets.newHashSet(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664);
private static final Set<Integer> ROCK_OBSTACLES = Sets.newHashSet(ROCKFALL, ROCKFALL_26680);
@Getter
private BufferedImage mineIcon;
@@ -67,6 +90,11 @@ public class MotherlodePlugin extends Plugin
private final MotherlodeSession session = new MotherlodeSession();
@Getter(AccessLevel.PACKAGE)
private final Set<WallObject> veins = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Set<GameObject> rocks = new HashSet<>();
@Override
public void configure(Binder binder)
{
@@ -129,4 +157,76 @@ public class MotherlodePlugin extends Plugin
session.resetRecent();
}
}
@Subscribe
public void onWallObjectSpanwed(WallObjectSpawned event)
{
WallObject wallObject = event.getWallObject();
if (MINE_SPOTS.contains(wallObject.getId()))
{
veins.add(wallObject);
}
}
@Subscribe
public void onWallObjectChanged(WallObjectChanged event)
{
WallObject previous = event.getPrevious();
WallObject wallObject = event.getWallObject();
veins.remove(previous);
if (MINE_SPOTS.contains(wallObject.getId()))
{
veins.add(wallObject);
}
}
@Subscribe
public void onWallObjectDespawned(WallObjectDespawned event)
{
WallObject wallObject = event.getWallObject();
veins.remove(wallObject);
}
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
GameObject gameObject = event.getGameObject();
if (ROCK_OBSTACLES.contains(gameObject.getId()))
{
rocks.add(gameObject);
}
}
@Subscribe
public void onGameObjectChanged(GameObjectChanged event)
{
GameObject previous = event.getPrevious();
GameObject gameObject = event.getGameObject();
rocks.remove(previous);
if (ROCK_OBSTACLES.contains(gameObject.getId()))
{
rocks.add(gameObject);
}
}
@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event)
{
GameObject gameObject = event.getGameObject();
rocks.remove(gameObject);
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOADING)
{
// on region changes the tiles get set to null
veins.clear();
rocks.clear();
}
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,43 +25,26 @@
*/
package net.runelite.client.plugins.motherlode;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.Region;
import net.runelite.api.Tile;
import net.runelite.api.Point;
import net.runelite.api.WallObject;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.util.Arrays;
import java.util.List;
import static net.runelite.api.ObjectID.ORE_VEIN_26661;
import static net.runelite.api.ObjectID.ORE_VEIN_26662;
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
import static net.runelite.api.ObjectID.ORE_VEIN_26664;
import static net.runelite.api.ObjectID.ROCKFALL;
import static net.runelite.api.ObjectID.ROCKFALL_26680;
class MotherlodeRocksOverlay extends Overlay
{
private static final int REGION_SIZE = 104;
private static final int MAX_DISTANCE = 2350;
private static final List<Integer> MINE_SPOTS = Arrays.asList(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664);
private static final List<Integer> ROCK_OBSTACLES = Arrays.asList(ROCKFALL, ROCKFALL_26680);
private final Client client;
private final MotherlodePlugin plugin;
private final MotherlodeConfig config;
@@ -76,7 +60,7 @@ class MotherlodeRocksOverlay extends Overlay
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
public Dimension render(Graphics2D graphics, java.awt.Point parent)
{
if (!config.enabled() || !config.showRocks())
{
@@ -85,7 +69,6 @@ class MotherlodeRocksOverlay extends Overlay
Player local = client.getLocalPlayer();
//Render mining spot
renderTiles(graphics, local);
return null;
@@ -93,57 +76,43 @@ class MotherlodeRocksOverlay extends Overlay
private void renderTiles(Graphics2D graphics, Player local)
{
Region region = client.getRegion();
Tile[][][] tiles = region.getTiles();
int z = client.getPlane();
for (int x = 0; x < REGION_SIZE; ++x)
Point localLocation = local.getLocalLocation();
for (WallObject vein : plugin.getVeins())
{
for (int y = 0; y < REGION_SIZE; ++y)
Point location = vein.getLocalLocation();
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
{
Tile tile = tiles[z][x][y];
renderVein(graphics, vein);
}
}
if (tile == null)
{
continue;
}
if (local.getLocalLocation().distanceTo(tile.getLocalLocation()) <= MAX_DISTANCE)
{
renderMine(graphics, tile);
}
for (GameObject rock : plugin.getRocks())
{
Point location = rock.getLocalLocation();
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
{
renderRock(graphics, rock);
}
}
}
private void renderMine(Graphics2D graphics, Tile tile)
private void renderVein(Graphics2D graphics, WallObject vein)
{
//Draw the Pay-dirt spots
WallObject wallObject = tile.getWallObject();
if (wallObject != null && MINE_SPOTS.contains(wallObject.getId()))
{
net.runelite.api.Point canvasLoc = Perspective.getCanvasImageLocation(client, graphics, wallObject.getLocalLocation(), plugin.getMineIcon(), 150);
Point canvasLoc = Perspective.getCanvasImageLocation(client, graphics, vein.getLocalLocation(), plugin.getMineIcon(), 150);
if (canvasLoc != null)
{
graphics.drawImage(plugin.getMineIcon(), canvasLoc.getX(), canvasLoc.getY(), null);
return;
}
if (canvasLoc != null)
{
graphics.drawImage(plugin.getMineIcon(), canvasLoc.getX(), canvasLoc.getY(), null);
}
}
//Draw the rock obstacles
GameObject[] gameObjects = tile.getGameObjects();
for (GameObject gameObject : gameObjects)
private void renderRock(Graphics2D graphics, GameObject rock)
{
Polygon poly = Perspective.getCanvasTilePoly(client, rock.getLocalLocation());
if (poly != null)
{
if (gameObject != null && ROCK_OBSTACLES.contains(gameObject.getId()))
{
Polygon poly = Perspective.getCanvasTilePoly(client, gameObject.getLocalLocation());
if (poly != null)
{
OverlayUtil.renderPolygon(graphics, poly, Color.red);
}
}
OverlayUtil.renderPolygon(graphics, poly, Color.red);
}
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,6 +25,10 @@
*/
package net.runelite.client.plugins.motherlode;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.Varbits;
import net.runelite.api.widgets.Widget;
@@ -32,11 +37,6 @@ import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import javax.inject.Inject;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
class MotherlodeSackOverlay extends Overlay
{
private final Client client;
@@ -70,8 +70,8 @@ class MotherlodeSackOverlay extends Overlay
if (config.showSack())
{
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt in sack:",
String.valueOf(client.getSetting(Varbits.SACK_NUMBER))
"Pay-dirt in sack:",
String.valueOf(client.getSetting(Varbits.SACK_NUMBER))
));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -24,16 +24,24 @@
*/
package net.runelite.mixins;
import net.runelite.api.Actor;
import net.runelite.api.GameObject;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.WallObject;
import net.runelite.api.events.GameObjectChanged;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.WallObjectChanged;
import net.runelite.api.events.WallObjectDespawned;
import net.runelite.api.events.WallObjectSpawned;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.api.events.GameObjectsChanged;
import static net.runelite.client.callback.Hooks.eventBus;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSTile;
@Mixin(RSTile.class)
@@ -42,6 +50,12 @@ public abstract class RSTileMixin implements RSTile
@Shadow("clientInstance")
private static RSClient client;
@Inject
private WallObject previousWallObject;
@Inject
private GameObject[] previousGameObjects;
@Inject
@Override
public Point getWorldLocation()
@@ -65,18 +79,84 @@ public abstract class RSTileMixin implements RSTile
return Perspective.regionToLocal(client, regionLocation);
}
@FieldHook("wallObject")
@Inject
public void wallObjectChanged(int idx)
{
WallObject previous = previousWallObject;
WallObject current = getWallObject();
previousWallObject = current;
if (current == null && previous != null)
{
WallObjectDespawned wallObjectDespawned = new WallObjectDespawned();
wallObjectDespawned.setTile(this);
wallObjectDespawned.setWallObject(previous);
eventBus.post(wallObjectDespawned);
}
else if (current != null && previous == null)
{
WallObjectSpawned wallObjectSpawned = new WallObjectSpawned();
wallObjectSpawned.setTile(this);
wallObjectSpawned.setWallObject(current);
eventBus.post(wallObjectSpawned);
}
else if (current != null && previous != null)
{
WallObjectChanged wallObjectChanged = new WallObjectChanged();
wallObjectChanged.setTile(this);
wallObjectChanged.setPrevious(previous);
wallObjectChanged.setWallObject(current);
eventBus.post(wallObjectChanged);
}
}
@FieldHook("objects")
@Inject
public void animationChanged(int idx)
public void gameObjectsChanged(int idx)
{
if (idx != -1) // this happens from the field assignment
if (idx == -1) // this happens from the field assignment
{
// GameObject that was changed.
GameObject go = getGameObjects()[idx];
if (go != null)
return;
}
if (previousGameObjects == null)
{
previousGameObjects = new GameObject[5];
}
// Previous game object
GameObject previous = previousGameObjects[idx];
// GameObject that was changed.
RSGameObject current = (RSGameObject) getGameObjects()[idx];
// Update previous object to current
previousGameObjects[idx] = current;
// Characters seem to generate a constant stream of new GameObjects
if (current == null || !(current.getRenderable() instanceof Actor))
{
if (current == null && previous != null)
{
GameObjectsChanged gameObjectsChanged = new GameObjectsChanged();
gameObjectsChanged.setGameObject(go);
GameObjectDespawned gameObjectDespawned = new GameObjectDespawned();
gameObjectDespawned.setTile(this);
gameObjectDespawned.setGameObject(previous);
eventBus.post(gameObjectDespawned);
}
else if (current != null && previous == null)
{
GameObjectSpawned gameObjectSpawned = new GameObjectSpawned();
gameObjectSpawned.setTile(this);
gameObjectSpawned.setGameObject(current);
eventBus.post(gameObjectSpawned);
}
else if (current != null && previous != null)
{
GameObjectChanged gameObjectsChanged = new GameObjectChanged();
gameObjectsChanged.setTile(this);
gameObjectsChanged.setPrevious(previous);
gameObjectsChanged.setGameObject(current);
eventBus.post(gameObjectsChanged);
}
}