MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getItems

Method getItems

game/state/tilemap/tile.cpp:577–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577std::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

Callers 2

orderDropMethod · 0.80

Calls 3

getItemMethod · 0.80
getTileMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected