herbiboar plugin: optimize object and tunnel overlays
This commit is contained in:
@@ -58,7 +58,7 @@ public class HerbiboarMinimapOverlay extends Overlay
|
|||||||
int finishId = plugin.getFinishId();
|
int finishId = plugin.getFinishId();
|
||||||
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
||||||
|
|
||||||
for (TileObject tileObject : plugin.getTrails().keySet())
|
for (TileObject tileObject : plugin.getTrails().values())
|
||||||
{
|
{
|
||||||
int id = tileObject.getId();
|
int id = tileObject.getId();
|
||||||
Point minimapLocation = tileObject.getMinimapLocation();
|
Point minimapLocation = tileObject.getMinimapLocation();
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.runelite.api.Tile;
|
|
||||||
import net.runelite.api.TileObject;
|
import net.runelite.api.TileObject;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
@@ -68,7 +66,7 @@ class HerbiboarOverlay extends Overlay
|
|||||||
// Draw start objects
|
// Draw start objects
|
||||||
if (config.isStartShown() && (currentTrail == null && finishId == 0))
|
if (config.isStartShown() && (currentTrail == null && finishId == 0))
|
||||||
{
|
{
|
||||||
plugin.getStarts().keySet().forEach((obj) ->
|
plugin.getStarts().values().forEach((obj) ->
|
||||||
{
|
{
|
||||||
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getStartColor());
|
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getStartColor());
|
||||||
});
|
});
|
||||||
@@ -78,7 +76,7 @@ class HerbiboarOverlay extends Overlay
|
|||||||
if (config.isTrailShown())
|
if (config.isTrailShown())
|
||||||
{
|
{
|
||||||
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
||||||
plugin.getTrails().keySet().forEach((x) ->
|
plugin.getTrails().values().forEach((x) ->
|
||||||
{
|
{
|
||||||
int id = x.getId();
|
int id = x.getId();
|
||||||
if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id)))
|
if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id)))
|
||||||
@@ -92,61 +90,60 @@ class HerbiboarOverlay extends Overlay
|
|||||||
if (config.isObjectShown() && currentTrail != null)
|
if (config.isObjectShown() && currentTrail != null)
|
||||||
{
|
{
|
||||||
int currentPath = plugin.getCurrentPath();
|
int currentPath = plugin.getCurrentPath();
|
||||||
plugin.getTrailObjects().keySet().forEach((obj) ->
|
WorldPoint[] trailLocs = currentTrail.getObjectLocs(currentPath);
|
||||||
|
for (WorldPoint trailLoc : trailLocs)
|
||||||
{
|
{
|
||||||
WorldPoint loc = obj.getWorldLocation();
|
if (trailLoc == null)
|
||||||
WorldPoint[] trailLocs = currentTrail.getObjectLocs(currentPath);
|
|
||||||
for (WorldPoint trailLoc : trailLocs)
|
|
||||||
{
|
{
|
||||||
if (trailLoc == null)
|
continue;
|
||||||
{
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trailLoc.equals(loc))
|
TileObject object = plugin.getTrailObjects().get(trailLoc);
|
||||||
|
if (object != null)
|
||||||
|
{
|
||||||
|
if (config.showClickBoxes())
|
||||||
{
|
{
|
||||||
if (config.showClickBoxes())
|
Area clickbox = object.getClickbox();
|
||||||
|
if (clickbox != null)
|
||||||
{
|
{
|
||||||
Area clickbox = obj.getClickbox();
|
|
||||||
graphics.setColor(config.getObjectColor());
|
graphics.setColor(config.getObjectColor());
|
||||||
graphics.draw(clickbox);
|
graphics.draw(clickbox);
|
||||||
graphics.setColor(new Color(255, 0, 255, 20));
|
graphics.setColor(new Color(255, 0, 255, 20));
|
||||||
graphics.fill(clickbox);
|
graphics.fill(clickbox);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getObjectColor());
|
{
|
||||||
}
|
OverlayUtil.renderTileOverlay(graphics, object, "", config.getObjectColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw finish tunnels
|
// Draw finish tunnels
|
||||||
if (config.isTunnelShown() && finishId > 0)
|
if (config.isTunnelShown() && finishId > 0)
|
||||||
{
|
{
|
||||||
WorldPoint finishLoc = plugin.getEndLocations().get(finishId - 1);
|
WorldPoint finishLoc = plugin.getEndLocations().get(finishId - 1);
|
||||||
Map<TileObject, Tile> tunnels = plugin.getTunnels();
|
TileObject object = plugin.getTunnels().get(finishLoc);
|
||||||
tunnels.keySet().forEach((obj) ->
|
if (object != null)
|
||||||
{
|
{
|
||||||
WorldPoint loc = obj.getWorldLocation();
|
if (config.showClickBoxes())
|
||||||
if (finishLoc.equals(loc))
|
|
||||||
{
|
{
|
||||||
if (config.showClickBoxes())
|
Area clickbox = object.getClickbox();
|
||||||
|
if (clickbox != null)
|
||||||
{
|
{
|
||||||
Area clickbox = obj.getClickbox();
|
|
||||||
Color col = config.getObjectColor();
|
Color col = config.getObjectColor();
|
||||||
graphics.setColor(col);
|
graphics.setColor(col);
|
||||||
graphics.draw(clickbox);
|
graphics.draw(clickbox);
|
||||||
graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
|
graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
|
||||||
graphics.fill(clickbox);
|
graphics.fill(clickbox);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getTunnelColor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
|
OverlayUtil.renderTileOverlay(graphics, object, "", config.getTunnelColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -108,16 +108,16 @@ public class HerbiboarPlugin extends Plugin
|
|||||||
private boolean inHerbiboarArea;
|
private boolean inHerbiboarArea;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Map<TileObject, Tile> trails = new HashMap<>();
|
private Map<WorldPoint, TileObject> trails = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Map<TileObject, Tile> tunnels = new HashMap<>();
|
private Map<WorldPoint, TileObject> tunnels = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Map<TileObject, Tile> starts = new HashMap<>();
|
private Map<WorldPoint, TileObject> starts = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Map<TileObject, Tile> trailObjects = new HashMap<>();
|
private Map<WorldPoint, TileObject> trailObjects = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -278,9 +278,13 @@ public class HerbiboarPlugin extends Plugin
|
|||||||
// Store relevant GameObjects (starts, objects used to trigger next trails, and some tunnels)
|
// Store relevant GameObjects (starts, objects used to trigger next trails, and some tunnels)
|
||||||
private void onGameObject(Tile tile, TileObject oldObject, TileObject newObject)
|
private void onGameObject(Tile tile, TileObject oldObject, TileObject newObject)
|
||||||
{
|
{
|
||||||
trailObjects.remove(oldObject);
|
if (oldObject != null)
|
||||||
tunnels.remove(oldObject);
|
{
|
||||||
starts.remove(oldObject);
|
WorldPoint oldLocation = oldObject.getWorldLocation();
|
||||||
|
trailObjects.remove(oldLocation);
|
||||||
|
tunnels.remove(oldLocation);
|
||||||
|
starts.remove(oldLocation);
|
||||||
|
}
|
||||||
|
|
||||||
if (newObject == null)
|
if (newObject == null)
|
||||||
{
|
{
|
||||||
@@ -290,29 +294,33 @@ public class HerbiboarPlugin extends Plugin
|
|||||||
// Starts
|
// Starts
|
||||||
if (START_OBJECT_IDS.contains(newObject.getId()))
|
if (START_OBJECT_IDS.contains(newObject.getId()))
|
||||||
{
|
{
|
||||||
starts.put(newObject, tile);
|
starts.put(newObject.getWorldLocation(), newObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameObject to trigger next trail (mushrooms, mud, seaweed, etc)
|
// GameObject to trigger next trail (mushrooms, mud, seaweed, etc)
|
||||||
if (HerbiboarTrail.getAllObjectLocs().contains(newObject.getWorldLocation()))
|
if (HerbiboarTrail.getAllObjectLocs().contains(newObject.getWorldLocation()))
|
||||||
{
|
{
|
||||||
trailObjects.put(newObject, tile);
|
trailObjects.put(newObject.getWorldLocation(), newObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Herbiboar tunnel
|
// Herbiboar tunnel
|
||||||
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
|
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
|
||||||
{
|
{
|
||||||
tunnels.put(newObject, tile);
|
tunnels.put(newObject.getWorldLocation(), newObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store relevant GroundObjects (tracks on trails, and some tunnels)
|
// Store relevant GroundObjects (tracks on trails, and some tunnels)
|
||||||
private void onGroundObject(Tile tile, TileObject oldObject, TileObject newObject)
|
private void onGroundObject(Tile tile, TileObject oldObject, TileObject newObject)
|
||||||
{
|
{
|
||||||
trails.remove(oldObject);
|
if (oldObject != null)
|
||||||
tunnels.remove(oldObject);
|
{
|
||||||
|
WorldPoint oldLocation = oldObject.getWorldLocation();
|
||||||
|
trails.remove(oldLocation);
|
||||||
|
tunnels.remove(oldLocation);
|
||||||
|
}
|
||||||
|
|
||||||
if (newObject == null)
|
if (newObject == null)
|
||||||
{
|
{
|
||||||
@@ -322,14 +330,14 @@ public class HerbiboarPlugin extends Plugin
|
|||||||
//Trails
|
//Trails
|
||||||
if (HerbiboarTrail.getTrailIds().contains(newObject.getId()))
|
if (HerbiboarTrail.getTrailIds().contains(newObject.getId()))
|
||||||
{
|
{
|
||||||
trails.put(newObject, tile);
|
trails.put(newObject.getWorldLocation(), newObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Herbiboar tunnel
|
//Herbiboar tunnel
|
||||||
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
|
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
|
||||||
{
|
{
|
||||||
tunnels.put(newObject, tile);
|
tunnels.put(newObject.getWorldLocation(), newObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user