SDK: Add LifetimeComponent and LifetimeSystem

This commit is contained in:
Lynix
2019-04-07 21:35:10 +02:00
parent 713a70dd10
commit 793c5abfe3
9 changed files with 140 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Systems/LifetimeSystem.hpp>
#include <NDK/Components/LifetimeComponent.hpp>
namespace Ndk
{
LifetimeSystem::LifetimeSystem()
{
Requires<LifetimeComponent>();
}
void LifetimeSystem::OnUpdate(float elapsedTime)
{
for (const Ndk::EntityHandle& entity : GetEntities())
{
auto& lifetime = entity->GetComponent<LifetimeComponent>();
if (lifetime.UpdateLifetime(elapsedTime))
entity->Kill();
}
}
SystemIndex LifetimeSystem::systemIndex;
}