}
}
@Override
public synchronized boolean setAgentPosition(int agentID, Vector2D newPosition) {
Polygon2D tile = this.getAgent(agentID).getAgentShape();
// Delete old position.
this.drawTile(
this.getAgent(agentID).getAgentShape(),
this.getAgentPosition(agentID),
this.getAgentAngle(agentID),
false);
// Try new position.
Polygon2D newShape = new Polygon2D();
for (Vector2D v : tile) {
newShape.add(new Vector2D(v));
}
newShape.rotate(Vector2D.NULL_VECTOR, this.getAgentAngle(agentID));
for (Vector2D p : newShape) {
Vector2D reqPos = new Vector2D(newPosition);
reqPos.translate(p);
if (this.getPix((int) Math.round(reqPos.x), (int) Math.round(reqPos.y))) {
// Redraw old position.