Refactor LootAssist
This commit is contained in:
@@ -5,7 +5,6 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
@@ -21,16 +20,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
public class LootAssistOverlay extends Overlay
|
||||
{
|
||||
|
||||
|
||||
private LootAssistPlugin plugin;
|
||||
private Client client;
|
||||
private DecimalFormat d = new DecimalFormat("##.#");
|
||||
|
||||
@Inject
|
||||
public LootAssistOverlay(Client client, LootAssistPlugin plugin)
|
||||
public LootAssistOverlay(Client client)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
@@ -48,9 +43,7 @@ public class LootAssistOverlay extends Overlay
|
||||
int y;
|
||||
try
|
||||
{
|
||||
|
||||
x = LocalPoint.fromWorld(client, pile.getLocation()).getSceneX();
|
||||
|
||||
y = LocalPoint.fromWorld(client, pile.getLocation()).getSceneY();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
@@ -73,32 +66,32 @@ public class LootAssistOverlay extends Overlay
|
||||
{
|
||||
String nameOverlay = pile.getPlayerName();
|
||||
String timeOverlay = d.format((pile.getTimeAppearing() - System.currentTimeMillis()) / 1000f);
|
||||
final Polygon poly = Perspective.getCanvasTilePoly(client,
|
||||
client.getScene().getTiles()[client.getPlane()][x][y].getLocalLocation());
|
||||
if (poly != null)
|
||||
{
|
||||
Point textLoc = Perspective.getCanvasTextLocation(client, graphics,
|
||||
LocalPoint.fromWorld(client, pile.getLocation()),
|
||||
nameOverlay, graphics.getFontMetrics().getHeight() * 7);
|
||||
Point timeLoc = Perspective.getCanvasTextLocation(client, graphics,
|
||||
LocalPoint.fromWorld(client, pile.getLocation()),
|
||||
timeOverlay, graphics.getFontMetrics().getHeight());
|
||||
OverlayUtil.renderPolygon(graphics, poly, Color.WHITE);
|
||||
if (timeRemaining < 5)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, timeLoc, timeOverlay, Color.RED);
|
||||
OverlayUtil.renderTextLocation(graphics, textLoc, nameOverlay, Color.RED);
|
||||
}
|
||||
if (timeRemaining < 2)
|
||||
{
|
||||
client.setHintArrow(WorldPoint.fromLocal(client,
|
||||
LocalPoint.fromWorld(client, pile.getLocation())));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, timeLoc, timeOverlay, Color.WHITE);
|
||||
OverlayUtil.renderTextLocation(graphics, textLoc, nameOverlay, Color.WHITE);
|
||||
}
|
||||
final Polygon poly = Perspective.getCanvasTilePoly(client,
|
||||
client.getScene().getTiles()[client.getPlane()][x][y].getLocalLocation());
|
||||
if (poly != null)
|
||||
{
|
||||
Point textLoc = Perspective.getCanvasTextLocation(client, graphics,
|
||||
LocalPoint.fromWorld(client, pile.getLocation()),
|
||||
nameOverlay, graphics.getFontMetrics().getHeight() * 7);
|
||||
Point timeLoc = Perspective.getCanvasTextLocation(client, graphics,
|
||||
LocalPoint.fromWorld(client, pile.getLocation()),
|
||||
timeOverlay, graphics.getFontMetrics().getHeight());
|
||||
OverlayUtil.renderPolygon(graphics, poly, Color.WHITE);
|
||||
if (timeRemaining < 5)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, timeLoc, timeOverlay, Color.RED);
|
||||
OverlayUtil.renderTextLocation(graphics, textLoc, nameOverlay, Color.RED);
|
||||
}
|
||||
if (timeRemaining < 2)
|
||||
{
|
||||
client.setHintArrow(WorldPoint.fromLocal(client,
|
||||
LocalPoint.fromWorld(client, pile.getLocation())));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, timeLoc, timeOverlay, Color.WHITE);
|
||||
OverlayUtil.renderTextLocation(graphics, textLoc, nameOverlay, Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@ package net.runelite.client.plugins.lootassist;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
@@ -28,21 +26,13 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
||||
)
|
||||
public class LootAssistPlugin extends Plugin
|
||||
{
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
LootAssistOverlay lootAssistOverlay;
|
||||
|
||||
@Inject
|
||||
private LootAssitConfig config;
|
||||
|
||||
|
||||
public static ConcurrentHashMap<WorldPoint, LootPile> lootPiles = new ConcurrentHashMap<>();
|
||||
static ConcurrentHashMap<WorldPoint, LootPile> lootPiles = new ConcurrentHashMap<>();
|
||||
|
||||
@Provides
|
||||
LootAssitConfig getConfig(ConfigManager configManager)
|
||||
|
||||
@@ -5,24 +5,28 @@ import lombok.Setter;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
public class LootPile
|
||||
class LootPile
|
||||
{
|
||||
private static final long TIME_UNTIL_VISIBLE = 60000;
|
||||
private final long timeCreated;
|
||||
|
||||
@Getter
|
||||
private final long timeAppearing;
|
||||
|
||||
@Getter
|
||||
private final WorldPoint location;
|
||||
|
||||
@Getter
|
||||
private final String playerName;
|
||||
@Getter @Setter
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean beingRendered = false;
|
||||
|
||||
public LootPile(WorldPoint location, String playerName)
|
||||
LootPile(WorldPoint location, String playerName)
|
||||
{
|
||||
this.timeCreated = System.currentTimeMillis();
|
||||
long timeCreated = System.currentTimeMillis();
|
||||
this.location = location;
|
||||
this.playerName = playerName;
|
||||
this.timeAppearing = this.timeCreated + TIME_UNTIL_VISIBLE;
|
||||
this.timeAppearing = timeCreated + TIME_UNTIL_VISIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user