Nowcalling module events

This commit is contained in:
Antoine Pilote
2025-04-02 16:49:28 -04:00
parent ef70a04da9
commit fff6997dd4
3 changed files with 25 additions and 4 deletions

View File

@@ -5,7 +5,6 @@
#include "Nuake/Physics/PhysicsManager.h"
#include "Nuake/AI/NavManager.h"
#include "Nuake/Audio/AudioManager.h"
#include "Nuake/FileSystem/FileSystem.h"
#include "Nuake/Core/Input.h"
#include "Nuake/Rendering/Renderer.h"
@@ -54,7 +53,6 @@ namespace Nuake
ScriptingEngineNet::Get().OnGameAssemblyLoaded().AddStatic(&Engine::OnScriptingEngineGameAssemblyLoaded);
AudioManager::Get().Initialize();
PhysicsManager::Get().Init();
NavManager::Get().Initialize();
@@ -151,13 +149,17 @@ namespace Nuake
// Fixed update
while (fixedUpdateDifference >= fixedUpdateRate)
{
currentWindow->FixedUpdate(fixedUpdateRate * timeScale);
const float scaledFixedTimestep = fixedUpdateRate * timeScale;
currentWindow->FixedUpdate(scaledFixedTimestep);
Modules::FixedUpdate(scaledFixedTimestep);
fixedUpdateDifference -= fixedUpdateRate;
}
Modules::Update(scaledTimeStep);
Input::Update();
AudioManager::Get().AudioUpdate();
}
}

View File

@@ -4,6 +4,7 @@
#include "AssimpModule/AssimpModule.h"
#include "AudioModule/AudioModule.h"
#include "ExampleModule/ExampleModule.h"
#include "ModuleDB.h"
#include "Nuake/UI/WidgetDrawer.h"
@@ -56,6 +57,22 @@ void DrawBoolWidget(entt::meta_type& type, entt::meta_any& instance)
}
void Nuake::Modules::FixedUpdate(float ts)
{
for (auto& moduleName : ModuleDB::Get().GetModules())
{
ModuleDB::Get().GetBaseImpl(moduleName).OnFixedUpdate.Broadcast(ts);
}
}
void Nuake::Modules::Update(float ts)
{
for (auto& moduleName : ModuleDB::Get().GetModules())
{
ModuleDB::Get().GetBaseImpl(moduleName).OnUpdate.Broadcast(ts);
}
}
void Nuake::Modules::StartupModules()
{
auto& drawer = WidgetDrawer::Get();

View File

@@ -12,6 +12,8 @@ namespace Nuake
public:
static void StartupModules();
static void FixedUpdate(float ts);
static void Update(float ts);
static void ShutdownModules();
};
}