forked from konatakun/powerbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile.java
93 lines (74 loc) · 2.02 KB
/
Tile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package org.powerbot.script;
import java.awt.Color;
/**
* Tile
* An object representing a 2D point within the Runescape world map.
*/
public class Tile implements Locatable, Nillable<Tile>, Comparable<Tile> {
public static final Tile NIL = new Tile(-1, -1, -1);
public static final Color TARGET_COLOR = new Color(255, 0, 0, 75);
protected final Vector3 p;
public Tile(final int x, final int y) {
this(x, y, 0);
}
public Tile(final int x, final int y, final int z) {
p = new Vector3(x, y, z);
}
public static Tile[] fromArray(final int[][] list) {
final Tile[] t = new Tile[list.length];
for (int i = 0; i < t.length; i++) {
final int l = list[i].length;
t[i] = new Tile(l > 0 ? list[i][0] : 0, l > 1 ? list[i][1] : 0, list[i].length > 2 ? list[i][2] : 0);
}
return t;
}
public int x() {
return p.x;
}
public int y() {
return p.y;
}
public int floor() {
return p.z;
}
public double distanceTo(final Locatable l) {
final Tile o;
return l == null || (o = l.tile()) == null || p.z != o.p.z || o.p.z == NIL.p.z ? Double.POSITIVE_INFINITY : p.distanceTo(o.p);
}
public Tile derive(final int x, final int y) {
return new Tile(p.x + x, p.y + y, p.z);
}
public Tile derive(final int x, final int y, final int z) {
return new Tile(p.x + x, p.y + y, z);
}
public org.powerbot.script.rt4.TileMatrix matrix(final org.powerbot.script.rt4.ClientContext ctx) {
return new org.powerbot.script.rt4.TileMatrix(ctx, this);
}
public org.powerbot.script.rt6.TileMatrix matrix(final org.powerbot.script.rt6.ClientContext ctx) {
return new org.powerbot.script.rt6.TileMatrix(ctx, this);
}
@Override
public Tile tile() {
return this;
}
@Override
public Tile nil() {
return NIL;
}
@Override
public int compareTo(final Tile o) {
return p.compareTo(o.p);
}
@Override
public String toString() {
return p.toString();
}
@Override
public boolean equals(final Object o) {
return o instanceof Tile && p.equals(((Tile) o).p);
}
@Override
public int hashCode() {
return p.hashCode();
}
}