forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExperienceValueHelper.cpp
More file actions
33 lines (29 loc) · 882 Bytes
/
Copy pathExperienceValueHelper.cpp
File metadata and controls
33 lines (29 loc) · 882 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
31
32
33
#include "ExperienceValueHelper.hpp"
#include "Components.hpp"
#include "EntitySystem.hpp"
void ExperienceValueHelper::set(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<ExperienceValueComponent>(id);
if(comp)
comp->value = val;
}
std::size_t ExperienceValueHelper::get(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<ExperienceValueComponent>(id);
if(comp)
return comp->value;
else
return std::size_t{};
}
void ExperienceValueHelper::increase(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<ExperienceValueComponent>(id);
if(comp)
comp->value += val;
}
void ExperienceValueHelper::decrease(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<ExperienceValueComponent>(id);
if(comp && comp->value >= val)
comp->value -= val;
}