forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicsSystem.cpp
More file actions
47 lines (41 loc) · 1.02 KB
/
GraphicsSystem.cpp
File metadata and controls
47 lines (41 loc) · 1.02 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "GraphicsSystem.hpp"
GraphicsSystem::GraphicsSystem(EntitySystem& ents)
: entities_{ents}, update_timer_{}, update_period_{1.f}
{ /* DUMMY BODY */ }
void GraphicsSystem::update(Ogre::Real delta)
{
if(update_timer_ < update_period_)
update_timer_ += delta;
else
{
update_timer_ = 0.f;
for(auto& ent : entities_.get_component_container<ExplosionComponent>())
{
if(ent.second.curr_radius >= ent.second.max_radius)
{
DestructorHelper::destroy(entities_, ent.first);
continue;
}
auto comp = entities_.get_component<GraphicsComponent>(ent.first);
if(comp && comp->node)
{
ent.second.curr_radius += ent.second.delta;
if(comp->manual_scaling)
{
comp->scale += ent.second.delta;
comp->node->setScale(comp->scale);
}
else
comp->node->setScale(comp->node->getScale() + ent.second.delta);
}
}
}
}
void GraphicsSystem::set_update_period(Ogre::Real val)
{
update_period_ = val;
}
Ogre::Real GraphicsSystem::get_update_period() const
{
return update_period_;
}