mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 11:33:03 +01:00
Add IsActionIdle/IsActionInterruptable getter and refactor uses
This commit is contained in:
@@ -474,7 +474,7 @@ void Guest::GivePassingPeepsPizza(Guest* passingPeep)
|
||||
int32_t otherPeepOppositeDirection = passingPeep->sprite_direction >> 3;
|
||||
if (peepDirection == otherPeepOppositeDirection)
|
||||
{
|
||||
if (passingPeep->Action == PeepActionType::Idle || passingPeep->Action == PeepActionType::Walking)
|
||||
if (passingPeep->IsActionInterruptable())
|
||||
{
|
||||
passingPeep->Action = PeepActionType::Wave2;
|
||||
passingPeep->ActionFrame = 0;
|
||||
@@ -491,7 +491,7 @@ void Guest::MakePassingPeepsSick(Guest* passingPeep)
|
||||
if (passingPeep->State != PeepState::Walking)
|
||||
return;
|
||||
|
||||
if (passingPeep->Action == PeepActionType::Idle || passingPeep->Action == PeepActionType::Walking)
|
||||
if (passingPeep->IsActionInterruptable())
|
||||
{
|
||||
passingPeep->Action = PeepActionType::ThrowUp;
|
||||
passingPeep->ActionFrame = 0;
|
||||
@@ -536,7 +536,7 @@ void Guest::UpdateEasterEggInteractions()
|
||||
{
|
||||
if (scenario_rand() <= 1456)
|
||||
{
|
||||
if (Action == PeepActionType::Idle || Action == PeepActionType::Walking)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
Action = PeepActionType::Joy;
|
||||
ActionFrame = 0;
|
||||
@@ -744,7 +744,7 @@ void Guest::loc_68F9F3()
|
||||
{
|
||||
if ((scenario_rand() & 0xFF) <= static_cast<uint8_t>((Nausea - 128) / 2))
|
||||
{
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
Action = PeepActionType::ThrowUp;
|
||||
ActionFrame = 0;
|
||||
@@ -1247,10 +1247,10 @@ void Guest::UpdateSitting()
|
||||
}
|
||||
else if (SittingSubState == PeepSittingSubState::SatDown)
|
||||
{
|
||||
if (Action < PeepActionType::Idle)
|
||||
if (!IsActionInterruptable())
|
||||
{
|
||||
UpdateAction();
|
||||
if (Action != PeepActionType::Walking)
|
||||
if (!IsActionWalking())
|
||||
return;
|
||||
|
||||
Action = PeepActionType::Idle;
|
||||
@@ -2341,7 +2341,7 @@ void Guest::ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRide)
|
||||
|
||||
void Guest::ReadMap()
|
||||
{
|
||||
if (Action == PeepActionType::Idle || Action == PeepActionType::Walking)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
Action = PeepActionType::ReadMap;
|
||||
ActionFrame = 0;
|
||||
@@ -3290,7 +3290,7 @@ void Guest::UpdateBuying()
|
||||
|
||||
if (SubState == 1)
|
||||
{
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
{
|
||||
UpdateAction();
|
||||
Invalidate();
|
||||
@@ -4781,7 +4781,7 @@ void Guest::UpdateRideMazePathfinding()
|
||||
return;
|
||||
}
|
||||
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
if (Energy > 64 && (scenario_rand() & 0xFFFF) <= 2427)
|
||||
{
|
||||
@@ -5174,7 +5174,7 @@ void Guest::UpdateWalking()
|
||||
|
||||
if (PeepFlags & PEEP_FLAGS_WAVING)
|
||||
{
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
if ((0xFFFF & scenario_rand()) < 936)
|
||||
{
|
||||
@@ -5189,7 +5189,7 @@ void Guest::UpdateWalking()
|
||||
|
||||
if (PeepFlags & PEEP_FLAGS_PHOTO)
|
||||
{
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
if ((0xFFFF & scenario_rand()) < 936)
|
||||
{
|
||||
@@ -5204,7 +5204,7 @@ void Guest::UpdateWalking()
|
||||
|
||||
if (PeepFlags & PEEP_FLAGS_PAINTING)
|
||||
{
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
if ((0xFFFF & scenario_rand()) < 936)
|
||||
{
|
||||
@@ -5481,7 +5481,7 @@ void Guest::UpdateQueuing()
|
||||
|
||||
uint8_t pathingResult;
|
||||
PerformNextAction(pathingResult);
|
||||
if (Action < PeepActionType::Idle)
|
||||
if (!IsActionInterruptable())
|
||||
return;
|
||||
if (SpriteType == PeepSpriteType::Normal)
|
||||
{
|
||||
@@ -5501,7 +5501,7 @@ void Guest::UpdateQueuing()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(TimeInQueue & 0x3F) && Action == PeepActionType::Idle && NextActionSpriteType == PeepActionSpriteType::WatchRide)
|
||||
if (!(TimeInQueue & 0x3F) && IsActionIdle() && NextActionSpriteType == PeepActionSpriteType::WatchRide)
|
||||
{
|
||||
switch (SpriteType)
|
||||
{
|
||||
@@ -5650,12 +5650,12 @@ void Guest::UpdateWatching()
|
||||
}
|
||||
else if (SubState == 1)
|
||||
{
|
||||
if (Action < PeepActionType::Idle)
|
||||
if (!IsActionInterruptable())
|
||||
{
|
||||
// 6917F6
|
||||
UpdateAction();
|
||||
Invalidate();
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
return;
|
||||
Action = PeepActionType::Idle;
|
||||
}
|
||||
@@ -5736,7 +5736,7 @@ void Guest::UpdateUsingBin()
|
||||
}
|
||||
case PeepUsingBinSubState::GoingBack:
|
||||
{
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
{
|
||||
UpdateAction();
|
||||
Invalidate();
|
||||
@@ -6592,7 +6592,7 @@ void Guest::SetSpriteType(PeepSpriteType new_sprite_type)
|
||||
ActionSpriteImageOffset = 0;
|
||||
WalkingFrameNum = 0;
|
||||
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
Action = PeepActionType::Walking;
|
||||
|
||||
PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
|
||||
@@ -6803,7 +6803,7 @@ void peep_thought_set_format_args(const rct_peep_thought* thought, Formatter& ft
|
||||
void Guest::InsertNewThought(PeepThoughtType thoughtType, uint8_t thoughtArguments)
|
||||
{
|
||||
PeepActionType newAction = PeepThoughtToActionMap[EnumValue(thoughtType)].action;
|
||||
if (newAction != PeepActionType::Walking && this->Action >= PeepActionType::Idle)
|
||||
if (newAction != PeepActionType::Walking && IsActionInterruptable())
|
||||
{
|
||||
Action = newAction;
|
||||
ActionFrame = 0;
|
||||
@@ -7270,10 +7270,10 @@ bool Guest::UpdateQueuePosition(PeepActionType previous_action)
|
||||
}
|
||||
}
|
||||
|
||||
if (Action < PeepActionType::Idle)
|
||||
if (!IsActionInterruptable())
|
||||
UpdateAction();
|
||||
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
return true;
|
||||
|
||||
Action = PeepActionType::Idle;
|
||||
|
||||
@@ -307,7 +307,7 @@ bool Peep::CheckForPath()
|
||||
|
||||
PeepActionSpriteType Peep::GetActionSpriteType()
|
||||
{
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{ // PeepActionType::None1 or PeepActionType::None2
|
||||
return PeepSpecialSpriteToSpriteTypeMap[SpecialSprite];
|
||||
}
|
||||
@@ -358,8 +358,7 @@ void Peep::SwitchToSpecialSprite(uint8_t special_sprite_id)
|
||||
|
||||
SpecialSprite = special_sprite_id;
|
||||
|
||||
// If NONE_1 or NONE_2
|
||||
if (Action >= PeepActionType::Idle)
|
||||
if (IsActionInterruptable())
|
||||
{
|
||||
ActionSpriteImageOffset = 0;
|
||||
}
|
||||
@@ -405,7 +404,7 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
|
||||
|
||||
xy_distance = x_delta + y_delta;
|
||||
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
if (xy_distance <= DestinationTolerance)
|
||||
{
|
||||
@@ -930,7 +929,7 @@ void Peep::Update()
|
||||
stepsToTake = 95;
|
||||
if ((PeepFlags & PEEP_FLAGS_SLOW_WALK) && State != PeepState::Queuing)
|
||||
stepsToTake /= 2;
|
||||
if (IsWalking() && GetNextIsSloped())
|
||||
if (IsActionWalking() && GetNextIsSloped())
|
||||
{
|
||||
stepsToTake /= 2;
|
||||
if (State == PeepState::Queuing)
|
||||
@@ -1248,7 +1247,7 @@ void peep_applause()
|
||||
peep_release_balloon(peep, peep->z + 9);
|
||||
|
||||
// Clap
|
||||
if ((peep->State == PeepState::Walking || peep->State == PeepState::Queuing) && peep->Action >= PeepActionType::Idle)
|
||||
if ((peep->State == PeepState::Walking || peep->State == PeepState::Queuing) && peep->IsActionInterruptable())
|
||||
{
|
||||
peep->Action = PeepActionType::Clap;
|
||||
peep->ActionFrame = 0;
|
||||
@@ -1528,11 +1527,21 @@ bool Peep::SetName(std::string_view value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Peep::IsWalking() const
|
||||
bool Peep::IsActionWalking() const
|
||||
{
|
||||
return Action == PeepActionType::Walking;
|
||||
}
|
||||
|
||||
bool Peep::IsActionIdle() const
|
||||
{
|
||||
return Action == PeepActionType::Idle;
|
||||
}
|
||||
|
||||
bool Peep::IsActionInterruptable() const
|
||||
{
|
||||
return IsActionIdle() || IsActionWalking();
|
||||
}
|
||||
|
||||
void peep_set_map_tooltip(Peep* peep)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
|
||||
@@ -743,7 +743,9 @@ public: // Peep
|
||||
void FormatNameTo(Formatter&) const;
|
||||
std::string GetName() const;
|
||||
bool SetName(std::string_view value);
|
||||
bool IsWalking() const;
|
||||
bool IsActionWalking() const;
|
||||
bool IsActionIdle() const;
|
||||
bool IsActionInterruptable() const;
|
||||
|
||||
// Reset the peep's stored goal, which means they will forget any stored pathfinding history
|
||||
// on the next peep_pathfind_choose_direction call.
|
||||
|
||||
@@ -996,7 +996,7 @@ void Staff::EntertainerUpdateNearbyPeeps() const
|
||||
*/
|
||||
bool Staff::DoEntertainerPathFinding()
|
||||
{
|
||||
if (((scenario_rand() & 0xFFFF) <= 0x4000) && (Action == PeepActionType::Idle || Action == PeepActionType::Walking))
|
||||
if (((scenario_rand() & 0xFFFF) <= 0x4000) && IsActionInterruptable())
|
||||
{
|
||||
Action = (scenario_rand() & 1) ? PeepActionType::Wave2 : PeepActionType::Joy;
|
||||
ActionFrame = 0;
|
||||
@@ -1213,7 +1213,7 @@ void Staff::UpdateWatering()
|
||||
}
|
||||
else if (SubState == 1)
|
||||
{
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
{
|
||||
UpdateAction();
|
||||
Invalidate();
|
||||
@@ -1277,7 +1277,7 @@ void Staff::UpdateEmptyingBin()
|
||||
}
|
||||
else if (SubState == 1)
|
||||
{
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
StateReset();
|
||||
return;
|
||||
@@ -1496,7 +1496,7 @@ void Staff::UpdateAnswering()
|
||||
}
|
||||
else if (SubState == 1)
|
||||
{
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
SubState = 2;
|
||||
peep_window_state_update(this);
|
||||
@@ -2184,7 +2184,7 @@ bool Staff::UpdateFixingFixVehicle(bool firstRun, const Ride* ride)
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2226,7 +2226,7 @@ bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride* ride)
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2331,7 +2331,7 @@ bool Staff::UpdateFixingFixStationEnd(bool firstRun)
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2444,7 +2444,7 @@ bool Staff::UpdateFixingFixStationStart(bool firstRun, const Ride* ride)
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (Action == PeepActionType::Walking)
|
||||
if (IsActionWalking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2472,7 +2472,7 @@ bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride)
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (IsWalking())
|
||||
if (IsActionWalking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2564,7 +2564,7 @@ bool Staff::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* r
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
if (!IsWalking())
|
||||
if (!IsActionWalking())
|
||||
{
|
||||
UpdateAction();
|
||||
Invalidate();
|
||||
|
||||
Reference in New Issue
Block a user