mining plugin: recolour pie in MLM during random segment of timer

This commit is contained in:
Twiglet1022
2019-06-05 21:10:05 +01:00
parent 6059c784c0
commit 2d12fbe5f4
2 changed files with 21 additions and 3 deletions

View File

@@ -31,6 +31,8 @@ import java.time.Instant;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
@@ -43,6 +45,13 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent;
class MiningOverlay extends Overlay
{
// Range of Motherlode vein respawn time not 100% confirmed but based on observation
@Getter(AccessLevel.PACKAGE)
private static final int ORE_VEIN_MAX_RESPAWN_TIME = 123;
private static final int ORE_VEIN_MIN_RESPAWN_TIME = 90;
private static final float ORE_VEIN_RANDOM_PERCENT_THRESHOLD = (float) ORE_VEIN_MIN_RESPAWN_TIME / ORE_VEIN_MAX_RESPAWN_TIME;
private static final Color DARK_GREEN = new Color(0, 100, 0);
private final Client client;
private final MiningPlugin plugin;
@@ -67,6 +76,8 @@ class MiningOverlay extends Overlay
Instant now = Instant.now();
for (Iterator<RockRespawn> it = respawns.iterator(); it.hasNext();)
{
Color pieFillColor = Color.YELLOW;
Color pieBorderColor = Color.ORANGE;
RockRespawn rockRespawn = it.next();
float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime();
WorldPoint worldPoint = rockRespawn.getWorldPoint();
@@ -84,9 +95,16 @@ class MiningOverlay extends Overlay
continue;
}
// Recolour pie on motherlode veins during the portion of the timer where they may respawn
if (rockRespawn.getRock() == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD)
{
pieFillColor = Color.GREEN;
pieBorderColor = DARK_GREEN;
}
ProgressPieComponent ppc = new ProgressPieComponent();
ppc.setBorderColor(Color.ORANGE);
ppc.setFill(Color.YELLOW);
ppc.setBorderColor(pieBorderColor);
ppc.setFill(pieFillColor);
ppc.setPosition(point);
ppc.setProgress(percent);
ppc.render(graphics);

View File

@@ -96,7 +96,7 @@ enum Rock
return inMiningGuild ? Duration.ofMinutes(6) : super.respawnTime;
}
},
ORE_VEIN(Duration.ofSeconds(108), 150),
ORE_VEIN(Duration.ofSeconds(MiningOverlay.getORE_VEIN_MAX_RESPAWN_TIME()), 150),
AMETHYST(Duration.ofSeconds(75), 120);
private static final Map<Integer, Rock> ROCKS;