Skip to content

Commit e848670

Browse files
committed
make units usable in treesets-maps
1 parent 5002031 commit e848670

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/bwapi/Unit.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import static bwapi.Race.Zerg;
1313
import static bwapi.UnitType.*;
1414

15-
public class Unit {
15+
public class Unit implements Comparable<Unit>{
1616
private static Set<Order> gatheringGasOrders = EnumSet.of(
1717
Harvest1, Harvest2, MoveToGas, WaitForGas, HarvestGas, ReturnGas, ResetCollision);
1818
private static Set<Order> gatheringMineralOrders = EnumSet.of(
@@ -4115,17 +4115,21 @@ public boolean canPlaceCOP(TilePosition target, boolean checkCanIssueCommandType
41154115
}
41164116

41174117

4118-
public boolean equals(final Object that) {
4119-
if (!(that instanceof Unit)) {
4118+
public boolean equals(final Object other) {
4119+
if (!(other instanceof Unit)) {
41204120
return false;
41214121
}
4122-
return getID() == ((Unit) that).getID();
4122+
return getID() == ((Unit) other).getID();
41234123
}
41244124

41254125
public int hashCode() {
41264126
return getID();
41274127
}
41284128

4129+
public int compareTo(final Unit other) {
4130+
return getID() - other.getID();
4131+
}
4132+
41294133
void updateType(final int frame) {
41304134
if (frame > lastTypeUpdate) {
41314135
lastTypeUpdate = frame;

0 commit comments

Comments
 (0)