mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 08:14:38 +01:00
Split off Update{Action,Walking}Animation and use for frozen peeps
This commit is contained in:
@@ -428,18 +428,13 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
|
||||
return UpdateWalkingAction(differenceLoc, xy_distance);
|
||||
}
|
||||
|
||||
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
|
||||
ActionFrame++;
|
||||
|
||||
// If last frame of action
|
||||
if (ActionFrame >= peepAnimation.frame_offsets.size())
|
||||
if (!UpdateActionAnimation())
|
||||
{
|
||||
ActionSpriteImageOffset = 0;
|
||||
Action = PeepActionType::Walking;
|
||||
UpdateCurrentActionSpriteType();
|
||||
return { { x, y } };
|
||||
}
|
||||
ActionSpriteImageOffset = peepAnimation.frame_offsets[ActionFrame];
|
||||
|
||||
// Should we throw up, and are we at the frame where sick appears?
|
||||
auto* guest = As<Guest>();
|
||||
@@ -451,6 +446,21 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
|
||||
return { { x, y } };
|
||||
}
|
||||
|
||||
bool Peep::UpdateActionAnimation()
|
||||
{
|
||||
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
|
||||
ActionFrame++;
|
||||
|
||||
// If last frame of action
|
||||
if (ActionFrame >= peepAnimation.frame_offsets.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ActionSpriteImageOffset = peepAnimation.frame_offsets[ActionFrame];
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<CoordsXY> Peep::UpdateWalkingAction(const CoordsXY& differenceLoc, int16_t& xy_distance)
|
||||
{
|
||||
if (!IsActionWalking())
|
||||
@@ -489,6 +499,13 @@ std::optional<CoordsXY> Peep::UpdateWalkingAction(const CoordsXY& differenceLoc,
|
||||
CoordsXY loc = { x, y };
|
||||
loc += walkingOffsetByDirection[nextDirection];
|
||||
|
||||
UpdateWalkingAnimation();
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
void Peep::UpdateWalkingAnimation()
|
||||
{
|
||||
WalkingFrameNum++;
|
||||
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
|
||||
if (WalkingFrameNum >= peepAnimation.frame_offsets.size())
|
||||
@@ -496,8 +513,6 @@ std::optional<CoordsXY> Peep::UpdateWalkingAction(const CoordsXY& differenceLoc,
|
||||
WalkingFrameNum = 0;
|
||||
}
|
||||
ActionSpriteImageOffset = peepAnimation.frame_offsets[WalkingFrameNum];
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
void Peep::ThrowUp()
|
||||
@@ -958,6 +973,17 @@ void Peep::Update()
|
||||
{
|
||||
if (PeepFlags & PEEP_FLAGS_POSITION_FROZEN)
|
||||
{
|
||||
if (!(PeepFlags & PEEP_FLAGS_ANIMATION_FROZEN))
|
||||
{
|
||||
// This is circumventing other logic, so only update every few ticks
|
||||
if ((GetGameState().CurrentTicks & 3) == 0)
|
||||
{
|
||||
if (IsActionWalking())
|
||||
UpdateWalkingAnimation();
|
||||
else
|
||||
UpdateActionAnimation();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user