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;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showBrokenStruts",
|
||||
name = "Show broken struts",
|
||||
description = "Shows broken water wheel struts"
|
||||
)
|
||||
default boolean showBrokenStruts()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showLootIcons",
|
||||
name = "Show ore icons",
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
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_26662;
|
||||
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
|
||||
@@ -109,7 +110,7 @@ public class MotherlodePlugin extends Plugin
|
||||
private MotherlodeOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private MotherlodeRocksOverlay rocksOverlay;
|
||||
private MotherlodeSceneOverlay sceneOverlay;
|
||||
|
||||
@Inject
|
||||
private MotherlodeSackOverlay motherlodeSackOverlay;
|
||||
@@ -148,6 +149,8 @@ public class MotherlodePlugin extends Plugin
|
||||
private final Set<WallObject> veins = new HashSet<>();
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<GameObject> rocks = new HashSet<>();
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<GameObject> brokenStruts = new HashSet<>();
|
||||
|
||||
@Provides
|
||||
MotherlodeConfig getConfig(ConfigManager configManager)
|
||||
@@ -159,7 +162,7 @@ public class MotherlodePlugin extends Plugin
|
||||
protected void startUp()
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(rocksOverlay);
|
||||
overlayManager.add(sceneOverlay);
|
||||
overlayManager.add(motherlodeGemOverlay);
|
||||
overlayManager.add(motherlodeOreOverlay);
|
||||
overlayManager.add(motherlodeSackOverlay);
|
||||
@@ -176,12 +179,13 @@ public class MotherlodePlugin extends Plugin
|
||||
protected void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(rocksOverlay);
|
||||
overlayManager.remove(sceneOverlay);
|
||||
overlayManager.remove(motherlodeGemOverlay);
|
||||
overlayManager.remove(motherlodeOreOverlay);
|
||||
overlayManager.remove(motherlodeSackOverlay);
|
||||
veins.clear();
|
||||
rocks.clear();
|
||||
brokenStruts.clear();
|
||||
|
||||
Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);
|
||||
|
||||
@@ -345,11 +349,7 @@ public class MotherlodePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject gameObject = event.getGameObject();
|
||||
if (ROCK_OBSTACLES.contains(gameObject.getId()))
|
||||
{
|
||||
rocks.add(gameObject);
|
||||
}
|
||||
addGameObject(event.getGameObject());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -360,15 +360,8 @@ public class MotherlodePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject previous = event.getPrevious();
|
||||
GameObject gameObject = event.getGameObject();
|
||||
|
||||
rocks.remove(previous);
|
||||
if (ROCK_OBSTACLES.contains(gameObject.getId()))
|
||||
{
|
||||
rocks.add(gameObject);
|
||||
}
|
||||
|
||||
removeGameObject(event.getPrevious());
|
||||
addGameObject(event.getGameObject());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -379,8 +372,7 @@ public class MotherlodePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject gameObject = event.getGameObject();
|
||||
rocks.remove(gameObject);
|
||||
removeGameObject(event.getGameObject());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -391,6 +383,7 @@ public class MotherlodePlugin extends Plugin
|
||||
// on region changes the tiles get set to null
|
||||
veins.clear();
|
||||
rocks.clear();
|
||||
brokenStruts.clear();
|
||||
|
||||
inMlm = checkInMlm();
|
||||
}
|
||||
@@ -513,4 +506,23 @@ public class MotherlodePlugin extends Plugin
|
||||
{
|
||||
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 net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.WallObject;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.game.SkillIconManager;
|
||||
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;
|
||||
|
||||
class MotherlodeRocksOverlay extends Overlay
|
||||
class MotherlodeSceneOverlay extends Overlay
|
||||
{
|
||||
private static final int MAX_DISTANCE = 2350;
|
||||
private static final int IMAGE_Z_OFFSET = 20;
|
||||
|
||||
private final Client client;
|
||||
private final MotherlodePlugin plugin;
|
||||
private final MotherlodeConfig config;
|
||||
|
||||
private final BufferedImage miningIcon;
|
||||
private final BufferedImage hammerIcon;
|
||||
|
||||
@Inject
|
||||
MotherlodeRocksOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager)
|
||||
MotherlodeSceneOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager, ItemManager itemManager)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
@@ -66,6 +70,7 @@ class MotherlodeRocksOverlay extends Overlay
|
||||
this.config = config;
|
||||
|
||||
miningIcon = iconManager.getSkillImage(Skill.MINING);
|
||||
hammerIcon = itemManager.getImage(ItemID.HAMMER);
|
||||
}
|
||||
|
||||
@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)
|
||||
@@ -136,4 +152,15 @@ class MotherlodeRocksOverlay extends Overlay
|
||||
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
|
||||
@Bind
|
||||
private MotherlodeRocksOverlay motherlodeRocksOverlay;
|
||||
private MotherlodeSceneOverlay motherlodeSceneOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
|
||||
Reference in New Issue
Block a user