1
0

Changed entity ownership model to use smart pointers

This commit is contained in:
Tiger Wang
2016-12-19 20:12:23 +00:00
parent 07f25253a2
commit 4ef47aed62
39 changed files with 484 additions and 425 deletions

View File

@@ -7,6 +7,7 @@
#include "ChunkDesc.h"
#include "../Noise/Noise.h"
#include "../BlockEntities/BlockEntity.h"
#include "../Entities/Entity.h"

View File

@@ -231,7 +231,7 @@ private:
cChunkDef::BiomeMap m_BiomeMap;
cBlockArea m_BlockArea;
cChunkDef::HeightMap m_HeightMap;
cEntityList m_Entities; // Individual entities are NOT owned by this object!
cEntityList m_Entities;
cBlockEntities m_BlockEntities; // Individual block entities are NOT owned by this object!
bool m_bUseDefaultBiomes;

View File

@@ -1489,11 +1489,11 @@ bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX
double AnimalY = a_RelY;
double AnimalZ = static_cast<double>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ + 0.5);
cMonster * NewMob = cMonster::NewMonsterFromType(AnimalToSpawn);
auto NewMob = cMonster::NewMonsterFromType(AnimalToSpawn);
NewMob->SetHealth(NewMob->GetMaxHealth());
NewMob->SetPosition(AnimalX, AnimalY, AnimalZ);
a_ChunkDesc.GetEntities().push_back(NewMob);
LOGD("Spawning %s #%i at {%.02f, %.02f, %.02f}", NewMob->GetClass(), NewMob->GetUniqueID(), AnimalX, AnimalY, AnimalZ);
a_ChunkDesc.GetEntities().emplace_back(std::move(NewMob));
return true;
}