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

Method removeEntity

source/game/StarWorldServer.cpp:2180–2202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2178}
2179
2180void WorldServer::removeEntity(EntityId entityId, bool andDie) {
2181 auto entity = m_entityMap->entity(entityId);
2182 if (!entity)
2183 return;
2184
2185 if (auto tileEntity = as<TileEntity>(entity))
2186 updateTileEntityTiles(tileEntity, true);
2187
2188 if (andDie)
2189 entity->destroy(nullptr);
2190
2191 for (auto const& pair : m_clientInfo) {
2192 auto& clientInfo = pair.second;
2193 if (auto version = clientInfo->clientSlavesNetVersion.maybeTake(entity->entityId())) {
2194 auto netRules = clientInfo->clientState.netCompatibilityRules();
2195 ByteArray finalDelta = entity->writeNetState(*version, netRules).first;
2196 clientInfo->outgoingPackets.append(make_shared<EntityDestroyPacket>(entity->entityId(), std::move(finalDelta), andDie));
2197 }
2198 }
2199
2200 m_entityMap->removeEntity(entityId);
2201 entity->uninit();
2202}
2203
2204float WorldServer::windLevel(Vec2F const& pos) const {
2205 return WorldImpl::windLevel(m_tileArray, pos, m_weather.wind());

Callers

nothing calls this directly

Calls 8

entityIdMethod · 0.80
entityMethod · 0.45
destroyMethod · 0.45
maybeTakeMethod · 0.45
netCompatibilityRulesMethod · 0.45
writeNetStateMethod · 0.45
appendMethod · 0.45
uninitMethod · 0.45

Tested by

no test coverage detected