Refactor AoE
This commit is contained in:
@@ -30,14 +30,14 @@ package net.runelite.client.plugins.aoewarnings;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
|
|
||||||
public class AoeProjectile
|
class AoeProjectile
|
||||||
{
|
{
|
||||||
private final Instant startTime;
|
private final Instant startTime;
|
||||||
private final LocalPoint targetPoint;
|
private final LocalPoint targetPoint;
|
||||||
private final AoeProjectileInfo aoeProjectileInfo;
|
private final AoeProjectileInfo aoeProjectileInfo;
|
||||||
private final int projectileLifetime;
|
private final int projectileLifetime;
|
||||||
|
|
||||||
public AoeProjectile(Instant startTime, LocalPoint targetPoint, AoeProjectileInfo aoeProjectileInfo, int projectileLifetime)
|
AoeProjectile(Instant startTime, LocalPoint targetPoint, AoeProjectileInfo aoeProjectileInfo, int projectileLifetime)
|
||||||
{
|
{
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.targetPoint = targetPoint;
|
this.targetPoint = targetPoint;
|
||||||
@@ -45,22 +45,22 @@ public class AoeProjectile
|
|||||||
this.projectileLifetime = projectileLifetime;
|
this.projectileLifetime = projectileLifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getStartTime()
|
Instant getStartTime()
|
||||||
{
|
{
|
||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalPoint getTargetPoint()
|
LocalPoint getTargetPoint()
|
||||||
{
|
{
|
||||||
return targetPoint;
|
return targetPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AoeProjectileInfo getAoeProjectileInfo()
|
AoeProjectileInfo getAoeProjectileInfo()
|
||||||
{
|
{
|
||||||
return aoeProjectileInfo;
|
return aoeProjectileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProjectileLifetime()
|
int getProjectileLifetime()
|
||||||
{
|
{
|
||||||
return projectileLifetime;
|
return projectileLifetime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import net.runelite.api.events.GameObjectSpawned;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.ProjectileMoved;
|
import net.runelite.api.events.ProjectileMoved;
|
||||||
import net.runelite.client.Notifier;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -74,23 +73,28 @@ public class AoeWarningPlugin extends Plugin
|
|||||||
@Getter
|
@Getter
|
||||||
private final Map<WorldPoint, CrystalBomb> bombs = new HashMap<>();
|
private final Map<WorldPoint, CrystalBomb> bombs = new HashMap<>();
|
||||||
private final Map<Projectile, AoeProjectile> projectiles = new HashMap<>();
|
private final Map<Projectile, AoeProjectile> projectiles = new HashMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AoeWarningConfig config;
|
public AoeWarningConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AoeWarningOverlay coreOverlay;
|
private AoeWarningOverlay coreOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BombOverlay bombOverlay;
|
private BombOverlay bombOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
@Inject
|
|
||||||
private Notifier notifier;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private List<WorldPoint> LightningTrail = new ArrayList<>();
|
private List<WorldPoint> LightningTrail = new ArrayList<>();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private List<WorldPoint> AcidTrail = new ArrayList<>();
|
private List<WorldPoint> AcidTrail = new ArrayList<>();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private List<WorldPoint> CrystalSpike = new ArrayList<>();
|
private List<WorldPoint> CrystalSpike = new ArrayList<>();
|
||||||
|
|
||||||
@@ -100,7 +104,7 @@ public class AoeWarningPlugin extends Plugin
|
|||||||
return configManager.getConfig(AoeWarningConfig.class);
|
return configManager.getConfig(AoeWarningConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Projectile, AoeProjectile> getProjectiles()
|
Map<Projectile, AoeProjectile> getProjectiles()
|
||||||
{
|
{
|
||||||
return projectiles;
|
return projectiles;
|
||||||
}
|
}
|
||||||
@@ -207,11 +211,8 @@ public class AoeWarningPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Map.Entry<WorldPoint, CrystalBomb>> it = bombs.entrySet().iterator();
|
for (Map.Entry<WorldPoint, CrystalBomb> entry : bombs.entrySet())
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
Map.Entry<WorldPoint, CrystalBomb> entry = it.next();
|
|
||||||
CrystalBomb bomb = entry.getValue();
|
CrystalBomb bomb = entry.getValue();
|
||||||
bomb.bombClockUpdate();
|
bomb.bombClockUpdate();
|
||||||
//bombClockUpdate smooths the shown timer; not using this results in 1.2 --> .6 vs. 1.2 --> 1.1, etc.
|
//bombClockUpdate smooths the shown timer; not using this results in 1.2 --> .6 vs. 1.2 --> 1.1, etc.
|
||||||
|
|||||||
@@ -24,6 +24,18 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.aoewarnings;
|
package net.runelite.client.plugins.aoewarnings;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Polygon;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
@@ -31,20 +43,11 @@ import net.runelite.api.Player;
|
|||||||
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.api.coords.WorldPoint;
|
||||||
import net.runelite.client.plugins.aoewarnings.CrystalBomb;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.*;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import javax.inject.Inject;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import java.awt.Graphics2D;
|
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||||
import java.awt.Dimension;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Polygon;
|
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.NumberFormat;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BombOverlay extends Overlay
|
public class BombOverlay extends Overlay
|
||||||
|
|||||||
@@ -24,14 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.aoewarnings;
|
package net.runelite.client.plugins.aoewarnings;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CrystalBomb
|
class CrystalBomb
|
||||||
{
|
{
|
||||||
@Getter
|
@Getter
|
||||||
private Instant plantedOn;
|
private Instant plantedOn;
|
||||||
@@ -49,7 +49,7 @@ public class CrystalBomb
|
|||||||
@Getter
|
@Getter
|
||||||
private WorldPoint worldLocation;
|
private WorldPoint worldLocation;
|
||||||
|
|
||||||
public CrystalBomb(GameObject gameObject, int startTick)
|
CrystalBomb(GameObject gameObject, int startTick)
|
||||||
{
|
{
|
||||||
this.plantedOn = Instant.now();
|
this.plantedOn = Instant.now();
|
||||||
this.objectId = gameObject.getId();
|
this.objectId = gameObject.getId();
|
||||||
@@ -57,7 +57,7 @@ public class CrystalBomb
|
|||||||
this.tickStarted = startTick;
|
this.tickStarted = startTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bombClockUpdate()
|
void bombClockUpdate()
|
||||||
{
|
{
|
||||||
lastClockUpdate = Instant.now();
|
lastClockUpdate = Instant.now();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user