This commit is contained in:
Major Cooke 2023-01-21 11:37:49 -06:00
parent 93bc2a3caf
commit 050f982fe2
4 changed files with 26 additions and 0 deletions

View file

@ -3524,6 +3524,8 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray<FString>& allwads, TArr
D_StartTitle (); // start up intro loop
setmodeneeded = false; // This may be set to true here, but isn't needed for a restart
}
staticEventManager.OnEngineInitialize();
return 0;
}
//==========================================================================

View file

@ -280,6 +280,14 @@ void EventManager::Shutdown()
handler->name(); \
}
void EventManager::OnEngineInitialize()
{
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
{
if (handler->IsStatic())
handler->OnEngineInitialize();
}
}
// note for the functions below.
// *Unsafe is executed on EVERY map load/close, including savegame loading, etc.
@ -773,6 +781,18 @@ FWorldEvent EventManager::SetupWorldEvent()
return e;
}
void DStaticEventHandler::OnEngineInitialize()
{
IFVIRTUAL(DStaticEventHandler, OnEngineInitialize)
{
// don't create excessive DObjects if not going to be processed anyway
if (isEmpty(func)) return;
VMValue params[1] = { (DStaticEventHandler*)this };
VMCall(func, params, 1, nullptr, 0);
}
}
void DStaticEventHandler::WorldLoaded()
{
IFVIRTUAL(DStaticEventHandler, WorldLoaded)

View file

@ -77,6 +77,7 @@ public:
void OnUnregister();
//
void OnEngineInitialize();
void WorldLoaded();
void WorldUnloaded(const FString& nextmap);
void WorldThingSpawned(AActor* actor);
@ -230,6 +231,8 @@ struct EventManager
// shutdown handlers
void Shutdown();
// after the engine is done creating data
void OnEngineInitialize();
// called right after the map has loaded (approximately same time as OPEN ACS scripts)
void WorldLoaded();
// called when the map is about to unload (approximately same time as UNLOADING ACS scripts)

View file

@ -89,6 +89,7 @@ class StaticEventHandler : Object native play version("2.4")
virtual void OnUnregister() {}
// actual handlers are here
virtual void OnEngineInitialize() {}
virtual void WorldLoaded(WorldEvent e) {}
virtual void WorldUnloaded(WorldEvent e) {}
virtual void WorldThingSpawned(WorldEvent e) {}