1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01:00

Move isSlowWalking property to animation group level

This commit is contained in:
Aaron van Geffen
2024-12-23 12:21:04 +01:00
parent cc668f080e
commit 6ed7fd461e
9 changed files with 22 additions and 30 deletions

View File

@@ -162,7 +162,7 @@ GameActions::Result StaffHireNewAction::QueryExecute(bool execute) const
auto* animObj = objManager.GetLoadedObject<PeepAnimationsObject>(animObjectIndex);
newPeep->PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
if (animObj->IsSlowWalking())
if (animObj->IsSlowWalking(PeepAnimationGroup::Normal))
newPeep->PeepFlags |= PEEP_FLAGS_SLOW_WALK;
const auto& spriteBounds = animObj->GetSpriteBounds(newPeep->AnimationGroup);

View File

@@ -89,7 +89,7 @@ GameActions::Result StaffSetCostumeAction::Execute() const
auto* animObj = objManager.GetLoadedObject<PeepAnimationsObject>(_costume);
staff->PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
if (animObj->IsSlowWalking())
if (animObj->IsSlowWalking(PeepAnimationGroup::Normal))
staff->PeepFlags |= PEEP_FLAGS_SLOW_WALK;
staff->AnimationFrameNum = 0;

View File

@@ -6769,9 +6769,11 @@ void Guest::SetAnimationGroup(PeepAnimationGroup new_sprite_type)
if (IsActionInterruptable())
Action = PeepActionType::Walking;
auto& objManager = GetContext()->GetObjectManager();
auto* animObj = objManager.GetLoadedObject<PeepAnimationsObject>(AnimationObjectIndex);
PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
Guard::Assert(EnumValue(new_sprite_type) < std::size(gAnimationGroupToSlowWalkMap));
if (gAnimationGroupToSlowWalkMap[EnumValue(new_sprite_type)])
if (animObj->IsSlowWalking(new_sprite_type))
{
PeepFlags |= PEEP_FLAGS_SLOW_WALK;
}

View File

@@ -126,12 +126,6 @@ static PeepAnimationType PeepActionToAnimationGroupMap[] = {
PeepAnimationType::WithdrawMoney,
};
const bool gAnimationGroupToSlowWalkMap[] = {
false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, true,
true, true, true, false, true, false, true, true, true, false, false, true, true, false, false, true,
true, true, true, true, true, true, false, true, false, true, true, true, true, true, true, true,
};
template<>
bool EntityBase::Is<Peep>() const
{

View File

@@ -422,8 +422,6 @@ enum
PATHING_RIDE_ENTRANCE = 1 << 3,
};
extern const bool gAnimationGroupToSlowWalkMap[48];
int32_t PeepGetStaffCount();
void PeepUpdateAll();
void PeepUpdateAllBoundingBoxes();

View File

@@ -29,6 +29,7 @@
#include "../object/ObjectList.h"
#include "../object/ObjectManager.h"
#include "../object/PathAdditionEntry.h"
#include "../object/PeepAnimationsObject.h"
#include "../object/SceneryGroupEntry.h"
#include "../object/SmallSceneryEntry.h"
#include "../object/TerrainSurfaceObject.h"
@@ -1650,8 +1651,11 @@ void Staff::Tick128UpdateStaff()
if (Action < PeepActionType::Idle)
Action = PeepActionType::Walking;
auto& objManager = GetContext()->GetObjectManager();
auto* animObj = objManager.GetLoadedObject<PeepAnimationsObject>(AnimationObjectIndex);
PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
if (gAnimationGroupToSlowWalkMap[EnumValue(newAnimationGroup)])
if (animObj->IsSlowWalking(newAnimationGroup))
{
PeepFlags |= PEEP_FLAGS_SLOW_WALK;
}

View File

@@ -95,16 +95,12 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root)
group.legacyPosition = RCT12PeepAnimationGroup::Invalid;
}
// Should we play back the walking animation more slowly?
group.isSlowWalking = Json::GetBoolean(groupJson["isSlowWalking"], false);
// Do we have a preferred way of addressing this object in scripts?
if (groupJson.contains("scriptName"))
{
group.scriptName = Json::GetString(groupJson["scriptName"]);
}
// If not, just use the object identifier.
else
{
group.scriptName = GetIdentifier();
}
group.scriptName = Json::GetString(groupJson["scriptName"], std::string(GetIdentifier()));
_animationGroups.push_back(group);
}
@@ -159,10 +155,6 @@ void PeepAnimationsObject::ReadProperties(json_t& props)
Guard::Assert(props["peepType"].is_string(), "PeepAnimationsObject::ReadProperties expects peepType to be a string");
_peepType = animationPeepTypeMap[Json::GetString(props["peepType"])];
Guard::Assert(
props["isSlowWalking"].is_boolean(), "PeepAnimationsObject::ReadProperties expects isSlowWalking to be a boolean");
_slowWalking = Json::GetBoolean(props["isSlowWalking"], false);
Guard::Assert(
props["noRandomPlacement"].is_boolean(),
"PeepAnimationsObject::ReadProperties expects noRandomPlacement to be a boolean");
@@ -209,6 +201,11 @@ std::string_view PeepAnimationsObject::GetScriptName(PeepAnimationGroup animGrou
return _animationGroups[EnumValue(animGroup)].scriptName;
}
bool PeepAnimationsObject::IsSlowWalking(PeepAnimationGroup animGroup) const
{
return _animationGroups[EnumValue(animGroup)].isSlowWalking;
}
void PeepAnimationsObject::DrawPreview(DrawPixelInfo& dpi, int32_t width, int32_t height) const
{
auto centre = ScreenCoordsXY{ width / 2, height / 2 };

View File

@@ -24,7 +24,6 @@ private:
ImageIndex _imageOffsetId;
std::vector<OpenRCT2::PeepAnimations> _animationGroups;
OpenRCT2::AnimationPeepType _peepType;
bool _slowWalking;
bool _noRandomPlacement;
public:
@@ -49,10 +48,7 @@ public:
RCT12PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const;
std::string_view GetScriptName(PeepAnimationGroup animGroup) const;
bool IsSlowWalking() const
{
return _slowWalking;
};
bool IsSlowWalking(PeepAnimationGroup animGroup) const;
bool ShouldExcludeFromRandomPlacement() const
{

View File

@@ -53,6 +53,7 @@ namespace OpenRCT2
struct PeepAnimations
{
public:
bool isSlowWalking = false;
RCT12PeepAnimationGroup legacyPosition;
std::string scriptName{};