Entity refactor loose ends
Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
This commit is contained in:
@@ -36,9 +36,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool mHasBegun;
|
bool mHasBegun;
|
||||||
Dict<entId, unique<EEntity>> mEntities_;
|
Dict<entId, unique<EEntity>> mEntities;
|
||||||
std::vector<unique<EEntity>>
|
|
||||||
mEntities;
|
|
||||||
std::vector<unique<EEntity>> mPendingEntities;
|
std::vector<unique<EEntity>> mPendingEntities;
|
||||||
|
|
||||||
////////// Static
|
////////// Static
|
||||||
|
|||||||
@@ -11,18 +11,14 @@ void WWorld::Begin() {
|
|||||||
}
|
}
|
||||||
void WWorld::Tick(float deltaTime) {
|
void WWorld::Tick(float deltaTime) {
|
||||||
|
|
||||||
// for (auto &entity : mPendingEntities) {
|
|
||||||
// entity->Begin();
|
|
||||||
// mEntities.push_back(std::move(entity));
|
|
||||||
// }
|
|
||||||
for (auto &entity : mPendingEntities) {
|
for (auto &entity : mPendingEntities) {
|
||||||
entity->Begin();
|
entity->Begin();
|
||||||
mEntities_.emplace(entity->Id, std::move(entity));
|
mEntities.emplace(entity->Id, std::move(entity));
|
||||||
}
|
}
|
||||||
mPendingEntities.clear();
|
mPendingEntities.clear();
|
||||||
|
|
||||||
for (auto iter = mEntities.begin(); iter != mEntities.end();) {
|
for (auto iter = mEntities.begin(); iter != mEntities.end();) {
|
||||||
if ((*iter)->IsDestroyed()) {
|
if ((*iter).second->IsDestroyed()) {
|
||||||
iter = mEntities.erase(iter);
|
iter = mEntities.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
++iter;
|
++iter;
|
||||||
@@ -30,7 +26,7 @@ void WWorld::Tick(float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto &entity : mEntities) {
|
for (auto &entity : mEntities) {
|
||||||
entity->Tick(deltaTime);
|
entity.second->Tick(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WWorld::FixedTick() {}
|
void WWorld::FixedTick() {}
|
||||||
@@ -44,13 +40,13 @@ void WWorld::Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EEntity &WWorld::GetEntity(entId id) {
|
EEntity &WWorld::GetEntity(entId id) {
|
||||||
return *mEntities_.find(id)->second;
|
return *mEntities.find(id)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WWorld::DestroyEntity(entId id) {
|
void WWorld::DestroyEntity(entId id) {
|
||||||
for (auto &entity : mEntities) {
|
for (auto &entity : mEntities) {
|
||||||
if (entity->Id == id) {
|
if (entity.second->Id == id) {
|
||||||
entity->Destroy();
|
entity.second->Destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +54,7 @@ void WWorld::DestroyEntity(entId id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t WWorld::GetTotalEntities() {
|
size_t WWorld::GetTotalEntities() {
|
||||||
return mEntities_.size();
|
return mEntities.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace craft
|
} // namespace craft
|
||||||
|
|||||||
Reference in New Issue
Block a user