mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
Almost forgot: WorldTick hook, since ZScript doesn't have delays
This commit is contained in:
parent
9a8a93fe51
commit
066b22af0a
4 changed files with 22 additions and 41 deletions
|
@ -262,6 +262,7 @@ void E_WorldThingDestroyed(AActor* actor)
|
|||
// normal event loopers (non-special, argument-less)
|
||||
DEFINE_EVENT_LOOPER(RenderFrame)
|
||||
DEFINE_EVENT_LOOPER(WorldLightning)
|
||||
DEFINE_EVENT_LOOPER(WorldTick)
|
||||
|
||||
// declarations
|
||||
IMPLEMENT_CLASS(DStaticEventHandler, false, false);
|
||||
|
@ -400,6 +401,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingSpawned)
|
|||
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDied)
|
||||
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDestroyed)
|
||||
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLightning)
|
||||
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldTick)
|
||||
DEFINE_EMPTY_HANDLER(DStaticEventHandler, RenderFrame)
|
||||
|
||||
// ===========================================
|
||||
|
@ -500,6 +502,19 @@ void DStaticEventHandler::WorldLightning()
|
|||
}
|
||||
}
|
||||
|
||||
void DStaticEventHandler::WorldTick()
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, WorldTick)
|
||||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldTick_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static DRenderEvent* E_SetupRenderEvent()
|
||||
{
|
||||
static DRenderEvent* e = nullptr;
|
||||
|
@ -532,44 +547,3 @@ void DStaticEventHandler::OnDestroy()
|
|||
E_UnregisterHandler(this);
|
||||
Super::OnDestroy();
|
||||
}
|
||||
/*
|
||||
void DStaticRenderEventHandler::Setup()
|
||||
{
|
||||
ViewPos = ::ViewPos;
|
||||
ViewAngle = ::ViewAngle;
|
||||
ViewPitch = ::ViewPitch;
|
||||
ViewRoll = ::ViewRoll;
|
||||
FracTic = ::r_TicFracF;
|
||||
Camera = ::camera;
|
||||
}
|
||||
|
||||
void DStaticRenderEventHandler::RenderFrame()
|
||||
{
|
||||
Setup();
|
||||
Super::RenderFrame();
|
||||
}
|
||||
|
||||
void DStaticWorldEventHandler::Setup()
|
||||
{
|
||||
IsSaveGame = savegamerestore;
|
||||
Thing = nullptr;
|
||||
}
|
||||
|
||||
void DStaticWorldEventHandler::WorldLoaded()
|
||||
{
|
||||
Setup();
|
||||
Super::WorldLoaded();
|
||||
}
|
||||
|
||||
void DStaticWorldEventHandler::WorldUnloaded()
|
||||
{
|
||||
Setup();
|
||||
Super::WorldUnloaded();
|
||||
}
|
||||
|
||||
void DStaticWorldEventHandler::WorldThingSpawned(AActor* actor)
|
||||
{
|
||||
Setup();
|
||||
Thing = actor;
|
||||
Super::WorldThingSpawned(actor);
|
||||
}*/
|
|
@ -33,6 +33,8 @@ void E_WorldThingDied(AActor* actor, AActor* inflictor);
|
|||
void E_WorldThingDestroyed(AActor* actor);
|
||||
// same as ACS SCRIPT_Lightning
|
||||
void E_WorldLightning();
|
||||
// this executes on every tick, before everything
|
||||
void E_WorldTick();
|
||||
// called on each render frame once.
|
||||
void E_RenderFrame();
|
||||
|
||||
|
@ -86,6 +88,7 @@ public:
|
|||
virtual void WorldThingDied(AActor*, AActor*);
|
||||
virtual void WorldThingDestroyed(AActor*);
|
||||
virtual void WorldLightning();
|
||||
virtual void WorldTick();
|
||||
virtual void RenderFrame();
|
||||
};
|
||||
class DEventHandler : public DStaticEventHandler
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "r_utility.h"
|
||||
#include "p_spec.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
|
||||
extern gamestate_t wipegamestate;
|
||||
|
||||
|
@ -125,6 +126,8 @@ void P_Ticker (void)
|
|||
/*Added by MC: Freeze mode.*/!(bglobal.freeze && players[i].Bot != NULL))
|
||||
P_PlayerThink (&players[i]);
|
||||
|
||||
// [ZZ] call the WorldTick hook
|
||||
E_WorldTick();
|
||||
StatusBar->Tick (); // [RH] moved this here
|
||||
level.Tick (); // [RH] let the level tick
|
||||
DThinker::RunThinkers ();
|
||||
|
|
|
@ -38,6 +38,7 @@ class StaticEventHandler : Object native
|
|||
virtual native void WorldThingDied(WorldEvent e);
|
||||
virtual native void WorldThingDestroyed(WorldEvent e);
|
||||
virtual native void WorldLightning(WorldEvent e); // for the sake of completeness.
|
||||
virtual native void WorldTick(WorldEvent e);
|
||||
|
||||
virtual native void RenderFrame(RenderEvent e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue