// Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//

#include <OgnOnPlaybackTickDatabase.h>
#include <omni/graph/action/IActionGraph.h>

namespace omni
{
namespace graph
{
namespace action
{

class OgnOnPlaybackTick
{
public:
    static bool compute(OgnOnPlaybackTickDatabase& db)
    {
        const auto& contextObj = db.abi_context();
        auto iContext = contextObj.iContext;

        if (!iContext->getIsPlaying(contextObj))
        {
            return true;
        }

        db.outputs.time() = iContext->getTime(contextObj);
        db.outputs.deltaSeconds() = iContext->getElapsedTime(contextObj);
        db.outputs.frame() = iContext->getFrame(contextObj);
        auto iActionGraph = getInterface();
        iActionGraph->setExecutionEnabled(outputs::tick.token(), db.getInstanceIndex());

        return true;
    }
};

REGISTER_OGN_NODE()
} // action
} // graph
} // omni
