// This is expensive, so precalculate when entity changes
public void updateEcmList() {
ArrayList<EcmBubble> list = new ArrayList<EcmBubble>();
for (Enumeration<Entity> e = game.getEntities(); e.hasMoreElements();) {
Entity ent = e.nextElement();
Coords entPos = ent.getPosition();
int range = ent.getECMRange();
boolean deployed = ent.isDeployed();
boolean offboard = ent.isOffBoard();
if((entPos == null) && (ent.getTransportId() != Entity.NONE)) {
Entity carrier = game.getEntity(ent.getTransportId());
if((null != carrier) && carrier.loadedUnitsHaveActiveECM()) {
entPos = carrier.getPosition();
deployed = carrier.isDeployed();
offboard = carrier.isOffBoard();
}
}
if ((entPos == null) || !deployed || offboard) {
continue;
}
if (range != Entity.NONE) {
int tint = PlayerColors.getColorRGB(ent.getOwner().getColorIndex());
list.add(new EcmBubble(entPos, range, tint));
}
if(game.getBoard().inSpace()) {
//then BAP is also ECCM so it needs a bubble
range = ent.getBAPRange();
int direction = -1;
if (range != Entity.NONE) {
if(range > 6) {
direction = ent.getFacing();
}
int tint = PlayerColors.getColorRGB(ent.getOwner()
.getColorIndex());
list.add(new EcmBubble(entPos, range, tint, direction));
}
}
}
HashMap<Coords, Integer> table = new HashMap<Coords, Integer>();
for (EcmBubble b : list) {
Integer col = new Integer(b.tint);
for (int x = -b.range; x <= b.range; x++) {
for (int y = -b.range; y <= b.range; y++) {
Coords c = new Coords(x + b.x, y + b.y);
// clip rectangle to hexagon
if ((b.distance(c) <= b.range) && ((b.direction == -1) || Compute.isInArc(b, b.direction, c, Compute.ARC_NOSE))) {
Integer tint = table.get(c);
if (tint == null) {
table.put(c, col);