diff options
author | mgueydan <gueydan.mathieuÃ@gmail.com> | 2013-09-07 22:19:56 +0200 |
---|---|---|
committer | mgueydan <gueydan.mathieuÃ@gmail.com> | 2013-09-07 22:19:56 +0200 |
commit | d2eb58f27780a3c65fedd0d21d152ee8866ebb86 (patch) | |
tree | 05160377f78b97b4916956eebfd07f8a830a8916 /source/Chunk.cpp | |
parent | Adding a getType in Monster that return an enum instead of an int or char (diff) | |
download | cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.gz cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.bz2 cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.lz cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.xz cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.zst cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.zip |
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r-- | source/Chunk.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp index db533f642..59a65a537 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -30,6 +30,8 @@ #include "PluginManager.h" #include "Blocks/BlockHandler.h" #include "Simulator/FluidSimulator.h" +#include "MobCensus.h" + #include <json/json.h> @@ -429,6 +431,43 @@ void cChunk::Stay(bool a_Stay) +void cChunk::CollectMobCensus(cMobCensus& toFill) +{ + toFill.CollectSpawnableChunck(*this); + std::list<const Vector3d*> playerPositions; + cPlayer* currentPlayer; + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr) + { + currentPlayer = (*itr)->GetPlayer(); + playerPositions.push_back(&(currentPlayer->GetPosition())); + } + + Vector3d currentPosition; + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) + { + //LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); + if ((*itr)->IsMob()) + { + try + { + cMonster& Monster = (cMonster&)(**itr); + currentPosition = Monster.GetPosition(); + for (std::list<const Vector3d*>::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); itr2 ++) + { + toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength()); + } + } + catch (std::bad_cast& e) + { + LOGD("Something wrong happend I'm collecting an entity that respond 'true' to IsMob() but are not castable in cMonster - No Action"); + } + } + } // for itr - m_Entitites[] +} + + + + void cChunk::Tick(float a_Dt) { |