mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
ECS System WIP
This commit is contained in:
54
entitysystem/ECWorld.cpp
Normal file
54
entitysystem/ECWorld.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Created by Daniu
|
||||
//
|
||||
|
||||
#include "ECWorld.h"
|
||||
#include "entitysystem/components/BasicComponents.h"
|
||||
|
||||
entt::entity ECWorld::CreateEntity()
|
||||
{
|
||||
return m_registry.create();
|
||||
}
|
||||
|
||||
void ECWorld::DestroyEntity(entt::entity entity)
|
||||
{
|
||||
if (m_registry.valid(entity))
|
||||
m_registry.destroy(entity);
|
||||
}
|
||||
|
||||
void ECWorld::Clear()
|
||||
{
|
||||
m_registry.clear();
|
||||
}
|
||||
|
||||
bool ECWorld::IsAlive(entt::entity entity) const
|
||||
{
|
||||
return m_registry.valid(entity);
|
||||
}
|
||||
|
||||
|
||||
entt::entity ECWorld::FindEntityByName(const std::string& name) const
|
||||
{
|
||||
auto view = m_registry.view<ECSComponent::Identification>();
|
||||
|
||||
for (auto entity : view)
|
||||
{
|
||||
const auto& id = view.get<ECSComponent::Identification>(entity);
|
||||
if (id.Name.ToString() == name)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
return entt::null;
|
||||
}
|
||||
|
||||
entt::registry& ECWorld::Registry()
|
||||
{
|
||||
return m_registry;
|
||||
}
|
||||
|
||||
const entt::registry& ECWorld::Registry() const
|
||||
{
|
||||
return m_registry;
|
||||
}
|
||||
Reference in New Issue
Block a user