forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventHelper.cpp
83 lines (73 loc) · 1.88 KB
/
EventHelper.cpp
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
#include "EventHelper.hpp"
#include "Components.hpp"
#include "EntitySystem.hpp"
void EventHelper::set_event_type(EntitySystem& ents, std::size_t id, EVENT_TYPE val)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
comp->event_type = val;
}
EVENT_TYPE EventHelper::get_event_type(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
return comp->event_type;
else
return EVENT_TYPE::NONE;
}
void EventHelper::set_target(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
comp->target = val;
}
std::size_t EventHelper::get_target(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
return comp->target;
else
return Component::NO_ENTITY;
}
void EventHelper::set_radius(EntitySystem& ents, std::size_t id, Ogre::Real val)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
comp->radius = val;
}
Ogre::Real EventHelper::get_radius(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
return comp->radius;
else
return 0.000001f;
}
void EventHelper::set_active(EntitySystem& ents, std::size_t id, bool val)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
comp->active = val;
}
bool EventHelper::is_active(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
return comp->active;
else
return false;
}
void EventHelper::set_event_handler(EntitySystem& ents, std::size_t id, std::size_t val)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
comp->handler = val;
}
std::size_t EventHelper::get_event_handler(EntitySystem& ents, std::size_t id)
{
auto comp = ents.get_component<EventComponent>(id);
if(comp)
return comp->handler;
else
return Component::NO_ENTITY;
}