-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSys_Gravity.cpp
More file actions
59 lines (48 loc) · 1.12 KB
/
Sys_Gravity.cpp
File metadata and controls
59 lines (48 loc) · 1.12 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
#include "Sys_Gravity.h"
#include "SysManager.h"
#include "WindowManager.h"
Sys_Gravity::Sys_Gravity(SysManager* systemManager) :
Sys(systemManager)
{
onCreate();
}
Sys_Gravity::~Sys_Gravity()
{
onDestroy();
}
void Sys_Gravity::start()
{
}
void Sys_Gravity::setupRequirements()
{
Bitmask req;
req.set((unsigned int)ComponentType::Movement);
req.set((unsigned int)ComponentType::Mass);
m_requirements.emplace_back(req);
}
void Sys_Gravity::subscribeToChannels()
{
}
void Sys_Gravity::unsubscribeFromChannels()
{
}
void Sys_Gravity::update(const float& deltaTime)
{
for (auto& id : m_actorIds)
{
auto actor = m_systemManager->getActorManager()->getActor(id);
auto massComp = actor->getComponent<Comp_Mass>(ComponentType::Mass);
auto moveComp = actor->getComponent<Comp_Movement>(ComponentType::Movement);
sf::Vector2f gravityForce = massComp->getMass() * M_GRAVITY * M_DOWN;
moveComp->accelerate(gravityForce);
}
}
void Sys_Gravity::handleEvent(const ActorId& actorId, const ActorEventType& eventId)
{
}
void Sys_Gravity::debugOverlay(WindowManager* windowManager)
{
}
void Sys_Gravity::notify(const Message& msg)
{
}