diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 70faf79358..1407aea0b5 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -461,7 +463,7 @@ namespace OpenRCT2::Ui::Windows } else { - GfxDrawSprite(dpi, ImageId(GetEntertainerCostumeSprite(peep->AnimationGroup)), { staffOrderIcon_x, y }); + GfxDrawSprite(dpi, GetCostumeInlineSprite(peep->AnimationObjectIndex), { staffOrderIcon_x, y }); } } @@ -728,36 +730,11 @@ namespace OpenRCT2::Ui::Windows } } - static uint32_t GetEntertainerCostumeSprite(PeepAnimationGroup type) + static ImageId GetCostumeInlineSprite(ObjectEntryIndex index) { - switch (type) - { - case PeepAnimationGroup::EntertainerPanda: - return SPR_STAFF_COSTUME_PANDA; - case PeepAnimationGroup::EntertainerTiger: - return SPR_STAFF_COSTUME_TIGER; - case PeepAnimationGroup::EntertainerElephant: - return SPR_STAFF_COSTUME_ELEPHANT; - case PeepAnimationGroup::EntertainerRoman: - return SPR_STAFF_COSTUME_ROMAN; - case PeepAnimationGroup::EntertainerGorilla: - return SPR_STAFF_COSTUME_GORILLA; - case PeepAnimationGroup::EntertainerSnowman: - return SPR_STAFF_COSTUME_SNOWMAN; - case PeepAnimationGroup::EntertainerKnight: - return SPR_STAFF_COSTUME_KNIGHT; - case PeepAnimationGroup::EntertainerAstronaut: - return SPR_STAFF_COSTUME_ASTRONAUT; - case PeepAnimationGroup::EntertainerBandit: - return SPR_STAFF_COSTUME_BANDIT; - case PeepAnimationGroup::EntertainerSheriff: - return SPR_STAFF_COSTUME_SHERIFF; - case PeepAnimationGroup::EntertainerPirate: - return SPR_STAFF_COSTUME_PIRATE; - case PeepAnimationGroup::Normal: - default: - return SPR_PEEP_SMALL_FACE_HAPPY; - } + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(index); + return ImageId(animObj->GetInlineImageId()); } }; diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 541e4b0205..048bb0a7bc 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -36,6 +36,8 @@ #include "../management/Marketing.h" #include "../management/NewsItem.h" #include "../network/network.h" +#include "../object/ObjectManager.h" +#include "../object/PeepAnimationsObject.h" #include "../paint/Paint.h" #include "../peep/GuestPathfinding.h" #include "../peep/PeepAnimationData.h" @@ -471,7 +473,10 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) bool Peep::UpdateActionAnimation() { - const PeepAnimation& peepAnimation = GetPeepAnimation(AnimationGroup, AnimationType); + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(AnimationObjectIndex); + + const PeepAnimation& peepAnimation = animObj->GetPeepAnimation(AnimationGroup, AnimationType); AnimationFrameNum++; // If last frame of action @@ -529,8 +534,11 @@ std::optional Peep::UpdateWalkingAction(const CoordsXY& differenceLoc, void Peep::UpdateWalkingAnimation() { + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(AnimationObjectIndex); + WalkingAnimationFrameNum++; - const PeepAnimation& peepAnimation = GetPeepAnimation(AnimationGroup, AnimationType); + const PeepAnimation& peepAnimation = animObj->GetPeepAnimation(AnimationGroup, AnimationType); if (WalkingAnimationFrameNum >= peepAnimation.frame_offsets.size()) { WalkingAnimationFrameNum = 0; @@ -2896,9 +2904,12 @@ void Peep::Paint(PaintSession& session, int32_t imageDirection) const imageOffset = 0; } + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(AnimationObjectIndex); + // In the following 4 calls to PaintAddImageAsParent/PaintAddImageAsChild, we add 5 (instead of 3) to the // bound_box_offset_z to make sure peeps are drawn on top of railways - uint32_t baseImageId = GetPeepAnimation(AnimationGroup, actionAnimationGroup).base_image; + uint32_t baseImageId = animObj->GetPeepAnimation(AnimationGroup, actionAnimationGroup).base_image; // Offset frame onto the base image, using rotation except for the 'picked up' state if (actionAnimationGroup != PeepAnimationType::Hanging) diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 9e23450a7a..bd8f92ada2 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -234,54 +234,60 @@ enum PeepNextFlags enum class PeepAnimationGroup : uint8_t { Normal = 0, - Handyman = 1, - Mechanic = 2, - Security = 3, - EntertainerPanda = 4, - EntertainerTiger = 5, - EntertainerElephant = 6, - EntertainerRoman = 7, - EntertainerGorilla = 8, - EntertainerSnowman = 9, - EntertainerKnight = 10, - EntertainerAstronaut = 11, - EntertainerBandit = 12, - EntertainerSheriff = 13, - EntertainerPirate = 14, - IceCream = 15, - Chips = 16, - Burger = 17, - Drink = 18, - Balloon = 19, - Candyfloss = 20, - Umbrella = 21, - Pizza = 22, - SecurityAlt = 23, - Popcorn = 24, - ArmsCrossed = 25, - HeadDown = 26, - Nauseous = 27, - VeryNauseous = 28, - RequireToilet = 29, - Hat = 30, - HotDog = 31, - Tentacle = 32, - ToffeeApple = 33, - Doughnut = 34, - Coffee = 35, - Chicken = 36, - Lemonade = 37, - Watching = 38, - Pretzel = 39, - Sunglasses = 40, - SuJongkwa = 41, - Juice = 42, - FunnelCake = 43, - Noodles = 44, - Sausage = 45, - Soup = 46, - Sandwich = 47, - Count = 48, + Handyman = 0, // 1, + Mechanic = 0, // 2, + + Security = 0, // 3, + SecurityAlt = 1, // 23, + + EntertainerPanda = 0, // 4, + EntertainerTiger = 0, // 5, + EntertainerElephant = 0, // 6, + EntertainerRoman = 0, // 7, + EntertainerGorilla = 0, // 8, + EntertainerSnowman = 0, // 9, + EntertainerKnight = 0, // 10, + EntertainerAstronaut = 0, // 11, + EntertainerBandit = 0, // 12, + EntertainerSheriff = 0, // 13, + EntertainerPirate = 0, // 14, + + // Guest variations (compensate for Staff/Entertainer slots) + IceCream = 15 - 14, + Chips = 16 - 14, + Burger = 17 - 14, + Drink = 18 - 14, + Balloon = 19 - 14, + Candyfloss = 20 - 14, + Umbrella = 21 - 14, + Pizza = 22 - 14, + + // Guest variations (compensate for SecurityAlt as well) + Popcorn = 24 - 15, + ArmsCrossed = 25 - 15, + HeadDown = 26 - 15, + Nauseous = 27 - 15, + VeryNauseous = 28 - 15, + RequireToilet = 29 - 15, + Hat = 30 - 15, + HotDog = 31 - 15, + Tentacle = 32 - 15, + ToffeeApple = 33 - 15, + Doughnut = 34 - 15, + Coffee = 35 - 15, + Chicken = 36 - 15, + Lemonade = 37 - 15, + Watching = 38 - 15, + Pretzel = 39 - 15, + Sunglasses = 40 - 15, + SuJongkwa = 41 - 15, + Juice = 42 - 15, + FunnelCake = 43 - 15, + Noodles = 44 - 15, + Sausage = 45 - 15, + Soup = 46 - 15, + Sandwich = 47 - 15, + Count = 48 - 15, Invalid = 255 }; diff --git a/src/openrct2/object/PeepAnimationsObject.cpp b/src/openrct2/object/PeepAnimationsObject.cpp index a89baea185..a851a75a1b 100644 --- a/src/openrct2/object/PeepAnimationsObject.cpp +++ b/src/openrct2/object/PeepAnimationsObject.cpp @@ -15,6 +15,7 @@ #include "../core/Guard.hpp" #include "../core/Json.hpp" #include "../peep/PeepAnimations.h" +#include "../rct12/RCT12.h" using namespace OpenRCT2; @@ -94,7 +95,7 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root) if (groupJson.contains("legacyPosition")) { auto position = Json::GetNumber(groupJson["legacyPosition"]); - if (position <= EnumValue(PeepAnimationGroup::Count)) + if (position <= EnumValue(RCT12PeepAnimationGroup::Count)) { group.legacyPosition = static_cast(position); } @@ -104,6 +105,16 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root) } } +ImageIndex PeepAnimationsObject::GetInlineImageId() const +{ + return _imageOffsetId; +} + +const PeepAnimation& PeepAnimationsObject::GetPeepAnimation(PeepAnimationGroup animGroup, PeepAnimationType animType) const +{ + return _animationGroups[EnumValue(animGroup)][animType]; +} + size_t PeepAnimationsObject::GetNumAnimationGroups() const { return _animationGroups.size(); diff --git a/src/openrct2/object/PeepAnimationsObject.h b/src/openrct2/object/PeepAnimationsObject.h index ee5a1f6e5c..de26d74e4e 100644 --- a/src/openrct2/object/PeepAnimationsObject.h +++ b/src/openrct2/object/PeepAnimationsObject.h @@ -29,6 +29,10 @@ public: void Load() override; void Unload() override; + ImageIndex GetInlineImageId() const; + const OpenRCT2::PeepAnimation& GetPeepAnimation( + PeepAnimationGroup animGroup, PeepAnimationType animType = PeepAnimationType::Walking) const; + size_t GetNumAnimationGroups() const; PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 9075894a48..dfc2592cdf 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1323,7 +1323,8 @@ namespace OpenRCT2::RCT1 { // TODO dst->AnimationObjectIndex = OBJECT_ENTRY_INDEX_NULL; - dst->AnimationGroup = RCT1::GetPeepAnimationGroup(src->AnimationGroup); + auto rct12AnimGroup = RCT1::GetPeepAnimationGroup(src->AnimationGroup); + dst->AnimationGroup = static_cast<::PeepAnimationGroup>(rct12AnimGroup); dst->Action = static_cast(src->Action); dst->SpecialSprite = src->SpecialSprite; diff --git a/src/openrct2/rct1/Tables.cpp b/src/openrct2/rct1/Tables.cpp index d375fdc230..534b32cea0 100644 --- a/src/openrct2/rct1/Tables.cpp +++ b/src/openrct2/rct1/Tables.cpp @@ -67,50 +67,50 @@ namespace OpenRCT2::RCT1 return map[colour]; } - ::PeepAnimationGroup GetPeepAnimationGroup(RCT1::PeepAnimationGroup rct1AnimationGroup) + RCT12PeepAnimationGroup GetPeepAnimationGroup(PeepAnimationGroup rct1AnimationGroup) { - static constexpr ::PeepAnimationGroup map[] = + static constexpr RCT12PeepAnimationGroup map[] = { - ::PeepAnimationGroup::Normal, // 0x00 - ::PeepAnimationGroup::Handyman, // 0x01 - ::PeepAnimationGroup::Mechanic, // 0x02 - ::PeepAnimationGroup::Security, // 0x03 - ::PeepAnimationGroup::EntertainerPanda, // 0x04 - ::PeepAnimationGroup::EntertainerTiger, // 0x05 - ::PeepAnimationGroup::EntertainerElephant, // 0x06 - ::PeepAnimationGroup::EntertainerRoman, // 0x07 - ::PeepAnimationGroup::EntertainerGorilla, // 0x08 - ::PeepAnimationGroup::EntertainerSnowman, // 0x09 - ::PeepAnimationGroup::EntertainerKnight, // 0x0A - ::PeepAnimationGroup::EntertainerAstronaut, // 0x0B - ::PeepAnimationGroup::IceCream, // 0x0C - ::PeepAnimationGroup::Chips, // 0x0D - ::PeepAnimationGroup::Burger, // 0x0E - ::PeepAnimationGroup::Drink, // 0x0F - ::PeepAnimationGroup::Balloon, // 0x10 - ::PeepAnimationGroup::Candyfloss, // 0x11 - ::PeepAnimationGroup::Umbrella, // 0x12 - ::PeepAnimationGroup::Pizza, // 0x13 - ::PeepAnimationGroup::SecurityAlt, // 0x14 - ::PeepAnimationGroup::Popcorn, // 0x15 - ::PeepAnimationGroup::ArmsCrossed, // 0x16 - ::PeepAnimationGroup::HeadDown, // 0x17 - ::PeepAnimationGroup::Nauseous, // 0x18 - ::PeepAnimationGroup::VeryNauseous, // 0x19 - ::PeepAnimationGroup::RequireToilet, // 0x1A - ::PeepAnimationGroup::Hat, // 0x1B - ::PeepAnimationGroup::HotDog, // 0x1C - ::PeepAnimationGroup::Tentacle, // 0x1D - ::PeepAnimationGroup::ToffeeApple, // 0x1E - ::PeepAnimationGroup::Doughnut, // 0x1F - ::PeepAnimationGroup::Coffee, // 0x20 - ::PeepAnimationGroup::Chicken, // 0x21 - ::PeepAnimationGroup::Lemonade, // 0x22 + RCT12PeepAnimationGroup::Normal, // 0x00 + RCT12PeepAnimationGroup::Handyman, // 0x01 + RCT12PeepAnimationGroup::Mechanic, // 0x02 + RCT12PeepAnimationGroup::Security, // 0x03 + RCT12PeepAnimationGroup::EntertainerPanda, // 0x04 + RCT12PeepAnimationGroup::EntertainerTiger, // 0x05 + RCT12PeepAnimationGroup::EntertainerElephant, // 0x06 + RCT12PeepAnimationGroup::EntertainerRoman, // 0x07 + RCT12PeepAnimationGroup::EntertainerGorilla, // 0x08 + RCT12PeepAnimationGroup::EntertainerSnowman, // 0x09 + RCT12PeepAnimationGroup::EntertainerKnight, // 0x0A + RCT12PeepAnimationGroup::EntertainerAstronaut, // 0x0B + RCT12PeepAnimationGroup::IceCream, // 0x0C + RCT12PeepAnimationGroup::Chips, // 0x0D + RCT12PeepAnimationGroup::Burger, // 0x0E + RCT12PeepAnimationGroup::Drink, // 0x0F + RCT12PeepAnimationGroup::Balloon, // 0x10 + RCT12PeepAnimationGroup::Candyfloss, // 0x11 + RCT12PeepAnimationGroup::Umbrella, // 0x12 + RCT12PeepAnimationGroup::Pizza, // 0x13 + RCT12PeepAnimationGroup::SecurityAlt, // 0x14 + RCT12PeepAnimationGroup::Popcorn, // 0x15 + RCT12PeepAnimationGroup::ArmsCrossed, // 0x16 + RCT12PeepAnimationGroup::HeadDown, // 0x17 + RCT12PeepAnimationGroup::Nauseous, // 0x18 + RCT12PeepAnimationGroup::VeryNauseous, // 0x19 + RCT12PeepAnimationGroup::RequireToilet, // 0x1A + RCT12PeepAnimationGroup::Hat, // 0x1B + RCT12PeepAnimationGroup::HotDog, // 0x1C + RCT12PeepAnimationGroup::Tentacle, // 0x1D + RCT12PeepAnimationGroup::ToffeeApple, // 0x1E + RCT12PeepAnimationGroup::Doughnut, // 0x1F + RCT12PeepAnimationGroup::Coffee, // 0x20 + RCT12PeepAnimationGroup::Chicken, // 0x21 + RCT12PeepAnimationGroup::Lemonade, // 0x22 }; if (EnumValue(rct1AnimationGroup) >= std::size(map)) { LOG_WARNING("Unsupported RCT1 peep sprite type: %d.", EnumValue(rct1AnimationGroup)); - return ::PeepAnimationGroup::Normal; + return RCT12PeepAnimationGroup::Normal; } return map[EnumValue(rct1AnimationGroup)]; } diff --git a/src/openrct2/rct1/Tables.h b/src/openrct2/rct1/Tables.h index 64fe3b4d37..1b7b424104 100644 --- a/src/openrct2/rct1/Tables.h +++ b/src/openrct2/rct1/Tables.h @@ -25,7 +25,7 @@ namespace OpenRCT2::RCT1 enum class PeepAnimationGroup : uint8_t; colour_t GetColour(colour_t colour); - ::PeepAnimationGroup GetPeepAnimationGroup(PeepAnimationGroup rct1AnimationGroup); + RCT12PeepAnimationGroup GetPeepAnimationGroup(PeepAnimationGroup rct1AnimationGroup); uint8_t GetRideType(RideType rideType, VehicleType vehicleType); VehicleColourSchemeCopyDescriptor GetColourSchemeCopyDescriptor(VehicleType vehicleType); diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index e8c2d3bacc..d322f32983 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -985,6 +985,61 @@ enum class RCT12PeepType : uint8_t Invalid = 0xFF }; +enum class RCT12PeepAnimationGroup : uint8_t +{ + Normal = 0, + Handyman = 1, + Mechanic = 2, + Security = 3, + EntertainerPanda = 4, + EntertainerTiger = 5, + EntertainerElephant = 6, + EntertainerRoman = 7, + EntertainerGorilla = 8, + EntertainerSnowman = 9, + EntertainerKnight = 10, + EntertainerAstronaut = 11, + EntertainerBandit = 12, + EntertainerSheriff = 13, + EntertainerPirate = 14, + IceCream = 15, + Chips = 16, + Burger = 17, + Drink = 18, + Balloon = 19, + Candyfloss = 20, + Umbrella = 21, + Pizza = 22, + SecurityAlt = 23, + Popcorn = 24, + ArmsCrossed = 25, + HeadDown = 26, + Nauseous = 27, + VeryNauseous = 28, + RequireToilet = 29, + Hat = 30, + HotDog = 31, + Tentacle = 32, + ToffeeApple = 33, + Doughnut = 34, + Coffee = 35, + Chicken = 36, + Lemonade = 37, + Watching = 38, + Pretzel = 39, + Sunglasses = 40, + SuJongkwa = 41, + Juice = 42, + FunnelCake = 43, + Noodles = 44, + Sausage = 45, + Soup = 46, + Sandwich = 47, + Count = 48, + + Invalid = 255 +}; + struct RCT12EntityBase { RCT12EntityIdentifier EntityIdentifier; // 0x00