Move ProcessPlayerAnimation to AnimationInfo
This commit is contained in:
parent
16b3b38908
commit
ff995adc2b
5 changed files with 23 additions and 18 deletions
|
|
@ -81,7 +81,7 @@ void AnimationInfo::SetNewAnimation(uint8_t *pData, int numberOfFrames, int dela
|
|||
|
||||
if (params == AnimationDistributionParams::ProcessAnimationPending) {
|
||||
// If ProcessAnimation will be called after SetNewAnimation (in same GameTick as NewPlrAnim), we increment the Animation-Counter.
|
||||
// If no delay is specified, this will result in complete skipped frame (see ProcessPlayerAnimation).
|
||||
// If no delay is specified, this will result in complete skipped frame (see ProcessAnimation).
|
||||
// But if we have a delay specified, this would only result in a reduced time the first frame is shown (one skipped delay).
|
||||
// Because of that, we only the remove one GameTick from the time the Animation is shown
|
||||
relevantAnimationGameTicksWithSkipping -= 1;
|
||||
|
|
@ -122,4 +122,18 @@ void AnimationInfo::SetNewAnimation(uint8_t *pData, int numberOfFrames, int dela
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationInfo::ProcessAnimation()
|
||||
{
|
||||
DelayCounter++;
|
||||
GameTicksSinceSequenceStarted++;
|
||||
if (DelayCounter > DelayLen) {
|
||||
DelayCounter = 0;
|
||||
CurrentFrame++;
|
||||
if (CurrentFrame > NumberOfFrames) {
|
||||
CurrentFrame = 1;
|
||||
GameTicksSinceSequenceStarted = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@ public:
|
|||
*/
|
||||
void SetNewAnimation(uint8_t *pData, int numberOfFrames, int delayLen, AnimationDistributionParams params = AnimationDistributionParams::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0);
|
||||
|
||||
/*
|
||||
* @brief Process the Animation for a GameTick (for example advances the frame)
|
||||
*/
|
||||
void ProcessAnimation();
|
||||
|
||||
private:
|
||||
/*
|
||||
* @brief Specifies how many animations-fractions are displayed between two gameticks. this can be > 0, if animations are skipped or < 0 if the same animation is shown in multiple times (delay specified).
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3637,21 +3637,7 @@ void ProcessPlayers()
|
|||
CheckNewPath(pnum);
|
||||
} while (tplayer);
|
||||
|
||||
ProcessPlayerAnimation(pnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessPlayerAnimation(int pnum)
|
||||
{
|
||||
plr[pnum].AnimInfo.DelayCounter++;
|
||||
plr[pnum].AnimInfo.GameTicksSinceSequenceStarted++;
|
||||
if (plr[pnum].AnimInfo.DelayCounter > plr[pnum].AnimInfo.DelayLen) {
|
||||
plr[pnum].AnimInfo.DelayCounter = 0;
|
||||
plr[pnum].AnimInfo.CurrentFrame++;
|
||||
if (plr[pnum].AnimInfo.CurrentFrame > plr[pnum].AnimInfo.FrameLen) {
|
||||
plr[pnum].AnimInfo.CurrentFrame = 1;
|
||||
plr[pnum].AnimInfo.GameTicksSinceSequenceStarted = 0;
|
||||
plr[pnum].AnimInfo.ProcessAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,7 +398,6 @@ void FreePlayerGFX(int pnum);
|
|||
*/
|
||||
void NewPlrAnim(int pnum, BYTE *pData, int numberOfFrames, int delayLen, int width, AnimationDistributionParams params = AnimationDistributionParams::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0);
|
||||
void SetPlrAnims(int pnum);
|
||||
void ProcessPlayerAnimation(int pnum);
|
||||
void CreatePlayer(int pnum, HeroClass c);
|
||||
int CalcStatDiff(int pnum);
|
||||
#ifdef _DEBUG
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void RunAnimationTest(int numFrames, int delay, AnimationDistributionParams para
|
|||
currentGameTick += 1;
|
||||
if (gameTickData->_FramesToSkip != 0)
|
||||
pPlayer->AnimInfo.CurrentFrame += gameTickData->_FramesToSkip;
|
||||
ProcessPlayerAnimation(pnum);
|
||||
pPlayer->AnimInfo.ProcessAnimation();
|
||||
EXPECT_EQ(pPlayer->AnimInfo.CurrentFrame, gameTickData->_ExpectedAnimationFrame);
|
||||
EXPECT_EQ(pPlayer->AnimInfo.DelayCounter, gameTickData->_ExpectedAnimationCnt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue