I had to change the way hooks are inserted into the object info.
In the next build, this example will work:
#include "UltraEngine.h"
using namespace UltraEngine;
struct MyObject : public Object
{
int count{ 0 };
static void Hook(shared_ptr<Object> source, shared_ptr<Object> extra)
{
auto world = source->As<World>();
auto o = extra->As<MyObject>();
o->count++;
Print(o->count);
}
};
int main(int argc, const char* argv[])
{
//Get the display list
auto displays = GetDisplays();
//Create a window
auto window = CreateWindow("Ultra Engine", 0, 0, 1920, 1080, displays[0], WINDOW_CLIENTCOORDS | WINDOW_CENTER | WINDOW_TITLEBAR);
//Create a world
auto world = CreateWorld();
auto o = std::make_shared<MyObject>();
world->AddHook(HOOKID_UPDATE, MyObject::Hook, o);
//Main loop
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
{
world->Update();
Sleep(1000);
}
return 0;
}