3#include "ComponentFunctions.hpp"
5namespace Grindstone::ECS {
6 template<
typename ComponentType>
7 void* CreateComponent(entt::registry& registry, entt::entity entity) {
8 return ®istry.emplace<ComponentType>(entity);
11 template<
typename ComponentType>
12 void RemoveComponent(entt::registry& registry, entt::entity entity) {
13 if (registry.any_of<ComponentType>(entity)) {
14 registry.remove<ComponentType>(entity);
18 template<
typename ComponentType>
20 return ComponentType::reflectionInfo;
23 template<
typename ComponentType>
24 bool TryGetComponent(entt::registry& registry, entt::entity entity,
void*& outComponent) {
25 ComponentType* foundComp = registry.try_get<ComponentType>(entity);
26 outComponent = foundComp;
28 return foundComp !=
nullptr;
31 template<
typename ComponentType>
32 bool HasComponent(entt::registry& registry, entt::entity entity) {
33 return registry.all_of<ComponentType>(entity);
36 template<
typename ComponentType>
37 void CopyRegistryComponents(entt::registry& dst, entt::registry& src) {
38 auto& srcEntities = src.view<ComponentType>();
40 for (entt::entity srcEntity : srcEntities) {
41 ComponentType srcComponent = src.get<ComponentType>(srcEntity);
42 dst.emplace_or_replace<ComponentType>(srcEntity, srcComponent);
Definition TypeDescriptorStruct.hpp:9