| 575 | } |
| 576 | |
| 577 | std::list<sp<BattleItem>> Tile::getItems() |
| 578 | { |
| 579 | std::list<sp<BattleItem>> result; |
| 580 | for (auto &o : ownedObjects) |
| 581 | { |
| 582 | if (o->getType() == TileObject::Type::Item) |
| 583 | { |
| 584 | auto item = std::static_pointer_cast<TileObjectBattleItem>(o)->getItem(); |
| 585 | if (!item->falling) |
| 586 | { |
| 587 | result.push_back(item); |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | for (int x = -1; x <= 1; x++) |
| 592 | { |
| 593 | for (int y = -1; y <= 1; y++) |
| 594 | { |
| 595 | if (x == 0 && y == 0) |
| 596 | { |
| 597 | continue; |
| 598 | } |
| 599 | auto pos = Vec3<int>{position.x + x, position.y + y, position.z}; |
| 600 | if (pos.x < 0 || pos.x >= map.size.x || pos.y < 0 || pos.y >= map.size.y) |
| 601 | continue; |
| 602 | auto t = map.getTile(pos); |
| 603 | for (auto &o : t->ownedObjects) |
| 604 | { |
| 605 | if (o->getType() == TileObject::Type::Item) |
| 606 | { |
| 607 | auto item = std::static_pointer_cast<TileObjectBattleItem>(o)->getItem(); |
| 608 | if (!item->falling) |
| 609 | { |
| 610 | result.push_back(item); |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | return result; |
| 617 | } |
| 618 | |
| 619 | }; // namespace OpenApoc |
no test coverage detected