diff options
author | mgueydan <gueydan.mathieuÃ@gmail.com> | 2013-09-08 00:11:38 +0200 |
---|---|---|
committer | mgueydan <gueydan.mathieuÃ@gmail.com> | 2013-09-08 00:11:38 +0200 |
commit | bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f (patch) | |
tree | 9c47274f2e308991d15422dcf515710c28fc5ab7 /source/ChunkMap.cpp | |
parent | Adding mob census (sorry this is a big commit as work was done before git integration i couldn't split it more) (diff) | |
download | cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar.gz cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar.bz2 cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar.lz cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar.xz cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.tar.zst cuberite-bf1fb0aa3dbd5b6b793d920c4e301e4782fe0f0f.zip |
Diffstat (limited to '')
-rw-r--r-- | source/ChunkMap.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index 610b293b5..f5cbacdc7 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -13,6 +13,7 @@ #include "PluginManager.h" #include "Entities/TNTEntity.h" #include "MobCensus.h" +#include "MobSpawner.h" #ifndef _WIN32 #include <cstdlib> // abs @@ -2167,6 +2168,19 @@ void cChunkMap::CollectMobCensus(cMobCensus& a_ToFill) +void cChunkMap::SpawnMobs(cMobSpawner& a_MobSpawner) +{ + cCSLock Lock(m_CSLayers); + for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) + { + (*itr)->SpawnMobs(a_MobSpawner); + } // for itr - m_Layers +} + + + + + void cChunkMap::Tick(float a_Dt) { cCSLock Lock(m_CSLayers); @@ -2343,6 +2357,20 @@ void cChunkMap::cChunkLayer::CollectMobCensus(cMobCensus& a_ToFill) +void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner) +{ + for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + { + // We only spawn close to players + if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients()) + { + m_Chunks[i]->SpawnMobs(a_MobSpawner); + } + } // for i - m_Chunks[] +} + + + void cChunkMap::cChunkLayer::Tick(float a_Dt) { for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) |