Refactor Safespot
This commit is contained in:
@@ -44,7 +44,7 @@ public class SafeSpotOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
if (safeSpotPlugin.isSafeSpotsRenderable())
|
if (safeSpotPlugin.isSafeSpotsRenderable())
|
||||||
{
|
{
|
||||||
if(safeSpotPlugin.getSafeSpotList() != null)
|
if (safeSpotPlugin.getSafeSpotList() != null)
|
||||||
{
|
{
|
||||||
if (safeSpotPlugin.getSafeSpotList().size() > 0)
|
if (safeSpotPlugin.getSafeSpotList().size() > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,16 +40,18 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
)
|
)
|
||||||
public class SafeSpotPlugin extends Plugin
|
public class SafeSpotPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OverlayManager overlayManager;
|
OverlayManager overlayManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SafeSpotConfig config;
|
private SafeSpotConfig config;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private ArrayList<Tile> safeSpotList;
|
private ArrayList<Tile> safeSpotList;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private boolean safeSpotsRenderable = false;
|
private boolean safeSpotsRenderable = false;
|
||||||
|
|
||||||
@@ -132,7 +134,8 @@ public class SafeSpotPlugin extends Plugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The ArrayList of 1-way safe spots
|
* The ArrayList of 1-way safe spots
|
||||||
* @param actor - The Actor that the tiles are a safe spot against
|
*
|
||||||
|
* @param actor - The Actor that the tiles are a safe spot against
|
||||||
* @param worldPoints - Worldpoints in the current scene
|
* @param worldPoints - Worldpoints in the current scene
|
||||||
* @return an ArrayList of Tiles where current player can attack actor but actor cannot attack local player
|
* @return an ArrayList of Tiles where current player can attack actor but actor cannot attack local player
|
||||||
*/
|
*/
|
||||||
@@ -140,7 +143,7 @@ public class SafeSpotPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
ArrayList<Tile> safeSpotList = new ArrayList<>();
|
ArrayList<Tile> safeSpotList = new ArrayList<>();
|
||||||
Tile[][][] tiles = client.getScene().getTiles();
|
Tile[][][] tiles = client.getScene().getTiles();
|
||||||
for (WorldPoint w:worldPoints)
|
for (WorldPoint w : worldPoints)
|
||||||
{
|
{
|
||||||
LocalPoint toPoint = LocalPoint.fromWorld(client, w);
|
LocalPoint toPoint = LocalPoint.fromWorld(client, w);
|
||||||
Tile fromTile = tiles[client.getPlane()][actor.getLocalLocation().getSceneX()]
|
Tile fromTile = tiles[client.getPlane()][actor.getLocalLocation().getSceneX()]
|
||||||
@@ -151,11 +154,11 @@ public class SafeSpotPlugin extends Plugin
|
|||||||
int bit = client.getCollisionMaps()[plane].getFlags()[toPoint.getSceneX()][toPoint.getSceneY()];
|
int bit = client.getCollisionMaps()[plane].getFlags()[toPoint.getSceneX()][toPoint.getSceneY()];
|
||||||
if (toTile.hasLineOfSightTo(fromTile) && !fromTile.hasLineOfSightTo(toTile))
|
if (toTile.hasLineOfSightTo(fromTile) && !fromTile.hasLineOfSightTo(toTile))
|
||||||
{
|
{
|
||||||
if (!((bit & CollisionDataFlag.BLOCK_MOVEMENT_OBJECT ) == CollisionDataFlag.BLOCK_MOVEMENT_OBJECT ||
|
if (!((bit & CollisionDataFlag.BLOCK_MOVEMENT_OBJECT) == CollisionDataFlag.BLOCK_MOVEMENT_OBJECT ||
|
||||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION )
|
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION)
|
||||||
== CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION ||
|
== CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION ||
|
||||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR ) == CollisionDataFlag.BLOCK_MOVEMENT_FLOOR ||
|
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR) == CollisionDataFlag.BLOCK_MOVEMENT_FLOOR ||
|
||||||
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FULL ) == CollisionDataFlag.BLOCK_MOVEMENT_FULL))
|
(bit & CollisionDataFlag.BLOCK_MOVEMENT_FULL) == CollisionDataFlag.BLOCK_MOVEMENT_FULL))
|
||||||
{
|
{
|
||||||
safeSpotList.add(toTile);
|
safeSpotList.add(toTile);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user