-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAreaAttackSystem.cpp
78 lines (55 loc) · 1.98 KB
/
AreaAttackSystem.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
#include "pch.h"
#include "AreaAttackSystem.h"
#include "StatesInclude.h"
AreaAttackSystem::AreaAttackSystem(std::shared_ptr<SceneManager> sceneManager) : System(sceneManager)
{
}
void AreaAttackSystem::TriggerAttack(AreaAttackComponent& area, EnemyComponent& enemy)
{
EventManager::GetInstance().ImmediateEvent("OnDamaged", std::make_pair(enemy.GetEntityID(), area.Damage));
}
void AreaAttackSystem::FixedUpdate(float deltaTime)
{
COMPLOOP(AreaAttackComponent, areacomp)
{
if (!areacomp.AttachedEntity.lock())
continue;
auto& attachtrans = *areacomp.AttachedEntity.lock().get()->GetComponent<TransformComponent>();
auto& maintrans = *areacomp.GetComponent<TransformComponent>();
maintrans.SetLocalLocation(attachtrans.World_Location);
maintrans.SetLocalQuaternion(attachtrans.World_Quaternion);
}
}
void AreaAttackSystem::Initialize()
{
COMPLOOP(AreaAttackComponent, areacomp)
Start(areacomp.GetEntityID());
}
void AreaAttackSystem::Start(uint32_t gameObjectId)
{
auto& entity = *GetSceneManager()->GetEntity(gameObjectId);
if (!entity.HasComponent<AreaAttackComponent>())
return;
auto& area = *entity.GetComponent<AreaAttackComponent>();
auto attachentity = GetSceneManager()->GetEntityByIdentityName(area.IdentityAttach);
if (attachentity)
{
area.AttachedEntity = attachentity;
}
}
void AreaAttackSystem::Finish(uint32_t gameObjectId)
{
}
void AreaAttackSystem::Finalize()
{
}
void AreaAttackSystem::EnterTrigger(std::shared_ptr<Entity> first, std::shared_ptr<Entity> second)
{
if (first->HasComponent<AreaAttackComponent>()&& second->HasComponent<EnemyComponent>())
TriggerAttack(*first->GetComponent<AreaAttackComponent>(), *second->GetComponent<EnemyComponent>());
else if (first->HasComponent<EnemyComponent>() && second->HasComponent<AreaAttackComponent>())
TriggerAttack(*second->GetComponent<AreaAttackComponent>(), *first->GetComponent<EnemyComponent>());
}
void AreaAttackSystem::ExitTrigger(std::shared_ptr<Entity> first, std::shared_ptr<Entity> second)
{
}