| 527 | } |
| 528 | |
| 529 | void DungeonGeneratorWorld::clearTileEntities(RectI const& bounds, Set<Vec2I> const& positions, bool clearAnchoredObjects) { |
| 530 | auto entities = m_worldServer->entityQuery(RectF(bounds).padded(1), entityTypeFilter<TileEntity>()); |
| 531 | auto geometry = m_worldServer->geometry(); |
| 532 | entities.filter([positions, geometry, clearAnchoredObjects](EntityPtr entity) { |
| 533 | auto tileEntity = as<TileEntity>(entity); |
| 534 | for (auto pos : tileEntity->spaces()) { |
| 535 | if (positions.contains(geometry.xwrap(pos + tileEntity->tilePosition()))) |
| 536 | return true; |
| 537 | } |
| 538 | if (clearAnchoredObjects) { |
| 539 | for (auto pos : tileEntity->roots()) { |
| 540 | if (positions.contains(geometry.xwrap(pos + tileEntity->tilePosition()))) |
| 541 | return true; |
| 542 | } |
| 543 | if (auto object = as<Object>(entity)) { |
| 544 | for (auto pos : object->anchorPositions()) { |
| 545 | if (positions.contains(geometry.xwrap(pos))) |
| 546 | return true; |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | return false; |
| 552 | }); |
| 553 | |
| 554 | for (auto entity : entities) |
| 555 | m_worldServer->removeEntity(entity->entityId(), false); |
| 556 | } |
| 557 | |
| 558 | SpawnerWorld::SpawnerWorld(WorldServer* server) |
| 559 | : m_worldServer(server) {} |
nothing calls this directly
no test coverage detected