use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.
the class BW method onUnitEvade.
private void onUnitEvade(int unitId) {
Unit unit = this.units.get(unitId);
if (unit == null) {
logger.error("onUnitEvade: no unit found for ID {}.", unitId);
}
listener.onUnitEvade(unit);
}
use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.
the class BW method onUnitRenegade.
private void onUnitRenegade(int unitId) {
Unit unit = this.units.get(unitId);
if (unit == null) {
logger.error("onUnitRenegade: no unit found for ID {}.", unitId);
}
listener.onUnitRenegade(unit);
}
use of org.openbw.bwapi4j.unit.Unit in project Ecgberht by Jabbo16.
the class DropShipAgent method setCargo.
public void setCargo(Set<Unit> cargo) {
this.cargoWanted = cargo;
for (Unit u : this.cargoWanted) {
if (u instanceof Worker && (((Worker) u).isCarryingMinerals() || ((Worker) u).isCarryingGas())) {
((Worker) u).returnCargo();
((MobileUnit) u).rightClick(unit, true);
} else
((MobileUnit) u).rightClick(unit, false);
}
}
use of org.openbw.bwapi4j.unit.Unit in project Ecgberht by Jabbo16.
the class DropShipAgent method checkLoaded.
private void checkLoaded() {
if (pickingUp == null)
return;
Unit transport = ((MobileUnit) pickingUp).getTransport();
if (transport != null && transport.equals(unit)) {
cargoLoaded.add(pickingUp);
cargoWanted.remove(pickingUp);
pickingUp = null;
}
}
use of org.openbw.bwapi4j.unit.Unit in project Ecgberht by Jabbo16.
the class DropShipAgent method picking.
private void picking() {
if (cargoWanted.isEmpty())
return;
if (pickingUp == null) {
double distB = Double.MAX_VALUE;
for (Unit u : cargoWanted) {
double distA = Util.broodWarDistance(unit.getPosition(), u.getPosition());
if (pickingUp == null || distA < distB) {
pickingUp = u;
distB = distA;
}
}
if (pickingUp != null) {
unit.load((MobileUnit) pickingUp);
}
} else {
if (unit.getOrderTarget() != null && unit.getOrderTarget().equals(pickingUp))
return;
checkLoaded();
}
}
Aggregations