Skip to content

Commit

Permalink
make units usable in treesets-maps
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperGeurtz committed Jan 20, 2019
1 parent 5002031 commit e848670
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/bwapi/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static bwapi.Race.Zerg;
import static bwapi.UnitType.*;

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


public boolean equals(final Object that) {
if (!(that instanceof Unit)) {
public boolean equals(final Object other) {
if (!(other instanceof Unit)) {
return false;
}
return getID() == ((Unit) that).getID();
return getID() == ((Unit) other).getID();
}

public int hashCode() {
return getID();
}

public int compareTo(final Unit other) {
return getID() - other.getID();
}

void updateType(final int frame) {
if (frame > lastTypeUpdate) {
lastTypeUpdate = frame;
Expand Down

0 comments on commit e848670

Please sign in to comment.