mining: show respawn timers after GameState change
This commit is contained in:
@@ -28,14 +28,12 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
|
||||||
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;
|
||||||
@@ -72,24 +70,18 @@ class MiningOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
for (Iterator<RockRespawn> it = respawns.iterator(); it.hasNext();)
|
for (RockRespawn rockRespawn : respawns)
|
||||||
{
|
{
|
||||||
Color pieFillColor = Color.YELLOW;
|
LocalPoint loc = LocalPoint.fromWorld(client, rockRespawn.getWorldPoint());
|
||||||
Color pieBorderColor = Color.ORANGE;
|
if (loc == null)
|
||||||
RockRespawn rockRespawn = it.next();
|
|
||||||
float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime();
|
|
||||||
WorldPoint worldPoint = rockRespawn.getWorldPoint();
|
|
||||||
LocalPoint loc = LocalPoint.fromWorld(client, worldPoint);
|
|
||||||
if (loc == null || percent > 1.0f)
|
|
||||||
{
|
{
|
||||||
it.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime();
|
||||||
Point point = Perspective.localToCanvas(client, loc, client.getPlane(), rockRespawn.getZOffset());
|
Point point = Perspective.localToCanvas(client, loc, client.getPlane(), rockRespawn.getZOffset());
|
||||||
if (point == null)
|
if (point == null || percent > 1.0f)
|
||||||
{
|
{
|
||||||
it.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +94,9 @@ class MiningOverlay extends Overlay
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color pieFillColor = Color.YELLOW;
|
||||||
|
Color pieBorderColor = Color.ORANGE;
|
||||||
|
|
||||||
// Recolour pie on motherlode veins during the portion of the timer where they may respawn
|
// Recolour pie on motherlode veins during the portion of the timer where they may respawn
|
||||||
if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD)
|
if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ public class MiningPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
switch (event.getGameState())
|
switch (event.getGameState())
|
||||||
{
|
{
|
||||||
case LOADING:
|
|
||||||
case HOPPING:
|
case HOPPING:
|
||||||
respawns.clear();
|
respawns.clear();
|
||||||
break;
|
break;
|
||||||
@@ -110,6 +109,7 @@ public class MiningPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick gameTick)
|
public void onGameTick(GameTick gameTick)
|
||||||
{
|
{
|
||||||
|
respawns.removeIf(RockRespawn::isExpired);
|
||||||
recentlyLoggedIn = false;
|
recentlyLoggedIn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,9 @@ class RockRespawn
|
|||||||
private final Instant startTime;
|
private final Instant startTime;
|
||||||
private final int respawnTime;
|
private final int respawnTime;
|
||||||
private final int zOffset;
|
private final int zOffset;
|
||||||
|
|
||||||
|
boolean isExpired()
|
||||||
|
{
|
||||||
|
return Instant.now().isAfter(startTime.plusMillis(respawnTime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user