+ } else {
+ controlled->SetSpeed(0.0f);
+ StopFollowers(*controlled);
+ controlled->StopAnimation();
+ moveTimer.Clear();
+ if (pushed) {
+ pushed->SetSpeed(0.0f);
+ pushed = 0;
+ }
+ }
+
+ lastLock = nowLock;
+}
+
+bool MapState::CheckBlocking() {
+ if (pushed) {
+ pushed->SetSpeed(0.0f);
+ pushed = 0;
+ }
+ const Tile *tile(map->TileAt(controlled->Position()));
+ Vector<int> direction;
+ switch (nextDirection) {
+ case Entity::ORIENTATION_NORTH:
+ if (tile && tile->BlocksNorth()) {
+ return true;
+ } else {
+ direction = Vector<int>(0, -map->Tileset()->Height());
+ }
+ break;
+ case Entity::ORIENTATION_EAST:
+ if (tile && tile->BlocksEast()) {
+ return true;
+ } else {
+ direction = Vector<int>(map->Tileset()->Width(), 0);
+ }
+ break;
+ case Entity::ORIENTATION_SOUTH:
+ if (tile && tile->BlocksSouth()) {
+ return true;
+ } else {
+ direction = Vector<int>(0, map->Tileset()->Height());
+ }
+ break;
+ case Entity::ORIENTATION_WEST:
+ if (tile && tile->BlocksWest()) {
+ return true;
+ } else {
+ direction = Vector<int>(-map->Tileset()->Width(), 0);
+ }
+ break;
+ default:
+ return false;
+ }
+ Vector<int> nextTilePosition(direction + controlled->Position());
+ Vector<int> nextTileCoords(map->TileCoordinates(nextTilePosition));
+ for (std::vector<Entity *>::const_iterator i(entities.begin()), end(entities.end()); i != end; ++i) {
+ const Entity &e(**i);
+ if (map->TileCoordinates(e.Position()) != nextTileCoords) continue;
+ if (!e.Blocking()) continue;
+ if (!pushing || !e.Pushable()) return true;
+ if (CheckBlocking(nextTilePosition, Entity::Orientation(nextDirection))) return true;
+ pushed = *i;
+ }
+ return false;
+}
+
+bool MapState::CheckBlocking(const Vector<int> &position, Entity::Orientation direction) const {
+ const Tile *tile(map->TileAt(position));
+ Vector<int> directionVector;
+ switch (direction) {
+ case Entity::ORIENTATION_NORTH:
+ if (tile && tile->BlocksNorth()) {
+ return true;
+ } else {
+ directionVector = Vector<int>(0, -map->Tileset()->Height());
+ }
+ break;
+ case Entity::ORIENTATION_EAST:
+ if (tile && tile->BlocksEast()) {
+ return true;
+ } else {
+ directionVector = Vector<int>(map->Tileset()->Width(), 0);
+ }
+ break;
+ case Entity::ORIENTATION_SOUTH:
+ if (tile && tile->BlocksSouth()) {
+ return true;
+ } else {
+ directionVector = Vector<int>(0, map->Tileset()->Height());
+ }
+ break;
+ case Entity::ORIENTATION_WEST:
+ if (tile && tile->BlocksWest()) {
+ return true;
+ } else {
+ directionVector = Vector<int>(-map->Tileset()->Width(), 0);
+ }
+ break;
+ default:
+ return false;
+ }
+ Vector<int> nextTileCoords(map->TileCoordinates(directionVector + position));
+ for (std::vector<Entity *>::const_iterator i(entities.begin()), end(entities.end()); i != end; ++i) {
+ const Entity &e(**i);
+ if (map->TileCoordinates(e.Position()) == nextTileCoords && e.Blocking()) {
+ return true;