MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / clearTileEntities

Method clearTileEntities

source/game/StarWorldGeneration.cpp:529–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void 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
558SpawnerWorld::SpawnerWorld(WorldServer* server)
559 : m_worldServer(server) {}

Callers

nothing calls this directly

Calls 12

paddedMethod · 0.80
anchorPositionsMethod · 0.80
entityIdMethod · 0.80
entityQueryMethod · 0.45
geometryMethod · 0.45
filterMethod · 0.45
spacesMethod · 0.45
containsMethod · 0.45
xwrapMethod · 0.45
tilePositionMethod · 0.45
rootsMethod · 0.45
removeEntityMethod · 0.45

Tested by

no test coverage detected