mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-06 06:09:52 +03:00
Added basic events for modules to register to
OnUpdate, OnFixedUpdate, OnSceneLoad, OnGameStateChanged
This commit is contained in:
@@ -71,17 +71,30 @@ void ExampleModule_Startup()
|
||||
|
||||
TestClass::InternalInitializeClass();
|
||||
|
||||
// Register the module & info
|
||||
auto& module = ModuleDB::Get().RegisterModule<ExampleModule>();
|
||||
module.instance = module.Resolve().construct();
|
||||
|
||||
module.Description = "This is an example module";
|
||||
|
||||
// This is to expose parameters in the modules settings
|
||||
module.RegisterSetting<&mySetting>("mySetting");
|
||||
|
||||
// This is to expose functions to the rest of the engine
|
||||
module.BindFunction<ExampleFunction>("ExampleFunction");
|
||||
module.BindFunction<ExampleModuleLog>("ExampleModuleLog", "hi");
|
||||
//module.Invoke("ExampleModuleLog", "Hello World");
|
||||
|
||||
// The module can hook to certain events
|
||||
module.OnUpdate.AddStatic([](float ts)
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
module.OnFixedUpdate.AddStatic([](float ts)
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
entt::id_type typeId = entt::hashed_string(TestClass::ClassName().c_str());
|
||||
entt::meta_type metaType = entt::resolve(typeId);
|
||||
@@ -157,8 +170,6 @@ void ExampleModule_Startup()
|
||||
//Logger::Log("Serialized original component: " + jsonDataOG.dump(4), "ExampleModule", VERBOSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ExampleModule_Shutdown()
|
||||
{
|
||||
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "Nuake/Core/Logger.h"
|
||||
#include "Nuake/Core/GameState.h"
|
||||
#include "Nuake/Core/MulticastDelegate.h"
|
||||
#include "Nuake/Core/Object/Object.h"
|
||||
|
||||
#include "Nuake/Scene/Scene.h"
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
#include "Nuake/Core/Logger.h"
|
||||
class ModuleInstance
|
||||
{
|
||||
public:
|
||||
@@ -21,7 +24,10 @@ public:
|
||||
return entt::resolve(entt::hashed_string(Name.c_str()));
|
||||
}
|
||||
|
||||
|
||||
MulticastDelegate<Ref<Nuake::Scene>> OnSceneLoad;
|
||||
MulticastDelegate<float> OnUpdate;
|
||||
MulticastDelegate<float> OnFixedUpdate;
|
||||
MulticastDelegate<Nuake::GameState> OnGameStateChanged;
|
||||
};
|
||||
|
||||
class Class
|
||||
|
||||
Reference in New Issue
Block a user