Update for EnTT 3.9

This commit is contained in:
Jérôme Leclercq
2022-02-08 20:05:14 +01:00
parent 6c35b0be57
commit f466a7494b
16 changed files with 11 additions and 124 deletions

View File

@@ -1,48 +0,0 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CORE_ECS_HPP
#define NAZARA_CORE_ECS_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Core.hpp>
#include <entt/entt.hpp>
namespace Nz
{
class CameraComponent;
class GraphicsComponent;
class NodeComponent;
class RigidBody3DComponent;
class ECS : public ModuleBase<ECS>
{
friend ModuleBase;
friend class Audio;
friend class Graphics;
friend class Physics2D;
friend class Physics3D;
friend class Utility;
friend class Widgets;
public:
using Dependencies = TypeList<Core>;
struct Config {};
inline ECS(Config /*config*/);
~ECS() = default;
private:
static inline void RegisterComponents();
NAZARA_CORE_API static ECS* s_instance;
};
}
#include <Nazara/Core/ECS.inl>
#endif // NAZARA_CORE_ECS_HPP

View File

@@ -1,42 +0,0 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/ECS.hpp>
#include <stdexcept>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
namespace Detail
{
template<typename T>
struct RegisterComponent
{
void operator()(entt::id_type& expectedId)
{
if (entt::type_seq<T>() != expectedId++)
throw std::runtime_error(std::string(entt::type_name<T>::value()) + " has wrong index, please initialize Nazara ECS before instancing your own components");
}
};
}
/*!
* \ingroup core
* \class Nz::ECS
* \brief Core class that represents the ECS module
*/
inline ECS::ECS(Config /*config*/) :
ModuleBase("ECS", this)
{
RegisterComponents();
}
inline void ECS::RegisterComponents()
{
entt::id_type expectedId = 0;
TypeListApply<TypeList<NodeComponent, CameraComponent, GraphicsComponent, RigidBody3DComponent>, Detail::RegisterComponent>(expectedId);
}
}
#include <Nazara/Core/DebugOff.hpp>