forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDestructorHelper.cpp
More file actions
30 lines (26 loc) · 908 Bytes
/
Copy pathDestructorHelper.cpp
File metadata and controls
30 lines (26 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "DestructorHelper.hpp"
#include "Components.hpp"
#include "EntitySystem.hpp"
#include "Util.hpp"
void DestructorHelper::set_blueprint(EntitySystem& ents, std::size_t id, const std::string& val)
{
auto comp = ents.get_component<DestructorComponent>(id);
if(comp)
comp->blueprint = val;
}
const std::string & DestructorHelper::get_blueprint(EntitySystem& ents, std::size_t id)
{
static std::string NO_BLUEPRINT{"ERROR"};
auto comp = ents.get_component<DestructorComponent>(id);
if(comp)
return comp->blueprint;
else
return NO_BLUEPRINT;
}
void DestructorHelper::destroy(EntitySystem& ents, std::size_t id, bool supress_dtor, std::size_t killer)
{
auto comp = ents.get_component<DestructorComponent>(id);
if(comp && !supress_dtor)
lpp::Script::get_singleton().call<void, std::size_t, std::size_t>(comp->blueprint + ".dtor", id, killer);
util::EntityDestroyer::destroy(ents, id);
}