Core/ApplicationBase: Add support for updaters with intervals

This commit is contained in:
SirLynix
2023-04-23 19:45:33 +02:00
parent a55560d1ca
commit de5e7bd8a8
17 changed files with 253 additions and 39 deletions

View File

@@ -1140,7 +1140,7 @@ int main()
}
});
app.AddUpdater([&](Nz::Time deltaTime)
app.AddUpdaterFunc([&](Nz::Time deltaTime)
{
if (lightAnimation)
elapsedTime += deltaTime;

View File

@@ -55,7 +55,7 @@ int main()
sound.Play();
Nz::MillisecondClock clock;
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 30));

View File

@@ -141,7 +141,7 @@ int main()
}
});
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
if (std::optional<Nz::Time> deltaTime = updateClock.RestartIfOver(Nz::Time::TickDuration(60)))
{

View File

@@ -118,7 +118,7 @@ int main()
Nz::PidController<Nz::Vector3f> headingController(0.5f, 0.f, 0.05f);
Nz::PidController<Nz::Vector3f> upController(1.f, 0.f, 0.1f);
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
fps++;

View File

@@ -256,7 +256,7 @@ int main()
headingEntity.get<Nz::NodeComponent>().SetRotation(camQuat);
});
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
if (std::optional<Nz::Time> deltaTime = updateClock.RestartIfOver(Nz::Time::TickDuration(60)))
{

View File

@@ -509,7 +509,7 @@ int main()
});
Nz::DegreeAnglef rotation = 0.f;
app.AddUpdater([&](Nz::Time elapsedTime)
app.AddUpdaterFunc([&](Nz::Time elapsedTime)
{
rotation += elapsedTime.AsSeconds() * 45.f;
//physSystem.GetPhysWorld().SetGravity(Nz::Quaternionf(Nz::EulerAnglesf(0.f, rotation, 0.f)) * Nz::Vector3f::Forward() * 10.f);
@@ -517,7 +517,7 @@ int main()
Nz::MillisecondClock fpsClock;
unsigned int fps = 0;
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
fps++;
if (fpsClock.RestartIfOver(Nz::Time::Second()))

View File

@@ -35,7 +35,7 @@ int main()
std::cout << "Playing sound..." << std::endl;
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
if (!music.IsPlaying())
app.Quit();

View File

@@ -68,7 +68,7 @@ int main()
character.emplace(physSytem.GetPhysWorld(), playerCollider, Nz::Vector3f::Up() * 5.f);
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
auto [position, rotation] = character->GetPositionAndRotation();
@@ -417,7 +417,7 @@ int main()
playerRotNode.SetRotation(camAngles);
});
app.AddUpdater([&](Nz::Time /*elapsedTime*/)
app.AddUpdaterFunc([&]
{
if (std::optional<Nz::Time> deltaTime = updateClock.RestartIfOver(Nz::Time::TickDuration(60)))
{