- Exhumed: Make playFrameSound() a method of SeqFrame.

This commit is contained in:
Mitchell Richters 2023-04-15 21:48:48 +10:00
parent 32cc320195
commit 95e84ba1f8
24 changed files with 40 additions and 49 deletions

View file

@ -139,7 +139,7 @@ void AIAnim::Tick(RunListEvent* ev)
if (!(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
{
playFrameSound(pActor, animSeq.frames[nFrame]);
animSeq.frames[nFrame].playSound(pActor);
}
if (pActor->spr.statnum == kStatIgnited)

View file

@ -130,7 +130,7 @@ void AIAnubis::Tick(RunListEvent* ev)
if (nAction < 11)
Gravity(ap);
playFrameSound(ap, seqFrame);
seqFrame.playSound(ap);
ap->spr.picnum = seqFrame.getFirstPicnum();
ap->nFrame++;

View file

@ -98,7 +98,7 @@ void AIBubble::Tick(RunListEvent* ev)
const auto& bubbSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex);
playFrameSound(pActor, bubbSeq.frames[pActor->nFrame]);
bubbSeq.frames[pActor->nFrame].playSound(pActor);
pActor->nFrame++;

View file

@ -806,7 +806,7 @@ void AIBullet::Tick(RunListEvent* ev)
const auto& seqFrame = bulletSeq.frames[pBullet->nFrame];
DExhumedActor* pActor = BulletList[nBullet].pActor;
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
if (seqFrame.flags & 0x80)
{

View file

@ -363,7 +363,7 @@ void AIFish::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= fishSeq.frames.Size()) {

View file

@ -261,7 +261,7 @@ void AIGrenade::Tick(RunListEvent* ev)
const auto& grenadeSeq = pActor->nFrame ? getSequence("grenboom") : getSequence("grenroll", pActor->nIndex);
const auto& seqFrame = grenadeSeq.frames[pActor->nHealth >> 8];
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->spr.picnum = seqFrame.getFirstPicnum();
pActor->nIndex2--;

View file

@ -381,7 +381,7 @@ void MoveWeapons(int nPlayer)
for (frames = var_1C; frames > 0; frames--)
{
playFrameSound(pPlayerActor, seqFrame.get());
seqFrame.get().playSound(pPlayerActor);
pPlayer->nWeapFrame++;

View file

@ -224,7 +224,7 @@ void AILavaDude::Tick(RunListEvent* ev)
if (nAction)
{
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= lavadudeSeq.frames.Size())

View file

@ -205,7 +205,7 @@ void AILion::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= lionSeq.frames.Size())

View file

@ -146,7 +146,7 @@ void AIMummy::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
bool bVal = false;

View file

@ -2180,7 +2180,7 @@ void DoDrips()
if (!pActor) continue;
const auto& dripSeq = getSequence("drips", !(pActor->sector()->Flag & kSectLava));
playFrameSound(pActor, dripSeq.frames[RandomSize(2) % dripSeq.frames.Size()]);
dripSeq.frames[RandomSize(2) % dripSeq.frames.Size()].playSound(pActor);
sDrip[i].nCount = RandomSize(8) + 90;
}

View file

@ -1918,7 +1918,7 @@ static void doPlayerActionSequence(Player* const pPlayer)
const auto& seqFrame = playerSeq.frames[pPlayerActor->nFrame];
const auto seqSize = playerSeq.frames.Size();
playFrameSound(pPlayerActor, seqFrame);
seqFrame.playSound(pPlayerActor);
pPlayerActor->nFrame++;
if (pPlayerActor->nFrame < seqSize)

View file

@ -550,7 +550,7 @@ void AIQueenEgg::Tick(RunListEvent* ev)
if (nAction != 4)
{
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pEgg->nFrame++;
if (pEgg->nFrame >= eggSeq.frames.Size())
@ -805,7 +805,7 @@ void AIQueenHead::Tick(RunListEvent* ev)
const auto& queenSeq = getSequence(pActor->nSeqFile, HeadSeq[QueenHead.nAction].nSeqId);
const auto& seqFrame = queenSeq.frames[QueenHead.nFrame];
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->spr.picnum = seqFrame.getFirstPicnum();
@ -1240,7 +1240,7 @@ void AIQueen::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
QueenList[nQueen].nFrame++;
if (QueenList[nQueen].nFrame >= queenSeq.frames.Size())

View file

@ -223,7 +223,7 @@ void AIRa::Tick(RunListEvent* ev)
if (Ra[nPlayer].nAction)
{
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
Ra[nPlayer].nFrame++;
if (Ra[nPlayer].nFrame >= raSeq.frames.Size())

View file

@ -251,7 +251,7 @@ void AIRat::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= ratSeq.frames.Size())

View file

@ -206,7 +206,7 @@ void AIRex::Tick(RunListEvent* ev)
// moves the mouth open and closed as it's idle?
while (--ecx != -1)
{
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= rexSeq.frames.Size())

View file

@ -216,7 +216,7 @@ void AIRoach::Tick(RunListEvent* ev)
const auto& seqFrame = roachSeq.frames[pActor->nFrame];
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= roachSeq.frames.Size())

View file

@ -211,7 +211,7 @@ void AIScorp::Tick(RunListEvent* ev)
const auto& seqFrame = scorpSeq.frames[pActor->nFrame];
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;

View file

@ -742,29 +742,6 @@ void seq_MoveSequence(DExhumedActor* actor, int16_t nSeq, int16_t nFrame)
//
//---------------------------------------------------------------------------
void playFrameSound(DExhumedActor* actor, const SeqFrame& seqFrame)
{
const int nSound = seqFrame.sound;
if (nSound == -1)
return;
if (actor)
{
D3PlayFX(nSound, actor);
}
else
{
PlayLocalSound(nSound, 0);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int frameIndex)
{
tspritetype* pTSprite = mytspriteArray->get(nSprite);

View file

@ -126,6 +126,21 @@ struct SeqFrame
{
return chunks[0].picnum;
}
const void playSound(DExhumedActor* const pActor) const
{
if (sound == -1)
return;
if (pActor)
{
D3PlayFX(sound, pActor);
}
else
{
PlayLocalSound(sound, 0);
}
}
};
struct Seq
@ -164,7 +179,6 @@ int getSeqFrameChunkPicnum(const int nChunk);
int getSeqFrameChunkFlags(const int nChunk);
TArray<Seq>* getFileSeqs(const FName nSeqFile);
void playFrameSound(DExhumedActor* actor, const SeqFrame& seqFrame);
inline const Seq& getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
{

View file

@ -145,7 +145,7 @@ void AISoul::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor;
if (!pActor) return;
playFrameSound(pActor, getSequence("set", 75).frames[0]);
getSequence("set", 75).frames[0].playSound(pActor);
if (pActor->spr.scale.X < 0.5)
{
@ -275,7 +275,7 @@ void AISet::Tick(RunListEvent* ev)
const auto& seqFrame = setSeq.frames[pActor->nFrame];
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
if (nAction == 3)
{

View file

@ -339,7 +339,7 @@ void AISnake::Tick(RunListEvent* ev)
DExhumedActor* pActor = SnakeList[nSnake].pSprites[0];
if (!pActor) return;
playFrameSound(pActor, getSequence("snakehed").frames[0]);
getSequence("snakehed").frames[0].playSound(pActor);
DExhumedActor* pEnemySprite = SnakeList[nSnake].pEnemy;

View file

@ -124,7 +124,7 @@ void AISpider::Tick(RunListEvent* ev)
spp->spr.picnum = spp->nFrame < 9 ? seqFrame.getFirstPicnum() : -1;
playFrameSound(spp, seqFrame);
seqFrame.playSound(spp);
spp->nFrame++;
if (spp->nFrame >= spiderSeq.frames.Size()) {

View file

@ -220,7 +220,7 @@ void AIWasp::Tick(RunListEvent* ev)
pActor->spr.picnum = seqFrame.getFirstPicnum();
playFrameSound(pActor, seqFrame);
seqFrame.playSound(pActor);
pActor->nFrame++;
if (pActor->nFrame >= waspSeq.frames.Size())