-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityRemoverSystem.cpp
More file actions
51 lines (42 loc) · 1.33 KB
/
EntityRemoverSystem.cpp
File metadata and controls
51 lines (42 loc) · 1.33 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
#include "pch.h"
#include "EntityRemoverSystem.h"
#include "VisPredComponents.h"
EntityRemoverSystem::EntityRemoverSystem(std::shared_ptr<SceneManager> scenemanager) :System(scenemanager)
{
}
void EntityRemoverSystem::EnterTrigger(std::shared_ptr<Entity> first, std::shared_ptr<Entity> second)
{
if (first->HasComponent<EntityRemoverComponet>())
AddRemoveEntity(first, second);
else if(second->HasComponent<EntityRemoverComponet>())
AddRemoveEntity(second, first);
}
void EntityRemoverSystem::ExitTrigger(std::shared_ptr<Entity> first, std::shared_ptr<Entity> second)
{
}
void EntityRemoverSystem::AddRemoveEntity(std::shared_ptr<Entity> remover, std::shared_ptr<Entity> removing)
{
auto removecomp = remover->GetComponent<EntityRemoverComponet>();
removecomp->RemoveEntitys.push_back(removing->GetEntityID());
}
void EntityRemoverSystem::Initialize()
{
}
void EntityRemoverSystem::Start(uint32_t gameObjectId)
{
}
void EntityRemoverSystem::Finish(uint32_t gameObjectId)
{
auto entity = GetSceneManager()->GetEntity(gameObjectId);
if (!entity->HasComponent<EntityRemoverComponet>())
return;
auto remover = entity->GetComponent<EntityRemoverComponet>();
for (auto entityid : remover->RemoveEntitys)
{
if (!m_PhysicsEngine->IsStatic(entityid))
GetSceneManager()->DestroyEntity(entityid);
}
}
void EntityRemoverSystem::Finalize()
{
}