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