mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- preparations for cleaning up Exhumed's event dispatcher.
This commit is contained in:
parent
b725adc426
commit
d130a43aa0
2 changed files with 98 additions and 0 deletions
|
@ -389,6 +389,49 @@ struct RunChannel
|
|||
short d;
|
||||
};
|
||||
|
||||
enum class EMessageType
|
||||
{
|
||||
ProcessChannel = 1,
|
||||
Tick,
|
||||
Process,
|
||||
Use,
|
||||
TouchFloor,
|
||||
LeaveSector,
|
||||
EnterSector,
|
||||
Damage,
|
||||
Draw,
|
||||
RadialDamage
|
||||
};
|
||||
|
||||
struct RunListEvent
|
||||
{
|
||||
EMessageType nMessage;
|
||||
int nIndex; // mostly the player, sometimes the channel list
|
||||
tspritetype* pTSprite; // for the draw event
|
||||
DExhumedActor* pActor; // for the damage event, radialSpr for radial damage - owner will not be passed as it can be retrieved from this.
|
||||
int nDamage, nRun;
|
||||
|
||||
int nRadialDamage; // Radial damage needs a bit more info.
|
||||
int nDamageRadius;
|
||||
};
|
||||
|
||||
struct ExhumedAI
|
||||
{
|
||||
virtual ~ExhumedAI() = default;
|
||||
virtual void ProcessChannel(RunListEvent* ev) {}
|
||||
virtual void Tick(RunListEvent* ev) {}
|
||||
virtual void Process(RunListEvent* ev) {}
|
||||
virtual void Use(RunListEvent* ev) {}
|
||||
virtual void TouchFloor(RunListEvent* ev) {}
|
||||
virtual void LeaveSector(RunListEvent* ev) {}
|
||||
virtual void EnterSector(RunListEvent* ev) {}
|
||||
virtual void Damage(RunListEvent* ev) {}
|
||||
virtual void Draw(RunListEvent* ev) {}
|
||||
virtual void RadialDamage(RunListEvent* ev) {}
|
||||
};
|
||||
|
||||
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);
|
||||
|
||||
typedef void(*AiFunc)(int, int, int, int nRun);
|
||||
|
||||
extern FreeListArray<RunStruct, kMaxRuns> RunData;
|
||||
|
|
|
@ -1699,5 +1699,60 @@ void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage)
|
|||
}
|
||||
}
|
||||
|
||||
// This is only temporary so that the event system can be refactored in smaller steps.
|
||||
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun)
|
||||
{
|
||||
RunListEvent ev;
|
||||
ev.nMessage = (EMessageType)(nMessage >> 16);
|
||||
ev.nIndex = nObject;
|
||||
switch (ev.nMessage)
|
||||
{
|
||||
case EMessageType::ProcessChannel:
|
||||
ai->ProcessChannel(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::Tick:
|
||||
ai->Tick(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::Process:
|
||||
ai->Process(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::Use:
|
||||
ai->Use(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::TouchFloor:
|
||||
ai->TouchFloor(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::LeaveSector:
|
||||
ai->LeaveSector(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::EnterSector:
|
||||
ai->EnterSector(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::Damage:
|
||||
ev.pActor = &exhumedActors[nObject];
|
||||
ai->Damage(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::Draw:
|
||||
ev.pTSprite = &mytsprite[nObject];
|
||||
ai->Draw(&ev);
|
||||
break;
|
||||
|
||||
case EMessageType::RadialDamage:
|
||||
ev.nRadialDamage = nRadialDamage;
|
||||
ev.nDamageRadius = nDamageRadius;
|
||||
ev.pActor = &exhumedActors[nRadialSpr];
|
||||
ai->RadialDamage(&ev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue