Add WorldLinePreActivated to override line activation, as a counterpart to WorldLineActivated.

This commit is contained in:
Mari the Deer 2018-03-24 15:59:20 +01:00 committed by Christoph Oelckers
commit 0656916bf2
4 changed files with 38 additions and 2 deletions

View file

@ -413,6 +413,12 @@ void E_WorldThingDestroyed(AActor* actor)
handler->WorldThingDestroyed(actor);
}
void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
handler->WorldLinePreActivated(line, actor, shouldactivate);
}
void E_WorldLineActivated(line_t* line, AActor* actor)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
@ -548,6 +554,7 @@ DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageType);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageFlags);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageAngle);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, ActivatedLine);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, ShouldActivate);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, IsReturn);
@ -634,6 +641,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDied)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingRevived)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDamaged)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDestroyed)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLinePreActivated)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLineActivated)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLightning)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldTick)
@ -796,6 +804,23 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
}
}
void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
{
IFVIRTUAL(DStaticEventHandler, WorldLinePreActivated)
{
// don't create excessive DObjects if not going to be processed anyway
if (func == DStaticEventHandler_WorldLinePreActivated_VMPtr)
return;
FWorldEvent e = E_SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ShouldActivate = *shouldactivate;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
*shouldactivate = e.ShouldActivate;
}
}
void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor)
{
IFVIRTUAL(DStaticEventHandler, WorldLineActivated)