// Copyright (C) 2024 Jérôme "SirLynix" 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 namespace Nz { template ApplicationUpdaterFunctor::ApplicationUpdaterFunctor(F functor) : m_functor(std::move(functor)) { } template Time ApplicationUpdaterFunctor::Update(Time elapsedTime) { if constexpr (std::is_invocable_v) return TriggerFunctor(elapsedTime); else if constexpr (std::is_invocable_v) return TriggerFunctor(); else static_assert(AlwaysFalse(), "updater functor must be callable with a Time or nothing"); } template template Time ApplicationUpdaterFunctor::TriggerFunctor(Args&&... args) { if constexpr (std::is_same_v, Time>) return m_functor(std::forward(args)...); else if constexpr (std::is_same_v, void>) { m_functor(std::forward(args)...); return Time::Zero(); } else static_assert(AlwaysFalse(), "updater functor must either return Time or void"); } template ApplicationUpdaterFunctorWithInterval::ApplicationUpdaterFunctorWithInterval(F functor, Time interval) : m_interval(interval), m_functor(std::move(functor)) { } template Time ApplicationUpdaterFunctorWithInterval::Update(Time elapsedTime) { if constexpr (std::is_invocable_v) { if constexpr (FixedInterval) m_functor(m_interval); else m_functor(elapsedTime); } else { static_assert(std::is_invocable_v, "updater functor must be callable with a Time or nothing"); m_functor(); } if constexpr (FixedInterval) return -m_interval; else return m_interval; } } #include