Add NPC chunk management + Generalize lerp

This commit is contained in:
Gent
2020-09-23 10:53:06 -04:00
parent 65bd2d120b
commit f2596bfb6a
7 changed files with 38 additions and 18 deletions

View File

@@ -56,6 +56,17 @@ void ChunkManager::removePlayer(std::pair<int, int> chunkPos, CNSocket* sock) {
// TODO: if players and NPCs are empty, free chunk and remove it from surrounding views
}
void ChunkManager::removeNPC(std::pair<int, int> chunkPos, int32_t id) {
if (!checkChunk(chunkPos))
return; // do nothing if chunk doesn't even exist
Chunk* chunk = chunks[chunkPos];
chunk->NPCs.erase(id); // gone
// TODO: if players and NPCs are empty, free chunk and remove it from surrounding views
}
bool ChunkManager::checkChunk(std::pair<int, int> chunk) {
return chunks.find(chunk) != chunks.end();
}