mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
Add WorldLinePreActivated to override line activation, as a counterpart to WorldLineActivated.
This commit is contained in:
parent
a4bee610b4
commit
0656916bf2
4 changed files with 38 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -40,6 +40,8 @@ void E_WorldThingRevived(AActor* actor);
|
|||
void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
|
||||
// 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);
|
||||
// called in P_ActivateLine after successful special execution.
|
||||
void E_WorldLineActivated(line_t* line, AActor* actor);
|
||||
// same as ACS SCRIPT_Lightning
|
||||
|
@ -141,6 +143,7 @@ public:
|
|||
void WorldThingRevived(AActor*);
|
||||
void WorldThingDamaged(AActor*, AActor*, AActor*, int, FName, int, DAngle);
|
||||
void WorldThingDestroyed(AActor*);
|
||||
void WorldLinePreActivated(line_t*, AActor*, bool*);
|
||||
void WorldLineActivated(line_t*, AActor*);
|
||||
void WorldLightning();
|
||||
void WorldTick();
|
||||
|
@ -198,8 +201,9 @@ struct FWorldEvent
|
|||
FName DamageType;
|
||||
int DamageFlags = 0;
|
||||
DAngle DamageAngle;
|
||||
// for lineactivated
|
||||
// for line(pre)activated
|
||||
line_t* ActivatedLine = nullptr;
|
||||
bool ShouldActivate = true;
|
||||
};
|
||||
|
||||
struct FPlayerEvent
|
||||
|
|
|
@ -189,6 +189,11 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
|
|||
return false;
|
||||
}
|
||||
|
||||
// [MK] Use WorldLinePreActivated to decide if activation should continue
|
||||
bool shouldactivate = true;
|
||||
E_WorldLinePreActivated(line, mo, &shouldactivate);
|
||||
if ( !shouldactivate ) return false;
|
||||
|
||||
bool remote = (line->special != 7 && line->special != 8 && (line->special < 11 || line->special > 14));
|
||||
if (line->locknumber > 0 && !P_CheckKeys (mo, line->locknumber, remote)) return false;
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ struct WorldEvent native play version("2.4")
|
|||
native readonly Name DamageType;
|
||||
native readonly EDmgFlags DamageFlags;
|
||||
native readonly double DamageAngle;
|
||||
// for lineactivated
|
||||
// for line(pre)activated
|
||||
native readonly Line ActivatedLine;
|
||||
native bool ShouldActivate;
|
||||
}
|
||||
|
||||
struct PlayerEvent native play version("2.4")
|
||||
|
@ -302,6 +303,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
virtual native void WorldThingRevived(WorldEvent e);
|
||||
virtual native void WorldThingDamaged(WorldEvent e);
|
||||
virtual native void WorldThingDestroyed(WorldEvent e);
|
||||
virtual native void WorldLinePreActivated(WorldEvent e);
|
||||
virtual native void WorldLineActivated(WorldEvent e);
|
||||
virtual native void WorldLightning(WorldEvent e); // for the sake of completeness.
|
||||
virtual native void WorldTick();
|
||||
|
|
Loading…
Reference in a new issue