Potato Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
World.cpp
Go to the documentation of this file.
1
2
3
#include "
Debug/Debug.hpp
"
4
#include "
Game/Actors/Player.hpp
"
5
6
#include "
World.hpp
"
7
8
World::World() {
9
10
}
11
12
World::~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
23
void
World::DestroyActor
(
Actor
* actor) {
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
32
const
ActorPool
&
World::GetAllActors
()
const
33
{
34
return
actorPool;
35
}
36
37
Actor
*
World::AddtoPool
(
Actor
* actor) {
38
if
(actor ==
nullptr
) {
return
nullptr
; }
39
40
actorPool.push_back(actor);
41
return
actor;
42
}
Debug.hpp
Player.hpp
World.hpp
ActorPool
std::vector< Actor * > ActorPool
Collection of actors in world.
Definition
World.hpp:11
Actor
Base actor class.
Definition
Actor.hpp:14
World::DestroyActor
void DestroyActor(Actor *actor)
Destroys actor from world.
Definition
World.cpp:23
World::AddtoPool
Actor * AddtoPool(Actor *actor)
Attempts to add external actor object to world managing system.
Definition
World.cpp:37
World::GetAllActors
const ActorPool & GetAllActors() const
Gets ActorPool.
Definition
World.cpp:32
Game
World.cpp
Generated by
1.17.0