File Name.hpp¶
File List > Components > Name.hpp
Go to the documentation of this file
#ifndef ENGINE_COMPONENTS_NAME_HPP_
#define ENGINE_COMPONENTS_NAME_HPP_
#include "ECS/Registry.hpp"
#include <string>
#include <utility>
namespace Engine {
struct Name {
std::string value;
static Name Create(std::string value = "") {
Name name;
name.value = std::move(value);
return name;
}
};
inline std::string GetEntityName(Registry& registry, Entity entity) {
if (registry.HasComponent<Name>(entity)) {
return registry.RequireComponent<Name>(entity).value;
}
return "Entity " + std::to_string(entity);
}
} // namespace Engine
#endif // ENGINE_COMPONENTS_NAME_HPP_