Allow retrieval of the custom Crush state in WorldThingGround

This commit is contained in:
nashmuhandes 2020-09-30 09:56:36 +08:00 committed by Christoph Oelckers
parent 7285c5aca8
commit 6e692e5571
4 changed files with 13 additions and 8 deletions

View file

@ -331,16 +331,16 @@ void EventManager::WorldThingDied(AActor* actor, AActor* inflictor)
handler->WorldThingDied(actor, inflictor); handler->WorldThingDied(actor, inflictor);
} }
void EventManager::WorldThingGround(AActor* actor) void EventManager::WorldThingGround(AActor* actor, FState* st)
{ {
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever. // don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe) if (actor->ObjectFlags & OF_EuthanizeMe)
return; return;
if (ShouldCallStatic(true)) staticEventManager.WorldThingGround(actor); if (ShouldCallStatic(true)) staticEventManager.WorldThingGround(actor, st);
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next) for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
handler->WorldThingGround(actor); handler->WorldThingGround(actor, st);
} }
void EventManager::WorldThingRevived(AActor* actor) void EventManager::WorldThingRevived(AActor* actor)
@ -646,6 +646,7 @@ DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageLineSide);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamagePosition); DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamagePosition);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageIsRadius); DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageIsRadius);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, NewDamage); DEFINE_FIELD_X(WorldEvent, FWorldEvent, NewDamage);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, CrushedState);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber); DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, IsReturn); DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, IsReturn);
@ -807,7 +808,7 @@ void DStaticEventHandler::WorldThingDied(AActor* actor, AActor* inflictor)
} }
} }
void DStaticEventHandler::WorldThingGround(AActor* actor) void DStaticEventHandler::WorldThingGround(AActor* actor, FState* st)
{ {
IFVIRTUAL(DStaticEventHandler, WorldThingGround) IFVIRTUAL(DStaticEventHandler, WorldThingGround)
{ {
@ -815,6 +816,7 @@ void DStaticEventHandler::WorldThingGround(AActor* actor)
if (isEmpty(func)) return; if (isEmpty(func)) return;
FWorldEvent e = owner->SetupWorldEvent(); FWorldEvent e = owner->SetupWorldEvent();
e.Thing = actor; e.Thing = actor;
e.CrushedState = st;
VMValue params[2] = { (DStaticEventHandler*)this, &e }; VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0); VMCall(func, params, 2, nullptr, 0);
} }

View file

@ -4,6 +4,7 @@
#include "serializer.h" #include "serializer.h"
#include "d_event.h" #include "d_event.h"
#include "sbar.h" #include "sbar.h"
#include "info.h"
class DStaticEventHandler; class DStaticEventHandler;
struct EventManager; struct EventManager;
@ -80,7 +81,7 @@ public:
void WorldUnloaded(); void WorldUnloaded();
void WorldThingSpawned(AActor* actor); void WorldThingSpawned(AActor* actor);
void WorldThingDied(AActor* actor, AActor* inflictor); void WorldThingDied(AActor* actor, AActor* inflictor);
void WorldThingGround(AActor* actor); void WorldThingGround(AActor* actor, FState* st);
void WorldThingRevived(AActor* actor); void WorldThingRevived(AActor* actor);
void WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle); void WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
void WorldThingDestroyed(AActor* actor); void WorldThingDestroyed(AActor* actor);
@ -163,6 +164,7 @@ struct FWorldEvent
DVector3 DamagePosition; DVector3 DamagePosition;
bool DamageIsRadius; // radius damage yes/no bool DamageIsRadius; // radius damage yes/no
int NewDamage = 0; // sector/line damaged. allows modifying damage int NewDamage = 0; // sector/line damaged. allows modifying damage
FState* CrushedState = nullptr; // custom crush state set in thingground
}; };
struct FPlayerEvent struct FPlayerEvent
@ -236,7 +238,7 @@ struct EventManager
// called after AActor::Die of each actor. // called after AActor::Die of each actor.
void WorldThingDied(AActor* actor, AActor* inflictor); void WorldThingDied(AActor* actor, AActor* inflictor);
// called inside AActor::Grind just before the corpse is destroyed // called inside AActor::Grind just before the corpse is destroyed
void WorldThingGround(AActor* actor); void WorldThingGround(AActor* actor, FState* st);
// called after AActor::Revive. // called after AActor::Revive.
void WorldThingRevived(AActor* actor); void WorldThingRevived(AActor* actor);
// called before P_DamageMobj and before AActor::DamageMobj virtuals. // called before P_DamageMobj and before AActor::DamageMobj virtuals.

View file

@ -1204,7 +1204,7 @@ bool AActor::Grind(bool items)
S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE); S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE);
Translation = BloodTranslation; Translation = BloodTranslation;
} }
Level->localEventManager->WorldThingGround(this); Level->localEventManager->WorldThingGround(this, state);
return false; return false;
} }
if (!(flags & MF_NOBLOOD)) if (!(flags & MF_NOBLOOD))
@ -1247,7 +1247,7 @@ bool AActor::Grind(bool items)
gib->Translation = BloodTranslation; gib->Translation = BloodTranslation;
} }
S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE); S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE);
Level->localEventManager->WorldThingGround(this); Level->localEventManager->WorldThingGround(this, nullptr);
} }
if (flags & MF_ICECORPSE) if (flags & MF_ICECORPSE)
{ {

View file

@ -37,6 +37,7 @@ struct WorldEvent native play version("2.4")
native readonly vector3 DamagePosition; native readonly vector3 DamagePosition;
native readonly bool DamageIsRadius; native readonly bool DamageIsRadius;
native int NewDamage; native int NewDamage;
native readonly State CrushedState;
} }
struct PlayerEvent native play version("2.4") struct PlayerEvent native play version("2.4")