Core: Add Lifetime component and system

This commit is contained in:
SirLynix
2022-07-02 19:43:02 +02:00
parent a61ebb7806
commit 99b4397d78
8 changed files with 217 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// 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_SYSTEMS_LIFETIMESYSTEM_HPP
#define NAZARA_CORE_SYSTEMS_LIFETIMESYSTEM_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Config.hpp>
#include <Nazara/Utils/TypeList.hpp>
#include <entt/entt.hpp>
namespace Nz
{
class NAZARA_CORE_API LifetimeSystem
{
public:
static constexpr bool AllowConcurrent = false;
static constexpr Int64 ExecutionOrder = 1'000'000;
using Components = TypeList<class LifetimeComponent>;
inline LifetimeSystem(entt::registry& registry);
LifetimeSystem(const LifetimeSystem&) = delete;
LifetimeSystem(LifetimeSystem&&) = delete;
~LifetimeSystem() = default;
void Update(float elapsedTime);
LifetimeSystem& operator=(const LifetimeSystem&) = delete;
LifetimeSystem& operator=(LifetimeSystem&&) = delete;
private:
entt::registry& m_registry;
};
}
#include <Nazara/Core/Systems/LifetimeSystem.inl>
#endif // NAZARA_CORE_SYSTEMS_LIFETIMESYSTEM_HPP

View File

@@ -0,0 +1,16 @@
// 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/Systems/LifetimeSystem.hpp>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
inline LifetimeSystem::LifetimeSystem(entt::registry& registry) :
m_registry(registry)
{
}
}
#include <Nazara/Core/DebugOff.hpp>