* Set the door open or closed.
*
* @param open true if the door is opened, false otherwise
*/
private void setOpen(final boolean open) {
final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
if (open) {
setResistance(0);
if (autoCloseDelay != 0) {
turnNotifier.notifyInSeconds(autoCloseDelay, this);
}
} else {
// Closing the gate - check there's nobody on the way
if (getZone() != null) {
for (Entity entity : getZone().getEntitiesAt(getX(), getY())) {
if (entity.getResistance() > 0) {
return;
}
}
}
setResistance(100);
// Stop the notifier, so that the door does not slam in front
// of someone who just opened it
turnNotifier.dontNotify(this);
}
isOpen = open;
notifyWorldAboutChanges();
}