Added activation type to WorldLine(Pre)Activated events

https://forum.zdoom.org/viewtopic.php?t=60232
This commit is contained in:
alexey.lysiuk 2018-04-14 11:33:17 +03:00
parent 83c513b6c9
commit ba4cc1a6ca
4 changed files with 17 additions and 12 deletions

View File

@ -404,16 +404,16 @@ void E_WorldThingDestroyed(AActor* actor)
handler->WorldThingDestroyed(actor);
}
void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
handler->WorldLinePreActivated(line, actor, shouldactivate);
handler->WorldLinePreActivated(line, actor, activationType, shouldactivate);
}
void E_WorldLineActivated(line_t* line, AActor* actor)
void E_WorldLineActivated(line_t* line, AActor* actor, int activationType)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
handler->WorldLineActivated(line, actor);
handler->WorldLineActivated(line, actor, activationType);
}
void E_PlayerEntered(int num, bool fromhub)
@ -545,6 +545,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, ActivationType);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, ShouldActivate);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber);
@ -795,7 +796,7 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
}
}
void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate)
{
IFVIRTUAL(DStaticEventHandler, WorldLinePreActivated)
{
@ -805,6 +806,7 @@ void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, boo
FWorldEvent e = E_SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ActivationType = activationType;
e.ShouldActivate = *shouldactivate;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
@ -812,7 +814,7 @@ void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, boo
}
}
void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor)
void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor, int activationType)
{
IFVIRTUAL(DStaticEventHandler, WorldLineActivated)
{
@ -822,6 +824,7 @@ void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor)
FWorldEvent e = E_SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ActivationType = activationType;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
}

View File

@ -41,9 +41,9 @@ void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int d
// called before AActor::Destroy of each actor.
void E_WorldThingDestroyed(AActor* actor);
// called in P_ActivateLine before executing special, set shouldactivate to false to prevent activation.
void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate);
void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate);
// called in P_ActivateLine after successful special execution.
void E_WorldLineActivated(line_t* line, AActor* actor);
void E_WorldLineActivated(line_t* line, AActor* actor, int activationType);
// same as ACS SCRIPT_Lightning
void E_WorldLightning();
// this executes on every tick, before everything, only when in valid level and not paused
@ -143,8 +143,8 @@ public:
void WorldThingRevived(AActor* actor);
void WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
void WorldThingDestroyed(AActor* actor);
void WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate);
void WorldLineActivated(line_t* line, AActor* actor);
void WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate);
void WorldLineActivated(line_t* line, AActor* actor, int activationType);
void WorldLightning();
void WorldTick();
@ -203,6 +203,7 @@ struct FWorldEvent
DAngle DamageAngle;
// for line(pre)activated
line_t* ActivatedLine = nullptr;
int ActivationType = 0;
bool ShouldActivate = true;
};

View File

@ -191,7 +191,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
// [MK] Use WorldLinePreActivated to decide if activation should continue
bool shouldactivate = true;
E_WorldLinePreActivated(line, mo, &shouldactivate);
E_WorldLinePreActivated(line, mo, activationType, &shouldactivate);
if ( !shouldactivate ) return false;
bool remote = (line->special != 7 && line->special != 8 && (line->special < 11 || line->special > 14));
@ -206,7 +206,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
line->args[3], line->args[4]);
// [MK] Fire up WorldLineActivated
if ( buttonSuccess ) E_WorldLineActivated(line, mo);
if ( buttonSuccess ) E_WorldLineActivated(line, mo, activationType);
special = line->special;
if (!repeat && buttonSuccess)

View File

@ -27,6 +27,7 @@ struct WorldEvent native play version("2.4")
native readonly double DamageAngle;
// for line(pre)activated
native readonly Line ActivatedLine;
native readonly int ActivationType;
native bool ShouldActivate;
}