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

Method addEntity

source/game/StarWorldClient.cpp:1363–1379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363void WorldClient::addEntity(EntityPtr const& entity, EntityId entityId) {
1364 if (!entity)
1365 return;
1366
1367 if (!inWorld())
1368 return;
1369
1370 if (entity->clientEntityMode() != ClientEntityMode::ClientSlaveOnly) {
1371 entity->init(this, m_entityMap->reserveEntityId(entityId), EntityMode::Master);
1372 m_entityMap->addEntity(entity);
1373 notifyEntityCreate(entity);
1374 } else {
1375 auto entityFactory = Root::singleton().entityFactory();
1376 auto netRules = m_clientState.netCompatibilityRules();
1377 m_outgoingPackets.append(make_shared<SpawnEntityPacket>(entity->entityType(), entityFactory->netStoreEntity(entity, netRules), entity->writeNetState(0, netRules).first));
1378 }
1379}
1380
1381TileDamageResult WorldClient::damageTiles(List<Vec2I> const& pos, TileLayer layer, Vec2F const& sourcePosition, TileDamage const& tileDamage, Maybe<EntityId> sourceEntity) {
1382 if (!inWorld())

Callers 3

reviveMainPlayerMethod · 0.45
handleIncomingPacketsMethod · 0.45
initWorldMethod · 0.45

Calls 10

singletonClass · 0.85
reserveEntityIdMethod · 0.80
entityFactoryMethod · 0.80
netStoreEntityMethod · 0.80
clientEntityModeMethod · 0.45
initMethod · 0.45
netCompatibilityRulesMethod · 0.45
appendMethod · 0.45
entityTypeMethod · 0.45
writeNetStateMethod · 0.45

Tested by

no test coverage detected