diff --git a/src/openrct2/object/PeepAnimationsObject.cpp b/src/openrct2/object/PeepAnimationsObject.cpp index 300f143613..c998122b92 100644 --- a/src/openrct2/object/PeepAnimationsObject.cpp +++ b/src/openrct2/object/PeepAnimationsObject.cpp @@ -104,6 +104,17 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root) } } + // 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(); + } + _animationGroups.push_back(group); } } @@ -143,6 +154,11 @@ PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup an return _animationGroups[EnumValue(animGroup)].legacyPosition; } +std::string_view PeepAnimationsObject::GetScriptName(PeepAnimationGroup animGroup) const +{ + return _animationGroups[EnumValue(animGroup)].scriptName; +} + void PeepAnimationsObject::DrawPreview(DrawPixelInfo& dpi, int32_t width, int32_t height) const { auto centre = ScreenCoordsXY{ width / 2, height / 2 }; diff --git a/src/openrct2/object/PeepAnimationsObject.h b/src/openrct2/object/PeepAnimationsObject.h index 767d00383c..f653f4eb15 100644 --- a/src/openrct2/object/PeepAnimationsObject.h +++ b/src/openrct2/object/PeepAnimationsObject.h @@ -13,6 +13,7 @@ #include "../peep/PeepAnimations.h" #include "Object.h" +#include #include class PeepAnimationsObject final : public Object @@ -41,6 +42,7 @@ public: OpenRCT2::AnimationPeepType GetPeepType() const; size_t GetNumAnimationGroups() const; PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const; + std::string_view GetScriptName(PeepAnimationGroup animGroup) const; bool IsSlowWalking() { diff --git a/src/openrct2/peep/PeepAnimations.h b/src/openrct2/peep/PeepAnimations.h index 2c1199ec2d..e3a7b87172 100644 --- a/src/openrct2/peep/PeepAnimations.h +++ b/src/openrct2/peep/PeepAnimations.h @@ -14,6 +14,7 @@ #include "../drawing/ImageIndexType.h" #include "../entity/Peep.h" +#include #include class PeepAnimationsObject; @@ -51,6 +52,7 @@ namespace OpenRCT2 public: // TODO: move type to RCT12? PeepAnimationGroup legacyPosition = PeepAnimationGroup::Invalid; + std::string scriptName{}; constexpr PeepAnimation& operator[](PeepAnimationType n) {