motherlode: Add overlay for broken water wheel struts
* Rename MotherlodeRocksOverlay to MotherlodeSceneOverlay * When strut is broken, red border with hammer icon will show around it.
This commit is contained in:
@@ -124,6 +124,16 @@ public interface MotherlodeConfig extends Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "showBrokenStruts",
|
||||||
|
name = "Show broken struts",
|
||||||
|
description = "Shows broken water wheel struts"
|
||||||
|
)
|
||||||
|
default boolean showBrokenStruts()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "showLootIcons",
|
keyName = "showLootIcons",
|
||||||
name = "Show ore icons",
|
name = "Show ore icons",
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import net.runelite.api.Item;
|
|||||||
import net.runelite.api.ItemContainer;
|
import net.runelite.api.ItemContainer;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
|
import static net.runelite.api.ObjectID.BROKEN_STRUT;
|
||||||
import static net.runelite.api.ObjectID.ORE_VEIN_26661;
|
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_26662;
|
||||||
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
|
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
|
||||||
@@ -109,7 +110,7 @@ public class MotherlodePlugin extends Plugin
|
|||||||
private MotherlodeOverlay overlay;
|
private MotherlodeOverlay overlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private MotherlodeRocksOverlay rocksOverlay;
|
private MotherlodeSceneOverlay sceneOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private MotherlodeSackOverlay motherlodeSackOverlay;
|
private MotherlodeSackOverlay motherlodeSackOverlay;
|
||||||
@@ -148,6 +149,8 @@ public class MotherlodePlugin extends Plugin
|
|||||||
private final Set<WallObject> veins = new HashSet<>();
|
private final Set<WallObject> veins = new HashSet<>();
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final Set<GameObject> rocks = new HashSet<>();
|
private final Set<GameObject> rocks = new HashSet<>();
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private final Set<GameObject> brokenStruts = new HashSet<>();
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
MotherlodeConfig getConfig(ConfigManager configManager)
|
MotherlodeConfig getConfig(ConfigManager configManager)
|
||||||
@@ -159,7 +162,7 @@ public class MotherlodePlugin extends Plugin
|
|||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
overlayManager.add(overlay);
|
overlayManager.add(overlay);
|
||||||
overlayManager.add(rocksOverlay);
|
overlayManager.add(sceneOverlay);
|
||||||
overlayManager.add(motherlodeGemOverlay);
|
overlayManager.add(motherlodeGemOverlay);
|
||||||
overlayManager.add(motherlodeOreOverlay);
|
overlayManager.add(motherlodeOreOverlay);
|
||||||
overlayManager.add(motherlodeSackOverlay);
|
overlayManager.add(motherlodeSackOverlay);
|
||||||
@@ -176,12 +179,13 @@ public class MotherlodePlugin extends Plugin
|
|||||||
protected void shutDown()
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
overlayManager.remove(rocksOverlay);
|
overlayManager.remove(sceneOverlay);
|
||||||
overlayManager.remove(motherlodeGemOverlay);
|
overlayManager.remove(motherlodeGemOverlay);
|
||||||
overlayManager.remove(motherlodeOreOverlay);
|
overlayManager.remove(motherlodeOreOverlay);
|
||||||
overlayManager.remove(motherlodeSackOverlay);
|
overlayManager.remove(motherlodeSackOverlay);
|
||||||
veins.clear();
|
veins.clear();
|
||||||
rocks.clear();
|
rocks.clear();
|
||||||
|
brokenStruts.clear();
|
||||||
|
|
||||||
Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);
|
Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);
|
||||||
|
|
||||||
@@ -345,11 +349,7 @@ public class MotherlodePlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject gameObject = event.getGameObject();
|
addGameObject(event.getGameObject());
|
||||||
if (ROCK_OBSTACLES.contains(gameObject.getId()))
|
|
||||||
{
|
|
||||||
rocks.add(gameObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -360,15 +360,8 @@ public class MotherlodePlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject previous = event.getPrevious();
|
removeGameObject(event.getPrevious());
|
||||||
GameObject gameObject = event.getGameObject();
|
addGameObject(event.getGameObject());
|
||||||
|
|
||||||
rocks.remove(previous);
|
|
||||||
if (ROCK_OBSTACLES.contains(gameObject.getId()))
|
|
||||||
{
|
|
||||||
rocks.add(gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -379,8 +372,7 @@ public class MotherlodePlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject gameObject = event.getGameObject();
|
removeGameObject(event.getGameObject());
|
||||||
rocks.remove(gameObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -391,6 +383,7 @@ public class MotherlodePlugin extends Plugin
|
|||||||
// on region changes the tiles get set to null
|
// on region changes the tiles get set to null
|
||||||
veins.clear();
|
veins.clear();
|
||||||
rocks.clear();
|
rocks.clear();
|
||||||
|
brokenStruts.clear();
|
||||||
|
|
||||||
inMlm = checkInMlm();
|
inMlm = checkInMlm();
|
||||||
}
|
}
|
||||||
@@ -513,4 +506,23 @@ public class MotherlodePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT;
|
return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void addGameObject(GameObject gameObject)
|
||||||
|
{
|
||||||
|
if (ROCK_OBSTACLES.contains(gameObject.getId()))
|
||||||
|
{
|
||||||
|
rocks.add(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BROKEN_STRUT == gameObject.getId())
|
||||||
|
{
|
||||||
|
brokenStruts.add(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeGameObject(GameObject gameObject)
|
||||||
|
{
|
||||||
|
rocks.remove(gameObject);
|
||||||
|
brokenStruts.remove(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,30 +34,34 @@ import java.awt.image.BufferedImage;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.WallObject;
|
import net.runelite.api.WallObject;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.game.SkillIconManager;
|
import net.runelite.client.game.SkillIconManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
|
||||||
class MotherlodeRocksOverlay extends Overlay
|
class MotherlodeSceneOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private static final int MAX_DISTANCE = 2350;
|
private static final int MAX_DISTANCE = 2350;
|
||||||
|
private static final int IMAGE_Z_OFFSET = 20;
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final MotherlodePlugin plugin;
|
private final MotherlodePlugin plugin;
|
||||||
private final MotherlodeConfig config;
|
private final MotherlodeConfig config;
|
||||||
|
|
||||||
private final BufferedImage miningIcon;
|
private final BufferedImage miningIcon;
|
||||||
|
private final BufferedImage hammerIcon;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MotherlodeRocksOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager)
|
MotherlodeSceneOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager, ItemManager itemManager)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||||
@@ -66,6 +70,7 @@ class MotherlodeRocksOverlay extends Overlay
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
miningIcon = iconManager.getSkillImage(Skill.MINING);
|
miningIcon = iconManager.getSkillImage(Skill.MINING);
|
||||||
|
hammerIcon = itemManager.getImage(ItemID.HAMMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,6 +120,17 @@ class MotherlodeRocksOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.showBrokenStruts())
|
||||||
|
{
|
||||||
|
for (GameObject brokenStrut : plugin.getBrokenStruts())
|
||||||
|
{
|
||||||
|
LocalPoint location = brokenStrut.getLocalLocation();
|
||||||
|
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||||
|
{
|
||||||
|
renderBrokenStrut(graphics, brokenStrut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderVein(Graphics2D graphics, WallObject vein)
|
private void renderVein(Graphics2D graphics, WallObject vein)
|
||||||
@@ -136,4 +152,15 @@ class MotherlodeRocksOverlay extends Overlay
|
|||||||
OverlayUtil.renderPolygon(graphics, poly, Color.red);
|
OverlayUtil.renderPolygon(graphics, poly, Color.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderBrokenStrut(Graphics2D graphics, GameObject brokenStrut)
|
||||||
|
{
|
||||||
|
Polygon poly = Perspective.getCanvasTilePoly(client, brokenStrut.getLocalLocation());
|
||||||
|
|
||||||
|
if (poly != null)
|
||||||
|
{
|
||||||
|
OverlayUtil.renderPolygon(graphics, poly, Color.red);
|
||||||
|
OverlayUtil.renderImageLocation(client, graphics, brokenStrut.getLocalLocation(), hammerIcon, IMAGE_Z_OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ public class MotherlodePluginTest
|
|||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
private MotherlodeRocksOverlay motherlodeRocksOverlay;
|
private MotherlodeSceneOverlay motherlodeSceneOverlay;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
|
|||||||
Reference in New Issue
Block a user