package model.entities; import model.world.Direction; import model.world.Position; import java.util.Set; public abstract class AbsActive extends AbsPassive implements IActive { /** * Change the current position by the position given */ @Override public void setPos(Position position) { pos = position; } /** * @param d direction in which to move * This functions can not check if the move is valid because the player * is not aware of the size of the grid in which he evolves. The controller * must first check the validity of the move. */ @Override public void move(Direction d) { // TODO Auto-generated method stub pos = new Position(pos.x + d.dx, pos.y + d.dy); } /** * Check if the Entity is not it and * check if the position of the other Entity is close enough to interact. * * @param entity_set The Set of all Entities to compute the interaction. */ @Override public void interact(Set entity_set) { // TODO Auto-generated method stub for(IEntity entity: entity_set) if (entity != this && Position.distance(this.getPos(), entity.getPos()) <= 1) { interact(entity); } } }