forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombatHelper.cpp
More file actions
91 lines (80 loc) · 2.13 KB
/
CombatHelper.cpp
File metadata and controls
91 lines (80 loc) · 2.13 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "CombatHelper.hpp"
#include "Components.hpp"
#include "EntitySystem.hpp"
void CombatHelper::set_target(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
comp->curr_target = val;
}
std::size_t CombatHelper::get_target(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
return comp->curr_target;
else
return Component::NO_ENTITY;
}
void CombatHelper::set_range(EntitySystem& ents, std::size_t id, Ogre::Real range)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
comp->range = range;
}
Ogre::Real CombatHelper::get_range(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
return comp->range;
else
return 0;
}
void CombatHelper::set_dmg_range(EntitySystem& ents, std::size_t id, std::size_t min, std::size_t max)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
{
comp->min_dmg = min;
comp->max_dmg = max;
}
}
std::tuple<std::size_t, std::size_t> CombatHelper::get_dmg_range(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
return std::make_tuple(comp->min_dmg, comp->max_dmg);
else
return std::tuple<std::size_t, std::size_t>{};
}
std::size_t CombatHelper::get_dmg(std::size_t min, std::size_t max)
{
return util::get_random(min, max);
}
void CombatHelper::set_cooldown(EntitySystem& ents, std::size_t id, Ogre::Real cd)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
comp->cooldown = cd;
}
Ogre::Real CombatHelper::get_cooldown(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
return comp->cooldown;
else
return 0;
}
void CombatHelper::set_atk_type(EntitySystem& ents, std::size_t id, ATTACK_TYPE type)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
comp->atk_type = type;
}
ATTACK_TYPE CombatHelper::get_atk_type(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<CombatComponent>(id);
if(comp)
return comp->atk_type;
else
return ATTACK_TYPE::NONE;
}