Add IsActionWalking getter and refactor uses

This commit is contained in:
Matt 2021-05-11 10:07:01 +03:00
parent 8d9e47ee1c
commit 088b476dc5
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
4 changed files with 20 additions and 14 deletions

View File

@ -3290,7 +3290,7 @@ void Guest::UpdateBuying()
if (SubState == 1)
{
if (Action != PeepActionType::Walking)
if (!IsWalking())
{
UpdateAction();
Invalidate();
@ -5655,7 +5655,7 @@ void Guest::UpdateWatching()
// 6917F6
UpdateAction();
Invalidate();
if (Action != PeepActionType::Walking)
if (!IsWalking())
return;
Action = PeepActionType::Idle;
}
@ -5736,7 +5736,7 @@ void Guest::UpdateUsingBin()
}
case PeepUsingBinSubState::GoingBack:
{
if (Action != PeepActionType::Walking)
if (!IsWalking())
{
UpdateAction();
Invalidate();
@ -7273,7 +7273,7 @@ bool Guest::UpdateQueuePosition(PeepActionType previous_action)
if (Action < PeepActionType::Idle)
UpdateAction();
if (Action != PeepActionType::Walking)
if (!IsWalking())
return true;
Action = PeepActionType::Idle;

View File

@ -405,7 +405,7 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
xy_distance = x_delta + y_delta;
if (Action == PeepActionType::Walking)
if (IsWalking())
{
if (xy_distance <= DestinationTolerance)
{
@ -930,7 +930,7 @@ void Peep::Update()
stepsToTake = 95;
if ((PeepFlags & PEEP_FLAGS_SLOW_WALK) && State != PeepState::Queuing)
stepsToTake /= 2;
if (Action == PeepActionType::Walking && (GetNextIsSloped()))
if (IsWalking() && GetNextIsSloped())
{
stepsToTake /= 2;
if (State == PeepState::Queuing)
@ -1528,6 +1528,11 @@ bool Peep::SetName(std::string_view value)
return false;
}
bool Peep::IsWalking() const
{
return Action == PeepActionType::Walking;
}
void peep_set_map_tooltip(Peep* peep)
{
auto ft = Formatter();

View File

@ -743,6 +743,7 @@ public: // Peep
void FormatNameTo(Formatter&) const;
std::string GetName() const;
bool SetName(std::string_view value);
bool IsWalking() const;
// Reset the peep's stored goal, which means they will forget any stored pathfinding history
// on the next peep_pathfind_choose_direction call.

View File

@ -1213,7 +1213,7 @@ void Staff::UpdateWatering()
}
else if (SubState == 1)
{
if (Action != PeepActionType::Walking)
if (!IsWalking())
{
UpdateAction();
Invalidate();
@ -1277,7 +1277,7 @@ void Staff::UpdateEmptyingBin()
}
else if (SubState == 1)
{
if (Action == PeepActionType::Walking)
if (IsWalking())
{
StateReset();
return;
@ -1496,7 +1496,7 @@ void Staff::UpdateAnswering()
}
else if (SubState == 1)
{
if (Action == PeepActionType::Walking)
if (IsWalking())
{
SubState = 2;
peep_window_state_update(this);
@ -2184,7 +2184,7 @@ bool Staff::UpdateFixingFixVehicle(bool firstRun, const Ride* ride)
UpdateCurrentActionSpriteType();
}
if (Action == PeepActionType::Walking)
if (IsWalking())
{
return true;
}
@ -2226,7 +2226,7 @@ bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride* ride)
UpdateCurrentActionSpriteType();
}
if (Action == PeepActionType::Walking)
if (IsWalking())
{
return true;
}
@ -2331,7 +2331,7 @@ bool Staff::UpdateFixingFixStationEnd(bool firstRun)
UpdateCurrentActionSpriteType();
}
if (Action == PeepActionType::Walking)
if (IsWalking())
{
return true;
}
@ -2472,7 +2472,7 @@ bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride)
UpdateCurrentActionSpriteType();
}
if (Action == PeepActionType::Walking)
if (IsWalking())
{
return true;
}
@ -2564,7 +2564,7 @@ bool Staff::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* r
UpdateCurrentActionSpriteType();
}
if (Action != PeepActionType::Walking)
if (!IsWalking())
{
UpdateAction();
Invalidate();