Potato Engine
Loading...
Searching...
No Matches
World.cpp
Go to the documentation of this file.
1
2
3#include "Debug/Debug.hpp"
5
6#include "World.hpp"
7
8World::World() {
9
10}
11
12World::~World() {
13
14 while (!actorPool.empty()) {
15 Actor* actor = actorPool.back();
16
17 delete actor; // free memory
18 actorPool.pop_back(); // erase nullptr
19 }
20
21}
22
24 auto it = std::find(actorPool.begin(), actorPool.end(), actor);
25
26 if (it != actorPool.end()) {
27 delete *it; // free memory
28 actorPool.erase(it); // erase nullptr
29 }
30}
31
33{
34 return actorPool;
35}
36
38 if (actor == nullptr) { return nullptr; }
39
40 actorPool.push_back(actor);
41 return actor;
42}
std::vector< Actor * > ActorPool
Collection of actors in world.
Definition World.hpp:11
Base actor class.
Definition Actor.hpp:14
void DestroyActor(Actor *actor)
Destroys actor from world.
Definition World.cpp:23
Actor * AddtoPool(Actor *actor)
Attempts to add external actor object to world managing system.
Definition World.cpp:37
const ActorPool & GetAllActors() const
Gets ActorPool.
Definition World.cpp:32