1
0

World:DoWithEntityByID() checks the entities-to-add as well.

This allows plugins to create entities and immediately act on them using that call. This will most likely need to be added to most of the DoWith<> and ForEach<> calls.
This commit is contained in:
Mattes D 2015-03-18 15:35:19 +01:00
parent c41183d450
commit 49e59ee06b

View File

@ -2911,6 +2911,20 @@ bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
bool cWorld::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback)
{
// First check the entities-to-add:
{
cCSLock Lock(m_CSEntitiesToAdd);
for (auto & ent: m_EntitiesToAdd)
{
if (ent->GetUniqueID() == a_UniqueID)
{
a_Callback.Item(ent);
return true;
}
} // for ent - m_EntitiesToAdd[]
}
// Then check the chunkmap:
return m_ChunkMap->DoWithEntityByID(a_UniqueID, a_Callback);
}